BeastSkills.java 2.7 KB

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