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

(import "goal_src/jak1/import/baby-spider-ag.gc")

;; definition of type baby-spider-spawn-params
(deftype baby-spider-spawn-params (structure)
  ((hatched?                          symbol      :offset-assert   0)
   (fast-start?                       symbol      :offset-assert   4)
   (hack-move-above-ground?           symbol      :offset-assert   8)
   (die-if-not-visible?               symbol      :offset-assert  12)
   (pickup                            int32       :offset-assert  16)
   (pickup-amount                     int32       :offset-assert  20)
   (event-death                       symbol      :offset-assert  24)
   (delay-before-dying-if-not-visible time-frame  :offset-assert  32)
   )
  :method-count-assert 11
  :size-assert         #x28
  :flag-assert         #xb00000028
  (:methods
    (init! (_type_ symbol symbol symbol symbol int int symbol) none 9)
    (set-delay! (_type_ time-frame) none 10)
    )
  )

;; definition for method 3 of type baby-spider-spawn-params
(defmethod inspect baby-spider-spawn-params ((obj baby-spider-spawn-params))
  (format #t "[~8x] ~A~%" obj 'baby-spider-spawn-params)
  (format #t "~Thatched?: ~A~%" (-> obj hatched?))
  (format #t "~Tfast-start?: ~A~%" (-> obj fast-start?))
  (format #t "~Thack-move-above-ground?: ~A~%" (-> obj hack-move-above-ground?))
  (format #t "~Tdie-if-not-visible?: ~A~%" (-> obj die-if-not-visible?))
  (format #t "~Tpickup: ~D~%" (-> obj pickup))
  (format #t "~Tpickup-amount: ~D~%" (-> obj pickup-amount))
  (format #t "~Tevent-death: ~A~%" (-> obj event-death))
  (format #t "~Tdelay-before-dying-if-not-visible: ~D~%" (-> obj delay-before-dying-if-not-visible))
  obj
  )

;; definition of type baby-spider
(deftype baby-spider (nav-enemy)
  ((die-if-not-visible?               symbol             :offset-assert 400)
   (hack-move-above-ground?           symbol             :offset-assert 404)
   (state-float                       float              :offset-assert 408)
   (wiggle-angle                      float              :offset-assert 412)
   (delta-wiggle-angle                float              :offset-assert 416)
   (wiggle-factor                     float              :offset-assert 420)
   (event-death                       symbol             :offset-assert 424)
   (delay-before-dying-if-not-visible time-frame         :offset-assert 432)
   (chase-rest-time                   time-frame         :offset-assert 440)
   (target-nav-time                   time-frame         :offset-assert 448)
   (unknown00                         basic              :offset-assert 456)
   (unknown01                         basic              :offset-assert 460)
   (wiggle-time                       time-frame         :offset-assert 464)
   (last-visible-time                 time-frame         :offset-assert 472)
   (up-vector                         vector     :inline :offset-assert 480)
   (state-vector                      vector     :inline :offset-assert 496)
   )
  :heap-base #x190
  :method-count-assert 76
  :size-assert         #x200
  :flag-assert         #x4c01900200
  (:states
    baby-spider-die-fast
    baby-spider-hatching
    baby-spider-resume
    )
  )

;; definition for method 3 of type baby-spider
(defmethod inspect baby-spider ((obj baby-spider))
  (let ((t9-0 (method-of-type nav-enemy inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Tdie-if-not-visible?: ~A~%" (-> obj die-if-not-visible?))
  (format #t "~T~Thack-move-above-ground?: ~A~%" (-> obj hack-move-above-ground?))
  (format #t "~T~Tstate-float: ~f~%" (-> obj state-float))
  (format #t "~T~Twiggle-angle: ~f~%" (-> obj wiggle-angle))
  (format #t "~T~Tdelta-wiggle-angle: ~f~%" (-> obj delta-wiggle-angle))
  (format #t "~T~Twiggle-factor: ~f~%" (-> obj wiggle-factor))
  (format #t "~T~Tevent-death: ~A~%" (-> obj event-death))
  (format #t "~T~Tdelay-before-dying-if-not-visible: ~D~%" (-> obj delay-before-dying-if-not-visible))
  (format #t "~T~Tchase-rest-time: ~D~%" (-> obj chase-rest-time))
  (format #t "~T~Ttarget-nav-time: ~D~%" (-> obj target-nav-time))
  (format #t "~T~Tfree-time: ~D~%" (-> obj free-time))
  (format #t "~T~Twiggle-time: ~D~%" (-> obj wiggle-time))
  (format #t "~T~Tlast-visible-time: ~D~%" (-> obj last-visible-time))
  (format #t "~T~Tup-vector: #<vector @ #x~X>~%" (-> obj up-vector))
  (format #t "~T~Tstate-vector: ~`vector`P~%" (-> obj state-vector))
  obj
  )

;; failed to figure out what this is:
(defskelgroup *baby-spider-sg* baby-spider baby-spider-lod0-jg -1
              ((baby-spider-lod0-mg (meters 20)) (baby-spider-lod1-mg (meters 40)) (baby-spider-lod2-mg (meters 999999)))
              :bounds (static-spherem 0 1 0 2.25)
              :shadow baby-spider-shadow-mg
              )

;; definition for symbol *baby-spider-nav-enemy-info*, type nav-enemy-info
(define *baby-spider-nav-enemy-info* (new 'static 'nav-enemy-info
                                       :idle-anim 6
                                       :walk-anim 8
                                       :turn-anim 8
                                       :notice-anim 11
                                       :run-anim 7
                                       :jump-anim 9
                                       :jump-land-anim 10
                                       :victory-anim 12
                                       :taunt-anim 12
                                       :die-anim 13
                                       :neck-joint 18
                                       :run-travel-speed (meters 7)
                                       :run-rotate-speed (degrees 7999.9995)
                                       :run-acceleration (meters 1)
                                       :run-turn-time (seconds 0.075)
                                       :walk-travel-speed (meters 2)
                                       :walk-rotate-speed (degrees 7999.9995)
                                       :walk-acceleration (meters 1)
                                       :walk-turn-time (seconds 0.075)
                                       :attack-shove-back (meters 3)
                                       :attack-shove-up (meters 2)
                                       :shadow-size (meters 1)
                                       :notice-nav-radius (meters 1)
                                       :nav-nearest-y-threshold (meters 10)
                                       :notice-distance (meters 30)
                                       :stop-chase-distance (meters 40)
                                       :frustration-distance (meters 3)
                                       :frustration-time (seconds 1.5)
                                       :die-anim-hold-frame 10000000000.0
                                       :jump-anim-start-frame 2.0
                                       :jump-land-anim-end-frame 10000000000.0
                                       :jump-height-min (meters 1)
                                       :jump-height-factor 0.5
                                       :jump-start-anim-speed 1.0
                                       :shadow-max-y (meters 1)
                                       :shadow-min-y (meters -1)
                                       :shadow-locus-dist (meters 150)
                                       :use-align #f
                                       :draw-shadow #f
                                       :move-to-ground #t
                                       :hover-if-no-ground #f
                                       :use-momentum #f
                                       :use-flee #f
                                       :use-proximity-notice #f
                                       :use-jump-blocked #f
                                       :use-jump-patrol #f
                                       :gnd-collide-with (collide-kind background)
                                       :debug-draw-neck #f
                                       :debug-draw-jump #f
                                       )
        )

;; definition for symbol *baby-spider-nav-enemy-info-for-cave-trap*, type nav-enemy-info
(define *baby-spider-nav-enemy-info-for-cave-trap* (new 'static 'nav-enemy-info
                                                     :idle-anim 6
                                                     :walk-anim 8
                                                     :turn-anim 8
                                                     :notice-anim 11
                                                     :run-anim 7
                                                     :jump-anim 9
                                                     :jump-land-anim 10
                                                     :victory-anim 12
                                                     :taunt-anim 12
                                                     :die-anim 13
                                                     :neck-joint 18
                                                     :run-travel-speed (meters 7)
                                                     :run-rotate-speed (degrees 7999.9995)
                                                     :run-acceleration (meters 1)
                                                     :run-turn-time (seconds 0.075)
                                                     :walk-travel-speed (meters 2)
                                                     :walk-rotate-speed (degrees 7999.9995)
                                                     :walk-acceleration (meters 1)
                                                     :walk-turn-time (seconds 0.075)
                                                     :attack-shove-back (meters 3)
                                                     :attack-shove-up (meters 2)
                                                     :shadow-size (meters 1)
                                                     :notice-nav-radius (meters 1)
                                                     :nav-nearest-y-threshold (meters 10)
                                                     :notice-distance (meters 80)
                                                     :stop-chase-distance (meters 90)
                                                     :frustration-distance (meters 3)
                                                     :frustration-time (seconds 1.5)
                                                     :die-anim-hold-frame 10000000000.0
                                                     :jump-anim-start-frame 2.0
                                                     :jump-land-anim-end-frame 10000000000.0
                                                     :jump-height-min (meters 1)
                                                     :jump-height-factor 0.5
                                                     :jump-start-anim-speed 1.0
                                                     :shadow-max-y (meters 1)
                                                     :shadow-min-y (meters -1)
                                                     :shadow-locus-dist (meters 150)
                                                     :use-align #f
                                                     :draw-shadow #f
                                                     :move-to-ground #t
                                                     :hover-if-no-ground #f
                                                     :use-momentum #f
                                                     :use-flee #f
                                                     :use-proximity-notice #f
                                                     :use-jump-blocked #f
                                                     :use-jump-patrol #f
                                                     :gnd-collide-with (collide-kind background)
                                                     :debug-draw-neck #f
                                                     :debug-draw-jump #f
                                                     )
        )

;; definition for method 9 of type baby-spider-spawn-params
;; INFO: Return type mismatch int vs none.
(defmethod init! baby-spider-spawn-params ((obj baby-spider-spawn-params)
                                         (arg0 symbol)
                                         (arg1 symbol)
                                         (arg2 symbol)
                                         (arg3 symbol)
                                         (arg4 int)
                                         (arg5 int)
                                         (arg6 symbol)
                                         )
  (set! (-> obj hatched?) arg0)
  (set! (-> obj fast-start?) arg1)
  (set! (-> obj die-if-not-visible?) arg2)
  (set! (-> obj hack-move-above-ground?) arg3)
  (set! (-> obj pickup) arg4)
  (set! (-> obj pickup-amount) arg5)
  (set! (-> obj event-death) arg6)
  (set! (-> obj delay-before-dying-if-not-visible) (seconds 2))
  (none)
  )

;; definition for method 10 of type baby-spider-spawn-params
;; INFO: Return type mismatch time-frame vs none.
(defmethod set-delay! baby-spider-spawn-params ((obj baby-spider-spawn-params) (arg0 time-frame))
  (set! (-> obj delay-before-dying-if-not-visible) arg0)
  (none)
  )

;; definition for method 44 of type baby-spider
(defmethod dummy-44 baby-spider ((obj baby-spider) (arg0 process) (arg1 event-message-block))
  (when ((method-of-type touching-shapes-entry prims-touching?)
         (the-as touching-shapes-entry (-> arg1 param 0))
         (-> obj collide-info)
         (the-as uint 1)
         )
    (if (nav-enemy-send-attack arg0 (the-as touching-shapes-entry (-> arg1 param 0)) 'generic)
        (go (method-of-object obj nav-enemy-victory))
        )
    )
  )

;; definition for function baby-spider-default-event-handler
;; INFO: Return type mismatch none vs object.
;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 7]
(defbehavior baby-spider-default-event-handler baby-spider ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
  (let ((v1-0 arg2))
    (the-as object (if (= v1-0 'victory)
                       (go-virtual nav-enemy-victory)
                       (nav-enemy-default-event-handler arg0 arg1 arg2 arg3)
                       )
            )
    )
  )

;; failed to figure out what this is:
baby-spider-default-event-handler

;; definition for method 39 of type baby-spider
;; Used lq/sq
(defmethod common-post baby-spider ((obj baby-spider))
  (when (logtest? (-> obj collide-info status) (cshape-moving-flags onsurf))
    (vector-deg-seek (-> obj up-vector) (-> obj up-vector) (-> obj collide-info surface-normal) 910.2222)
    (vector-normalize! (-> obj up-vector) 1.0)
    )
  (forward-up-nopitch->quaternion
    (-> obj collide-info quat)
    (vector-z-quaternion! (new-stack-vector0) (-> obj collide-info quat))
    (-> obj up-vector)
    )
  ((the-as (function nav-enemy none) (find-parent-method baby-spider 39)) obj)
  (none)
  )

;; definition for method 38 of type baby-spider
(defmethod TODO-RENAME-38 baby-spider ((obj baby-spider))
  (integrate-for-enemy-with-move-to-ground!
    (-> obj collide-info)
    (-> obj collide-info transv)
    (collide-kind background)
    8192.0
    #t
    #f
    #f
    )
  (none)
  )

;; definition for method 51 of type baby-spider
;; INFO: Return type mismatch float vs none.
(defmethod dummy-51 baby-spider ((obj baby-spider))
  (let* ((f0-0 (rand-vu-float-range 0.0 1.0))
         (f1-1 (+ 1.0 (* 2.0 f0-0)))
         (f2-2 f1-1)
         (f2-4 (/ 1.0 f2-2))
         (f0-2 (+ 1.0 (* 0.2 f0-0)))
         )
    (set! (-> obj delta-wiggle-angle) (* 910.2222 f1-1))
    (set! (-> obj wiggle-factor) (* 1.5 f2-4))
    (set! (-> obj target-speed) (* 28672.0 f0-2))
    )
  (none)
  )

;; definition for method 52 of type baby-spider
;; INFO: Return type mismatch vector vs symbol.
;; Used lq/sq
(defmethod dummy-52 baby-spider ((obj baby-spider) (arg0 vector))
  (+! (-> obj wiggle-angle) (-> obj delta-wiggle-angle))
  (if (< 65536.0 (-> obj wiggle-angle))
      (set! (-> obj wiggle-angle) (+ -65536.0 (-> obj wiggle-angle)))
      )
  (let* ((v1-3 (-> obj collide-info trans))
         (a1-2 (vector-! (new 'stack-no-clear 'vector) v1-3 arg0))
         (s2-0 (vector-rotate-around-y! (new 'stack-no-clear 'vector) a1-2 16384.0))
         (v1-4
           (vector+*! (new 'stack-no-clear 'vector) arg0 s2-0 (* (-> obj wiggle-factor) (sin (-> obj wiggle-angle))))
           )
         (v0-3 (-> obj nav target-pos))
         )
    (set! (-> v0-3 quad) (-> v1-4 quad))
    (the-as symbol v0-3)
    )
  )

;; definition for method 53 of type baby-spider
(defmethod dummy-53 baby-spider ((obj baby-spider))
  (cond
    ((logtest? (-> obj draw status) (draw-status was-drawn))
     (set! (-> obj last-visible-time) (-> *display* base-frame-counter))
     (return #f)
     )
    (else
      (if (-> obj die-if-not-visible?)
          (return (>= (- (-> *display* base-frame-counter) (-> obj last-visible-time))
                      (-> obj delay-before-dying-if-not-visible)
                      )
                  )
          )
      )
    )
  #f
  )

;; failed to figure out what this is:
(defstate baby-spider-hatching (baby-spider)
  :event baby-spider-default-event-handler
  :code (behavior ()
    (ja-channel-push! 1 0)
    (ja-no-eval :group! baby-spider-birth-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (if (dummy-53 self)
          (go baby-spider-die-fast)
          )
      (suspend)
      (ja :num! (seek!))
      )
    (go baby-spider-resume)
    (none)
    )
  :post (the-as (function none :behavior baby-spider) nav-enemy-simple-post)
  )

;; failed to figure out what this is:
(defstate baby-spider-resume (baby-spider)
  :event baby-spider-default-event-handler
  :code (behavior ()
    (cond
      ((not *target*)
       (go-virtual nav-enemy-idle)
       )
      ((TODO-RENAME-46 self (-> self nav-info notice-distance))
       (go-virtual nav-enemy-chase)
       )
      ((and (and *target* (>= (-> self enemy-info idle-distance)
                              (vector-vector-distance (-> self collide-info trans) (-> *target* control trans))
                              )
                 )
            (>= (- (-> *display* base-frame-counter) (-> self state-time)) (-> self state-timeout))
            (nonzero? (-> self draw))
            (logtest? (-> self draw status) (draw-status was-drawn))
            )
       (go-virtual nav-enemy-patrol)
       )
      )
    (go-virtual nav-enemy-idle)
    (none)
    )
  )

;; failed to figure out what this is:
(defstate nav-enemy-idle (baby-spider)
  :virtual #t
  :event baby-spider-default-event-handler
  :enter (behavior ()
    (let ((gp-0 (new 'stack-no-clear 'vector)))
      (set! (-> gp-0 quad) (-> self collide-info trans quad))
      (let ((t9-0 (-> (method-of-type nav-enemy nav-enemy-idle) enter)))
        (if t9-0
            (t9-0)
            )
        )
      (if (-> self hack-move-above-ground?)
          (set! (-> self collide-info trans quad) (-> gp-0 quad))
          )
      )
    (none)
    )
  :trans (behavior ()
    (if (dummy-53 self)
        (go baby-spider-die-fast)
        )
    (let ((t9-2 (-> (method-of-type nav-enemy nav-enemy-idle) trans)))
      (if t9-2
          (t9-2)
          )
      )
    (none)
    )
  :post (behavior ()
    (ja-post)
    (none)
    )
  )

;; failed to figure out what this is:
(defstate nav-enemy-patrol (baby-spider)
  :virtual #t
  :event baby-spider-default-event-handler
  :trans (behavior ()
    (if (dummy-53 self)
        (go baby-spider-die-fast)
        )
    (let ((t9-2 (-> (method-of-type nav-enemy nav-enemy-patrol) trans)))
      (if t9-2
          (t9-2)
          )
      )
    (none)
    )
  :code (behavior ()
    (let ((f30-0 (nav-enemy-rnd-float-range 0.9 1.1)))
      (loop
        (ja-no-eval :group! (-> self draw art-group data (-> self nav-info walk-anim))
                    :num! (seek! max f30-0)
                    :frame-num 0.0
                    )
        (until (ja-done? 0)
          (suspend)
          (ja :num! (seek! max f30-0))
          )
        )
      )
    (none)
    )
  )

;; failed to figure out what this is:
(defstate nav-enemy-notice (baby-spider)
  :virtual #t
  :event baby-spider-default-event-handler
  :trans (behavior ()
    (if (dummy-53 self)
        (go baby-spider-die-fast)
        )
    (let ((t9-2 (-> (method-of-type nav-enemy nav-enemy-notice) trans)))
      (if t9-2
          (t9-2)
          )
      )
    (none)
    )
  :code (behavior ()
    (ja-no-eval :num! (loop!))
    (ja-channel-push! 1 (seconds 0.17))
    (ja-no-eval :group! baby-spider-notice-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (ja-blend-eval)
      (suspend)
      (ja :num! (seek!))
      )
    (ja-no-eval :num! (seek!))
    (go-virtual nav-enemy-chase)
    (none)
    )
  )

;; failed to figure out what this is:
(defstate nav-enemy-chase (baby-spider)
  :virtual #t
  :event baby-spider-default-event-handler
  :trans (behavior ()
    (if (dummy-53 self)
        (go baby-spider-die-fast)
        )
    (if (>= (- (-> *display* base-frame-counter) (-> self state-time)) (-> self chase-rest-time))
        (go-virtual nav-enemy-victory)
        )
    (let ((t9-3 (-> (method-of-type nav-enemy nav-enemy-chase) trans)))
      (if t9-3
          (t9-3)
          )
      )
    (none)
    )
  :code (behavior ()
    (set! (-> self target-nav-time) (-> *display* base-frame-counter))
    (set! (-> self wiggle-time) (+ (-> *display* base-frame-counter) (seconds -10)))
    (set! (-> self wiggle-angle) 0.0)
    (set! (-> self chase-rest-time) (rand-vu-int-range (seconds 1) (seconds 4)))
    (ja-channel-push! 1 (seconds 0.17))
    (ja :group! baby-spider-run-ja :num! min)
    (loop
      (when (>= (- (-> *display* base-frame-counter) (-> self wiggle-time)) (seconds 1))
        (set! (-> self wiggle-time) (-> *display* base-frame-counter))
        (dummy-51 self)
        )
      (suspend)
      (ja :num! (loop!))
      )
    (none)
    )
  :post (behavior ()
    (dummy-52 self (target-pos 0))
    (nav-enemy-travel-post)
    (none)
    )
  )

;; failed to figure out what this is:
(defstate nav-enemy-stop-chase (baby-spider)
  :virtual #t
  :event baby-spider-default-event-handler
  :trans (behavior ()
    (if (dummy-53 self)
        (go baby-spider-die-fast)
        )
    (let ((t9-2 (-> (method-of-type nav-enemy nav-enemy-stop-chase) trans)))
      (if t9-2
          (t9-2)
          )
      )
    (none)
    )
  :code (-> (method-of-type nav-enemy nav-enemy-stop-chase) code)
  )

;; failed to figure out what this is:
(defstate nav-enemy-stare (baby-spider)
  :virtual #t
  :event baby-spider-default-event-handler
  :trans (behavior ()
    (if (dummy-53 self)
        (go baby-spider-die-fast)
        )
    (let ((t9-2 (-> (method-of-type nav-enemy nav-enemy-stare) trans)))
      (if t9-2
          (t9-2)
          )
      )
    (none)
    )
  :code (behavior ()
    (set! (-> self rotate-speed) 1456355.5)
    (set! (-> self turn-time) (seconds 0.075))
    (let ((f30-0 (rand-vu-float-range 0.8 1.2)))
      (loop
        (logior! (-> self nav-enemy-flags) (nav-enemy-flags enable-travel))
        (ja-channel-push! 1 (seconds 0.1))
        (ja-no-eval :group! baby-spider-celebrate-ja :num! (seek! max f30-0) :frame-num 0.0)
        (until (ja-done? 0)
          (suspend)
          (ja :num! (seek! max f30-0))
          )
        (ja-no-eval :num! (loop!))
        (logclear! (-> self nav-enemy-flags) (nav-enemy-flags enable-travel))
        (let ((gp-0 (rand-vu-int-range 300 600))
              (s5-0 (-> *display* base-frame-counter))
              )
          (until (>= (- (-> *display* base-frame-counter) s5-0) gp-0)
            (ja :num-func num-func-identity :frame-num 0.0)
            (ja-blend-eval)
            (suspend)
            (suspend)
            )
          )
        )
      )
    (none)
    )
  )

;; failed to figure out what this is:
(defstate nav-enemy-give-up (baby-spider)
  :virtual #t
  :event baby-spider-default-event-handler
  :trans (behavior ()
    (if (dummy-53 self)
        (go baby-spider-die-fast)
        )
    (let ((t9-2 (-> (method-of-type nav-enemy nav-enemy-give-up) trans)))
      (if t9-2
          (t9-2)
          )
      )
    (none)
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.075))
    (ja-no-eval :group! baby-spider-idle-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (logclear! (-> self nav flags) (nav-control-flags navcf17 navcf19))
    (nav-enemy-get-new-patrol-point)
    (ja-no-eval :group! baby-spider-idle-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (seek-to-point-toward-point!
        (-> self collide-info)
        (-> self nav destination-pos)
        (-> self rotate-speed)
        (-> self turn-time)
        )
      (suspend)
      (ja :num! (seek!))
      )
    (go-virtual nav-enemy-patrol)
    (none)
    )
  )

;; failed to figure out what this is:
(defstate nav-enemy-attack (baby-spider)
  :virtual #t
  :event baby-spider-default-event-handler
  :trans (behavior ()
    (if (dummy-53 self)
        (go baby-spider-die-fast)
        )
    (let ((t9-2 (-> (method-of-type nav-enemy nav-enemy-attack) trans)))
      (if t9-2
          (t9-2)
          )
      )
    (none)
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.075))
    (ja-no-eval :group! baby-spider-idle-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (go-virtual nav-enemy-victory)
    (none)
    )
  )

;; failed to figure out what this is:
(defstate nav-enemy-victory (baby-spider)
  :virtual #t
  :event baby-spider-default-event-handler
  :trans (behavior ()
    (if (dummy-53 self)
        (go baby-spider-die-fast)
        )
    (let ((t9-2 (-> (method-of-type nav-enemy nav-enemy-victory) trans)))
      (if t9-2
          (t9-2)
          )
      )
    (none)
    )
  :code (-> (method-of-type nav-enemy nav-enemy-victory) code)
  )

;; failed to figure out what this is:
(defstate nav-enemy-die (baby-spider)
  :virtual #t
  :event (the-as
    (function process int symbol event-message-block object :behavior baby-spider)
    process-drawable-death-event-handler
    )
  :enter (behavior ()
    (let ((v1-0 (-> self event-death)))
      (if v1-0
          (send-event (ppointer->process (-> self parent)) v1-0)
          )
      )
    (set! (-> self draw bounds y) 8192.0)
    (set! (-> self draw bounds w) 22528.0)
    (let ((t9-1 (-> (method-of-type nav-enemy nav-enemy-die) enter)))
      (if t9-1
          (t9-1)
          )
      )
    (none)
    )
  )

;; failed to figure out what this is:
(defstate baby-spider-die-fast (baby-spider)
  :event baby-spider-default-event-handler
  :code (behavior ()
    (cleanup-for-death self)
    (let ((v1-2 (-> self event-death)))
      (if v1-2
          (send-event (ppointer->process (-> self parent)) v1-2)
          )
      )
    (none)
    )
  )

;; definition for method 47 of type baby-spider
;; INFO: Return type mismatch int vs none.
(defmethod initialize-collision baby-spider ((obj baby-spider))
  (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player))))
    (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process))
    (set! (-> s5-0 reaction) default-collision-reaction)
    (set! (-> s5-0 no-reaction)
          (the-as (function collide-shape-moving collide-shape-intersect vector vector none) nothing)
          )
    (let ((s4-0 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 3))))
      (set! (-> s4-0 prim-core collide-as) (collide-kind enemy))
      (set! (-> s4-0 collide-with) (collide-kind target))
      (set! (-> s4-0 prim-core action) (collide-action solid))
      (set! (-> s4-0 prim-core offense) (collide-offense normal-attack))
      (set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 4096.0)
      (set-root-prim! s5-0 s4-0)
      )
    (set! (-> s5-0 nav-radius) 4096.0)
    (backup-collide-with-as s5-0)
    (set! (-> obj collide-info) s5-0)
    )
  0
  (none)
  )

;; definition for method 48 of type baby-spider
;; INFO: Return type mismatch int vs none.
;; Used lq/sq
(defmethod TODO-RENAME-48 baby-spider ((obj baby-spider))
  (set! (-> obj last-visible-time) (-> *display* base-frame-counter))
  (initialize-skeleton obj *baby-spider-sg* '())
  (if (= (-> obj parent 0 type) cave-trap)
      (TODO-RENAME-45 obj *baby-spider-nav-enemy-info-for-cave-trap*)
      (TODO-RENAME-45 obj *baby-spider-nav-enemy-info*)
      )
  (let ((v1-11 (-> obj draw shadow-ctrl settings)))
    (logclear! (-> v1-11 flags) (shadow-flags shdf03))
    (set! (-> v1-11 fade-dist) 98304.0)
    )
  (vector-float*! (-> obj collide-info scale) *identity-vector* 0.63)
  (set! (-> obj neck up) (the-as uint 1))
  (set! (-> obj neck nose) (the-as uint 2))
  (set! (-> obj neck ear) (the-as uint 0))
  (set! (-> obj wiggle-angle) 0.0)
  (set! (-> obj delta-wiggle-angle) 910.2222)
  (set! (-> obj wiggle-factor) 1.5)
  (set! (-> obj reaction-time) (rand-vu-int-range (seconds 0.1) (seconds 0.8)))
  (set! (-> obj chase-rest-time) (seconds 1))
  (set! (-> obj up-vector quad) (-> *y-vector* quad))
  0
  (none)
  )

;; definition for function baby-spider-init-by-other
;; INFO: Return type mismatch object vs none.
;; Used lq/sq
(defbehavior baby-spider-init-by-other baby-spider ((arg0 baby-spider) (arg1 vector) (arg2 vector) (arg3 baby-spider-spawn-params))
  (set! (-> self event-death) (-> arg3 event-death))
  (set! (-> self die-if-not-visible?) (-> arg3 die-if-not-visible?))
  (set! (-> self delay-before-dying-if-not-visible) (-> arg3 delay-before-dying-if-not-visible))
  (initialize-collision self)
  (logior! (-> self mask) (process-mask actor-pause))
  (set! (-> self collide-info trans quad) (-> arg1 quad))
  (forward-up->quaternion (-> self collide-info quat) arg2 *up-vector*)
  (vector-float*! (-> self collide-info scale) *identity-vector* 0.63)
  (vector-float*! (-> self collide-info transv) arg2 8192.0)
  (set! (-> self mask) (logior (process-mask enemy) (-> self mask)))
  (set! (-> self entity) (-> arg0 entity))
  (TODO-RENAME-48 self)
  (set! (-> self enemy-info pickup-type) (the-as pickup-type (-> arg3 pickup)))
  (set! (-> self enemy-info pickup-amount) (the float (-> arg3 pickup-amount)))
  (create-connection!
    *cavecrystal-light-control*
    self
    (-> self entity)
    (the-as (function object object object object object) cavecrystal-light-control-default-callback)
    -1
    4096.0
    )
  (cond
    ((-> arg3 hatched?)
     (go baby-spider-hatching)
     )
    ((-> arg3 fast-start?)
     (go baby-spider-resume)
     )
    (else
      (go-virtual nav-enemy-idle)
      )
    )
  (none)
  )

;; definition for method 11 of type baby-spider
;; INFO: Return type mismatch object vs none.
(defmethod init-from-entity! baby-spider ((obj baby-spider) (arg0 entity-actor))
  (set! (-> obj die-if-not-visible?) #f)
  (set! (-> obj delay-before-dying-if-not-visible) (seconds 2))
  (set! (-> obj hack-move-above-ground?) #f)
  (set! (-> obj event-death) #f)
  (initialize-collision obj)
  (process-drawable-from-entity! obj arg0)
  (set! (-> obj mask) (logior (process-mask enemy) (-> obj mask)))
  (logior! (-> obj mask) (process-mask actor-pause))
  (set! (-> obj nav) (new 'process 'nav-control (-> obj collide-info) 24 40960.0))
  (logior! (-> obj nav flags) (nav-control-flags display-marks navcf3 navcf5 navcf6 navcf7))
  (set! (-> obj path) (new 'process 'path-control obj 'path 0.0))
  (logior! (-> obj path flags) (path-control-flag display draw-line draw-point draw-text))
  (create-connection!
    *cavecrystal-light-control*
    obj
    (-> obj entity)
    (the-as (function object object object object object) cavecrystal-light-control-default-callback)
    -1
    4096.0
    )
  (TODO-RENAME-48 obj)
  (go (method-of-object obj nav-enemy-idle))
  (none)
  )
