ai tweaks

This commit is contained in:
austin 2024-08-15 13:14:02 -04:00
parent 8fcd0a8f64
commit 7775cb5e24
5 changed files with 82 additions and 4 deletions

View File

@ -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:

View File

@ -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;
}

View File

@ -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;
}
}
}

View File

@ -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;
}
}
}

View File

@ -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())
),