Skip to content

Commit

Permalink
[jak2] implement pc cheats in menu (#3275)
Browse files Browse the repository at this point in the history
Adds the opengoal cheats to the secrets menu. Only cheats that are fully
functional and unlockable are there right now, which is eight cheats.

This update will reset most Jak 2 settings.

Also fixes #3274 .
  • Loading branch information
ManDude authored Dec 28, 2023
1 parent a01d78c commit 349919f
Show file tree
Hide file tree
Showing 23 changed files with 1,017 additions and 311 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"comments": true,
"strings": true
},
"editor.wordBasedSuggestions": true,
"editor.wordBasedSuggestions": "matchingDocuments",
"editor.snippetSuggestions": "top"
},
"python.formatting.provider": "black",
Expand Down
7 changes: 7 additions & 0 deletions decompiler/config/jak2/all-types.gc
Original file line number Diff line number Diff line change
Expand Up @@ -7382,6 +7382,13 @@
(progress-cheats-weather-bad #x1261)
(progress-cheats-weather-good #x1262)
(progress-cheats-hijack-lines #x1263)
(progress-cheats-locked #x1264)
(progress-cheats-turbo-board-unlock #x1265)
(progress-cheats-health-bars-unlock #x1266)
(progress-cheats-vehicle-health-bars-unlock #x1267)
(progress-cheats-statistics-unlock #x1268)
(progress-cheats-suck-in-all-unlock #x1269)
(progress-cheats-fast-travel-unlock #x126a)
(progress-camera-options #x1280)
(progress-camera-options-first-horz #x1281)
(progress-camera-options-first-vert #x1282)
Expand Down
17 changes: 17 additions & 0 deletions decompiler/config/jak2/ntsc_v1/var_names.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -4639,5 +4639,22 @@
"vars": {
"t1-3": ["imp-sound", "sound-name"]
}
},
"(method 9 menu-secret-option)": {
"vars": {
"s5-1": "hero?",
"s3-0": "min-item",
"s2-0": "max-item",
"s5-2": "scroll-sound?",
"v1-74": "item",
"a0-54": "flag",
"a1-9": "on-off?"
}
},
"(method 10 menu-unlocked-menu-option)": {
"vars": {
"s5-0": "secrets",
"f30-0": "alpha"
}
}
}
7 changes: 7 additions & 0 deletions game/assets/jak2/text/game_custom_text_en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@
"1261": "Bad Weather",
"1262": "Nice Weather",
"1263": "Vehicle Hijack Voice Lines",
"1264": "Locked",
"1265": "Hit all 3 valves and find Mar's Statue in \"~S\" in under ~D seconds",
"1266": "Reduce Haven City's population count by ~D",
"1267": "Reduce Haven City's vehicle count by ~D",
"1268": "Hunt every species of Metal Head",
"1269": "Use the JET-Board to break open containers",
"126a": "Transport the Rift Rider while leaving Samos and Young Samos unscathed",
"1280": "Camera Options",
"1281": "Left/Right (1st Person)",
"1282": "Up/Down (1st Person)",
Expand Down
2 changes: 1 addition & 1 deletion game/graphics/opengl_renderer/loader/Loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ void Loader::update_blocking(TexturePool& tex_pool) {
}

const std::string* Loader::get_most_unloadable_level() {
for (const auto& [name, lev] : m_loaded_tfrag3_levels) {
for (auto& [name, lev] : m_loaded_tfrag3_levels) {
if (lev->frames_since_last_used > 180 &&
std::find(m_desired_levels.begin(), m_desired_levels.end(), name) ==
m_desired_levels.end()) {
Expand Down
18 changes: 10 additions & 8 deletions game/sound/989snd/loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,14 @@ SFXBlock* SFXBlock::ReadBlock(nonstd::span<u8> bank_data, nonstd::span<u8> sampl
sfx.Flags.flags = data.read<u16>();

u32 FirstSFXGrain = data.read<u32>();

auto grains = data.at(FirstGrain + FirstSFXGrain);
for (auto& grain : sfx.Grains) {
if (block->Version < 2) {
grain = ReadGrainV1(grains, block->SampleData.get());
} else {
grain = ReadGrainV2(grains, data.at(GrainData), block->SampleData.get());
if (NumGrains) {
auto grains = data.at(FirstGrain + FirstSFXGrain);
for (auto& grain : sfx.Grains) {
if (block->Version < 2) {
grain = ReadGrainV1(grains, block->SampleData.get());
} else {
grain = ReadGrainV2(grains, data.at(GrainData), block->SampleData.get());
}
}
}
}
Expand All @@ -276,7 +277,8 @@ SFXBlock* SFXBlock::ReadBlock(nonstd::span<u8> bank_data, nonstd::span<u8> sampl
data.set_seek(BlockNames);
auto names = data.read<SFXBlockNames>();

char buf[16];
char buf[17];
buf[16] = 0;
strncpy(buf, (char*)names.BlockName, 8);
block->Name = buf;

Expand Down
7 changes: 7 additions & 0 deletions goal_src/goal-lib.gc
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,13 @@
`(& (-> ,@args))
)

(defmacro xor (a b)
"xor for #t and #f"
(with-gensyms (a-temp b-temp)
`(let ((,a-temp ,a) (,b-temp ,b))
(or (and ,a-temp (not ,b-temp)) (and (not ,a-temp) ,b-temp))))
)

(defmacro logior! (place amount)
`(set! ,place (logior ,place ,amount))
)
Expand Down
3 changes: 0 additions & 3 deletions goal_src/jak1/pc/pckernel-common.gc
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,6 @@

(none))

;; where we store the input progress for the cheat codes. make sure there's enough space for all cheats.
(define *pc-cheat-temp* (new 'global 'inline-array 'uint8 PC_CHEAT_MAX))

(defmacro pc-cheat-toggle-and-tune (cheats-var cheat)
"quickly toggle a cheat code and play an appropriate sound"
`(begin
Expand Down
3 changes: 3 additions & 0 deletions goal_src/jak1/pc/pckernel.gc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
(-> *setting-control* default language)
)

;; where we store the input progress for the cheat codes. make sure there's enough space for all cheats.
(define *pc-cheat-temp* (new 'global 'inline-array 'uint8 PC_CHEAT_MAX))

(defmethod update-cheats pc-settings-jak1 ((obj pc-settings-jak1))
"run cheats."

Expand Down
25 changes: 25 additions & 0 deletions goal_src/jak2/engine/gfx/mood/mood.gc
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,20 @@ Returns the current value of `lightning-id`"
(-> this target-interp fog)
(* (/ 1.0 (-> this speed-interp fog)) (seconds-per-frame))
)
(#when PC_PORT ;; og:preserve-this
(cond
((pc-cheats? (-> *pc-settings* cheats) weather-good)
(set! (-> this current-interp cloud) 0.0)
(set! (-> this current-interp fog) 0.0)
(logclear! (-> *pc-settings* cheats) (pc-cheats weather-bad))
)
((pc-cheats? (-> *pc-settings* cheats) weather-bad)
(set! (-> this current-interp cloud) 1.0)
(set! (-> this current-interp fog) 1.0)
(logclear! (-> *pc-settings* cheats) (pc-cheats weather-good))
)
)
)
(when (!= (-> this time-until-random cloud) -99.0)
(set! (-> this time-until-random cloud) (- (-> this time-until-random cloud) (* 300.0 (seconds-per-frame))))
(when (< (-> this time-until-random cloud) 0.0)
Expand Down Expand Up @@ -1232,12 +1246,23 @@ Returns the current value of `lightning-id`"
(let* ((f0-114 (fmax 0.0 (fmin (* 4.0 (fmax 0.0 (+ -0.5 f26-2)) (fmax 0.0 (+ -0.5 f30-2))) f28-2)))
(f30-3 (fmin 0.75 f0-114))
)
(#when PC_PORT ;; og:preserve-this
(cond
((pc-cheats? (-> *pc-settings* cheats) weather-good)
(set! f30-3 0.0)
)
((pc-cheats? (-> *pc-settings* cheats) weather-bad)
(set! f30-3 f0-114)
)
)
)
(set! (-> *setting-control* user-default rain) f30-3)
(cond
((and (or (and (level-get-target-inside *level*) (= (-> (level-get-target-inside *level*) name) 'nest))
(< 0.0 (-> *setting-control* user-current rain))
)
(!= *master-mode* 'progress)
(#if PC_PORT (not (pc-cheats? (-> *pc-settings* cheats) weather-good)) #t) ;; og:preserve-this
)
(gen-lightning-and-thunder! this)
(cond
Expand Down
2 changes: 1 addition & 1 deletion goal_src/jak2/engine/target/board/target-board.gc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
(the text-id (+ (text-id trick-board-none) trick)))

(defmethod render-combo board-trick-tracker ((this board-trick-tracker))
(when (not (-> *pc-settings* jetboard-trick-text?))
(when (not (pc-cheats? (-> *pc-settings* cheats) board-tricks))
(return 0))

(clear *temp-string*)
Expand Down
Loading

0 comments on commit 349919f

Please sign in to comment.