StarStones.java 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 gracia.AI;
  20. import ai.npc.AbstractNpcAI;
  21. import com.l2jserver.gameserver.model.L2Object;
  22. import com.l2jserver.gameserver.model.actor.L2Npc;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.skills.Skill;
  25. import com.l2jserver.gameserver.network.SystemMessageId;
  26. /**
  27. * Star Stones AI.
  28. * @author Gigiikun
  29. */
  30. public class StarStones extends AbstractNpcAI
  31. {
  32. // @formatter:off
  33. private static final int[] MOBS =
  34. {
  35. 18684, 18685, 18686, 18687, 18688, 18689, 18690, 18691, 18692
  36. };
  37. // @formatter:on
  38. private static final int COLLECTION_RATE = 1;
  39. public StarStones()
  40. {
  41. super(StarStones.class.getSimpleName(), "gracia/AI");
  42. addSkillSeeId(MOBS);
  43. }
  44. @Override
  45. public String onSkillSee(L2Npc npc, L2PcInstance caster, Skill skill, L2Object[] targets, boolean isSummon)
  46. {
  47. if (skill.getId() == 932)
  48. {
  49. int itemId = 0;
  50. switch (npc.getId())
  51. {
  52. case 18684:
  53. case 18685:
  54. case 18686:
  55. // give Red item
  56. itemId = 14009;
  57. break;
  58. case 18687:
  59. case 18688:
  60. case 18689:
  61. // give Blue item
  62. itemId = 14010;
  63. break;
  64. case 18690:
  65. case 18691:
  66. case 18692:
  67. // give Green item
  68. itemId = 14011;
  69. break;
  70. default:
  71. // unknown npc!
  72. return super.onSkillSee(npc, caster, skill, targets, isSummon);
  73. }
  74. if (getRandom(100) < 33)
  75. {
  76. caster.sendPacket(SystemMessageId.THE_COLLECTION_HAS_SUCCEEDED);
  77. caster.addItem("StarStone", itemId, getRandom(COLLECTION_RATE + 1, 2 * COLLECTION_RATE), null, true);
  78. }
  79. else if (((skill.getLevel() == 1) && (getRandom(100) < 15)) || ((skill.getLevel() == 2) && (getRandom(100) < 50)) || ((skill.getLevel() == 3) && (getRandom(100) < 75)))
  80. {
  81. caster.sendPacket(SystemMessageId.THE_COLLECTION_HAS_SUCCEEDED);
  82. caster.addItem("StarStone", itemId, getRandom(1, COLLECTION_RATE), null, true);
  83. }
  84. else
  85. {
  86. caster.sendPacket(SystemMessageId.THE_COLLECTION_HAS_FAILED);
  87. }
  88. npc.deleteMe();
  89. }
  90. return super.onSkillSee(npc, caster, skill, targets, isSummon);
  91. }
  92. }