jak-project/goal_src/jak2/engine/target/target-h.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

375 lines
14 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: target-h.gc
;; name in dgo: target-h
;; dgos: ENGINE, GAME
(declare-type sidekick process-drawable)
(declare-type gun process-drawable)
(declare-type racer-info basic)
(declare-type tube-info basic)
(declare-type flut-info basic)
(declare-type board-info basic)
(declare-type pilot-info basic)
(declare-type gun-info basic)
(declare-type darkjak-info basic)
(declare-type mech-info basic)
(declare-type indax-info basic)
(declare-type turret-info basic)
(declare-type sparticle-launcher basic)
;; NOTE - for level-info, defined in `logic-target`
(define-extern start (function symbol continue-point target))
;; for target
(define-extern want-to-darkjak? (function symbol :behavior target))
(define-extern can-feet? (function symbol symbol :behavior target))
(define-extern slide-down-test (function none :behavior target))
(define-extern target-standard-event-handler (function process int symbol event-message-block object :behavior target))
(define-extern target-state-hook-exit (function none :behavior target))
(define-extern move-legs? (function symbol :behavior target))
(define-extern can-duck? (function symbol :behavior target))
(define-extern can-jump? (function symbol symbol :behavior target))
(define-extern target-jump-go (function none :behavior target))
(define-extern can-hands? (function symbol symbol :behavior target))
(define-extern target-stance-anim (function none :behavior target))
(define-extern target-effect-exit (function none :behavior target))
(define-extern can-roll? (function symbol :behavior target))
(define-extern target-walk-event-handler (function process int symbol event-message-block object :behavior target))
(define-extern target-walk-anim (function int none :behavior target))
(define-extern set-forward-vel (function float vector :behavior target))
(define-extern ja-done? (function int symbol :behavior process-drawable))
(define-extern delete-back-vel (function none :behavior target))
(define-extern target-top-anim-base-mode (function int none :behavior target))
(define-extern target-jump-event-handler (function process int symbol event-message-block object :behavior target))
(define-extern ja-group-size (function int :behavior process-drawable))
(define-extern target-falling-anim (function int time-frame symbol :behavior target))
(define-extern *uppercut-jump-mods* surface)
(define-extern ja-eval (function int :behavior process-drawable))
(define-extern target-land-effect (function none :behavior target))
(define-extern target-hit-ground-anim (function symbol symbol none :behavior target))
(define-extern are-still? (function symbol :behavior target))
(define-extern *attack-end-mods* surface)
(define-extern target-dangerous-event-handler (function process int symbol event-message-block object :behavior target))
(define-extern target-start-attack (function none :behavior target))
(define-extern target-danger-set! (function symbol symbol none :behavior target))
(define-extern smack-surface? (function symbol symbol :behavior target))
(define-extern target-height-above-ground (function float :behavior target))
(define-extern target-align-vel-z-adjust (function float float :behavior target))
(define-extern part-tracker-init (function sparticle-launch-group time-frame (function part-tracker none) (pointer process-drawable) process matrix none :behavior part-tracker))
(define-extern target-bonk-event-handler (function process int symbol event-message-block object :behavior target))
(define-extern target-attack-air-anim (function none :behavior target))
(define-extern *uppercut-mods* surface)
(define-extern touch-tracker-init (function vector float time-frame none :behavior touch-tracker))
;; target-util
(define-extern target-move-dist (function time-frame float :behavior target))
(define-extern get-intersect-point (function vector touching-prims-entry collide-shape touching-shapes-entry vector))
;; target-swim
;; target-darkjak
(define-extern set-darkjak-texture-morph! (function float none))
(define-extern process-drawable-random-point! (function process-drawable vector vector))
(define-extern target-falling-anim-trans (function none :behavior target))
(define-extern ja-blend-eval (function int :behavior process-drawable))
;; target-gun - TODO move to `gun-h` perhaps?
(define-extern target-gun-end-mode (function symbol symbol :behavior target))
(define-extern target-gun-marking-menu (function target none))
(define-extern gun-init (function none :behavior gun))
(declare-type gun-red-shot process-drawable)
(define-extern target-gun-type-set! (function pickup-type none :behavior target))
(define-extern target-gun-fire-blue (function (pointer process) :behavior target))
(define-extern target-gun-fire-yellow (function (pointer process) :behavior target))
(define-extern target-gun-fire-red (function (pointer gun-red-shot) :behavior target))
(define-extern target-gun-fire-dark (function (pointer process) :behavior target))
(define-extern target-pos (function int vector))
(define-extern stop (function symbol int))
;; target-anim
;; target2
(define-extern target-gun-check (function none :behavior target))
(define-extern target-gun-fire (function pickup-type none :behavior target))
(define-extern target-darkjak-end-mode (function none :behavior target))
(define-extern target-gun-init (function pickup-type none :behavior target))
(define-extern *hit-ground-hard-mods* surface)
(define-extern *float-mods* surface)
(define-extern target-send-attack (function process symbol touching-shapes-entry int int penetrate symbol :behavior target))
(define-extern target-powerup-effect (function symbol none :behavior target))
(defenum darkjak-stage
:bitfield #t
:type uint32
(force-on)
(active)
(bomb0)
(bomb1)
(invinc)
(giant)
(no-anim)
(disable-force-on)
)
;; og:ignore-form:(new 'static 'boxed-array
;; DECOMP BEGINS
(deftype target (process-focusable)
((self target :override)
(fact fact-info-target :override)
(control control-info :overlay-at root)
(skel2 joint-control)
(shadow-backup shadow-geo)
(target-flags uint32 :overlay-at state-flags)
(game game-info)
(neck joint-mod)
(head joint-mod)
(upper-body joint-mod)
(horns joint-mod)
(hair joint-mod 2)
(darkjak-interp float)
(darkjak-giant-interp float)
(arm-ik joint-mod-ik 2)
(leg-ik joint-mod-ik 2)
(foot joint-mod 2)
(mech-ik joint-mod-ik 2)
(init-time time-frame :overlay-at (-> mech-ik 0))
(teleport-time time-frame)
(state-hook-time time-frame)
(state-hook (function none :behavior target))
(cam-user-mode symbol)
(sidekick (pointer sidekick))
(manipy (pointer manipy))
(mirror (pointer process-drawable))
(attack-info attack-info :inline)
(attack-info-rec attack-info :inline)
(attack-info-old attack-info 8 :inline)
(anim-seed uint64)
(alt-cam-pos vector :inline)
(current-level level)
(saved-pos transformq :inline)
(saved-owner uint64)
(alt-neck-pos vector :inline)
(focus-search (array collide-shape))
(excitement float)
(shock-effect-time time-frame)
(beard? symbol)
(spool-anim spool-anim)
(ambient-time time-frame)
(fp-hud handle)
(no-load-wait uint64)
(no-look-around-wait uint64)
(burn-proc handle)
(pre-joint-hook (function none :behavior target))
(notify handle)
(mode-cache basic)
(mode-param1 handle)
(mode-param2 uint64)
(mode-param3 uint64)
(tobot-state state)
(tobot? symbol)
(tobot-recorder basic)
(color-effect basic)
(color-effect-start-time time-frame)
(color-effect-duration uint64)
(racer racer-info)
(tube tube-info)
(flut flut-info)
(board board-info)
(pilot pilot-info)
(gun gun-info)
(mech mech-info)
(turret turret-info)
(darkjak darkjak-info)
(indax indax-info)
)
(:methods
(do-edge-grabs (_type_ collide-cache collide-edge-spec) none)
(init-target (_type_ continue-point symbol) none :behavior target)
)
(:states
target-attack
(target-attack-air symbol)
(target-attack-uppercut float float)
(target-attack-uppercut-jump float float)
(target-board-clone-anim handle)
target-board-duck-stance
target-board-falling
(target-board-flip float float symbol)
(target-board-get-off object symbol)
target-board-get-on
(target-board-grab symbol)
(target-board-grenade handle)
target-board-halfpipe
(target-board-hit vector attack-info)
target-board-hit-ground
(target-board-hold float float symbol)
(target-board-jump meters meters symbol)
target-board-jump-kick
(target-board-pegasus handle)
(target-board-ride-edge symbol)
target-board-stance
(target-board-start object)
(target-board-trickx float float symbol)
(target-board-turn-to vector time-frame)
(target-board-wall-kick vector float)
target-carry-drop
target-carry-falling
(target-carry-hit-ground symbol)
(target-carry-jump float float symbol)
target-carry-pickup
target-carry-stance
target-carry-throw
target-carry-walk
(target-clone-anim handle)
(target-continue continue-point)
target-darkjak-bomb0
(target-darkjak-bomb1 float float)
target-darkjak-get-off
(target-darkjak-get-on darkjak-stage)
target-darkjak-giant
target-darkjak-running-attack
(target-death symbol)
(target-demo symbol)
(target-double-jump float float)
(target-duck-high-jump float float symbol)
(target-duck-high-jump-jump float float symbol)
(target-duck-stance symbol)
(target-duck-walk symbol)
target-edge-grab
(target-edge-grab-jump float float)
target-edge-grab-off
(target-falling symbol)
target-float
(target-flop float float float)
(target-flop-hit-ground symbol)
(target-flut-start handle)
(target-grab symbol)
target-gun-stance
target-gun-walk
target-hide
(target-high-jump float float object)
(target-hit symbol attack-info)
(target-hit-ground symbol)
(target-hit-ground-hard float)
target-ice-stance
target-ice-walk
target-indax-attack
(target-indax-attack-air symbol)
(target-indax-death symbol)
(target-indax-double-jump float float)
(target-indax-falling symbol)
(target-indax-hit symbol attack-info)
(target-indax-hit-ground symbol)
(target-indax-jump float float surface)
target-indax-running-attack
target-indax-stance
(target-indax-start handle)
target-indax-trip
target-indax-walk
(target-jump float float surface)
(target-jump-forward float float)
(target-launch float symbol vector int)
target-load-wait
target-look-around
target-mech-carry-drag
target-mech-carry-drop
target-mech-carry-falling
(target-mech-carry-hit-ground symbol)
(target-mech-carry-jump float float symbol)
target-mech-carry-pickup
target-mech-carry-stance
target-mech-carry-throw
target-mech-carry-walk
(target-mech-clone-anim handle)
(target-mech-death symbol)
(target-mech-falling symbol)
target-mech-get-off
(target-mech-get-on handle)
target-mech-grab
(target-mech-hit symbol attack-info)
(target-mech-hit-ground symbol)
(target-mech-jump float float surface)
target-mech-punch
target-mech-stance
(target-mech-start handle float symbol)
target-mech-walk
(target-pilot-clone-anim handle)
(target-pilot-death symbol)
(target-pilot-edge-grab pilot-edge-grab-info)
target-pilot-get-off
target-pilot-get-on
target-pilot-grab
(target-pilot-hit symbol attack-info)
target-pilot-impact
target-pilot-stance
(target-pilot-start handle symbol symbol)
(target-play-anim string handle)
(target-pole-cycle handle)
(target-pole-flip-forward float float float)
(target-pole-flip-forward-jump float float)
(target-pole-flip-up object object float)
(target-pole-flip-up-jump float float)
(target-racing-start handle)
target-roll
(target-roll-flip float float)
target-running-attack
target-slide-down
target-slide-down-to-ground
target-stance
target-stance-ambient
target-stance-look-around
target-startup
target-swim-down
(target-swim-jump float float)
(target-swim-jump-jump float float surface)
target-swim-stance
target-swim-up
target-swim-walk
(target-title symbol)
target-tube
(target-tube-death symbol)
(target-tube-hit symbol attack-info)
(target-tube-jump float float)
(target-tube-start handle)
target-turn-around
target-turret-get-off
(target-turret-get-on handle)
(target-turret-stance handle)
target-wade-stance
target-wade-walk
target-walk
(target-warp-in vector vector target)
(target-warp-out vector vector target)
target-yellow-jump-blast
)
)
(define-perm *target* target #f)
(deftype sidekick (process-drawable)
((parent (pointer target) :override)
(control control-info :overlay-at root)
(anim-seed uint64 :offset 208)
(shadow-in-movie? symbol)
(special-anim-time time-frame)
(special-anim-interp float)
(special-anim-frame float)
(offset transformq :inline)
(mirror (pointer process-drawable))
)
(:states
sidekick-clone
)
)
(define-perm *sidekick* sidekick #f)