All pastes #50794 Raw Edit

Anonymous

public text v1 · immutable
#50794 ·published 2006-04-23 22:49 UTC
rendered paste body
Index: D:/workspace/GameServer_tmp/java/net/sf/l2j/gameserver/ai/L2SiegeGuardAI.java
===================================================================
--- D:/workspace/GameServer_tmp/java/net/sf/l2j/gameserver/ai/L2SiegeGuardAI.java	(revision 218)
+++ D:/workspace/GameServer_tmp/java/net/sf/l2j/gameserver/ai/L2SiegeGuardAI.java	(working copy)
@@ -21,6 +21,7 @@
 import static net.sf.l2j.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE;
 import static net.sf.l2j.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
 import static net.sf.l2j.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
+import static net.sf.l2j.gameserver.ai.CtrlIntention.AI_INTENTION_FOLLOW;
 
 import java.util.concurrent.Future;
 import java.util.logging.Logger;
@@ -40,6 +41,7 @@
 import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
 import net.sf.l2j.gameserver.model.actor.instance.L2SiegeGuardInstance;
+import net.sf.l2j.gameserver.model.actor.instance.L2SummonInstance;
 
 
 /**
@@ -133,6 +135,10 @@
         // Check if the target isn't dead
         if (target.isAlikeDead()) return false;
         
+        // Get the owner if the target is a summon
+        if (target instanceof L2SummonInstance)
+         target = ((L2SummonInstance)target).getOwner();
+        
         return (
                 target instanceof L2PcInstance &&
                 !((L2PcInstance)target).isInvul() &&        //   Not invul and
@@ -163,6 +169,12 @@
             {
                 L2Attackable npc = (L2Attackable)_actor;
                 
+                // remove from knownlist all dead or alikedead players
+                for(L2PcInstance in:npc.getKnownList().getKnownPlayers())
+                {
+                  if(in.isAlikeDead()) npc.getKnownList().removeKnownObject(in);
+                }
+
                 // If its _knownPlayer isn't empty set the Intention to AI_INTENTION_ACTIVE
                 if(npc.getKnownList().getKnownPlayers().size() > 0)
                     intention = AI_INTENTION_ACTIVE;
@@ -564,7 +576,16 @@
         // Check if the actor can't use skills and if a thinking action isn't already in progress
         if (thinking || _actor.isAllSkillsDisabled())
             return;
-        
+
+        if((!_actor.isVisible()) || (!_actor.hasAI()))
+            setIntention(AI_INTENTION_IDLE);
+     
+        if((getIntention() == AI_INTENTION_FOLLOW) && (_actor.getKnownList().getKnownPlayers().isEmpty()))
+            setIntention(AI_INTENTION_IDLE);
+          
+        if(getIntention() == AI_INTENTION_IDLE)
+          return;
+
         // Start thinking action
         thinking = true;
         
@@ -597,7 +618,14 @@
      */
     protected void onEvtAttacked(L2Character attacker)
     {
-        // Calculate the attack timeout
+        if(attacker == null) 
+        {
+           _log.warning("L2SiegeGuardAI.java: onEvtAttacked(L2Character attacker)   ->  attacker=null, RETURNING with setting attacktimeout");
+           _attack_timeout = GameTimeController.getGameTicks();
+           return;
+        }        
+
+    // Calculate the attack timeout
         _attack_timeout = MAX_ATTACK_TIMEOUT + GameTimeController.getGameTicks();
         
         // Set the _globalAggro to 0 to permit attack even just after spawn