EvasGiftBox.java 2.4 KB

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