EvasGiftBox.java 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright (C) 2004-2014 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.L2Attackable;
  22. import com.l2jserver.gameserver.model.actor.L2Npc;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.holders.ItemHolder;
  25. /**
  26. * Eva's Gift Box AI.
  27. * @author St3eT
  28. */
  29. public final class EvasGiftBox extends AbstractNpcAI
  30. {
  31. // NPC
  32. private static final int BOX = 32342; // Eva's Gift Box
  33. // Skill
  34. private static final int BUFF = 1073; // Kiss of Eva
  35. // Items
  36. private static final ItemHolder CORAL = new ItemHolder(9692, 1); // Red Coral
  37. private static final ItemHolder CRYSTAL = new ItemHolder(9693, 1); // Crystal Fragment
  38. private EvasGiftBox()
  39. {
  40. super(EvasGiftBox.class.getSimpleName(), "ai/individual");
  41. addKillId(BOX);
  42. addSpawnId(BOX);
  43. }
  44. @Override
  45. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  46. {
  47. if (killer.isAffectedBySkill(BUFF))
  48. {
  49. if (getRandomBoolean())
  50. {
  51. npc.dropItem(killer, CRYSTAL);
  52. }
  53. else if (getRandom(100) < 33)
  54. {
  55. npc.dropItem(killer, CORAL);
  56. }
  57. }
  58. return super.onKill(npc, killer, isSummon);
  59. }
  60. @Override
  61. public String onSpawn(L2Npc npc)
  62. {
  63. npc.setIsNoRndWalk(true);
  64. ((L2Attackable) npc).setOnKillDelay(0);
  65. return super.onSpawn(npc);
  66. }
  67. public static void main(String[] args)
  68. {
  69. new EvasGiftBox();
  70. }
  71. }