NPC refactor (#10122)
Co-authored-by: metalgearsloth <metalgearsloth@gmail.com>
This commit is contained in:
109
Resources/Prototypes/NPCs/attack.yml
Normal file
109
Resources/Prototypes/NPCs/attack.yml
Normal file
@@ -0,0 +1,109 @@
|
||||
# -- Ranged --
|
||||
# Tries to shoot a target in LOS in range.
|
||||
- type: htnCompound
|
||||
id: TurretCompound
|
||||
branches:
|
||||
- tasks:
|
||||
- id: PickRangedTargetPrimitive
|
||||
- id: RangedAttackTargetPrimitive
|
||||
- tasks:
|
||||
- id: IdleSpinCompound
|
||||
|
||||
# Tries to shoot a target at range.
|
||||
- type: htnCompound
|
||||
id: RangedCombatCompound
|
||||
branches:
|
||||
- tasks:
|
||||
- id: PickRangedTargetPrimitive
|
||||
- id: RangedAttackTargetCompound
|
||||
|
||||
# Tries to ranged attack our target.
|
||||
- type: htnCompound
|
||||
id: RangedAttackTargetCompound
|
||||
preconditions:
|
||||
- !type:KeyExistsPrecondition
|
||||
key: CombatTarget
|
||||
branches:
|
||||
# Keep hitting them if they're in LOS
|
||||
- tasks:
|
||||
- id: RangedAttackTargetPrimitive
|
||||
|
||||
# Move to range and hit them
|
||||
- tasks:
|
||||
- id: MoveToCombatTargetPrimitive
|
||||
- id: RangedAttackTargetPrimitive
|
||||
|
||||
|
||||
- type: htnPrimitive
|
||||
id: PickRangedTargetPrimitive
|
||||
operator: !type:PickRangedTargetOperator
|
||||
|
||||
# Attacks the specified target if they're in LOS.
|
||||
- type: htnPrimitive
|
||||
id: RangedAttackTargetPrimitive
|
||||
operator: !type:RangedOperator
|
||||
targetKey: CombatTarget
|
||||
preconditions:
|
||||
- !type:KeyExistsPrecondition
|
||||
key: CombatTarget
|
||||
- !type:TargetInRangePrecondition
|
||||
targetKey: CombatTarget
|
||||
# TODO: Non-scuffed
|
||||
rangeKey: RangedRange
|
||||
- !type:TargetInLOSPrecondition
|
||||
targetKey: CombatTarget
|
||||
rangeKey: RangedRange
|
||||
|
||||
|
||||
# -- Melee --
|
||||
# Selects a target in melee and tries to attack it.
|
||||
- type: htnCompound
|
||||
id: MeleeCombatCompound
|
||||
branches:
|
||||
# Unarmed combat
|
||||
- tasks:
|
||||
- id: PickMeleeTargetPrimitive
|
||||
- id: MeleeAttackTargetCompound
|
||||
|
||||
# Tries to melee attack our target.
|
||||
- type: htnCompound
|
||||
id: MeleeAttackTargetCompound
|
||||
preconditions:
|
||||
- !type:KeyExistsPrecondition
|
||||
key: CombatTarget
|
||||
branches:
|
||||
# Keep hitting them if they're in range
|
||||
- tasks:
|
||||
- id: MeleeAttackTargetPrimitive
|
||||
|
||||
# Move to melee range and hit them
|
||||
- tasks:
|
||||
- id: MoveToCombatTargetPrimitive
|
||||
- id: MeleeAttackTargetPrimitive
|
||||
|
||||
|
||||
- type: htnPrimitive
|
||||
id: PickMeleeTargetPrimitive
|
||||
operator: !type:PickMeleeTargetOperator
|
||||
|
||||
# Attacks the specified target if they're in range.
|
||||
- type: htnPrimitive
|
||||
id: MeleeAttackTargetPrimitive
|
||||
operator: !type:MeleeOperator
|
||||
targetKey: CombatTarget
|
||||
preconditions:
|
||||
- !type:KeyExistsPrecondition
|
||||
key: CombatTarget
|
||||
- !type:TargetInRangePrecondition
|
||||
targetKey: CombatTarget
|
||||
rangeKey: MeleeRange
|
||||
|
||||
# Moves the owner into range of the combat target.
|
||||
- type: htnPrimitive
|
||||
id: MoveToCombatTargetPrimitive
|
||||
operator: !type:MoveToOperator
|
||||
pathfindInPlanning: true
|
||||
removeKeyOnFinish: false
|
||||
targetKey: CombatTargetCoordinates
|
||||
pathfindKey: CombatTargetPathfind
|
||||
rangeKey: MeleeRange
|
||||
@@ -1,57 +0,0 @@
|
||||
- type: behaviorSet
|
||||
id: Clothing
|
||||
actions:
|
||||
- EquipAnyHeadExp
|
||||
- EquipAnyOuterClothingExp
|
||||
- EquipAnyGlovesExp
|
||||
- EquipAnyShoesExp
|
||||
- PickUpAnyNearbyHeadExp
|
||||
- PickUpAnyNearbyOuterClothingExp
|
||||
- PickUpAnyNearbyGlovesExp
|
||||
- PickUpAnyNearbyShoesExp
|
||||
|
||||
- type: behaviorSet
|
||||
id: Hunger
|
||||
actions:
|
||||
- PickUpNearbyFoodExp
|
||||
- UseFoodInInventoryExp
|
||||
|
||||
- type: behaviorSet
|
||||
id: Idle
|
||||
actions:
|
||||
- CloseLastEntityStorage
|
||||
- WanderAndWait
|
||||
|
||||
- type: behaviorSet
|
||||
id: PathingDummy
|
||||
actions:
|
||||
- MoveRightAndLeftTen
|
||||
|
||||
- type: behaviorSet
|
||||
id: CleanBot
|
||||
actions:
|
||||
- BufferNearbyPuddlesExp
|
||||
- WanderAndWait
|
||||
|
||||
- type: behaviorSet
|
||||
id: MediBot
|
||||
actions:
|
||||
- InjectNearbyExp
|
||||
|
||||
- type: behaviorSet
|
||||
id: Spirate
|
||||
actions:
|
||||
- EquipMeleeExp
|
||||
- PickUpMeleeWeaponExp
|
||||
- MeleeAttackNearbyExp
|
||||
|
||||
- type: behaviorSet
|
||||
id: Thirst
|
||||
actions:
|
||||
- PickUpNearbyDrinkExp
|
||||
- UseDrinkInInventoryExp
|
||||
|
||||
- type: behaviorSet
|
||||
id: UnarmedAttackHostiles
|
||||
actions:
|
||||
- UnarmedAttackNearbyHostilesExp
|
||||
31
Resources/Prototypes/NPCs/cleanbot.yml
Normal file
31
Resources/Prototypes/NPCs/cleanbot.yml
Normal file
@@ -0,0 +1,31 @@
|
||||
- type: htnCompound
|
||||
id: CleanbotCompound
|
||||
branches:
|
||||
- tasks:
|
||||
- id: BufferNearbyPuddlesCompound
|
||||
- tasks:
|
||||
- id: IdleCompound
|
||||
|
||||
# Picks a random puddle in range to move to and idle
|
||||
- type: htnCompound
|
||||
id: BufferNearbyPuddlesCompound
|
||||
branches:
|
||||
- tasks:
|
||||
- id: PickPuddlePrimitive
|
||||
- id: MoveToAccessiblePrimitive
|
||||
- id: SetIdleTimePrimitive
|
||||
- id: WaitIdleTimePrimitive
|
||||
|
||||
|
||||
- type: htnPrimitive
|
||||
id: PickPuddlePrimitive
|
||||
operator: !type:PickAccessibleComponentOperator
|
||||
rangeKey: BufferRange
|
||||
targetKey: MovementTarget
|
||||
component: Puddle
|
||||
|
||||
- type: htnPrimitive
|
||||
id: SetIdleTimePrimitive
|
||||
operator: !type:SetFloatOperator
|
||||
targetKey: IdleTime
|
||||
amount: 3
|
||||
55
Resources/Prototypes/NPCs/follow.yml
Normal file
55
Resources/Prototypes/NPCs/follow.yml
Normal file
@@ -0,0 +1,55 @@
|
||||
# There are limitations to this ATM. The pathfinder is too slow to check accessibility well
|
||||
# and reachable only takes in an entity so sometimes the follow idle spot is outside of the follow range
|
||||
|
||||
# Follows the specified target.
|
||||
- type: htnCompound
|
||||
id: FollowCompound
|
||||
branches:
|
||||
# Head to follow target
|
||||
- tasks:
|
||||
- id: FollowPrimitive
|
||||
# Keep idling near follow target
|
||||
- tasks:
|
||||
- id: WaitFollowPrimitive
|
||||
# Pick a new idle spot near the follow target
|
||||
- tasks:
|
||||
- id: PickAccessibleNearFollowPrimitive
|
||||
- id: IdleNearFollowPrimitive
|
||||
- id: RandomIdleTimePrimitive
|
||||
- id: WaitFollowPrimitive
|
||||
|
||||
|
||||
- type: htnPrimitive
|
||||
id: WaitFollowPrimitive
|
||||
operator: !type:WaitOperator
|
||||
key: IdleTime
|
||||
preconditions:
|
||||
- !type:KeyExistsPrecondition
|
||||
key: IdleTime
|
||||
- !type:CoordinatesInRangePrecondition
|
||||
targetKey: FollowTarget
|
||||
rangeKey: FollowRange
|
||||
|
||||
- type: htnPrimitive
|
||||
id: PickAccessibleNearFollowPrimitive
|
||||
operator: !type:PickAccessibleOperator
|
||||
# originKey: FollowTarget
|
||||
rangeKey: FollowCloseRange
|
||||
targetKey: FollowIdleTarget
|
||||
|
||||
- type: htnPrimitive
|
||||
id: IdleNearFollowPrimitive
|
||||
operator: !type:MoveToOperator
|
||||
targetKey: FollowIdleTarget
|
||||
|
||||
- type: htnPrimitive
|
||||
id: FollowPrimitive
|
||||
operator: !type:MoveToOperator
|
||||
pathfindInPlanning: true
|
||||
targetKey: FollowTarget
|
||||
rangeKey: FollowCloseRange
|
||||
removeKeyOnFinish: false
|
||||
preconditions:
|
||||
- !type:CoordinatesNotInRangePrecondition
|
||||
targetKey: FollowTarget
|
||||
rangeKey: FollowRange
|
||||
68
Resources/Prototypes/NPCs/idle.yml
Normal file
68
Resources/Prototypes/NPCs/idle.yml
Normal file
@@ -0,0 +1,68 @@
|
||||
# Picks a random location for the NPC to move to and idle.
|
||||
- type: htnCompound
|
||||
id: IdleCompound
|
||||
branches:
|
||||
- tasks:
|
||||
- id: WaitIdleTimePrimitive
|
||||
# Pick a new spot and wait there.
|
||||
- tasks:
|
||||
- id: PickAccessiblePrimitive
|
||||
- id: MoveToAccessiblePrimitive
|
||||
- id: RandomIdleTimePrimitive
|
||||
- id: WaitIdleTimePrimitive
|
||||
preconditions:
|
||||
- !type:BuckledPrecondition
|
||||
isBuckled: false
|
||||
- !type:PulledPrecondition
|
||||
isPulled: false
|
||||
|
||||
# Spin to a random rotation and idle.
|
||||
- type: htnCompound
|
||||
id: IdleSpinCompound
|
||||
branches:
|
||||
- tasks:
|
||||
- id: WaitIdleTimePrimitive
|
||||
# Pick a new angle and spin there
|
||||
- tasks:
|
||||
- id: PickRandomRotationPrimitive
|
||||
- id: RotateToTargetPrimitive
|
||||
- id: RandomIdleTimePrimitive
|
||||
- id: WaitIdleTimePrimitive
|
||||
|
||||
|
||||
# Primitives
|
||||
- type: htnPrimitive
|
||||
id: PickRandomRotationPrimitive
|
||||
operator: !type:PickRandomRotationOperator
|
||||
targetKey: RotateTarget
|
||||
|
||||
- type: htnPrimitive
|
||||
id: RotateToTargetPrimitive
|
||||
operator: !type:RotateToTargetOperator
|
||||
targetKey: RotateTarget
|
||||
|
||||
- type: htnPrimitive
|
||||
id: PickAccessiblePrimitive
|
||||
operator: !type:PickAccessibleOperator
|
||||
rangeKey: IdleRange
|
||||
targetKey: MovementTarget
|
||||
|
||||
- type: htnPrimitive
|
||||
id: MoveToAccessiblePrimitive
|
||||
operator: !type:MoveToOperator
|
||||
pathfindInPlanning: false
|
||||
|
||||
- type: htnPrimitive
|
||||
id: RandomIdleTimePrimitive
|
||||
operator: !type:RandomOperator
|
||||
targetKey: IdleTime
|
||||
minKey: MinimumIdleTime
|
||||
maxKey: MaximumIdleTime
|
||||
|
||||
- type: htnPrimitive
|
||||
id: WaitIdleTimePrimitive
|
||||
operator: !type:WaitOperator
|
||||
key: IdleTime
|
||||
preconditions:
|
||||
- !type:KeyExistsPrecondition
|
||||
key: IdleTime
|
||||
41
Resources/Prototypes/NPCs/medibot.yml
Normal file
41
Resources/Prototypes/NPCs/medibot.yml
Normal file
@@ -0,0 +1,41 @@
|
||||
- type: htnCompound
|
||||
id: MedibotCompound
|
||||
branches:
|
||||
- tasks:
|
||||
- id: InjectNearbyCompound
|
||||
- tasks:
|
||||
- id: IdleCompound
|
||||
|
||||
- type: htnCompound
|
||||
id: InjectNearbyCompound
|
||||
branches:
|
||||
- tasks:
|
||||
- id: PickNearbyInjectablePrimitive
|
||||
- id: MedibotSpeakPrimitive
|
||||
- id: MoveToAccessiblePrimitive
|
||||
- id: SetIdleTimePrimitive
|
||||
- id: WaitIdleTimePrimitive
|
||||
- id: MedibotInjectPrimitive
|
||||
|
||||
|
||||
- type: htnPrimitive
|
||||
id: MedibotSpeakPrimitive
|
||||
operator: !type:SpeakOperator
|
||||
speech: medibot-start-inject
|
||||
|
||||
- type: htnPrimitive
|
||||
id: PickNearbyInjectablePrimitive
|
||||
operator: !type:PickNearbyInjectableOperator
|
||||
targetKey: InjectTarget
|
||||
targetMoveKey: MovementTarget
|
||||
|
||||
- type: htnPrimitive
|
||||
id: MedibotInjectPrimitive
|
||||
operator: !type:MedibotInjectOperator
|
||||
targetKey: InjectTarget
|
||||
|
||||
- type: htnPrimitive
|
||||
id: SetIdleTimePrimitive
|
||||
operator: !type:SetFloatOperator
|
||||
targetKey: IdleTime
|
||||
amount: 3
|
||||
18
Resources/Prototypes/NPCs/mob.yml
Normal file
18
Resources/Prototypes/NPCs/mob.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
# Really you should write your own
|
||||
- type: htnCompound
|
||||
id: SimpleHostileCompound
|
||||
branches:
|
||||
- tasks:
|
||||
- id: MeleeCombatCompound
|
||||
- tasks:
|
||||
- id: IdleCompound
|
||||
|
||||
- type: htnCompound
|
||||
id: DragonCarpCompound
|
||||
branches:
|
||||
- tasks:
|
||||
- id: MeleeCombatCompound
|
||||
- tasks:
|
||||
- id: FollowCompound
|
||||
- tasks:
|
||||
- id: IdleCompound
|
||||
21
Resources/Prototypes/NPCs/test.yml
Normal file
21
Resources/Prototypes/NPCs/test.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
# Selects a random pathfind point and tries to move there.
|
||||
- type: htnCompound
|
||||
id: MoveToPathfindPointCompound
|
||||
branches:
|
||||
- tasks:
|
||||
- id: PickPathfindPointPrimitive
|
||||
- id: MoveToAccessiblePrimitive
|
||||
|
||||
|
||||
- type: htnPrimitive
|
||||
id: PickPathfindPointPrimitive
|
||||
operator: !type:PickPathfindPointOperator
|
||||
|
||||
- type: entity
|
||||
id: MobPathfindDummy
|
||||
name: Pathfind dummy
|
||||
suffix: NPC
|
||||
parent: MobXenoRouny
|
||||
components:
|
||||
- type: HTN
|
||||
rootTask: MoveToPathfindPointCompound
|
||||
7
Resources/Prototypes/NPCs/xeno.yml
Normal file
7
Resources/Prototypes/NPCs/xeno.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
- type: htnCompound
|
||||
id: XenoCompound
|
||||
branches:
|
||||
- tasks:
|
||||
- id: MeleeCombatCompound
|
||||
- tasks:
|
||||
- id: IdleCompound
|
||||
Reference in New Issue
Block a user