Valkyrie Queen fight improved

This commit is contained in:
Kino 2017-01-21 12:07:36 -05:00
parent c9a68f0574
commit e47e045482
2 changed files with 135 additions and 22 deletions

View file

@ -0,0 +1,116 @@
package com.legacy.aether.server.entities.ai;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.pathfinding.Path;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class EntityAIAttackContinuously extends EntityAIBase
{
World worldObj;
protected EntityCreature attacker;
protected int attackTick;
double speedTowardsTarget;
boolean longMemory;
Path entityPathEntity;
private double targetX;
private double targetY;
private double targetZ;
protected final int attackInterval = 20;
public EntityAIAttackContinuously(EntityCreature creature, double speedIn, boolean useLongMemory)
{
this.attacker = creature;
this.worldObj = creature.worldObj;
this.speedTowardsTarget = speedIn;
this.longMemory = useLongMemory;
this.setMutexBits(3);
}
@Override
public boolean shouldExecute()
{
EntityLivingBase entitylivingbase = this.attacker.getAttackTarget();
if (entitylivingbase == null)
{
return false;
}
else if (!entitylivingbase.isEntityAlive())
{
return false;
}
else
{
this.entityPathEntity = this.attacker.getNavigator().getPathToEntityLiving(entitylivingbase);
return this.entityPathEntity != null;
}
}
@Override
public boolean continueExecuting()
{
EntityLivingBase entitylivingbase = this.attacker.getAttackTarget();
return entitylivingbase == null ? false : (!entitylivingbase.isEntityAlive() ? false : (!this.longMemory ? !this.attacker.getNavigator().noPath() : (!this.attacker.isWithinHomeDistanceFromPosition(new BlockPos(entitylivingbase)) ? false : !(entitylivingbase instanceof EntityPlayer) || !((EntityPlayer)entitylivingbase).isSpectator() && !((EntityPlayer)entitylivingbase).isCreative())));
}
@Override
public void startExecuting()
{
this.attacker.getNavigator().setPath(this.entityPathEntity, this.speedTowardsTarget);
}
@Override
public void resetTask()
{
EntityLivingBase entitylivingbase = this.attacker.getAttackTarget();
if (entitylivingbase instanceof EntityPlayer && (((EntityPlayer)entitylivingbase).isSpectator() || ((EntityPlayer)entitylivingbase).isCreative()))
{
this.attacker.setAttackTarget((EntityLivingBase)null);
}
this.attacker.getNavigator().clearPathEntity();
}
@Override
public void updateTask()
{
EntityLivingBase entitylivingbase = this.attacker.getAttackTarget();
this.attacker.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F);
double d0 = this.attacker.getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ);
if ((this.longMemory || this.attacker.getEntitySenses().canSee(entitylivingbase)) && (this.targetX == 0.0D && this.targetY == 0.0D && this.targetZ == 0.0D || entitylivingbase.getDistanceSq(this.targetX, this.targetY, this.targetZ) >= 1.0D || this.attacker.getRNG().nextFloat() < 0.05F))
{
this.targetX = entitylivingbase.posX;
this.targetY = entitylivingbase.getEntityBoundingBox().minY;
this.targetZ = entitylivingbase.posZ;
}
this.attackTick = Math.max(this.attackTick - 1, 0);
this.checkAndPerformAttack(entitylivingbase, d0);
}
protected void checkAndPerformAttack(EntityLivingBase p_190102_1_, double p_190102_2_)
{
double d0 = this.getAttackReachSqr(p_190102_1_);
if (p_190102_2_ <= d0 && this.attackTick <= 0)
{
this.attackTick = 20;
this.attacker.swingArm(EnumHand.MAIN_HAND);
this.attacker.attackEntityAsMob(p_190102_1_);
}
}
protected double getAttackReachSqr(EntityLivingBase attackTarget)
{
return (double)(this.attacker.width * 2.0F * this.attacker.width * 2.0F + attackTarget.width);
}
}

View file

@ -5,7 +5,7 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
@ -31,6 +31,7 @@ import com.legacy.aether.server.Aether;
import com.legacy.aether.server.blocks.BlocksAether;
import com.legacy.aether.server.blocks.dungeon.BlockDungeonBase;
import com.legacy.aether.server.blocks.util.EnumStoneType;
import com.legacy.aether.server.entities.ai.EntityAIAttackContinuously;
import com.legacy.aether.server.entities.ai.valkyrie_queen.ValkyrieQueenAIWander;
import com.legacy.aether.server.entities.projectile.crystals.EntityThunderBall;
import com.legacy.aether.server.entities.util.AetherNameGen;
@ -45,7 +46,7 @@ public class EntityValkyrieQueen extends EntityMob
public static final DataParameter<Boolean> VALKYRIE_READY = EntityDataManager.<Boolean>createKey(EntityValkyrieQueen.class, DataSerializers.BOOLEAN);
private int attackTime;
private EntityAIAttackContinuously enhancedCombat = new EntityAIAttackContinuously(this, 0.65D, false);
public int angerLevel;
@ -82,7 +83,8 @@ public class EntityValkyrieQueen extends EntityMob
public void registerEntityAI()
{
this.targetTasks.addTask(0, new EntityAIAttackMelee(this, 0.65D, true));
this.targetTasks.addTask(0, this.enhancedCombat);
this.tasks.addTask(0, new EntityAISwimming(this));
this.tasks.addTask(2, new ValkyrieQueenAIWander(this, 0.5D));
}
@ -249,8 +251,6 @@ public class EntityValkyrieQueen extends EntityMob
{
super.onEntityUpdate();
--this.attackTime;
if (!this.isBossReady())
{
this.motionY *= .5f;
@ -473,24 +473,20 @@ public class EntityValkyrieQueen extends EntityMob
{
boolean flag = false;
if (this.attackTime <= 0 && entity.getEntityBoundingBox().maxY > getEntityBoundingBox().minY && entity.getEntityBoundingBox().minY < getEntityBoundingBox().maxY)
{
this.attackTime = 20;
swingArm();
flag = entity.attackEntityFrom(DamageSource.causeMobDamage(this), 7);
if (entity != null && this.getAttackTarget() != null && entity == getAttackTarget() && entity instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer)entity;
this.swingArm();
flag = entity.attackEntityFrom(DamageSource.causeMobDamage(this), 7);
if (player.getHealth() <= 0 || player.isDead)
{
this.setAttackTarget(null);
this.angerLevel = this.chatTime = 0;
chatItUp(player, "As expected of a human.");
unlockDoor();
}
}
if (entity != null && this.getAttackTarget() != null && entity == this.getAttackTarget() && entity instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer)entity;
if (player.getHealth() <= 0 || player.isDead)
{
this.setAttackTarget(null);
this.angerLevel = this.chatTime = 0;
this.chatItUp(player, "As expected of a human.");
this.unlockDoor();
}
}
return flag;
@ -560,6 +556,7 @@ public class EntityValkyrieQueen extends EntityMob
else
{
this.spawnExplosionParticle();
this.enhancedCombat.resetTask();
this.setPosition((double) newX + 0.5D, (double) newY + 0.5D, (double) newZ + 0.5D);
this.isJumping = false;