Walker improvements.

This commit is contained in:
MobiusDev
2016-08-24 21:20:19 +00:00
parent 65b99da7af
commit 3a550abff7
4 changed files with 45 additions and 48 deletions

View File

@ -31,11 +31,10 @@ public class L2WalkRoute
public L2WalkRoute(String name, List<L2NpcWalkerNode> route, boolean repeat, boolean once, byte repeatType)
{
_name = name;
_nodeList = route;
_repeatType = repeatType;
_repeatWalk = ((_repeatType >= 0) && (_repeatType <= 2)) && repeat;
_repeatWalk = (_repeatType >= 0) && (_repeatType <= 2) && repeat;
}
public String getName()

View File

@ -25,13 +25,12 @@ import com.l2jmobius.gameserver.model.events.EventDispatcher;
import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcMoveRouteFinished;
/**
* Holds info about current walk progress
* Holds info about current walk progress.
* @author GKR, UnAfraid
*/
public class WalkInfo
{
private final String _routeName;
private ScheduledFuture<?> _walkCheckTask;
private boolean _blocked = false;
private boolean _suspended = false;
@ -64,9 +63,8 @@ public class WalkInfo
/**
* Calculate next node for this WalkInfo and send debug message from given npc
* @param npc NPC to debug message to be sent from
* @return
*/
public boolean calculateNextNode(L2Npc npc)
public synchronized void calculateNextNode(L2Npc npc)
{
// Check this first, within the bounds of random moving, we have no conception of "first" or "last" node
if (getRoute().getRepeatType() == WalkingManager.REPEAT_RANDOM)
@ -101,7 +99,7 @@ public class WalkInfo
if (!getRoute().repeatWalk())
{
WalkingManager.getInstance().cancelMoving(npc);
return false;
return;
}
switch (getRoute().getRepeatType())
@ -125,14 +123,12 @@ public class WalkInfo
}
}
}
else if (_currentNode == -1) // First node arrived, when direction is first <-- last
else if (_currentNode == WalkingManager.NO_REPEAT) // First node arrived, when direction is first <-- last
{
_currentNode = 1;
_forward = true;
}
}
return true;
}
/**
@ -222,4 +218,10 @@ public class WalkInfo
{
_walkCheckTask = val;
}
@Override
public String toString()
{
return "WalkInfo [_routeName=" + _routeName + ", _walkCheckTask=" + _walkCheckTask + ", _blocked=" + _blocked + ", _suspended=" + _suspended + ", _stoppedByAttack=" + _stoppedByAttack + ", _currentNode=" + _currentNode + ", _forward=" + _forward + ", _lastActionTime=" + _lastActionTime + "]";
}
}

View File

@ -38,6 +38,7 @@ public class ArrivedTask implements Runnable
@Override
public void run()
{
_npc.broadcastInfo();
_walk.setBlocked(false);
WalkingManager.getInstance().startMoving(_npc, _walk.getRoute().getName());
}