jak-project/goal_src/jak1/engine/target/target-util.gc
ManDude cd68cb671e
deftype and defmethod syntax major changes (#3094)
Major change to how `deftype` shows up in our code:
- the decompiler will no longer emit the `offset-assert`,
`method-count-assert`, `size-assert` and `flag-assert` parameters. There
are extremely few cases where having this in the decompiled code is
helpful, as the types there come from `all-types` which already has
those parameters. This also doesn't break type consistency because:
  - the asserts aren't compared.
- the first step of the test uses `all-types`, which has the asserts,
which will throw an error if they're bad.
- the decompiler won't emit the `heap-base` parameter unless necessary
now.
- the decompiler will try its hardest to turn a fixed-offset field into
an `overlay-at` field. It falls back to the old offset if all else
fails.
- `overlay-at` now supports field "dereferencing" to specify the offset
that's within a field that's a structure, e.g.:
```lisp
(deftype foobar (structure)
  ((vec    vector  :inline)
   (flags  int32   :overlay-at (-> vec w))
   )
  )
```
in this structure, the offset of `flags` will be 12 because that is the
final offset of `vec`'s `w` field within this structure.
- **removed ID from all method declarations.** IDs are only ever
automatically assigned now. Fixes #3068.
- added an `:overlay` parameter to method declarations, in order to
declare a new method that goes on top of a previously-defined method.
Syntax is `:overlay <method-name>`. Please do not ever use this.
- added `state-methods` list parameter. This lets you quickly specify a
list of states to be put in the method table. Same syntax as the
`states` list parameter. The decompiler will try to put as many states
in this as it can without messing with the method ID order.

Also changes `defmethod` to make the first type definition (before the
arguments) optional. The type can now be inferred from the first
argument. Fixes #3093.

---------

Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com>
2023-10-30 03:20:02 +00:00

1191 lines
46 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: target-util.gc
;; name in dgo: target-util
;; dgos: GAME, ENGINE
(define-extern target-collide-set! (function symbol float int :behavior target))
;; DECOMP BEGINS
(defskelgroup *jchar-sg* eichar eichar-lod0-jg -1
((eichar-lod0-mg (meters 999999)))
:bounds (static-spherem 0 2 0 3)
:longest-edge (meters 1)
:shadow eichar-shadow-mg
:texture-level 2
:sort 1
)
(define *target-shadow-control*
(new 'static 'shadow-control :settings (new 'static 'shadow-settings
:flags (shadow-flags disable-fade)
:shadow-dir (new 'static 'vector :x -0.4226 :y -0.9063 :w 409600.0)
:bot-plane (new 'static 'plane :y 1.0 :w 37683.2)
:top-plane (new 'static 'plane :y 1.0 :w 4096.0)
)
)
)
(deftype target-bank (basic)
((jump-collide-offset meters)
(jump-height-min meters)
(jump-height-max meters)
(double-jump-height-min meters)
(double-jump-height-max meters)
(flip-jump-height-min meters)
(flip-jump-height-max meters)
(duck-jump-height-min meters)
(duck-jump-height-max meters)
(flop-jump-height-min meters)
(flop-jump-height-max meters)
(attack-jump-height-min meters)
(attack-jump-height-max meters)
(edge-grab-jump-height-min meters)
(edge-grab-jump-height-max meters)
(swim-jump-height-min meters)
(swim-jump-height-max meters)
(tube-jump-height-min meters)
(tube-jump-height-max meters)
(wheel-duration time-frame)
(wheel-jump-pre-window time-frame)
(wheel-jump-post-window time-frame)
(wheel-timeout time-frame)
(wheel-speed-min meters)
(wheel-speed-inc meters)
(wheel-flip-duration time-frame)
(wheel-flip-height meters)
(wheel-flip-dist meters)
(wheel-flip-art-height meters)
(wheel-flip-art-dist meters)
(duck-slide-distance meters)
(fall-far meters)
(fall-far-inc meters)
(attack-timeout time-frame)
(ground-timeout time-frame)
(slide-down-timeout time-frame)
(fall-timeout time-frame)
(fall-stumble-threshold meters)
(yellow-projectile-speed meters)
(hit-invulnerable-timeout time-frame)
(run-cycle-length float)
(walk-cycle-dist meters)
(walk-up-cycle-dist meters)
(walk-down-cycle-dist meters)
(walk-side-cycle-dist meters)
(run-cycle-dist meters)
(run-up-cycle-dist meters)
(run-down-cycle-dist meters)
(run-side-cycle-dist meters)
(run-wall-cycle-dist meters)
(duck-walk-cycle-dist meters)
(wade-shallow-walk-cycle-dist meters)
(wade-deep-walk-cycle-dist meters)
(smack-surface-dist meters)
(smack-surface-height meters)
(min-dive-depth meters)
(root-radius meters)
(root-offset vector :inline)
(body-radius meters)
(edge-radius meters)
(edge-offset vector :inline)
(head-radius meters)
(head-height meters)
(head-offset vector :inline)
(spin-radius meters)
(spin-offset vector :inline)
(duck-spin-radius meters)
(duck-spin-offset vector :inline)
(punch-radius meters)
(punch-offset vector :inline)
(uppercut-radius meters)
(uppercut0-offset vector :inline)
(uppercut1-offset vector :inline)
(flop-radius meters)
(flop0-offset vector :inline)
(flop1-offset vector :inline)
(stuck-time seconds)
(stuck-timeout seconds)
(stuck-distance meters)
(tongue-pull-speed-min float)
(tongue-pull-speed-max float)
(yellow-attack-timeout time-frame)
)
)
(define *TARGET-bank* (new 'static 'target-bank
:jump-collide-offset (meters 0.7)
:jump-height-min (meters 1.01)
:jump-height-max (meters 3.5)
:double-jump-height-min (meters 1)
:double-jump-height-max (meters 2.5)
:flip-jump-height-min (meters 5)
:flip-jump-height-max (meters 7)
:duck-jump-height-min (meters 5)
:duck-jump-height-max (meters 7)
:flop-jump-height-min (meters 5)
:flop-jump-height-max (meters 7)
:attack-jump-height-min (meters 4)
:attack-jump-height-max (meters 5.5)
:edge-grab-jump-height-min (meters 1.7)
:edge-grab-jump-height-max (meters 1.7)
:swim-jump-height-min (meters 5)
:swim-jump-height-max (meters 5)
:tube-jump-height-min (meters 1.75)
:tube-jump-height-max (meters 2.5)
:wheel-duration (seconds 0.5)
:wheel-jump-pre-window (seconds 1)
:wheel-jump-post-window (seconds 0.1)
:wheel-speed-min (meters 11.5)
:wheel-speed-inc (meters 1.5)
:wheel-flip-duration (seconds 0.7)
:wheel-flip-height (meters 3.52)
:wheel-flip-dist (meters 17.3)
:wheel-flip-art-height (meters 3.2969)
:wheel-flip-art-dist (meters 12.5)
:duck-slide-distance (meters 5.75)
:fall-far (meters 30)
:fall-far-inc (meters 20)
:attack-timeout (seconds 0.3)
:ground-timeout (seconds 0.2)
:slide-down-timeout (seconds 0.2)
:fall-timeout (seconds 1)
:fall-stumble-threshold (meters 39.9)
:yellow-projectile-speed (meters 60)
:hit-invulnerable-timeout (seconds 3)
:run-cycle-length 60.0
:walk-cycle-dist (meters 2.8)
:walk-up-cycle-dist (meters 2.8)
:walk-down-cycle-dist (meters 2.8)
:walk-side-cycle-dist (meters 2.8)
:run-cycle-dist (meters 6.25)
:run-up-cycle-dist (meters 5)
:run-down-cycle-dist (meters 5)
:run-side-cycle-dist (meters 6.25)
:run-wall-cycle-dist (meters 2.8)
:duck-walk-cycle-dist (meters 3.25)
:wade-shallow-walk-cycle-dist (meters 6)
:wade-deep-walk-cycle-dist (meters 6)
:smack-surface-dist (meters 1.25)
:min-dive-depth (meters 2)
:root-radius (meters 2.2)
:root-offset (new 'static 'vector :y 4915.2 :w 1.0)
:body-radius (meters 0.7)
:edge-radius (meters 0.35)
:edge-offset (new 'static 'vector :y 4915.2 :z 4096.0 :w 1.0)
:head-radius (meters 0.7)
:head-height (meters 1.4)
:head-offset (new 'static 'vector :y 4915.2 :w 1.0)
:spin-radius (meters 2.2)
:spin-offset (new 'static 'vector :y 6553.6 :w 1.0)
:duck-spin-radius (meters 1.2)
:duck-spin-offset (new 'static 'vector :y 4096.0 :w 1.0)
:punch-radius (meters 1.3)
:punch-offset (new 'static 'vector :y 5324.8 :w 1.0)
:uppercut-radius (meters 1)
:uppercut0-offset (new 'static 'vector :y 3276.8 :w 1.0)
:uppercut1-offset (new 'static 'vector :y 9011.2 :w 1.0)
:flop-radius (meters 1.4)
:flop0-offset (new 'static 'vector :y 3276.8 :w 1.0)
:flop1-offset (new 'static 'vector :y 9011.2 :w 1.0)
:stuck-time (seconds 0.3)
:stuck-timeout (seconds 2)
:stuck-distance (meters 0.05)
:tongue-pull-speed-min 0.15
:tongue-pull-speed-max 0.22
:yellow-attack-timeout (seconds 0.2)
)
)
(defbehavior target-start-attack target ()
(+! (-> self control unknown-dword50) 1)
(set! (-> self control unknown-dword51) 0)
0
(none)
)
(defbehavior target-danger-set! target ((arg0 symbol) (arg1 symbol))
(let ((s4-0 (-> self control unknown-sphere00))
(s5-0 (-> self control unknown-sphere01))
(gp-0 (-> self control unknown-sphere02))
(f30-0 (if arg1
2.0
1.0
)
)
)
(dotimes (v1-4 3)
(set! (-> self control unknown-sphere-array00 v1-4 prim-core offense) (collide-offense normal-attack))
)
(sphere<-vector+r!
(the-as sphere (-> self control root-prim local-sphere))
(-> *TARGET-bank* root-offset)
(-> *TARGET-bank* root-radius)
)
(set! (-> self control unknown-symbol30) arg0)
(logclear! (-> self state-flags) (state-flags dangerous))
(set! (-> s4-0 transform-index) -2)
(set! (-> s4-0 prim-core collide-as) (collide-kind))
(set! (-> s4-0 collide-with) (collide-kind))
(set! (-> s4-0 local-sphere w) 0.0)
(set! (-> s4-0 prim-core offense) (collide-offense no-offense))
(set! (-> s5-0 transform-index) -2)
(set! (-> s5-0 prim-core collide-as) (collide-kind))
(set! (-> s5-0 collide-with) (collide-kind))
(set! (-> s5-0 local-sphere w) 0.0)
(set! (-> s5-0 prim-core offense) (collide-offense no-offense))
(set! (-> gp-0 transform-index) -2)
(set! (-> gp-0 prim-core collide-as) (collide-kind))
(set! (-> gp-0 collide-with) (collide-kind))
(set! (-> gp-0 local-sphere w) 0.0)
(set! (-> gp-0 prim-core offense) (collide-offense no-offense))
(case arg0
(('harmless #f)
(set! (-> self control unknown-symbol30) #f)
(target-collide-set! (-> self control unknown-symbol00) (-> self control unknown-float90))
)
(('spin 'spin-air)
(sphere<-vector+r!
(the-as sphere (-> self control root-prim local-sphere))
(new 'static 'vector :y 6553.6 :w 1.0)
9830.4
)
(logior! (-> self state-flags) (state-flags dangerous))
(set! (-> s4-0 prim-core collide-as) (collide-kind target target-attack))
(set! (-> s4-0 collide-with)
(collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
)
(sphere<-vector+r!
(the-as sphere (-> s4-0 local-sphere))
(-> *TARGET-bank* spin-offset)
(-> *TARGET-bank* spin-radius)
)
)
(('duck-spin)
(sphere<-vector+r!
(the-as sphere (-> self control root-prim local-sphere))
(new 'static 'vector :y 6553.6 :w 1.0)
10649.6
)
(logior! (-> self state-flags) (state-flags dangerous))
(set! (-> s4-0 prim-core collide-as) (collide-kind target target-attack))
(set! (-> s4-0 collide-with)
(collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
)
(sphere<-vector+r!
(the-as sphere (-> s4-0 local-sphere))
(-> *TARGET-bank* duck-spin-offset)
(-> *TARGET-bank* duck-spin-radius)
)
(set! (-> s5-0 prim-core collide-as) (collide-kind target target-attack))
(set! (-> s5-0 collide-with)
(collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
)
(sphere<-vector+r! (the-as sphere (-> s5-0 local-sphere)) *null-vector* (-> *TARGET-bank* duck-spin-radius))
(set! (-> s5-0 transform-index) 32)
)
(('duck-slide)
(logior! (-> self state-flags) (state-flags dangerous))
(set! (-> s4-0 prim-core collide-as) (collide-kind target target-attack))
(set! (-> s4-0 collide-with)
(collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
)
(sphere<-vector+r!
(the-as sphere (-> s4-0 local-sphere))
(-> *TARGET-bank* duck-spin-offset)
(-> *TARGET-bank* duck-spin-radius)
)
(set! (-> s5-0 prim-core collide-as) (collide-kind target target-attack))
(set! (-> s5-0 collide-with)
(collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
)
(sphere<-vector+r! (the-as sphere (-> s5-0 local-sphere)) *null-vector* (-> *TARGET-bank* duck-spin-radius))
(set! (-> s5-0 transform-index) 28)
)
(('wheel-solid)
(logior! (-> self state-flags) (state-flags dangerous))
(set! (-> s4-0 prim-core collide-as) (collide-kind target target-attack))
(set! (-> s4-0 collide-with)
(collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
)
(dotimes (v1-57 3)
(set! (-> self control unknown-sphere-array00 v1-57 prim-core offense) (collide-offense touch))
)
(sphere<-vector+r!
(the-as sphere (-> s4-0 local-sphere))
(-> *TARGET-bank* duck-spin-offset)
(+ 819.2 (-> *TARGET-bank* duck-spin-radius))
)
(set! (-> s5-0 prim-core collide-as) (collide-kind target target-attack))
(set! (-> s5-0 collide-with)
(collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
)
(sphere<-vector+r! (the-as sphere (-> s5-0 local-sphere)) *null-vector* (-> *TARGET-bank* duck-spin-radius))
(set! (-> s5-0 transform-index) 7)
(set! (-> self control unknown-symbol30) 'roll)
)
(('flip)
(logior! (-> self state-flags) (state-flags dangerous))
(set! (-> s4-0 prim-core collide-as) (collide-kind target target-attack))
(set! (-> s4-0 collide-with)
(collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
)
(dotimes (v1-71 3)
(set! (-> self control unknown-sphere-array00 v1-71 prim-core offense) (collide-offense touch))
)
(sphere<-vector+r!
(the-as sphere (-> s4-0 local-sphere))
(-> *TARGET-bank* duck-spin-offset)
(+ 819.2 (-> *TARGET-bank* duck-spin-radius))
)
(set! (-> s5-0 prim-core collide-as) (collide-kind target target-attack))
(set! (-> s5-0 collide-with)
(collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
)
(sphere<-vector+r! (the-as sphere (-> s5-0 local-sphere)) *null-vector* (-> *TARGET-bank* duck-spin-radius))
(set! (-> s5-0 transform-index) 7)
(set! (-> self control unknown-symbol30) 'flip)
)
(('punch)
(sphere<-vector+r!
(the-as sphere (-> self control root-prim local-sphere))
(new 'static 'vector :y 6553.6 :w 1.0)
11878.4
)
(logior! (-> self state-flags) (state-flags dangerous))
(set! (-> s4-0 prim-core collide-as) (collide-kind target target-attack))
(set! (-> s4-0 collide-with)
(collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
)
(sphere<-vector+r!
(the-as sphere (-> s4-0 local-sphere))
(-> *TARGET-bank* punch-offset)
(-> *TARGET-bank* punch-radius)
)
(set! (-> s5-0 prim-core collide-as) (collide-kind target target-attack))
(set! (-> s5-0 collide-with)
(collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
)
(sphere<-vector+r! (the-as sphere (-> s5-0 local-sphere)) *null-vector* (-> *TARGET-bank* punch-radius))
(set! (-> s5-0 transform-index) 22)
)
(('uppercut)
(sphere<-vector+r!
(the-as sphere (-> self control root-prim local-sphere))
(new 'static 'vector :y 6553.6 :w 1.0)
11878.4
)
(logior! (-> self state-flags) (state-flags dangerous))
(set! (-> s4-0 prim-core collide-as) (collide-kind target target-attack))
(set! (-> s4-0 collide-with)
(collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
)
(sphere<-vector+r!
(the-as sphere (-> s4-0 local-sphere))
(-> *TARGET-bank* uppercut0-offset)
(-> *TARGET-bank* uppercut-radius)
)
(set! (-> s5-0 prim-core collide-as) (collide-kind target target-attack))
(set! (-> s5-0 collide-with)
(collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
)
(sphere<-vector+r! (the-as sphere (-> s5-0 local-sphere)) *null-vector* (-> *TARGET-bank* uppercut-radius))
(set! (-> s5-0 transform-index) 22)
(set! (-> gp-0 prim-core collide-as) (collide-kind target target-attack))
(set! (-> gp-0 collide-with)
(collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
)
(sphere<-vector+r!
(the-as sphere (-> gp-0 local-sphere))
(-> *TARGET-bank* uppercut1-offset)
(-> *TARGET-bank* uppercut-radius)
)
)
(('flop)
(logior! (-> self state-flags) (state-flags dangerous))
(set! (-> s4-0 prim-core collide-as) (collide-kind target target-attack))
(set! (-> s4-0 collide-with)
(collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
)
(dotimes (v1-114 3)
(set! (-> self control unknown-sphere-array00 v1-114 prim-core offense) (collide-offense strong-attack))
)
(sphere<-vector+r!
(the-as sphere (-> s4-0 local-sphere))
(-> *TARGET-bank* flop0-offset)
(-> *TARGET-bank* flop-radius)
)
(set! f30-0 1.0)
(set! (-> self control unknown-symbol30) 'flop)
)
(('flop-down)
(logior! (-> self state-flags) (state-flags dangerous))
(set! (-> s4-0 prim-core collide-as) (collide-kind target target-attack))
(set! (-> s4-0 collide-with)
(collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
)
(dotimes (v1-124 3)
(set! (-> self control unknown-sphere-array00 v1-124 prim-core offense) (collide-offense strong-attack))
)
(sphere<-vector+r!
(the-as sphere (-> s4-0 local-sphere))
(-> *TARGET-bank* flop0-offset)
(-> *TARGET-bank* flop-radius)
)
(set! (-> s5-0 prim-core collide-as) (collide-kind target target-attack))
(set! (-> s5-0 collide-with)
(collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
)
(sphere<-vector+r!
(the-as sphere (-> s5-0 local-sphere))
(-> *TARGET-bank* flop1-offset)
(-> *TARGET-bank* flop-radius)
)
(if (!= f30-0 1.0)
(set! f30-0 2.1)
)
(set! (-> self control unknown-symbol30) 'flop)
)
(('flut-attack)
(sphere<-vector+r!
(the-as sphere (-> self control root-prim local-sphere))
(new 'static 'vector :y 6553.6 :w 1.0)
12288.0
)
(logior! (-> self state-flags) (state-flags dangerous))
(set! (-> s4-0 prim-core collide-as) (collide-kind target target-attack))
(set! (-> s4-0 collide-with)
(collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
)
(sphere<-vector+r!
(the-as sphere (-> s4-0 local-sphere))
(-> *TARGET-bank* spin-offset)
(+ 2048.0 (-> *TARGET-bank* punch-radius))
)
(set! (-> s5-0 prim-core collide-as) (collide-kind target target-attack))
(set! (-> s5-0 collide-with)
(collide-kind cak-1 cak-2 cak-3 powerup crate enemy wall-object ground-object mother-spider)
)
(sphere<-vector+r!
(the-as sphere (-> s5-0 local-sphere))
*null-vector*
(+ 1228.8 (-> *TARGET-bank* punch-radius))
)
(set! (-> s5-0 transform-index) 37)
(dotimes (v1-148 3)
(set! (-> self control unknown-sphere-array00 v1-148 prim-core offense) (collide-offense strong-attack))
)
)
(else
(format 0 "ERROR: ~A unknown danger mode ~A" self arg0)
)
)
(when (and (!= f30-0 1.0) (not (or (= arg0 'harmless) (= arg0 #f))))
(set! (-> self control root-prim local-sphere w) (* (-> self control root-prim local-sphere w) f30-0))
(set! (-> s4-0 local-sphere w) (* (-> s4-0 local-sphere w) f30-0))
(set! (-> s5-0 local-sphere w) (* (-> s5-0 local-sphere w) f30-0))
(set! (-> gp-0 local-sphere w) (* (-> gp-0 local-sphere w) f30-0))
)
)
)
(defbehavior target-collide-set! target ((arg0 symbol) (arg1 float))
(let ((gp-0 (-> self control)))
(set! (-> self control unknown-symbol00) arg0)
(set! (-> self control unknown-float90) arg1)
(dotimes (v1-2 3)
(set! (-> gp-0 unknown-sphere-array00 v1-2 prim-core offense) (collide-offense touch))
(set! (-> gp-0 unknown-sphere-array00 v1-2 transform-index) -2)
)
(case arg0
(('pole)
(set-vector! (-> gp-0 unknown-sphere-array00 0 local-sphere) 0.0 0.0 0.0 (-> *TARGET-bank* body-radius))
(set-vector! (-> gp-0 unknown-sphere-array00 1 local-sphere) 0.0 0.0 0.0 (-> *TARGET-bank* body-radius))
(set-vector! (-> gp-0 unknown-sphere-array00 2 local-sphere) 0.0 0.0 0.0 (-> *TARGET-bank* body-radius))
(set! (-> gp-0 unknown-sphere-array00 0 transform-index) 28)
(set! (-> gp-0 unknown-sphere-array00 1 transform-index) 26)
(set! (-> gp-0 unknown-sphere-array00 2 transform-index) 7)
)
(('racer)
(set! (-> gp-0 unknown-vector11 y) 4096.0)
(sphere<-vector+r!
(the-as sphere (-> gp-0 root-prim local-sphere))
(new 'static 'vector :y 8192.0 :w 1.0)
16384.0
)
(set-vector! (-> gp-0 unknown-sphere-array00 0 local-sphere) 0.0 6553.6 0.0 6553.6)
(set-vector! (-> gp-0 unknown-sphere-array00 1 local-sphere) 0.0 9420.8 0.0 6553.6)
(set-vector! (-> gp-0 unknown-sphere-array00 2 local-sphere) 0.0 12288.0 0.0 6553.6)
(dotimes (v1-22 3)
(set! (-> gp-0 unknown-sphere-array00 v1-22 prim-core offense) (collide-offense strong-attack))
)
)
(('flut)
(sphere<-vector+r!
(the-as sphere (-> gp-0 root-prim local-sphere))
(new 'static 'vector :y 8192.0 :w 1.0)
12288.0
)
(set-vector! (-> gp-0 unknown-sphere-array00 0 local-sphere) 0.0 4915.2 0.0 4915.2)
(set-vector! (-> gp-0 unknown-sphere-array00 1 local-sphere) 0.0 7782.4004 0.0 4915.2)
(set-vector! (-> gp-0 unknown-sphere-array00 2 local-sphere) 0.0 10649.6 0.0 4915.2)
)
(('duck)
(set! (-> self control unknown-float91) arg1)
(let ((f30-0 (- 1.0 arg1)))
(set! (-> gp-0 unknown-vector11 y) 0.0)
(sphere<-vector+r!
(the-as sphere (-> gp-0 root-prim local-sphere))
(-> *TARGET-bank* root-offset)
(-> *TARGET-bank* root-radius)
)
(set-vector!
(-> gp-0 unknown-sphere-array00 0 local-sphere)
0.0
(-> *TARGET-bank* body-radius)
(* 0.0 f30-0)
(-> *TARGET-bank* body-radius)
)
(set-vector!
(-> gp-0 unknown-sphere-array00 1 local-sphere)
0.0
(+ (-> *TARGET-bank* body-radius) (* 2867.2 f30-0))
0.0
(-> *TARGET-bank* body-radius)
)
(set-vector!
(-> gp-0 unknown-sphere-array00 2 local-sphere)
0.0
(+ (-> *TARGET-bank* body-radius) (* 5734.4 f30-0))
0.0
(-> *TARGET-bank* body-radius)
)
)
)
(('tube)
(set! (-> self control unknown-float91) arg1)
(let ((f30-1 (- 1.0 arg1)))
(set! (-> gp-0 unknown-vector11 y) 0.0)
(sphere<-vector+r!
(the-as sphere (-> gp-0 root-prim local-sphere))
(-> *TARGET-bank* root-offset)
(-> *TARGET-bank* root-radius)
)
(set-vector!
(-> gp-0 unknown-sphere-array00 0 local-sphere)
0.0
(-> *TARGET-bank* body-radius)
(* 0.0 f30-1)
(-> *TARGET-bank* body-radius)
)
(set-vector!
(-> gp-0 unknown-sphere-array00 1 local-sphere)
0.0
(+ (-> *TARGET-bank* body-radius) (* 2867.2 f30-1))
0.0
(-> *TARGET-bank* body-radius)
)
(set-vector!
(-> gp-0 unknown-sphere-array00 2 local-sphere)
0.0
(+ (-> *TARGET-bank* body-radius) (* 5734.4 f30-1))
0.0
(-> *TARGET-bank* body-radius)
)
)
(dotimes (v1-52 3)
(set! (-> gp-0 unknown-sphere-array00 v1-52 prim-core offense) (collide-offense strong-attack))
)
)
(else
(set! (-> self control unknown-float91) 0.0)
(set! (-> gp-0 unknown-vector11 y) 0.0)
(sphere<-vector+r!
(the-as sphere (-> gp-0 root-prim local-sphere))
(-> *TARGET-bank* root-offset)
(-> *TARGET-bank* root-radius)
)
(set-vector!
(-> gp-0 unknown-sphere-array00 0 local-sphere)
0.0
(-> *TARGET-bank* body-radius)
0.0
(-> *TARGET-bank* body-radius)
)
(set-vector!
(-> gp-0 unknown-sphere-array00 1 local-sphere)
0.0
(+ 2867.2 (-> *TARGET-bank* body-radius))
0.0
(-> *TARGET-bank* body-radius)
)
(set-vector!
(-> gp-0 unknown-sphere-array00 2 local-sphere)
0.0
(+ 5734.4 (-> *TARGET-bank* body-radius))
0.0
(-> *TARGET-bank* body-radius)
)
)
)
)
0
)
(defmethod get-quaternion ((this control-info))
(-> this unknown-quaternion00)
)
(defbehavior target-align-vel-z-adjust target ((arg0 float))
(let ((f1-0 (-> self control unknown-float61)))
(* arg0 (if (< 0.0 f1-0)
(* (- 1.0 f1-0) (-> self control unknown-surface01 alignv))
(-> self control unknown-surface01 alignv)
)
)
)
)
(defmethod apply-alignment ((this target) (arg0 align-opts) (arg1 transformq) (arg2 vector))
(let ((s2-0 (new 'stack-no-clear 'vector)))
(set! (-> s2-0 quad) (-> arg2 quad))
(set! (-> s2-0 z) (target-align-vel-z-adjust (-> s2-0 z)))
(when (logtest? arg0 (align-opts adjust-x-vel adjust-y-vel adjust-xz-vel))
(let* ((s3-0 (-> this control unknown-matrix01))
(s0-0 (-> this control unknown-matrix00))
(s1-0 (vector-matrix*! (new 'stack-no-clear 'vector) (-> this control dynam gravity) s0-0))
(a1-3 (vector-matrix*! (new 'stack-no-clear 'vector) (-> this control transv) s0-0))
)
(if (logtest? arg0 (align-opts no-gravity))
(set-vector! s1-0 0.0 0.0 0.0 1.0)
)
(when (logtest? arg0 (align-opts adjust-x-vel))
(set! (-> a1-3 x)
(+ (* (-> arg1 trans x) (-> s2-0 x) (-> *display* frames-per-second)) (* (-> s1-0 x) (seconds-per-frame)))
)
(if (not (logtest? arg0 (align-opts adjust-xz-vel keep-other-velocities)))
(set! (-> a1-3 z) 0.0)
)
)
(if (and (logtest? arg0 (align-opts adjust-y-vel))
(not (and (logtest? arg0 (align-opts ignore-y-if-zero)) (= (-> arg1 trans y) 0.0)))
)
(set! (-> a1-3 y)
(+ (* (-> arg1 trans y) (-> s2-0 y) (-> *display* frames-per-second)) (* (-> s1-0 y) (seconds-per-frame)))
)
)
(when (logtest? arg0 (align-opts adjust-xz-vel))
(set! (-> a1-3 z)
(+ (* (-> arg1 trans z) (-> s2-0 z) (-> *display* frames-per-second)) (* (-> s1-0 z) (seconds-per-frame)))
)
(if (not (logtest? arg0 (align-opts adjust-x-vel keep-other-velocities)))
(set! (-> a1-3 x) 0.0)
)
)
(vector-matrix*! (-> this control transv) a1-3 s3-0)
)
)
)
(if (logtest? arg0 (align-opts adjust-quat))
(quaternion-normalize!
(quaternion*! (-> this control unknown-quaternion00) (-> this control unknown-quaternion00) (-> arg1 quat))
)
)
(the-as collide-shape (-> this control))
)
(defun average-turn-angle ((arg0 target))
(let ((f30-0 0.0))
(dotimes (s5-0 8)
(+! f30-0
(fabs
(deg-diff
(atan (-> arg0 control unknown-vector-array00 s5-0 x) (-> arg0 control unknown-vector-array00 s5-0 z))
0.0
)
)
)
)
(* 0.125 f30-0)
)
)
(defbehavior can-play-stance-amibent? target ()
(and (time-elapsed? (-> self state-time) (seconds 30))
(not (-> *setting-control* current talking))
(not (-> *setting-control* current spooling))
(not (-> *setting-control* current movie))
(not (-> *setting-control* current hint))
(not (logtest? (-> self control status) (cshape-moving-flags t-act)))
(not (logtest? (-> self water flags) (water-flags wt09)))
)
)
(defbehavior can-jump? target ((arg0 symbol))
(and (or (logtest? (-> self control status) (cshape-moving-flags onsurf))
(not (time-elapsed? (-> self control unknown-dword11) (-> *TARGET-bank* ground-timeout)))
(and (logtest? (-> self control status) (cshape-moving-flags onsurf))
(< 0.866 (-> self control surface-angle))
)
)
(and (not (logtest? (-> self control unknown-surface01 flags) (surface-flags prevent-jump)))
(not (logtest? (-> self state-flags) (state-flags prevent-jump)))
(case arg0
(('target-wheel-flip)
(>= 0.5 (-> self control unknown-float61))
)
(else
#t
)
)
)
)
)
(defbehavior move-legs? target ()
(!= (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) stick0-speed) 0.0)
)
(defbehavior target-height-above-ground target ()
(- (-> self control trans y) (-> self control shadow-pos y))
)
(defbehavior fall-test target ()
(when (and (not (logtest? (-> self control status) (cshape-moving-flags onsurf)))
(time-elapsed? (-> self control unknown-dword11) (-> *TARGET-bank* ground-timeout))
(>= 0.0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))
(let ((v1-15 (ja-group)))
(or (not (or (= v1-15 eichar-attack-punch-ja)
(= v1-15 eichar-attack-punch-end-ja)
(= v1-15 eichar-attack-punch-alt-end-ja)
)
)
(< 4096.0 (target-height-above-ground))
)
)
)
(when (and (not (time-elapsed? (-> self control rider-time) (-> *TARGET-bank* ground-timeout)))
(logtest? (-> self control unknown-surface01 flags) (surface-flags moving-ground))
)
(+! (-> self control transv x) (-> self control rider-last-move x))
(+! (-> self control transv z) (-> self control rider-last-move z))
)
(go target-falling #f)
)
(none)
)
(defbehavior slide-down-test target ()
(if (and (not (logtest? (-> self control status) (cshape-moving-flags onsurf csmf07)))
(time-elapsed? (-> self control unknown-dword11) (-> *TARGET-bank* ground-timeout))
(logtest? (-> self control status) (cshape-moving-flags tsurf))
(< 0.5 (-> self control surface-angle))
)
(go target-slide-down)
)
(none)
)
(defbehavior smack-surface? target ((arg0 symbol))
(and (< 0.7 (-> self control touch-angle))
(and (< (-> self control surface-angle) 0.3)
(logtest? (-> self control status) (cshape-moving-flags twall))
(or arg0 (not (logtest? (-> self control status) (cshape-moving-flags t-act))))
)
)
)
(defbehavior can-wheel? target ()
(and (logtest? (-> self control status) (cshape-moving-flags onsurf))
(or (not (logtest? (-> self control status) (cshape-moving-flags twall)))
(>= 0.7 (-> self control touch-angle))
)
(and (< (-> self control unknown-float61) 0.7)
(not (logtest? (-> self state-flags) (state-flags prevent-duck)))
)
)
)
(defbehavior can-duck? target ()
(and (logtest? (-> self control status) (cshape-moving-flags onsurf))
(>= (-> self control unknown-float60) 0.7)
(not (logtest? (-> self water flags) (water-flags wt11 wt12)))
(not (logtest? (-> self state-flags) (state-flags prevent-duck)))
(or (not (logtest? (-> self water flags) (water-flags wt10)))
(< (- (- (-> self control trans y) (- (-> self water base-height) (-> self water wade-height)))) 2457.6)
)
)
)
(defbehavior can-exit-duck? target ()
(let ((gp-0 (new 'stack-no-clear 'collide-using-spheres-params)))
(let ((s5-0 (new 'stack-no-clear 'inline-array 'sphere 2)))
(dotimes (s4-0 2)
((method-of-type sphere new) (the-as symbol (-> s5-0 s4-0)) sphere)
)
(set! (-> s5-0 0 quad) (-> self control trans quad))
(set! (-> s5-0 0 y) (+ 5734.4 (-> *TARGET-bank* body-radius) (-> s5-0 0 y)))
(set! (-> s5-0 0 w) (-> *TARGET-bank* body-radius))
(set! (-> s5-0 1 quad) (-> self control trans quad))
(set! (-> s5-0 1 y) (+ 2867.2 (-> *TARGET-bank* body-radius) (-> s5-0 1 y)))
(set! (-> s5-0 1 w) (-> *TARGET-bank* body-radius))
(set! (-> gp-0 spheres) s5-0)
)
(set! (-> gp-0 num-spheres) (the-as uint 2))
(set! (-> gp-0 collide-with) (-> self control root-prim collide-with))
(set! (-> gp-0 proc) #f)
(set! (-> gp-0 ignore-pat) (new 'static 'pat-surface :noentity #x1))
(set! (-> gp-0 solid-only) #t)
(if (fill-and-probe-using-spheres *collide-cache* gp-0)
#f
#t
)
)
)
(defbehavior can-hands? target ((arg0 symbol))
(cond
((or (not (cpad-pressed? (-> self control unknown-cpad-info00 number) square))
(or (and (logtest? (-> self state-flags) (state-flags prevent-attack))
(or (not (logtest? (-> self state-flags) (state-flags remove-prevents)))
(not (and (= (-> self fact eco-type) (pickup-type eco-yellow)) (>= (-> self fact eco-level) 1.0)))
)
)
(logtest? (-> self control unknown-surface01 flags) (surface-flags prevent-attacks-during-launch-jump surf08))
)
)
#f
)
((and (or (not arg0) (and (not (time-elapsed? (-> self control unknown-dword11) (-> *TARGET-bank* ground-timeout)))
(< (-> self control unknown-float61) 0.7)
)
)
(time-elapsed?
(if (and (= (-> self fact eco-type) (pickup-type eco-yellow)) (>= (-> self fact eco-level) 1.0))
(-> *TARGET-bank* yellow-attack-timeout)
(-> *TARGET-bank* attack-timeout)
)
(-> self control unknown-dword31)
)
)
#t
)
(else
(set-time! (-> self control unknown-dword32))
#f
)
)
)
(defbehavior can-feet? target ()
(cond
((or (logtest? (-> self state-flags) (state-flags prevent-attack))
(logtest? (-> self control unknown-surface01 flags) (surface-flags prevent-attacks-during-launch-jump surf09))
)
#f
)
((time-elapsed? (-> *TARGET-bank* attack-timeout) (-> self control unknown-dword33))
#t
)
(else
(set-time! (-> self control unknown-dword34))
#f
)
)
)
(defbehavior vector-local+! target ((arg0 vector) (arg1 vector))
(let ((s5-0 (new-stack-vector0)))
(vector-matrix*! s5-0 arg1 (-> self control unknown-matrix01))
(vector+! arg0 arg0 s5-0)
)
)
(defbehavior move-forward target ((arg0 float))
(let ((a1-0 (new-stack-vector0))
(gp-0 (new-stack-vector0))
)
(set-vector! a1-0 0.0 0.0 arg0 1.0)
(vector-matrix*! gp-0 a1-0 (-> self control unknown-matrix01))
(vector+! (-> self control transv) (-> self control transv) gp-0)
)
)
(defbehavior set-forward-vel target ((arg0 float))
(let ((gp-0 (new-stack-vector0)))
(vector-matrix*! gp-0 (-> self control transv) (-> self control unknown-matrix00))
(set! (-> gp-0 z) arg0)
(set! (-> gp-0 x) 0.0)
(vector-matrix*! (-> self control transv) gp-0 (-> self control unknown-matrix01))
)
)
(defbehavior delete-back-vel target ()
(let ((s5-0 (new-stack-vector0)))
(vector-z-quaternion! s5-0 (-> self control dir-targ))
(let ((gp-0 (new-stack-vector0))
(f30-0 (vector-dot s5-0 (-> self control transv)))
)
0.0
(vector-! gp-0 (-> self control transv) (vector-float*! gp-0 s5-0 f30-0))
(let* ((f0-3 (vector-length gp-0))
(f1-0 f0-3)
)
(if (< f30-0 0.0)
(set! f30-0 0.0)
)
(vector+!
(-> self control transv)
(vector-float*! (-> self control transv) s5-0 f30-0)
(vector-float*! gp-0 gp-0 (/ f0-3 f1-0))
)
)
)
)
0
(none)
)
(defbehavior set-side-vel target ((arg0 float))
(let ((gp-0 (new-stack-vector0)))
(vector-matrix*! gp-0 (-> self control transv) (-> self control unknown-matrix00))
(set! (-> gp-0 x) arg0)
(set! (-> gp-0 z) 0.0)
(vector-matrix*! (-> self control transv) gp-0 (-> self control unknown-matrix01))
)
)
(defun target-timed-invulnerable ((arg0 time-frame) (arg1 target))
(logior! (-> arg1 state-flags) (state-flags timed-invulnerable))
(set-time! (-> arg1 control unknown-dword80))
(set! (-> arg1 control unknown-dword81) arg0)
(set-collide-kinds (-> arg1 control) 2 (collide-kind target-attack) (collide-kind))
0
(none)
)
(defun target-timed-invulnerable-off ((arg0 target))
(logclear! (-> arg0 draw status) (draw-status hidden))
(logclear! (-> arg0 state-flags) (state-flags timed-invulnerable))
(set-collide-kinds (-> arg0 control) 2 (collide-kind) (collide-kind target-attack))
0
(none)
)
(defmethod combine! ((this attack-info) (arg0 attack-info))
(with-pp
(let ((s4-0 (-> arg0 mask)))
(set! (-> this mask) (-> arg0 mask))
(if (logtest? s4-0 (attack-mask attacker))
(set! (-> this attacker) (-> arg0 attacker))
)
(if (logtest? s4-0 (attack-mask mode))
(set! (-> this mode) (-> arg0 mode))
)
(if (logtest? s4-0 (attack-mask angle))
(set! (-> this angle) (-> arg0 angle))
)
(if (logtest? s4-0 (attack-mask dist))
(set! (-> this dist) (-> arg0 dist))
)
(if (logtest? s4-0 (attack-mask control))
(set! (-> this control) (-> arg0 control))
)
(if (logtest? s4-0 (attack-mask speed))
(set! (-> this speed) (-> arg0 speed))
)
(if (logtest? s4-0 (attack-mask shove-back))
(set! (-> this shove-back) (-> arg0 shove-back))
)
(if (logtest? s4-0 (attack-mask shove-up))
(set! (-> this shove-up) (-> arg0 shove-up))
)
(if (logtest? s4-0 (attack-mask invinc-time))
(set! (-> this invinc-time) (-> arg0 invinc-time))
)
(if (logtest? s4-0 (attack-mask rotate-to))
(set! (-> this rotate-to) (-> arg0 rotate-to))
)
(if (logtest? s4-0 (attack-mask intersection))
(set! (-> this intersection quad) (-> arg0 intersection quad))
)
(cond
((not (logtest? s4-0 (attack-mask vector)))
(let* ((s3-0 pp)
(s2-0 (handle->process (-> this attacker)))
(v1-39 (if (and (nonzero? s2-0) (type-type? (-> s2-0 type) process-drawable))
s2-0
)
)
)
(when v1-39
(set! (-> this trans quad) (-> (the-as process-drawable v1-39) root trans quad))
(vector-!
(-> this vector)
(-> (the-as process-drawable s3-0) root trans)
(-> (the-as process-drawable v1-39) root trans)
)
(logior! (-> this mask) (attack-mask vector))
)
)
)
(else
(let* ((s3-1 (handle->process (-> this attacker)))
(a0-16 (if (and (nonzero? s3-1) (type-type? (-> s3-1 type) process-drawable))
s3-1
)
)
)
(if a0-16
(set! (-> this trans quad) (-> (the-as process-drawable a0-16) root trans quad))
)
)
(set! (-> this vector quad) (-> arg0 vector quad))
(if (not (logtest? s4-0 (attack-mask shove-back)))
(set! (-> this shove-back) (vector-xz-length (-> this vector)))
)
(if (not (logtest? s4-0 (attack-mask shove-up)))
(set! (-> this shove-up) (-> this vector y))
)
)
)
(if (not (logtest? (-> this mask) (attack-mask dist)))
(set! (-> this dist) (fabs (-> this shove-back)))
)
(if (logtest? s4-0 (attack-mask trans))
(set! (-> this trans quad) (-> arg0 trans quad))
)
)
(none)
)
)
(defbehavior ground-tween-initialize target ((arg0 ground-tween-info) (arg1 uint) (arg2 uint) (arg3 uint) (arg4 uint) (arg5 uint) (arg6 uint))
(set! (-> arg0 group 0) arg2)
(set! (-> arg0 group 1) arg3)
(set! (-> arg0 group 2) arg4)
(set! (-> arg0 group 3) arg5)
(set! (-> arg0 group 4) arg6)
(dotimes (s3-0 3)
(set! (-> arg0 chan s3-0) (+ arg1 s3-0))
(ja :chan (-> arg0 chan s3-0) :group! arg2 :num! min :frame-interp (fabs (-> arg0 blend s3-0)))
)
arg0
)
(defbehavior ground-tween-update target ((arg0 ground-tween-info) (arg1 float) (arg2 float))
(let ((f0-1 (fmax -1.0 (fmin 1.0 (* 2.0 arg1))))
(f30-0 (fmax -1.0 (fmin 1.0 (* 1.6 arg2))))
)
(let ((f1-5 (fabs (- f0-1 (the-as float (-> arg0 blend 1))))))
(set! (-> arg0 blend 1) (seek (the-as float (-> arg0 blend 1)) f0-1 (fmax 0.05 (fmin 0.2 (* 0.25 f1-5)))))
)
(let ((f0-7 (fabs (- f30-0 (the-as float (-> arg0 blend 2))))))
(set! (-> arg0 blend 2) (seek (the-as float (-> arg0 blend 2)) f30-0 (fmax 0.05 (fmin 0.2 (* 0.25 f0-7)))))
)
)
(if (>= (-> arg0 blend 1) 0.0)
(ja :chan (-> arg0 chan 1) :group! (-> arg0 group 1) :frame-interp (fabs (-> arg0 blend 1)))
(ja :chan (-> arg0 chan 1) :group! (-> arg0 group 2) :frame-interp (fabs (-> arg0 blend 1)))
)
(if (>= (-> arg0 blend 2) 0.0)
(ja :chan (-> arg0 chan 2) :group! (-> arg0 group 4) :frame-interp (fabs (-> arg0 blend 2)))
(ja :chan (-> arg0 chan 2) :group! (-> arg0 group 3) :frame-interp (fabs (-> arg0 blend 2)))
)
0
(none)
)
(defun target-pos ((arg0 int))
(let ((a1-0 *target*))
(cond
(a1-0
(if (zero? arg0)
(-> a1-0 control trans)
(vector<-cspace! (new 'static 'vector) (-> a1-0 node-list data arg0))
)
)
(else
(camera-pos)
)
)
)
)
(defun target-cam-pos ()
(let ((gp-0 *target*))
(the-as
vector
(cond
((not gp-0)
(camera-pos)
)
((logtest? (-> gp-0 state-flags) (state-flags use-alt-cam-pos))
(add-debug-sphere
*display-camera-marks*
(bucket-id debug-no-zbuf)
(-> gp-0 alt-cam-pos)
819.2
(new 'static 'rgba :r #xff :a #x80)
)
(-> gp-0 alt-cam-pos)
)
((logtest? (state-flags has-saved-position) (-> gp-0 state-flags))
(add-debug-sphere
*display-camera-marks*
(bucket-id debug-no-zbuf)
(-> gp-0 alt-cam-pos)
819.2
(new 'static 'rgba :r #xff :a #x80)
)
(-> gp-0 alt-cam-pos)
)
((logtest? (state-flags falling-into-pool-of-bad) (-> gp-0 state-flags))
(let ((s5-0 (the-as object (new 'static 'vector))))
(set! (-> (the-as vector s5-0) quad) (-> (&-> (-> gp-0 control) unknown-qword00) 0))
(set! (-> (the-as vector s5-0) y) (fmax (-> (the-as vector s5-0) y) (-> gp-0 alt-cam-pos y)))
(add-debug-sphere
*display-camera-marks*
(bucket-id debug-no-zbuf)
(the-as vector s5-0)
819.2
(new 'static 'rgba :r #xff :a #x80)
)
s5-0
)
)
(else
(add-debug-sphere
*display-camera-marks*
(bucket-id debug-no-zbuf)
(the-as vector (&-> (-> gp-0 control) unknown-qword00))
819.2
(new 'static 'rgba :r #xff :a #x80)
)
(&-> (-> gp-0 control) unknown-qword00)
)
)
)
)
)
(defun target-joint-pos ()
(let ((v1-0 *target*))
(if v1-0
(vector<-cspace! (new 'static 'vector) (-> v1-0 node-list data (-> v1-0 draw origin-joint-index)))
(camera-pos)
)
)
)
(defun target-rot ()
(let ((v1-0 *target*))
(if v1-0
(-> v1-0 control unknown-quaternion00)
*unity-quaternion*
)
)
)