[jak2] get new cheats working (#2885)

This commit is contained in:
ManDude
2023-08-07 00:15:53 +01:00
committed by GitHub
parent a7cf66fda6
commit 9aa9b9d8e0
42 changed files with 1011 additions and 273 deletions
+9 -7
View File
@@ -7257,6 +7257,7 @@
(progress-aspect-ratio-custom-ratio #x120c)
(progress-vsync #x120d)
(progress-text-language #x120e)
(progress-cheats #x120f)
)
;; ---text-id-h:text-id
@@ -9326,7 +9327,8 @@
(vector vector 3 :inline :offset-assert 112)
))
(define-extern *traffic-manager* process)
(declare-type traffic-manager process)
(define-extern *traffic-manager* traffic-manager)
(define-extern *ctywide-entity* entity)
(define-extern *lwide-entity* entity)
(define-extern *race-vehicle-entity* entity-actor)
@@ -13293,7 +13295,7 @@
(race-number-turbos int32 :offset-assert 516)
(bot-health float 3 :offset-assert 520)
(demo-state uint32 :offset-assert 532)
(wanted-flash basic :offset-assert 536)
(wanted-flash symbol :offset-assert 536)
(distance float :offset-assert 540)
(kiosk-timeout uint64 :offset-assert 544)
(pause-start-time time-frame :offset-assert 552)
@@ -33128,7 +33130,7 @@
(view-anims () _type_ :state 45)
(enemy-method-46 "@abstract" (_type_ int) none 46)
(enemy-method-47 (_type_ vector) float 47)
(enemy-method-48 (_type_ process event-message-block) int 48)
(take-damage-from-attack (_type_ process event-message-block) int 48)
(enemy-method-49 (_type_) time-frame :behavior enemy 49)
(enemy-method-50 (_type_ vector) vector 50)
(enemy-method-51 (_type_) float 51)
@@ -49064,9 +49066,9 @@
(deftype traffic-guard-type-settings (structure)
((target-count int8 :offset-assert 0)
(inaccuracy float :offset-assert 4)
(acquire-delay uint16 :offset-assert 8)
(shot-delay uint16 :offset-assert 10)
(burst-delay uint16 :offset-assert 12)
(acquire-delay uint16 :offset-assert 8 :decomp-as time-frame)
(shot-delay uint16 :offset-assert 10 :decomp-as time-frame)
(burst-delay uint16 :offset-assert 12 :decomp-as time-frame)
(shot-count int8 :offset-assert 14)
(rand-shot-count int8 :offset-assert 15)
)
@@ -49766,7 +49768,7 @@
(vehicle-method-109 (_type_) none 109)
(vehicle-method-110 (_type_) none 110)
(vehicle-method-111 (_type_ object target) none 111)
(vehicle-method-112 (_type_ object) none 112)
(decrease-traffic-alert-level (_type_ int) int 112)
(vehicle-method-113 (_type_) none 113)
(vehicle-method-114 (_type_) none 114)
(vehicle-method-115 (_type_ vector) none 115)
-2
View File
@@ -134,14 +134,12 @@
"game_name": "jak2_pal",
"expected_elf_name": "SCES_516.08",
"is_pal": true,
"obj_file_name_map_file": "goal_src/jak2/build/all_objs.json",
"object_patches": {}
},
"ntsc_v2": {
"game_name": "jak2_us2",
"label_types_merge_file": "decompiler/config/jak2/ntsc_v2/label_types.jsonc",
"anonymous_function_types_merge_file": "decompiler/config/jak2/ntsc_v2/anonymous_function_types.jsonc",
"obj_file_name_map_file": "goal_src/jak2/build/all_objs.json",
"object_patches": {}
},
"jp": {
@@ -21,5 +21,6 @@
"120b": "Ratio must not be lower than 4x3 (~f).",
"120c": "Current ratio is ~f.",
"120d": "V-Sync",
"120e": "Text Language"
"120e": "Text Language",
"120f": "OpenGOAL Secrets"
}
@@ -13,6 +13,7 @@ in vec4 fragment_color;
flat in uvec2 tex_info;
uniform int gfx_hack_no_tex;
uniform uint warp_sample_mode;
uniform sampler2D tex_T0;
@@ -25,7 +26,7 @@ void main() {
// 0x2 is decal
// 0x4 is fog
if (gfx_hack_no_tex == 0) {
if (warp_sample_mode == 1 || gfx_hack_no_tex == 0) {
vec4 T0 = sample_tex(tex_coord.xy, tex_info.x);
if ((tex_info.y & 1u) == 0) {
if ((tex_info.y & 2u) == 0) {
+14 -3
View File
@@ -461,7 +461,7 @@
(with-gensyms (sw)
;; save the switch to a variable (only evaluated once)
`(let ((sw ,switch))
`(let ((,sw ,switch))
;; build the cond construct with each case
(cond ,@(apply
(lambda (x) `(
@@ -476,11 +476,11 @@
)
;; if the list is made up of a single condition
( (= (length conditions) 1)
`((,comp sw ,(first conditions)) ,@body)
`((,comp ,sw ,(first conditions)) ,@body)
)
;; otherwise it is made up of multiple conditions, or them together!
(#t
`((or ,@(apply (lambda (c) `(,comp sw ,c)) conditions)) ,@body)
`((or ,@(apply (lambda (c) `(,comp ,sw ,c)) conditions)) ,@body)
)
)
@@ -509,6 +509,17 @@
)
)
(defmacro the-as-safe (type obj)
(with-gensyms (temp)
`(let ((,temp ,obj))
(if (type? ,temp ,type)
(the-as ,type ,temp))
)
)
)
;;;;;;;;;;;;;;;;;;;
;; Math Macros
;;;;;;;;;;;;;;;;;;;
-31
View File
@@ -84,32 +84,6 @@
)
;; cheats
(defconstant PC_CHEAT_MAX 18) ;; number of cheats
(defenum pc-cheats
:bitfield #t
:type uint64
(eco-green)
(eco-red)
(eco-blue)
(eco-yellow)
(invinc)
(sidekick-blue)
(tunes)
(sky)
(mirror)
(big-head)
(small-head)
(big-fist)
(no-tex)
(hard-rats)
(hero-mode)
(huge-head)
(big-head-npc)
(oh-my-goodness)
)
(defmacro pc-cheats? (obj &rest cheats)
`(logtest? ,obj (pc-cheats ,@cheats)))
@@ -230,9 +204,6 @@
(discord-rpc? symbol) ;; enable discord rich presence integration
(speedrunner-mode? symbol) ;; enable speedrunner mode
(cheats pc-cheats)
(cheats-known pc-cheats)
(flava-hack int64)
;; TODO - save/restore original settings (language/sound/etc)
@@ -442,8 +413,6 @@
(defmethod reset-extra pc-settings ((obj pc-settings) (call-handlers symbol))
"Set the default goodies settings"
(set! (-> obj cheats) (pc-cheats))
(set! (-> obj cheats-known) (pc-cheats))
0)
(defmacro with-pc (&rest body)
+31
View File
@@ -19,6 +19,31 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; cheats
(defconstant PC_CHEAT_MAX 18) ;; number of cheats
(defenum pc-cheats
:bitfield #t
:type uint64
(eco-green)
(eco-red)
(eco-blue)
(eco-yellow)
(invinc)
(sidekick-blue)
(tunes)
(sky)
(mirror)
(big-head)
(small-head)
(big-fist)
(no-tex)
(hard-rats)
(hero-mode)
(huge-head)
(big-head-npc)
(oh-my-goodness)
)
;; pc enum for languages. this is the game's languages + custom ones.
(defenum pc-language
:type uint16
@@ -73,6 +98,9 @@
;; The Jak 1 version of the pc-settings object.
(deftype pc-settings-jak1 (pc-settings)
(
(cheats pc-cheats)
(cheats-known pc-cheats)
(skip-movies? symbol) ;; if on, enable cutscene skipping
(subtitles? symbol) ;; if on, cutscene subtitles will show up
(text-language pc-language) ;; language for game text
@@ -152,6 +180,9 @@
((method-of-type pc-settings reset-extra) obj call-handlers)
(set! (-> obj cheats) (pc-cheats))
(set! (-> obj cheats-known) (pc-cheats))
(dotimes (i PC_SPOOL_LOG_LENGTH)
(set! (-> obj scenes-seen i) 0)
)
+1
View File
@@ -428,6 +428,7 @@
"enemy-h.o"
"nav-enemy-h.o"
"rigid-body-h.o"
"damage-number.o" ;; added
"enemy.o"
"nav-enemy.o"
"base-plat.o"
+1 -1
View File
@@ -328,7 +328,7 @@
(view-anims () _type_ :state 45)
(enemy-method-46 (_type_ int) none 46)
(enemy-method-47 (_type_ vector) float 47)
(enemy-method-48 (_type_ process event-message-block) int 48)
(take-damage-from-attack (_type_ process event-message-block) int 48)
(enemy-method-49 (_type_) time-frame :behavior enemy 49)
(enemy-method-50 (_type_ vector) vector 50)
(enemy-method-51 (_type_) float 51)
+19 -4
View File
@@ -1715,9 +1715,24 @@ This commonly includes things such as:
)
(send-event (ppointer->process (-> obj parent)) 'child-hit)
0
(if (not *debug-unkillable*)
(enemy-method-48 obj arg0 arg3)
)
(when (not *debug-unkillable*)
(#cond
(PC_PORT
(let ((old-hp (-> obj hit-points))
(dmg-taken (take-damage-from-attack obj arg0 arg3)))
(when (> dmg-taken 0)
(process-spawn damage-number (damage-amount-from-attack obj arg0 arg3) (-> obj root trans) (-> obj mask))
(send-damage-to-bar *health-bar-manager* obj dmg-taken old-hp))
(when (nonzero? (-> obj fated-time))
(aif (get-bar-for-process *health-bar-manager* obj)
(send-event (ppointer->process it) 'set-hit-points 0)
(send-damage-to-bar *health-bar-manager* obj 1 1))
)
)
)
(#t
(take-damage-from-attack obj arg0 arg3)))
)
(let ((s2-1 (the-as attack-info (enemy-method-58 obj arg0 arg3))))
(when s2-1
(logclear! (-> obj enemy-flags) (enemy-flag called-dying))
@@ -2003,7 +2018,7 @@ This commonly includes things such as:
)
)
(defmethod enemy-method-48 enemy ((obj enemy) (arg0 process) (arg1 event-message-block))
(defmethod take-damage-from-attack enemy ((obj enemy) (arg0 process) (arg1 event-message-block))
(let* ((v1-1 (damage-amount-from-attack obj arg0 arg1))
(s5-0 (-> obj hit-points))
(s4-1 (max 0 (- s5-0 v1-1)))
+2 -1
View File
@@ -81,10 +81,11 @@
(declare-type nav-mesh basic)
(declare-type nav-branch structure)
(declare-type traffic-manager process)
;; DECOMP BEGINS
(define *traffic-manager* (the-as process #f))
(define *traffic-manager* (the-as traffic-manager #f))
(define *ctywide-entity* (the-as entity #f))
@@ -2431,6 +2431,12 @@ This commonly includes things such as:
(if arg5
(mem-copy! (&-> sv-56 type) (&-> arg5 type) 40)
)
(#when PC_PORT
(when (and (pc-cheats? (-> *pc-settings* cheats) suck-in-all)
(!= arg1 (pickup-type skill)))
(logior! (-> sv-56 options) (actor-option suck-in))
)
)
(set! (-> sv-56 pickup-type) arg1)
(set! (-> sv-56 pickup-spawn-amount) 1.0)
(while (> sv-48 0)
@@ -1023,6 +1023,25 @@
)
)
)
(#when PC_PORT
;; time cheats (doesn't work properly)
(cond
((movie?)
)
((pc-cheats? (-> *pc-settings* cheats) slow-speed)
;(update-rates! (-> *display* entity-clock) (* 0.3 (-> *display* entity-clock clock-ratio)))
;(update-rates! (-> *display* target-clock) (* 0.5 (-> *display* target-clock clock-ratio)))
)
((pc-cheats? (-> *pc-settings* cheats) fast-speed)
;(update-rates! (-> *display* entity-clock) (* 60.0 (-> *display* entity-clock clock-ratio)))
;(update-rates! (-> *display* target-clock) (* 2.0 (-> *display* target-clock clock-ratio)))
)
((logtest? (-> self game features) (game-feature unk-game-feature-01 unk-game-feature-03 unk-game-feature-05))
)
(else
)
)
)
(target-eco-process)
(target-color-effect-process)
(let ((a0-89 (-> self current-level)))
+1 -1
View File
@@ -309,7 +309,7 @@
(race-number-turbos int32 :offset-assert 516)
(bot-health float 3 :offset-assert 520)
(demo-state uint32 :offset-assert 532)
(wanted-flash basic :offset-assert 536)
(wanted-flash symbol :offset-assert 536)
(distance float :offset-assert 540)
(kiosk-timeout uint64 :offset-assert 544)
(pause-start-time time-frame :offset-assert 552)
+2 -2
View File
@@ -680,8 +680,8 @@
(('matrix-blend-max-partial)
(set! (-> obj matrix-blend-max-partial) arg2)
)
(('string-spline-max-move-player)
(set! (-> obj string-spline-max-move-player) arg2)
(('string-spline-max-move) ;; original game had a copypasta bug here
(set! (-> obj string-spline-max-move) arg2)
)
(('string-spline-accel)
(set! (-> obj string-spline-accel) arg2)
+1 -1
View File
@@ -147,7 +147,7 @@
(set! (-> gp-0 progress-interp-speed) (/ 1.0 30))
(#when PC_PORT
(when (-> *pc-settings* fast-progress?)
(*! (-> gp-0 progress-interp-speed) *progress-speed*)
(*! (-> gp-0 progress-interp-speed) (-> *pc-cheat-state* progress-speed))
)
)
)
@@ -59,6 +59,13 @@
(set! (-> self control current-surface target-speed) (* (-> self control current-surface target-speed) f0-11))
(set! (-> self control current-surface transv-max) (* (-> self control current-surface transv-max) f0-11))
)
(#when PC_PORT
;; turbo jet board cheat
(when (cheat-state-flag? turbo-board)
(*! (-> self control current-surface target-speed) (-> *pc-cheat-state* turbo-board-speed))
(*! (-> self control current-surface transv-max) (-> *pc-cheat-state* turbo-board-speed))
)
)
(let ((s5-0 (new-stack-vector0)))
(vector-z-quaternion! s5-0 (-> self control quat-for-control))
(when (logtest? (-> self control mod-surface flags) (surface-flag xz-local))
+4 -4
View File
@@ -1062,7 +1062,7 @@
(defbehavior progress-trans progress ()
;; pc port note : added variable
(let ((speed-mod (if (-> *pc-settings* fast-progress?) *progress-speed* 1.0)))
(let ((speed-mod (if (-> *pc-settings* fast-progress?) (-> *pc-cheat-state* progress-speed) 1.0)))
(cond
((and (= (-> self next) 'none)
(or (= (-> *progress-state* starting-state) 'main) (= (-> self anim-frame) 1.0))
@@ -1399,7 +1399,7 @@
)
)
;; pc port note : added variable
(speed-mod (if (-> *pc-settings* fast-progress?) *progress-speed* 1.0))
(speed-mod (if (-> *pc-settings* fast-progress?) (-> *pc-cheat-state* progress-speed) 1.0))
)
(when (hud-hidden?)
(set! (-> *blit-displays-work* menu-mode) #t)
@@ -1662,7 +1662,7 @@
(set! (-> v1-2 progress-interp-speed) (/ 1.0 45))
(#when PC_PORT
(when (-> *pc-settings* fast-progress?)
(*! (-> v1-2 progress-interp-speed) *progress-speed*)
(*! (-> v1-2 progress-interp-speed) (-> *pc-cheat-state* progress-speed))
)
)
)
@@ -1670,7 +1670,7 @@
)
:trans (behavior ()
;; pc port note : added variable
(let ((speed-mod (if (-> *pc-settings* fast-progress?) *progress-speed* 1.0)))
(let ((speed-mod (if (-> *pc-settings* fast-progress?) (-> *pc-cheat-state* progress-speed) 1.0)))
(seek! (-> self anim-frame) 0.0 (* speed-mod 0.02 (-> self clock time-adjust-ratio)))
(cond
((= (-> self anim-frame) 0.0)
+1
View File
@@ -593,6 +593,7 @@
(progress-aspect-ratio-custom-ratio #x120c)
(progress-vsync #x120d)
(progress-text-language #x120e)
(progress-cheats #x120f)
)
;; ---text-id
+1 -1
View File
@@ -1507,7 +1507,7 @@
;; - we don't return #t for run-logic?
(let ((s3-0 (or (logtest? (-> arg0 mask) (process-mask process-tree))
;; prevent if not both (clear to run and run-logic? = #t)
(not (and (zero? (logand (-> arg2 prevent-from-run) (-> arg0 mask))) (run-logic? arg0)))
(not (and (not (logtest? (-> arg2 prevent-from-run) (-> arg0 mask))) (run-logic? arg0)))
(begin (logior! (-> arg0 mask) (process-mask kernel-run)) (arg1 arg0))
)
)
@@ -788,7 +788,7 @@
)
)
)
(v1-10 *traffic-manager*)
(v1-10 (the-as process *traffic-manager*))
)
(cond
((not (logtest? (-> arg1 waypoint-bits) 1))
@@ -2327,48 +2327,48 @@ Process is recycled and moved to reserved, if it deactivates."
:ped-tazer (new 'static 'traffic-guard-type-settings
:target-count 5
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:ped-rifle (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 2
:rand-shot-count 1
)
:ped-grenade (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:ped-roboguard (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:bike-turret (new 'static 'traffic-guard-type-settings
:target-count 1
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x5dc
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 5)
:shot-count 2
:rand-shot-count 1
)
:hellcat-turret (new 'static 'traffic-guard-type-settings
:target-count 1
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x5dc
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 5)
:shot-count 2
:rand-shot-count 1
)
@@ -2377,46 +2377,46 @@ Process is recycled and moved to reserved, if it deactivates."
:ped-tazer (new 'static 'traffic-guard-type-settings
:target-count 5
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:ped-rifle (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 2
:rand-shot-count 1
)
:ped-grenade (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:ped-roboguard (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:bike-turret (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x5dc
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 5)
:shot-count 2
:rand-shot-count 1
)
:hellcat-turret (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x5dc
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 5)
:shot-count 2
:rand-shot-count 1
)
@@ -2425,48 +2425,48 @@ Process is recycled and moved to reserved, if it deactivates."
:ped-tazer (new 'static 'traffic-guard-type-settings
:target-count 3
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:ped-rifle (new 'static 'traffic-guard-type-settings
:target-count 4
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 2
:rand-shot-count 1
)
:ped-grenade (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:ped-roboguard (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:bike-turret (new 'static 'traffic-guard-type-settings
:target-count 2
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x5dc
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 5)
:shot-count 2
:rand-shot-count 1
)
:hellcat-turret (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x5dc
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 5)
:shot-count 2
:rand-shot-count 1
)
@@ -2475,49 +2475,49 @@ Process is recycled and moved to reserved, if it deactivates."
:ped-tazer (new 'static 'traffic-guard-type-settings
:target-count 2
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:ped-rifle (new 'static 'traffic-guard-type-settings
:target-count 7
:inaccuracy 0.25
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 2
:rand-shot-count 1
)
:ped-grenade (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:ped-roboguard (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:bike-turret (new 'static 'traffic-guard-type-settings
:target-count 3
:inaccuracy 0.25
:acquire-delay #xe1
:shot-delay #x4b
:burst-delay #x4b0
:acquire-delay (seconds 0.75)
:shot-delay (seconds 0.25)
:burst-delay (seconds 4)
:shot-count 2
:rand-shot-count 1
)
:hellcat-turret (new 'static 'traffic-guard-type-settings
:target-count 2
:inaccuracy 0.25
:acquire-delay #xe1
:shot-delay #x4b
:burst-delay #x4b0
:acquire-delay (seconds 0.75)
:shot-delay (seconds 0.25)
:burst-delay (seconds 4)
:shot-count 2
:rand-shot-count 1
)
@@ -2526,49 +2526,49 @@ Process is recycled and moved to reserved, if it deactivates."
:ped-tazer (new 'static 'traffic-guard-type-settings
:target-count 2
:inaccuracy 0.125
:acquire-delay #x96
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 0.5)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:ped-rifle (new 'static 'traffic-guard-type-settings
:target-count 7
:inaccuracy 0.125
:acquire-delay #x96
:shot-delay #x2d
:burst-delay #x258
:acquire-delay (seconds 0.5)
:shot-delay (seconds 0.15)
:burst-delay (seconds 2)
:shot-count 2
:rand-shot-count 2
)
:ped-grenade (new 'static 'traffic-guard-type-settings
:inaccuracy 0.125
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x384
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 3)
:shot-count 1
)
:ped-roboguard (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:bike-turret (new 'static 'traffic-guard-type-settings
:target-count 3
:inaccuracy 0.125
:acquire-delay #x96
:shot-delay #x4b
:burst-delay #x384
:acquire-delay (seconds 0.5)
:shot-delay (seconds 0.25)
:burst-delay (seconds 3)
:shot-count 2
:rand-shot-count 2
)
:hellcat-turret (new 'static 'traffic-guard-type-settings
:target-count 2
:inaccuracy 0.125
:acquire-delay #x96
:shot-delay #x4b
:burst-delay #x384
:acquire-delay (seconds 0.5)
:shot-delay (seconds 0.25)
:burst-delay (seconds 3)
:shot-count 2
:rand-shot-count 2
)
@@ -2755,6 +2755,16 @@ Process is recycled and moved to reserved, if it deactivates."
(-> a0-10 min-target-count)
)
)
(#when PC_PORT
;; peaceful city cheat
(when (and (pc-cheats? (-> *pc-settings* cheats) city-peace) (not (task-node-open? (game-task-node city-help-kid-battle))))
(set! (-> a0-10 target-count) (-> a0-10 min-target-count))
(set! (-> obj alert-state level) 0)
(logclear! (-> obj alert-state flags) (traffic-alert-flag alert-ending))
(if (zero? (-> a0-10 target-count))
(send-event *traffic-manager* 'deactivate-by-type (-> a0-10 object-type)))
)
)
)
)
)
@@ -2819,7 +2829,7 @@ Process is recycled and moved to reserved, if it deactivates."
(s5-0
(when (not (logtest? (-> obj alert-state flags) (traffic-alert-flag alarm-on)))
(logior! (-> obj alert-state flags) (traffic-alert-flag alarm-on))
(set! (-> *game-info* wanted-flash) (the-as basic #t))
(set! (-> *game-info* wanted-flash) #t)
(if (= (-> *setting-control* user-current music) 'city1)
(set-setting! 'sound-mode #f 0.0 1)
)
@@ -18,9 +18,9 @@
)
(define *transport-turret-state-info* (new 'static 'traffic-guard-type-settings
:acquire-delay #x1c2
:shot-delay #x4b
:burst-delay #x384
:acquire-delay (seconds 1.5)
:shot-delay (seconds 0.25)
:burst-delay (seconds 3)
:shot-count 2
:rand-shot-count 1
)
@@ -437,7 +437,7 @@
(vehicle-method-109 (_type_) none 109)
(vehicle-method-110 (_type_) none 110)
(vehicle-method-111 (_type_ object target) none 111)
(vehicle-method-112 (_type_ object) none 112)
(decrease-traffic-alert-level (_type_ int) int 112)
(vehicle-method-113 (_type_) none 113)
(vehicle-method-114 (_type_) none 114)
(vehicle-method-115 (_type_ vector) none 115)
@@ -588,6 +588,17 @@ This commonly includes things such as:
(format #t "vehicle::apply-damage: hit melt (damage ~f)~%" arg0)
)
)
(#when PC_PORT
;; vehicle invuln cheats
(when (and (pc-cheats? (-> *pc-settings* cheats) vehicle-invuln)
*target*
(focus-test? *target* pilot)
(nonzero? (-> *target* pilot))
(= obj (handle->process (-> *target* pilot vehicle))))
(if (!= (-> arg1 pat event) (pat-event melt))
(set! arg0 0.0))
)
)
(set! (-> obj hit-points) (- (-> obj hit-points) (* arg0 (-> obj damage-factor))))
(let ((s4-1 (-> arg1 prim-id))
(s3-0 0)
@@ -1064,10 +1075,9 @@ This commonly includes things such as:
(none)
)
(defmethod vehicle-method-112 vehicle ((obj vehicle) (arg0 object))
(decrease-alert-level (-> obj controller traffic) (the-as int arg0))
(defmethod decrease-traffic-alert-level vehicle ((obj vehicle) (arg0 int))
(decrease-alert-level (-> obj controller traffic) arg0)
0
(none)
)
(defmethod vehicle-method-80 vehicle ((obj vehicle))
@@ -1335,6 +1335,29 @@
)
(defmethod vehicle-method-124 vehicle ((obj vehicle))
(#when PC_PORT
;; vehicle hp display cheat
(when (pc-cheats? (-> *pc-settings* cheats) vehicle-health-bars)
(when (and *target* (focus-test? *target* pilot) (nonzero? (-> *target* pilot)))
(when (= (handle->process (-> *target* pilot vehicle)) obj)
(let ((x 0) (y 0)
(w 0) (h 0)
(screen-pos (new 'static 'vector4w)))
;; convert 3D -> 2D screen now (store result in screen-pos)
(when (transform-point-qword! screen-pos (-> *target* root trans))
;; set params
(set! w (the int (* 52.0 (-> *video-params* relative-x-scale))))
(set! h (the int 10.0))
(set! x (- (+ (/ (-> screen-pos x) 16) -1792) (/ w 2)))
(set! y (+ (+ (/ (-> screen-pos y) 16) -1855) 20))
(draw-health-bar x y w h (-> obj hit-points) (bucket-id debug-no-zbuf1))
)))
)
)
)
(vehicle-method-94 obj)
(vehicle-method-121 obj)
(vehicle-method-97 obj)
@@ -717,7 +717,7 @@
(if (logtest? (-> *game-info* secrets) (game-secrets hero-mode))
(set! f0-4 (* 0.6666667 f0-4))
)
(if (not (and (-> self next-state) (let ((v1-109 (-> self next-state name)))
(when (not (and (-> self next-state) (let ((v1-109 (-> self next-state name)))
(or (= v1-109 'fall-down)
(= v1-109 'overload-recover)
(= v1-109 'tail-attack)
@@ -727,6 +727,19 @@
)
)
)
(#when PC_PORT
(let* ((old-hp (-> self stage-hit-points))
(dmg-to-use (if (= (-> self stage) 3)
f0-4
(/ f0-4 2.0)))
(dmg-taken (if (logtest? (-> *game-info* secrets) (game-secrets hero-mode))
(* dmg-to-use 1.5) dmg-to-use)))
(when (> dmg-taken 0.0)
(process-spawn damage-number-metalkor dmg-taken (-> self root trans) (-> self mask))
;(send-damage-to-bar *health-bar-manager* self dmg-taken old-hp)
)
)
)
(set! (-> self stage-hit-points) (fmax 0.0 (- (-> self stage-hit-points) f0-4)))
)
)
+445
View File
@@ -0,0 +1,445 @@
;;-*-Lisp-*-
(in-package goal)
#|
Processes for the damage numbers for enemy damage and health bar for enemy health.
Enemies spawn the numbers on hit, and send a message to a health bar manager to spawn a health bar
with the appropriate settings.
We do it like this instead of adding code to draw health bars to enemy itself to avoid having to
add more fields.
|#
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; damage number and health bars
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(deftype damage-number (process)
((trans vector :inline)
(trans-2d vector4w :inline)
(on-screen? symbol)
(damage int32)
(parent-mask process-mask)
(font font-context)
(y-ofs float)
)
(:methods
(active () _type_ :state 14)
(initialize-font (_type_) font-context))
)
(defstate active (damage-number)
:virtual #t
:trans (behavior ()
(when (not (logtest? (-> *kernel-context* prevent-from-run) (-> self parent-mask)))
;; make font float upwards
(+! (-> self y-ofs) (* 1.0 (-> self clock time-adjust-ratio)))
)
;; convert 3D -> 2D screen now (result in trans-2d)
(set! (-> self on-screen?) (transform-point-qword! (-> self trans-2d) (-> self trans)))
;; position font
(set-origin! (-> self font) (+ (/ (-> self trans-2d x) 16) -1792)
(+ (/ (-> self trans-2d y) 16) -1855))
(set-depth! (-> self font) (/ (-> self trans-2d z) 16))
;; now center (we could do this earlier but it's fine)
(-! (-> self font origin x) (/ (-> self font width) 2))
;; now move it up
(-! (-> self font origin y) (-> self y-ofs))
(none))
:code (behavior ()
(let ((state-time (current-time)))
;; move up for a bit
(until (>= (- (current-time) state-time) (seconds 1))
(suspend))
;; now fade out
(set! state-time (current-time))
(until (>= (- (current-time) state-time) (seconds 0.5))
(set! (-> self font alpha) (lerp-scale 1.0 0.0 (the float (- (current-time) state-time)) 0.0 (fsec 0.5)))
(suspend))
)
)
:post (behavior ()
(when (and (-> self on-screen?) ;; text is onscreen
(pc-cheats? (-> *pc-settings* cheats) health-bars) ;; cheat enabled
)
(print-game-text (string-format "~D" (-> self damage)) (-> self font) #f 44 (bucket-id debug-no-zbuf1)))
)
)
(defmethod relocate damage-number ((obj damage-number) (diff int))
(if (nonzero? (-> obj font))
(&+! (-> obj font) diff)
)
(the-as damage-number ((the-as (function process int process) (find-parent-method damage-number 7)) obj diff))
)
(defmethod initialize-font damage-number ((self damage-number))
"create the font that will be used used."
(if (zero? (-> self font))
(set! (-> self font) (new 'process 'font-context *font-default-matrix* 0 0 0.0 (font-color default) (font-flags shadow kerning))))
(set-scale! (-> self font) (lerp-scale 0.45 0.8 (the float (-> self damage)) 1.0 15.0))
(set-flags! (-> self font) (font-flags shadow kerning large middle))
(set-width! (-> self font) 100)
(set-width! (-> self font) 50)
)
(defbehavior damage-number-init-by-other damage-number ((dmg int) (pos vector) (parent-mask process-mask))
"initialize a damage-number"
;; copy params
(set! (-> self damage) dmg)
(set! (-> self parent-mask) parent-mask)
(vector-copy! (-> self trans) pos)
;; init font
(initialize-font self)
;; process settings to still render while paused
(process-mask-clear! (-> self mask) pause)
(go-virtual active)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; METALKOR VARIATION
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(deftype damage-number-metalkor (damage-number)
((damage-metalkor float)
)
)
(defstate active (damage-number-metalkor)
:virtual #t
:post (behavior ()
(if *debug-segment*
(add-debug-x #t (bucket-id debug-no-zbuf2) (-> self trans) *color-cyan*))
(when (and (-> self on-screen?) ;; text is onscreen
(pc-cheats? (-> *pc-settings* cheats) health-bars) ;; cheat enabled
)
(let ((dmg-display *temp-string*))
(set! dmg-display
(cond
((< (abs (- (* (-> self damage-metalkor) (/ 1000.0 4.0)) (the float (/ (-> self damage) 10)))) 0.001)
(string-format "~D" (/ (-> self damage) 10)))
((< (abs (- (* (-> self damage-metalkor) (/ 10000.0 4.0)) (the float (/ (-> self damage) 1)))) 0.001)
(string-format "~,,1f" (/ (the float (-> self damage)) 10)))
(else
(string-format "~,,2f" (/ (* (-> self damage-metalkor) 2500) 10)))
))
(if #f
(format dmg-display " (~D/~,,4f)" (-> self damage) (-> self damage-metalkor)))
(print-game-text dmg-display (-> self font) #f 44 (bucket-id debug-no-zbuf1))
;(print-game-text (string-format "~D (~,,4f)" (-> self damage) (-> self damage-metalkor)) (-> self font) #f 44 (bucket-id debug-no-zbuf1))
))
)
)
(defbehavior damage-number-metalkor-init-by-other damage-number-metalkor ((dmg float) (pos vector) (parent-mask process-mask))
"initialize a damage-number-metalkor"
;; copy params
(set! (-> self damage-metalkor) dmg)
(set! (-> self damage) (/ (the int (* (-> self damage-metalkor) 10000)) 4))
(set! (-> self parent-mask) parent-mask)
(vector-copy! (-> self trans) pos)
;; init font
(initialize-font self)
(set-scale! (-> self font) (lerp-scale 0.45 0.8 (/ (the float (-> self damage)) 10) 1.0 15.0))
;; process settings to still render while paused
(process-mask-clear! (-> self mask) pause)
(go-virtual active)
)
(defun draw-health-bar ((x int) (y int) (width int) (height int) (percentage float) (bucket bucket-id))
"Draw a rectangular health bar at the given location. color fades from green to yellow to red."
(let* ((color (static-rgba 0 0 0 #x80))
(bar-w (the int (* percentage (max 0 (+ width -4)))))
(x2 (+ x width))
(bx2 (+ x 2 bar-w)))
(cond
((>= percentage 0.6)
;; fade from green -> yellow
(set! (-> color r) (the int (lerp-scale (the float (-> *color-green* r)) (the float (-> *color-yellow* r)) percentage 1.0 0.55)))
(set! (-> color g) (the int (lerp-scale (the float (-> *color-green* g)) (the float (-> *color-yellow* g)) percentage 1.0 0.55)))
(set! (-> color b) (the int (lerp-scale (the float (-> *color-green* b)) (the float (-> *color-yellow* b)) percentage 1.0 0.55)))
)
(else
;; fade from yellow -> red
(set! (-> color r) (the int (lerp-scale (the float (-> *color-yellow* r)) (the float (-> *color-red* r)) percentage 0.55 0.1)))
(set! (-> color g) (the int (lerp-scale (the float (-> *color-yellow* g)) (the float (-> *color-red* g)) percentage 0.55 0.1)))
(set! (-> color b) (the int (lerp-scale (the float (-> *color-yellow* b)) (the float (-> *color-red* b)) percentage 0.55 0.1)))
)
)
(with-dma-buffer-add-bucket ((buf (-> *display* frames (-> *display* on-screen) debug-buf))
bucket
)
(cond
((< x -2)
(+! width x)
(+! bar-w (+ x 2)))
((< x 0)
(+! width x))
((>= x2 512)
(-! width (- x2 512)))
)
(cond
((>= bx2 512)
(-! bar-w (- bx2 512)))
)
(cond
((< y -2)
(+! height y))
((< y 0)
(+! height y))
)
(draw-sprite2d-xy buf x y (max 0 width) (max 0 height) (new 'static 'rgba :a #x40))
(draw-sprite2d-xy buf (+ x 2) (+ y 2) (max 0 bar-w) (max 0 (+ height -4)) color)
)
)
#f
)
(deftype health-bar (process)
((ppointer (pointer health-bar) :override)
(trans-2d vector4w :inline)
(width float)
(height float)
(on-screen? symbol)
(font font-context)
(hit-points-max float)
(hit-points float)
;; who this bar is for
(owner handle)
;; linked list fields
(prev-bar (pointer health-bar))
(next-bar (pointer health-bar))
)
(:methods
(idle () _type_ :state 14))
)
(defmethod relocate health-bar ((obj health-bar) (diff int))
(if (nonzero? (-> obj font))
(&+! (-> obj font) diff)
)
(the-as health-bar ((the-as (function process int process) (find-parent-method health-bar 7)) obj diff))
)
(deftype health-bar-manager (basic)
((head (pointer health-bar))
(tail (pointer health-bar))
)
(:methods
(new (symbol type) _type_)
(append-to-list (_type_ (pointer health-bar)) (pointer health-bar))
(remove-from-list (_type_ (pointer health-bar)) (pointer health-bar))
(get-bar-for-process (_type_ process-drawable) (pointer health-bar))
(send-damage-to-bar (_type_ process-drawable int int) (pointer health-bar))
(set-proc-bar-hit-points (_type_ process-drawable int) (pointer health-bar))
)
)
(defmethod new health-bar-manager ((allocation symbol) (type-to-make type))
(let ((obj (object-new allocation type-to-make (the-as int (-> type-to-make size)))))
(set! (-> obj head) #f)
(set! (-> obj tail) #f)
obj)
)
(defmethod append-to-list health-bar-manager ((obj health-bar-manager) (bar-ptr (pointer health-bar)))
"add a health bar to the end of the linked list"
(set! (-> bar-ptr 0 prev-bar) (-> obj tail))
(cond
((-> obj tail)
;; list has stuff
(set! (-> obj tail 0 next-bar) bar-ptr)
)
(else
;; no tail means list is empty. fill head.
(set! (-> obj head) bar-ptr)
)
)
(set! (-> obj tail) bar-ptr)
bar-ptr)
(defmethod remove-from-list health-bar-manager ((obj health-bar-manager) (bar-ptr (pointer health-bar)))
"remove a health bar from the linked list. call this when deactivating it"
(if (= (-> obj head) bar-ptr)
(set! (-> obj head) (-> bar-ptr 0 next-bar)))
(if (= (-> obj tail) bar-ptr)
(set! (-> obj tail) (-> bar-ptr 0 prev-bar)))
(if (-> bar-ptr 0 next-bar)
(set! (-> bar-ptr 0 next-bar 0 prev-bar) (-> bar-ptr 0 prev-bar)))
(if (-> bar-ptr 0 prev-bar)
(set! (-> bar-ptr 0 prev-bar 0 next-bar) (-> bar-ptr 0 next-bar)))
bar-ptr)
(defmethod get-bar-for-process health-bar-manager ((obj health-bar-manager) (proc process-drawable))
"return the health bar associated with that process. #f = not found"
(let ((cur-bar (-> obj head)))
(while cur-bar
(if (= (handle->process (-> cur-bar 0 owner)) proc)
(return cur-bar))
(set! cur-bar (-> cur-bar 0 next-bar))
)
)
(the (pointer health-bar) #f))
(define *health-bar-manager* (new 'global 'health-bar-manager))
(defstate idle (health-bar)
:virtual #t
:event (behavior ((from process) (argc int) (msg symbol) (block event-message-block))
(case msg
(('damage)
(-! (-> self hit-points) (the float (the-as int (-> block param 0))))
#t)
(('set-hit-points)
(set! (-> self hit-points) (the float (the-as int (-> block param 0))))
#t)
)
)
:trans (behavior ()
;; convert 3D -> 2D screen now (result in trans-2d)
(when (handle->process (-> self owner))
(set! (-> self on-screen?) (transform-point-qword! (-> self trans-2d) (-> (the process-drawable (handle->process (-> self owner))) root trans)))
)
;; set store width and height.
(set! (-> self width) (* (-> self font width) (-> *video-params* relative-x-scale)))
(set! (-> self height) (-> self font height))
;; position font
(set-origin! (-> self font) (+ (/ (-> self trans-2d x) 16) -1792)
(+ (/ (-> self trans-2d y) 16) -1855))
(set-depth! (-> self font) (/ (-> self trans-2d z) 16))
;; now center (we could do this earlier but it's fine)
(-! (-> self font origin x) (/ (-> self width) 2))
(none))
:code (behavior ()
(while (and (handle->process (-> self owner)) (not (case (-> (handle->process (-> self owner)) next-state name) (('inactive 'hidden) #t))))
(suspend))
)
:post (behavior ()
(when (and (-> self on-screen?) ;; text is onscreen
(pc-cheats? (-> *pc-settings* cheats) health-bars) ;; cheat enabled
(> (meters 160) (vector-vector-distance (-> (the process-drawable (handle->process (-> self owner))) root trans) (math-camera-pos))))
(draw-health-bar (the int (-> self font origin x)) (the int (-> self font origin y))
(the int (-> self width)) (the int (-> self height))
(/ (-> self hit-points) (-> self hit-points-max))
(bucket-id debug-no-zbuf1))
;(print-game-text (string-format "~,,0f/~,,0f" (-> self hit-points) (-> self hit-points-max)) (-> self font) #f 44 (bucket-id debug-no-zbuf1))
)
)
)
(defmethod deactivate health-bar ((self health-bar))
(remove-from-list *health-bar-manager* (process->ppointer self))
((method-of-type process deactivate) self)
(none)
)
(defbehavior health-bar-init-by-other health-bar ((hit-points int) (hit-points-max int) (owner handle))
"initialize a health-bar"
;; copy params
(set! (-> self hit-points-max) (the float hit-points-max))
(set! (-> self hit-points) (the float hit-points))
;; set owner
(set! (-> self owner) owner)
;; linked list fields
(set! (-> self prev-bar) #f)
(set! (-> self next-bar) #f)
(append-to-list *health-bar-manager* (the (pointer health-bar) (process->ppointer self)))
;; init font
(set! (-> self font) (new 'process 'font-context *font-default-matrix* 0 0 0.0 (font-color default) (font-flags shadow kerning)))
(set-scale! (-> self font) 0.35)
(set-flags! (-> self font) (font-flags shadow kerning large middle left))
(set-width! (-> self font) 34)
(set-height! (-> self font) 10)
;; process settings to still render while paused
(process-mask-clear! (-> self mask) pause)
;; ready to handle events immediately
(set! (-> self event-hook) (-> (method-of-object self idle) event))
(go-virtual idle)
)
(defmethod send-damage-to-bar health-bar-manager ((obj health-bar-manager) (from process-drawable) (damage int) (hit-points-old int))
"send damage and hit point information of an enemy to its health bar. creates one if needed."
(let ((the-bar (get-bar-for-process obj from)))
(cond
(the-bar
(send-event (ppointer->process the-bar) 'damage damage)
)
(else
(set! the-bar (process-spawn health-bar (- hit-points-old damage) hit-points-old (process->handle from)))
)
)
the-bar)
)
(defmethod set-proc-bar-hit-points health-bar-manager ((obj health-bar-manager) (proc process-drawable) (hit-points int))
"simply set the hit points (not max hit points) of a process's health bar"
(let ((the-bar (get-bar-for-process obj proc)))
(send-event (ppointer->process the-bar) 'set-hit-points hit-points)
the-bar)
)
+92 -5
View File
@@ -11,14 +11,41 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; version: 0.1.0.2
(defconstant PC_KERNEL_VERSION (static-pckernel-version 0 1 0 2))
;; version: 0.1.1.2
(defconstant PC_KERNEL_VERSION (static-pckernel-version 0 1 1 2))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; types and enums
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; cheats
(defconstant PC_CHEAT_MAX 20) ;; number of cheats
(defenum pc-cheats
:bitfield #t
:type uint64
(eco-green)
(eco-red)
(eco-blue)
(eco-yellow)
(turbo-board)
(health-bars)
(vehicle-health-bars)
(vehicle-invuln)
(statistics)
(suck-in-all)
(music-player)
(no-textures)
(fast-movies)
(slow-movies)
(fast-speed)
(slow-speed)
(fast-travel)
(orb-tracker)
(real-time-of-day)
(city-peace)
)
;; pc enum for languages. this is the game's languages + custom ones.
(defenum pc-language
:type uint16
@@ -49,6 +76,10 @@
;; The Jak 2 version of the pc-settings object.
(deftype pc-settings-jak2 (pc-settings)
(
(cheats pc-cheats)
(cheats-revealed pc-cheats)
(cheats-purchased pc-cheats)
(fast-airlock? symbol)
(fast-elevator? symbol)
(fast-progress? symbol)
@@ -100,6 +131,16 @@
(set! (-> obj fast-progress?) #f)
0)
(defmethod reset-extra pc-settings-jak2 ((obj pc-settings-jak2) (call-handlers symbol))
"Set the default goodies settings"
((method-of-type pc-settings reset-extra) obj call-handlers)
(set! (-> obj cheats) (pc-cheats))
(set! (-> obj cheats-revealed) (pc-cheats))
(set! (-> obj cheats-purchased) (pc-cheats))
0)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; other
@@ -109,9 +150,55 @@
(defun get-video-params () *video-params*)
(define *progress-speed* 1.5)
(define *airlock-speed* 1.75)
(define *airlock-close-speed* 1.75)
(defenum pc-cheat-state-flag
:bitfield #t
:type uint8
(turbo-board) ;; should turbo board be used
(clear-time-mod)
)
(deftype pc-cheat-state (structure)
((progress-speed float)
(airlock-speed float)
(airlock-close-speed float)
(turbo-board-speed float)
(flags pc-cheat-state-flag)
)
)
(define *pc-cheat-state* (new 'static 'pc-cheat-state
:progress-speed 1.5
:airlock-speed 1.75
:airlock-close-speed 1.75
:turbo-board-speed 1.5
))
(defmacro cheat-state-flag? (&rest flags)
"are the specified flags enabled?"
`(logtest? (-> *pc-cheat-state* flags) (pc-cheat-state-flag ,@flags)))
(defmacro set-cheat-state-flag! (&rest flags)
"set the specified flags"
`(logior! (-> *pc-cheat-state* flags) (pc-cheat-state-flag ,@flags)))
(defmacro clear-cheat-state-flag! (&rest flags)
"clear the specified flags"
`(logclear! (-> *pc-cheat-state* flags) (pc-cheat-state-flag ,@flags)))
(defmacro give-cheat! (&rest cheats)
`(begin
(logior! (-> *pc-settings* cheats) (pc-cheats ,@cheats))
(logior! (-> *pc-settings* cheats-revealed) (pc-cheats ,@cheats))
(logior! (-> *pc-settings* cheats-purchased) (pc-cheats ,@cheats))
)
)
(defmacro lock-cheat! (&rest cheats)
`(begin
(logclear! (-> *pc-settings* cheats) (pc-cheats ,@cheats))
(logclear! (-> *pc-settings* cheats-revealed) (pc-cheats ,@cheats))
(logclear! (-> *pc-settings* cheats-purchased) (pc-cheats ,@cheats))
)
)
+69 -2
View File
@@ -10,6 +10,7 @@
(define-extern get-active-mission-description (function discord-info string))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; methods
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -107,16 +108,72 @@
(defmethod get-airlock-speed pc-settings-jak2 ((obj pc-settings-jak2))
"return the current speed modifier for airlocks"
(if (-> obj fast-airlock?)
*airlock-speed*
(-> *pc-cheat-state* airlock-speed)
1.0))
(defmethod get-airlock-close-speed pc-settings-jak2 ((obj pc-settings-jak2))
"return the current closing speed modifier for airlocks"
(if (-> obj fast-airlock?)
*airlock-close-speed*
(-> *pc-cheat-state* airlock-close-speed)
1.0))
(defmethod update-cheats pc-settings-jak2 ((obj pc-settings-jak2))
"run cheats."
;; run cheats here.
;;;;;;;;;;;;;;;;;;;
(when (pc-cheats? (-> obj cheats) real-time-of-day)
(let ((date (new 'stack-no-clear 'scf-time)))
(scf-get-time date)
(when (zero? (-> date stat))
(let* ((cur-time (-> *display* bg-clock frame-counter))
(day-len (seconds 1440)) ;; a full in-game day
(want-hour (bcd->dec (-> date hour)))
(want-minute (bcd->dec (-> date minute)))
(target-hour-frame (/ (the int (* (fsec 3600) want-hour)) 60))
(target-minute-frame (/ (the int (* (fsec 60) want-minute)) 60))
)
(set! (-> *display* bg-clock frame-counter) (+ (- cur-time (mod cur-time day-len)) day-len (+ target-hour-frame target-minute-frame)))
))
))
;; turbo jet board cheat
(cond
((and (pc-cheats? (-> *pc-settings* cheats) turbo-board)
*target*
(focus-test? *target* board)
(case (-> *load-state* vis-nick)
(('ctysluma 'ctyslumb 'ctyslumc
'ctygena 'ctygenb 'ctygenc
'ctyport 'ctymarka 'ctymarkb
'ctypal 'ctyfarma 'ctyfarmb
'stadium 'ctyinda 'ctyindb) #t)
(('forest) #t #|(not (task-node-open? (game-task-node forest-scouts-pegasus)))|#)))
(set-setting! 'string-spline-max-move 'abs (* (-> *pc-cheat-state* turbo-board-speed) (meters 2)) 0)
(set-setting! 'string-spline-accel 'abs (* (-> *pc-cheat-state* turbo-board-speed) (meters 0.045)) 0)
(set-setting! 'string-spline-max-move-player 'abs (* (-> *pc-cheat-state* turbo-board-speed) (meters 1.5)) 0)
(set-setting! 'string-spline-accel-player 'abs (* (-> *pc-cheat-state* turbo-board-speed) (meters 0.035)) 0)
(set-cheat-state-flag! turbo-board)
)
(else
(remove-setting! 'string-spline-max-move)
(remove-setting! 'string-spline-accel)
(remove-setting! 'string-spline-max-move-player)
(remove-setting! 'string-spline-accel-player)
(clear-cheat-state-flag! turbo-board)
)
)
(pc-set-gfx-hack (pc-gfx-hack no-tex) (pc-cheats? (-> obj cheats) no-textures))
;; run cheats end!!!
;;;;;;;;;;;;;;;;;;;;
0)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; file I/O
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -132,6 +189,9 @@
(("fast-elevator?") (set! (-> obj fast-elevator?) (file-stream-read-symbol file)))
(("fast-progress?") (set! (-> obj fast-progress?) (file-stream-read-symbol file)))
(("text-language") (set! (-> obj text-language) (the-as pc-language (file-stream-read-int file))))
(("cheats") (set! (-> obj cheats) (the-as pc-cheats (file-stream-read-int file))))
(("cheats-revealed") (set! (-> obj cheats-revealed) (the-as pc-cheats (file-stream-read-int file))))
(("cheats-purchased") (set! (-> obj cheats-purchased) (the-as pc-cheats (file-stream-read-int file))))
)
0)
@@ -144,6 +204,9 @@
(format file " (fast-elevator? ~A)~%" (-> obj fast-elevator?))
(format file " (fast-progress? ~A)~%" (-> obj fast-progress?))
(format file " (text-language ~D)~%" (-> obj text-language))
(format file " (cheats #x~x)~%" (-> obj cheats))
(format file " (cheats-revealed #x~x)~%" (-> obj cheats-revealed))
(format file " (cheats-purchased #x~x)~%" (-> obj cheats-purchased))
0)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -158,6 +221,8 @@
;;;; other
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun draw-build-revision ()
(with-dma-buffer-add-bucket ((buf (-> (current-frame) global-buf))
(bucket-id debug-no-zbuf1))
@@ -179,6 +244,8 @@
(format #t "~%"))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; process pools
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -40,4 +40,19 @@
)
(deftype menu-aspect-ratio-custom-option (menu-option)
()
)
(deftype progress-cheat-info (basic)
((name text-id)
(unlock text-id)
(flag pc-cheats)
(avail-after game-task-node)
)
)
+1
View File
@@ -1,5 +1,6 @@
@echo off
cd ..\..
task set-game-jak2
task set-decomp-ntscv1
task extract
pause
+6
View File
@@ -0,0 +1,6 @@
@echo off
cd ..\..
task set-game-jak2
task set-decomp-pal
task extract
pause
+1 -1
View File
@@ -428,7 +428,7 @@
(view-anims () _type_ :state 45)
(enemy-method-46 (_type_ int) none 46)
(enemy-method-47 (_type_ vector) float 47)
(enemy-method-48 (_type_ process event-message-block) int 48)
(take-damage-from-attack (_type_ process event-message-block) int 48)
(enemy-method-49 (_type_) time-frame :behavior enemy 49)
(enemy-method-50 (_type_ vector) vector 50)
(enemy-method-51 (_type_) float 51)
+2 -2
View File
@@ -1808,7 +1808,7 @@ This commonly includes things such as:
(send-event (ppointer->process (-> obj parent)) 'child-hit)
0
(if (not *debug-unkillable*)
(enemy-method-48 obj arg0 arg3)
(take-damage-from-attack obj arg0 arg3)
)
(let ((s2-1 (the-as attack-info (enemy-method-58 obj arg0 arg3))))
(when s2-1
@@ -2098,7 +2098,7 @@ This commonly includes things such as:
)
;; definition for method 48 of type enemy
(defmethod enemy-method-48 enemy ((obj enemy) (arg0 process) (arg1 event-message-block))
(defmethod take-damage-from-attack enemy ((obj enemy) (arg0 process) (arg1 event-message-block))
(let* ((v1-1 (damage-amount-from-attack obj arg0 arg1))
(s5-0 (-> obj hit-points))
(s4-1 (max 0 (- s5-0 v1-1)))
+2 -2
View File
@@ -1,8 +1,8 @@
;;-*-Lisp-*-
(in-package goal)
;; definition for symbol *traffic-manager*, type process
(define *traffic-manager* (the-as process #f))
;; definition for symbol *traffic-manager*, type traffic-manager
(define *traffic-manager* (the-as traffic-manager #f))
;; definition for symbol *ctywide-entity*, type entity
(define *ctywide-entity* (the-as entity #f))
+1 -1
View File
@@ -303,7 +303,7 @@
(race-number-turbos int32 :offset-assert 516)
(bot-health float 3 :offset-assert 520)
(demo-state uint32 :offset-assert 532)
(wanted-flash basic :offset-assert 536)
(wanted-flash symbol :offset-assert 536)
(distance float :offset-assert 540)
(kiosk-timeout uint64 :offset-assert 544)
(pause-start-time time-frame :offset-assert 552)
@@ -854,7 +854,7 @@
)
)
)
(v1-10 *traffic-manager*)
(v1-10 (the-as process *traffic-manager*))
)
(cond
((not (logtest? (-> arg1 waypoint-bits) 1))
+91 -91
View File
@@ -2488,48 +2488,48 @@ Process is recycled and moved to reserved, if it deactivates."
:ped-tazer (new 'static 'traffic-guard-type-settings
:target-count 5
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:ped-rifle (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 2
:rand-shot-count 1
)
:ped-grenade (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:ped-roboguard (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:bike-turret (new 'static 'traffic-guard-type-settings
:target-count 1
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x5dc
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 5)
:shot-count 2
:rand-shot-count 1
)
:hellcat-turret (new 'static 'traffic-guard-type-settings
:target-count 1
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x5dc
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 5)
:shot-count 2
:rand-shot-count 1
)
@@ -2538,46 +2538,46 @@ Process is recycled and moved to reserved, if it deactivates."
:ped-tazer (new 'static 'traffic-guard-type-settings
:target-count 5
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:ped-rifle (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 2
:rand-shot-count 1
)
:ped-grenade (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:ped-roboguard (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:bike-turret (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x5dc
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 5)
:shot-count 2
:rand-shot-count 1
)
:hellcat-turret (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x5dc
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 5)
:shot-count 2
:rand-shot-count 1
)
@@ -2586,48 +2586,48 @@ Process is recycled and moved to reserved, if it deactivates."
:ped-tazer (new 'static 'traffic-guard-type-settings
:target-count 3
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:ped-rifle (new 'static 'traffic-guard-type-settings
:target-count 4
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 2
:rand-shot-count 1
)
:ped-grenade (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:ped-roboguard (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:bike-turret (new 'static 'traffic-guard-type-settings
:target-count 2
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x5dc
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 5)
:shot-count 2
:rand-shot-count 1
)
:hellcat-turret (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x5dc
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 5)
:shot-count 2
:rand-shot-count 1
)
@@ -2636,49 +2636,49 @@ Process is recycled and moved to reserved, if it deactivates."
:ped-tazer (new 'static 'traffic-guard-type-settings
:target-count 2
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:ped-rifle (new 'static 'traffic-guard-type-settings
:target-count 7
:inaccuracy 0.25
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 2
:rand-shot-count 1
)
:ped-grenade (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:ped-roboguard (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:bike-turret (new 'static 'traffic-guard-type-settings
:target-count 3
:inaccuracy 0.25
:acquire-delay #xe1
:shot-delay #x4b
:burst-delay #x4b0
:acquire-delay (seconds 0.75)
:shot-delay (seconds 0.25)
:burst-delay (seconds 4)
:shot-count 2
:rand-shot-count 1
)
:hellcat-turret (new 'static 'traffic-guard-type-settings
:target-count 2
:inaccuracy 0.25
:acquire-delay #xe1
:shot-delay #x4b
:burst-delay #x4b0
:acquire-delay (seconds 0.75)
:shot-delay (seconds 0.25)
:burst-delay (seconds 4)
:shot-count 2
:rand-shot-count 1
)
@@ -2687,49 +2687,49 @@ Process is recycled and moved to reserved, if it deactivates."
:ped-tazer (new 'static 'traffic-guard-type-settings
:target-count 2
:inaccuracy 0.125
:acquire-delay #x96
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 0.5)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:ped-rifle (new 'static 'traffic-guard-type-settings
:target-count 7
:inaccuracy 0.125
:acquire-delay #x96
:shot-delay #x2d
:burst-delay #x258
:acquire-delay (seconds 0.5)
:shot-delay (seconds 0.15)
:burst-delay (seconds 2)
:shot-count 2
:rand-shot-count 2
)
:ped-grenade (new 'static 'traffic-guard-type-settings
:inaccuracy 0.125
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x384
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 3)
:shot-count 1
)
:ped-roboguard (new 'static 'traffic-guard-type-settings
:inaccuracy 0.5
:acquire-delay #x12c
:shot-delay #x4b
:burst-delay #x258
:acquire-delay (seconds 1)
:shot-delay (seconds 0.25)
:burst-delay (seconds 2)
:shot-count 1
)
:bike-turret (new 'static 'traffic-guard-type-settings
:target-count 3
:inaccuracy 0.125
:acquire-delay #x96
:shot-delay #x4b
:burst-delay #x384
:acquire-delay (seconds 0.5)
:shot-delay (seconds 0.25)
:burst-delay (seconds 3)
:shot-count 2
:rand-shot-count 2
)
:hellcat-turret (new 'static 'traffic-guard-type-settings
:target-count 2
:inaccuracy 0.125
:acquire-delay #x96
:shot-delay #x4b
:burst-delay #x384
:acquire-delay (seconds 0.5)
:shot-delay (seconds 0.25)
:burst-delay (seconds 3)
:shot-count 2
:rand-shot-count 2
)
@@ -2988,7 +2988,7 @@ Process is recycled and moved to reserved, if it deactivates."
(s5-0
(when (not (logtest? (-> obj alert-state flags) (traffic-alert-flag alarm-on)))
(logior! (-> obj alert-state flags) (traffic-alert-flag alarm-on))
(set! (-> *game-info* wanted-flash) (the-as basic #t))
(set! (-> *game-info* wanted-flash) #t)
(if (= (-> *setting-control* user-current music) 'city1)
(set-setting! 'sound-mode #f 0.0 1)
)
@@ -12,9 +12,9 @@
;; definition for symbol *transport-turret-state-info*, type traffic-guard-type-settings
(define *transport-turret-state-info* (new 'static 'traffic-guard-type-settings
:acquire-delay #x1c2
:shot-delay #x4b
:burst-delay #x384
:acquire-delay (seconds 1.5)
:shot-delay (seconds 0.25)
:burst-delay (seconds 3)
:shot-count 2
:rand-shot-count 1
)
@@ -696,7 +696,7 @@
(vehicle-method-109 (_type_) none 109)
(vehicle-method-110 (_type_) none 110)
(vehicle-method-111 (_type_ object target) none 111)
(vehicle-method-112 (_type_ object) none 112)
(decrease-traffic-alert-level (_type_ int) int 112)
(vehicle-method-113 (_type_) none 113)
(vehicle-method-114 (_type_) none 114)
(vehicle-method-115 (_type_ vector) none 115)
@@ -1208,11 +1208,9 @@ This commonly includes things such as:
)
;; definition for method 112 of type vehicle
;; WARN: Return type mismatch int vs none.
(defmethod vehicle-method-112 vehicle ((obj vehicle) (arg0 object))
(decrease-alert-level (-> obj controller traffic) (the-as int arg0))
(defmethod decrease-traffic-alert-level vehicle ((obj vehicle) (arg0 int))
(decrease-alert-level (-> obj controller traffic) arg0)
0
(none)
)
;; definition for method 80 of type vehicle