Spoil.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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.effecthandlers;
  16. import com.l2jserver.gameserver.ai.CtrlEvent;
  17. import com.l2jserver.gameserver.model.L2Effect;
  18. import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
  19. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  20. import com.l2jserver.gameserver.network.SystemMessageId;
  21. import com.l2jserver.gameserver.skills.Env;
  22. import com.l2jserver.gameserver.skills.Formulas;
  23. import com.l2jserver.gameserver.templates.effects.EffectTemplate;
  24. import com.l2jserver.gameserver.templates.skills.L2EffectType;
  25. /**
  26. *
  27. * @author Ahmed
  28. *
  29. * This is the Effect support for spoil.
  30. *
  31. * This was originally done by _drunk_
  32. */
  33. public class Spoil extends L2Effect
  34. {
  35. public Spoil(Env env, EffectTemplate template)
  36. {
  37. super(env, template);
  38. }
  39. /**
  40. *
  41. * @see com.l2jserver.gameserver.model.L2Effect#getEffectType()
  42. */
  43. @Override
  44. public L2EffectType getEffectType()
  45. {
  46. return L2EffectType.SPOIL;
  47. }
  48. /**
  49. *
  50. * @see com.l2jserver.gameserver.model.L2Effect#onStart()
  51. */
  52. @Override
  53. public boolean onStart()
  54. {
  55. if (!(getEffector() instanceof L2PcInstance))
  56. return false;
  57. if (!(getEffected() instanceof L2MonsterInstance))
  58. return false;
  59. L2MonsterInstance target = (L2MonsterInstance) getEffected();
  60. if (target == null)
  61. return false;
  62. if (target.isSpoil())
  63. {
  64. getEffector().sendPacket(SystemMessageId.ALREADY_SPOILED);
  65. return false;
  66. }
  67. // SPOIL SYSTEM by Lbaldi
  68. boolean spoil = false;
  69. if (target.isDead() == false)
  70. {
  71. spoil = Formulas.calcMagicSuccess(getEffector(), target, getSkill());
  72. if (spoil)
  73. {
  74. target.setSpoil(true);
  75. target.setIsSpoiledBy(getEffector().getObjectId());
  76. getEffector().sendPacket(SystemMessageId.SPOIL_SUCCESS);
  77. }
  78. target.getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, getEffector());
  79. }
  80. return true;
  81. }
  82. /**
  83. *
  84. * @see com.l2jserver.gameserver.model.L2Effect#onActionTime()
  85. */
  86. @Override
  87. public boolean onActionTime()
  88. {
  89. return false;
  90. }
  91. }