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

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

;; definition of type warrior
(deftype warrior (process-taskable)
  ()
  :heap-base #x110
  :method-count-assert 53
  :size-assert         #x17c
  :flag-assert         #x350110017c
  )

;; definition for method 3 of type warrior
(defmethod inspect warrior ((obj warrior))
  (let ((t9-0 (method-of-type process-taskable inspect)))
    (t9-0 obj)
    )
  obj
  )

;; failed to figure out what this is:
(defskelgroup *warrior-sg* warrior warrior-lod0-jg warrior-idle-ja
              ((warrior-lod0-mg (meters 20)) (warrior-lod1-mg (meters 40)) (warrior-lod2-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 4)
              :shadow warrior-shadow-mg
              )

;; definition for method 52 of type warrior
;; INFO: Return type mismatch int vs none.
(defmethod dummy-52 warrior ((obj warrior))
  (let ((v1-1 (-> obj draw shadow-ctrl)))
    (when v1-1
      (let ((f0-0 (-> obj root-override trans y)))
        (let ((a0-2 v1-1))
          (set! (-> a0-2 settings bot-plane w) (- (+ -4096.0 f0-0)))
          )
        0
        (set! (-> v1-1 settings top-plane w) (- (+ 3072.0 f0-0)))
        )
      0
      )
    )
  (none)
  )

;; definition for method 48 of type warrior
(defmethod draw-npc-shadow warrior ((obj warrior))
  (-> obj draw shadow-ctrl)
  (cond
    ((and (-> obj draw shadow)
          (zero? (-> obj draw cur-lod))
          (logtest? (-> obj draw status) (draw-status was-drawn))
          )
     (let ((v1-9 (-> obj draw shadow-ctrl)))
       (logclear! (-> v1-9 settings flags) (shadow-flags disable-draw))
       )
     0
     (update-direction-from-time-of-day (-> obj draw shadow-ctrl))
     )
    (else
      (let ((v1-14 (-> obj draw shadow-ctrl)))
        (logior! (-> v1-14 settings flags) (shadow-flags disable-draw))
        )
      0
      )
    )
  (none)
  )

;; definition for method 32 of type warrior
(defmethod play-anim! warrior ((obj warrior) (arg0 symbol))
  (with-pp
    (set! (-> obj talk-message) (game-text-id press-to-talk))
    (case (current-status (-> obj tasks))
      (((task-status need-hint) (task-status need-introduction))
       (if arg0
           (close-status! (-> obj tasks) (task-status need-introduction))
           )
       (new 'static 'spool-anim
         :name "warrior-introduction"
         :index 6
         :parts 29
         :command-list '((125 joint "cameraB")
           (260 joint "camera")
           (574 joint "cameraB")
           (918 joint "camera")
           (1174 joint "cameraB")
           (1174 shadow self #f)
           (1301 joint "camera")
           (1301 shadow self #t)
           (2025 joint "cameraB")
           (2322 joint "camera")
           (2560 joint "cameraB")
           )
         )
       )
      (((task-status need-reminder))
       (set! (-> obj skippable) #t)
       (new 'static 'spool-anim :name "warrior-reminder-1" :index 7 :parts 3 :command-list '())
       )
      (((task-status need-reward-speech))
       (cond
         (arg0
           (set! (-> obj cell-for-task) (current-task (-> obj tasks)))
           (close-current! (-> obj tasks))
           (send-event *target* 'get-pickup 5 (- (-> *GAME-bank* money-task-inc)))
           (send-event (-> (entity-by-type allpontoons) extra process) 'clone (process->handle obj))
           (dotimes (s5-2 (entity-actor-count (-> obj entity) 'alt-actor))
             (entity-birth-no-kill (entity-actor-lookup (-> obj entity) 'alt-actor s5-2))
             (let ((s4-2 (new 'stack-no-clear 'event-message-block)))
               (set! (-> s4-2 from) pp)
               (set! (-> s4-2 num-params) 0)
               (set! (-> s4-2 message) 'die)
               (let ((s3-0 send-event-function)
                     (v1-25 (entity-actor-lookup (-> obj entity) 'alt-actor s5-2))
                     )
                 (s3-0
                   (if v1-25
                       (-> v1-25 extra process)
                       )
                   s4-2
                   )
                 )
               )
             )
           )
         (else
           (set! (-> obj will-talk) #t)
           (set! (-> obj talk-message) (game-text-id press-to-trade-money))
           )
         )
       (new 'static 'spool-anim
         :name "warrior-resolution"
         :index 8
         :parts 6
         :command-list '((508 blackout 10) (511 blackout 0))
         )
       )
      (else
        (if arg0
            (format
              0
              "ERROR: <GMJ>: ~S playing anim for task status ~S~%"
              (-> obj name)
              (task-status->string (current-status (-> obj tasks)))
              )
            )
        (-> obj draw art-group data 5)
        )
      )
    )
  )

;; definition for method 31 of type warrior
(defmethod get-art-elem warrior ((obj warrior))
  (-> obj draw art-group data 5)
  )

;; failed to figure out what this is:
(defstate play-anim (warrior)
  :virtual #t
  :exit (behavior ()
    (send-event (-> (entity-by-type allpontoons) extra process) 'end-mode)
    ((-> (method-of-type process-taskable play-anim) exit))
    (none)
    )
  )

;; definition for method 43 of type warrior
(defmethod TODO-RENAME-43 warrior ((obj warrior))
  (when (TODO-RENAME-10 (-> obj ambient) (new 'stack-no-clear 'vector) (seconds 2) 61440.0 obj)
    (let ((f0-2 (rand-float-gen)))
      (cond
        ((< 0.66 f0-2)
         (play-ambient (-> obj ambient) "WAR-LO1A" #f (-> obj root-override trans))
         )
        ((< 0.33 f0-2)
         (play-ambient (-> obj ambient) "WAR-LO1B" #f (-> obj root-override trans))
         )
        (else
          (play-ambient (-> obj ambient) "WAR-LO1C" #f (-> obj root-override trans))
          )
        )
      )
    )
  )

;; definition for method 41 of type warrior
;; INFO: Return type mismatch int vs none.
(defmethod initialize-collision warrior ((obj warrior) (arg0 int) (arg1 vector))
  (let ((s5-0 (new 'process 'collide-shape obj (collide-list-enum hit-by-player))))
    (let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 2) 0)))
      (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 indestructible))
      (set-vector! (-> s4-0 local-sphere) -3072.0 8192.0 0.0 11264.0)
      (set-root-prim! s5-0 s4-0)
      (let ((s3-0 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
        (set! (-> s3-0 prim-core collide-as) (collide-kind enemy))
        (set! (-> s3-0 collide-with) (collide-kind target))
        (set! (-> s3-0 prim-core action) (collide-action solid))
        (set! (-> s3-0 prim-core offense) (collide-offense indestructible))
        (set-vector! (-> s3-0 local-sphere) -2048.0 9216.0 0.0 8192.0)
        (append-prim s4-0 s3-0)
        )
      (let ((s3-1 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
        (set! (-> s3-1 prim-core collide-as) (collide-kind enemy))
        (set! (-> s3-1 collide-with) (collide-kind target))
        (set! (-> s3-1 prim-core action) (collide-action solid))
        (set! (-> s3-1 prim-core offense) (collide-offense indestructible))
        (set-vector! (-> s3-1 local-sphere) 0.0 2048.0 0.0 4096.0)
        (append-prim s4-0 s3-1)
        )
      )
    (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w)))
    (backup-collide-with-as s5-0)
    (set! (-> obj root-override) s5-0)
    )
  0
  (none)
  )

;; definition for method 11 of type warrior
(defmethod init-from-entity! warrior ((obj warrior) (arg0 entity-actor))
  (dummy-40 obj arg0 *warrior-sg* 3 33 (new 'static 'vector :y -4096.0 :w 10240.0) 5)
  (set! (-> obj tasks) (get-task-control (game-task village2-warrior-money)))
  (set! (-> obj sound-flava) (music-flava warrior))
  (set! (-> obj draw light-index) (the-as uint 3))
  (dummy-42 obj)
  (none)
  )
