SinEater.java 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*
  2. * Copyright (C) 2004-2015 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 ai.individual;
  20. import ai.npc.AbstractNpcAI;
  21. import com.l2jserver.gameserver.model.actor.L2Npc;
  22. import com.l2jserver.gameserver.model.actor.L2Summon;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.events.EventType;
  25. import com.l2jserver.gameserver.model.events.ListenerRegisterType;
  26. import com.l2jserver.gameserver.model.events.annotations.Id;
  27. import com.l2jserver.gameserver.model.events.annotations.RegisterEvent;
  28. import com.l2jserver.gameserver.model.events.annotations.RegisterType;
  29. import com.l2jserver.gameserver.model.events.impl.character.OnCreatureAttacked;
  30. import com.l2jserver.gameserver.model.events.impl.character.OnCreatureKill;
  31. import com.l2jserver.gameserver.network.NpcStringId;
  32. import com.l2jserver.gameserver.network.clientpackets.Say2;
  33. import com.l2jserver.gameserver.network.serverpackets.NpcSay;
  34. /**
  35. * Sin Eater AI.
  36. * @author St3eT.
  37. */
  38. public final class SinEater extends AbstractNpcAI
  39. {
  40. // NPCs
  41. private static final int SIN_EATER = 12564;
  42. private SinEater()
  43. {
  44. super(SinEater.class.getSimpleName(), "ai/individual");
  45. addSummonSpawnId(SIN_EATER);
  46. addSummonTalkId(SIN_EATER);
  47. }
  48. @Override
  49. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  50. {
  51. if (event.equals("TALK") && (player != null) && (player.getSummon() != null))
  52. {
  53. if (getRandom(100) < 30)
  54. {
  55. final int random = getRandom(100);
  56. final L2Summon summon = player.getSummon();
  57. if (random < 20)
  58. {
  59. broadcastSummonSay(summon, NpcStringId.YAWWWWN_ITS_SO_BORING_HERE_WE_SHOULD_GO_AND_FIND_SOME_ACTION);
  60. }
  61. else if (random < 40)
  62. {
  63. broadcastSummonSay(summon, NpcStringId.HEY_IF_YOU_CONTINUE_TO_WASTE_TIME_YOU_WILL_NEVER_FINISH_YOUR_PENANCE);
  64. }
  65. else if (random < 60)
  66. {
  67. broadcastSummonSay(summon, NpcStringId.I_KNOW_YOU_DONT_LIKE_ME_THE_FEELING_IS_MUTUAL);
  68. }
  69. else if (random < 80)
  70. {
  71. broadcastSummonSay(summon, NpcStringId.I_NEED_A_DRINK);
  72. }
  73. else
  74. {
  75. broadcastSummonSay(summon, NpcStringId.OH_THIS_IS_DRAGGING_ON_TOO_LONG_AT_THIS_RATE_I_WONT_MAKE_IT_HOME_BEFORE_THE_SEVEN_SEALS_ARE_BROKEN);
  76. }
  77. }
  78. startQuestTimer("TALK", 60000, null, player);
  79. }
  80. return super.onAdvEvent(event, npc, player);
  81. }
  82. @RegisterEvent(EventType.ON_CREATURE_KILL)
  83. @RegisterType(ListenerRegisterType.NPC)
  84. @Id(SIN_EATER)
  85. public void onCreatureKill(OnCreatureKill event)
  86. {
  87. final int random = getRandom(100);
  88. final L2Summon summon = (L2Summon) event.getTarget();
  89. if (random < 30)
  90. {
  91. broadcastSummonSay(summon, NpcStringId.OH_THIS_IS_JUST_GREAT_WHAT_ARE_YOU_GOING_TO_DO_NOW);
  92. }
  93. else if (random < 70)
  94. {
  95. broadcastSummonSay(summon, NpcStringId.YOU_INCONSIDERATE_MORON_CANT_YOU_EVEN_TAKE_CARE_OF_LITTLE_OLD_ME);
  96. }
  97. else
  98. {
  99. broadcastSummonSay(summon, NpcStringId.OH_NO_THE_MAN_WHO_EATS_ONES_SINS_HAS_DIED_PENITENCE_IS_FURTHER_AWAY);
  100. }
  101. }
  102. @RegisterEvent(EventType.ON_CREATURE_ATTACKED)
  103. @RegisterType(ListenerRegisterType.NPC)
  104. @Id(SIN_EATER)
  105. public void onCreatureAttacked(OnCreatureAttacked event)
  106. {
  107. if (getRandom(100) < 30)
  108. {
  109. final int random = getRandom(100);
  110. final L2Summon summon = (L2Summon) event.getTarget();
  111. if (random < 35)
  112. {
  113. broadcastSummonSay(summon, NpcStringId.OH_THAT_SMARTS);
  114. }
  115. else if (random < 70)
  116. {
  117. broadcastSummonSay(summon, NpcStringId.HEY_MASTER_PAY_ATTENTION_IM_DYING_OVER_HERE);
  118. }
  119. else
  120. {
  121. broadcastSummonSay(summon, NpcStringId.WHAT_HAVE_I_DONE_TO_DESERVE_THIS);
  122. }
  123. }
  124. }
  125. @Override
  126. public void onSummonSpawn(L2Summon summon)
  127. {
  128. broadcastSummonSay(summon, getRandomBoolean() ? NpcStringId.HEY_IT_SEEMS_LIKE_YOU_NEED_MY_HELP_DOESNT_IT : NpcStringId.ALMOST_GOT_IT_OUCH_STOP_DAMN_THESE_BLOODY_MANACLES);
  129. startQuestTimer("TALK", 60000, null, summon.getOwner());
  130. }
  131. @Override
  132. public void onSummonTalk(L2Summon summon)
  133. {
  134. if (getRandom(100) < 10)
  135. {
  136. final int random = getRandom(100);
  137. if (random < 25)
  138. {
  139. broadcastSummonSay(summon, NpcStringId.USING_A_SPECIAL_SKILL_HERE_COULD_TRIGGER_A_BLOODBATH);
  140. }
  141. else if (random < 50)
  142. {
  143. broadcastSummonSay(summon, NpcStringId.HEY_WHAT_DO_YOU_EXPECT_OF_ME);
  144. }
  145. else if (random < 75)
  146. {
  147. broadcastSummonSay(summon, NpcStringId.UGGGGGH_PUSH_ITS_NOT_COMING_OUT);
  148. }
  149. else
  150. {
  151. broadcastSummonSay(summon, NpcStringId.AH_I_MISSED_THE_MARK);
  152. }
  153. }
  154. }
  155. private void broadcastSummonSay(L2Summon summon, NpcStringId npcstringId)
  156. {
  157. summon.broadcastPacket(new NpcSay(summon.getObjectId(), Say2.NPC_ALL, summon.getId(), npcstringId));
  158. }
  159. public static void main(String[] args)
  160. {
  161. new SinEater();
  162. }
  163. }