initial commit
This commit is contained in:
parent
3c9ee26b06
commit
22186c33b9
1458 changed files with 282792 additions and 0 deletions
73
java/src/game/ai/EntityAIHurtByTarget.java
Executable file
73
java/src/game/ai/EntityAIHurtByTarget.java
Executable file
|
@ -0,0 +1,73 @@
|
|||
package game.ai;
|
||||
|
||||
import game.entity.types.EntityLiving;
|
||||
import game.world.BoundingBox;
|
||||
|
||||
public class EntityAIHurtByTarget extends EntityAITarget
|
||||
{
|
||||
private boolean entityCallsForHelp;
|
||||
|
||||
/** Store the previous revengeTimer value */
|
||||
private int revengeTimerOld;
|
||||
private final Class[] targetClasses;
|
||||
|
||||
public EntityAIHurtByTarget(EntityLiving creatureIn, boolean entityCallsForHelpIn, Class... targetClassesIn)
|
||||
{
|
||||
super(creatureIn, false);
|
||||
this.entityCallsForHelp = entityCallsForHelpIn;
|
||||
this.targetClasses = targetClassesIn;
|
||||
this.setMutexBits(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
int i = this.taskOwner.getAttackedTime();
|
||||
return i != this.revengeTimerOld && this.isSuitableTarget(this.taskOwner.getAttackedBy());
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
this.taskOwner.setAttackTarget(this.taskOwner.getAttackedBy());
|
||||
this.revengeTimerOld = this.taskOwner.getAttackedTime();
|
||||
|
||||
if (this.entityCallsForHelp)
|
||||
{
|
||||
double d0 = this.getTargetDistance();
|
||||
|
||||
for (EntityLiving entitycreature : this.taskOwner.worldObj.getEntitiesWithinAABB(this.taskOwner.getClass(), (new BoundingBox(this.taskOwner.posX, this.taskOwner.posY, this.taskOwner.posZ, this.taskOwner.posX + 1.0D, this.taskOwner.posY + 1.0D, this.taskOwner.posZ + 1.0D)).expand(d0, 10.0D, d0)))
|
||||
{
|
||||
if (this.taskOwner != entitycreature && /* !(entitycreature.isPlayer()) && */ entitycreature.getAttackTarget() == null) // && !entitycreature.isOnSameTeam(this.taskOwner.getAITarget()))
|
||||
{
|
||||
boolean flag = false;
|
||||
|
||||
for (Class oclass : this.targetClasses)
|
||||
{
|
||||
if (entitycreature.getClass() == oclass)
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
this.setEntityAttackTarget(entitycreature, this.taskOwner.getAttackedBy());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.startExecuting();
|
||||
}
|
||||
|
||||
protected void setEntityAttackTarget(EntityLiving creatureIn, EntityLiving entityLivingBaseIn)
|
||||
{
|
||||
creatureIn.setAttackTarget(entityLivingBaseIn);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue