Skip to content

Commit

Permalink
Orb placer debug tool (#69)
Browse files Browse the repository at this point in the history
* init skeleton for orb placer

* fix a lot

* port to jak 2

* rest of jak2 files

* print positions to console

* copy back over fine-tuning from orb hunt
  • Loading branch information
dallmeyer authored Mar 25, 2024
1 parent be23bb7 commit 099b7e6
Show file tree
Hide file tree
Showing 13 changed files with 955 additions and 6 deletions.
2 changes: 2 additions & 0 deletions goal_src/jak1/dgos/game.gd
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,9 @@
"hud-classes-pc.o" ;; added
"mod-settings.o" ;; added
"mod-common-functions.o" ;; added
"orb-placer.o" ;; added
"mod-custom-code.o" ;; added
"mod-debug.o" ;; added
;; keep zoomer stuff loaded
"target-racer-h.o"
"racer-part.o"
Expand Down
7 changes: 7 additions & 0 deletions goal_src/jak1/engine/common-obs/collectables.gc
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,7 @@
)
)

(define-extern orb-placer-list-maintenace (function symbol none))
(defstate pickup (money)
:virtual #t
:code (behavior ((arg0 object) (arg1 handle))
Expand All @@ -1124,6 +1125,12 @@
(runs-on-orb-pickup (ppointer->process (-> self parent))) ;; trigger hook for mod base
(convert-to-hud-object self (the-as hud (ppointer->process (-> *hud-parts* money))))
)
:exit (behavior ()
;; refresh orb-placer list in debug mode
(when *debug-segment*
(orb-placer-list-maintenace #t)
)
)
)

(defmethod initialize ((this money))
Expand Down
29 changes: 26 additions & 3 deletions goal_src/jak1/engine/mods/mod-common-functions.gc
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ if the result of rand-vu-int-range is 1, then DANCE! if it is not 1, then Don't
(defmacro pd-pos-m (procname)
`(let* ((obj (the process-drawable (process-by-ename ,procname)))
(vec (-> obj root trans)))
(format 0 "~m ~m ~m~%" (-> vec x) (-> vec y) (-> vec z) 4096.0)
(format 0 "~m ~m ~m~%" (-> vec x) (-> vec y) (-> vec z))
(none)
)
)
Expand Down Expand Up @@ -441,6 +441,29 @@ if the result of rand-vu-int-range is 1, then DANCE! if it is not 1, then Don't
(draw-xyz jak 0.0 3.0 3.0)
)

;; Helper functions for spawning orbs (used by orb placer in debug mode)

(defun spawn-money ((vec vector) (amount float) (bob? symbol))
(let ((fax (new 'static 'fact-info)))
(set! (-> fax pickup-type) (pickup-type money))
(set! (-> fax pickup-amount) amount)
(set! (-> fax pickup-spawn-amount) amount)
(set! (-> fax fade-time) (the-as time-frame 0))

(let ((proc (the money (ppointer->process (birth-pickup-at-point vec (pickup-type money) amount #t *active-pool* fax)))))
(when bob?
(set! (-> proc bob-amount) 1024.0)
)
(format 0 "spawned ~A~%" proc)
;; return handle to the orb
(process->handle proc)
)
)
)



(defun spawn-money-meters ((x float) (y float) (z float) (amount float) (bob? symbol))
(let ((vec (new 'stack-no-clear 'vector)))
(set-vector-meters! vec x y z)
(spawn-money vec amount bob?)
)
)
7 changes: 6 additions & 1 deletion goal_src/jak1/engine/mods/mod-custom-code.gc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
(input-display-off)
)

;; ensure orb-placer is spawned/killed as requested, debug menu is updated
(when *debug-segment*
(orb-placer-maintenance)
)

(none)
)

Expand Down Expand Up @@ -136,4 +141,4 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;

#| these are no longer recommended/supported however we include them anyways to not break anyones mods.
|#
|#
34 changes: 34 additions & 0 deletions goal_src/jak1/engine/mods/mod-debug.gc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
;;-*-Lisp-*-
(in-package goal)

;; For debug-only additions to the mod-base. Anything defined in this file will be unavailable in retail mode.
(declare-file (debug))

;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Additional debug menu(s)
;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun-debug debug-menu-make-modding-tools-menu ((ctx debug-menu-context))
(let ((modding-tools-menu (new 'debug 'debug-menu ctx "Modding Tools")))

;; orb-placer menu
(let ((orb-placer-menu (new 'debug 'debug-menu ctx "Orb Placer")))
(debug-menu-append-item orb-placer-menu (new-dm-bool "Edit Mode?" *orb-placer-enabled?* dm-boolean-toggle-pick-func))
(debug-menu-append-item orb-placer-menu (new-dm-func "Add Orb" #f orb-placer-add))
(let ((select-orb-menu (new 'debug 'debug-menu ctx "Select Orb")))
(set! *orb-placer-select-menu* select-orb-menu)
;; populated on orb add
(debug-menu-append-item orb-placer-menu (new-dm-submenu "Select Orb" select-orb-menu))
)
(debug-menu-append-item orb-placer-menu (new-dm-func "Print Selected Orb Position" #f orb-placer-print-selected))
(debug-menu-append-item orb-placer-menu (new-dm-func "Print All Orb Positions" #f orb-placer-print-all))

(debug-menu-append-item modding-tools-menu (new-dm-submenu "Orb Placer" orb-placer-menu))
)
(new-dm-submenu "Modding Tools" modding-tools-menu)
)
)

(when (-> *debug-menu-context* root-menu)
(debug-menu-append-item (-> *debug-menu-context* root-menu) (debug-menu-make-modding-tools-menu *debug-menu-context*))
)
Loading

0 comments on commit 099b7e6

Please sign in to comment.