space-station-14 icon indicating copy to clipboard operation
space-station-14 copied to clipboard

Added new HTN operations and preconditions

Open Tornado-Technology opened this issue 9 months ago • 1 comments

About the PR

At the code level (These operators are not used in prototypes), new prototypes have been added for various mathematical operations with float and bool, as well as playing music.

Why / Balance

When designing complex monster behavior, I was faced with the need to create various state falsies, creating random delays that would act as an ability cooldown rather than a wait for the monster. Various distance checks, as well as sound effects.

Technical details

Just new HTN operators, and moving some old ones to the new namespace "Math"

Media

https://github.com/space-wizards/space-station-14/assets/54727692/0a6570ad-59f2-4a20-9692-7214980c9047

  • [x] I have added screenshots/videos to this PR showcasing its changes ingame, or this PR does not require an ingame showcase

Breaking changes

Move SetFloatOperator from Content.Server.NPC.HTN.PrimitiveTasks.Operators -> Content.Server.NPC.HTN.PrimitiveTasks.Operators.Math

Tornado-Technology avatar Apr 29 '24 13:04 Tornado-Technology

Example to use:

- type: htnCompound
  id: TestCompound
  branches:
    - tasks:
      - !type:HTNPrimitiveTask
        operator: !type:UnPullOperator
        preconditions:
          - !type:PulledPrecondition
            isPulled: true
    
   - tasks:
      - !type:HTNPrimitiveTask
        preconditions:
          - !type:KeyBoolEqualsPrecondition
            key: AbilityIsReady
            value: true
        operator: !type:PlaySoundOperator
          sound: # some example sound path
     - !type:HTNPrimitiveTask
        operator: !type:SetBoolOperator
          targetKey: AbilityIsReady
          value: false
   
   - tasks:
      - !type:HTNCompoundTask
        task: MeleeAttackTargetCompound
    
    - tasks:
      - !type:HTNPrimitiveTask
        preconditions:
          - !type:KeyBoolEqualsPrecondition
            key: AbilityIsReady
            value: false
        operator: !type:SetBoolOperator
          targetKey: AbilityIsReady
          value: true

      - !type:HTNCompoundTask
        task: IdleCompound

Tornado-Technology avatar Apr 29 '24 13:04 Tornado-Technology

Looks okay. Checked, the tasks work correctly. It may be worth removing these talking dummies in the future.

TheShuEd avatar May 08 '24 09:05 TheShuEd