[1.6.4] Добрый моб

200
0
Как заставить моба атаковать всех кроме игрока?
 
771
5
Код:
public boolean canAttackClass(Class entity){
    return entity != EntityPlayer.class;
}
А в когда пихаешь в таски АИ атаки ставь EntityLivingBase.class как таргет.
 
200
0
Не, NPC можно оставить жизнь
[merge_posts_bbcode]Добавлено: 03.08.2014 00:28:51[/merge_posts_bbcode]

Majestic написал(а):
Код:
public boolean canAttackClass(Class entity){
    return entity != EntityPlayer.class;
}
А в когда пихаешь в таски АИ атаки ставь EntityLivingBase.class как таргет.
Го пример про гаргет таски АИ
 
771
5
Вот такое в конструкторе:

Код:
targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, true));

Не забудь и своего моба в проверку добавить(canAttackClass), а то они будут друг с другом драться =)
 
200
0
Чот хз 
Код:
public class EntityThompsonMob extends EntityMob //Еще тут может быть EntityAnimal для пассивного моба, еще есть IAnimal и EntityCreature, но о них позже.
{

    public EntityThompsonMob(World par1World)
    {
        super(par1World);
        this.setSize(0.9F, 1.5F); //Размерчики
        this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 4.0D));
        this.tasks.addTask(1, new EntityAISwimming(this)); //Плавает
        this.tasks.addTask(9, new EntityAIWander(this, 0.4D));
        this.tasks.addTask(8, new EntityAILookIdle(this));
        this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityMob.class, 0, true));
        this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, true));
        this.experienceValue = 5;
    }
    
    public boolean canAttackClass(Class entity){
        return entity != EntityPlayer.class || entity != EntityThompsonMob.class;
    }
    
    @Override
    protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
        //this.getEntityAttribute(SharedMonsterAttributes.followRange).setAttribute(40.0D);
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(200.0D); //Макс хп у моба.
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.20000000298023224D);//Скорость передвижения
        this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setAttribute(30.0D);
   }

    @Override
    protected String getLivingSound()
    {
        return "mob.zombie.say";//Это обычные звуки, их в yourmod/sound/MobLiving.
    }

    @Override
    protected String getHurtSound()
    {
        return "mob.zombie.hurt";//Это звуки урона, их туда же.
    }

    @Override
    protected String getDeathSound()
    {
        return "mob.zombie.death";//Типо звуки смерти.
    }

    @Override
    protected float getSoundVolume() //Громкость звуков
    {
        return 0.4F;
    }
    
    
    @Override
    protected void dropFewItems(boolean par1, int par2)
    {
        //this.dropItem(SpiderMod.symbiote.itemID, 4);
    }
}
 
200
0
Не атакует, тупо стоит и всё.
 
2,955
12
Вообще второй параметр EntityAIAttackTask'e это расстояние
И в EntityAIwander второй параметр тоже расстояние
[merge_posts_bbcode]Добавлено: 03.08.2014 01:56:08[/merge_posts_bbcode]

А чтоб он атаковал при прикосновении нужно добавить таск EntityAIAttackOnCollide
 
200
0
Dragon2488 написал(а):
Вообще второй параметр EntityAIAttackTask'e это расстояние
И в EntityAIwander второй параметр тоже расстояние
[merge_posts_bbcode]Добавлено: 03.08.2014 01:56:08[/merge_posts_bbcode]

А чтоб он атаковал при прикосновении нужно добавить таск EntityAIAttackOnCollide
Код:
    public EntityThompsonMob(World par1World)
    {
        super(par1World);
        this.setSize(0.9F, 1.5F); //Размерчики
        this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityLiving.class, 0.4D, true));
        this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityMob.class, 0.4D, true));
        this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 4.0D));
        this.tasks.addTask(1, new EntityAISwimming(this)); //Плавает
        this.tasks.addTask(9, new EntityAIWander(this, 2.4D));
        this.tasks.addTask(8, new EntityAILookIdle(this));
        this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F));
        this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityMob.class, 8.0F));
        this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
        this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityMob.class, 0, true));
        this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, true));
        this.experienceValue = 5;
    }
    
    public boolean canAttackClass(Class entity){
        return entity != EntityPlayer.class || entity != EntityThompsonMob.class;
    }
    
    @Override
    protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.followRange).setAttribute(40.0D);
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(200.0D); //Макс хп у моба.
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.20000000298023224D);//Скорость передвижения
        this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setAttribute(30.0D);
   }

    @Override
    protected String getLivingSound()
    {
        return "mob.zombie.say";//Это обычные звуки, их в yourmod/sound/MobLiving.
    }

    @Override
    protected String getHurtSound()
    {
        return "mob.zombie.hurt";//Это звуки урона, их туда же.
    }

    @Override
    protected String getDeathSound()
    {
        return "mob.zombie.death";//Типо звуки смерти.
    }

    @Override
    protected float getSoundVolume() //Громкость звуков
    {
        return 0.4F;
    }
    
    @Override
    protected void dropFewItems(boolean par1, int par2)
    {
        //this.dropItem(SpiderMod.symbiote.itemID, 4);
    }
}
Так:?
 
771
5
Убрать this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityMob.class, 0, true));
В canAttackClass не ||, а &&.
 
2,955
12
У тебя всего по два. Он и так буде атаковать мобов, так как класс мобов extends EntityLiving И я попутал. там где EntityAIWander второй параметр скорость, а не расстояние.
 
200
0
Код:
public class EntityThompsonMob extends EntityMob //Еще тут может быть EntityAnimal для пассивного моба, еще есть IAnimal и EntityCreature, но о них позже.
{

    public EntityThompsonMob(World par1World)
    {
        super(par1World);
        this.setSize(0.9F, 1.5F); //Размерчики
        this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityLiving.class, 0.4D, true));
        this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityMob.class, 0.4D, true));
        this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 4.0D));
        this.tasks.addTask(1, new EntityAISwimming(this)); //Плавает
        this.tasks.addTask(9, new EntityAIWander(this, 2.4D));
        this.tasks.addTask(8, new EntityAILookIdle(this));
        this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F));
        this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityMob.class, 8.0F));
        this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
        this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, true));
        this.experienceValue = 5;
    }
    
    public boolean canAttackClass(Class entity){
        return entity != EntityPlayer.class && entity != EntityThompsonMob.class;
    }
    
    @Override
    protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.followRange).setAttribute(40.0D);
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(200.0D); //Макс хп у моба.
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.20000000298023224D);//Скорость передвижения
        this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setAttribute(30.0D);
   }

    @Override
    protected String getLivingSound()
    {
        return "mob.zombie.say";//Это обычные звуки, их в yourmod/sound/MobLiving.
    }

    @Override
    protected String getHurtSound()
    {
        return "mob.zombie.hurt";//Это звуки урона, их туда же.
    }

    @Override
    protected String getDeathSound()
    {
        return "mob.zombie.death";//Типо звуки смерти.
    }

    @Override
    protected float getSoundVolume() //Громкость звуков
    {
        return 0.4F;
    }
    
    @Override
    protected void dropFewItems(boolean par1, int par2)
    {
        //this.dropItem(SpiderMod.symbiote.itemID, 4);
    }
}
Так:?
 
200
0
Так:?
Код:
public class EntityThompsonMob extends EntityMob //Еще тут может быть EntityAnimal для пассивного моба, еще есть IAnimal и EntityCreature, но о них позже.
{

    public EntityThompsonMob(World par1World)
    {
        super(par1World);
        this.setSize(0.9F, 1.5F); //Размерчики
        this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityLiving.class, 0.4D, true));
        this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 4.0D));
        this.tasks.addTask(1, new EntityAISwimming(this)); //Плавает
        this.tasks.addTask(9, new EntityAIWander(this, 2.4D));
        this.tasks.addTask(8, new EntityAILookIdle(this));
        this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F));
        this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
        this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, true));
        this.experienceValue = 5;
    }
    
    public boolean canAttackClass(Class entity){
        return entity != EntityPlayer.class && entity != EntityThompsonMob.class;
    }
    
    @Override
    protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.followRange).setAttribute(40.0D);
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(200.0D); //Макс хп у моба.
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.20000000298023224D);//Скорость передвижения
        this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setAttribute(30.0D);
   }

    @Override
    protected String getLivingSound()
    {
        return "mob.zombie.say";//Это обычные звуки, их в yourmod/sound/MobLiving.
    }

    @Override
    protected String getHurtSound()
    {
        return "mob.zombie.hurt";//Это звуки урона, их туда же.
    }

    @Override
    protected String getDeathSound()
    {
        return "mob.zombie.death";//Типо звуки смерти.
    }

    @Override
    protected float getSoundVolume() //Громкость звуков
    {
        return 0.4F;
    }
    
    @Override
    protected void dropFewItems(boolean par1, int par2)
    {
        //this.dropItem(SpiderMod.symbiote.itemID, 4);
    }
}
 
771
5
Айдишник поменяй targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, true));
1 измени на 2.
 
200
0
Всё равно не атакует
 
Сверху