# Прототип поведения ИИ для питомцев. Как у короля крыс, только для питомцев

- type: htnCompound
  id: PetCompound
  branches:
  - preconditions:
    - !type:HasOrdersPrecondition
      orders: enum.PetOrderType.Stay
    tasks:
    - !type:HTNCompoundTask
      task: IdleCompound
  - preconditions:
    - !type:HasOrdersPrecondition
      orders: enum.PetOrderType.Follow
    tasks:
    - !type:HTNCompoundTask
      task: FollowCompound
  - preconditions:
    - !type:HasOrdersPrecondition
      orders: enum.PetOrderType.Attack
    tasks:
    - !type:HTNCompoundTask
      task: PetTargetAttackCompound

- type: htnCompound
  id: PetTargetAttackCompound
  branches:
  - tasks:
    - !type:HTNCompoundTask
      task: PetCombatCompound
  - tasks:
    - !type:HTNCompoundTask
      task: IdleCompound

- type: htnCompound
  id: PetCombatCompound
  branches:
  - preconditions:
    - !type:ActiveHandComponentPrecondition
      components:
      - type: MeleeWeapon
        damage:
          types:
            Blunt: 0
      invert: true
    tasks:
    - !type:HTNCompoundTask
      task: PickupMeleeCompound
  - tasks:
    - !type:HTNPrimitiveTask
      operator: !type:UtilityOperator
        proto: OrderedTargets
    - !type:HTNCompoundTask
      task: MeleeAttackOrderedTargetCompound
