use of am2.bosses.EntityLightningGuardian in project ArsMagica2 by Mithion.
the class EntityAILightningBolt method doStrike.
private void doStrike() {
EntityLightningGuardian guardian = getEntity();
if (guardian.getAttackTarget() != null && guardian.getEntitySenses().canSee(guardian.getAttackTarget())) {
if (guardian.getDistanceSqToEntity(guardian.getAttackTarget()) > 400) {
guardian.getNavigator().tryMoveToEntityLiving(guardian.getAttackTarget(), 0.5f);
return;
}
guardian.getNavigator().clearPathEntity();
if (guardian.getRNG().nextDouble() > 0.2f) {
AMCore.proxy.particleManager.BoltFromEntityToEntity(guardian.worldObj, guardian, guardian, guardian.getAttackTarget(), 0);
guardian.getAttackTarget().attackEntityFrom(DamageSources.causeEntityLightningDamage(guardian), 3);
if (guardian.getAttackTarget() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) guardian.getAttackTarget();
if (player.capabilities.isFlying)
player.capabilities.isFlying = false;
if (player.isRiding())
player.dismountEntity(player.ridingEntity);
}
} else {
AMCore.proxy.particleManager.BoltFromEntityToPoint(guardian.worldObj, guardian, guardian.getAttackTarget().posX - 0.5 + guardian.getRNG().nextDouble(), guardian.getAttackTarget().posY - 0.5 + guardian.getRNG().nextDouble() + guardian.getAttackTarget().getEyeHeight(), guardian.getAttackTarget().posZ - 0.5 + guardian.getRNG().nextDouble());
}
}
}
use of am2.bosses.EntityLightningGuardian in project ArsMagica2 by Mithion.
the class EntityAIStatic method doStrike.
private void doStrike() {
EntityLightningGuardian guardian = getEntity();
List<EntityLivingBase> entities = guardian.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, guardian.boundingBox.expand(8, 3, 8));
for (EntityLivingBase e : entities) if (e != guardian)
e.attackEntityFrom(DamageSources.causeEntityLightningDamage(guardian), 8);
}
use of am2.bosses.EntityLightningGuardian in project ArsMagica2 by Mithion.
the class EntityAILightningRod method updateTask.
@Override
public void updateTask() {
EntityLightningGuardian guardian = getEntity();
float factor = ((guardian.getHealth() / guardian.getMaxHealth()) + 0.1f);
cooldownTicks = (int) (500 * factor);
int ticks = guardian.getTicksInCurrentAction();
if (ticks <= 25) {
target = guardian.getAttackTarget();
if (target != null)
startPos = new AMVector3(target);
} else {
if (target == null || target.isDead || startPos == null) {
resetTask();
return;
}
guardian.getLookHelper().setLookPositionWithEntity(target, 30, 30);
if (ticks > 85 && ticks <= 150) {
if (!guardian.worldObj.isRemote && ticks % 20 == 0)
guardian.worldObj.playSoundAtEntity(guardian, "arsmagica2:mob.lightningguardian.lightning_rod_1", 1.0f, guardian.getRNG().nextFloat() * 0.5f + 0.5f);
}
if (ticks > 25 && ticks <= 85) {
forcePosition(target, startPos.x, startPos.y + ((ticks - 25) * 0.1), startPos.z);
ExtendedProperties.For(target).setDisableGravity(true);
if (!guardian.worldObj.isRemote && ticks == 30)
guardian.worldObj.playSoundAtEntity(guardian, "arsmagica2:mob.lightningguardian.lightning_rod_start", 1.0f, guardian.getRNG().nextFloat() * 0.5f + 0.5f);
} else if (ticks > 85 && ticks <= 105) {
forcePosition(target, startPos.x, startPos.y + 6, startPos.z);
} else if (ticks > 105 && ticks <= 150) {
forcePosition(target, startPos.x, startPos.y + 6, startPos.z);
if (ticks > 115) {
hasAttacked = true;
target.attackEntityFrom(DamageSources.causeEntityLightningDamage(guardian), 3);
}
AMCore.proxy.particleManager.BoltFromEntityToEntity(guardian.worldObj, guardian, guardian, target, 0);
if (!guardian.worldObj.isRemote && ticks % 20 == 0)
guardian.worldObj.playSoundAtEntity(guardian, "arsmagica2:mob.lightningguardian.idle", 1.0f, guardian.getRNG().nextFloat() * 0.5f + 0.5f);
} else if (ticks > 150 && ticks <= 158) {
if (!hasThrown) {
target.addVelocity(0, -3, 0);
target.fallDistance = 5;
ExtendedProperties.For(target).setDisableGravity(false);
hasThrown = true;
}
} else if (ticks > 165) {
if (!hasBolted) {
hasBolted = true;
EntityLightningBolt bolt = new EntityLightningBolt(guardian.worldObj, target.posX, target.posY, target.posZ);
bolt.setPosition(target.posX, target.posY, target.posZ);
guardian.worldObj.addWeatherEffect(bolt);
}
}
}
}
Aggregations