EffectFear.java 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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.ai.CtrlIntention;
  17. import net.sf.l2j.gameserver.model.L2CharPosition;
  18. import net.sf.l2j.gameserver.model.L2Effect;
  19. import net.sf.l2j.gameserver.model.actor.instance.L2FolkInstance;
  20. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  21. import net.sf.l2j.gameserver.model.actor.instance.L2SiegeFlagInstance;
  22. import net.sf.l2j.gameserver.model.actor.instance.L2SiegeGuardInstance;
  23. import net.sf.l2j.gameserver.model.actor.instance.L2SiegeSummonInstance;
  24. import net.sf.l2j.gameserver.skills.Env;
  25. /**
  26. * @author littlecrow
  27. *
  28. * Implementation of the Fear Effect
  29. */
  30. final class EffectFear extends L2Effect
  31. {
  32. public static final int FEAR_RANGE = 500;
  33. public EffectFear(Env env, EffectTemplate template)
  34. {
  35. super(env, template);
  36. }
  37. @Override
  38. public EffectType getEffectType()
  39. {
  40. return EffectType.FEAR;
  41. }
  42. /** Notify started */
  43. @Override
  44. public void onStart()
  45. {
  46. if (!getEffected().isAfraid())
  47. {
  48. getEffected().startFear();
  49. onActionTime();
  50. }
  51. }
  52. /** Notify exited */
  53. @Override
  54. public void onExit()
  55. {
  56. getEffected().stopFear(this);
  57. }
  58. @Override
  59. public boolean onActionTime()
  60. {
  61. // Fear skills cannot be used l2pcinstance to l2pcinstance. Heroic Dread, Curse: Fear, Fear, Horror, Sword Symphony, Word of Fear and Mass Curse Fear are the exceptions.
  62. if(getEffected() instanceof L2PcInstance && getEffector() instanceof L2PcInstance && getSkill().getId() != 1376 && getSkill().getId() != 1169 && getSkill().getId() != 65 && getSkill().getId() != 1092 && getSkill().getId() != 98 && getSkill().getId() != 1272 && getSkill().getId() != 1381) return false;
  63. if(getEffected() instanceof L2FolkInstance) return false;
  64. if(getEffected() instanceof L2SiegeGuardInstance) return false;
  65. // Fear skills cannot be used on Headquarters Flag.
  66. if(getEffected() instanceof L2SiegeFlagInstance) return false;
  67. if(getEffected() instanceof L2SiegeSummonInstance)
  68. return false;
  69. int posX = getEffected().getX();
  70. int posY = getEffected().getY();
  71. int posZ = getEffected().getZ();
  72. int signx=-1;
  73. int signy=-1;
  74. if (getEffected().getX() > getEffector().getX())
  75. signx=1;
  76. if (getEffected().getY() > getEffector().getY())
  77. signy=1;
  78. posX += signx*FEAR_RANGE;
  79. posY += signy*FEAR_RANGE;
  80. getEffected().setRunning();
  81. getEffected().getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO,new L2CharPosition(posX,posY,posZ,0));
  82. return true;
  83. }
  84. }