Skip to content

Instantly share code, notes, and snippets.

@VlLight
Last active December 19, 2015 23:08
Show Gist options
  • Save VlLight/6032523 to your computer and use it in GitHub Desktop.
Save VlLight/6032523 to your computer and use it in GitHub Desktop.
Walking Manager fixes for L2Guards
Index: java/com/l2jserver/gameserver/ai/L2AttackableAI.java
===================================================================
--- java/com/l2jserver/gameserver/ai/L2AttackableAI.java (revision 6097)
+++ java/com/l2jserver/gameserver/ai/L2AttackableAI.java (working copy)
@@ -543,15 +543,15 @@
((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();
}
- // 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)
{
Index: java/com/l2jserver/gameserver/instancemanager/WalkingManager.java
===================================================================
--- java/com/l2jserver/gameserver/instancemanager/WalkingManager.java (revision 6097)
+++ java/com/l2jserver/gameserver/instancemanager/WalkingManager.java (working copy)
@@ -330,13 +330,13 @@
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, node);
walk.setBlocked(false);
walk.setStoppedByAttack(false);
- }
- else
- {
- npc.sendDebugMessage("Failed to continue moving along route '" + routeName + "' (wrong AI state)");
- }
- }
- }
+ }
+ else
+ {
+ npc.sendDebugMessage("Failed to continue moving along route '" + routeName + "' (wrong AI state - " + npc.getAI().getIntention() + ")");
+ }
+ }
+ }
}
/**
Index: java/com/l2jserver/gameserver/model/actor/instance/L2GuardInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2GuardInstance.java (revision 6097)
+++ java/com/l2jserver/gameserver/model/actor/instance/L2GuardInstance.java (working copy)
@@ -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 @@
private static final int RETURN_INTERVAL = 60000;
+ private Future<?> _returnTask;
+
public class ReturnTask implements Runnable
{
@Override
@@ -73,8 +76,6 @@
{
super(objectId, template);
setInstanceType(InstanceType.L2GuardInstance);
-
- ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new ReturnTask(), RETURN_INTERVAL, RETURN_INTERVAL + Rnd.nextInt(60000));
}
@Override
@@ -121,6 +122,11 @@
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()))
Index: java/com/l2jserver/gameserver/model/actor/knownlist/GuardKnownList.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/knownlist/GuardKnownList.java (revision 6097)
+++ java/com/l2jserver/gameserver/model/actor/knownlist/GuardKnownList.java (working copy)
@@ -90,13 +90,13 @@
}
// Check if the aggression list of this guard is empty.
- if (getActiveChar().getAggroList().isEmpty())
- {
- // Set the L2GuardInstance to AI_INTENTION_IDLE
- if (getActiveChar().hasAI())
- {
- getActiveChar().getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null);
- }
+ if (getActiveChar().getAggroList().isEmpty())
+ {
+ // Set the L2GuardInstance to AI_INTENTION_IDLE
+ if (getActiveChar().hasAI() && !getActiveChar().isWalker())
+ {
+ getActiveChar().getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null);
+ }
}
return true;
Index: java/com/l2jserver/gameserver/model/actor/knownlist/NpcKnownList.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/knownlist/NpcKnownList.java (revision 6097)
+++ java/com/l2jserver/gameserver/model/actor/knownlist/NpcKnownList.java (working copy)
@@ -23,12 +23,13 @@
import java.util.concurrent.ScheduledFuture;
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.actor.L2Attackable;
-import com.l2jserver.gameserver.model.actor.L2Character;
-import com.l2jserver.gameserver.model.actor.L2Npc;
+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;
import com.l2jserver.gameserver.model.actor.instance.L2FestivalGuideInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.quest.Quest;
@@ -130,13 +131,13 @@
{
final Collection<L2PcInstance> players = getKnownPlayers().values();
if (players != null)
- {
- for (L2PcInstance pl : players)
- {
- if (!pl.isDead() && !pl.isInvul() && pl.isInsideRadius(monster, monster.getAggroRange(), true, false))
- {
- // Send aggroRangeEnter
- if (monster.getHating(pl) == 0)
+ {
+ for (L2PcInstance pl : players)
+ {
+ 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)
{
monster.addDamageHate(pl, 0, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment