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

(import "goal_src/jak1/import/eichar-ag.gc")

;; failed to figure out what this is:
(defskelgroup *jchar-sg* eichar eichar-lod0-jg -1
              ((eichar-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 2 0 3)
              :longest-edge (meters 1)
              :shadow eichar-shadow-mg
              :texture-level 2
              :sort 1
              )

;; definition for symbol *target-shadow-control*, type shadow-control
(define *target-shadow-control*
  (new 'static 'shadow-control :settings (new 'static 'shadow-settings
                                           :flags (shadow-flags disable-fade)
                                           :shadow-dir (new 'static 'vector :x -0.4226 :y -0.9063 :w 409600.0)
                                           :bot-plane (new 'static 'plane :y 1.0 :w 37683.2)
                                           :top-plane (new 'static 'plane :y 1.0 :w 4096.0)
                                           )
                               )
  )

;; definition of type target-bank
(deftype target-bank (basic)
  ((jump-collide-offset          meters             :offset-assert   4)
   (jump-height-min              meters             :offset-assert   8)
   (jump-height-max              meters             :offset-assert  12)
   (double-jump-height-min       meters             :offset-assert  16)
   (double-jump-height-max       meters             :offset-assert  20)
   (flip-jump-height-min         meters             :offset-assert  24)
   (flip-jump-height-max         meters             :offset-assert  28)
   (duck-jump-height-min         meters             :offset-assert  32)
   (duck-jump-height-max         meters             :offset-assert  36)
   (flop-jump-height-min         meters             :offset-assert  40)
   (flop-jump-height-max         meters             :offset-assert  44)
   (attack-jump-height-min       meters             :offset-assert  48)
   (attack-jump-height-max       meters             :offset-assert  52)
   (edge-grab-jump-height-min    meters             :offset-assert  56)
   (edge-grab-jump-height-max    meters             :offset-assert  60)
   (swim-jump-height-min         meters             :offset-assert  64)
   (swim-jump-height-max         meters             :offset-assert  68)
   (tube-jump-height-min         meters             :offset-assert  72)
   (tube-jump-height-max         meters             :offset-assert  76)
   (wheel-duration               time-frame         :offset-assert  80)
   (wheel-jump-pre-window        time-frame         :offset-assert  88)
   (wheel-jump-post-window       time-frame         :offset-assert  96)
   (wheel-timeout                time-frame         :offset-assert 104)
   (wheel-speed-min              meters             :offset-assert 112)
   (wheel-speed-inc              meters             :offset-assert 116)
   (wheel-flip-duration          time-frame         :offset-assert 120)
   (wheel-flip-height            meters             :offset-assert 128)
   (wheel-flip-dist              meters             :offset-assert 132)
   (wheel-flip-art-height        meters             :offset-assert 136)
   (wheel-flip-art-dist          meters             :offset-assert 140)
   (duck-slide-distance          meters             :offset-assert 144)
   (fall-far                     meters             :offset-assert 148)
   (fall-far-inc                 meters             :offset-assert 152)
   (attack-timeout               time-frame         :offset-assert 160)
   (ground-timeout               time-frame         :offset-assert 168)
   (slide-down-timeout           time-frame         :offset-assert 176)
   (fall-timeout                 time-frame         :offset-assert 184)
   (fall-stumble-threshold       meters             :offset-assert 192)
   (yellow-projectile-speed      meters             :offset-assert 196)
   (hit-invulnerable-timeout     time-frame         :offset-assert 200)
   (run-cycle-length             float              :offset-assert 208)
   (walk-cycle-dist              meters             :offset-assert 212)
   (walk-up-cycle-dist           meters             :offset-assert 216)
   (walk-down-cycle-dist         meters             :offset-assert 220)
   (walk-side-cycle-dist         meters             :offset-assert 224)
   (run-cycle-dist               meters             :offset-assert 228)
   (run-up-cycle-dist            meters             :offset-assert 232)
   (run-down-cycle-dist          meters             :offset-assert 236)
   (run-side-cycle-dist          meters             :offset-assert 240)
   (run-wall-cycle-dist          meters             :offset-assert 244)
   (duck-walk-cycle-dist         meters             :offset-assert 248)
   (wade-shallow-walk-cycle-dist meters             :offset-assert 252)
   (wade-deep-walk-cycle-dist    meters             :offset-assert 256)
   (smack-surface-dist           meters             :offset-assert 260)
   (smack-surface-height         meters             :offset-assert 264)
   (min-dive-depth               meters             :offset-assert 268)
   (root-radius                  meters             :offset-assert 272)
   (root-offset                  vector     :inline :offset-assert 288)
   (body-radius                  meters             :offset-assert 304)
   (edge-radius                  meters             :offset-assert 308)
   (edge-offset                  vector     :inline :offset-assert 320)
   (head-radius                  meters             :offset-assert 336)
   (head-height                  meters             :offset-assert 340)
   (head-offset                  vector     :inline :offset-assert 352)
   (spin-radius                  meters             :offset-assert 368)
   (spin-offset                  vector     :inline :offset-assert 384)
   (duck-spin-radius             meters             :offset-assert 400)
   (duck-spin-offset             vector     :inline :offset-assert 416)
   (punch-radius                 meters             :offset-assert 432)
   (punch-offset                 vector     :inline :offset-assert 448)
   (uppercut-radius              meters             :offset-assert 464)
   (uppercut0-offset             vector     :inline :offset-assert 480)
   (uppercut1-offset             vector     :inline :offset-assert 496)
   (flop-radius                  meters             :offset-assert 512)
   (flop0-offset                 vector     :inline :offset-assert 528)
   (flop1-offset                 vector     :inline :offset-assert 544)
   (stuck-time                   seconds            :offset-assert 560)
   (stuck-timeout                seconds            :offset-assert 568)
   (stuck-distance               meters             :offset-assert 576)
   (tongue-pull-speed-min        float              :offset-assert 580)
   (tongue-pull-speed-max        float              :offset-assert 584)
   (yellow-attack-timeout        time-frame         :offset-assert 592)
   )
  :method-count-assert 9
  :size-assert         #x258
  :flag-assert         #x900000258
  )

;; definition for method 3 of type target-bank
(defmethod inspect target-bank ((obj target-bank))
  (format #t "[~8x] ~A~%" obj (-> obj type))
  (format #t "~Tjump-collide-offset: (meters ~m)~%" (-> obj jump-collide-offset))
  (format #t "~Tjump-height-min: (meters ~m)~%" (-> obj jump-height-min))
  (format #t "~Tjump-height-max: (meters ~m)~%" (-> obj jump-height-max))
  (format #t "~Tdouble-jump-height-min: (meters ~m)~%" (-> obj double-jump-height-min))
  (format #t "~Tdouble-jump-height-max: (meters ~m)~%" (-> obj double-jump-height-max))
  (format #t "~Tflip-jump-height-min: (meters ~m)~%" (-> obj flip-jump-height-min))
  (format #t "~Tflip-jump-height-max: (meters ~m)~%" (-> obj flip-jump-height-max))
  (format #t "~Tduck-jump-height-min: (meters ~m)~%" (-> obj duck-jump-height-min))
  (format #t "~Tduck-jump-height-max: (meters ~m)~%" (-> obj duck-jump-height-max))
  (format #t "~Tflop-jump-height-min: (meters ~m)~%" (-> obj flop-jump-height-min))
  (format #t "~Tflop-jump-height-max: (meters ~m)~%" (-> obj flop-jump-height-max))
  (format #t "~Tattack-jump-height-min: (meters ~m)~%" (-> obj attack-jump-height-min))
  (format #t "~Tattack-jump-height-max: (meters ~m)~%" (-> obj attack-jump-height-max))
  (format #t "~Tedge-grab-jump-height-min: (meters ~m)~%" (-> obj edge-grab-jump-height-min))
  (format #t "~Tedge-grab-jump-height-max: (meters ~m)~%" (-> obj edge-grab-jump-height-max))
  (format #t "~Tswim-jump-height-min: (meters ~m)~%" (-> obj swim-jump-height-min))
  (format #t "~Tswim-jump-height-max: (meters ~m)~%" (-> obj swim-jump-height-max))
  (format #t "~Ttube-jump-height-min: (meters ~m)~%" (-> obj tube-jump-height-min))
  (format #t "~Ttube-jump-height-max: (meters ~m)~%" (-> obj tube-jump-height-max))
  (format #t "~Twheel-duration: ~D~%" (-> obj wheel-duration))
  (format #t "~Twheel-jump-pre-window: ~D~%" (-> obj wheel-jump-pre-window))
  (format #t "~Twheel-jump-post-window: ~D~%" (-> obj wheel-jump-post-window))
  (format #t "~Twheel-timeout: ~D~%" (-> obj wheel-timeout))
  (format #t "~Twheel-speed-min: (meters ~m)~%" (-> obj wheel-speed-min))
  (format #t "~Twheel-speed-inc: (meters ~m)~%" (-> obj wheel-speed-inc))
  (format #t "~Twheel-flip-duration: ~D~%" (-> obj wheel-flip-duration))
  (format #t "~Twheel-flip-height: (meters ~m)~%" (-> obj wheel-flip-height))
  (format #t "~Twheel-flip-dist: (meters ~m)~%" (-> obj wheel-flip-dist))
  (format #t "~Twheel-flip-art-height: (meters ~m)~%" (-> obj wheel-flip-art-height))
  (format #t "~Twheel-flip-art-dist: (meters ~m)~%" (-> obj wheel-flip-art-dist))
  (format #t "~Tduck-slide-distance: (meters ~m)~%" (-> obj duck-slide-distance))
  (format #t "~Tfall-far: (meters ~m)~%" (-> obj fall-far))
  (format #t "~Tfall-far-inc: (meters ~m)~%" (-> obj fall-far-inc))
  (format #t "~Tattack-timeout: ~D~%" (-> obj attack-timeout))
  (format #t "~Tground-timeout: ~D~%" (-> obj ground-timeout))
  (format #t "~Tslide-down-timeout: ~D~%" (-> obj slide-down-timeout))
  (format #t "~Tfall-timeout: ~D~%" (-> obj fall-timeout))
  (format #t "~Tfall-stumble-threshold: (meters ~m)~%" (-> obj fall-stumble-threshold))
  (format #t "~Tyellow-projectile-speed: (meters ~m)~%" (-> obj yellow-projectile-speed))
  (format #t "~Thit-invulnerable-timeout: ~D~%" (-> obj hit-invulnerable-timeout))
  (format #t "~Trun-cycle-length: ~f~%" (-> obj run-cycle-length))
  (format #t "~Twalk-cycle-dist: (meters ~m)~%" (-> obj walk-cycle-dist))
  (format #t "~Twalk-up-cycle-dist: (meters ~m)~%" (-> obj walk-up-cycle-dist))
  (format #t "~Twalk-down-cycle-dist: (meters ~m)~%" (-> obj walk-down-cycle-dist))
  (format #t "~Twalk-side-cycle-dist: (meters ~m)~%" (-> obj walk-side-cycle-dist))
  (format #t "~Trun-cycle-dist: (meters ~m)~%" (-> obj run-cycle-dist))
  (format #t "~Trun-up-cycle-dist: (meters ~m)~%" (-> obj run-up-cycle-dist))
  (format #t "~Trun-down-cycle-dist: (meters ~m)~%" (-> obj run-down-cycle-dist))
  (format #t "~Trun-side-cycle-dist: (meters ~m)~%" (-> obj run-side-cycle-dist))
  (format #t "~Trun-wall-cycle-dist: (meters ~m)~%" (-> obj run-wall-cycle-dist))
  (format #t "~Tduck-walk-cycle-dist: (meters ~m)~%" (-> obj duck-walk-cycle-dist))
  (format #t "~Twade-shallow-walk-cycle-dist: (meters ~m)~%" (-> obj wade-shallow-walk-cycle-dist))
  (format #t "~Twade-deep-walk-cycle-dist: (meters ~m)~%" (-> obj wade-deep-walk-cycle-dist))
  (format #t "~Tsmack-surface-dist: (meters ~m)~%" (-> obj smack-surface-dist))
  (format #t "~Tsmack-surface-height: (meters ~m)~%" (-> obj smack-surface-height))
  (format #t "~Tmin-dive-depth: (meters ~m)~%" (-> obj min-dive-depth))
  (format #t "~Troot-radius: (meters ~m)~%" (-> obj root-radius))
  (format #t "~Troot-offset: ~`vector`P~%" (-> obj root-offset))
  (format #t "~Tbody-radius: (meters ~m)~%" (-> obj body-radius))
  (format #t "~Tedge-radius: (meters ~m)~%" (-> obj edge-radius))
  (format #t "~Tedge-offset: ~`vector`P~%" (-> obj edge-offset))
  (format #t "~Thead-radius: (meters ~m)~%" (-> obj head-radius))
  (format #t "~Thead-height: (meters ~m)~%" (-> obj head-height))
  (format #t "~Thead-offset: ~`vector`P~%" (-> obj head-offset))
  (format #t "~Tspin-radius: (meters ~m)~%" (-> obj spin-radius))
  (format #t "~Tspin-offset: ~`vector`P~%" (-> obj spin-offset))
  (format #t "~Tduck-spin-radius: (meters ~m)~%" (-> obj duck-spin-radius))
  (format #t "~Tduck-spin-offset: ~`vector`P~%" (-> obj duck-spin-offset))
  (format #t "~Tpunch-radius: (meters ~m)~%" (-> obj punch-radius))
  (format #t "~Tpunch-offset: ~`vector`P~%" (-> obj punch-offset))
  (format #t "~Tuppercut-radius: (meters ~m)~%" (-> obj uppercut-radius))
  (format #t "~Tuppercut0-offset: ~`vector`P~%" (-> obj uppercut0-offset))
  (format #t "~Tuppercut1-offset: ~`vector`P~%" (-> obj uppercut1-offset))
  (format #t "~Tflop-radius: (meters ~m)~%" (-> obj flop-radius))
  (format #t "~Tflop0-offset: ~`vector`P~%" (-> obj flop0-offset))
  (format #t "~Tflop1-offset: ~`vector`P~%" (-> obj flop1-offset))
  (format #t "~Tstuck-time: (seconds ~e)~%" (-> obj stuck-time))
  (format #t "~Tstuck-timeout: (seconds ~e)~%" (-> obj stuck-timeout))
  (format #t "~Tstuck-distance: (meters ~m)~%" (-> obj stuck-distance))
  (format #t "~Ttongue-pull-speed-min: ~f~%" (-> obj tongue-pull-speed-min))
  (format #t "~Ttongue-pull-speed-max: ~f~%" (-> obj tongue-pull-speed-max))
  (format #t "~Tyellow-attack-timeout: ~D~%" (-> obj yellow-attack-timeout))
  obj
  )

;; definition for symbol *TARGET-bank*, type target-bank
(define *TARGET-bank* (new 'static 'target-bank
                        :jump-collide-offset (meters 0.7)
                        :jump-height-min (meters 1.01)
                        :jump-height-max (meters 3.5)
                        :double-jump-height-min (meters 1)
                        :double-jump-height-max (meters 2.5)
                        :flip-jump-height-min (meters 5)
                        :flip-jump-height-max (meters 7)
                        :duck-jump-height-min (meters 5)
                        :duck-jump-height-max (meters 7)
                        :flop-jump-height-min (meters 5)
                        :flop-jump-height-max (meters 7)
                        :attack-jump-height-min (meters 4)
                        :attack-jump-height-max (meters 5.5)
                        :edge-grab-jump-height-min (meters 1.7)
                        :edge-grab-jump-height-max (meters 1.7)
                        :swim-jump-height-min (meters 5)
                        :swim-jump-height-max (meters 5)
                        :tube-jump-height-min (meters 1.75)
                        :tube-jump-height-max (meters 2.5)
                        :wheel-duration (seconds 0.5)
                        :wheel-jump-pre-window (seconds 1)
                        :wheel-jump-post-window (seconds 0.1)
                        :wheel-speed-min (meters 11.5)
                        :wheel-speed-inc (meters 1.5)
                        :wheel-flip-duration (seconds 0.7)
                        :wheel-flip-height (meters 3.52)
                        :wheel-flip-dist (meters 17.3)
                        :wheel-flip-art-height (meters 3.2969)
                        :wheel-flip-art-dist (meters 12.5)
                        :duck-slide-distance (meters 5.75)
                        :fall-far (meters 30)
                        :fall-far-inc (meters 20)
                        :attack-timeout (seconds 0.3)
                        :ground-timeout (seconds 0.2)
                        :slide-down-timeout (seconds 0.2)
                        :fall-timeout (seconds 1)
                        :fall-stumble-threshold (meters 39.9)
                        :yellow-projectile-speed (meters 60)
                        :hit-invulnerable-timeout (seconds 3)
                        :run-cycle-length 60.0
                        :walk-cycle-dist (meters 2.8)
                        :walk-up-cycle-dist (meters 2.8)
                        :walk-down-cycle-dist (meters 2.8)
                        :walk-side-cycle-dist (meters 2.8)
                        :run-cycle-dist (meters 6.25)
                        :run-up-cycle-dist (meters 5)
                        :run-down-cycle-dist (meters 5)
                        :run-side-cycle-dist (meters 6.25)
                        :run-wall-cycle-dist (meters 2.8)
                        :duck-walk-cycle-dist (meters 3.25)
                        :wade-shallow-walk-cycle-dist (meters 6)
                        :wade-deep-walk-cycle-dist (meters 6)
                        :smack-surface-dist (meters 1.25)
                        :min-dive-depth (meters 2)
                        :root-radius (meters 2.2)
                        :root-offset (new 'static 'vector :y 4915.2 :w 1.0)
                        :body-radius (meters 0.7)
                        :edge-radius (meters 0.35)
                        :edge-offset (new 'static 'vector :y 4915.2 :z 4096.0 :w 1.0)
                        :head-radius (meters 0.7)
                        :head-height (meters 1.4)
                        :head-offset (new 'static 'vector :y 4915.2 :w 1.0)
                        :spin-radius (meters 2.2)
                        :spin-offset (new 'static 'vector :y 6553.6 :w 1.0)
                        :duck-spin-radius (meters 1.2)
                        :duck-spin-offset (new 'static 'vector :y 4096.0 :w 1.0)
                        :punch-radius (meters 1.3)
                        :punch-offset (new 'static 'vector :y 5324.8 :w 1.0)
                        :uppercut-radius (meters 1)
                        :uppercut0-offset (new 'static 'vector :y 3276.8 :w 1.0)
                        :uppercut1-offset (new 'static 'vector :y 9011.2 :w 1.0)
                        :flop-radius (meters 1.4)
                        :flop0-offset (new 'static 'vector :y 3276.8 :w 1.0)
                        :flop1-offset (new 'static 'vector :y 9011.2 :w 1.0)
                        :stuck-time (seconds 0.3)
                        :stuck-timeout (seconds 2)
                        :stuck-distance (meters 0.05)
                        :tongue-pull-speed-min 0.15
                        :tongue-pull-speed-max 0.22
                        :yellow-attack-timeout (seconds 0.2)
                        )
        )

;; definition for function target-start-attack
;; INFO: Return type mismatch int vs none.
(defbehavior target-start-attack target ()
  (+! (-> self control unknown-dword50) 1)
  (set! (-> self control unknown-dword51) 0)
  0
  (none)
  )

;; definition for function target-danger-set!
(defbehavior target-danger-set! target ((arg0 symbol) (arg1 symbol))
  (let ((s4-0 (-> self control unknown-sphere00))
        (s5-0 (-> self control unknown-sphere01))
        (gp-0 (-> self control unknown-sphere02))
        (f30-0 (if arg1
                   2.0
                   1.0
                   )
               )
        )
    (dotimes (v1-4 3)
      (set! (-> self control unknown-sphere-array00 v1-4 prim-core offense) (collide-offense normal-attack))
      )
    (sphere<-vector+r!
      (the-as sphere (-> self control root-prim local-sphere))
      (-> *TARGET-bank* root-offset)
      (-> *TARGET-bank* root-radius)
      )
    (set! (-> self control unknown-symbol30) arg0)
    (logclear! (-> self state-flags) (state-flags dangerous))
    (set! (-> s4-0 transform-index) -2)
    (set! (-> s4-0 prim-core collide-as) (collide-kind))
    (set! (-> s4-0 collide-with) (collide-kind))
    (set! (-> s4-0 local-sphere w) 0.0)
    (set! (-> s4-0 prim-core offense) (collide-offense no-offense))
    (set! (-> s5-0 transform-index) -2)
    (set! (-> s5-0 prim-core collide-as) (collide-kind))
    (set! (-> s5-0 collide-with) (collide-kind))
    (set! (-> s5-0 local-sphere w) 0.0)
    (set! (-> s5-0 prim-core offense) (collide-offense no-offense))
    (set! (-> gp-0 transform-index) -2)
    (set! (-> gp-0 prim-core collide-as) (collide-kind))
    (set! (-> gp-0 collide-with) (collide-kind))
    (set! (-> gp-0 local-sphere w) 0.0)
    (set! (-> gp-0 prim-core offense) (collide-offense no-offense))
    (case arg0
      (('harmless #f)
       (set! (-> self control unknown-symbol30) #f)
       (target-collide-set! (-> self control unknown-symbol00) (-> self control unknown-float90))
       )
      (('spin 'spin-air)
       (sphere<-vector+r!
         (the-as sphere (-> self control root-prim local-sphere))
         (new 'static 'vector :y 6553.6 :w 1.0)
         9830.4
         )
       (logior! (-> self state-flags) (state-flags dangerous))
       (set! (-> s4-0 prim-core collide-as) (collide-kind target target-attack))
       (set! (-> s4-0 collide-with)
             (collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
             )
       (sphere<-vector+r!
         (the-as sphere (-> s4-0 local-sphere))
         (-> *TARGET-bank* spin-offset)
         (-> *TARGET-bank* spin-radius)
         )
       )
      (('duck-spin)
       (sphere<-vector+r!
         (the-as sphere (-> self control root-prim local-sphere))
         (new 'static 'vector :y 6553.6 :w 1.0)
         10649.6
         )
       (logior! (-> self state-flags) (state-flags dangerous))
       (set! (-> s4-0 prim-core collide-as) (collide-kind target target-attack))
       (set! (-> s4-0 collide-with)
             (collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
             )
       (sphere<-vector+r!
         (the-as sphere (-> s4-0 local-sphere))
         (-> *TARGET-bank* duck-spin-offset)
         (-> *TARGET-bank* duck-spin-radius)
         )
       (set! (-> s5-0 prim-core collide-as) (collide-kind target target-attack))
       (set! (-> s5-0 collide-with)
             (collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
             )
       (sphere<-vector+r! (the-as sphere (-> s5-0 local-sphere)) *null-vector* (-> *TARGET-bank* duck-spin-radius))
       (set! (-> s5-0 transform-index) 32)
       )
      (('duck-slide)
       (logior! (-> self state-flags) (state-flags dangerous))
       (set! (-> s4-0 prim-core collide-as) (collide-kind target target-attack))
       (set! (-> s4-0 collide-with)
             (collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
             )
       (sphere<-vector+r!
         (the-as sphere (-> s4-0 local-sphere))
         (-> *TARGET-bank* duck-spin-offset)
         (-> *TARGET-bank* duck-spin-radius)
         )
       (set! (-> s5-0 prim-core collide-as) (collide-kind target target-attack))
       (set! (-> s5-0 collide-with)
             (collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
             )
       (sphere<-vector+r! (the-as sphere (-> s5-0 local-sphere)) *null-vector* (-> *TARGET-bank* duck-spin-radius))
       (set! (-> s5-0 transform-index) 28)
       )
      (('wheel-solid)
       (logior! (-> self state-flags) (state-flags dangerous))
       (set! (-> s4-0 prim-core collide-as) (collide-kind target target-attack))
       (set! (-> s4-0 collide-with)
             (collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
             )
       (dotimes (v1-57 3)
         (set! (-> self control unknown-sphere-array00 v1-57 prim-core offense) (collide-offense touch))
         )
       (sphere<-vector+r!
         (the-as sphere (-> s4-0 local-sphere))
         (-> *TARGET-bank* duck-spin-offset)
         (+ 819.2 (-> *TARGET-bank* duck-spin-radius))
         )
       (set! (-> s5-0 prim-core collide-as) (collide-kind target target-attack))
       (set! (-> s5-0 collide-with)
             (collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
             )
       (sphere<-vector+r! (the-as sphere (-> s5-0 local-sphere)) *null-vector* (-> *TARGET-bank* duck-spin-radius))
       (set! (-> s5-0 transform-index) 7)
       (set! (-> self control unknown-symbol30) 'roll)
       )
      (('flip)
       (logior! (-> self state-flags) (state-flags dangerous))
       (set! (-> s4-0 prim-core collide-as) (collide-kind target target-attack))
       (set! (-> s4-0 collide-with)
             (collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
             )
       (dotimes (v1-71 3)
         (set! (-> self control unknown-sphere-array00 v1-71 prim-core offense) (collide-offense touch))
         )
       (sphere<-vector+r!
         (the-as sphere (-> s4-0 local-sphere))
         (-> *TARGET-bank* duck-spin-offset)
         (+ 819.2 (-> *TARGET-bank* duck-spin-radius))
         )
       (set! (-> s5-0 prim-core collide-as) (collide-kind target target-attack))
       (set! (-> s5-0 collide-with)
             (collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
             )
       (sphere<-vector+r! (the-as sphere (-> s5-0 local-sphere)) *null-vector* (-> *TARGET-bank* duck-spin-radius))
       (set! (-> s5-0 transform-index) 7)
       (set! (-> self control unknown-symbol30) 'flip)
       )
      (('punch)
       (sphere<-vector+r!
         (the-as sphere (-> self control root-prim local-sphere))
         (new 'static 'vector :y 6553.6 :w 1.0)
         11878.4
         )
       (logior! (-> self state-flags) (state-flags dangerous))
       (set! (-> s4-0 prim-core collide-as) (collide-kind target target-attack))
       (set! (-> s4-0 collide-with)
             (collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
             )
       (sphere<-vector+r!
         (the-as sphere (-> s4-0 local-sphere))
         (-> *TARGET-bank* punch-offset)
         (-> *TARGET-bank* punch-radius)
         )
       (set! (-> s5-0 prim-core collide-as) (collide-kind target target-attack))
       (set! (-> s5-0 collide-with)
             (collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
             )
       (sphere<-vector+r! (the-as sphere (-> s5-0 local-sphere)) *null-vector* (-> *TARGET-bank* punch-radius))
       (set! (-> s5-0 transform-index) 22)
       )
      (('uppercut)
       (sphere<-vector+r!
         (the-as sphere (-> self control root-prim local-sphere))
         (new 'static 'vector :y 6553.6 :w 1.0)
         11878.4
         )
       (logior! (-> self state-flags) (state-flags dangerous))
       (set! (-> s4-0 prim-core collide-as) (collide-kind target target-attack))
       (set! (-> s4-0 collide-with)
             (collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
             )
       (sphere<-vector+r!
         (the-as sphere (-> s4-0 local-sphere))
         (-> *TARGET-bank* uppercut0-offset)
         (-> *TARGET-bank* uppercut-radius)
         )
       (set! (-> s5-0 prim-core collide-as) (collide-kind target target-attack))
       (set! (-> s5-0 collide-with)
             (collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
             )
       (sphere<-vector+r! (the-as sphere (-> s5-0 local-sphere)) *null-vector* (-> *TARGET-bank* uppercut-radius))
       (set! (-> s5-0 transform-index) 22)
       (set! (-> gp-0 prim-core collide-as) (collide-kind target target-attack))
       (set! (-> gp-0 collide-with)
             (collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
             )
       (sphere<-vector+r!
         (the-as sphere (-> gp-0 local-sphere))
         (-> *TARGET-bank* uppercut1-offset)
         (-> *TARGET-bank* uppercut-radius)
         )
       )
      (('flop)
       (logior! (-> self state-flags) (state-flags dangerous))
       (set! (-> s4-0 prim-core collide-as) (collide-kind target target-attack))
       (set! (-> s4-0 collide-with)
             (collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
             )
       (dotimes (v1-114 3)
         (set! (-> self control unknown-sphere-array00 v1-114 prim-core offense) (collide-offense strong-attack))
         )
       (sphere<-vector+r!
         (the-as sphere (-> s4-0 local-sphere))
         (-> *TARGET-bank* flop0-offset)
         (-> *TARGET-bank* flop-radius)
         )
       (set! f30-0 1.0)
       (set! (-> self control unknown-symbol30) 'flop)
       )
      (('flop-down)
       (logior! (-> self state-flags) (state-flags dangerous))
       (set! (-> s4-0 prim-core collide-as) (collide-kind target target-attack))
       (set! (-> s4-0 collide-with)
             (collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
             )
       (dotimes (v1-124 3)
         (set! (-> self control unknown-sphere-array00 v1-124 prim-core offense) (collide-offense strong-attack))
         )
       (sphere<-vector+r!
         (the-as sphere (-> s4-0 local-sphere))
         (-> *TARGET-bank* flop0-offset)
         (-> *TARGET-bank* flop-radius)
         )
       (set! (-> s5-0 prim-core collide-as) (collide-kind target target-attack))
       (set! (-> s5-0 collide-with)
             (collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
             )
       (sphere<-vector+r!
         (the-as sphere (-> s5-0 local-sphere))
         (-> *TARGET-bank* flop1-offset)
         (-> *TARGET-bank* flop-radius)
         )
       (if (!= f30-0 1.0)
           (set! f30-0 2.1)
           )
       (set! (-> self control unknown-symbol30) 'flop)
       )
      (('flut-attack)
       (sphere<-vector+r!
         (the-as sphere (-> self control root-prim local-sphere))
         (new 'static 'vector :y 6553.6 :w 1.0)
         12288.0
         )
       (logior! (-> self state-flags) (state-flags dangerous))
       (set! (-> s4-0 prim-core collide-as) (collide-kind target target-attack))
       (set! (-> s4-0 collide-with)
             (collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
             )
       (sphere<-vector+r!
         (the-as sphere (-> s4-0 local-sphere))
         (-> *TARGET-bank* spin-offset)
         (+ 2048.0 (-> *TARGET-bank* punch-radius))
         )
       (set! (-> s5-0 prim-core collide-as) (collide-kind target target-attack))
       (set! (-> s5-0 collide-with)
             (collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
             )
       (sphere<-vector+r!
         (the-as sphere (-> s5-0 local-sphere))
         *null-vector*
         (+ 1228.8 (-> *TARGET-bank* punch-radius))
         )
       (set! (-> s5-0 transform-index) 37)
       (dotimes (v1-148 3)
         (set! (-> self control unknown-sphere-array00 v1-148 prim-core offense) (collide-offense strong-attack))
         )
       )
      (else
        (format 0 "ERROR: ~A unknown danger mode ~A" self arg0)
        )
      )
    (when (and (!= f30-0 1.0) (not (or (= arg0 'harmless) (= arg0 #f))))
      (set! (-> self control root-prim local-sphere w) (* (-> self control root-prim local-sphere w) f30-0))
      (set! (-> s4-0 local-sphere w) (* (-> s4-0 local-sphere w) f30-0))
      (set! (-> s5-0 local-sphere w) (* (-> s5-0 local-sphere w) f30-0))
      (let ((f0-37 (* (-> gp-0 local-sphere w) f30-0)))
        (set! (-> gp-0 local-sphere w) f0-37)
        f0-37
        )
      )
    )
  )

;; definition for function target-collide-set!
(defbehavior target-collide-set! target ((arg0 symbol) (arg1 float))
  (let ((gp-0 (-> self control)))
    (set! (-> self control unknown-symbol00) arg0)
    (set! (-> self control unknown-float90) arg1)
    (dotimes (v1-2 3)
      (set! (-> gp-0 unknown-sphere-array00 v1-2 prim-core offense) (collide-offense touch))
      (set! (-> gp-0 unknown-sphere-array00 v1-2 transform-index) -2)
      )
    (case arg0
      (('pole)
       (set-vector! (-> gp-0 unknown-sphere-array00 0 local-sphere) 0.0 0.0 0.0 (-> *TARGET-bank* body-radius))
       (set-vector! (-> gp-0 unknown-sphere-array00 1 local-sphere) 0.0 0.0 0.0 (-> *TARGET-bank* body-radius))
       (set-vector! (-> gp-0 unknown-sphere-array00 2 local-sphere) 0.0 0.0 0.0 (-> *TARGET-bank* body-radius))
       (set! (-> gp-0 unknown-sphere-array00 0 transform-index) 28)
       (set! (-> gp-0 unknown-sphere-array00 1 transform-index) 26)
       (set! (-> gp-0 unknown-sphere-array00 2 transform-index) 7)
       )
      (('racer)
       (set! (-> gp-0 unknown-vector11 y) 4096.0)
       (sphere<-vector+r!
         (the-as sphere (-> gp-0 root-prim local-sphere))
         (new 'static 'vector :y 8192.0 :w 1.0)
         16384.0
         )
       (set-vector! (-> gp-0 unknown-sphere-array00 0 local-sphere) 0.0 6553.6 0.0 6553.6)
       (set-vector! (-> gp-0 unknown-sphere-array00 1 local-sphere) 0.0 9420.8 0.0 6553.6)
       (set-vector! (-> gp-0 unknown-sphere-array00 2 local-sphere) 0.0 12288.0 0.0 6553.6)
       (dotimes (v1-22 3)
         (set! (-> gp-0 unknown-sphere-array00 v1-22 prim-core offense) (collide-offense strong-attack))
         )
       )
      (('flut)
       (sphere<-vector+r!
         (the-as sphere (-> gp-0 root-prim local-sphere))
         (new 'static 'vector :y 8192.0 :w 1.0)
         12288.0
         )
       (set-vector! (-> gp-0 unknown-sphere-array00 0 local-sphere) 0.0 4915.2 0.0 4915.2)
       (set-vector! (-> gp-0 unknown-sphere-array00 1 local-sphere) 0.0 7782.4004 0.0 4915.2)
       (set-vector! (-> gp-0 unknown-sphere-array00 2 local-sphere) 0.0 10649.6 0.0 4915.2)
       )
      (('duck)
       (set! (-> self control unknown-float91) arg1)
       (let ((f30-0 (- 1.0 arg1)))
         (set! (-> gp-0 unknown-vector11 y) 0.0)
         (sphere<-vector+r!
           (the-as sphere (-> gp-0 root-prim local-sphere))
           (-> *TARGET-bank* root-offset)
           (-> *TARGET-bank* root-radius)
           )
         (set-vector!
           (-> gp-0 unknown-sphere-array00 0 local-sphere)
           0.0
           (-> *TARGET-bank* body-radius)
           (* 0.0 f30-0)
           (-> *TARGET-bank* body-radius)
           )
         (set-vector!
           (-> gp-0 unknown-sphere-array00 1 local-sphere)
           0.0
           (+ (-> *TARGET-bank* body-radius) (* 2867.2 f30-0))
           0.0
           (-> *TARGET-bank* body-radius)
           )
         (set-vector!
           (-> gp-0 unknown-sphere-array00 2 local-sphere)
           0.0
           (+ (-> *TARGET-bank* body-radius) (* 5734.4 f30-0))
           0.0
           (-> *TARGET-bank* body-radius)
           )
         )
       )
      (('tube)
       (set! (-> self control unknown-float91) arg1)
       (let ((f30-1 (- 1.0 arg1)))
         (set! (-> gp-0 unknown-vector11 y) 0.0)
         (sphere<-vector+r!
           (the-as sphere (-> gp-0 root-prim local-sphere))
           (-> *TARGET-bank* root-offset)
           (-> *TARGET-bank* root-radius)
           )
         (set-vector!
           (-> gp-0 unknown-sphere-array00 0 local-sphere)
           0.0
           (-> *TARGET-bank* body-radius)
           (* 0.0 f30-1)
           (-> *TARGET-bank* body-radius)
           )
         (set-vector!
           (-> gp-0 unknown-sphere-array00 1 local-sphere)
           0.0
           (+ (-> *TARGET-bank* body-radius) (* 2867.2 f30-1))
           0.0
           (-> *TARGET-bank* body-radius)
           )
         (set-vector!
           (-> gp-0 unknown-sphere-array00 2 local-sphere)
           0.0
           (+ (-> *TARGET-bank* body-radius) (* 5734.4 f30-1))
           0.0
           (-> *TARGET-bank* body-radius)
           )
         )
       (dotimes (v1-52 3)
         (set! (-> gp-0 unknown-sphere-array00 v1-52 prim-core offense) (collide-offense strong-attack))
         )
       )
      (else
        (set! (-> self control unknown-float91) 0.0)
        (set! (-> gp-0 unknown-vector11 y) 0.0)
        (sphere<-vector+r!
          (the-as sphere (-> gp-0 root-prim local-sphere))
          (-> *TARGET-bank* root-offset)
          (-> *TARGET-bank* root-radius)
          )
        (set-vector!
          (-> gp-0 unknown-sphere-array00 0 local-sphere)
          0.0
          (-> *TARGET-bank* body-radius)
          0.0
          (-> *TARGET-bank* body-radius)
          )
        (set-vector!
          (-> gp-0 unknown-sphere-array00 1 local-sphere)
          0.0
          (+ 2867.2 (-> *TARGET-bank* body-radius))
          0.0
          (-> *TARGET-bank* body-radius)
          )
        (set-vector!
          (-> gp-0 unknown-sphere-array00 2 local-sphere)
          0.0
          (+ 5734.4 (-> *TARGET-bank* body-radius))
          0.0
          (-> *TARGET-bank* body-radius)
          )
        )
      )
    )
  0
  )

;; definition for method 27 of type control-info
(defmethod get-quaternion control-info ((obj control-info))
  (-> obj unknown-quaternion00)
  )

;; definition for function target-align-vel-z-adjust
(defbehavior target-align-vel-z-adjust target ((arg0 float))
  (let ((f1-0 (-> self control unknown-float61)))
    (* arg0 (if (< 0.0 f1-0)
                (* (- 1.0 f1-0) (-> self control unknown-surface01 alignv))
                (-> self control unknown-surface01 alignv)
                )
       )
    )
  )

;; definition for method 16 of type target
;; INFO: Used lq/sq
;; INFO: Return type mismatch control-info vs collide-shape.
(defmethod apply-alignment target ((obj target) (arg0 align-opts) (arg1 transformq) (arg2 vector))
  (let ((s2-0 (new 'stack-no-clear 'vector)))
    (set! (-> s2-0 quad) (-> arg2 quad))
    (set! (-> s2-0 z) (target-align-vel-z-adjust (-> s2-0 z)))
    (when (logtest? arg0 (align-opts adjust-x-vel adjust-y-vel adjust-xz-vel))
      (let* ((s3-0 (-> obj control unknown-matrix01))
             (s0-0 (-> obj control unknown-matrix00))
             (s1-0 (vector-matrix*! (new 'stack-no-clear 'vector) (-> obj control dynam gravity) s0-0))
             (a1-3 (vector-matrix*! (new 'stack-no-clear 'vector) (-> obj control transv) s0-0))
             )
        (if (logtest? arg0 (align-opts no-gravity))
            (set-vector! s1-0 0.0 0.0 0.0 1.0)
            )
        (when (logtest? arg0 (align-opts adjust-x-vel))
          (set! (-> a1-3 x) (+ (* (-> arg1 trans x) (-> s2-0 x) (-> *display* frames-per-second))
                               (* (-> s1-0 x) (-> *display* seconds-per-frame))
                               )
                )
          (if (zero? (logand arg0 (align-opts adjust-xz-vel keep-other-velocities)))
              (set! (-> a1-3 z) 0.0)
              )
          )
        (if (and (logtest? arg0 (align-opts adjust-y-vel))
                 (not (and (logtest? arg0 (align-opts ignore-y-if-zero)) (= (-> arg1 trans y) 0.0)))
                 )
            (set! (-> a1-3 y) (+ (* (-> arg1 trans y) (-> s2-0 y) (-> *display* frames-per-second))
                                 (* (-> s1-0 y) (-> *display* seconds-per-frame))
                                 )
                  )
            )
        (when (logtest? arg0 (align-opts adjust-xz-vel))
          (set! (-> a1-3 z) (+ (* (-> arg1 trans z) (-> s2-0 z) (-> *display* frames-per-second))
                               (* (-> s1-0 z) (-> *display* seconds-per-frame))
                               )
                )
          (if (zero? (logand arg0 (align-opts adjust-x-vel keep-other-velocities)))
              (set! (-> a1-3 x) 0.0)
              )
          )
        (vector-matrix*! (-> obj control transv) a1-3 s3-0)
        )
      )
    )
  (if (logtest? arg0 (align-opts adjust-quat))
      (quaternion-normalize!
        (quaternion*! (-> obj control unknown-quaternion00) (-> obj control unknown-quaternion00) (-> arg1 quat))
        )
      )
  (the-as collide-shape (-> obj control))
  )

;; definition for function average-turn-angle
(defun average-turn-angle ((arg0 target))
  (let ((f30-0 0.0))
    (dotimes (s5-0 8)
      (+! f30-0
          (fabs
            (deg-diff
              (atan (-> arg0 control unknown-vector-array00 s5-0 x) (-> arg0 control unknown-vector-array00 s5-0 z))
              0.0
              )
            )
          )
      )
    (* 0.125 f30-0)
    )
  )

;; definition for function can-play-stance-amibent?
(defbehavior can-play-stance-amibent? target ()
  (and (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 30))
       (not (-> *setting-control* current talking))
       (not (-> *setting-control* current spooling))
       (not (-> *setting-control* current movie))
       (not (-> *setting-control* current hint))
       (zero? (logand (-> self control status) (cshape-moving-flags t-act)))
       (zero? (logand (-> self water flags) (water-flags wt09)))
       )
  )

;; definition for function can-jump?
(defbehavior can-jump? target ((arg0 symbol))
  (and (or (logtest? (-> self control status) (cshape-moving-flags onsurf))
           (< (- (-> *display* base-frame-counter) (-> self control unknown-dword11)) (-> *TARGET-bank* ground-timeout))
           (and (logtest? (-> self control status) (cshape-moving-flags onsurf))
                (< 0.866 (-> self control surface-angle))
                )
           )
       (and (zero? (logand (-> self control unknown-surface01 flags) (surface-flags prevent-jump)))
            (zero? (logand (-> self state-flags) (state-flags prevent-jump)))
            (case arg0
              (('target-wheel-flip)
               (>= 0.5 (-> self control unknown-float61))
               )
              (else
                #t
                )
              )
            )
       )
  )

;; definition for function move-legs?
(defbehavior move-legs? target ()
  (!= (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) stick0-speed) 0.0)
  )

;; definition for function target-height-above-ground
(defbehavior target-height-above-ground target ()
  (- (-> self control trans y) (-> self control shadow-pos y))
  )

;; definition for function fall-test
;; INFO: Return type mismatch object vs none.
(defbehavior fall-test target ()
  (when (and (zero? (logand (-> self control status) (cshape-moving-flags onsurf)))
             (>= (- (-> *display* base-frame-counter) (-> self control unknown-dword11)) (-> *TARGET-bank* ground-timeout))
             (>= 0.0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))
             (let ((v1-15 (ja-group)))
               (or (not (or (= v1-15 (-> self draw art-group data 59))
                            (= v1-15 (-> self draw art-group data 60))
                            (= v1-15 (-> self draw art-group data 61))
                            )
                        )
                   (< 4096.0 (target-height-above-ground))
                   )
               )
             )
    (when (and (< (- (-> *display* base-frame-counter) (-> self control rider-time)) (-> *TARGET-bank* ground-timeout))
               (logtest? (-> self control unknown-surface01 flags) (surface-flags moving-ground))
               )
      (+! (-> self control transv x) (-> self control rider-last-move x))
      (+! (-> self control transv z) (-> self control rider-last-move z))
      )
    (go target-falling #f)
    )
  (none)
  )

;; definition for function slide-down-test
;; INFO: Return type mismatch object vs none.
(defbehavior slide-down-test target ()
  (if (and (zero? (logand (-> self control status) (cshape-moving-flags onsurf csmf07)))
           (>= (- (-> *display* base-frame-counter) (-> self control unknown-dword11)) (-> *TARGET-bank* ground-timeout))
           (logtest? (-> self control status) (cshape-moving-flags tsurf))
           (< 0.5 (-> self control surface-angle))
           )
      (go target-slide-down)
      )
  (none)
  )

;; definition for function smack-surface?
(defbehavior smack-surface? target ((arg0 symbol))
  (and (< 0.7 (-> self control touch-angle))
       (and (< (-> self control surface-angle) 0.3)
            (logtest? (-> self control status) (cshape-moving-flags twall))
            (or arg0 (zero? (logand (-> self control status) (cshape-moving-flags t-act))))
            )
       )
  )

;; definition for function can-wheel?
(defbehavior can-wheel? target ()
  (and (logtest? (-> self control status) (cshape-moving-flags onsurf))
       (or (zero? (logand (-> self control status) (cshape-moving-flags twall)))
           (>= 0.7 (-> self control touch-angle))
           )
       (and (< (-> self control unknown-float61) 0.7)
            (zero? (logand (-> self state-flags) (state-flags prevent-duck)))
            )
       )
  )

;; definition for function can-duck?
(defbehavior can-duck? target ()
  (and (logtest? (-> self control status) (cshape-moving-flags onsurf))
       (>= (-> self control unknown-float60) 0.7)
       (zero? (logand (-> self water flags) (water-flags wt11 wt12)))
       (zero? (logand (-> self state-flags) (state-flags prevent-duck)))
       (or (zero? (logand (-> self water flags) (water-flags wt10)))
           (< (- (- (-> self control trans y) (- (-> self water base-height) (-> self water wade-height)))) 2457.6)
           )
       )
  )

;; definition for function can-exit-duck?
;; INFO: Used lq/sq
(defbehavior can-exit-duck? target ()
  (let ((gp-0 (new 'stack-no-clear 'collide-using-spheres-params)))
    (let ((s5-0 (new 'stack-no-clear 'inline-array 'sphere 2)))
      (dotimes (s4-0 2)
        ((method-of-type sphere new) (the-as symbol (-> s5-0 s4-0)) sphere)
        )
      (set! (-> s5-0 0 quad) (-> self control trans quad))
      (set! (-> s5-0 0 y) (+ 5734.4 (-> *TARGET-bank* body-radius) (-> s5-0 0 y)))
      (set! (-> s5-0 0 w) (-> *TARGET-bank* body-radius))
      (set! (-> s5-0 1 quad) (-> self control trans quad))
      (set! (-> s5-0 1 y) (+ 2867.2 (-> *TARGET-bank* body-radius) (-> s5-0 1 y)))
      (set! (-> s5-0 1 w) (-> *TARGET-bank* body-radius))
      (set! (-> gp-0 spheres) s5-0)
      )
    (set! (-> gp-0 num-spheres) (the-as uint 2))
    (set! (-> gp-0 collide-with) (-> self control root-prim collide-with))
    (set! (-> gp-0 proc) #f)
    (set! (-> gp-0 ignore-pat) (new 'static 'pat-surface :noentity #x1))
    (set! (-> gp-0 solid-only) #t)
    (if (fill-and-probe-using-spheres *collide-cache* gp-0)
        #f
        #t
        )
    )
  )

;; definition for function can-hands?
(defbehavior can-hands? target ((arg0 symbol))
  (cond
    ((or (zero? (logand (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0)
                        (pad-buttons square)
                        )
                )
         (or (and (logtest? (-> self state-flags) (state-flags prevent-attack))
                  (or (zero? (logand (-> self state-flags) (state-flags remove-prevents)))
                      (not (and (= (-> self fact-info-target eco-type) (pickup-type eco-yellow))
                                (>= (-> self fact-info-target eco-level) 1.0)
                                )
                           )
                      )
                  )
             (logtest? (-> self control unknown-surface01 flags) (surface-flags prevent-attacks-during-launch-jump surf08))
             )
         )
     #f
     )
    ((and (or (not arg0)
              (and (< (- (-> *display* base-frame-counter) (-> self control unknown-dword11)) (-> *TARGET-bank* ground-timeout))
                   (< (-> self control unknown-float61) 0.7)
                   )
              )
          (>= (- (-> *display* base-frame-counter)
                 (if (and (= (-> self fact-info-target eco-type) (pickup-type eco-yellow))
                          (>= (-> self fact-info-target eco-level) 1.0)
                          )
                     (-> *TARGET-bank* yellow-attack-timeout)
                     (-> *TARGET-bank* attack-timeout)
                     )
                 )
              (-> self control unknown-dword31)
              )
          )
     #t
     )
    (else
      (set! (-> self control unknown-dword32) (-> *display* base-frame-counter))
      #f
      )
    )
  )

;; definition for function can-feet?
(defbehavior can-feet? target ()
  (cond
    ((or (logtest? (-> self state-flags) (state-flags prevent-attack))
         (logtest? (-> self control unknown-surface01 flags) (surface-flags prevent-attacks-during-launch-jump surf09))
         )
     #f
     )
    ((>= (- (-> *display* base-frame-counter) (-> *TARGET-bank* attack-timeout)) (-> self control unknown-dword33))
     #t
     )
    (else
      (set! (-> self control unknown-dword34) (-> *display* base-frame-counter))
      #f
      )
    )
  )

;; definition for function vector-local+!
;; INFO: Used lq/sq
(defbehavior vector-local+! target ((arg0 vector) (arg1 vector))
  (let ((s5-0 (new-stack-vector0)))
    (vector-matrix*! s5-0 arg1 (-> self control unknown-matrix01))
    (vector+! arg0 arg0 s5-0)
    )
  )

;; definition for function move-forward
;; INFO: Used lq/sq
(defbehavior move-forward target ((arg0 float))
  (let ((a1-0 (new-stack-vector0))
        (gp-0 (new-stack-vector0))
        )
    (set-vector! a1-0 0.0 0.0 arg0 1.0)
    (vector-matrix*! gp-0 a1-0 (-> self control unknown-matrix01))
    (vector+! (-> self control transv) (-> self control transv) gp-0)
    )
  )

;; definition for function set-forward-vel
;; INFO: Used lq/sq
(defbehavior set-forward-vel target ((arg0 float))
  (let ((gp-0 (new-stack-vector0)))
    (vector-matrix*! gp-0 (-> self control transv) (-> self control unknown-matrix00))
    (set! (-> gp-0 z) arg0)
    (set! (-> gp-0 x) 0.0)
    (vector-matrix*! (-> self control transv) gp-0 (-> self control unknown-matrix01))
    )
  )

;; definition for function delete-back-vel
;; INFO: Used lq/sq
;; INFO: Return type mismatch int vs none.
(defbehavior delete-back-vel target ()
  (let ((s5-0 (new-stack-vector0)))
    (vector-z-quaternion! s5-0 (-> self control dir-targ))
    (let ((gp-0 (new-stack-vector0))
          (f30-0 (vector-dot s5-0 (-> self control transv)))
          )
      0.0
      (vector-! gp-0 (-> self control transv) (vector-float*! gp-0 s5-0 f30-0))
      (let* ((f0-3 (vector-length gp-0))
             (f1-0 f0-3)
             )
        (if (< f30-0 0.0)
            (set! f30-0 0.0)
            )
        (vector+!
          (-> self control transv)
          (vector-float*! (-> self control transv) s5-0 f30-0)
          (vector-float*! gp-0 gp-0 (/ f0-3 f1-0))
          )
        )
      )
    )
  0
  (none)
  )

;; definition for function set-side-vel
;; INFO: Used lq/sq
(defbehavior set-side-vel target ((arg0 float))
  (let ((gp-0 (new-stack-vector0)))
    (vector-matrix*! gp-0 (-> self control transv) (-> self control unknown-matrix00))
    (set! (-> gp-0 x) arg0)
    (set! (-> gp-0 z) 0.0)
    (vector-matrix*! (-> self control transv) gp-0 (-> self control unknown-matrix01))
    )
  )

;; definition for function target-timed-invulnerable
;; INFO: Return type mismatch int vs none.
(defun target-timed-invulnerable ((arg0 time-frame) (arg1 target))
  (logior! (-> arg1 state-flags) (state-flags timed-invulnerable))
  (set! (-> arg1 control unknown-dword80) (-> *display* base-frame-counter))
  (set! (-> arg1 control unknown-dword81) arg0)
  (set-collide-kinds (-> arg1 control) 2 (collide-kind target-attack) (collide-kind))
  0
  (none)
  )

;; definition for function target-timed-invulnerable-off
;; INFO: Return type mismatch int vs none.
(defun target-timed-invulnerable-off ((arg0 target))
  (logclear! (-> arg0 draw status) (draw-status hidden))
  (logclear! (-> arg0 state-flags) (state-flags timed-invulnerable))
  (set-collide-kinds (-> arg0 control) 2 (collide-kind) (collide-kind target-attack))
  0
  (none)
  )

;; definition for method 9 of type attack-info
;; INFO: Used lq/sq
;; INFO: Return type mismatch attack-info vs none.
(defmethod combine! attack-info ((obj attack-info) (arg0 attack-info))
  (with-pp
    (let ((s4-0 (-> arg0 mask)))
      (set! (-> obj mask) (-> arg0 mask))
      (if (logtest? s4-0 (attack-mask attacker))
          (set! (-> obj attacker) (-> arg0 attacker))
          )
      (if (logtest? s4-0 (attack-mask mode))
          (set! (-> obj mode) (-> arg0 mode))
          )
      (if (logtest? s4-0 (attack-mask angle))
          (set! (-> obj angle) (-> arg0 angle))
          )
      (if (logtest? s4-0 (attack-mask dist))
          (set! (-> obj dist) (-> arg0 dist))
          )
      (if (logtest? s4-0 (attack-mask control))
          (set! (-> obj control) (-> arg0 control))
          )
      (if (logtest? s4-0 (attack-mask speed))
          (set! (-> obj speed) (-> arg0 speed))
          )
      (if (logtest? s4-0 (attack-mask shove-back))
          (set! (-> obj shove-back) (-> arg0 shove-back))
          )
      (if (logtest? s4-0 (attack-mask shove-up))
          (set! (-> obj shove-up) (-> arg0 shove-up))
          )
      (if (logtest? s4-0 (attack-mask invinc-time))
          (set! (-> obj invinc-time) (-> arg0 invinc-time))
          )
      (if (logtest? s4-0 (attack-mask rotate-to))
          (set! (-> obj rotate-to) (-> arg0 rotate-to))
          )
      (if (logtest? s4-0 (attack-mask intersection))
          (set! (-> obj intersection quad) (-> arg0 intersection quad))
          )
      (cond
        ((zero? (logand s4-0 (attack-mask vector)))
         (let* ((s3-0 pp)
                (s2-0 (handle->process (-> obj attacker)))
                (v1-39 (if (and (nonzero? s2-0) (type-type? (-> s2-0 type) process-drawable))
                           s2-0
                           )
                       )
                )
           (when v1-39
             (set! (-> obj trans quad) (-> (the-as process-drawable v1-39) root trans quad))
             (vector-!
               (-> obj vector)
               (-> (the-as process-drawable s3-0) root trans)
               (-> (the-as process-drawable v1-39) root trans)
               )
             (logior! (-> obj mask) (attack-mask vector))
             )
           )
         )
        (else
          (let* ((s3-1 (handle->process (-> obj attacker)))
                 (a0-16 (if (and (nonzero? s3-1) (type-type? (-> s3-1 type) process-drawable))
                            s3-1
                            )
                        )
                 )
            (if a0-16
                (set! (-> obj trans quad) (-> (the-as process-drawable a0-16) root trans quad))
                )
            )
          (set! (-> obj vector quad) (-> arg0 vector quad))
          (if (zero? (logand s4-0 (attack-mask shove-back)))
              (set! (-> obj shove-back) (vector-xz-length (-> obj vector)))
              )
          (if (zero? (logand s4-0 (attack-mask shove-up)))
              (set! (-> obj shove-up) (-> obj vector y))
              )
          )
        )
      (if (zero? (logand (-> obj mask) (attack-mask dist)))
          (set! (-> obj dist) (fabs (-> obj shove-back)))
          )
      (if (logtest? s4-0 (attack-mask trans))
          (set! (-> obj trans quad) (-> arg0 trans quad))
          )
      )
    (none)
    )
  )

;; definition for function ground-tween-initialize
(defbehavior ground-tween-initialize target ((arg0 ground-tween-info) (arg1 uint) (arg2 uint) (arg3 uint) (arg4 uint) (arg5 uint) (arg6 uint))
  (set! (-> arg0 group 0) arg2)
  (set! (-> arg0 group 1) arg3)
  (set! (-> arg0 group 2) arg4)
  (set! (-> arg0 group 3) arg5)
  (set! (-> arg0 group 4) arg6)
  (dotimes (s3-0 3)
    (set! (-> arg0 chan s3-0) (+ arg1 s3-0))
    (ja :chan (-> arg0 chan s3-0) :group! arg2 :num! min :frame-interp (fabs (-> arg0 blend s3-0)))
    )
  arg0
  )

;; definition for function ground-tween-update
;; INFO: Return type mismatch int vs none.
(defbehavior ground-tween-update target ((arg0 ground-tween-info) (arg1 float) (arg2 float))
  (let ((f0-1 (fmax -1.0 (fmin 1.0 (* 2.0 arg1))))
        (f30-0 (fmax -1.0 (fmin 1.0 (* 1.6 arg2))))
        )
    (let ((f1-5 (fabs (- f0-1 (the-as float (-> arg0 blend 1))))))
      (set! (-> arg0 blend 1) (seek (the-as float (-> arg0 blend 1)) f0-1 (fmax 0.05 (fmin 0.2 (* 0.25 f1-5)))))
      )
    (let ((f0-7 (fabs (- f30-0 (the-as float (-> arg0 blend 2))))))
      (set! (-> arg0 blend 2) (seek (the-as float (-> arg0 blend 2)) f30-0 (fmax 0.05 (fmin 0.2 (* 0.25 f0-7)))))
      )
    )
  (if (>= (-> arg0 blend 1) 0.0)
      (ja :chan (-> arg0 chan 1) :group! (-> arg0 group 1) :frame-interp (fabs (-> arg0 blend 1)))
      (ja :chan (-> arg0 chan 1) :group! (-> arg0 group 2) :frame-interp (fabs (-> arg0 blend 1)))
      )
  (if (>= (-> arg0 blend 2) 0.0)
      (ja :chan (-> arg0 chan 2) :group! (-> arg0 group 4) :frame-interp (fabs (-> arg0 blend 2)))
      (ja :chan (-> arg0 chan 2) :group! (-> arg0 group 3) :frame-interp (fabs (-> arg0 blend 2)))
      )
  0
  (none)
  )

;; definition for function target-pos
(defun target-pos ((arg0 int))
  (let ((a1-0 *target*))
    (cond
      (a1-0
        (if (zero? arg0)
            (-> a1-0 control trans)
            (vector<-cspace! (new 'static 'vector) (-> a1-0 node-list data arg0))
            )
        )
      (else
        (camera-pos)
        )
      )
    )
  )

;; definition for function target-cam-pos
;; INFO: Used lq/sq
;; INFO: Return type mismatch object vs vector.
(defun target-cam-pos ()
  (let ((gp-0 *target*))
    (the-as
      vector
      (cond
        ((not gp-0)
         (camera-pos)
         )
        ((logtest? (-> gp-0 state-flags) (state-flags use-alt-cam-pos))
         (add-debug-sphere
           *display-camera-marks*
           (bucket-id debug-no-zbuf)
           (-> gp-0 alt-cam-pos)
           819.2
           (new 'static 'rgba :r #xff :a #x80)
           )
         (-> gp-0 alt-cam-pos)
         )
        ((logtest? (state-flags has-saved-position) (-> gp-0 state-flags))
         (add-debug-sphere
           *display-camera-marks*
           (bucket-id debug-no-zbuf)
           (-> gp-0 alt-cam-pos)
           819.2
           (new 'static 'rgba :r #xff :a #x80)
           )
         (-> gp-0 alt-cam-pos)
         )
        ((logtest? (state-flags falling-into-pool-of-bad) (-> gp-0 state-flags))
         (let ((s5-0 (the-as object (new 'static 'vector))))
           (set! (-> (the-as vector s5-0) quad) (-> (&-> (-> gp-0 control) unknown-qword00) 0))
           (set! (-> (the-as vector s5-0) y) (fmax (-> (the-as vector s5-0) y) (-> gp-0 alt-cam-pos y)))
           (add-debug-sphere
             *display-camera-marks*
             (bucket-id debug-no-zbuf)
             (the-as vector s5-0)
             819.2
             (new 'static 'rgba :r #xff :a #x80)
             )
           s5-0
           )
         )
        (else
          (add-debug-sphere
            *display-camera-marks*
            (bucket-id debug-no-zbuf)
            (the-as vector (&-> (-> gp-0 control) unknown-qword00))
            819.2
            (new 'static 'rgba :r #xff :a #x80)
            )
          (&-> (-> gp-0 control) unknown-qword00)
          )
        )
      )
    )
  )

;; definition for function target-joint-pos
(defun target-joint-pos ()
  (let ((v1-0 *target*))
    (if v1-0
        (vector<-cspace! (new 'static 'vector) (-> v1-0 node-list data (-> v1-0 draw origin-joint-index)))
        (camera-pos)
        )
    )
  )

;; definition for function target-rot
(defun target-rot ()
  (let ((v1-0 *target*))
    (if v1-0
        (-> v1-0 control unknown-quaternion00)
        *unity-quaternion*
        )
    )
  )
