;;-*-Lisp-*-
(in-package goal)

;; name: kanga-lizard.gc
;; name in dgo: kanga-lizard
;; dgos: WASCHASE

;; +++waschase-speech-flag
(defenum waschase-speech-flag
  :type uint64
  :bitfield #t
  (wsf0 0)
  (wsf1 1)
  (wsf2 2)
  (wsf3 3)
  (wsf4 4)
  (wsf5 5)
  (wsf6 6)
  )
;; ---waschase-speech-flag


;; +++waschase-speech-info-flag
(defenum waschase-speech-info-flag
  :type uint8
  :bitfield #t
  (wsi0 0)
  (wsi1 1)
  (wsi2 2)
  (wsi3 3)
  (wsi4 4)
  (wsi5 5)
  (wsi6 6)
  (wsi7 7)
  )
;; ---waschase-speech-info-flag


;; DECOMP BEGINS

(define *kanga-lizard-speech-list* (new 'static 'inline-array talker-speech-class 33
                                     (new 'static 'talker-speech-class :name "none")
                                     (new 'static 'talker-speech-class
                                       :name "dax310"
                                       :channel (gui-channel daxter)
                                       :speech #x1
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax311"
                                       :channel (gui-channel daxter)
                                       :speech #x2
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax312"
                                       :channel (gui-channel daxter)
                                       :speech #x3
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax313"
                                       :channel (gui-channel daxter)
                                       :speech #x4
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax314"
                                       :channel (gui-channel daxter)
                                       :speech #x5
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax315"
                                       :channel (gui-channel daxter)
                                       :speech #x6
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax316"
                                       :channel (gui-channel daxter)
                                       :speech #x7
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax317"
                                       :channel (gui-channel daxter)
                                       :speech #x8
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax318"
                                       :channel (gui-channel daxter)
                                       :speech #x9
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax319"
                                       :channel (gui-channel daxter)
                                       :speech #xa
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax320"
                                       :channel (gui-channel daxter)
                                       :speech #xb
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax321"
                                       :channel (gui-channel daxter)
                                       :speech #xc
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax322"
                                       :channel (gui-channel daxter)
                                       :speech #xd
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax323"
                                       :channel (gui-channel daxter)
                                       :speech #xe
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax324"
                                       :channel (gui-channel daxter)
                                       :speech #xf
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax325"
                                       :channel (gui-channel daxter)
                                       :speech #x10
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax326"
                                       :channel (gui-channel daxter)
                                       :speech #x11
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax327"
                                       :channel (gui-channel daxter)
                                       :speech #x12
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax328"
                                       :channel (gui-channel daxter)
                                       :speech #x13
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax329"
                                       :channel (gui-channel daxter)
                                       :speech #x14
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax330"
                                       :channel (gui-channel daxter)
                                       :speech #x15
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax331"
                                       :channel (gui-channel daxter)
                                       :speech #x16
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax332"
                                       :channel (gui-channel daxter)
                                       :speech #x17
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax333"
                                       :channel (gui-channel daxter)
                                       :speech #x18
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax334"
                                       :channel (gui-channel daxter)
                                       :speech #x19
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax335"
                                       :channel (gui-channel daxter)
                                       :speech #x1a
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax336"
                                       :channel (gui-channel daxter)
                                       :speech #x1b
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax337"
                                       :channel (gui-channel daxter)
                                       :speech #x1c
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax338"
                                       :channel (gui-channel daxter)
                                       :speech #x1d
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax339"
                                       :channel (gui-channel daxter)
                                       :speech #x1e
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax340"
                                       :channel (gui-channel daxter)
                                       :speech #x1f
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     (new 'static 'talker-speech-class
                                       :name "dax341"
                                       :channel (gui-channel daxter)
                                       :speech #x20
                                       :neg #x1
                                       :on-close #f
                                       :camera #f
                                       )
                                     )
        )

(deftype waschase-speech-instance (structure)
  ((speech       uint16)
   (probability  float)
   (flags        waschase-speech-flag)
   (play-count   uint32)
   )
  )


(deftype waschase-speech-info (structure)
  ((speeches          (array waschase-speech-instance))
   (play-time         time-frame)
   (current-random    time-frame)
   (minimum-interval  time-frame)
   (random-interval   time-frame)
   (last-played       int8)
   (flags             waschase-speech-info-flag)
   )
  )


(deftype waschase-speech-group (structure)
  ((play-time  time-frame)
   (info       (array waschase-speech-info))
   )
  )


(define *waschase-speech*
  (new 'static 'waschase-speech-group
    :info (new 'static 'boxed-array :type waschase-speech-info
      (new 'static 'waschase-speech-info
        :speeches (new 'static 'boxed-array :type waschase-speech-instance
          (new 'static 'waschase-speech-instance :speech #x8 :probability 1.0 :flags (waschase-speech-flag wsf2))
          (new 'static 'waschase-speech-instance :speech #x5 :probability 1.0 :flags (waschase-speech-flag wsf2))
          (new 'static 'waschase-speech-instance :speech #x6 :probability 1.0 :flags (waschase-speech-flag wsf2))
          (new 'static 'waschase-speech-instance :speech #x4 :probability 1.0)
          )
        )
      (new 'static 'waschase-speech-info
        :speeches (new 'static 'boxed-array :type waschase-speech-instance
          (new 'static 'waschase-speech-instance :speech #xa :probability 1.0 :flags (waschase-speech-flag wsf3))
          (new 'static 'waschase-speech-instance :speech #x2 :probability 1.0 :flags (waschase-speech-flag wsf2))
          (new 'static 'waschase-speech-instance :speech #x9 :probability 1.0 :flags (waschase-speech-flag wsf2))
          (new 'static 'waschase-speech-instance :speech #x3 :probability 1.0 :flags (waschase-speech-flag wsf2))
          (new 'static 'waschase-speech-instance :speech #x1 :probability 1.0)
          )
        :minimum-interval (seconds 1)
        )
      (new 'static 'waschase-speech-info
        :speeches (new 'static 'boxed-array :type waschase-speech-instance
          (new 'static 'waschase-speech-instance :speech #x7 :probability 1.0 :flags (waschase-speech-flag wsf2))
          (new 'static 'waschase-speech-instance :speech #x11 :probability 1.0)
          (new 'static 'waschase-speech-instance :speech #x15 :probability 1.0)
          )
        :minimum-interval (seconds 0.2)
        )
      (new 'static 'waschase-speech-info
        :speeches (new 'static 'boxed-array :type waschase-speech-instance
          (new 'static 'waschase-speech-instance :speech #x1b :probability 1.0)
          (new 'static 'waschase-speech-instance :speech #x1c :probability 1.0)
          (new 'static 'waschase-speech-instance :speech #x1f :probability 1.0)
          )
        :minimum-interval (seconds 20)
        :random-interval (seconds 5)
        :flags (waschase-speech-info-flag wsi0)
        )
      (new 'static 'waschase-speech-info
        :speeches (new 'static 'boxed-array :type waschase-speech-instance
          (new 'static 'waschase-speech-instance :speech #xc :probability 1.0)
          (new 'static 'waschase-speech-instance :speech #xd :probability 1.0)
          (new 'static 'waschase-speech-instance :speech #xe :probability 1.0)
          (new 'static 'waschase-speech-instance :speech #x10 :probability 1.0)
          (new 'static 'waschase-speech-instance :speech #x12 :probability 1.0)
          (new 'static 'waschase-speech-instance :speech #x13 :probability 1.0)
          (new 'static 'waschase-speech-instance :speech #x14 :probability 1.0)
          (new 'static 'waschase-speech-instance :speech #x19 :probability 1.0)
          )
        :minimum-interval (seconds 20)
        :random-interval (seconds 5)
        :flags (waschase-speech-info-flag wsi0)
        )
      (new 'static 'waschase-speech-info
        :speeches (new 'static 'boxed-array :type waschase-speech-instance
          (new 'static 'waschase-speech-instance :speech #x16 :probability 1.0)
          (new 'static 'waschase-speech-instance :speech #x17 :probability 1.0)
          (new 'static 'waschase-speech-instance :speech #x18 :probability 1.0)
          )
        :minimum-interval (seconds 8)
        )
      (new 'static 'waschase-speech-info
        :speeches (new 'static 'boxed-array :type waschase-speech-instance
          (new 'static 'waschase-speech-instance :speech #x1d :probability 1.0 :flags (waschase-speech-flag wsf2))
          (new 'static 'waschase-speech-instance :speech #xf :probability 1.0 :flags (waschase-speech-flag wsf2))
          (new 'static 'waschase-speech-instance :speech #x1e :probability 1.0 :flags (waschase-speech-flag wsf2))
          (new 'static 'waschase-speech-instance :speech #x1a :probability 1.0)
          )
        :minimum-interval (seconds 20)
        :random-interval (seconds 5)
        :flags (waschase-speech-info-flag wsi0)
        )
      (new 'static 'waschase-speech-info
        :speeches (new 'static 'boxed-array :type waschase-speech-instance
          (new 'static 'waschase-speech-instance :speech #xb :probability 1.0 :flags (waschase-speech-flag wsf4))
          )
        )
      (new 'static 'waschase-speech-info
        :speeches (new 'static 'boxed-array :type waschase-speech-instance
          (new 'static 'waschase-speech-instance :speech #x20 :probability 1.0 :flags (waschase-speech-flag wsf0 wsf4))
          )
        )
      )
    )
  )

;; WARN: Return type mismatch symbol vs none.
(defun reset-waschase-speeches ()
  (set! (-> *waschase-speech* play-time) 0)
  (dotimes (v1-1 (-> *waschase-speech* info length))
    (let ((a0-2 (-> *waschase-speech* info v1-1)))
      (dotimes (a1-2 (-> a0-2 speeches length))
        (set! (-> a0-2 speeches a1-2 play-count) (the-as uint 0))
        )
      (set! (-> a0-2 play-time) 0)
      (set! (-> a0-2 current-random) 0)
      (set! (-> a0-2 last-played) -1)
      )
    )
  (none)
  )

;; WARN: Function waschase-play-speech has a return type of none, but the expression builder found a return statement.
(defun waschase-play-speech ((arg0 int))
  (let ((gp-0 (-> *waschase-speech* info arg0)))
    (if (zero? (-> gp-0 speeches length))
        (return 0)
        )
    (if (logtest? (-> gp-0 flags) (waschase-speech-info-flag wsi0))
        (set! (-> gp-0 play-time) (-> *waschase-speech* play-time))
        )
    (if (not (time-elapsed? (-> gp-0 play-time) (+ (-> gp-0 minimum-interval) (-> gp-0 current-random))))
        (return 0)
        )
    (let ((f30-0 0.0)
          (s5-0 (-> gp-0 speeches 0 play-count))
          )
      (dotimes (v1-18 (-> gp-0 speeches length))
        (let ((a0-8 (-> gp-0 speeches v1-18)))
          (cond
            ((or (< s5-0 (-> a0-8 play-count))
                 (and (logtest? (-> a0-8 flags) (waschase-speech-flag wsf1)) (nonzero? (-> gp-0 play-time)))
                 (and (logtest? (-> a0-8 flags) (waschase-speech-flag wsf2)) (zero? (-> gp-0 play-time)))
                 (and (logtest? (-> a0-8 flags) (waschase-speech-flag wsf0)) (> (-> a0-8 play-count) 0))
                 (or (and (logtest? (-> a0-8 flags) (waschase-speech-flag wsf3)) (!= (-> *game-info* counter) 1.0))
                     (and (not (logtest? (-> a0-8 flags) (waschase-speech-flag wsf4))) (= (-> gp-0 last-played) v1-18))
                     )
                 )
             (logclear! (-> a0-8 flags) (waschase-speech-flag wsf5))
             )
            ((= (-> a0-8 play-count) s5-0)
             (+! f30-0 (-> a0-8 probability))
             (logior! (-> a0-8 flags) (waschase-speech-flag wsf5))
             )
            (else
              (set! s5-0 (-> a0-8 play-count))
              (set! f30-0 (-> a0-8 probability))
              (logior! (-> a0-8 flags) (waschase-speech-flag wsf5))
              )
            )
          )
        )
      (let ((f0-3 (* f30-0 (rand-vu))))
        (dotimes (s4-0 (-> gp-0 speeches length))
          (let ((s3-0 (-> gp-0 speeches s4-0)))
            (cond
              ((or (not (logtest? (-> s3-0 flags) (waschase-speech-flag wsf5))) (< s5-0 (-> s3-0 play-count)))
               )
              ((or (>= (-> s3-0 probability) f0-3)
                   (logtest? (-> s3-0 flags) (waschase-speech-flag wsf1))
                   (and (logtest? (-> s3-0 flags) (waschase-speech-flag wsf3)) (zero? (-> s3-0 play-count)))
                   )
               (when (nonzero? (talker-spawn-func
                                 (-> *kanga-lizard-speech-list* (-> s3-0 speech))
                                 *entity-pool*
                                 (target-pos 0)
                                 (the-as region #f)
                                 )
                               )
                 (set! (-> s3-0 play-count) (+ s5-0 1))
                 (set-time! (-> *waschase-speech* play-time))
                 (set-time! (-> gp-0 play-time))
                 (set! (-> gp-0 current-random)
                       (the-as time-frame (the int (* (rand-vu) (the float (-> gp-0 random-interval)))))
                       )
                 (set! (-> gp-0 last-played) s4-0)
                 )
               (return 0)
               )
              (else
                (set! f0-3 (- f0-3 (-> gp-0 speeches s4-0 probability)))
                )
              )
            )
          )
        )
      )
    )
  0
  (none)
  )

(defpartgroup group-kanga-lizard-dust
  :id 524
  :duration (seconds 0.017)
  :flags (sp0)
  :bounds (static-bspherem 0 0 0 12)
  :parts ((sp-item 2054 :fade-after (meters 200) :falloff-to (meters 200)))
  )

(defpart 2054
  :init-specs ((:texture (dirtpuff01 level-default-sprite))
    (:num 1.0)
    (:x (meters -0.5) (meters 1.5))
    (:scale-x (meters 1) (meters 0.5))
    (:rot-z (degrees 0) (degrees 3600))
    (:scale-y (meters 1) (meters 0.5))
    (:r 120.0)
    (:g 100.0)
    (:b 80.0)
    (:a 32.0 32.0)
    (:vel-y (meters 0.02) (meters 0.02))
    (:scalevel-x (meters 0.0033333334) (meters 0.0033333334))
    (:rotvel-z (degrees -0.3) (degrees 0.6))
    (:scalevel-y :copy scalevel-x)
    (:fade-a -0.10666667 -0.21333334)
    (:friction 0.95 0.03)
    (:timer (seconds 2.167))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-13))
    (:rotate-y (degrees 0) (degrees 3600))
    )
  )

(defskelgroup skel-kanga-lizard kanga-lizard kanga-lizard-lod0-jg kanga-lizard-idle-ja
              ((kanga-lizard-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 2)
              :shadow kanga-lizard-shadow-mg
              :origin-joint-index 3
              )

(deftype kanga-lizard (nav-enemy)
  ((minimap             connection-minimap)
   (last-focus-ping     time-frame)
   (total-flee-time     time-frame)
   (current-flee-start  time-frame)
   (being-attacked      symbol)
   )
  (:state-methods
    hidden
    reinit-if-find-nav-mesh
    die-eaten
    )
  )


(define *kanga-lizard-nav-enemy-info*
  (new 'static 'nav-enemy-info
    :use-die-falling #t
    :use-victory #f
    :use-jump-blocked #f
    :debug-draw-neck #f
    :jump-debug-draw #f
    :move-to-ground #t
    :hover-if-no-ground #f
    :idle-anim-script (new 'static 'inline-array idle-control-frame 3
      (new 'static 'idle-control-frame :command (idle-control-cmd push) :param0 30)
      (new 'static 'idle-control-frame
        :command (idle-control-cmd play)
        :anim #x3
        :param0 100
        :param1 100
        :param2 '((new 'static 'bfloat :data 1.0) (new 'static 'bfloat :data 1.0))
        )
      (new 'static 'idle-control-frame)
      )
    :idle-anim 3
    :notice-anim 7
    :hostile-anim 6
    :hit-anim 3
    :knocked-anim 3
    :knocked-land-anim 3
    :die-anim 3
    :die-falling-anim 3
    :victory-anim 3
    :jump-wind-up-anim -1
    :jump-in-air-anim 8
    :jump-land-anim 9
    :neck-joint -1
    :look-at-joint 11
    :bullseye-joint 11
    :notice-distance (meters 70)
    :notice-distance-delta (meters 50)
    :proximity-notice-distance (meters 70)
    :default-hit-points 1.0
    :gnd-collide-with (collide-spec backgnd obstacle hit-by-others-list)
    :overlaps-others-collide-with-filter (collide-spec jak bot player-list)
    :penetrate-knocked (penetrate
      touch
      generic-attack
      lunge
      flop
      punch
      spin
      roll
      uppercut
      bonk
      tube
      vehicle
      flut-attack
      board
      mech
      mech-punch
      mech-bonk
      dark-skin
      dark-punch
      dark-bomb
      dark-smack
      flut
      shield
      explode
      jak-yellow-shot
      jak-red-shot
      jak-blue-shot
      jak-dark-shot
      enemy-yellow-shot
      enemy-dark-shot
      eco-yellow
      eco-red
      eco-blue
      eco-green
      knocked
      jak-red-shockwave
      jak-dark-nuke
      jak-dark-blackhole
      emp-blast
      penetrate38
      penetrate39
      penetrate40
      penetrate41
      penetrate42
      penetrate43
      penetrate44
      penetrate45
      penetrate46
      penetrate47
      penetrate48
      penetrate49
      penetrate50
      penetrate51
      penetrate52
      penetrate53
      penetrate54
      penetrate55
      penetrate56
      penetrate57
      penetrate58
      penetrate59
      penetrate60
      penetrate61
      penetrate64
      penetrate63
      )
    :movement-gravity (meters -100)
    :friction 0.8
    :attack-shove-back (meters 3.5)
    :attack-shove-up (meters 2)
    :attack-mode 'generic
    :attack-damage 2
    :recover-gnd-collide-with (collide-spec backgnd crate obstacle hit-by-others-list pusher)
    :knocked-can-land-timeout (seconds 0.1)
    :knocked-recover-timeout (seconds 2)
    :ragdoll-blend-out-time (seconds 0.25)
    :ragdoll-rotate-velocity-mult 1.0
    :jump-height-min (meters 3)
    :jump-height-factor 0.5
    :knocked-seek-ry-clamp 6371.5557
    :knocked-soft-vxz-lo (meters 17.6)
    :knocked-soft-vxz-hi (meters 26.4)
    :knocked-soft-vy-lo (meters 20)
    :knocked-soft-vy-hi (meters 30)
    :knocked-medium-vxz-lo (meters 36)
    :knocked-medium-vxz-hi (meters 48)
    :knocked-medium-vy-lo (meters 33)
    :knocked-medium-vy-hi (meters 37)
    :knocked-hard-vxz-lo (meters 19.2)
    :knocked-hard-vxz-hi (meters 28.8)
    :knocked-hard-vy-lo (meters 44.8)
    :knocked-hard-vy-hi (meters 51.2)
    :knocked-huge-vxz-lo (meters 40.2)
    :knocked-huge-vxz-hi (meters 60.8)
    :knocked-huge-vy-lo (meters 44.8)
    :knocked-huge-vy-hi (meters 53.2)
    :knocked-yellow-vxz-lo (meters 10)
    :knocked-yellow-vxz-hi (meters 12)
    :knocked-yellow-vy-lo (meters 14)
    :knocked-yellow-vy-hi (meters 20)
    :knocked-red-vxz-lo (meters 6)
    :knocked-red-vxz-hi (meters 48)
    :knocked-red-vy-lo (meters 23)
    :knocked-red-vy-hi (meters 37)
    :knocked-blue-vxz-lo (meters 10)
    :knocked-blue-vxz-hi (meters 12)
    :knocked-blue-vy-lo (meters 6)
    :knocked-blue-vy-hi (meters 20)
    :ragdoll-info (new 'static 'ragdoll-setup
      :orient-tform (new 'static 'vector :x 0.9999 :y -0.0032 :z 0.0024 :w 13772.991)
      :scale (new 'static 'vector :x 1.0 :y 1.0 :z 1.0)
      :bg-collide-with (collide-spec backgnd player-list)
      :joint-setup (new 'static 'boxed-array :type ragdoll-joint-setup
        (new 'static 'ragdoll-joint-setup
          :joint-index 3
          :parent-joint -1
          :geo-tform (new 'static 'vector :x 0.9991 :z -0.0416 :w 10.176285)
          :axial-slop 1887.9647
          :max-angle 3752.4458
          :coll-rad 758.9888
          )
        (new 'static 'ragdoll-joint-setup
          :joint-index 4
          :parent-joint -1
          :pre-tform (new 'static 'vector :x -0.9999 :z 0.0069 :w 14429.517)
          :geo-tform (new 'static 'vector :x -0.947 :y -0.0257 :z 0.3201 :w 3779.9888)
          :axial-slop 1887.9647
          :max-angle 3752.4458
          :coll-rad 758.9888
          )
        (new 'static 'ragdoll-joint-setup
          :joint-index 5
          :parent-joint -1
          :pre-tform (new 'static 'vector :x -0.5773 :z 0.8165 :w 1479.4387)
          :geo-tform (new 'static 'vector :x 0.2924 :y -0.5288 :z 0.7967 :w 2947.0447)
          :axial-slop 1887.9647
          :max-angle 3752.4458
          :coll-rad 758.9888
          )
        (new 'static 'ragdoll-joint-setup
          :joint-index 6
          :parent-joint -1
          :pre-tform (new 'static 'vector :x 0.7717 :z 0.6359 :w 3573.86)
          :geo-tform (new 'static 'vector :x -0.7554 :y -0.4867 :z -0.4384 :w 5439.4517)
          :axial-slop 1887.9647
          :max-angle 3752.4458
          :coll-rad 758.9888
          )
        (new 'static 'ragdoll-joint-setup
          :joint-index 7
          :parent-joint 3
          :pre-tform (new 'static 'vector :x 0.4816 :z -0.8763 :w 17529.496)
          :geo-tform (new 'static 'vector :x 0.6441 :y 0.7607 :z 0.0792 :w 22136.586)
          :axial-slop 1887.9647
          :max-angle 3752.4458
          :coll-rad 758.9888
          )
        (new 'static 'ragdoll-joint-setup
          :joint-index 8
          :parent-joint -1
          :pre-tform (new 'static 'vector :x 0.6547 :z -0.7558 :w 12808.429)
          :geo-tform (new 'static 'vector :x 0.3892 :y 0.7465 :z -0.5396 :w 22594.555)
          :axial-slop 1887.9647
          :max-angle 3752.4458
          :coll-rad 758.9888
          )
        (new 'static 'ragdoll-joint-setup
          :joint-index 9
          :parent-joint -1
          :pre-tform (new 'static 'vector :x -0.3307 :z -0.9437 :w 16955.62)
          :geo-tform (new 'static 'vector :x -0.4067 :y 0.7082 :z 0.5769 :w 23004.555)
          :axial-slop 1887.9647
          :max-angle 3752.4458
          :coll-rad 758.9888
          )
        (new 'static 'ragdoll-joint-setup
          :joint-index 10
          :parent-joint -1
          :pre-tform (new 'static 'vector :x 0.3307 :z 0.9437 :w 14144.125)
          :geo-tform (new 'static 'vector :x -0.3842 :y 0.7535 :z 0.5334 :w 22536.373)
          :axial-slop 1887.9647
          :max-angle 3752.4458
          :coll-rad 758.9888
          )
        (new 'static 'ragdoll-joint-setup
          :joint-index 11
          :parent-joint 3
          :pre-tform (new 'static 'vector :x 0.9997 :z 0.0202 :w 13538.154)
          :geo-tform (new 'static 'vector :x -0.9948 :y 0.0638 :z 0.079 :w 9134.188)
          :axial-slop 1887.9647
          :max-angle 3752.4458
          :coll-rad 758.9888
          )
        (new 'static 'ragdoll-joint-setup
          :joint-index 12
          :parent-joint -1
          :pre-tform (new 'static 'vector :x -0.1367 :z -0.9906 :w 14377.907)
          :geo-tform (new 'static 'vector :x -0.1677 :y -0.3997 :z 0.9011 :w 16489.148)
          :axial-slop 1887.9647
          :max-angle 3752.4458
          :coll-rad 758.9888
          )
        (new 'static 'ragdoll-joint-setup
          :joint-index 13
          :parent-joint -1
          :pre-tform (new 'static 'vector :x 0.9415 :z -0.3368 :w 18629.918)
          :geo-tform (new 'static 'vector :x -0.5256 :y 0.0211 :z 0.8504 :w 31708.156)
          :axial-slop 1887.9647
          :max-angle 3752.4458
          :coll-rad 758.9888
          )
        (new 'static 'ragdoll-joint-setup
          :joint-index 14
          :parent-joint -1
          :pre-tform (new 'static 'vector :x 0.411 :z 0.9116 :w 15460.562)
          :geo-tform (new 'static 'vector :x -0.401 :y 0.6835 :z 0.6099 :w 23241.305)
          :axial-slop 1887.9647
          :max-angle 3752.4458
          :coll-rad 758.9888
          )
        (new 'static 'ragdoll-joint-setup
          :joint-index 15
          :parent-joint 11
          :pre-tform (new 'static 'vector :x -0.9887 :z 0.1493 :w 9420.326)
          :geo-tform (new 'static 'vector :x -0.9619 :y 0.0385 :z -0.2706 :w 9354.7)
          :axial-slop 1887.9647
          :max-angle 3752.4458
          :coll-rad 758.9888
          )
        (new 'static 'ragdoll-joint-setup
          :joint-index 16
          :parent-joint -1
          :pre-tform (new 'static 'vector :x -0.9714 :z -0.2373 :w 8648.932)
          :geo-tform (new 'static 'vector :x 0.9244 :y -0.0244 :z 0.3806 :w 8285.861)
          :axial-slop 1887.9647
          :max-angle 3752.4458
          :coll-rad 758.9888
          )
        (new 'static 'ragdoll-joint-setup
          :joint-index 17
          :parent-joint -1
          :pre-tform (new 'static 'vector :x 0.9225 :z 0.3859 :w 7855.491)
          :geo-tform (new 'static 'vector :x 0.9999 :y -0.0105 :z -0.0083 :w 20456.498)
          :axial-slop 1887.9647
          :max-angle 3752.4458
          :coll-rad 758.9888
          )
        (new 'static 'ragdoll-joint-setup
          :joint-index 18
          :parent-joint 11
          :pre-tform (new 'static 'vector :x 0.022 :z 0.9997 :w 14975.687)
          :geo-tform (new 'static 'vector :x 0.6762 :y -0.6219 :z -0.3947 :w 26276.166)
          :axial-slop 1887.9647
          :max-angle 3752.4458
          :coll-rad 758.9888
          )
        (new 'static 'ragdoll-joint-setup
          :joint-index 19
          :parent-joint -1
          :pre-tform (new 'static 'vector :x 0.9991 :z -0.0415 :w 17548.375)
          :geo-tform (new 'static 'vector :x 0.1052 :y -0.9944 :z 0.0043 :w 16773.139)
          :axial-slop 1887.9647
          :max-angle 3752.4458
          :coll-rad 758.9888
          )
        (new 'static 'ragdoll-joint-setup
          :joint-index 20
          :parent-joint -1
          :pre-tform (new 'static 'vector :x 0.0144 :z -0.9998 :w 14961.196)
          :geo-tform (new 'static 'vector :x 0.655 :y -0.4754 :z 0.5872 :w 23006.104)
          :axial-slop 1887.9647
          :max-angle 3752.4458
          :coll-rad 758.9888
          )
        (new 'static 'ragdoll-joint-setup
          :joint-index 21
          :parent-joint 3
          :pre-tform (new 'static 'vector :x 0.5888 :z 0.8082 :w 19406.248)
          :geo-tform (new 'static 'vector :x 0.5126 :y -0.8073 :z -0.2922 :w 17383.37)
          :axial-slop 1887.9647
          :max-angle 3752.4458
          :coll-rad 758.9888
          )
        (new 'static 'ragdoll-joint-setup
          :joint-index 22
          :parent-joint -1
          :pre-tform (new 'static 'vector :x 0.9497 :z 0.3131 :w 9941.41)
          :geo-tform (new 'static 'vector :x 0.5708 :y -0.632 :z 0.524 :w 20043.166)
          :axial-slop 1887.9647
          :max-angle 3752.4458
          :coll-rad 758.9888
          )
        (new 'static 'ragdoll-joint-setup
          :joint-index 23
          :parent-joint -1
          :pre-tform (new 'static 'vector :x 0.0666 :z 0.9977 :w 18923.191)
          :geo-tform (new 'static 'vector :x -0.6091 :y -0.5547 :z -0.5667 :w 21395.646)
          :axial-slop 1887.9647
          :max-angle 3752.4458
          :coll-rad 758.9888
          )
        (new 'static 'ragdoll-joint-setup
          :joint-index 24
          :parent-joint -1
          :pre-tform (new 'static 'vector :x -0.0666 :z -0.9977 :w 15931.328)
          :geo-tform (new 'static 'vector :x -0.4184 :y -0.8014 :z -0.4272 :w 17251.479)
          :axial-slop 1887.9647
          :max-angle 3752.4458
          :coll-rad 758.9888
          )
        )
      )
    :shadow-size (meters 2)
    :shadow-max-y (meters 1)
    :shadow-min-y (meters -1)
    :shadow-locus-dist (meters 150)
    :gem-joint -1
    :gem-offset (new 'static 'sphere :r 163840.0)
    :knocked-off #t
    :callback-info #f
    :use-momentum #t
    :use-frustration #t
    :use-stop-chase #f
    :use-circling #t
    :use-pacing #t
    :walk-anim 5
    :turn-anim -1
    :run-anim 6
    :taunt-anim -1
    :run-travel-speed (meters 19)
    :run-acceleration (meters 64)
    :run-turning-acceleration (meters 120)
    :walk-travel-speed (meters 7)
    :walk-acceleration (meters 4)
    :walk-turning-acceleration (meters 100)
    :maximum-rotation-rate (degrees 360)
    :notice-nav-radius (meters 2)
    :frustration-distance (meters 8)
    :frustration-time (seconds 4)
    :blocked-time (seconds 0.3)
    :circle-dist-lo 20480.0
    :circle-dist-hi 61440.0
    :nav-mesh #f
    )
  )

(set! (-> *kanga-lizard-nav-enemy-info* fact-defaults) *fact-info-enemy-defaults*)

(defmethod coin-flip? ((this kanga-lizard))
  "Return #t half the time, #f the other."
  #f
  )

(defmethod mark-as-dead ((this kanga-lizard))
  (when (-> this minimap)
    (logior! (-> this minimap flags) (minimap-flag fade-out))
    (set! (-> this minimap) #f)
    )
  ((method-of-type nav-enemy mark-as-dead) this)
  (none)
  )

(defmethod event-handler ((this kanga-lizard) (arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
  "Commmon handler for events."
  (case arg2
    (('death-end)
     (when (-> this minimap)
       (logior! (-> this minimap flags) (minimap-flag fade-out))
       (set! (-> this minimap) #f)
       )
     (process-entity-status! this (entity-perm-status subtask-complete) #t)
     )
    )
  ((method-of-type nav-enemy event-handler) this arg0 arg1 arg2 arg3)
  )

(defmethod go-fallback-init ((this kanga-lizard))
  "If there's no specific settings for initial state, go to this state after spawning."
  (when (= (-> this nav state mesh) *default-nav-mesh*)
    (set! (-> *kanga-lizard-nav-enemy-info* nav-mesh) #f)
    (go (method-of-object this reinit-if-find-nav-mesh))
    )
  (let* ((v1-8 (-> *game-info* sub-task-list (game-task-node wascity-chase-resolution)))
         (v1-10 (if (-> v1-8 manager)
                    (-> v1-8 manager manager)
                    (the-as handle #f)
                    )
                )
         )
    (when (handle->process v1-10)
      (if (send-event (handle->process v1-10) 'should-live? (-> this entity))
          (go (method-of-object this idle))
          )
      )
    )
  (go (method-of-object this hidden))
  )

(defmethod on-dying ((this kanga-lizard))
  (if (not (and (-> this next-state) (= (-> this next-state name) 'die-eaten)))
      (waschase-play-speech 2)
      )
  (let* ((v1-8 (-> *game-info* sub-task-list (game-task-node wascity-chase-resolution)))
         (v1-10 (if (-> v1-8 manager)
                    (-> v1-8 manager manager)
                    (the-as handle #f)
                    )
                )
         )
    (if (handle->process v1-10)
        (send-event (handle->process v1-10) 'dying (-> this entity))
        )
    )
  (when (-> this minimap)
    (logior! (-> this minimap flags) (minimap-flag fade-out))
    (set! (-> this minimap) #f)
    )
  ((method-of-type nav-enemy on-dying) this)
  (none)
  )

(defmethod should-flee-from? ((this kanga-lizard) (arg0 process-focusable))
  "Return if this enemy should flee from the process."
  (not (logtest? (-> arg0 focus-status) (focus-status ignore)))
  )

(defmethod can-become-hostile-to? ((this kanga-lizard) (arg0 process-focusable) (arg1 vector))
  "Return if this enemy can become hostile to the process."
  #t
  )

(defmethod get-awareness-of-proc ((this kanga-lizard) (arg0 process-focusable) (arg1 enemy-best-focus))
  "Check what the enemies awareness of this pfoc would be. Optionally return more awareness stats in enemy-best-focus."
  (cond
    ((< (+ (current-time) (seconds -3)) (-> this last-focus-ping))
     (set! (-> this enemy-info notice-distance) 409600.0)
     (set! (-> this enemy-info proximity-notice-distance) 409600.0)
     )
    ((logtest? (-> this enemy-flags) (enemy-flag alert))
     (set! (-> this enemy-info notice-distance) 163840.0)
     (set! (-> this enemy-info proximity-notice-distance) 163840.0)
     )
    (else
      (set! (-> this enemy-info notice-distance) 286720.0)
      (set! (-> this enemy-info proximity-notice-distance) 286720.0)
      )
    )
  (let* ((t9-0 (method-of-type nav-enemy get-awareness-of-proc))
         (v0-0 (t9-0 this arg0 arg1))
         )
    (set! (-> this enemy-info notice-distance) 286720.0)
    (set! (-> this enemy-info proximity-notice-distance) 286720.0)
    v0-0
    )
  )

;; WARN: Return type mismatch int vs search-info-flag.
(defmethod get-search-info-flag ((this kanga-lizard))
  "Get search-info-flag for this process."
  (set-time! (-> this last-focus-ping))
  (the-as search-info-flag 0)
  )

(defmethod init-enemy-collision! ((this kanga-lizard))
  "Typical place to construct collision shapes"
  (let ((s5-0 (new 'process 'collide-shape-moving this (collide-list-enum usually-hit-by-player))))
    (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process))
    (set! (-> s5-0 reaction) cshape-reaction-default)
    (set! (-> s5-0 no-reaction)
          (the-as (function collide-shape-moving collide-query vector vector object) nothing)
          )
    (set! (-> s5-0 penetrated-by) (penetrate
                                    generic-attack
                                    lunge
                                    flop
                                    punch
                                    spin
                                    roll
                                    uppercut
                                    bonk
                                    tube
                                    flut-attack
                                    board
                                    mech-punch
                                    dark-punch
                                    dark-smack
                                    flut
                                    )
          )
    (let ((v1-7 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-7 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-7 prim-core collide-with) (collide-spec backgnd jak bot player-list))
      (set! (-> v1-7 prim-core action) (collide-action solid))
      (set-vector! (-> v1-7 local-sphere) 0.0 4096.0 0.0 4096.0)
      (set! (-> s5-0 total-prims) (the-as uint 1))
      (set! (-> s5-0 root-prim) v1-7)
      )
    (set! (-> s5-0 nav-radius) 8192.0)
    (let ((v1-9 (-> s5-0 root-prim)))
      (set! (-> s5-0 backup-collide-as) (-> v1-9 prim-core collide-as))
      (set! (-> s5-0 backup-collide-with) (-> v1-9 prim-core collide-with))
      )
    (set! (-> this root) s5-0)
    )
  0
  (none)
  )

(defmethod init-enemy! ((this kanga-lizard))
  "Typical place for shared init code. Runs from entity or process style init."
  (initialize-skeleton
    this
    (the-as skeleton-group (art-group-get-by-name *level* "skel-kanga-lizard" (the-as (pointer level) #f)))
    (the-as pair 0)
    )
  (if (nav-mesh-from-res-tag (-> this entity) 'nav-mesh-actor 0)
      (set! (-> *kanga-lizard-nav-enemy-info* nav-mesh) #f)
      (set! (-> *kanga-lizard-nav-enemy-info* nav-mesh) *default-nav-mesh*)
      )
  (setup-enemy! this *kanga-lizard-nav-enemy-info*)
  (let ((v1-8 (-> this nav)))
    (set! (-> v1-8 speed-scale) 1.0)
    )
  0
  (set-gravity-length (-> this root dynam) 573440.0)
  (set! (-> this root pause-adjust-distance) 204800.0)
  (set! (-> this part) (create-launch-control (-> *part-group-id-table* 524) this))
  (set! (-> this last-focus-ping) 0)
  (set! (-> this minimap) (add-icon! *minimap* this (the-as uint 129) (the-as int #f) (the-as vector #t) 0))
  0
  (none)
  )

(defstate flee (kanga-lizard)
  :virtual #t
  :enter (behavior ()
    (let ((t9-0 (-> (method-of-type nav-enemy flee) enter)))
      (if t9-0
          (t9-0)
          )
      )
    (let ((gp-0 (-> self nav)))
      (set! (-> gp-0 target-speed)
            (* (lerp-scale 1.0 1.25 (-> *game-info* counter) 6.0 1.0) (-> self enemy-info run-travel-speed))
            )
      )
    0
    (sound-play "kanga-swish")
    self
    (waschase-play-speech 1)
    (set-time! (-> self current-flee-start))
    (set! (-> self being-attacked) #f)
    )
  :exit (behavior ()
    (let ((t9-0 (-> (method-of-type nav-enemy flee) exit)))
      (if t9-0
          (t9-0)
          )
      )
    (+! (-> self total-flee-time) (- (current-time) (-> self current-flee-start)))
    )
  :trans (behavior ()
    (let ((t9-0 (-> (method-of-type nav-enemy flee) trans)))
      (if t9-0
          (t9-0)
          )
      )
    (spawn (-> self part) (-> self root trans))
    (let ((f0-1 (the float (+ (-> self total-flee-time) (- (current-time) (-> self current-flee-start)))))
          (gp-0 (-> self nav))
          )
      (set! (-> gp-0 target-speed)
            (* (lerp-scale 1.0 0.8 f0-1 6000.0 36000.0) (-> self enemy-info run-travel-speed))
            )
      )
    0
    (cond
      ((not *target*)
       (set! (-> self being-attacked) #f)
       )
      ((and (focus-test? *target* dangerous)
            (let ((f0-4 (vector-vector-distance-squared (-> self root trans) (target-pos 0)))
                  (f1-1 61440.0)
                  )
              (< f0-4 (* f1-1 f1-1))
              )
            )
       (set! (-> self being-attacked) #t)
       )
      ((-> self being-attacked)
       self
       (waschase-play-speech 5)
       (set! (-> self being-attacked) #f)
       )
      )
    )
  )

(defstate reinit-if-find-nav-mesh (kanga-lizard)
  :virtual #t
  :enter (behavior ()
    (set-time! (-> self state-time))
    (logior! (-> self draw status) (draw-control-status no-draw-bounds))
    (let ((v1-6 (-> self root root-prim)))
      (set! (-> v1-6 prim-core collide-as) (collide-spec))
      (set! (-> v1-6 prim-core collide-with) (collide-spec))
      )
    0
    )
  :trans (behavior ()
    (when (time-elapsed? (-> self state-time) (seconds 0.2))
      (if (nav-mesh-from-res-tag (-> self entity) 'nav-mesh-actor 0)
          (deactivate self)
          )
      (set-time! (-> self state-time))
      )
    (when (and *display-entity-errors* (not *display-capture-mode*))
      (let ((s2-0 (cond
                    ((nonzero? (-> self root))
                     (-> self root trans)
                     )
                    ((-> self entity)
                     (-> self entity extra trans)
                     )
                    (else
                      (the-as vector #f)
                      )
                    )
                  )
            )
        (when s2-0
          (let ((gp-0 add-debug-text-3d)
                (s5-0 #t)
                (s4-0 577)
                )
            (format (clear *temp-string*) "~2j~s error for ~s" "no nav mesh" (-> self name))
            (gp-0 s5-0 (the-as bucket-id s4-0) *temp-string* s2-0 (font-color red) (the-as vector2h #f))
            )
          )
        )
      )
    )
  :code sleep-code
  )

(defstate hidden (kanga-lizard)
  :virtual #t
  :enter (behavior ()
    (set-time! (-> self state-time))
    (logior! (-> self draw status) (draw-control-status no-draw-bounds))
    (let ((v1-6 (-> self root root-prim)))
      (set! (-> v1-6 prim-core collide-as) (collide-spec))
      (set! (-> v1-6 prim-core collide-with) (collide-spec))
      )
    0
    )
  :exit (behavior ()
    (logclear! (-> self draw status) (draw-control-status no-draw-bounds))
    (let ((v1-3 (-> self root root-prim)))
      (set! (-> v1-3 prim-core collide-as) (-> self root backup-collide-as))
      (set! (-> v1-3 prim-core collide-with) (-> self root backup-collide-with))
      )
    (ja-channel-push! 1 0)
    (ja :group! kanga-lizard-idle-ja :num! min)
    )
  :trans (behavior ()
    (when (time-elapsed? (-> self state-time) (seconds 0.2))
      (let* ((v1-5 (-> *game-info* sub-task-list (game-task-node wascity-chase-resolution)))
             (v1-7 (if (-> v1-5 manager)
                       (-> v1-5 manager manager)
                       (the-as handle #f)
                       )
                   )
             )
        (when (handle->process v1-7)
          (if (send-event (handle->process v1-7) 'should-live? (-> self entity))
              (go-virtual idle)
              )
          )
        )
      (set-time! (-> self state-time))
      )
    )
  :code sleep-code
  )

(defstate knocked (kanga-lizard)
  :virtual #t
  :enter (behavior ()
    (when (send-event (handle->process (-> self incoming attacker-handle)) 'change-mode 'kanga)
      enter-state
      (-> self incoming attacker-handle)
      (go-virtual die-eaten)
      )
    (let ((t9-2 (-> (method-of-type nav-enemy knocked) enter)))
      (if t9-2
          (t9-2)
          )
      )
    )
  )

(defstate die-eaten (kanga-lizard)
  :virtual #t
  :event enemy-event-handler
  :enter (behavior ()
    self
    (waschase-play-speech 0)
    (on-dying self)
    (let ((v1-3 (-> self root root-prim)))
      (set! (-> v1-3 prim-core collide-as) (collide-spec))
      (set! (-> v1-3 prim-core collide-with) (collide-spec))
      )
    0
    (set-time! (-> self state-time))
    (set! (-> self hit-points) 0.0)
    (nav-enemy-method-184 self)
    (nav-enemy-method-182 self)
    (nav-enemy-method-178 self)
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.075))
    (let ((f30-0 (rnd-float-range self 0.8 1.2)))
      (ja-no-eval :group! kanga-lizard-flut-kanga-catch-ja :num! (seek! max f30-0) :frame-num (ja-aframe 20.0 0))
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek! max f30-0))
        )
      )
    (send-event self 'death-end)
    (let ((gp-1 (-> self child)))
      (while gp-1
        (send-event (ppointer->process gp-1) 'notice 'die)
        (set! gp-1 (-> gp-1 0 brother))
        )
      )
    (while (-> self child)
      (suspend)
      )
    (cleanup-for-death self)
    )
  :post nav-enemy-simple-post
  )

(defmethod draw ((this hud-kanga-lizard))
  (set-hud-piece-position! (-> this sprites 0) (the int (+ 472.0 (* 130.0 (-> this offset)))) 160)
  (format (clear (-> this strings 0 text)) "~D" (-> this values 0 current))
  (set-as-offset-from! (the-as hud-sprite (-> this strings 0 pos)) (-> this sprites 0 pos) -16 65)
  ((method-of-type hud draw) this)
  0
  (none)
  )

(defmethod update-values! ((this hud-kanga-lizard))
  (set! (-> this values 0 target) (the int (-> *game-info* counter)))
  ((method-of-type hud update-values!) this)
  0
  (none)
  )

(defmethod init-callback ((this hud-kanga-lizard))
  (set! (-> this level) (level-get *level* 'waschase))
  (set! (-> this gui-id)
        (add-process *gui-control* this (gui-channel hud-middle-right) (gui-action hidden) (-> this name) 81920.0 0)
        )
  (logior! (-> this flags) (hud-flags show))
  (set! (-> this sprites 0 tid) (the-as texture-id (get-texture hud-kanga-lizard waschase-minimap)))
  (set! (-> this sprites 0 scale-x) 1.0)
  (set! (-> this sprites 0 scale-y) 1.0)
  (set! (-> this sprites 0 flags) (hud-sprite-flags hsf2))
  (alloc-string-if-needed this 0)
  (set! (-> this strings 0 scale) 0.6)
  (set! (-> this strings 0 flags) (font-flags shadow kerning right large))
  0
  (none)
  )

(deftype task-manager-kanga-lizard (task-manager)
  ((manager-entity     entity)
   (check-timer        time-frame)
   (main-timer         time-frame)
   (actor-group        (pointer actor-group))
   (actor-group-count  int32)
   (dead-mask          uint32)
   (last-eaten-talk    int8)
   (last-die-talk      int8)
   (been-on-flut       symbol)
   )
  (:methods
    (init-actor-group! (_type_) none)
    )
  )


(defstate active (task-manager-kanga-lizard)
  :virtual #t
  :enter (behavior ()
    (let ((t9-0 (-> (method-of-type task-manager active) enter)))
      (if t9-0
          (t9-0)
          )
      )
    (set! (-> self check-timer) 0)
    (set-time! (-> self main-timer))
    (set! (-> self been-on-flut) #f)
    )
  )

(defmethod taskman-event-handler ((this task-manager-kanga-lizard) (arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
  (case arg2
    (('should-live?)
     (when (> (-> this actor-group-count) 0)
       (let ((a1-1 (-> arg3 param 0))
             (v1-3 1)
             )
         (dotimes (a2-1 (-> this actor-group 0 length))
           (if (= a1-1 (-> this actor-group 0 data a2-1 actor))
               (return (not (logtest? v1-3 (-> this dead-mask))))
               )
           (set! v1-3 (* v1-3 2))
           )
         )
       )
     #f
     )
    (('dying)
     (when (> (-> this actor-group-count) 0)
       (let ((a1-2 (-> arg3 param 0))
             (v1-9 1)
             )
         (dotimes (a2-2 (-> this actor-group 0 length))
           (when (= a1-2 (-> this actor-group 0 data a2-2 actor))
             (logior! (-> this dead-mask) v1-9)
             (return #t)
             )
           (set! v1-9 (* v1-9 2))
           )
         )
       )
     #f
     )
    (else
      ((method-of-type task-manager taskman-event-handler) this arg0 arg1 arg2 arg3)
      )
    )
  )

;; WARN: Return type mismatch connection vs none.
(defmethod task-manager-method-26 ((this task-manager-kanga-lizard))
  (let ((t9-0 (method-of-type task-manager task-manager-method-26)))
    (t9-0 this)
    )
  (when (time-elapsed? (-> this check-timer) (seconds 0.1))
    (init-actor-group! this)
    (when (> (-> this actor-group-count) 0)
      (let ((a0-4 1)
            (s5-0 0)
            )
        (let ((v1-9 0))
          (dotimes (a1-0 (-> this actor-group 0 length))
            (let ((a2-3 (-> this actor-group 0 data a1-0 actor)))
              (if (logtest? (-> a2-3 extra perm status) (entity-perm-status subtask-complete))
                  (logior! (-> this dead-mask) a0-4)
                  )
              (when (not (logtest? a0-4 (-> this dead-mask)))
                (+! s5-0 1)
                (let ((a2-5 (-> a2-3 extra process)))
                  (if (and a2-5 (-> a2-5 next-state) (= (-> a2-5 next-state name) 'flee))
                      (+! v1-9 1)
                      )
                  )
                )
              )
            (set! a0-4 (* a0-4 2))
            )
          (cond
            ((zero? s5-0)
             (waschase-play-speech 8)
             )
            ((and *target* (focus-test? *target* dangerous))
             )
            ((nonzero? v1-9)
             (waschase-play-speech 4)
             )
            ((= s5-0 1)
             (waschase-play-speech 3)
             )
            ((or (-> this been-on-flut) (time-elapsed? (-> this main-timer) (seconds 10)))
             (waschase-play-speech 6)
             )
            )
          )
        (set! (-> *game-info* counter) (the float s5-0))
        (if (and (zero? s5-0)
                 (or (not *target*)
                     (not (and (-> *target* next-state) (= (-> *target* next-state name) 'target-flut-kanga-catch)))
                     )
                 )
            (send-event this 'complete)
            )
        )
      )
    (set-time! (-> this check-timer))
    )
  (when (and *target* (focus-test? *target* flut))
    (set! (-> this been-on-flut) #t)
    (if (!= (-> *setting-control* user-target music) 'waschase)
        (set-setting! 'music 'waschase 0.0 0)
        )
    )
  (none)
  )

;; WARN: Return type mismatch object vs none.
(defmethod init-actor-group! ((this task-manager-kanga-lizard))
  (local-vars (sv-16 res-tag))
  (when (not (-> this manager-entity))
    (let ((a0-2 (entity-by-name "flut-1")))
      (cond
        (a0-2
          (set! (-> this manager-entity) a0-2)
          (set! sv-16 (new 'static 'res-tag))
          (let ((v1-2 (res-lump-data a0-2 'actor-groups pointer :tag-ptr (& sv-16))))
            (cond
              ((and v1-2 (nonzero? (-> sv-16 elt-count)))
               (set! (-> this actor-group-count) (the-as int (-> sv-16 elt-count)))
               (set! (-> this actor-group) (the-as (pointer actor-group) v1-2))
               )
              (else
                (format 0 "ERROR: ~S: entity missing actor-group!~%" (game-task->string (-> this node-info task)))
                )
              )
            )
          (set! (-> this hud-counter)
                (ppointer->handle (process-spawn hud-kanga-lizard :init hud-init-by-other :name "hud-kanga-lizard" :to this))
                )
          )
        (else
          (format 0 "ERROR: ~S: unable to find entity~%" (game-task->string (-> this node-info task)))
          )
        )
      )
    )
  (none)
  )

;; WARN: Return type mismatch object vs none.
(defmethod task-manager-method-25 ((this task-manager-kanga-lizard))
  (let ((t9-0 (method-of-type task-manager task-manager-method-25)))
    (t9-0 this)
    )
  (send-event (handle->process (-> this hud-counter)) 'hide-and-die)
  (none)
  )

(defmethod set-time-limit ((this task-manager-kanga-lizard))
  (let ((t9-0 (method-of-type task-manager set-time-limit)))
    (t9-0 this)
    )
  (set! (-> this manager-entity) #f)
  (set! (-> this actor-group-count) 0)
  (set! (-> this dead-mask) (the-as uint 0))
  (set-setting! 'extra-bank '((wascity3 waskang1)) 0.0 0)
  (reset-waschase-speeches)
  (none)
  )
