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

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

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

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

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

;; definition for method 32 of type assistant-firecanyon
(defmethod play-anim! assistant-firecanyon ((obj assistant-firecanyon) (arg0 symbol))
  (case (current-status (-> obj tasks))
    (((task-status need-reward-speech))
     (if arg0
         (close-current! (-> obj tasks))
         )
     (new 'static 'spool-anim
       :name "assistant-firecanyon-resolution"
       :index 13
       :parts 11
       :command-list '((0 want-levels village1 firecanyon)
         (151 joint "cameraB")
         (346 joint "camera")
         (346 shadow self #f)
         (461 joint "cameraB")
         (546 joint "camera")
         (636 joint "cameraB")
         (695 alive "balloon-12")
         (696 joint "camera")
         (821 alive "balloon-16")
         (822 joint "cameraB")
         (962 joint "camera")
         (1268 shadow self #t)
         )
       )
     )
    (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 3)
      )
    )
  )

;; definition for method 31 of type assistant-firecanyon
(defmethod get-art-elem assistant-firecanyon ((obj assistant-firecanyon))
  (if (= (current-status (-> obj tasks)) (task-status invalid))
      (-> obj draw art-group data 8)
      (-> obj draw art-group data 3)
      )
  )

;; failed to figure out what this is:
(defstate hidden (assistant-firecanyon)
  :virtual #t
  :trans (behavior ()
    ((-> (method-of-type process-taskable hidden) trans))
    (when (and (cond
                 ((and *target* (>= 61440.0 (vector-vector-distance (-> self root-override trans) (-> *target* control trans))))
                  #t
                  )
                 (else
                   (set! (-> self state-time) (-> *display* base-frame-counter))
                   #f
                   )
                 )
               (and (not (closed? (-> self tasks) (game-task firecanyon-assistant) (task-status need-reward-speech)))
                    (not (movie?))
                    (not (level-hint-displayed?))
                    (not (and *cheat-mode* (cpad-hold? 0 l3)))
                    (< (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 10))
                    )
               )
      (hide-hud)
      (kill-current-level-hint '() '(sidekick voicebox) 'exit)
      (when (and (seen-text? *game-info* (game-text-id firecanyon-need-cells))
                 (hud-hidden?)
                 (can-grab-display? self)
                 (not (-> *setting-control* current hint))
                 )
        (let ((gp-0
                (new 'stack 'font-context *font-default-matrix* 32 160 0.0 (font-color default) (font-flags shadow kerning))
                )
              )
          (let ((v1-26 gp-0))
            (set! (-> v1-26 width) (the float 448))
            )
          (let ((v1-27 gp-0))
            (set! (-> v1-27 height) (the float 80))
            )
          (let ((v1-28 gp-0))
            (set! (-> v1-28 scale) 0.8)
            )
          (set! (-> gp-0 flags) (font-flags shadow kerning middle large))
          (print-game-text (lookup-text! *common-text* (game-text-id firecanyon-need-cells-text) #f) gp-0 #f 128 22)
          )
        )
      (level-hint-spawn
        (game-text-id firecanyon-need-cells)
        "asstvb09"
        (the-as entity #f)
        *entity-pool*
        (game-task none)
        )
      )
    (none)
    )
  )

;; failed to figure out what this is:
(defstate idle (assistant-firecanyon)
  :virtual #t
  :code (behavior ()
    (if (!= (ja-group) (get-art-elem self))
        (ja-channel-push! 1 (seconds 0.05))
        )
    (loop
      (let ((gp-0 #t))
        (cond
          ((= (current-status (-> self tasks)) (task-status invalid))
           (when (< (rand-float-gen) 0.5)
             (ja :group! assistant-firecanyon-idle-a-ja)
             (let* ((f30-0 2.0)
                    (v1-16 (/ (the-as int (rand-uint31-gen *random-generator*)) 256))
                    (v1-17 (the-as number (logior #x3f800000 v1-16)))
                    )
               (countdown (gp-1 (+ (the int (* f30-0 (+ -1.0 (the-as float v1-17)))) 3))
                 (ja-no-eval :group! (ja-group) :num! (seek!) :frame-num 0.0)
                 (until (ja-done? 0)
                   (suspend)
                   (ja :num! (seek!))
                   )
                 )
               )
             (set! gp-0 #f)
             )
           (when (or gp-0 (< (rand-float-gen) 0.5))
             (ja-no-eval :group! assistant-firecanyon-idle-to-b-ja :num! (seek!) :frame-num 0.0)
             (until (ja-done? 0)
               (suspend)
               (ja :num! (seek!))
               )
             (ja :group! assistant-firecanyon-idle-b-ja)
             (let* ((f30-1 2.0)
                    (v1-83 (/ (the-as int (rand-uint31-gen *random-generator*)) 256))
                    (v1-84 (the-as number (logior #x3f800000 v1-83)))
                    )
               (countdown (gp-2 (+ (the int (* f30-1 (+ -1.0 (the-as float v1-84)))) 3))
                 (ja-no-eval :group! (ja-group) :num! (seek!) :frame-num 0.0)
                 (until (ja-done? 0)
                   (suspend)
                   (ja :num! (seek!))
                   )
                 )
               )
             (ja-no-eval :group! assistant-firecanyon-idle-to-a-ja :num! (seek!) :frame-num 0.0)
             (until (ja-done? 0)
               (suspend)
               (ja :num! (seek!))
               )
             )
           (when (< (rand-float-gen) 0.25)
             (ja :group! assistant-firecanyon-idle-wipe-brow-ja)
             (ja-no-eval :group! (ja-group) :num! (seek!) :frame-num 0.0)
             (until (ja-done? 0)
               (suspend)
               (ja :num! (seek!))
               )
             )
           )
          (else
            (when (< (rand-float-gen) 0.8)
              (ja :group! assistant-firecanyon-idle-twist-ja)
              (let* ((f30-2 4.0)
                     (v1-184 (/ (the-as int (rand-uint31-gen *random-generator*)) 256))
                     (v1-185 (the-as number (logior #x3f800000 v1-184)))
                     )
                (countdown (gp-3 (+ (the int (* f30-2 (+ -1.0 (the-as float v1-185)))) 8))
                  (ja-no-eval :group! (ja-group) :num! (seek!) :frame-num 0.0)
                  (until (ja-done? 0)
                    (suspend)
                    (ja :num! (seek!))
                    )
                  )
                )
              (set! gp-0 #f)
              )
            (when (or gp-0 (< (rand-float-gen) 0.5))
              (ja-no-eval :group! assistant-firecanyon-idle-down-ja :num! (seek!) :frame-num 0.0)
              (until (ja-done? 0)
                (suspend)
                (ja :num! (seek!))
                )
              (ja :group! assistant-firecanyon-idle-examine-ja)
              (let* ((f30-3 2.0)
                     (v1-251 (/ (the-as int (rand-uint31-gen *random-generator*)) 256))
                     (v1-252 (the-as number (logior #x3f800000 v1-251)))
                     )
                (countdown (gp-4 (+ (the int (* f30-3 (+ -1.0 (the-as float v1-252)))) 3))
                  (ja-no-eval :group! (ja-group) :num! (seek!) :frame-num 0.0)
                  (until (ja-done? 0)
                    (suspend)
                    (ja :num! (seek!))
                    )
                  )
                )
              (ja-no-eval :group! assistant-firecanyon-idle-up-ja :num! (seek!) :frame-num 0.0)
              (until (ja-done? 0)
                (suspend)
                (ja :num! (seek!))
                )
              )
            (when (< (rand-float-gen) 0.5)
              (ja :group! assistant-firecanyon-idle-fiddle-ja)
              (let* ((f30-4 2.0)
                     (v1-316 (/ (the-as int (rand-uint31-gen *random-generator*)) 256))
                     (v1-317 (the-as number (logior #x3f800000 v1-316)))
                     )
                (countdown (gp-5 (+ (the int (* f30-4 (+ -1.0 (the-as float v1-317)))) 3))
                  (ja-no-eval :group! (ja-group) :num! (seek!) :frame-num 0.0)
                  (until (ja-done? 0)
                    (suspend)
                    (ja :num! (seek!))
                    )
                  )
                )
              )
            )
          )
        )
      )
    (none)
    )
  )

;; definition for method 39 of type assistant-firecanyon
(defmethod should-display? assistant-firecanyon ((obj assistant-firecanyon))
  (first-any (-> obj tasks) #t)
  (= (current-status (-> obj tasks)) (task-status need-reward-speech))
  )

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