瀏覽代碼

BETA: WalkingManager related fixes
* More informative debug messages
* Disable ReturnHome task for walking L2GuardInstance
* Reported by: Yunaleska
* Tested by: Yunaleska
* Reviewed by: UnAfraid

VlLight 11 年之前
父節點
當前提交
cc008b1780

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

@@ -540,21 +540,21 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
 			{
 				if (((L2MonsterInstance) npc).hasMinions())
 				{
-					((L2MonsterInstance) npc).getMinionList().deleteReusedMinions();
-				}
-			}
-		}
-		
-		// Check if the actor is a L2GuardInstance
-		if (npc instanceof L2GuardInstance)
-		{
-			// Order to the L2GuardInstance to return to its home location because there's no target to attack
-			((L2GuardInstance) npc).returnHome();
-		}
-		
-		// If this is a festival monster, then it remains in the same location.
-		if (npc instanceof L2FestivalMonsterInstance)
-		{
+					((L2MonsterInstance) npc).getMinionList().deleteReusedMinions();
+				}
+			}
+		}
+		
+		// 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();
+		}
+		
+		// If this is a festival monster, then it remains in the same location.
+		if (npc instanceof L2FestivalMonsterInstance)
+		{
 			return;
 		}
 		

+ 2 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/WalkingManager.java

@@ -270,7 +270,7 @@ public class WalkingManager extends DocumentParser
 					
 					if (!npc.isInsideRadius(node, 3000, true, false))
 					{
-						String message = "Route '" + routeName + "': NPC is too far from starting point, walking will not start";
+						String message = "Route '" + routeName + "': NPC (id=" + npc.getNpcId() + ", x=" + npc.getX() + ", y=" + npc.getY() + ", z=" + npc.getZ() + ") is too far from starting point (node x=" + node.getX() + ", y=" + node.getY() + ", z=" + node.getZ() + ", range=" + npc.getDistanceSq(node.getX(), node.getY(), node.getZ()) + "), walking will not start";
 						_log.warning(getClass().getSimpleName() + ": " + message);
 						npc.sendDebugMessage(message);
 						return;
@@ -333,7 +333,7 @@ public class WalkingManager extends DocumentParser
 				}
 				else
 				{
-					npc.sendDebugMessage("Failed to continue moving along route '" + routeName + "' (wrong AI state)");
+					npc.sendDebugMessage("Failed to continue moving along route '" + routeName + "' (wrong AI state - " + npc.getAI().getIntention() + ")");
 				}
 			}
 		}

+ 8 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2GuardInstance.java

@@ -19,6 +19,7 @@
 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;
@@ -46,6 +47,8 @@ public class L2GuardInstance extends L2Attackable
 	
 	private static final int RETURN_INTERVAL = 60000;
 	
+	private Future<?> _returnTask;
+	
 	public class ReturnTask implements Runnable
 	{
 		@Override
@@ -73,8 +76,6 @@ public class L2GuardInstance extends L2Attackable
 	{
 		super(objectId, template);
 		setInstanceType(InstanceType.L2GuardInstance);
-		
-		ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new ReturnTask(), RETURN_INTERVAL, RETURN_INTERVAL + Rnd.nextInt(60000));
 	}
 	
 	@Override
@@ -121,6 +122,11 @@ 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()))

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/knownlist/GuardKnownList.java

@@ -93,7 +93,7 @@ public class GuardKnownList extends AttackableKnownList
 		if (getActiveChar().getAggroList().isEmpty())
 		{
 			// Set the L2GuardInstance to AI_INTENTION_IDLE
-			if (getActiveChar().hasAI())
+			if (getActiveChar().hasAI() && !getActiveChar().isWalker())
 			{
 				getActiveChar().getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null);
 			}

+ 2 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/knownlist/NpcKnownList.java

@@ -26,6 +26,7 @@ import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ai.CtrlIntention;
 import com.l2jserver.gameserver.instancemanager.WalkingManager;
 import com.l2jserver.gameserver.model.L2Object;
+import com.l2jserver.gameserver.model.L2Object.InstanceType;
 import com.l2jserver.gameserver.model.actor.L2Attackable;
 import com.l2jserver.gameserver.model.actor.L2Character;
 import com.l2jserver.gameserver.model.actor.L2Npc;
@@ -133,7 +134,7 @@ public class NpcKnownList extends CharKnownList
 					{
 						for (L2PcInstance pl : players)
 						{
-							if (!pl.isDead() && !pl.isInvul() && pl.isInsideRadius(monster, monster.getAggroRange(), true, false))
+							if (!pl.isDead() && !pl.isInvul() && pl.isInsideRadius(monster, monster.getAggroRange(), true, false) && (monster.isMonster() || (monster.isInstanceType(InstanceType.L2GuardInstance) && (pl.getKarma() > 0))))
 							{
 								// Send aggroRangeEnter
 								if (monster.getHating(pl) == 0)