SummonTreasureKey.java 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 net.sf.l2j.gameserver.handler.skillhandlers;
  16. import java.util.logging.Logger;
  17. import net.sf.l2j.gameserver.handler.ISkillHandler;
  18. import net.sf.l2j.gameserver.model.L2Character;
  19. import net.sf.l2j.gameserver.model.L2Object;
  20. import net.sf.l2j.gameserver.model.L2Skill;
  21. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  22. import net.sf.l2j.gameserver.templates.L2SkillType;
  23. import net.sf.l2j.util.Rnd;
  24. /**
  25. * @author evill33t
  26. *
  27. */
  28. public class SummonTreasureKey implements ISkillHandler
  29. {
  30. static Logger _log = Logger.getLogger(SummonTreasureKey.class.getName());
  31. private static final L2SkillType[] SKILL_IDS =
  32. {
  33. L2SkillType.SUMMON_TREASURE_KEY
  34. };
  35. /**
  36. *
  37. * @see net.sf.l2j.gameserver.handler.ISkillHandler#useSkill(net.sf.l2j.gameserver.model.L2Character, net.sf.l2j.gameserver.model.L2Skill, net.sf.l2j.gameserver.model.L2Object[])
  38. */
  39. public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
  40. {
  41. if (!(activeChar instanceof L2PcInstance))
  42. return;
  43. L2PcInstance player = (L2PcInstance) activeChar;
  44. try
  45. {
  46. int item_id = 0;
  47. switch (skill.getLevel())
  48. {
  49. case 1:
  50. {
  51. item_id = Rnd.get(6667, 6669);
  52. break;
  53. }
  54. case 2:
  55. {
  56. item_id = Rnd.get(6668, 6670);
  57. break;
  58. }
  59. case 3:
  60. {
  61. item_id = Rnd.get(6669, 6671);
  62. break;
  63. }
  64. case 4:
  65. {
  66. item_id = Rnd.get(6670, 6672);
  67. break;
  68. }
  69. }
  70. player.addItem("Skill", item_id, Rnd.get(2, 3), player, false);
  71. }
  72. catch (Exception e)
  73. {
  74. _log.warning("Error using skill summon Treasure Key:" + e);
  75. }
  76. }
  77. /**
  78. *
  79. * @see net.sf.l2j.gameserver.handler.ISkillHandler#getSkillIds()
  80. */
  81. public L2SkillType[] getSkillIds()
  82. {
  83. return SKILL_IDS;
  84. }
  85. }