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

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

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

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

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

;; definition for method 32 of type gambler
(defmethod play-anim! gambler ((obj gambler) (arg0 symbol))
  (set! (-> obj talk-message) (game-text-id press-to-talk))
  (case (current-status (-> obj tasks))
    (((task-status need-hint) (task-status need-introduction))
     (when arg0
       (close-status! (-> obj tasks) (task-status need-introduction))
       (close-specific-task! (game-task village2-gambler-money) (task-status need-introduction))
       )
     (new 'static 'spool-anim
       :name "gambler-introduction-1"
       :index 11
       :parts 9
       :command-list '((0 want-levels village2 rolling)
         (0 display-level rolling #f)
         (29 joint "cameraB")
         (103 joint "camera")
         (231 joint "cameraB")
         (730 display-level rolling display)
         (730 want-force-vis rolling #t)
         (732 alive "gorge-pusher-5")
         (732 alive "gorge-pusher-6")
         (732 alive "gorge-start-1")
         (732 joint "camera")
         (945 joint "cameraB")
         (950 dead "gorge-pusher-5")
         (950 dead "gorge-pusher-6")
         (950 dead "gorge-start-1")
         (950 display-level rolling #f)
         (950 want-force-vis rolling #f)
         )
       )
     )
    (((task-status need-reminder))
     (set! (-> obj skippable) #t)
     (cond
       ((closed? (-> obj tasks) (game-task rolling-race) (task-status need-reward-speech))
        (new 'static 'spool-anim :name "gambler-reminder-money" :index 13 :parts 2 :command-list '())
        )
       ((closed? (-> obj tasks) (game-task village2-gambler-money) (task-status need-reward-speech))
        (new 'static 'spool-anim :name "gambler-reminder-race" :index 12 :parts 2 :command-list '())
        )
       ((zero? (get-reminder (-> obj tasks) 5))
        (if arg0
            (save-reminder (-> obj tasks) 1 5)
            )
        (new 'static 'spool-anim :name "gambler-reminder-race" :index 12 :parts 2 :command-list '())
        )
       (else
         (if arg0
             (save-reminder (-> obj tasks) 0 5)
             )
         (new 'static 'spool-anim :name "gambler-reminder-money" :index 13 :parts 2 :command-list '())
         )
       )
     )
    (((task-status need-reward-speech))
     (if (not arg0)
         (set! (-> obj will-talk) #t)
         )
     (case (current-task (-> obj tasks))
       (((game-task rolling-race))
        (when arg0
          (set! (-> obj cell-for-task) (current-task (-> obj tasks)))
          (close-current! (-> obj tasks))
          )
        (new 'static 'spool-anim :name "gambler-resolution-race" :index 14 :parts 3 :command-list '())
        )
       (else
         (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)))
             )
           (else
             (set! (-> obj talk-message) (game-text-id press-to-trade-money))
             )
           )
         (new 'static 'spool-anim :name "gambler-resolution-money" :index 15 :parts 2 :command-list '())
         )
       )
     )
    (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 7)
      )
    )
  )

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

;; definition for method 43 of type gambler
(defmethod TODO-RENAME-43 gambler ((obj gambler))
  (when (TODO-RENAME-10 (-> obj ambient) (new 'stack-no-clear 'vector) (seconds 30) 61440.0 obj)
    (let ((f0-2 (rand-float-gen)))
      (cond
        ((< 0.9230769 f0-2)
         (play-ambient (-> obj ambient) "GAM-AM01" #f (-> obj root-override trans))
         )
        ((< 0.84615386 f0-2)
         (play-ambient (-> obj ambient) "GAM-AM02" #f (-> obj root-override trans))
         )
        ((< 0.7692308 f0-2)
         (play-ambient (-> obj ambient) "GAM-AM03" #f (-> obj root-override trans))
         )
        ((< 0.6923077 f0-2)
         (play-ambient (-> obj ambient) "GAM-AM04" #f (-> obj root-override trans))
         )
        ((< 0.61538464 f0-2)
         (play-ambient (-> obj ambient) "GAM-AM05" #f (-> obj root-override trans))
         )
        ((< 0.53846157 f0-2)
         (play-ambient (-> obj ambient) "GAM-AM06" #f (-> obj root-override trans))
         )
        ((< 0.46153846 f0-2)
         (play-ambient (-> obj ambient) "GAM-AM07" #f (-> obj root-override trans))
         )
        ((< 0.3846154 f0-2)
         (play-ambient (-> obj ambient) "GAM-AM08" #f (-> obj root-override trans))
         )
        ((< 0.30769232 f0-2)
         (play-ambient (-> obj ambient) "GAM-AM09" #f (-> obj root-override trans))
         )
        ((< 0.23076923 f0-2)
         (if (not (task-closed? (game-task ogre-boss) (task-status need-reminder)))
             (play-ambient (-> obj ambient) "GAM-AM10" #f (-> obj root-override trans))
             )
         )
        ((< 0.15384616 f0-2)
         (play-ambient (-> obj ambient) "GAM-AM11" #f (-> obj root-override trans))
         )
        ((< 0.07692308 f0-2)
         (play-ambient (-> obj ambient) "GAM-AM12" #f (-> obj root-override trans))
         )
        (else
          (play-ambient (-> obj ambient) "GAM-AM13" #f (-> obj root-override trans))
          )
        )
      )
    )
  )

;; failed to figure out what this is:
(defstate idle (gambler)
  :virtual #t
  :code (behavior ()
    (when (!= (ja-group) gambler-idle-fidget-ja)
      (ja-channel-push! 1 (seconds 0.2))
      (ja :group! gambler-idle-fidget-ja)
      )
    (loop
      (ja-no-eval :group! (ja-group) :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      (TODO-RENAME-43 self)
      (let ((f0-9 (rand-float-gen)))
        (cond
          ((< f0-9 0.16666667)
           (ja :group! gambler-idle-tiptoe-ja)
           )
          ((< f0-9 0.33333334)
           (ja :group! gambler-idle-look-1-ja)
           )
          ((< f0-9 0.5)
           (ja :group! gambler-idle-fidget-ja)
           )
          ((< f0-9 0.6666667)
           (ja :group! gambler-idle-scratch-1-ja)
           )
          ((< f0-9 0.8333333)
           (ja :group! gambler-idle-look-2-ja)
           )
          (else
            (ja :group! gambler-idle-scratch-2-ja)
            )
          )
        )
      )
    (none)
    )
  )

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