2
0

SummonTreasureKey.java 2.5 KB

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