From c2d8ff3f3fd34613812425b3e9a09923a853a0c2 Mon Sep 17 00:00:00 2001
From: Nos <NosBit@users.noreply.github.com>
Date: Sat, 4 Jan 2014 04:59:26 +0000
Subject: [PATCH] BETA: Hide effect should remove the target and stop attacks
 of characters targeting the effected.

Reported by: thorl2, Sdw
---
 .../scripts/handlers/effecthandlers/Hide.java | 27 +++++++++++++++----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/effecthandlers/Hide.java b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/effecthandlers/Hide.java
index d543911c36..cad1801c2d 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/effecthandlers/Hide.java
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/effecthandlers/Hide.java
@@ -20,6 +20,7 @@ package handlers.effecthandlers;
 
 import com.l2jserver.gameserver.ai.CtrlIntention;
 import com.l2jserver.gameserver.model.StatsSet;
+import com.l2jserver.gameserver.model.actor.L2Character;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.conditions.Condition;
 import com.l2jserver.gameserver.model.effects.AbstractEffect;
@@ -55,13 +56,29 @@ public final class Hide extends AbstractEffect
 		if (info.getEffected().isPlayer())
 		{
 			L2PcInstance activeChar = info.getEffected().getActingPlayer();
-			
-			activeChar.setTarget(null);
-			activeChar.abortAttack();
-			activeChar.abortCast();
-			activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
 			activeChar.getAppearance().setInvisible();
 			
+			if ((activeChar.getAI().getNextIntention() != null) && (activeChar.getAI().getNextIntention().getCtrlIntention() == CtrlIntention.AI_INTENTION_ATTACK))
+			{
+				activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+			}
+			
+			for (L2Character target : activeChar.getKnownList().getKnownCharacters())
+			{
+				try
+				{
+					if (target.getTarget() == activeChar)
+					{
+						target.setTarget(null);
+						target.abortAttack();
+						target.abortCast();
+						target.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+					}
+				}
+				catch (NullPointerException e)
+				{
+				}
+			}
 		}
 	}
 }
\ No newline at end of file
-- 
GitLab