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

(import "goal_src/jak1/import/assistant-village3-ag.gc")

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

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

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

;; definition for method 52 of type assistant-villagec
;; INFO: Return type mismatch int vs none.
(defmethod dummy-52 assistant-villagec ((obj assistant-villagec))
  (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) (- (+ -2048.0 f0-0)))
          )
        0
        (set! (-> v1-1 settings top-plane w) (- (+ 1024.0 f0-0)))
        )
      0
      )
    )
  (none)
  )

;; definition for method 48 of type assistant-villagec
(defmethod draw-npc-shadow assistant-villagec ((obj assistant-villagec))
  (-> 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 assistant-villagec
(defmethod play-anim! assistant-villagec ((obj assistant-villagec) (arg0 symbol))
  (set! (-> obj talk-message) (game-text-id press-to-talk-to-assistant))
  (cond
    ((= (get-task-status (game-task finalboss-movies)) (task-status need-introduction))
     (if arg0
         (format
           0
           "ERROR: <GMJ>: ~S playing anim for task status ~S~%"
           (-> obj name)
           (task-status->string (current-status (-> obj tasks)))
           )
         )
     (get-art-elem obj)
     )
    (else
      (new 'static 'spool-anim :name "assistant-village3-reminder" :index 4 :parts 3 :command-list '())
      )
    )
  )

;; definition for method 31 of type assistant-villagec
(defmethod get-art-elem assistant-villagec ((obj assistant-villagec))
  (-> obj draw art-group data 3)
  )

;; definition for method 39 of type assistant-villagec
(defmethod should-display? assistant-villagec ((obj assistant-villagec))
  (and (task-closed? (game-task village3-button) (task-status need-introduction)) (not (sages-kidnapped?)))
  )

;; definition for method 47 of type assistant-villagec
;; INFO: Return type mismatch basic vs symbol.
(defmethod target-above-threshold? assistant-villagec ((obj assistant-villagec))
  (the-as symbol (and *target* (< (-> (target-pos 0) z) -14245888.0)))
  )

;; definition for method 43 of type assistant-villagec
(defmethod TODO-RENAME-43 assistant-villagec ((obj assistant-villagec))
  (when (TODO-RENAME-10 (-> obj ambient) (new 'stack-no-clear 'vector) (seconds 30) 122880.0 obj)
    (let ((f0-2 (rand-float-gen)))
      (cond
        ((< 0.85714287 f0-2)
         (play-ambient (-> obj ambient) "ASSTLP31" #f (-> obj root-override trans))
         )
        ((< 0.71428573 f0-2)
         (play-ambient (-> obj ambient) "ASSTLP32" #f (-> obj root-override trans))
         )
        ((< 0.5714286 f0-2)
         (play-ambient (-> obj ambient) "ASSTLP33" #f (-> obj root-override trans))
         )
        ((< 0.42857143 f0-2)
         (let ((v1-16 (get-task-status (game-task lavatube-end))))
           (if (not (or (= v1-16 (task-status need-reward-speech)) (= v1-16 (task-status invalid))))
               (play-ambient (-> obj ambient) "ASSTLP34" #f (-> obj root-override trans))
               )
           )
         )
        ((< 0.2857143 f0-2)
         (let ((v1-21 (get-task-status (game-task lavatube-end))))
           (if (not (or (= v1-21 (task-status need-reward-speech)) (= v1-21 (task-status invalid))))
               (play-ambient (-> obj ambient) "ASSTLP35" #f (-> obj root-override trans))
               )
           )
         )
        ((< 0.14285715 f0-2)
         (let ((v1-26 (get-task-status (game-task lavatube-end))))
           (if (not (or (= v1-26 (task-status need-reward-speech)) (= v1-26 (task-status invalid))))
               (play-ambient (-> obj ambient) "ASSTLP36" #f (-> obj root-override trans))
               )
           )
         )
        ((nonzero? (get-task-status (game-task citadel-sage-green)))
         (play-ambient (-> obj ambient) "ASSTLP37" #f (-> obj root-override trans))
         )
        )
      )
    )
  )

;; failed to figure out what this is:
(defstate idle (assistant-villagec)
  :virtual #t
  :code (behavior ()
    (if (!= (ja-group) (get-art-elem self))
        (ja-channel-push! 1 (seconds 0.05))
        )
    (loop
      (TODO-RENAME-43 self)
      (ja-no-eval :group! assistant-village3-idle-ja :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      (let ((gp-0 (-> *display* base-frame-counter)))
        (while (let ((s5-0 (-> *display* base-frame-counter))
                     (f30-0 300.0)
                     (f28-0 0.16)
                     (f26-0 0.17000002)
                     )
                 (< (- s5-0 (the-as time-frame (the int (* f30-0 (+ f28-0 (* f26-0 (rand-float-gen))))))) gp-0)
                 )
          (suspend)
          )
        )
      (ja-no-eval :group! (ja-group) :num! (seek! (ja-aframe 0.0 0)) :frame-num (ja-aframe 16.0 0))
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek! (ja-aframe 0.0 0)))
        )
      (let ((gp-3 (-> *display* base-frame-counter)))
        (while (let ((s5-1 (-> *display* base-frame-counter))
                     (f30-1 300.0)
                     (f28-1 0.16)
                     (f26-1 0.17000002)
                     )
                 (< (- s5-1 (the-as time-frame (the int (* f30-1 (+ f28-1 (* f26-1 (rand-float-gen))))))) gp-3)
                 )
          (suspend)
          )
        )
      )
    (none)
    )
  )

;; definition for method 11 of type assistant-villagec
(defmethod init-from-entity! assistant-villagec ((obj assistant-villagec) (arg0 entity-actor))
  (dummy-40 obj arg0 *assistant-village3-sg* 3 31 (new 'static 'vector :w 4096.0) 5)
  (set! (-> obj tasks) (get-task-control (game-task assistant-village3)))
  (dummy-42 obj)
  (none)
  )
