Prechádzať zdrojové kódy

BETA: Remove double implementation of return home for guards.
* Reviewed by: malyelfik, Zoey76, !UnAfraid

St3eT 11 rokov pred
rodič
commit
a7a7fe6a5f

+ 7 - 7
L2J_Server_BETA/java/com/l2jserver/gameserver/ai/L2AttackableAI.java

@@ -564,11 +564,17 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
 			}
 		}
 		
+		// Check if the mob should not return to spawn point
+		if (!npc.canReturnToSpawnPoint())
+		{
+			return;
+		}
+		
 		// Check if the actor is a L2GuardInstance
 		if ((npc instanceof L2GuardInstance) && !npc.isWalker())
 		{
 			// Order to the L2GuardInstance to return to its home location because there's no target to attack
-			((L2GuardInstance) npc).returnHome();
+			npc.returnHome();
 		}
 		
 		// If this is a festival monster, then it remains in the same location.
@@ -577,12 +583,6 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
 			return;
 		}
 		
-		// Check if the mob should not return to spawn point
-		if (!npc.canReturnToSpawnPoint())
-		{
-			return;
-		}
-		
 		// Minions following leader
 		final L2Character leader = npc.getLeader();
 		if ((leader != null) && !leader.isAlikeDead())

+ 0 - 37
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2GuardInstance.java

@@ -19,11 +19,9 @@
 package com.l2jserver.gameserver.model.actor.instance;
 
 import java.util.List;
-import java.util.concurrent.Future;
 import java.util.logging.Logger;
 
 import com.l2jserver.Config;
-import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ai.CtrlIntention;
 import com.l2jserver.gameserver.ai.L2AttackableAI;
 import com.l2jserver.gameserver.enums.InstanceType;
@@ -46,22 +44,6 @@ public class L2GuardInstance extends L2Attackable
 {
 	private static Logger _log = Logger.getLogger(L2GuardInstance.class.getName());
 	
-	private static final int RETURN_INTERVAL = 60000;
-	
-	private Future<?> _returnTask;
-	
-	public class ReturnTask implements Runnable
-	{
-		@Override
-		public void run()
-		{
-			if (getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE)
-			{
-				returnHome();
-			}
-		}
-	}
-	
 	/**
 	 * Constructor of L2GuardInstance (use L2Character and L2NpcInstance constructor).<br>
 	 * <B><U> Actions</U> :</B>
@@ -100,20 +82,6 @@ public class L2GuardInstance extends L2Attackable
 		return attacker instanceof L2MonsterInstance;
 	}
 	
-	/**
-	 * Notify the L2GuardInstance to return to its home location (AI_INTENTION_MOVE_TO) and clear its _aggroList.
-	 */
-	@Override
-	public void returnHome()
-	{
-		if (!isInsideRadius(getSpawn(), 150, false, false))
-		{
-			clearAggroList();
-			
-			getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, getSpawn().getLocation());
-		}
-	}
-	
 	/**
 	 * Set the home location of its L2GuardInstance.
 	 */
@@ -123,11 +91,6 @@ public class L2GuardInstance extends L2Attackable
 		setIsNoRndWalk(true);
 		super.onSpawn();
 		
-		if ((_returnTask == null) && !isWalker())
-		{
-			_returnTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new ReturnTask(), RETURN_INTERVAL, RETURN_INTERVAL + Rnd.nextInt(60000));
-		}
-		
 		// check the region where this mob is, do not activate the AI if region is inactive.
 		L2WorldRegion region = L2World.getInstance().getRegion(getX(), getY());
 		if ((region != null) && (!region.isActive()))