EvasGiftBoxes.java 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. import com.l2jserver.gameserver.model.actor.L2Npc;
  17. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  18. import com.l2jserver.gameserver.model.quest.Quest;
  19. import com.l2jserver.gameserver.model.quest.QuestState;
  20. import com.l2jserver.util.Rnd;
  21. public class EvasGiftBoxes extends Quest
  22. {
  23. final private static int GIFTBOX = 32342;
  24. final private static int KISSOFEVA = 1073;
  25. // index 0: without kiss of eva
  26. // index 1: with kiss of eva
  27. // chance,itemId,...
  28. final private static int[][] CHANCES = {{2,9692,1,9693},{100,9692,50,9693}};
  29. final private static String qn = "EvasGiftBoxes";
  30. public EvasGiftBoxes(int questId, String name, String descr)
  31. {
  32. super(questId, name, descr);
  33. addKillId(GIFTBOX);
  34. addSpawnId(GIFTBOX);
  35. }
  36. @Override
  37. public String onSpawn(L2Npc npc)
  38. {
  39. npc.setIsNoRndWalk(true);
  40. return super.onSpawn(npc);
  41. }
  42. @Override
  43. public String onKill (L2Npc npc, L2PcInstance killer, boolean isPet)
  44. {
  45. if (npc.getNpcId() == GIFTBOX)
  46. {
  47. QuestState st = killer.getQuestState(qn);
  48. if (st == null)
  49. st = newQuestState(killer);
  50. int isKissOfEvaBuffed = 0;
  51. if (killer.getFirstEffect(KISSOFEVA) != null)
  52. isKissOfEvaBuffed = 1;
  53. for (int i = 0; i < CHANCES[isKissOfEvaBuffed].length; i += 2)
  54. if (Rnd.get(100) < CHANCES[isKissOfEvaBuffed][i])
  55. st.giveItems(CHANCES[isKissOfEvaBuffed][i+1],1);
  56. }
  57. return super.onKill(npc,killer,isPet);
  58. }
  59. public static void main(String[] args)
  60. {
  61. new EvasGiftBoxes(-1,qn,"ai");
  62. }
  63. }