EffectSignet.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 net.sf.l2j.gameserver.skills.effects;
  16. import net.sf.l2j.gameserver.datatables.SkillTable;
  17. import net.sf.l2j.gameserver.model.L2Character;
  18. import net.sf.l2j.gameserver.model.L2Effect;
  19. import net.sf.l2j.gameserver.model.L2Skill;
  20. import net.sf.l2j.gameserver.model.actor.instance.L2EffectPointInstance;
  21. import net.sf.l2j.gameserver.network.SystemMessageId;
  22. import net.sf.l2j.gameserver.serverpackets.MagicSkillUse;
  23. import net.sf.l2j.gameserver.serverpackets.SystemMessage;
  24. import net.sf.l2j.gameserver.skills.Env;
  25. import net.sf.l2j.gameserver.skills.l2skills.L2SkillSignet;
  26. import net.sf.l2j.gameserver.skills.l2skills.L2SkillSignetCasttime;
  27. /**
  28. * @authors Forsaiken, Sami
  29. */
  30. final class EffectSignet extends L2Effect
  31. {
  32. private L2Skill _skill;
  33. private L2EffectPointInstance _actor;
  34. public EffectSignet(Env env, EffectTemplate template)
  35. {
  36. super(env, template);
  37. }
  38. @Override
  39. public EffectType getEffectType()
  40. {
  41. return EffectType.SIGNET_EFFECT;
  42. }
  43. @Override
  44. public void onStart()
  45. {
  46. if (getSkill() instanceof L2SkillSignet)
  47. _skill = SkillTable.getInstance().getInfo(((L2SkillSignet)getSkill()).effectId, getLevel());
  48. else if (getSkill() instanceof L2SkillSignetCasttime)
  49. _skill = SkillTable.getInstance().getInfo(((L2SkillSignetCasttime)getSkill()).effectId, getLevel());
  50. _actor = (L2EffectPointInstance)getEffected();
  51. }
  52. @Override
  53. public boolean onActionTime()
  54. {
  55. //if (getCount() == getTotalCount() - 1) return true; // do nothing first time
  56. if (_skill == null) return true;
  57. int mpConsume = _skill.getMpConsume();
  58. if (mpConsume > getEffector().getCurrentMp())
  59. {
  60. getEffector().sendPacket(new SystemMessage(SystemMessageId.SKILL_REMOVED_DUE_LACK_MP));
  61. return false;
  62. }
  63. else
  64. getEffector().reduceCurrentMp(mpConsume);
  65. for (L2Character cha : _actor.getKnownList().getKnownCharactersInRadius(getSkill().getSkillRadius()))
  66. {
  67. if (cha == null)
  68. continue;
  69. _skill.getEffects(_actor, cha);
  70. // there doesn't seem to be a visible effect with MagicSkillLaunched packet...
  71. _actor.broadcastPacket(new MagicSkillUse(_actor,cha,_skill.getId(),_skill.getLevel(),0,0));
  72. }
  73. return true;
  74. }
  75. @Override
  76. public void onExit()
  77. {
  78. if (_actor != null)
  79. {
  80. _actor.deleteMe();
  81. }
  82. }
  83. }