diff --git a/src/main/java/electrosphere/net/synchronization/server/ServerSynchronizationManager.java b/src/main/java/electrosphere/net/synchronization/server/ServerSynchronizationManager.java index 0b5d38aa..1e7703ce 100644 --- a/src/main/java/electrosphere/net/synchronization/server/ServerSynchronizationManager.java +++ b/src/main/java/electrosphere/net/synchronization/server/ServerSynchronizationManager.java @@ -2,6 +2,8 @@ package electrosphere.net.synchronization.server; import electrosphere.entity.state.movement.speed.ServerWalkTree; +import electrosphere.logger.LoggerInterface; + import java.util.LinkedList; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; @@ -50,7 +52,11 @@ public class ServerSynchronizationManager { switch(message.getMessageSubtype()){ case CLIENTREQUESTBTREEACTION: { Entity entity = EntityLookupUtils.getEntityById(message.getentityId()); - updateEntityState(entity,message.getbTreeId(),message); + if(entity != null){ + updateEntityState(entity,message.getbTreeId(),message); + } else { + LoggerInterface.loggerNetworking.WARNING("Receiving packet from client to perform action for nonexistant entity! " + message.getentityId()); + } } break; case UPDATECLIENTSTATE: case UPDATECLIENTDOUBLESTATE: diff --git a/src/main/java/electrosphere/server/ai/nodes/actions/move/MoveStartNode.java b/src/main/java/electrosphere/server/ai/nodes/actions/move/MoveStartNode.java index 016e9bd6..ba1a3bc7 100644 --- a/src/main/java/electrosphere/server/ai/nodes/actions/move/MoveStartNode.java +++ b/src/main/java/electrosphere/server/ai/nodes/actions/move/MoveStartNode.java @@ -21,7 +21,7 @@ public class MoveStartNode implements AITreeNode { */ public MoveStartNode(MovementRelativeFacing facing){ if(facing == null){ - throw new IllegalArgumentException("Trying to create walk start tree with null facing!"); + throw new IllegalArgumentException("Trying to create move start tree node with null facing!"); } this.facing = facing; } diff --git a/src/main/java/electrosphere/server/ai/nodes/actions/move/WalkStartNode.java b/src/main/java/electrosphere/server/ai/nodes/actions/move/WalkStartNode.java new file mode 100644 index 00000000..25d788c5 --- /dev/null +++ b/src/main/java/electrosphere/server/ai/nodes/actions/move/WalkStartNode.java @@ -0,0 +1,30 @@ +package electrosphere.server.ai.nodes.actions.move; + +import electrosphere.entity.Entity; +import electrosphere.entity.state.movement.speed.ServerWalkTree; +import electrosphere.server.ai.blackboard.Blackboard; +import electrosphere.server.ai.nodes.AITreeNode; + +public class WalkStartNode implements AITreeNode { + + /** + * Constructor + */ + public WalkStartNode(){ + } + + @Override + public AITreeNodeResult evaluate(Entity entity, Blackboard blackboard) { + if(ServerWalkTree.getServerWalkTree(entity) != null){ + ServerWalkTree serverWalkTree = ServerWalkTree.getServerWalkTree(entity); + if(serverWalkTree.isWalking()){ + return AITreeNodeResult.SUCCESS; + } else { + serverWalkTree.start(); + return AITreeNodeResult.RUNNING; + } + } else { + return AITreeNodeResult.FAILURE; + } + } +} diff --git a/src/main/java/electrosphere/server/ai/nodes/actions/move/WalkStopNode.java b/src/main/java/electrosphere/server/ai/nodes/actions/move/WalkStopNode.java new file mode 100644 index 00000000..ae0fc2d5 --- /dev/null +++ b/src/main/java/electrosphere/server/ai/nodes/actions/move/WalkStopNode.java @@ -0,0 +1,30 @@ +package electrosphere.server.ai.nodes.actions.move; + +import electrosphere.entity.Entity; +import electrosphere.entity.state.movement.speed.ServerWalkTree; +import electrosphere.server.ai.blackboard.Blackboard; +import electrosphere.server.ai.nodes.AITreeNode; + +public class WalkStopNode implements AITreeNode { + + /** + * Constructor + */ + public WalkStopNode(){ + } + + @Override + public AITreeNodeResult evaluate(Entity entity, Blackboard blackboard) { + if(ServerWalkTree.getServerWalkTree(entity) != null){ + ServerWalkTree serverGroundMovementTree = ServerWalkTree.getServerWalkTree(entity); + if(serverGroundMovementTree.isWalking()){ + serverGroundMovementTree.stop(); + return AITreeNodeResult.RUNNING; + } else { + return AITreeNodeResult.SUCCESS; + } + } else { + return AITreeNodeResult.FAILURE; + } + } +} diff --git a/src/main/java/electrosphere/server/ai/trees/creature/melee/MeleeAITree.java b/src/main/java/electrosphere/server/ai/trees/creature/melee/MeleeAITree.java index 387625ee..2e69bf86 100644 --- a/src/main/java/electrosphere/server/ai/trees/creature/melee/MeleeAITree.java +++ b/src/main/java/electrosphere/server/ai/trees/creature/melee/MeleeAITree.java @@ -11,6 +11,8 @@ import electrosphere.server.ai.nodes.actions.combat.MeleeRangeCheckNode.MeleeRan import electrosphere.server.ai.nodes.actions.move.FaceTargetNode; import electrosphere.server.ai.nodes.actions.move.MoveStartNode; import electrosphere.server.ai.nodes.actions.move.MoveStopNode; +import electrosphere.server.ai.nodes.actions.move.WalkStartNode; +import electrosphere.server.ai.nodes.actions.move.WalkStopNode; import electrosphere.server.ai.nodes.checks.IsMovingNode; import electrosphere.server.ai.nodes.checks.equip.HasWeaponNode; import electrosphere.server.ai.nodes.meta.collections.RandomizerNode; @@ -65,14 +67,20 @@ public class MeleeAITree { new SequenceNode( new PublishStatusNode("Waiting"), new FaceTargetNode(), - new TimerNode(new SucceederNode(null), 1200) + new TimerNode(new SucceederNode(null), 600) + ), + //wait + new SequenceNode( + new PublishStatusNode("Waiting"), + new FaceTargetNode(), + new TimerNode(new SucceederNode(null), 300) ), //attack new SequenceNode( new PublishStatusNode("Attacking"), new FaceTargetNode(), new AttackStartNode(), - new TimerNode(new SucceederNode(null), 150) + new TimerNode(new SucceederNode(null), 300) ) ) ), @@ -95,24 +103,28 @@ public class MeleeAITree { //strafe to the right new SequenceNode( new PublishStatusNode("Strafing right"), + new WalkStartNode(), new InverterNode(new OnFailureNode( new MoveStartNode(MovementRelativeFacing.RIGHT), new FailerNode(null) )), new FaceTargetNode(), new TimerNode(new SucceederNode(null), 600), + new SucceederNode(new WalkStopNode()), new SucceederNode(new MoveStopNode()) ), //strafe to the left new SequenceNode( new PublishStatusNode("Strafing left"), + new WalkStartNode(), new InverterNode(new OnFailureNode( new MoveStartNode(MovementRelativeFacing.LEFT), new FailerNode(null) )), new FaceTargetNode(), new TimerNode(new SucceederNode(null), 600), + new SucceederNode(new WalkStopNode()), new SucceederNode(new MoveStopNode()) ),