FrightenedRagnaOrc.java 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * Copyright (C) 2004-2013 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.ai.CtrlIntention;
  22. import com.l2jserver.gameserver.model.L2CharPosition;
  23. import com.l2jserver.gameserver.model.actor.L2Attackable;
  24. import com.l2jserver.gameserver.model.actor.L2Npc;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. import com.l2jserver.gameserver.model.holders.SkillHolder;
  27. import com.l2jserver.gameserver.model.itemcontainer.PcInventory;
  28. import com.l2jserver.gameserver.network.NpcStringId;
  29. import com.l2jserver.gameserver.network.clientpackets.Say2;
  30. import com.l2jserver.util.Rnd;
  31. /**
  32. * Frightened Ragna Orc AI.
  33. * @author Gladicek, malyelfik
  34. */
  35. public final class FrightenedRagnaOrc extends AbstractNpcAI
  36. {
  37. // NPC ID
  38. private static final int MOB_ID = 18807;
  39. // Chances
  40. private static final int ADENA = 10000;
  41. private static final int CHANCE = 1000;
  42. private static final int ADENA2 = 1000000;
  43. private static final int CHANCE2 = 10;
  44. // Skill
  45. private static final SkillHolder SKILL = new SkillHolder(6234, 1);
  46. private FrightenedRagnaOrc(String name, String descr)
  47. {
  48. super(name, descr);
  49. addAttackId(MOB_ID);
  50. addKillId(MOB_ID);
  51. }
  52. @Override
  53. public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isPet)
  54. {
  55. if (npc.isScriptValue(0))
  56. {
  57. npc.setScriptValue(1);
  58. startQuestTimer("say", (getRandom(5) + 3) * 1000, npc, null, true);
  59. }
  60. else if ((npc.getCurrentHp() < (npc.getMaxHp() * 0.2)) && npc.isScriptValue(1))
  61. {
  62. startQuestTimer("reward", 10000, npc, attacker);
  63. broadcastNpcSay(npc, Say2.NPC_ALL, NpcStringId.WAIT_WAIT_STOP_SAVE_ME_AND_ILL_GIVE_YOU_10000000_ADENA);
  64. npc.setScriptValue(2);
  65. }
  66. return super.onAttack(npc, attacker, damage, isPet);
  67. }
  68. @Override
  69. public String onKill(L2Npc npc, L2PcInstance player, boolean isPet)
  70. {
  71. final NpcStringId msg = (Rnd.nextBoolean()) ? NpcStringId.UGH_A_CURSE_UPON_YOU : NpcStringId.I_REALLY_DIDNT_WANT_TO_FIGHT;
  72. broadcastNpcSay(npc, Say2.NPC_ALL, msg);
  73. cancelQuestTimer("say", npc, null);
  74. cancelQuestTimer("reward", npc, player);
  75. return super.onKill(npc, player, isPet);
  76. }
  77. @Override
  78. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  79. {
  80. switch (event)
  81. {
  82. case "say":
  83. {
  84. if (npc.isDead() || !npc.isScriptValue(1))
  85. {
  86. cancelQuestTimer("say", npc, null);
  87. return null;
  88. }
  89. final NpcStringId msg = (Rnd.nextBoolean()) ? NpcStringId.I_DONT_WANT_TO_FIGHT : NpcStringId.IS_THIS_REALLY_NECESSARY;
  90. broadcastNpcSay(npc, Say2.NPC_ALL, msg);
  91. break;
  92. }
  93. case "reward":
  94. {
  95. if (!npc.isDead() && npc.isScriptValue(2))
  96. {
  97. if (getRandom(100000) < CHANCE2)
  98. {
  99. final NpcStringId msg = (Rnd.nextBoolean()) ? NpcStringId.TH_THANKS_I_COULD_HAVE_BECOME_GOOD_FRIENDS_WITH_YOU : NpcStringId.ILL_GIVE_YOU_10000000_ADENA_LIKE_I_PROMISED_I_MIGHT_BE_AN_ORC_WHO_KEEPS_MY_PROMISES;
  100. broadcastNpcSay(npc, Say2.NPC_ALL, msg);
  101. npc.setScriptValue(3);
  102. npc.doCast(SKILL.getSkill());
  103. for (int i = 0; i < 10; i++)
  104. {
  105. ((L2Attackable) npc).dropItem(player, PcInventory.ADENA_ID, ADENA2);
  106. }
  107. }
  108. else if (getRandom(100000) < CHANCE)
  109. {
  110. final NpcStringId msg = (Rnd.nextBoolean()) ? NpcStringId.TH_THANKS_I_COULD_HAVE_BECOME_GOOD_FRIENDS_WITH_YOU : NpcStringId.SORRY_BUT_THIS_IS_ALL_I_HAVE_GIVE_ME_A_BREAK;
  111. broadcastNpcSay(npc, Say2.NPC_ALL, msg);
  112. npc.setScriptValue(3);
  113. npc.doCast(SKILL.getSkill());
  114. for (int i = 0; i < 10; i++)
  115. {
  116. ((L2Attackable) npc).dropItem(player, PcInventory.ADENA_ID, ADENA);
  117. }
  118. }
  119. else
  120. {
  121. final NpcStringId msg = (Rnd.nextBoolean()) ? NpcStringId.THANKS_BUT_THAT_THING_ABOUT_10000000_ADENA_WAS_A_LIE_SEE_YA : NpcStringId.YOURE_PRETTY_DUMB_TO_BELIEVE_ME;
  122. broadcastNpcSay(npc, Say2.NPC_ALL, msg);
  123. }
  124. startQuestTimer("despawn", 1000, npc, null);
  125. }
  126. break;
  127. }
  128. case "despawn":
  129. {
  130. npc.setRunning();
  131. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition((npc.getX() + getRandom(-800, 800)), (npc.getY() + getRandom(-800, 800)), npc.getZ(), npc.getHeading()));
  132. npc.deleteMe();
  133. break;
  134. }
  135. }
  136. return null;
  137. }
  138. public static void main(String[] args)
  139. {
  140. new FrightenedRagnaOrc(FrightenedRagnaOrc.class.getSimpleName(), "ai");
  141. }
  142. }