From a68af35527b06a64f53f096082428583447bb966 Mon Sep 17 00:00:00 2001 From: Nos <NosBit@users.noreply.github.com> Date: Sat, 28 Dec 2013 01:47:56 +0000 Subject: [PATCH] BETA: Reworked `Fear` effect movement effected now runs a straight line away from effector as long as effect lasts. Reported by: Tavo22 Reviewed by: !UnAfraid --- .../scripts/handlers/effecthandlers/Fear.java | 53 +++++++++---------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/effecthandlers/Fear.java b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/effecthandlers/Fear.java index 56b0b81b66..1be14cde62 100644 --- a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/effecthandlers/Fear.java +++ b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/effecthandlers/Fear.java @@ -34,6 +34,7 @@ import com.l2jserver.gameserver.model.effects.AbstractEffect; import com.l2jserver.gameserver.model.effects.EffectFlag; import com.l2jserver.gameserver.model.effects.L2EffectType; import com.l2jserver.gameserver.model.skills.BuffInfo; +import com.l2jserver.gameserver.util.Util; /** * Fear effect implementation. @@ -70,27 +71,38 @@ public final class Fear extends AbstractEffect return L2EffectType.FEAR; } + @Override + public int getTicks() + { + return 5; + } + @Override public boolean onActionTime(BuffInfo info) { - int posX = info.getEffected().getX(); - int posY = info.getEffected().getY(); - int posZ = info.getEffected().getZ(); - - int _dX = -1; - int _dY = -1; - if (info.getEffected().getX() > info.getEffector().getX()) + fearAction(info, false); + return false; + } + + @Override + public void onStart(BuffInfo info) + { + if (info.getEffected().isCastingNow() && info.getEffected().canAbortCast()) { - _dX = 1; + info.getEffected().abortCast(); } - if (info.getEffected().getY() > info.getEffector().getY()) - { - _dY = 1; - } + info.getEffected().getAI().notifyEvent(CtrlEvent.EVT_AFRAID); + fearAction(info, true); + } + + private void fearAction(BuffInfo info, boolean start) + { + double radians = Math.toRadians(start ? Util.calculateAngleFrom(info.getEffector(), info.getEffected()) : Util.convertHeadingToDegree(info.getEffected().getHeading())); - posX += _dX * FEAR_RANGE; - posY += _dY * FEAR_RANGE; + int posX = (int) (info.getEffected().getX() + (FEAR_RANGE * Math.cos(radians))); + int posY = (int) (info.getEffected().getY() + (FEAR_RANGE * Math.sin(radians))); + int posZ = info.getEffected().getZ(); if (Config.GEODATA > 0) { @@ -105,18 +117,5 @@ public final class Fear extends AbstractEffect } info.getEffected().getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(posX, posY, posZ)); - return false; - } - - @Override - public void onStart(BuffInfo info) - { - if (info.getEffected().isCastingNow() && info.getEffected().canAbortCast()) - { - info.getEffected().abortCast(); - } - - info.getEffected().getAI().notifyEvent(CtrlEvent.EVT_AFRAID); - onActionTime(info); } } -- GitLab