SummonAgathion.java 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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.
  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 boolean onStart()
  38. {
  39. if ((getEffector() == null) || (getEffected() == null) || !getEffector().isPlayer() || !getEffected().isPlayer() || getEffected().isAlikeDead())
  40. {
  41. return false;
  42. }
  43. final L2PcInstance player = getEffector().getActingPlayer();
  44. if (player.isInOlympiadMode())
  45. {
  46. player.sendPacket(SystemMessageId.THIS_SKILL_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT);
  47. return false;
  48. }
  49. setAgathionId(player);
  50. player.broadcastUserInfo();
  51. return true;
  52. }
  53. @Override
  54. public void onExit()
  55. {
  56. super.onExit();
  57. final L2PcInstance player = getEffector().getActingPlayer();
  58. if (player != null)
  59. {
  60. player.setAgathionId(0);
  61. player.broadcastUserInfo();
  62. }
  63. }
  64. /**
  65. * Set the player's agathion Id.
  66. * @param player the player to set the agathion Id.
  67. */
  68. protected void setAgathionId(L2PcInstance player)
  69. {
  70. player.setAgathionId((getSkill() == null) ? 0 : getSkill().getNpcId());
  71. }
  72. @Override
  73. public boolean onActionTime()
  74. {
  75. return true;
  76. }
  77. @Override
  78. public L2EffectType getEffectType()
  79. {
  80. return L2EffectType.SUMMON_AGATHION;
  81. }
  82. }