Guest User

Untitled

a guest
Apr 8th, 2019
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.59 KB | None | 0 0
  1. package net.sf.l2j.gameserver.scripting.scripts.ai.group;
  2.  
  3. import net.sf.l2j.gameserver.datatables.SkillTable;
  4. import net.sf.l2j.gameserver.geoengine.GeoEngine;
  5. import net.sf.l2j.gameserver.model.WorldObject;
  6. import net.sf.l2j.gameserver.model.L2Skill;
  7. import net.sf.l2j.gameserver.model.actor.Attackable;
  8. import net.sf.l2j.gameserver.model.actor.Npc;
  9. import net.sf.l2j.gameserver.model.actor.instance.Player;
  10. import net.sf.l2j.gameserver.model.base.Sex;
  11. import net.sf.l2j.gameserver.scripting.EventType;
  12. import net.sf.l2j.gameserver.scripting.scripts.ai.L2AttackableAIScript;
  13. import net.sf.l2j.gameserver.templates.skills.L2SkillType;
  14.  
  15. /**
  16. * This script holds MoS monsters behavior. If they see you with an equipped weapon, they will speak and attack you.
  17. */
  18. public class Monastery extends L2AttackableAIScript
  19. {
  20. private static final int[] BROTHERS_SEEKERS_MONKS =
  21. {
  22. 22124,
  23. 22125,
  24. 22126,
  25. 22127,
  26. 22129
  27. };
  28.  
  29. private static final int[] GUARDIANS_BEHOLDERS =
  30. {
  31. 22134,
  32. 22135
  33. };
  34.  
  35. public Monastery()
  36. {
  37. super("ai/group");
  38. }
  39.  
  40. @Override
  41. protected void registerNpcs()
  42. {
  43. addEventIds(BROTHERS_SEEKERS_MONKS, EventType.ON_AGGRO, EventType.ON_SPAWN, EventType.ON_SPELL_FINISHED);
  44. addEventIds(GUARDIANS_BEHOLDERS, EventType.ON_SKILL_SEE);
  45. }
  46.  
  47. @Override
  48. public String onAggro(Npc npc, Player player, boolean isPet)
  49. {
  50. if (!npc.isInCombat())
  51. {
  52. if (player.getActiveWeaponInstance() != null)
  53. {
  54. npc.setTarget(player);
  55. npc.broadcastNpcSay(((player.getAppearance().getSex() == Sex.FEMALE) ? "Sister " : "Brother ") + player.getName() + ", move your weapon away!");
  56.  
  57. switch (npc.getNpcId())
  58. {
  59. case 22124:
  60. case 22126:
  61. npc.doCast(SkillTable.getInstance().getInfo(4589, 8));
  62. break;
  63.  
  64. default:
  65. attack(((Attackable) npc), player);
  66. break;
  67. }
  68. }
  69. else if (((Attackable) npc).getMostHated() == null)
  70. return null;
  71. }
  72. return super.onAggro(npc, player, isPet);
  73. }
  74.  
  75. @Override
  76. public String onSkillSee(Npc npc, Player caster, L2Skill skill, WorldObject[] targets, boolean isPet)
  77. {
  78. if (skill.getSkillType() == L2SkillType.AGGDAMAGE && targets.length != 0)
  79. {
  80. for (WorldObject obj : targets)
  81. {
  82. if (obj.equals(npc))
  83. {
  84. npc.broadcastNpcSay(((caster.getAppearance().getSex() == Sex.FEMALE) ? "Sister " : "Brother ") + caster.getName() + ", move your weapon away!");
  85. attack(((Attackable) npc), caster);
  86. break;
  87. }
  88. }
  89. }
  90. return super.onSkillSee(npc, caster, skill, targets, isPet);
  91. }
  92.  
  93. @Override
  94. public String onSpawn(Npc npc)
  95. {
  96. for (Player target : npc.getKnownTypeInRadius(Player.class, npc.getTemplate().getAggroRange()))
  97. {
  98. if (!target.isDead() && GeoEngine.getInstance().canSeeTarget(npc, target))
  99. {
  100. if (target.getActiveWeaponInstance() != null && !npc.isInCombat() && npc.getTarget() == null)
  101. {
  102. npc.setTarget(target);
  103. npc.broadcastNpcSay(((target.getAppearance().getSex() == Sex.FEMALE) ? "Sister " : "Brother ") + target.getName() + ", move your weapon away!");
  104.  
  105. switch (npc.getNpcId())
  106. {
  107. case 22124:
  108. case 22126:
  109. case 22127:
  110. npc.doCast(SkillTable.getInstance().getInfo(4589, 8));
  111. break;
  112.  
  113. default:
  114. attack(((Attackable) npc), target);
  115. break;
  116. }
  117. }
  118. }
  119. }
  120. return super.onSpawn(npc);
  121. }
  122.  
  123. @Override
  124. public String onSpellFinished(Npc npc, Player player, L2Skill skill)
  125. {
  126. if (skill.getId() == 4589)
  127. attack(((Attackable) npc), player);
  128.  
  129. return super.onSpellFinished(npc, player, skill);
  130. }
  131. }
Advertisement
Add Comment
Please, Sign In to add comment