ai tweaks
This commit is contained in:
parent
8fcd0a8f64
commit
7775cb5e24
@ -2,6 +2,8 @@ package electrosphere.net.synchronization.server;
|
|||||||
|
|
||||||
|
|
||||||
import electrosphere.entity.state.movement.speed.ServerWalkTree;
|
import electrosphere.entity.state.movement.speed.ServerWalkTree;
|
||||||
|
import electrosphere.logger.LoggerInterface;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
@ -50,7 +52,11 @@ public class ServerSynchronizationManager {
|
|||||||
switch(message.getMessageSubtype()){
|
switch(message.getMessageSubtype()){
|
||||||
case CLIENTREQUESTBTREEACTION: {
|
case CLIENTREQUESTBTREEACTION: {
|
||||||
Entity entity = EntityLookupUtils.getEntityById(message.getentityId());
|
Entity entity = EntityLookupUtils.getEntityById(message.getentityId());
|
||||||
|
if(entity != null){
|
||||||
updateEntityState(entity,message.getbTreeId(),message);
|
updateEntityState(entity,message.getbTreeId(),message);
|
||||||
|
} else {
|
||||||
|
LoggerInterface.loggerNetworking.WARNING("Receiving packet from client to perform action for nonexistant entity! " + message.getentityId());
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
case UPDATECLIENTSTATE:
|
case UPDATECLIENTSTATE:
|
||||||
case UPDATECLIENTDOUBLESTATE:
|
case UPDATECLIENTDOUBLESTATE:
|
||||||
|
|||||||
@ -21,7 +21,7 @@ public class MoveStartNode implements AITreeNode {
|
|||||||
*/
|
*/
|
||||||
public MoveStartNode(MovementRelativeFacing facing){
|
public MoveStartNode(MovementRelativeFacing facing){
|
||||||
if(facing == null){
|
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;
|
this.facing = facing;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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.FaceTargetNode;
|
||||||
import electrosphere.server.ai.nodes.actions.move.MoveStartNode;
|
import electrosphere.server.ai.nodes.actions.move.MoveStartNode;
|
||||||
import electrosphere.server.ai.nodes.actions.move.MoveStopNode;
|
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.IsMovingNode;
|
||||||
import electrosphere.server.ai.nodes.checks.equip.HasWeaponNode;
|
import electrosphere.server.ai.nodes.checks.equip.HasWeaponNode;
|
||||||
import electrosphere.server.ai.nodes.meta.collections.RandomizerNode;
|
import electrosphere.server.ai.nodes.meta.collections.RandomizerNode;
|
||||||
@ -65,14 +67,20 @@ public class MeleeAITree {
|
|||||||
new SequenceNode(
|
new SequenceNode(
|
||||||
new PublishStatusNode("Waiting"),
|
new PublishStatusNode("Waiting"),
|
||||||
new FaceTargetNode(),
|
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
|
//attack
|
||||||
new SequenceNode(
|
new SequenceNode(
|
||||||
new PublishStatusNode("Attacking"),
|
new PublishStatusNode("Attacking"),
|
||||||
new FaceTargetNode(),
|
new FaceTargetNode(),
|
||||||
new AttackStartNode(),
|
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
|
//strafe to the right
|
||||||
new SequenceNode(
|
new SequenceNode(
|
||||||
new PublishStatusNode("Strafing right"),
|
new PublishStatusNode("Strafing right"),
|
||||||
|
new WalkStartNode(),
|
||||||
new InverterNode(new OnFailureNode(
|
new InverterNode(new OnFailureNode(
|
||||||
new MoveStartNode(MovementRelativeFacing.RIGHT),
|
new MoveStartNode(MovementRelativeFacing.RIGHT),
|
||||||
new FailerNode(null)
|
new FailerNode(null)
|
||||||
)),
|
)),
|
||||||
new FaceTargetNode(),
|
new FaceTargetNode(),
|
||||||
new TimerNode(new SucceederNode(null), 600),
|
new TimerNode(new SucceederNode(null), 600),
|
||||||
|
new SucceederNode(new WalkStopNode()),
|
||||||
new SucceederNode(new MoveStopNode())
|
new SucceederNode(new MoveStopNode())
|
||||||
),
|
),
|
||||||
|
|
||||||
//strafe to the left
|
//strafe to the left
|
||||||
new SequenceNode(
|
new SequenceNode(
|
||||||
new PublishStatusNode("Strafing left"),
|
new PublishStatusNode("Strafing left"),
|
||||||
|
new WalkStartNode(),
|
||||||
new InverterNode(new OnFailureNode(
|
new InverterNode(new OnFailureNode(
|
||||||
new MoveStartNode(MovementRelativeFacing.LEFT),
|
new MoveStartNode(MovementRelativeFacing.LEFT),
|
||||||
new FailerNode(null)
|
new FailerNode(null)
|
||||||
)),
|
)),
|
||||||
new FaceTargetNode(),
|
new FaceTargetNode(),
|
||||||
new TimerNode(new SucceederNode(null), 600),
|
new TimerNode(new SucceederNode(null), 600),
|
||||||
|
new SucceederNode(new WalkStopNode()),
|
||||||
new SucceederNode(new MoveStopNode())
|
new SucceederNode(new MoveStopNode())
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user