BeastSkills.java 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Copyright (C) 2004-2013 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 handlers.skillhandlers;
  20. import com.l2jserver.gameserver.handler.ISkillHandler;
  21. import com.l2jserver.gameserver.model.L2Object;
  22. import com.l2jserver.gameserver.model.actor.L2Character;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.actor.instance.L2TamedBeastInstance;
  25. import com.l2jserver.gameserver.model.skills.L2Skill;
  26. import com.l2jserver.gameserver.model.skills.L2SkillType;
  27. /**
  28. * @author _drunk_
  29. */
  30. public class BeastSkills implements ISkillHandler
  31. {
  32. // private static Logger _log = Logger.getLogger(BeastSkills.class.getName());
  33. private static final L2SkillType[] SKILL_IDS =
  34. {
  35. L2SkillType.BEAST_FEED,
  36. L2SkillType.BEAST_RELEASE,
  37. L2SkillType.BEAST_RELEASE_ALL,
  38. L2SkillType.BEAST_SKILL,
  39. L2SkillType.BEAST_ACCOMPANY
  40. };
  41. @Override
  42. public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
  43. {
  44. if (!activeChar.isPlayer())
  45. {
  46. return;
  47. }
  48. L2SkillType type = skill.getSkillType();
  49. L2PcInstance player = activeChar.getActingPlayer();
  50. L2Object target = player.getTarget();
  51. switch (type)
  52. {
  53. case BEAST_FEED:
  54. L2Object[] targetList = skill.getTargetList(activeChar);
  55. if (targetList == null)
  56. {
  57. return;
  58. }
  59. // This is just a dummy skill handler for the golden food and crystal food skills,
  60. // since the AI responce onSkillUse handles the rest.
  61. break;
  62. case BEAST_RELEASE:
  63. if ((target != null) && (target instanceof L2TamedBeastInstance))
  64. {
  65. ((L2TamedBeastInstance) target).deleteMe();
  66. }
  67. break;
  68. case BEAST_RELEASE_ALL:
  69. if (player.getTrainedBeasts() != null)
  70. {
  71. for (L2TamedBeastInstance beast : player.getTrainedBeasts())
  72. {
  73. beast.deleteMe();
  74. }
  75. }
  76. break;
  77. case BEAST_ACCOMPANY:
  78. // Unknown effect now
  79. break;
  80. case BEAST_SKILL:
  81. if ((target != null) && (target instanceof L2TamedBeastInstance))
  82. {
  83. ((L2TamedBeastInstance) target).castBeastSkills();
  84. }
  85. break;
  86. }
  87. }
  88. @Override
  89. public L2SkillType[] getSkillIds()
  90. {
  91. return SKILL_IDS;
  92. }
  93. }