jak-project/goal_src/jak3/engine/common-obs/bouncer.gc
Hat Kid 949508d0ed
decomp3: traffic/citizen/faction code, desert-rescue (#3506)
- `cty-faction-h`
- `nav-graph`
- `citizen-h`
- `citizen`
- `civilian`
- `traffic-engine`
- `traffic-manager`
- `cty-attack-controller`
- `cty-faction`
- `formation-object`
- `formations`
- `squad-control-city-h`
- `squad-control-city`
- `traffic-util`
- `wlander-female`
- `wlander-h`
- `wlander-male`
- `speech-manager`
- `desert-rescue`
- `desresc-path`
- `neo-satellite`
- `rope-prim-system-h`
- `rope-prim-system`
- `rope-system`
- `wland-passenger`
- `cty-guard-projectile`
- `ctywide-init`
- `ff-squad-control`
- `guard-grenade`
- `guard-rifle`
- `guard-states`
- `guard-tazer`
- `ctywide-speech`
- `citizen-chick`
- `citizen-fat`
- `citizen-norm`
- `guard`
- `bike`
- `car`
- `test-bike`
- `vehicle-rider`
- `desert-rescue-bbush`
- `ff-squad-control-h`
- `flee-info`
- `guard-h`
- `mission-squad-control`
- `kg-squad-control`
- `kg-squad-member-h`
- `kg-squad-member`
- `mh-squad-control`
- `mh-squad-member-h`
- `mh-squad-member`
- `ctywide-obs-h`
- `ctywide-obs`
- `ctywide-part`
- `ctywide-scenes`
- `ctywide-tasks`
- `ctywide-texture`
- `billiards`
- `guide-arrow`
- `kg-vehicles`
- `flying-turret`
- `roboguard-city`
- `citizen-enemy`
- `metalhead-flitter`
- `metalhead-grunt`
- `metalhead-predator`
- `spydroid`
- `kg-squad-control-h`
- `mh-squad-control-h`
- `krimson-wall`
- `ctyport-obs`
- `ctyinda-obs`
- `ctyinda-part`
- `ctyindb-obs`
- `ctyindb-part`
- `ctyport-attack`
- `h-torpedo`
- `ctyport-part`
- `ctyport-scenes`
- `external-player-control`
- `desert-chase-path-h`
- `desert-chase-path`
- `desert-chase`
- `desert-jump`
- `wcar-catapult`
- `bombbot-h`
- `bombbot`
- `bombbot-path`
- `cty-hijack-missile`
- `cty-hijack`
- `ctyport-attack-bbush`
- `ctysluma-part`
- `ctyslumb-part`
- `ctyslumc-obs`
- `ctyslumc-part`
- `searchlight`
- `cty-destroy-grid`
- `ctyfarm-obs`
- `ctyfarma-part`
- `ctyfarmb-part`
- `freehq-part`
- `freehq-scenes`
- `onintent-scenes`
- `onintent-part`
- `cty-sniper-battery`
- `cty-sniper-turret`
- `intro-obs`
- `intro-part`
- `intro-scenes`
- `palcab-part`
- `palroof-part`
2024-05-09 19:18:55 -04:00

250 lines
7.3 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: bouncer.gc
;; name in dgo: bouncer
;; dgos: GAME
;; DECOMP BEGINS
(deftype bouncer (process-drawable)
((root collide-shape :override)
(spring-height meters)
(smush float)
(mods basic)
(use-alternate-jump? symbol)
)
(:state-methods
idle
fire
smush
)
(:methods
(init-skel! (_type_) none)
(init-collision! (_type_) none)
(play-sound (_type_) none)
(bouncer-method-26 (_type_) none)
)
)
(method-set! bouncer 12 (method-of-type process run-logic?))
(defstate idle (bouncer)
:virtual #t
:event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
(case message
(('bonk)
(when ((method-of-type touching-shapes-entry prims-touching?)
(the-as touching-shapes-entry (-> block param 0))
(-> self root)
(the-as uint 1)
)
(when (send-event proc 'jump (-> self spring-height) (-> self spring-height) (-> self mods))
(play-sound self)
(go-virtual fire)
)
)
)
(('touch)
(let ((gp-1 (-> block param 0)))
(cond
(((method-of-type touching-shapes-entry prims-touching-action?)
(the-as touching-shapes-entry gp-1)
(-> self root)
(collide-action solid)
(collide-action)
)
(when ((method-of-type touching-shapes-entry prims-touching?)
(the-as touching-shapes-entry gp-1)
(-> self root)
(the-as uint 1)
)
(if (not (and (-> self next-state) (let ((v1-22 (-> self next-state name)))
(or (= v1-22 'smush) (= v1-22 'fire))
)
)
)
(go-virtual smush)
)
)
)
(((method-of-type touching-shapes-entry prims-touching?)
(the-as touching-shapes-entry gp-1)
(-> self root)
(the-as uint 4)
)
(persist-with-delay
*setting-control*
(the-as symbol (process->ppointer self))
(seconds 0.05)
'double-jump
#f
0.0
0
)
)
)
)
)
(('attack)
(let ((v1-29 (the-as object (-> block param 1)))
(a0-16 (-> block param 0))
(a2-6 0)
)
(cond
((= (-> (the-as attack-info v1-29) mode) 'flop)
(set! a2-6 1)
)
((= (-> (the-as attack-info v1-29) mode) 'board)
(set! a2-6 9)
)
)
(when (and (nonzero? a2-6)
(and ((method-of-type touching-shapes-entry prims-touching?)
(the-as touching-shapes-entry a0-16)
(-> self root)
(the-as uint a2-6)
)
(send-event proc 'jump (-> self spring-height) (-> self spring-height) (-> self mods))
)
)
(play-sound self)
(go-virtual fire)
#f
)
)
)
)
)
:code (behavior ()
(if (nonzero? (-> self draw))
(ja :group! (get-art-by-name (-> self draw art-group) "idle" art-joint-anim) :num! min)
)
(transform-post)
(until #f
(logior! (-> self mask) (process-mask sleep))
(suspend)
)
#f
)
)
(defstate smush (bouncer)
:virtual #t
:event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
(case message
(('touch)
(set-time! (-> self state-time))
#f
)
(else
((-> (method-of-object self idle) event) proc argc message block)
)
)
)
:code (behavior ()
(set-time! (-> self state-time))
(set! (-> self smush) 0.0)
(until #f
(if (and (nonzero? (-> self draw)) (time-elapsed? (-> self state-time) (seconds 0.2)))
(ja :num! (seek! 0.0 0.1))
(ja :num! (seek!
(lerp-scale
(ja-aframe 6.0 0)
(ja-aframe 2.0 0)
(vector-vector-xz-distance (target-pos 0) (-> self root trans))
0.0
4096.0
)
0.2
)
)
)
(suspend)
(let ((v1-17 (and (nonzero? (-> self draw)) (ja-min? 0))))
(if v1-17
(go-virtual idle)
(go-virtual idle)
)
)
)
#f
)
:post transform-post
)
(defstate fire (bouncer)
:virtual #t
:code (behavior ()
(when (or (-> self use-alternate-jump?) (-> *setting-control* user-current use-alternate-bouncer?))
(persist-with-delay *setting-control* 'slave-options (seconds 2.5) 'slave-options 'clear 0.0 16)
(persist-with-delay *setting-control* 'slave-options2 (seconds 2.5) 'slave-options 'set 0.0 #x2000000)
)
(cpad-set-buzz! (-> *cpad-list* cpads 0) 1 178 (seconds 0.1))
(bouncer-method-26 self)
(when (nonzero? (-> self draw))
(ja-no-eval :group! (get-art-by-name (-> self draw art-group) "idle" art-joint-anim)
:num! (seek!)
:frame-num (ja-aframe 6.0 0)
)
(until (ja-done? 0)
(suspend)
(ja :num! (seek!))
)
)
(go-virtual idle)
)
:post transform-post
)
(defmethod play-sound ((this bouncer))
(sound-play "trampoline")
0
(none)
)
(defmethod bouncer-method-26 ((this bouncer))
0
(none)
)
(defmethod init-skel! ((this bouncer))
(break!)
0
(none)
)
(defmethod init-collision! ((this bouncer))
(let ((s5-0 (new 'process 'collide-shape this (collide-list-enum hit-by-player))))
(let ((v1-2 (new 'process 'collide-shape-prim-mesh s5-0 (the-as uint 0) (the-as uint 0))))
(set! (-> v1-2 prim-core collide-as) (collide-spec crate))
(set! (-> v1-2 prim-core collide-with) (collide-spec jak player-list))
(set! (-> v1-2 prim-core action) (collide-action solid))
(set! (-> v1-2 transform-index) 0)
(set-vector! (-> v1-2 local-sphere) 0.0 3072.0 0.0 6963.2)
(set! (-> s5-0 total-prims) (the-as uint 1))
(set! (-> s5-0 root-prim) v1-2)
)
(set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w)))
(let ((v1-5 (-> s5-0 root-prim)))
(set! (-> s5-0 backup-collide-as) (-> v1-5 prim-core collide-as))
(set! (-> s5-0 backup-collide-with) (-> v1-5 prim-core collide-with))
)
(set! (-> this root) s5-0)
)
0
(none)
)
(defmethod init-from-entity! ((this bouncer) (arg0 entity-actor))
(set! (-> this mods) #f)
(init-collision! this)
(process-drawable-from-entity! this arg0)
(init-skel! this)
(nav-mesh-connect-from-ent this)
(set! (-> this spring-height) (res-lump-float arg0 'spring-height :default 45056.0))
(set! (-> this use-alternate-jump?) (= (res-lump-value arg0 'behavior-type uint128 :time -1000000000.0) 1))
(go (method-of-object this idle))
)