Advertisement
horato

Raidbosses

Jun 18th, 2011
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.11 KB | None | 0 0
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package ai.group_template;
  16.  
  17. import java.util.List;
  18.  
  19. import javolution.util.FastList;
  20.  
  21. import com.l2jserver.gameserver.Announcements;
  22. import com.l2jserver.gameserver.ThreadPoolManager;
  23. import com.l2jserver.gameserver.datatables.SkillTable;
  24. import com.l2jserver.gameserver.model.L2Object;
  25. import com.l2jserver.gameserver.model.L2Object.InstanceType;
  26. import com.l2jserver.gameserver.model.L2Skill;
  27. import com.l2jserver.gameserver.model.actor.L2Character;
  28. import com.l2jserver.gameserver.model.actor.L2Npc;
  29. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  30. import com.l2jserver.util.Rnd;
  31.  
  32. public class customRaidbossFire extends L2AttackableAIScript
  33. {
  34. private enum ClassType
  35. {
  36. Mage, Tank, Archer, Summoner, Healer, Enchanter, Fighter, Dagger, Kamael
  37. }
  38.  
  39. private static L2PcInstance _healer = null;
  40. private static L2PcInstance _mage = null;
  41. private static int _healersCount = 0;
  42. private static List<L2Character> _playersInRadius;
  43. private static final int[] _RBs = { 1000000, 1000001, 1000002, 1000003, 1000004 };
  44. private static final int[][] _spawns = { { -59516, 178947, -4814 }, { -61428, 181346, -4814 }, { -60755, 179650, -4814 }, { -59503, 183817, -4814 }, { -62385, 184108, -4820 }, { -62396, 183535, -4820 }, { -58521, 183911, -4814 }, { -59511, 186596, -4814 }, { -55855, 181347, -4814 }, { -57013, 186110, -4968 }, { -57372, 186112, -4968 }, { -57390, 186413, -4968 }, { -57013, 186452, -4968 } };
  45. private static L2Npc _currentSpawn;
  46. private static int _currentSpawnLoc = 0;
  47. private static long _lastAttackTime = 0;
  48.  
  49. public customRaidbossFire(int questId, String name, String descr)
  50. {
  51. super(questId, name, descr);
  52. for (int id : _RBs)
  53. {
  54. addAttackId(id);
  55. addSpawnId(id);
  56. addKillId(id);
  57. addAggroRangeEnterId(id);
  58. addSkillSeeId(id);
  59. }
  60. _playersInRadius = new FastList<L2Character>();
  61. _currentSpawnLoc = Rnd.get(0, _spawns.length - 1);
  62.  
  63. _currentSpawn = addSpawn(_RBs[Rnd.get(_RBs.length)], _spawns[_currentSpawnLoc][0], _spawns[_currentSpawnLoc][1], _spawns[_currentSpawnLoc][2], 0, false, 0);
  64. System.out.println(_spawns[_currentSpawnLoc][0] + "," + _spawns[_currentSpawnLoc][1] + "," + _spawns[_currentSpawnLoc][2]);
  65. ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Runnable()
  66. {
  67. public void run()
  68. {
  69. if ((System.currentTimeMillis() - _lastAttackTime) > 600000)
  70. {
  71. respawn();
  72. }
  73. }
  74. }, 10, 1000);
  75.  
  76. }
  77.  
  78. @Override
  79. public String onAttack(L2Npc npc, L2PcInstance player, int damage, boolean isPet)
  80. {
  81. _lastAttackTime = System.currentTimeMillis();
  82.  
  83. for (L2Character smth : npc.getKnownList().getKnownCharacters())
  84. if (smth.getInstanceType() == InstanceType.L2PcInstance)
  85. {
  86. _playersInRadius.add(smth);
  87. }
  88.  
  89. //Healers check
  90. if (_playersInRadius.contains(_healer))
  91. {
  92. npc.setTarget(_healer);
  93. if (Rnd.get(1, 100) <= 50)
  94. npc.doCast(SkillTable.getInstance().getInfo(1064, 130)); //Silence +30 chance
  95. if (_healer.isDead())
  96. _healer = null;
  97. }
  98. else
  99. {
  100. _healer = null;
  101. }
  102.  
  103. //Mages check
  104. if (_playersInRadius.contains(_healer) && _healersCount <= 0)
  105. {
  106. npc.setTarget(_mage);
  107. if (Rnd.get(1, 100) <= 50)
  108. npc.doCast(SkillTable.getInstance().getInfo(1064, 130)); //Silence +30 chance
  109. if (_mage.isDead())
  110. _mage = null;
  111. }
  112. else
  113. {
  114. _mage = null;
  115. }
  116.  
  117. return super.onAttack(npc, player, damage, isPet);
  118. }
  119.  
  120. @Override
  121. public String onKill(L2Npc npc, L2PcInstance killer, boolean isPet)
  122. {
  123. Announcements.getInstance().announceToAll("Raidboss " + npc.getName() + " was killed by " + killer.getName());
  124. _lastAttackTime = (System.currentTimeMillis() + 3600000);
  125. return super.onKill(npc, killer, isPet);
  126. }
  127.  
  128. @Override
  129. public String onSpawn(L2Npc npc)
  130. {
  131. _lastAttackTime = System.currentTimeMillis();
  132. Announcements.getInstance().announceToAll("Raidboss in Fire Temple was spawned.");
  133. return super.onSpawn(npc);
  134. }
  135.  
  136. @Override
  137. public String onSkillSee(L2Npc npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet)
  138. {
  139. //if (!((L2RaidBossInstance) npc).getAggroList().containsKey(caster))
  140. // return "";
  141. _playersInRadius.addAll(npc.getKnownList().getKnownCharactersInRadius(1100));
  142. switch (skill.getId())
  143. {
  144. case 1553: //Chain heal
  145. case 1219: //Greater Group Heal
  146. case 1218: //Greater Battle Heal
  147. case 1217: //Greater Heal
  148. if (_healer == null)
  149. _healer = caster;
  150. break;
  151. case 1239: //Hurricane
  152. case 1230: //Prominence
  153. case 1148: //Death spike
  154. if (_mage == null)
  155. _mage = caster;
  156. break;
  157. }
  158.  
  159. return super.onSkillSee(npc, caster, skill, targets, isPet);
  160. }
  161.  
  162. @Override
  163. public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isPet)
  164. {
  165. if (npc.getNpcId() >= 1000000 && npc.getNpcId() <= 1000004)
  166. {
  167. if (getClassType(player) == ClassType.Healer)
  168. _healersCount++;
  169. }
  170. return super.onAggroRangeEnter(npc, player, isPet);
  171. }
  172.  
  173. private void respawn()
  174. {
  175. _currentSpawn.deleteMe();
  176. _currentSpawnLoc = Rnd.get(0, _spawns.length - 1);
  177. _currentSpawn = addSpawn(_RBs[Rnd.get(_RBs.length)], _spawns[_currentSpawnLoc][0], _spawns[_currentSpawnLoc][1], _spawns[_currentSpawnLoc][2], 0, false, 0);
  178. System.out.println(_spawns[_currentSpawnLoc][0] + "," + _spawns[_currentSpawnLoc][1] + "," + _spawns[_currentSpawnLoc][2]);
  179. }
  180.  
  181. private ClassType getClassType(L2PcInstance player)
  182. {
  183. switch (player.getClassId())
  184. {
  185. case duelist:
  186. return ClassType.Fighter;
  187. case dreadnought:
  188. return ClassType.Fighter;
  189. case phoenixKnight:
  190. return ClassType.Tank;
  191. case hellKnight:
  192. return ClassType.Tank;
  193. case adventurer:
  194. return ClassType.Dagger;
  195. case sagittarius:
  196. return ClassType.Archer;
  197. case archmage:
  198. return ClassType.Mage;
  199. case soultaker:
  200. return ClassType.Mage;
  201. case arcanaLord:
  202. return ClassType.Summoner;
  203. case cardinal:
  204. return ClassType.Healer;
  205. case hierophant:
  206. return ClassType.Healer;
  207. case evaTemplar:
  208. return ClassType.Tank;
  209. case swordMuse:
  210. return ClassType.Enchanter;
  211. case windRider:
  212. return ClassType.Dagger;
  213. case moonlightSentinel:
  214. return ClassType.Archer;
  215. case mysticMuse:
  216. return ClassType.Mage;
  217. case elementalMaster:
  218. return ClassType.Summoner;
  219. case evaSaint:
  220. return ClassType.Healer;
  221. case shillienTemplar:
  222. return ClassType.Tank;
  223. case spectralDancer:
  224. return ClassType.Enchanter;
  225. case ghostHunter:
  226. return ClassType.Dagger;
  227. case ghostSentinel:
  228. return ClassType.Archer;
  229. case stormScreamer:
  230. return ClassType.Mage;
  231. case spectralMaster:
  232. return ClassType.Summoner;
  233. case shillienSaint:
  234. return ClassType.Healer;
  235. case titan:
  236. return ClassType.Fighter;
  237. case grandKhauatari:
  238. return ClassType.Fighter;
  239. case overlord:
  240. return ClassType.Healer;
  241. case doomcryer:
  242. return ClassType.Enchanter;
  243. case fortuneSeeker:
  244. return ClassType.Fighter;
  245. case maestro:
  246. return ClassType.Fighter;
  247. case doombringer:
  248. return ClassType.Fighter;
  249. case maleSoulhound:
  250. return ClassType.Kamael;
  251. case femaleSoulhound:
  252. return ClassType.Kamael;
  253. case arbalester:
  254. return ClassType.Kamael;
  255. case trickster:
  256. return ClassType.Kamael;
  257. case judicator:
  258. return ClassType.Mage;
  259.  
  260. }
  261.  
  262. return null;
  263. }
  264.  
  265. public static void main(String[] args)
  266. {
  267. new customRaidbossFire(-1, "customRaidbossFire", "ai");
  268. }
  269. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement