SummonAgathion.java 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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.effecthandlers;
  20. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  21. import com.l2jserver.gameserver.model.effects.EffectTemplate;
  22. import com.l2jserver.gameserver.model.effects.L2Effect;
  23. import com.l2jserver.gameserver.model.effects.L2EffectType;
  24. import com.l2jserver.gameserver.model.stats.Env;
  25. import com.l2jserver.gameserver.network.SystemMessageId;
  26. /**
  27. * Summon Agathion effect implementation.
  28. * @author Zoey76
  29. */
  30. public class SummonAgathion extends L2Effect
  31. {
  32. public SummonAgathion(Env env, EffectTemplate template)
  33. {
  34. super(env, template);
  35. }
  36. @Override
  37. public L2EffectType getEffectType()
  38. {
  39. return L2EffectType.NONE;
  40. }
  41. @Override
  42. public boolean isInstant()
  43. {
  44. return true;
  45. }
  46. @Override
  47. public boolean onActionTime()
  48. {
  49. return true; // TODO: Review.
  50. }
  51. @Override
  52. public void onExit()
  53. {
  54. super.onExit();
  55. final L2PcInstance player = getEffector().getActingPlayer();
  56. if (player != null)
  57. {
  58. player.setAgathionId(0);
  59. player.broadcastUserInfo();
  60. }
  61. }
  62. @Override
  63. public boolean onStart()
  64. {
  65. if ((getEffector() == null) || (getEffected() == null) || !getEffector().isPlayer() || !getEffected().isPlayer() || getEffected().isAlikeDead())
  66. {
  67. return false;
  68. }
  69. final L2PcInstance player = getEffector().getActingPlayer();
  70. if (player.isInOlympiadMode())
  71. {
  72. player.sendPacket(SystemMessageId.THIS_SKILL_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT);
  73. return false;
  74. }
  75. setAgathionId(player);
  76. player.broadcastUserInfo();
  77. return true;
  78. }
  79. /**
  80. * Set the player's agathion Id.
  81. * @param player the player to set the agathion Id
  82. */
  83. protected void setAgathionId(L2PcInstance player)
  84. {
  85. player.setAgathionId((getSkill() == null) ? 0 : getSkill().getNpcId());
  86. }
  87. }