SummonTreasureKey.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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.L2Skill.SkillType;
  22. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  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 SkillType[] SKILL_IDS = {SkillType.SUMMON_TREASURE_KEY};
  32. public void useSkill(L2Character activeChar, @SuppressWarnings("unused")
  33. L2Skill skill, @SuppressWarnings("unused")L2Object[] targets)
  34. {
  35. if (!(activeChar instanceof L2PcInstance)) return;
  36. L2PcInstance player = (L2PcInstance) activeChar;
  37. try
  38. {
  39. int item_id = 0;
  40. switch (skill.getLevel())
  41. {
  42. case 1:
  43. {
  44. item_id = Rnd.get(6667, 6669);
  45. break;
  46. }
  47. case 2:
  48. {
  49. item_id = Rnd.get(6668, 6670);
  50. break;
  51. }
  52. case 3:
  53. {
  54. item_id = Rnd.get(6669, 6671);
  55. break;
  56. }
  57. case 4:
  58. {
  59. item_id = Rnd.get(6670, 6672);
  60. break;
  61. }
  62. }
  63. player.addItem("Skill", item_id, Rnd.get(2,3), player, false);
  64. }
  65. catch (Exception e)
  66. {
  67. _log.warning("Error using skill summon Treasure Key:" + e);
  68. }
  69. }
  70. public SkillType[] getSkillIds()
  71. {
  72. return SKILL_IDS;
  73. }
  74. }