EffectTransformation.java 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 com.l2jserver.gameserver.skills.effects;
  16. import com.l2jserver.gameserver.instancemanager.TransformationManager;
  17. import com.l2jserver.gameserver.model.L2Effect;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. import com.l2jserver.gameserver.network.SystemMessageId;
  20. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  21. import com.l2jserver.gameserver.skills.Env;
  22. import com.l2jserver.gameserver.templates.effects.EffectTemplate;
  23. import com.l2jserver.gameserver.templates.skills.L2EffectType;
  24. /**
  25. *
  26. * @author nBd
  27. */
  28. public class EffectTransformation extends L2Effect
  29. {
  30. public EffectTransformation(Env env, EffectTemplate template)
  31. {
  32. super(env, template);
  33. }
  34. // Special constructor to steal this effect
  35. public EffectTransformation(Env env, L2Effect effect)
  36. {
  37. super(env, effect);
  38. }
  39. /**
  40. *
  41. * @see com.l2jserver.gameserver.model.L2Effect#getEffectType()
  42. */
  43. @Override
  44. public L2EffectType getEffectType()
  45. {
  46. return L2EffectType.TRANSFORMATION;
  47. }
  48. /**
  49. *
  50. * @see com.l2jserver.gameserver.model.L2Effect#onStart()
  51. */
  52. @Override
  53. public boolean onStart()
  54. {
  55. if (!(getEffected() instanceof L2PcInstance))
  56. return false;
  57. L2PcInstance trg = (L2PcInstance) getEffected();
  58. if (trg == null)
  59. return false;
  60. if (trg.isAlikeDead() || trg.isCursedWeaponEquipped())
  61. return false;
  62. if (trg.getTransformation() != null)
  63. {
  64. trg.sendPacket(new SystemMessage(SystemMessageId.YOU_ALREADY_POLYMORPHED_AND_CANNOT_POLYMORPH_AGAIN));
  65. return false;
  66. }
  67. TransformationManager.getInstance().transformPlayer(getSkill().getTransformId(), trg);
  68. return true;
  69. }
  70. /**
  71. *
  72. * @see com.l2jserver.gameserver.model.L2Effect#onActionTime()
  73. */
  74. @Override
  75. public boolean onActionTime()
  76. {
  77. return false;
  78. }
  79. @Override
  80. public void onExit()
  81. {
  82. getEffected().stopTransformation(this);
  83. }
  84. }