mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-19 02:39:05 +00:00
Check KO
This commit is contained in:
1 parent
0c48bac2ef
commit
83a07d8b1d
4 files changed
+20
-6
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import kamkeel.addon.DBCAddon;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -111,7 +112,7 @@ public class CombatHandler {
|
||||
if(target == null || !target.isEntityAlive())
|
||||
return false;
|
||||
|
||||
if(target instanceof EntityPlayer && ((EntityPlayer)target).capabilities.disableDamage)
|
||||
if(target instanceof EntityPlayer && (((EntityPlayer)target).capabilities.disableDamage || DBCAddon.instance.isKO(npc, (EntityPlayer) target)))
|
||||
return false;
|
||||
|
||||
return npc.isInRange(target, npc.stats.aggroRange);
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import kamkeel.addon.DBCAddon;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.pathfinding.PathEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
@@ -25,7 +27,7 @@ public class EntityAIAttackTarget extends EntityAIBase
|
||||
private PathEntity entityPathEntity;
|
||||
private int field_75445_i;
|
||||
private boolean navOverride = false;
|
||||
|
||||
|
||||
public EntityAIAttackTarget(EntityNPCInterface par1EntityLiving){
|
||||
this.attackTick = 0;
|
||||
this.npc = par1EntityLiving;
|
||||
@@ -48,10 +50,10 @@ public class EntityAIAttackTarget extends EntityAIBase
|
||||
else if (this.npc.inventory.getProjectile() != null && this.npc.ai.useRangeMelee == 0){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
double var2 = this.npc.getDistanceSq(entitylivingbase.posX, entitylivingbase.boundingBox.minY, entitylivingbase.posZ);
|
||||
double var3 = this.npc.ai.distanceToMelee * this.npc.ai.distanceToMelee;
|
||||
|
||||
|
||||
if (this.npc.ai.useRangeMelee == 1 && var2 > var3){
|
||||
return false;
|
||||
}
|
||||
@@ -70,14 +72,18 @@ public class EntityAIAttackTarget extends EntityAIBase
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
this.entityTarget = this.npc.getAttackTarget();
|
||||
|
||||
|
||||
if(entityTarget == null || !entityTarget.isEntityAlive())
|
||||
return false;
|
||||
|
||||
if(entityTarget instanceof EntityPlayer && DBCAddon.instance.isKO(npc, (EntityPlayer) this.entityTarget))
|
||||
return false;
|
||||
|
||||
if(npc.getDistanceToEntity(entityTarget) > npc.stats.aggroRange)
|
||||
return false;
|
||||
if (this.npc.ai.useRangeMelee == 1 && npc.getDistanceSqToEntity(entityTarget) > (this.npc.ai.distanceToMelee * this.npc.ai.distanceToMelee))
|
||||
return false;
|
||||
|
||||
|
||||
return this.npc.isWithinHomeDistance(MathHelper.floor_double(entityTarget.posX), MathHelper.floor_double(entityTarget.posY), MathHelper.floor_double(entityTarget.posZ));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package noppes.npcs.ai.selector;
|
||||
|
||||
import kamkeel.addon.DBCAddon;
|
||||
import net.minecraft.command.IEntitySelector;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -63,6 +64,10 @@ public class NPCAttackSelector implements IEntitySelector
|
||||
if(npc.faction.isAggressiveToPlayer((EntityPlayer) entity)){
|
||||
if(PixelmonHelper.Enabled && npc.advanced.job == EnumJobType.Spawner)
|
||||
return PixelmonHelper.canBattle((EntityPlayerMP)entity, npc);
|
||||
|
||||
if(DBCAddon.instance.isKO(npc, (EntityPlayer) entity))
|
||||
return false;
|
||||
|
||||
return !((EntityPlayerMP)entity).capabilities.disableDamage;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -627,6 +627,8 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
public void setAttackTarget(EntityLivingBase entity){
|
||||
if(entity instanceof EntityPlayer && ((EntityPlayer)entity).capabilities.disableDamage || entity != null && entity == getOwner())
|
||||
return;
|
||||
if(entity instanceof EntityPlayer && DBCAddon.instance.isKO(this, (EntityPlayer) entity))
|
||||
return;
|
||||
if (!isRemote()) {
|
||||
if (getAttackTarget() != entity && entity != null) {
|
||||
NpcEvent.TargetEvent event = new NpcEvent.TargetEvent(wrappedNPC,entity);
|
||||
|
||||
Reference in new issue
Block a user