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

;; name: target-h.gc
;; name in dgo: target-h
;; dgos: GAME

;; +++target-flags
(defenum target-flags
  :type uint32
  :bitfield #t
  (tf0 0)
  (tf1 1)
  (tf2 2)
  (tinvuln1 3)
  (tf4 4)
  (tf5 5)
  (tf6 6)
  (prevent-jump 7)
  (prevent-attack 8)
  (prevent-duck 9)
  (tf10 10)
  (tf11 11)
  (tf12 12)
  (tf13 13)
  (tf14 14)
  (tf15 15)
  (tf16 16)
  (prevent-board 17)
  (prevent-gun 18)
  (lleg-still 19)
  (rleg-still 20)
  (lleg-no-ik 21)
  (rleg-no-ik 22)
  (prevent-double-jump 23)
  (disable-attacks 24)
  (tinvuln2 25)
  (tf26 26)
  (tf27 27)
  (invisible 28)
  (tf29 29)
  (tf30 30)
  (tf31 31)
  )
;; ---target-flags


;; +++darkjak-stage
(defenum darkjak-stage
  :bitfield #t
  :type uint32
  (force-on)
  (endless-dark)
  (active)
  (smack)
  (bomb0)
  (bomb1)
  (tracking)
  (invinc)
  (invis)
  (no-anim)
  )
;; ---darkjak-stage


(declare-type rigid-body-impact structure)
(declare-type sidekick process-drawable)
(declare-type racer-info basic)
(declare-type tube-info basic)
(declare-type flut-info basic)
(declare-type board-info basic)
(declare-type pilot-info basic)
(declare-type gun-info basic)
(declare-type mech-info basic)
(declare-type turret-info basic)
(declare-type indax-info basic)
(declare-type ladder-info basic)
(declare-type darkjak-info basic)
(declare-type lightjak-info basic)

;; target-util
(define-extern target-pos (function int vector))
(define-extern can-exit-duck? (function target symbol))
(define-extern target-collide-set! (function symbol float int :behavior target))
(define-extern target-move-dist (function time-frame float :behavior target))
(define-extern get-intersect-point (function vector touching-prims-entry collide-shape touching-shapes-entry vector))
(define-extern target-update-segs (function process-drawable float))

;; logic-target
(define-extern target-darkjak-setup (function symbol none :behavior target))
(define-extern target-lightjak-setup (function symbol none :behavior target))
(define-extern target-sidekick-setup (function symbol none :behavior target))
(define-extern target-board-setup (function symbol none :behavior target))
(define-extern target-board-joint-points (function none :behavior target))
(define-extern target-gun-setup (function symbol none :behavior target))
(define-extern target-gun-joint-pre (function none :behavior target))
(define-extern target-gun-joint-points (function none :behavior target))
(define-extern target-powerup-process (function none :behavior target))
(define-extern target-generic-event-handler (function process int symbol event-message-block object :behavior target))
(define-extern target-exit (function none :behavior target))
(define-extern activate-hud (function target none))
(define-extern *target-geo-control* external-art-buffer)
(define-extern *target-anim-control* external-art-buffer)

;; target-handler
(define-extern target-gun-end-mode (function symbol symbol :behavior target))
(define-extern target-powerup-effect (function symbol none :behavior target))
(define-extern target-gun-type-set! (function pickup-type none :behavior target))
(define-extern vehicle-spawn (function vehicle-type traffic-object-spawn-params process-drawable))
(define-extern target-gun-init (function pickup-type none :behavior target))
(define-extern target-invisible-stop (function none :behavior target))
(define-extern target-gun-fire (function pickup-type none :behavior target))

;; target-anim
(define-extern *attack-end-mods* surface)

;; target
(define-extern want-to-powerjak? (function symbol :behavior target))
(define-extern target-invisible-start (function time-frame none :behavior target))
(define-extern target-top-anim-base-mode (function int none :behavior target))
(define-extern target-land-effect (function none :behavior target))
(define-extern *attack-find-mods* surface)
(define-extern *uppercut-mods* surface)
(define-extern *uppercut-jump-mods* surface)

;; target2
(define-extern *trip-mods* surface)
(define-extern *look-around-mods* surface)
(define-extern target-gun-check (function none :behavior target))
(define-extern target-darkjak-end-mode (function symbol none :behavior target))
(define-extern target-lightjak-end-mode (function symbol none :behavior target))
(define-extern want-to-gun? (function target symbol symbol :behavior process))
(define-extern *hit-ground-hard-mods* surface)
(define-extern *float-mods* surface)
(define-extern *blast-recover-mods* surface)

;; target-death
(define-extern pre-intro-play (function none))
(define-extern intro-play (function none))
(define-extern find-nearest-entity (function vector type entity))
(define-extern have-vehicle-v-type? (function vehicle-type symbol))
(define-extern entity-birth-no-kill (function entity process))
(define-extern process-drawable-burn-effect (function time-frame rgbaf :behavior target))
(define-extern warp-gate type)
(define-extern htorpedo type)
(define-extern target-turret type)
(define-extern scorpion-gun-manager type)
(define-extern bt-gun-manager type)

;; target-gun
(declare-type gun process-drawable)
(define-extern target-gun-marking-menu (function target none))
(define-extern gun-init (function none :behavior gun))
(define-extern truncate-player-ammo (function pickup-type none))
(define-extern target-gun-can-fire-yellow? (function pickup-type symbol :behavior target))
(define-extern target-gun-fire-yellow (function pickup-type (pointer process) :behavior target))
(define-extern target-gun-can-fire-red? (function pickup-type symbol :behavior target))
(define-extern target-gun-fire-red (function pickup-type (pointer process) :behavior target))
(define-extern target-gun-can-fire-blue? (function pickup-type symbol :behavior target))
(define-extern target-gun-fire-blue (function pickup-type (pointer process) :behavior target))
(define-extern target-gun-can-fire-dark? (function pickup-type symbol :behavior target))
(define-extern target-gun-fire-dark (function pickup-type (pointer process) :behavior target))

;; powerups
(define-extern target-darkjak-process (function none :behavior target))

;; target-darkjak
(define-extern *darkjak-trans-mods* surface)

;; target-ladder
(define-extern *ladder-mods* surface)

;; target-tube
(define-extern *tube-mods* surface)
(define-extern *tube-jump-mods* surface)
(define-extern *tube-hit-mods* surface)
(define-extern *tube-surface* surface)

;; target-flut
(define-extern *flut-walk-mods* surface)
(define-extern *flut-run-racer-mods* surface)
(define-extern *flut-run-wild-mods* surface)
(define-extern *flut-jump-wild-mods* surface)
(define-extern *flut-jump-mods* surface)
(define-extern *flut-jump-racer-mods* surface)
(define-extern *flut-double-jump-mods* surface)
(define-extern *flut-double-jump-racer-mods* surface)
(define-extern *flut-run-attack-mods* surface)
(define-extern *flut-air-attack-mods* surface)
(define-extern *flut-get-off-mods* surface)

;; target-pilot
(define-extern *pilot-mods* surface)
(define-extern *pilot-get-on-mods* surface)
(define-extern *pilot-get-off-mods* surface)

;; target-turret
(define-extern *turret-get-on-mods* surface)

;; target-indax
(define-extern *indax-walk-mods* surface)
(define-extern *indax-jump-mods* surface)
(define-extern *indax-double-jump-mods* surface)
(define-extern *indax-bounce-mods* surface)
(define-extern target-indax-exit (function none :behavior target))

;; target-indax-hang
(define-extern *indax-hang-walk-mods* surface)
(define-extern *indax-hang-dodge-mods* surface)
(define-extern *indax-hang-attack-mods* surface)

;; +++lightjak-stage
(defenum lightjak-stage
  :bitfield #t
  :type uint32
  (ls0 0)
  (ls1 1)
  (ls2 2)
  (regen 3)
  (swoop 4)
  (freeze 5)
  (ls6 6)
  (ls7 7)
  (ls8 8)
  (ls9 9)
  (ls10 10)
  (ls11 11)
  (ls12 12)
  (ls13 13)
  (ls14 14)
  (ls15 15)
  )
;; ---lightjak-stage


;; +++target-geo
(defenum target-geo
  :type int32
  (uninitialized -2)
  (none -1)
  (jakb 4) ;; jak 2 model
  (jakb-old 5) ;; weird broken jak 2 model
  (jakc 6) ;; jak 3 model
  )
;; ---target-geo


;; +++target-anim
(defenum target-anim
  :type int32
  (uninitialized -2)
  (unknown -1)
  (default 0)
  (board 1)
  (dark 2)
  (light 3)
  )
;; ---target-anim


;; +++target-effect
(defenum target-effect
  :type uint64
  :bitfield #t
  (te0 0)
  (te1 1)
  (te2 2)
  (te3 3)
  (te4 4)
  (te5 5)
  (te6 6)
  )
;; ---target-effect


;; DECOMP BEGINS

(deftype target (process-focusable)
  ((self                         target           :override)
   (ppointer                     (pointer target) :override)
   (fact                         fact-info-target :override)
   (control                      control-info      :overlay-at root)
   (skel2                        joint-control)
   (shadow-backup                shadow-geo)
   (target-flags                 target-flags      :overlay-at state-flags)
   (game                         game-info)
   (neck                         joint-mod)
   (head                         joint-mod)
   (upper-body                   joint-mod)
   (horns                        joint-mod)
   (hair                         joint-mod         2)
   (arm-ik                       joint-mod-ik      2)
   (leg-ik                       joint-mod-ik      2)
   (foot                         joint-mod         2)
   (cloth                        symbol)
   (mech-ik                      joint-mod-ik      2)
   (init-time                    time-frame        :overlay-at (-> mech-ik 0))
   (teleport-time                time-frame)
   (state-hook-time              time-frame)
   (state-hook                   (function none :behavior target))
   (cam-user-mode                symbol)
   (sidekick                     (pointer sidekick))
   (manipy                       (pointer manipy))
   (mirror                       (pointer process-drawable))
   (attack-info                  attack-info       :inline)
   (attack-info-rec              attack-info       :inline)
   (attack-info-old              attack-info       8 :inline)
   (anim-seed                    uint64)
   (alt-cam-pos                  vector            :inline)
   (current-level                level)
   (saved-pos                    transformq        :inline)
   (saved-owner                  handle)
   (alt-neck-pos                 vector            :inline)
   (focus-search                 (array collide-shape))
   (handle-search                (array handle))
   (excitement                   float)
   (shock-effect-time            time-frame)
   (beard?                       symbol)
   (spool-anim                   spool-anim)
   (ambient-time                 time-frame)
   (fp-hud                       handle)
   (no-load-wait                 time-frame)
   (no-look-around-wait          time-frame)
   (burn-proc                    handle)
   (pre-joint-hook               (function none :behavior target))
   (notify                       handle)
   (death-resetter               resetter-spec     :inline)
   (mode-cache                   symbol)
   (mode-param1                  handle)
   (mode-param2                  uint64)
   (mode-param3                  uint64)
   (major-mode-exit-hook         (function none :behavior target))
   (major-mode-event-hook        (function process int symbol event-message-block object :behavior target))
   (sub-mode-exit-hook           (function none :behavior target))
   (ext-geo-control              external-art-buffer)
   (pending-ext-geo              target-geo)
   (ext-geo                      target-geo)
   (ext-anim-control             external-art-buffer)
   (pending-ext-anim             target-anim)
   (ext-anim                     target-anim)
   (tobot-state                  state)
   (tobot?                       symbol)
   (tobot-recorder               basic)
   (target-effect                target-effect)
   (color-effect                 symbol)
   (color-effect-start-time      time-frame)
   (color-effect-duration        time-frame)
   (racer                        racer-info)
   (tube                         tube-info)
   (flut                         flut-info)
   (board                        board-info)
   (pilot                        pilot-info)
   (gun                          gun-info)
   (mech                         mech-info)
   (turret                       turret-info)
   (indax                        indax-info)
   (ladder                       ladder-info)
   (darkjak-interp               float)
   (darkjak-interp-old           float)
   (darkjak-giant-interp         float)
   (darkjak                      darkjak-info)
   (lightjak-interp              float)
   (lightjak-interp-old          float)
   (lightjak                     lightjak-info)
   (scarf-interp-targ            float)
   (scarf-interp                 float)
   (scarf-interp-old             float)
   (goggles-interp-targ          float)
   (goggles-interp               float)
   (goggles-interp-old           float)
   (invisible-interp             float)
   (invisible-start-time         time-frame)
   (invisible-duration           time-frame)
   (invisible-shadow-dir-backup  vector            :inline)
   )
  (:methods
    (target-method-28 (_type_ collide-cache collide-edge-spec) none)
    (target-init! (_type_ continue-point symbol) none)
    )
  (:states
    target-attack
    (target-attack-air symbol)
    (target-attack-uppercut float float)
    (target-attack-uppercut-jump float float)
    (target-blast-recover rigid-body-impact)
    (target-board-clone-anim handle)
    target-board-duck-stance
    target-board-falling
    (target-board-flip float float symbol)
    (target-board-get-off handle symbol)
    target-board-get-on
    (target-board-grab symbol)
    (target-board-grenade handle)
    target-board-halfpipe
    (target-board-hit symbol attack-info)
    target-board-hit-ground
    (target-board-hold float float symbol)
    (target-board-jump meters meters symbol)
    target-board-jump-kick
    (target-board-ride-edge symbol)
    target-board-stance
    (target-board-start handle)
    (target-board-trickx float float symbol)
    (target-board-tricky float float symbol)
    target-board-turn-around
    (target-board-turn-to vector time-frame)
    (target-board-wall-kick vector float)
    target-carry-pickup
    (target-clone-anim handle)
    (target-continue continue-point)
    (target-credits int)
    target-darkjak-bomb0
    (target-darkjak-bomb1 float float)
    target-darkjak-get-off
    (target-darkjak-get-on darkjak-stage)
    target-darkjak-running-attack
    target-darkjak-smack
    target-darkjak-smack-charge
    (target-death symbol)
    target-demo
    (target-double-jump float float)
    (target-duck-high-jump float float symbol)
    (target-duck-high-jump-jump float float symbol)
    (target-duck-stance symbol)
    (target-duck-walk symbol)
    (target-eco-powerup int float)
    target-edge-grab
    (target-edge-grab-jump float float symbol)
    target-edge-grab-off
    (target-falling object)
    target-float
    (target-flop float float float object)
    (target-flop-hit-ground symbol)
    (target-flut-air-attack float)
    target-flut-air-attack-hit-ground
    (target-flut-clone-anim handle)
    (target-flut-death symbol)
    (target-flut-double-jump float float)
    (target-flut-eject symbol)
    (target-flut-falling object)
    (target-flut-get-off handle)
    target-flut-get-off-jump
    (target-flut-get-on handle)
    target-flut-grab
    (target-flut-hit symbol attack-info)
    target-flut-hit-ground
    (target-flut-jump float float)
    (target-flut-kanga-catch handle symbol)
    target-flut-run-wild
    target-flut-running-attack
    target-flut-stance
    (target-flut-start handle symbol int)
    target-flut-walk
    (target-grab symbol)
    (target-grab-ride handle)
    target-gun-stance
    target-gun-walk
    target-hide
    (target-high-jump float float object)
    (target-hit symbol attack-info)
    (target-hit-ground symbol)
    (target-hit-ground-hard float)
    target-ice-stance
    target-ice-walk
    target-indax-attack
    (target-indax-attack-air symbol)
    (target-indax-death symbol)
    (target-indax-double-jump float float)
    (target-indax-falling symbol)
    target-indax-get-off
    (target-indax-grab symbol)
    target-indax-hang
    target-indax-hang-attack
    target-indax-hang-dodge
    target-indax-hang-stance
    target-indax-hang-turn-around
    target-indax-hang-walk
    (target-indax-hit symbol attack-info)
    (target-indax-hit-ground symbol)
    (target-indax-jump float float surface)
    target-indax-running-attack
    target-indax-stance
    (target-indax-start handle object)
    target-indax-trip
    target-indax-walk
    (target-invisible-get-on handle time-frame)
    (target-jump float float surface)
    (target-jump-forward float float symbol)
    target-ladder
    target-ladder-jump-off
    target-ladder-slide-down
    target-ladder-stance
    (target-ladder-start handle)
    target-ladder-switch
    target-ladder-walk-down
    target-ladder-walk-up
    (target-launch float symbol vector int)
    target-launch-dir
    target-lightjak-freeze
    target-lightjak-get-off
    (target-lightjak-get-on lightjak-stage)
    (target-lightjak-regen int)
    target-lightjak-shield
    (target-lightjak-swoop float)
    (target-lightjak-swoop-again float)
    (target-lightjak-swoop-falling symbol)
    target-load-wait
    target-look-around
    target-mech-carry-drag
    target-mech-carry-drop
    target-mech-carry-falling
    (target-mech-carry-hit-ground symbol)
    (target-mech-carry-jump float float)
    target-mech-carry-pickup
    target-mech-carry-stance
    target-mech-carry-throw
    target-mech-carry-walk
    (target-mech-clone-anim handle)
    (target-mech-death symbol)
    (target-mech-falling symbol)
    target-mech-get-off
    (target-mech-get-on handle)
    (target-mech-get-up handle)
    target-mech-grab
    (target-mech-hit symbol attack-info)
    (target-mech-hit-ground symbol)
    (target-mech-jump float float surface)
    target-mech-punch
    target-mech-shield
    target-mech-stance
    (target-mech-start handle float symbol)
    target-mech-walk
    (target-pilot-clone-anim handle)
    target-pilot-daxter-perch
    (target-pilot-death symbol)
    (target-pilot-edge-grab pilot-edge-grab-info)
    (target-pilot-get-off handle)
    target-pilot-get-on
    target-pilot-grab
    (target-pilot-hit symbol attack-info)
    target-pilot-impact
    target-pilot-stance
    (target-pilot-start handle symbol symbol)
    (target-play-anim string handle)
    (target-pole-cycle handle)
    (target-pole-flip-forward float float float)
    (target-pole-flip-forward-jump float float)
    (target-pole-flip-up float float float)
    (target-pole-flip-up-jump float float symbol)
    target-powerjak-get-on
    (target-racing-start handle)
    target-roll
    (target-roll-flip float float)
    target-running-attack
    target-slide-down
    target-slide-down-to-ground
    target-stance
    target-stance-ambient
    target-stance-look-around
    target-startup
    target-swim
    target-swim-down
    (target-swim-jump float float)
    (target-swim-jump-jump float float surface)
    target-swim-stance
    target-swim-up
    target-swim-walk
    (target-title symbol)
    target-tube
    (target-tube-death symbol)
    (target-tube-hit symbol attack-info)
    (target-tube-jump float float)
    (target-tube-start handle)
    target-tube-walk
    target-turn-around
    target-turret-get-off
    (target-turret-get-on handle)
    (target-turret-stance handle)
    target-turret-stance-fire
    target-wade-stance
    target-wade-walk
    target-walk
    (target-warp-in vector vector object)
    (target-warp-out vector vector handle)
    target-yellow-jump-blast
    tobot-stance
    )
  )


(define-perm *target* target #f)

(deftype sidekick (process-drawable)
  ((parent               (pointer target) :override)
   (control              control-info      :overlay-at root)
   (anim-seed            uint64            :offset 208)
   (shadow-in-movie?     symbol)
   (special-anim-time    time-frame)
   (special-anim-interp  float)
   (special-anim-frame   float)
   (offset               transformq        :inline)
   (mirror               (pointer process-drawable))
   (ear                  joint-mod         2)
   (flap                 joint-mod         2)
   )
  (:states
    sidekick-clone
    )
  )


(define-perm *sidekick* sidekick #f)
