melee ai tweaks
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2024-08-15 10:46:12 -04:00
parent 61c5599265
commit 89a0df81a5
5 changed files with 150 additions and 63 deletions

View File

@ -14,7 +14,6 @@
+ fix the vibes
Stability
Movement penalty while swinging weapon
Only have ai strafe if its outside attack range
Ticketed randomizer node for BTs to more heavily weight attacking and waiting
Slow down strafe movement somehow

View File

@ -574,6 +574,8 @@ True behavior trees
- Colections
- Combat
Melee ai using BT framework
Server block nullchecks
Melee AI tweaks
# TODO

View File

@ -101,12 +101,14 @@ public class ServerBlockTree implements BehaviorTree {
this.stateTransitionUtil.reset();
setState(BlockState.COOLDOWN);
//activate hitboxes
List<Entity> attachedEntities = AttachUtils.getChildrenList(parent);
for(Entity currentAttached : attachedEntities){
if(HitboxCollectionState.hasHitboxState(currentAttached)){
HitboxCollectionState currentState = HitboxCollectionState.getHitboxState(currentAttached);
currentState.setActive(false);
currentState.setBlockOverride(false);
if(AttachUtils.hasChildren(parent)){
List<Entity> attachedEntities = AttachUtils.getChildrenList(parent);
for(Entity currentAttached : attachedEntities){
if(HitboxCollectionState.hasHitboxState(currentAttached)){
HitboxCollectionState currentState = HitboxCollectionState.getHitboxState(currentAttached);
currentState.setActive(false);
currentState.setBlockOverride(false);
}
}
}
}
@ -131,12 +133,14 @@ public class ServerBlockTree implements BehaviorTree {
} break;
case COOLDOWN: {
//activate hitboxes
List<Entity> attachedEntities = AttachUtils.getChildrenList(parent);
for(Entity currentAttached : attachedEntities){
if(HitboxCollectionState.hasHitboxState(currentAttached)){
HitboxCollectionState currentState = HitboxCollectionState.getHitboxState(currentAttached);
currentState.setActive(false);
currentState.setBlockOverride(false);
if(AttachUtils.hasChildren(parent)){
List<Entity> attachedEntities = AttachUtils.getChildrenList(parent);
for(Entity currentAttached : attachedEntities){
if(HitboxCollectionState.hasHitboxState(currentAttached)){
HitboxCollectionState currentState = HitboxCollectionState.getHitboxState(currentAttached);
currentState.setActive(false);
currentState.setBlockOverride(false);
}
}
}
this.stateTransitionUtil.simulate(BlockState.COOLDOWN);

View File

@ -44,7 +44,6 @@ public class TimerNode implements DecoratorNode {
this.child = child;
this.frameCount = frameCount;
this.timerId = Globals.aiManager.getTimerService().createTimer();
System.out.println("Created timer node with id " + this.timerId);
}
@Override

View File

@ -44,65 +44,148 @@ public class MeleeAITree {
//preconditions here
new HasWeaponNode(),
new MeleeTargetingNode(attackerTreeData.getAggroRange()),
//determine strategy
new RandomizerNode(
//wait
new SequenceNode(
new PublishStatusNode("Waiting"),
new FaceTargetNode(),
new TimerNode(new SucceederNode(null), 1200)
),
//move to hover distance
new SequenceNode(
new PublishStatusNode("Strafing right"),
new InverterNode(new OnFailureNode(
new WalkStartNode(MovementRelativeFacing.RIGHT),
new FailerNode(null)
)),
new FaceTargetNode(),
new TimerNode(new SucceederNode(null), 600),
new SucceederNode(new WalkStopNode())
),
//perform different actions based on distance to target
new SelectorNode(
//move from hover distance to melee range
//in attack range
new SequenceNode(
new PublishStatusNode("Strafing left"),
new InverterNode(new OnFailureNode(
new WalkStartNode(MovementRelativeFacing.LEFT),
new FailerNode(null)
)),
new FaceTargetNode(),
new TimerNode(new SucceederNode(null), 600),
new SucceederNode(new WalkStopNode())
),
//check prior to performing action
new MeleeRangeCheckNode(attackerTreeData,MeleeRangeCheckType.ATTACK),
//move towards target and attack
new SequenceNode(
new PublishStatusNode("Attack target"),
//move towards target if its outside of melee range
new UntilNode(AITreeNodeResult.SUCCESS,
//or
new SelectorNode(
//in range
new MeleeRangeCheckNode(attackerTreeData,MeleeRangeCheckType.ATTACK),
//approaching target
new SequenceNode(
new PublishStatusNode("Approaching target"),
new FaceTargetNode(),
new OnFailureNode(new IsMovingNode(), new WalkStartNode(MovementRelativeFacing.FORWARD)),
new MeleeRangeCheckNode(attackerTreeData,MeleeRangeCheckType.ATTACK)
)
)
),
//set state
//stop walking now that we're in range
new PublishStatusNode("Slowing down"),
new WalkStopNode(),
new UntilNode(AITreeNodeResult.FAILURE, new IsMovingNode()),
new PublishStatusNode("Attacking"),
new AttackStartNode()
//select action to perform
new RandomizerNode(
//wait
new SequenceNode(
new PublishStatusNode("Waiting"),
new FaceTargetNode(),
new TimerNode(new SucceederNode(null), 1200)
),
//attack
new SequenceNode(
new PublishStatusNode("Attacking"),
new FaceTargetNode(),
new AttackStartNode(),
new TimerNode(new SucceederNode(null), 150)
)
)
),
//in aggro range
new SequenceNode(
//check prior to performing action
new MeleeRangeCheckNode(attackerTreeData,MeleeRangeCheckType.AGGRO),
//select action to perform
new RandomizerNode(
//wait
new SequenceNode(
new PublishStatusNode("Waiting"),
new FaceTargetNode(),
new TimerNode(new SucceederNode(null), 1200)
),
//strafe to the right
new SequenceNode(
new PublishStatusNode("Strafing right"),
new InverterNode(new OnFailureNode(
new WalkStartNode(MovementRelativeFacing.RIGHT),
new FailerNode(null)
)),
new FaceTargetNode(),
new TimerNode(new SucceederNode(null), 600),
new SucceederNode(new WalkStopNode())
),
//strafe to the left
new SequenceNode(
new PublishStatusNode("Strafing left"),
new InverterNode(new OnFailureNode(
new WalkStartNode(MovementRelativeFacing.LEFT),
new FailerNode(null)
)),
new FaceTargetNode(),
new TimerNode(new SucceederNode(null), 600),
new SucceederNode(new WalkStopNode())
),
//approach target
//move towards target and attack
new SequenceNode(
new PublishStatusNode("Move into attack range"),
new FaceTargetNode(),
new SucceederNode(new WalkStartNode(MovementRelativeFacing.FORWARD)),
new TimerNode(new SucceederNode(null), 600)
)
)
)
)
// //determine strategy
// new RandomizerNode(
// //wait
// new SequenceNode(
// new PublishStatusNode("Waiting"),
// new FaceTargetNode(),
// new TimerNode(new SucceederNode(null), 1200)
// ),
// //move to hover distance
// new SequenceNode(
// new PublishStatusNode("Strafing right"),
// new InverterNode(new OnFailureNode(
// new WalkStartNode(MovementRelativeFacing.RIGHT),
// new FailerNode(null)
// )),
// new FaceTargetNode(),
// new TimerNode(new SucceederNode(null), 600),
// new SucceederNode(new WalkStopNode())
// ),
// //move from hover distance to melee range
// new SequenceNode(
// new PublishStatusNode("Strafing left"),
// new InverterNode(new OnFailureNode(
// new WalkStartNode(MovementRelativeFacing.LEFT),
// new FailerNode(null)
// )),
// new FaceTargetNode(),
// new TimerNode(new SucceederNode(null), 600),
// new SucceederNode(new WalkStopNode())
// ),
// //move towards target and attack
// new SequenceNode(
// new PublishStatusNode("Attack target"),
// //move towards target if its outside of melee range
// new UntilNode(AITreeNodeResult.SUCCESS,
// //or
// new SelectorNode(
// //in range
// new MeleeRangeCheckNode(attackerTreeData,MeleeRangeCheckType.ATTACK),
// //approaching target
// new SequenceNode(
// new PublishStatusNode("Approaching target"),
// new FaceTargetNode(),
// new OnFailureNode(new IsMovingNode(), new WalkStartNode(MovementRelativeFacing.FORWARD)),
// new MeleeRangeCheckNode(attackerTreeData,MeleeRangeCheckType.ATTACK)
// )
// )
// ),
// //stop walking now that we're in range
// new PublishStatusNode("Slowing down"),
// new WalkStopNode(),
// new UntilNode(AITreeNodeResult.FAILURE, new IsMovingNode()),
// new PublishStatusNode("Attacking"),
// new AttackStartNode()
// )
// )
);
}