diff --git a/src/main/java/com/l2jserver/datapack/ai/individual/NecromancerOfTheValley.java b/src/main/java/com/l2jserver/datapack/ai/individual/NecromancerOfTheValley.java index db1652838ff6a2283d23105404427e56574f3ed0..6c3df39fd8ff69dab438a0804cceea9e827a881a 100644 --- a/src/main/java/com/l2jserver/datapack/ai/individual/NecromancerOfTheValley.java +++ b/src/main/java/com/l2jserver/datapack/ai/individual/NecromancerOfTheValley.java @@ -1,5 +1,5 @@ /* - * Copyright © 2004-2020 L2J DataPack + * Copyright © 2004-2021 L2J DataPack * * This file is part of L2J DataPack. * @@ -19,6 +19,7 @@ package com.l2jserver.datapack.ai.individual; import com.l2jserver.datapack.ai.npc.AbstractNpcAI; +import com.l2jserver.gameserver.model.actor.L2Character; import com.l2jserver.gameserver.model.actor.L2Npc; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; import com.l2jserver.gameserver.model.holders.SkillHolder; @@ -27,44 +28,62 @@ import com.l2jserver.gameserver.model.skills.Skill; /** * Necromancer of the Valley AI. * @author Adry_85 - * @since 2.6.0.0 + * @author Maneco2 + * @since 2.6.2.0 */ -public class NecromancerOfTheValley extends AbstractNpcAI { +public class NecromancerOfTheValley extends AbstractNpcAI +{ // NPCs private static final int EXPLODING_ORC_GHOST = 22818; private static final int WRATHFUL_ORC_GHOST = 22819; private static final int NECROMANCER_OF_THE_VALLEY = 22858; // Skill private static final SkillHolder SELF_DESTRUCTION = new SkillHolder(6850); + // Variable + private static final String MID_HP_FLAG = "MID_HP_FLAG"; // Misc private static final double HP_PERCENTAGE = 0.60; - public NecromancerOfTheValley() { + public NecromancerOfTheValley() + { super(NecromancerOfTheValley.class.getSimpleName(), "ai/individual"); addAttackId(NECROMANCER_OF_THE_VALLEY); + addSpawnId(EXPLODING_ORC_GHOST); addSpellFinishedId(EXPLODING_ORC_GHOST); } @Override - public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon) { - if ((npc.getCurrentHp() < (npc.getMaxHp() * HP_PERCENTAGE))) { - if (getRandom(10) < 1) { - if (getRandomBoolean()) { - final L2Npc explodingOrcGhost = addSpawn(EXPLODING_ORC_GHOST, npc.getX(), npc.getY(), npc.getZ(), 0, false, 0, false); - addAttackDesire(explodingOrcGhost, attacker, 10000); - addSkillCastDesire(npc, attacker, SELF_DESTRUCTION, 999999999L); - } else { - final L2Npc wrathfulOrcGhost = addSpawn(WRATHFUL_ORC_GHOST, npc.getX(), npc.getY(), npc.getZ(), 0, false, 0, false); - addAttackDesire(wrathfulOrcGhost, attacker, 10000); - } + public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon) + { + if (npc.getCurrentHp() < (npc.getMaxHp() * HP_PERCENTAGE)) + { + if ((getRandom(100) < 10) && !npc.getVariables().getBoolean(MID_HP_FLAG, false)) + { + npc.getVariables().set(MID_HP_FLAG, true); + addAttackDesire(addSpawn((getRandomBoolean() ? EXPLODING_ORC_GHOST : WRATHFUL_ORC_GHOST), npc, true), attacker); } } return super.onAttack(npc, attacker, damage, isSummon); } @Override - public String onSpellFinished(L2Npc npc, L2PcInstance player, Skill skill) { - if ((skill == SELF_DESTRUCTION.getSkill()) && (npc != null) && !npc.isDead()) { + public String onSpawn(L2Npc npc) + { + for (L2Character obj : npc.getKnownList().getKnownCharactersInRadius(200)) + { + if (obj.isPlayer() && !obj.isDead()) + { + addSkillCastDesire(npc, obj, SELF_DESTRUCTION, 1000000L); + } + } + return super.onSpawn(npc); + } + + @Override + public String onSpellFinished(L2Npc npc, L2PcInstance player, Skill skill) + { + if ((skill == SELF_DESTRUCTION.getSkill()) && (npc != null) && !npc.isDead()) + { npc.doDie(player); } return super.onSpellFinished(npc, player, skill);