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

;; name: target-carry.gc
;; name in dgo: target-carry
;; dgos: ENGINE, GAME

;; DECOMP BEGINS

(define *carry-walk-mods* (new 'static 'surface
                            :name 'run
                            :turnv 524288.0
                            :turnvv 910222.25
                            :tiltv 65536.0
                            :tiltvv 262144.0
                            :transv-max 24576.0
                            :target-speed 24576.0
                            :seek0 1.0
                            :seek90 1.0
                            :seek180 1.0
                            :fric 1.0
                            :nonlin-fric-dist 1.0
                            :slip-factor 1.0
                            :slide-factor 1.0
                            :slope-up-factor 1.0
                            :slope-down-factor 1.0
                            :slope-slip-angle 1.0
                            :impact-fric 1.0
                            :bend-factor 1.0
                            :bend-speed 1.0
                            :alignv 1.0
                            :slope-up-traction 1.0
                            :align-speed 1.0
                            :turnvf 30.0
                            :turnvvf 30.0
                            :tiltvf 150.0
                            :tiltvvf 15.0
                            :flags (surface-flag look-around no-turn-around gun-off)
                            )
        )

(define *carry-jump-mods* (new 'static 'surface
                            :name 'jump
                            :turnv 524288.0
                            :turnvv 910222.25
                            :tiltv 65536.0
                            :tiltvv 262144.0
                            :transv-max 24576.0
                            :target-speed 24576.0
                            :seek0 0.3
                            :seek90 0.3
                            :seek180 0.3
                            :fric 0.2
                            :nonlin-fric-dist 1.0
                            :slip-factor 1.0
                            :slide-factor 1.0
                            :slope-up-factor 1.0
                            :slope-down-factor 1.0
                            :slope-slip-angle 1.0
                            :impact-fric 1.0
                            :bend-factor 1.0
                            :bend-speed 1.0
                            :alignv 1.0
                            :slope-up-traction 1.0
                            :align-speed 1.0
                            :turnvf 30.0
                            :turnvvf 30.0
                            :tiltvf 150.0
                            :tiltvvf 15.0
                            :mode 'air
                            :flags (surface-flag air gun-off)
                            )
        )

;; WARN: Return type mismatch object vs none.
(defbehavior target-carry-update target ()
  (carry-info-method-9 (-> self carry))
  (when (and (= (-> self control collide-mode) 'carry) (< (-> self control collide-mode-transition) 1.0))
    (let ((gp-0 (new 'stack-no-clear 'collide-query))
          (s5-0 (new 'stack-no-clear 'inline-array 'sphere 1))
          )
      (dotimes (s4-0 1)
        ((method-of-type sphere new) (the-as symbol (-> s5-0 s4-0)) sphere)
        )
      (let ((f30-0 (seek (-> self control collide-mode-transition) 1.0 (/ (-> self clock time-adjust-ratio) 10))))
        (set! (-> s5-0 0 quad) (-> self control collision-spheres 2 prim-core world-sphere quad))
        (set! (-> s5-0 0 r) (lerp-scale (-> *TARGET-bank* body-radius) 7372.8 f30-0 0.0 1.0))
        (let ((v1-17 gp-0))
          (set! (-> v1-17 best-dist) (the-as float s5-0))
          (set! (-> v1-17 num-spheres) (the-as uint 1))
          (set! (-> v1-17 collide-with) (-> self control root-prim prim-core collide-with))
          (set! (-> v1-17 ignore-process0) #f)
          (set! (-> v1-17 ignore-process1) #f)
          (set! (-> v1-17 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1))
          (set! (-> v1-17 best-my-prim) (the-as collide-shape-prim #t))
          (set! (-> v1-17 action-mask) (collide-action solid))
          )
        (if (not (fill-and-probe-using-spheres *collide-cache* gp-0))
            (target-collide-set! 'carry f30-0)
            )
        )
      )
    )
  (send-event (handle->process (-> self carry other)) 'carry (-> self carry))
  (none)
  )

;; WARN: Return type mismatch focus-status vs none.
(defbehavior target-carry-post target ()
  (target-post)
  (target-carry-update)
  (logior! (-> self focus-status) (focus-status carry))
  (none)
  )

(defstate target-carry-pickup (target)
  :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
    (case message
      (('touched)
       (cond
         (((method-of-type touching-shapes-entry prims-touching?)
           (the-as touching-shapes-entry (-> block param 0))
           (-> self control)
           (the-as uint 1920)
           )
          (let ((a1-2 (new 'stack-no-clear 'event-message-block)))
            (set! (-> a1-2 from) (process->ppointer self))
            (set! (-> a1-2 num-params) 0)
            (set! (-> a1-2 message) 'carry?)
            (let ((a1-3 (send-event-function proc a1-2)))
              (when a1-3
                (let ((f0-0 (distance-from-destination (-> self carry) (the-as carry-info a1-3))))
                  (when (and (>= f0-0 0.0) (< f0-0 (-> self carry other-value)))
                    (set! (-> self carry other) (process->handle proc))
                    (set! (-> self carry other-value) f0-0)
                    )
                  )
                )
              )
            )
          #f
          )
         (else
           (target-standard-event-handler proc argc message block)
           )
         )
       )
      (else
        (target-standard-event-handler proc argc message block)
        )
      )
    )
  :enter (behavior ()
    (set! (-> self control mod-surface) *walk-mods*)
    (set-time! (-> self state-time))
    (set-forward-vel 0.0)
    (set! (-> self carry other) (the-as handle #f))
    (set! (-> self carry other-value) 100000000000.0)
    (set! (-> self carry max-distance) 12288.0)
    (set! (-> self carry mode) (carry-mode carry))
    (carry-info-method-9 (-> self carry))
    )
  :exit (behavior ()
    (when (not (and (-> self next-state) (let ((v1-3 (-> self next-state name)))
                                           (or (= v1-3 'target-carry-stance)
                                               (= v1-3 'target-carry-walk)
                                               (= v1-3 'target-carry-drop)
                                               (= v1-3 'target-carry-throw)
                                               (= v1-3 'target-carry-jump)
                                               (= v1-3 'target-carry-falling)
                                               (= v1-3 'target-carry-hit-ground)
                                               (= v1-3 'target-carry-throw)
                                               )
                                           )
                    )
               )
      (logclear! (-> self focus-status) (focus-status carry))
      (send-event (handle->process (-> self carry other)) 'drop (-> self carry) *null-vector*)
      (target-collide-set! 'normal 0.0)
      (target-exit)
      )
    )
  :code (behavior ()
    (let ((f30-0 0.0))
      (let ((f28-0 0.0))
        (ja-channel-push! 2 (seconds 0.1))
        (target-danger-set! 'carry? #f)
        (ja :group! (-> self draw art-group data 319) :num! min)
        (ja :chan 1
            :group! (-> self draw art-group data 318)
            :num! (chan 0)
            :frame-interp0 f30-0
            :frame-interp1 f30-0
            )
        (suspend)
        (format #t "carry picked ~A~%" (handle->process (-> self carry other)))
        (let ((a1-5 (new 'stack-no-clear 'event-message-block)))
          (set! (-> a1-5 from) (process->ppointer self))
          (set! (-> a1-5 num-params) 0)
          (set! (-> a1-5 message) 'carry-info)
          (let ((gp-1 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-5))))
            (when gp-1
              (let* ((s5-1 (vector-! (new 'stack-no-clear 'vector) (-> gp-1 point) (-> self control trans)))
                     (s4-0 (new-stack-vector0))
                     (f26-0 (vector-dot (-> self control local-normal) s5-1))
                     )
                0.0
                (vector-! s4-0 s5-1 (vector-float*! s4-0 (-> self control local-normal) f26-0))
                (let* ((f24-0 (vector-length s4-0))
                       (f22-0 f24-0)
                       )
                  (set! f28-0 (lerp-scale 1.0 0.0 f26-0 1638.4 4505.6))
                  (vector+!
                    s5-1
                    (vector-float*! s5-1 (-> self control local-normal) f26-0)
                    (vector-float*! s4-0 s4-0 (/ f24-0 f22-0))
                    )
                  )
                )
              (forward-up-nopitch->quaternion
                (-> self control dir-targ)
                (vector-normalize! (vector-! (new-stack-vector0) (-> gp-1 point) (-> self control trans)) 1.0)
                (vector-y-quaternion! (new-stack-vector0) (-> self control dir-targ))
                )
              )
            )
          )
        (target-danger-set! 'harmless #f)
        (ja-no-eval :num! (seek! (ja-aframe 5.0 0)))
        (while (not (ja-done? 0))
          (set! f30-0 (seek f30-0 f28-0 (* 5.0 (seconds-per-frame))))
          (ja :chan 1 :frame-interp0 f30-0 :frame-interp1 f30-0)
          (suspend)
          (ja-eval)
          )
        (when (send-event (handle->process (-> self carry other)) 'pickup (-> self carry))
          (target-collide-set! 'carry 0.0)
          (ja-no-eval :num! (seek!))
          (while (not (ja-done? 0))
            (set! f30-0 (seek f30-0 f28-0 (* 5.0 (seconds-per-frame))))
            (ja :chan 1 :frame-interp0 f30-0 :frame-interp1 f30-0)
            (when (< 22.0 (ja-aframe-num 0))
              (let ((a1-22 (new 'stack-no-clear 'event-message-block)))
                (set! (-> a1-22 from) (process->ppointer self))
                (set! (-> a1-22 num-params) 0)
                (set! (-> a1-22 message) 'carry-info)
                (let ((gp-4 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-22))))
                  (if gp-4
                      (seek! (-> gp-4 grab-trans-blend) 0.0 (* 2.0 (seconds-per-frame)))
                      )
                  )
                )
              )
            (suspend)
            (ja-eval)
            )
          (go target-carry-stance)
          )
        )
      (ja-no-eval :num! (seek! 0.0))
      (while (not (ja-done? 0))
        (ja :chan 1 :frame-interp0 f30-0 :frame-interp1 f30-0)
        (suspend)
        (ja-eval)
        )
      )
    (go target-stance)
    )
  :post (behavior ()
    (target-no-stick-post)
    (carry-info-method-9 (-> self carry))
    (target-carry-update)
    )
  )

(defstate target-carry-drop (target)
  :event target-standard-event-handler
  :enter (behavior ()
    (set! (-> self control mod-surface) *walk-mods*)
    (set-time! (-> self state-time))
    (set-forward-vel 0.0)
    )
  :code (behavior ()
    (let ((f30-0 1.0))
      (let ((a1-0 (new 'stack-no-clear 'event-message-block)))
        (set! (-> a1-0 from) (process->ppointer self))
        (set! (-> a1-0 num-params) 0)
        (set! (-> a1-0 message) 'carry-info)
        (let ((a0-5 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-0))))
          (when a0-5
            (let ((gp-0 (new 'stack-no-clear 'vector)))
              (set! (-> gp-0 quad) (-> a0-5 point quad))
              (set! (-> gp-0 y) (- (-> gp-0 y) (-> a0-5 process 0 control root-prim prim-core world-sphere w)))
              (let ((s5-0 (new-stack-vector0))
                    (f28-0 (vector-dot (-> self control local-normal) gp-0))
                    )
                0.0
                (vector-! s5-0 gp-0 (vector-float*! s5-0 (-> self control local-normal) f28-0))
                (let* ((f26-0 (vector-length s5-0))
                       (f24-0 f26-0)
                       )
                  (set! f30-0 (lerp-scale 1.0 0.0 f28-0 1638.4 4505.6))
                  (vector+!
                    gp-0
                    (vector-float*! gp-0 (-> self control local-normal) f28-0)
                    (vector-float*! s5-0 s5-0 (/ f26-0 f24-0))
                    )
                  )
                )
              )
            )
          )
        )
      (ja-channel-push! 2 (seconds 0.1))
      (ja :group! (-> self draw art-group data 319) :num! max)
      (ja :chan 1
          :group! (-> self draw art-group data 318)
          :num! (chan 0)
          :frame-interp0 f30-0
          :frame-interp1 f30-0
          )
      )
    (suspend)
    (ja-no-eval :num! (seek! (ja-aframe 5.0 0)))
    (while (not (ja-done? 0))
      (let ((a1-9 (new 'stack-no-clear 'event-message-block)))
        (set! (-> a1-9 from) (process->ppointer self))
        (set! (-> a1-9 num-params) 0)
        (set! (-> a1-9 message) 'carry-info)
        (let ((gp-4 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-9))))
          (when gp-4
            (if (< 22.0 (ja-aframe-num 0))
                (seek! (-> gp-4 grab-trans-blend) 1.0 (* 2.0 (seconds-per-frame)))
                )
            (let ((s4-0 (-> gp-4 process 0 control))
                  (gp-5 (new 'stack-no-clear 'collide-query))
                  )
              (let ((s5-1 (new 'stack-no-clear 'inline-array 'sphere 1)))
                (dotimes (s3-0 1)
                  ((method-of-type sphere new) (the-as symbol (-> s5-1 s3-0)) sphere)
                  )
                (set! (-> s5-1 0 quad) (-> s4-0 root-prim prim-core world-sphere quad))
                (let ((v1-64 gp-5))
                  (set! (-> v1-64 best-dist) (the-as float s5-1))
                  (set! (-> v1-64 num-spheres) (the-as uint 1))
                  (set! (-> v1-64 collide-with) (-> self control root-prim prim-core collide-with))
                  (set! (-> v1-64 ignore-process0) #f)
                  (set! (-> v1-64 ignore-process1) #f)
                  (set! (-> v1-64 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1))
                  (set! (-> v1-64 best-my-prim) (the-as collide-shape-prim #t))
                  (set! (-> v1-64 action-mask) (collide-action solid))
                  )
                )
              (when (fill-and-probe-using-spheres *collide-cache* gp-5)
                (ja-no-eval :num! (seek!))
                (while (not (ja-done? 0))
                  (when (< 22.0 (ja-aframe-num 0))
                    (let ((a1-14 (new 'stack-no-clear 'event-message-block)))
                      (set! (-> a1-14 from) (process->ppointer self))
                      (set! (-> a1-14 num-params) 0)
                      (set! (-> a1-14 message) 'carry-info)
                      (let ((gp-6 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-14))))
                        (if gp-6
                            (seek! (-> gp-6 grab-trans-blend) 0.0 (* 2.0 (seconds-per-frame)))
                            )
                        )
                      )
                    )
                  (suspend)
                  (ja-eval)
                  )
                (go target-carry-stance)
                )
              )
            )
          )
        )
      (suspend)
      (ja-eval)
      )
    (send-event (handle->process (-> self carry other)) 'drop (-> self carry) *null-vector*)
    (target-collide-set! 'normal 0.0)
    (ja-no-eval :num! (seek! 0.0))
    (while (not (ja-done? 0))
      (suspend)
      (ja-eval)
      )
    (go target-stance)
    )
  :post (-> target-carry-pickup post)
  )

(defstate target-carry-stance (target)
  :event target-standard-event-handler
  :enter (behavior ()
    (set! (-> self control mod-surface) *carry-walk-mods*)
    (set-time! (-> self state-time))
    )
  :exit (behavior ()
    ((-> target-carry-pickup exit))
    (set! (-> self control bend-target) 0.0)
    (target-state-hook-exit)
    )
  :trans (behavior ()
    ((-> self state-hook))
    (when (move-legs?)
      (set! (-> self control bend-target) 0.0)
      (remove-exit)
      (go target-carry-walk)
      )
    (if (cpad-pressed? (-> self control cpad number) r1)
        (go target-carry-drop)
        )
    ;; og:preserve-this - High FPS Fix - https://github.com/open-goal/jak-project/pull/3178
    (if (and (recently-pressed? x)
             (can-jump? #f)
             )
        (go target-carry-jump (-> *TARGET-bank* carry-jump-height-min) (-> *TARGET-bank* carry-jump-height-max) #f)
        )
    (if (and (cpad-pressed? (-> self control cpad number) square) (can-hands? #t))
        (go target-carry-throw)
        )
    (fall-test (the-as (state symbol target) target-carry-falling) -4096000.0)
    )
  :code (behavior ()
    (let ((v1-2 (ja-group)))
      (when (not (and v1-2 (= v1-2 (-> self draw art-group data 316))))
        (ja-channel-push! 1 (seconds 0.1))
        (ja :group! (-> self draw art-group data 316))
        )
      )
    (until #f
      (suspend)
      (ja :num! (loop!))
      )
    #f
    )
  :post target-carry-post
  )

(defstate target-carry-walk (target)
  :event target-standard-event-handler
  :enter (behavior ()
    (set-time! (-> self state-time))
    (set! (-> self control mod-surface) *carry-walk-mods*)
    )
  :exit (behavior ()
    ((-> target-carry-pickup exit))
    (target-effect-exit)
    (target-state-hook-exit)
    )
  :trans (behavior ()
    ((-> self state-hook))
    (when (not (move-legs?))
      (target-effect-exit)
      (remove-exit)
      (go target-carry-stance)
      )
    (if (cpad-pressed? (-> self control cpad number) r1)
        (go target-carry-drop)
        )
    ;; og:preserve-this - High FPS Fix - https://github.com/open-goal/jak-project/pull/3178
    (if (and (recently-pressed? x)
             (can-jump? #f)
             )
        (go target-carry-jump (-> *TARGET-bank* carry-jump-height-min) (-> *TARGET-bank* carry-jump-height-max) #f)
        )
    (if (and (cpad-pressed? (-> self control cpad number) square) (can-hands? #t))
        (go target-carry-throw)
        )
    (fall-test (the-as (state symbol target) target-carry-falling) -4096000.0)
    )
  :code (behavior ()
    (let ((v1-2 (ja-group)))
      (when (not (and v1-2 (= v1-2 (-> self draw art-group data 317))))
        (ja-channel-push! 1 (seconds 0.1))
        (ja :group! (-> self draw art-group data 317) :dist (-> *TARGET-bank* walk-cycle-dist))
        )
      )
    (until #f
      (suspend)
      (let* ((f0-2 (* (current-cycle-distance (-> self skel)) (-> self control scale x)))
             (f0-4 (/ (-> self control ctrl-xz-vel) (* 1.25 f0-2)))
             )
        (ja :num! (loop! f0-4))
        )
      )
    #f
    )
  :post target-carry-post
  )

(defstate target-carry-falling (target)
  :event target-jump-event-handler
  :enter (behavior ()
    (set! (-> self control mod-surface) *carry-jump-mods*)
    (set-time! (-> self state-time))
    )
  :trans (behavior ()
    (if (logtest? (-> self control status) (collide-status on-surface))
        (go target-carry-hit-ground #f)
        )
    (let* ((f0-0 (target-move-dist (-> *TARGET-bank* stuck-time)))
           (v1-9 (ja-group))
           (v1-12 (if (and v1-9 (= v1-9 (-> self draw art-group data 322)))
                      15
                      -1
                      )
                  )
           )
      (when (if (and (< f0-0 (-> *TARGET-bank* stuck-distance))
                     (and (>= v1-12 0)
                          (time-elapsed? (-> self state-time) v1-12)
                          (not (and *cheat-mode* (cpad-hold? (-> self control cpad number) r2)))
                          )
                     )
                #t
                )
        (logior! (-> self control status) (collide-status on-surface))
        (go target-carry-hit-ground 'stuck)
        )
      )
    )
  :code (behavior ()
    (let ((v1-2 (ja-group)))
      (cond
        ((and v1-2 (= v1-2 (-> self draw art-group data 322)))
         )
        (else
          (ja-channel-push! 1 (seconds 0.33))
          (ja :group! (-> self draw art-group data 322))
          (while (!= (-> self skel root-channel 0) (-> self skel channel))
            (suspend)
            )
          )
        )
      )
    (ja-no-eval :group! (-> self draw art-group data 322) :num! (loop!) :frame-num 0.0)
    (until #f
      (suspend)
      (ja :group! jakb-jump-loop-ja :num! (loop!))
      )
    #f
    )
  :post target-carry-post
  )

(defstate target-carry-hit-ground (target)
  :event target-walk-event-handler
  :enter (behavior ((arg0 symbol))
    (case arg0
      (('stuck)
       )
      (else
        (target-land-effect)
        )
      )
    (set! (-> self control last-running-attack-end-time) 0)
    (set! (-> self control last-attack-end-time) 0)
    (if (>= (-> self control ground-impact-vel) (-> *TARGET-bank* fall-stumble-threshold))
        (set-forward-vel 0.0)
        )
    (if (!= (-> self control ground-pat material) (pat-material ice))
        (delete-back-vel)
        )
    (set! (-> self control mod-surface) *carry-walk-mods*)
    (start-bobbing!
      (-> self water)
      (lerp-scale 0.0 4096.0 (-> self control ground-impact-vel) 40960.0 102400.0)
      600
      1500
      )
    )
  :exit (behavior ()
    (logclear! (-> self state-flags) (state-flags lleg-still rleg-still))
    )
  :trans (behavior ()
    ;; og:preserve-this - High FPS Fix - https://github.com/open-goal/jak-project/pull/3178
    (if (and (recently-pressed? x)
             (can-jump? #f)
             )
        (go target-carry-jump (-> *TARGET-bank* carry-jump-height-min) (-> *TARGET-bank* carry-jump-height-max) #f)
        )
    (if (!= (-> *cpad-list* cpads (-> self control cpad number) stick0-speed) 0.0)
        (go target-carry-walk)
        )
    (fall-test (the-as (state symbol target) target-carry-falling) -4096000.0)
    )
  :code (behavior ((arg0 symbol))
    (target-hit-ground-anim #f (are-still?))
    (go target-carry-stance)
    )
  :post target-carry-post
  )

(defstate target-carry-jump (target)
  :event target-jump-event-handler
  :enter (behavior ((arg0 float) (arg1 float) (arg2 symbol))
    (set-time! (-> self state-time))
    (sound-play "jump" :vol 70)
    (init-var-jump arg0 arg1 #t #f (-> self control transv) 2.0)
    (logclear! (-> self control status) (collide-status on-surface on-ground touch-surface))
    (set! (-> self control mod-surface) *carry-jump-mods*)
    (set! (-> self control unknown-float36)
          (fmax 0.0 (fmin 1.0 (* 0.00004359654 (+ -11468.8 (-> self control ctrl-xz-vel)))))
          )
    (set! (-> self control unknown-float35)
          (fmax 0.0 (fmin 1.0 (* 0.000048828126 (+ -10240.0 (-> self control ctrl-xz-vel)))))
          )
    )
  :exit (behavior ()
    ((-> target-carry-pickup exit))
    (target-exit)
    )
  :trans (behavior ()
    (set! (-> self control unknown-float36)
          (fmax
            (-> self control unknown-float36)
            (* 0.003921569 (the float (-> *cpad-list* cpads (-> self control cpad number) abutton (abutton-idx x)))) ;; og:preserve-this abutton indexing
            )
          )
    ((-> target-carry-falling trans))
    (mod-var-jump #t #f (cpad-hold? (-> self control cpad number) x) (-> self control transv))
    (seek!
      (-> self control unknown-float35)
      (fmax 0.0 (fmin 1.0 (* 0.000048828126 (+ -10240.0 (-> self control ctrl-xz-vel)))))
      (seconds-per-frame)
      )
    )
  :code (behavior ((arg0 float) (arg1 float) (arg2 symbol))
    (ja-channel-push! 1 (seconds 0.05))
    (ja :group! (-> self draw art-group data 321) :num! min)
    (suspend)
    (ja :group! (-> self draw art-group data 321) :num! (+!))
    (suspend)
    (until (ja-done? 0)
      (let ((f30-0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))
            (f0-4 (- 6.0 (ja-aframe-num 0)))
            (gp-1 (-> self skel root-channel 0))
            )
        (set! (-> gp-1 param 0) (the float (+ (-> gp-1 frame-group frames num-frames) -1)))
        (let ((v1-27 (and (< 0.0 f30-0) (< 0.0 f0-4))))
          (set! (-> gp-1 param 1)
                (if v1-27
                    (fmin (fmin 3.0 f0-4) (/ (* 5.0 f0-4) (the float (time-to-apex f30-0 -245760.0))))
                    1.0
                    )
                )
          )
        (joint-control-channel-group-eval! gp-1 (the-as art-joint-anim #f) num-func-seek!)
        )
      (suspend)
      )
    (go target-carry-falling)
    )
  :post target-carry-post
  )

(defstate target-carry-throw (target)
  :event target-standard-event-handler
  :enter (behavior ()
    (set! (-> self control mod-surface) *walk-mods*)
    (set-time! (-> self state-time))
    (set-forward-vel 0.0)
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.1))
    (ja-no-eval :group! (-> self draw art-group data 320) :num! (seek! (ja-aframe 19.0 0)) :frame-num 0.0)
    (until (ja-done? 0)
      (let ((a1-3 (new 'stack-no-clear 'event-message-block)))
        (set! (-> a1-3 from) (process->ppointer self))
        (set! (-> a1-3 num-params) 0)
        (set! (-> a1-3 message) 'carry-info)
        (let ((gp-1 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-3))))
          (if gp-1
              (seek! (-> gp-1 grab-trans-blend) 1.0 (* 4.0 (seconds-per-frame)))
              )
          )
        )
      (suspend)
      (ja :num! (seek! (ja-aframe 19.0 0)))
      )
    (let ((a1-7 (new 'stack-no-clear 'event-message-block)))
      (set! (-> a1-7 from) (process->ppointer self))
      (set! (-> a1-7 num-params) 0)
      (set! (-> a1-7 message) 'carry-info)
      (let ((v1-30 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-7))))
        (when v1-30
          (let ((s4-0 (-> v1-30 process 0 control))
                (gp-3 (new 'stack-no-clear 'collide-query))
                )
            (let ((s5-0 (new 'stack-no-clear 'inline-array 'sphere 1)))
              (dotimes (s3-0 1)
                ((method-of-type sphere new) (the-as symbol (-> s5-0 s3-0)) sphere)
                )
              (set! (-> s5-0 0 quad) (-> s4-0 root-prim prim-core world-sphere quad))
              (let ((v1-38 gp-3))
                (set! (-> v1-38 best-dist) (the-as float s5-0))
                (set! (-> v1-38 num-spheres) (the-as uint 1))
                (set! (-> v1-38 collide-with) (-> self control root-prim prim-core collide-with))
                (set! (-> v1-38 ignore-process0) #f)
                (set! (-> v1-38 ignore-process1) #f)
                (set! (-> v1-38 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1))
                (set! (-> v1-38 best-my-prim) (the-as collide-shape-prim #t))
                (set! (-> v1-38 action-mask) (collide-action solid))
                )
              )
            (when (fill-and-probe-using-spheres *collide-cache* gp-3)
              (ja-no-eval :num! (seek! 0.0))
              (while (not (ja-done? 0))
                (let ((a1-11 (new 'stack-no-clear 'event-message-block)))
                  (set! (-> a1-11 from) (process->ppointer self))
                  (set! (-> a1-11 num-params) 0)
                  (set! (-> a1-11 message) 'carry-info)
                  (let ((gp-4 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-11))))
                    (if gp-4
                        (seek! (-> gp-4 grab-trans-blend) 0.0 (* 4.0 (seconds-per-frame)))
                        )
                    )
                  )
                (suspend)
                (ja-eval)
                )
              (go target-carry-stance)
              )
            )
          )
        )
      )
    (let ((v1-58 (vector-float*! (new 'stack-no-clear 'vector) (-> self control local-normal) 79764.13)))
      (vector+float*! v1-58 v1-58 (-> self control c-R-w vector 2) 32768.0)
      (send-event (handle->process (-> self carry other)) 'drop (-> self carry) v1-58)
      )
    (target-collide-set! 'normal 0.0)
    (ja-no-eval :num! (seek!))
    (while (not (ja-done? 0))
      (suspend)
      (ja-eval)
      )
    (go target-stance)
    )
  :post (-> target-carry-pickup post)
  )
