New solution for attack movement issue.
This commit is contained in:
		@@ -23,13 +23,14 @@ import com.l2jmobius.gameserver.enums.InstanceType;
 | 
			
		||||
import com.l2jmobius.gameserver.geoengine.GeoEngine;
 | 
			
		||||
import com.l2jmobius.gameserver.handler.IActionHandler;
 | 
			
		||||
import com.l2jmobius.gameserver.model.L2Object;
 | 
			
		||||
import com.l2jmobius.gameserver.model.Location;
 | 
			
		||||
import com.l2jmobius.gameserver.model.actor.L2Character;
 | 
			
		||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
 | 
			
		||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
 | 
			
		||||
import com.l2jmobius.gameserver.model.entity.L2Event;
 | 
			
		||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
 | 
			
		||||
import com.l2jmobius.gameserver.model.events.EventType;
 | 
			
		||||
import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcFirstTalk;
 | 
			
		||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
 | 
			
		||||
import com.l2jmobius.gameserver.network.serverpackets.MoveToPawn;
 | 
			
		||||
 | 
			
		||||
public class L2NpcAction implements IActionHandler
 | 
			
		||||
@@ -80,16 +81,18 @@ public class L2NpcAction implements IActionHandler
 | 
			
		||||
		else if (interact)
 | 
			
		||||
		{
 | 
			
		||||
			// Check if the activeChar is attackable (without a forced attack) and isn't dead
 | 
			
		||||
			if (target.isAutoAttackable(activeChar) && !((L2Npc) target).isAlikeDead())
 | 
			
		||||
			if (target.isAutoAttackable(activeChar) && !((L2Character) target).isAlikeDead())
 | 
			
		||||
			{
 | 
			
		||||
				// Check if target is in LoS
 | 
			
		||||
				if (GeoEngine.getInstance().canSeeTarget(activeChar, target))
 | 
			
		||||
				{
 | 
			
		||||
					// Set the L2PcInstance Intention to AI_INTENTION_ATTACK
 | 
			
		||||
					activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
					final Location destination = GeoEngine.getInstance().canMoveToTargetLoc(activeChar.getX(), activeChar.getY(), activeChar.getZ(), target.getX(), target.getY(), target.getZ(), activeChar.getInstanceId());
 | 
			
		||||
					activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, destination);
 | 
			
		||||
					// Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
 | 
			
		||||
					activeChar.sendPacket(ActionFailed.STATIC_PACKET);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			else if (!target.isAutoAttackable(activeChar))
 | 
			
		||||
 
 | 
			
		||||
@@ -22,7 +22,6 @@ import com.l2jmobius.gameserver.enums.PrivateStoreType;
 | 
			
		||||
import com.l2jmobius.gameserver.geoengine.GeoEngine;
 | 
			
		||||
import com.l2jmobius.gameserver.handler.IActionHandler;
 | 
			
		||||
import com.l2jmobius.gameserver.model.L2Object;
 | 
			
		||||
import com.l2jmobius.gameserver.model.Location;
 | 
			
		||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
 | 
			
		||||
import com.l2jmobius.gameserver.model.entity.TvTEvent;
 | 
			
		||||
import com.l2jmobius.gameserver.network.SystemMessageId;
 | 
			
		||||
@@ -105,13 +104,8 @@ public class L2PcInstanceAction implements IActionHandler
 | 
			
		||||
						if (GeoEngine.getInstance().canSeeTarget(activeChar, player))
 | 
			
		||||
						{
 | 
			
		||||
							activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player);
 | 
			
		||||
							activeChar.onActionRequest();
 | 
			
		||||
						}
 | 
			
		||||
						else
 | 
			
		||||
						{
 | 
			
		||||
							final Location destination = GeoEngine.getInstance().canMoveToTargetLoc(activeChar.getX(), activeChar.getY(), activeChar.getZ(), player.getX(), player.getY(), player.getZ(), activeChar.getInstanceId());
 | 
			
		||||
							activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, destination);
 | 
			
		||||
						}
 | 
			
		||||
						activeChar.onActionRequest();
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
@@ -122,11 +116,6 @@ public class L2PcInstanceAction implements IActionHandler
 | 
			
		||||
					{
 | 
			
		||||
						activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, player);
 | 
			
		||||
					}
 | 
			
		||||
					else
 | 
			
		||||
					{
 | 
			
		||||
						final Location destination = GeoEngine.getInstance().canMoveToTargetLoc(activeChar.getX(), activeChar.getY(), activeChar.getZ(), player.getX(), player.getY(), player.getZ(), activeChar.getInstanceId());
 | 
			
		||||
						activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, destination);
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -72,12 +72,9 @@ public class L2SummonAction implements IActionHandler
 | 
			
		||||
				{
 | 
			
		||||
					activeChar.updateNotMoveUntil();
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				else if (GeoEngine.getInstance().canSeeTarget(activeChar, target))
 | 
			
		||||
				{
 | 
			
		||||
					if (GeoEngine.getInstance().canSeeTarget(activeChar, target))
 | 
			
		||||
					{
 | 
			
		||||
						activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, target);
 | 
			
		||||
					}
 | 
			
		||||
					activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, target);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user