Created
April 5, 2013 17:57
-
-
Save St3eT/5321294 to your computer and use it in GitHub Desktop.
Rewrite AI NecromancerValley (Diff version)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Eclipse Workspace Patch 1.0 | |
#P L2J_DataPack_BETA | |
Index: dist/game/data/scripts/ai/individual/NecromancerValley.java | |
=================================================================== | |
--- dist/game/data/scripts/ai/individual/NecromancerValley.java (revision 9545) | |
+++ dist/game/data/scripts/ai/individual/NecromancerValley.java (working copy) | |
@@ -25,7 +25,7 @@ | |
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.util.Rnd; | |
+import com.l2jserver.gameserver.model.holders.SkillHolder; | |
/** | |
* Necromancer of the Valley AI. | |
@@ -33,59 +33,84 @@ | |
*/ | |
public class NecromancerValley extends AbstractNpcAI | |
{ | |
- private static final int NECROMANCER = 22858; | |
- private static final int EXPLODING_ORC_GHOST = 22818; | |
- private static final int WRATHFUL_ORC_GHOST = 22819; | |
+ // NPC | |
+ private static final int NECROMANCER = 22858; // Necromancer of the Valley | |
+ private static final int EXPLODING_ORC_GHOST = 22818; // Exploding Orc Ghost | |
+ private static final int WRATHFUL_ORC_GHOST = 22819; // Wrathful Orc Ghost | |
+ // Skill | |
+ private static SkillHolder SELF_DESTRUCTION = new SkillHolder(6850, 1); // Self-destruction | |
+ | |
private NecromancerValley(String name, String descr) | |
{ | |
super(name, descr); | |
addAttackId(NECROMANCER); | |
addKillId(NECROMANCER); | |
+ addSpawnId(EXPLODING_ORC_GHOST); | |
} | |
@Override | |
- public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon) | |
+ public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) | |
{ | |
- if (Rnd.get(100) < 20) | |
+ if (event.equalsIgnoreCase("SelfDestruction") && !npc.isDead()) | |
{ | |
- L2Character attacker = isSummon ? killer.getSummon() : killer; | |
- L2Attackable Orc = (L2Attackable) addSpawn(EXPLODING_ORC_GHOST, npc.getX(), npc.getY(), npc.getZ() + 10, npc.getHeading(), false, 0, true); | |
- Orc.setRunning(); | |
- Orc.addDamageHate(attacker, 0, 600); | |
- Orc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, attacker); | |
- L2Attackable Ork2 = (L2Attackable) addSpawn(WRATHFUL_ORC_GHOST, npc.getX(), npc.getY(), npc.getZ() + 20, npc.getHeading(), false, 0, false); | |
- Ork2.setRunning(); | |
- Ork2.addDamageHate(attacker, 0, 600); | |
- Ork2.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, attacker); | |
- | |
+ npc.abortAttack(); | |
+ npc.disableCoreAI(true); | |
+ npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE); | |
+ npc.doCast(SELF_DESTRUCTION.getSkill()); | |
} | |
- | |
+ return super.onAdvEvent(event, npc, player); | |
+ } | |
+ | |
+ @Override | |
+ public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon) | |
+ { | |
+ spawnGhost(npc, killer, isSummon, 20); | |
return super.onKill(npc, killer, isSummon); | |
} | |
@Override | |
public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon) | |
{ | |
- if (Rnd.get(100) < 1) | |
+ spawnGhost(npc, attacker, isSummon, 1); | |
+ return super.onAttack(npc, attacker, damage, isSummon); | |
+ } | |
+ | |
+ @Override | |
+ public String onSpawn(L2Npc npc) | |
+ { | |
+ startQuestTimer("SelfDestruction", 3000, npc, null); | |
+ return super.onSpawn(npc); | |
+ } | |
+ | |
+ private void spawnGhost(L2Npc npc, L2PcInstance player, boolean isSummon, int chance) | |
+ { | |
+ if ((npc.getScriptValue() < 2) && (getRandom(100) < chance)) | |
{ | |
- L2Character player = isSummon ? attacker.getSummon() : attacker; | |
- L2Attackable Orc = (L2Attackable) addSpawn(EXPLODING_ORC_GHOST, npc.getX(), npc.getY(), npc.getZ() + 10, npc.getHeading(), false, 0, true); | |
- Orc.setRunning(); | |
- Orc.addDamageHate(player, 0, 600); | |
- Orc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player); | |
- L2Attackable Ork2 = (L2Attackable) addSpawn(WRATHFUL_ORC_GHOST, npc.getX(), npc.getY(), npc.getZ() + 20, npc.getHeading(), false, 0, false); | |
- Ork2.setRunning(); | |
- Ork2.addDamageHate(player, 0, 600); | |
- Ork2.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player); | |
- | |
+ int val = npc.getScriptValue(); | |
+ final L2Character attacker = isSummon ? player.getSummon() : player; | |
+ final L2Attackable Ghost1 = (L2Attackable) addSpawn(getRandom(EXPLODING_ORC_GHOST, WRATHFUL_ORC_GHOST), npc.getX(), npc.getY(), npc.getZ() + 10, npc.getHeading(), false, 0, true); | |
+ attackPlayer(Ghost1, attacker); | |
+ val++; | |
+ if ((val < 2) && (getRandom(100) < 10)) | |
+ { | |
+ final L2Attackable Ghost2 = (L2Attackable) addSpawn(getRandom(EXPLODING_ORC_GHOST, WRATHFUL_ORC_GHOST), npc.getX(), npc.getY(), npc.getZ() + 20, npc.getHeading(), false, 0, false); | |
+ attackPlayer(Ghost2, attacker); | |
+ val++; | |
+ } | |
+ npc.setScriptValue(val); | |
} | |
- | |
- return super.onAttack(npc, attacker, damage, isSummon); | |
} | |
+ private void attackPlayer(L2Attackable npc, L2Character player) | |
+ { | |
+ npc.setRunning(); | |
+ npc.addDamageHate(player, 0, 600); | |
+ npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player); | |
+ } | |
+ | |
public static void main(String[] args) | |
{ | |
new NecromancerValley(NecromancerValley.class.getSimpleName(), "ai"); | |
} | |
-} | |
+} | |
\ No newline at end of file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment