BeastSkills.java 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. @Override
  39. public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
  40. {
  41. if (!(activeChar instanceof L2PcInstance))
  42. return;
  43. L2SkillType type = skill.getSkillType();
  44. L2PcInstance player = activeChar.getActingPlayer();
  45. L2Object target = player.getTarget();
  46. switch(type)
  47. {
  48. case BEAST_FEED:
  49. L2Object[] targetList = skill.getTargetList(activeChar);
  50. if (targetList == null)
  51. {
  52. return;
  53. }
  54. // This is just a dummy skill handler for the golden food and crystal food skills,
  55. // since the AI responce onSkillUse handles the rest.
  56. break;
  57. case BEAST_RELEASE:
  58. if (target != null && target instanceof L2TamedBeastInstance)
  59. ((L2TamedBeastInstance)target).deleteMe();
  60. break;
  61. case BEAST_RELEASE_ALL:
  62. if (player.getTrainedBeasts() != null)
  63. for(L2TamedBeastInstance beast : player.getTrainedBeasts())
  64. beast.deleteMe();
  65. break;
  66. case BEAST_ACCOMPANY:
  67. // Unknown effect now
  68. break;
  69. case BEAST_SKILL:
  70. if (target != null && target instanceof L2TamedBeastInstance)
  71. ((L2TamedBeastInstance)target).castBeastSkills();
  72. break;
  73. }
  74. }
  75. @Override
  76. public L2SkillType[] getSkillIds()
  77. {
  78. return SKILL_IDS;
  79. }
  80. }