Chimeras.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * Copyright (C) 2004-2014 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J DataPack is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package hellbound.AI;
  20. import ai.npc.AbstractNpcAI;
  21. import com.l2jserver.gameserver.ThreadPoolManager;
  22. import com.l2jserver.gameserver.model.L2Object;
  23. import com.l2jserver.gameserver.model.Location;
  24. import com.l2jserver.gameserver.model.actor.L2Npc;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. import com.l2jserver.gameserver.model.skills.Skill;
  27. import hellbound.HellboundEngine;
  28. /**
  29. * Chimeras AI.
  30. * @author DS
  31. */
  32. public final class Chimeras extends AbstractNpcAI
  33. {
  34. // NPCs
  35. private static final int[] NPCS =
  36. {
  37. 22349, // Chimera of Earth
  38. 22350, // Chimera of Darkness
  39. 22351, // Chimera of Wind
  40. 22352, // Chimera of Fire
  41. };
  42. private static final int CELTUS = 22353;
  43. // Locations
  44. private static final Location[] LOCATIONS =
  45. {
  46. new Location(3678, 233418, -3319),
  47. new Location(2038, 237125, -3363),
  48. new Location(7222, 240617, -2033),
  49. new Location(9969, 235570, -1993)
  50. };
  51. // Skills
  52. private static final int BOTTLE = 2359; // Magic Bottle
  53. // Items
  54. private static final int DIM_LIFE_FORCE = 9680;
  55. private static final int LIFE_FORCE = 9681;
  56. private static final int CONTAINED_LIFE_FORCE = 9682;
  57. public Chimeras()
  58. {
  59. super(Chimeras.class.getSimpleName(), "hellbound/AI");
  60. addSkillSeeId(NPCS);
  61. addSpawnId(CELTUS);
  62. addSkillSeeId(CELTUS);
  63. }
  64. @Override
  65. public final String onSpawn(L2Npc npc)
  66. {
  67. if (HellboundEngine.getInstance().getLevel() == 7) // Have random spawn points only in 7 lvl
  68. {
  69. final Location loc = LOCATIONS[getRandom(LOCATIONS.length)];
  70. if (!npc.isInsideRadius(loc, 200, false, false))
  71. {
  72. npc.getSpawn().setLocation(loc);
  73. ThreadPoolManager.getInstance().scheduleGeneral(new Teleport(npc, loc), 100);
  74. }
  75. }
  76. return super.onSpawn(npc);
  77. }
  78. @Override
  79. public final String onSkillSee(L2Npc npc, L2PcInstance caster, Skill skill, L2Object[] targets, boolean isSummon)
  80. {
  81. if ((skill.getId() == BOTTLE) && !npc.isDead())
  82. {
  83. if ((targets.length > 0) && (targets[0] == npc))
  84. {
  85. if (npc.getCurrentHp() < (npc.getMaxHp() * 0.1))
  86. {
  87. if (HellboundEngine.getInstance().getLevel() == 7)
  88. {
  89. HellboundEngine.getInstance().updateTrust(3, true);
  90. }
  91. npc.setIsDead(true);
  92. if (npc.getId() == CELTUS)
  93. {
  94. npc.dropItem(caster, CONTAINED_LIFE_FORCE, 1);
  95. }
  96. else
  97. {
  98. if (getRandom(100) < 80)
  99. {
  100. npc.dropItem(caster, DIM_LIFE_FORCE, 1);
  101. }
  102. else if (getRandom(100) < 80)
  103. {
  104. npc.dropItem(caster, LIFE_FORCE, 1);
  105. }
  106. }
  107. npc.onDecay();
  108. }
  109. }
  110. }
  111. return super.onSkillSee(npc, caster, skill, targets, isSummon);
  112. }
  113. private static class Teleport implements Runnable
  114. {
  115. private final L2Npc _npc;
  116. private final Location _loc;
  117. public Teleport(L2Npc npc, Location loc)
  118. {
  119. _npc = npc;
  120. _loc = loc;
  121. }
  122. @Override
  123. public void run()
  124. {
  125. _npc.teleToLocation(_loc, false);
  126. }
  127. }
  128. }