/** Performs a ranged attack according to the AI's rangedAttackID. */ private void doRangedAttack() { // 43% chance to "miss" int chanceToMiss = entityHost.isPotionActive(Potion.moveSpeed) ? 10 : 43; if (worldObj.rand.nextInt(100) < chanceToMiss) { AMCore.instance.proxy.particleManager.BoltFromPointToPoint( worldObj, entityHost.posX, entityHost.posY + entityHost.getEyeHeight(), entityHost.posZ, attackTarget.posX + worldObj.rand.nextFloat() - 0.5f, attackTarget.posY + attackTarget.getEyeHeight() + worldObj.rand.nextFloat() - 0.5f, attackTarget.posZ + worldObj.rand.nextFloat() - 0.5f, 2, -1); } else { AMCore.instance.proxy.particleManager.BoltFromEntityToEntity( worldObj, entityHost, entityHost, attackTarget, this.damage, 2, -1); float manaDrained = this.manaDrainedPerCasterLevel * ExtendedProperties.For(attackTarget).getMagicLevel(); ExtendedProperties.For(attackTarget) .setCurrentMana(ExtendedProperties.For(attackTarget).getCurrentMana() - (manaDrained)); ExtendedProperties.For(attackTarget).forceSync(); attackTarget.attackEntityFrom( DamageSource.causeIndirectMagicDamage(entityHost, entityHost), this.damage); if (manaDrained > 100) { entityHost.heal(1); if (entityHost.worldObj.difficultySetting == EnumDifficulty.HARD) { attackTarget.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 40, 1, true)); entityHost.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 40, 3, true)); } } } }