# SPDX-FileCopyrightText: 2022 metalgearsloth <metalgearsloth@gmail.com>
# SPDX-FileCopyrightText: 2023 metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 PopGamer46 <yt1popgamer@gmail.com>
# SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 GoobBot <uristmchands@proton.me>
# SPDX-FileCopyrightText: 2025 Ilya246 <ilyukarno@gmail.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
# Picks a random location for the NPC to move to and idle.
- type: htnCompound
  id: IdleCompound
  branches:
    - tasks:
        - !type:HTNPrimitiveTask
          operator: !type:WaitOperator
            key: IdleTime
          preconditions:
            - !type:KeyExistsPrecondition
              key: IdleTime

    # Pick a new spot and wait there.
    - preconditions:
        - !type:BuckledPrecondition
          isBuckled: false
        - !type:PulledPrecondition
          isPulled: false
      tasks:
        - !type:HTNPrimitiveTask
          operator: !type:PickAccessibleOperator
            rangeKey: IdleRange

        - !type:HTNPrimitiveTask
          operator: !type:MoveToOperator
            pathfindInPlanning: false

        - !type:HTNPrimitiveTask
          operator: !type:RandomOperator
            targetKey: IdleTime
            minKey: MinimumIdleTime
            maxKey: MaximumIdleTime

        - !type:HTNPrimitiveTask
          operator: !type:WaitOperator
            key: IdleTime
          preconditions:
            - !type:KeyExistsPrecondition
              key: IdleTime

# Spin to a random rotation and idle.
- type: htnCompound
  id: IdleSpinCompound
  branches:
    - tasks:
        - !type:HTNPrimitiveTask
          operator: !type:WaitOperator
            key: IdleTime
          preconditions:
            - !type:KeyExistsPrecondition
              key: IdleTime

    # Pick a new angle and spin there
    - tasks:
        - !type:HTNPrimitiveTask
          operator: !type:PickRandomRotationOperator
            targetKey: RotateTarget

        - !type:HTNPrimitiveTask
          operator: !type:RotateToTargetOperator
            targetKey: RotateTarget

        - !type:HTNPrimitiveTask
          operator: !type:RandomOperator
            targetKey: IdleTime
            minKey: MinimumIdleTime
            maxKey: MaximumIdleTime

        - !type:HTNPrimitiveTask
          operator: !type:WaitOperator
            key: IdleTime
          preconditions:
            - !type:KeyExistsPrecondition
              key: IdleTime
