Го пример про гаргет таски АИMajestic написал(а):А в когда пихаешь в таски АИ атаки ставь EntityLivingBase.class как таргет.Код:public boolean canAttackClass(Class entity){ return entity != EntityPlayer.class; }
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Однако ни скелетов, ни хрюшек он не трогаетDragon2488 написал(а):Да так.