[Enhancement] Always Win Doggy Race (#256)

* Always Win Doggy Race Hookified

* uint8_t -> bool

* Trailing comma

---------

Co-authored-by: Archez <Archez@users.noreply.github.com>
This commit is contained in:
aMannus
2024-05-22 09:05:03 -05:00
committed by Garrett Cox
co-authored by Archez
parent a994c13b49
commit bda4845572
7 changed files with 55 additions and 1 deletions
+12
View File
@@ -39,6 +39,12 @@ static std::unordered_map<Ship::WindowBackend, const char*> windowBackendsMap =
{ Ship::WindowBackend::GX2, "GX2" }
};
static const std::unordered_map<int32_t, const char*> alwaysWinDoggyraceOptions = {
{ ALWAYS_WIN_DOGGY_RACE_OFF, "Off" },
{ ALWAYS_WIN_DOGGY_RACE_MASKOFTRUTH, "When owning Mask of Truth" },
{ ALWAYS_WIN_DOGGY_RACE_ALWAYS, "Always" },
};
namespace BenGui {
void DrawMenuBarIcon() {
@@ -353,6 +359,12 @@ void DrawEnhancementsMenu() {
ImGui::EndMenu();
}
if (UIWidgets::BeginMenu("Minigames")) {
UIWidgets::CVarCombobox("Always Win Doggy Race", "gEnhancements.Minigames.AlwaysWinDoggyRace", alwaysWinDoggyraceOptions);
ImGui::EndMenu();
}
if (UIWidgets::BeginMenu("Modes")) {
if (UIWidgets::CVarCheckbox("Play As Kafei", "gModes.PlayAsKafei", {
.tooltip = "Requires scene reload to take effect."
+3
View File
@@ -13,6 +13,9 @@ void InitEnhancements() {
RegisterFierceDeityAnywhere();
RegisterNoBlastMaskCooldown();
// Minigames
RegisterAlwaysWinDoggyRace();
// Restorations
RegisterSideRoll();
+7
View File
@@ -8,11 +8,18 @@
#include "Masks/FierceDeityAnywhere.h"
#include "Masks/NoBlastMaskCooldown.h"
#include "Masks/FastTransformation.h"
#include "Minigames/AlwaysWinDoggyRace.h"
#include "Cutscenes/SkipEntranceCutscenes.h"
#include "Cutscenes/HideTitleCards.h"
#include "Restorations/SideRoll.h"
#include "Graphics/PlayAsKafei.h"
enum AlwaysWinDoggyRaceOptions {
ALWAYS_WIN_DOGGY_RACE_OFF,
ALWAYS_WIN_DOGGY_RACE_MASKOFTRUTH,
ALWAYS_WIN_DOGGY_RACE_ALWAYS,
};
#ifdef __cplusplus
extern "C" {
#endif
@@ -32,6 +32,7 @@ typedef enum {
GI_VB_SHOW_TITLE_CARD,
GI_VB_PLAY_ENTRANCE_CS,
GI_VB_DISABLE_FD_MASK,
GI_VB_DOGGY_RACE_SET_MAX_SPEED,
GI_VB_LOWER_RAZOR_SWORD_DURABILITY,
GI_VB_SET_BLAST_MASK_COOLDOWN_TIMER,
GI_VB_PATCH_SIDEROLL,
@@ -0,0 +1,20 @@
#include <libultraship/bridge.h>
#include "Enhancements/GameInteractor/GameInteractor.h"
#include "Enhancements/Enhancements.h"
extern "C" {
#include <z64save.h>
extern SaveContext gSaveContext;
extern u8 gItemSlots[77];
}
void RegisterAlwaysWinDoggyRace() {
REGISTER_VB_SHOULD(GI_VB_DOGGY_RACE_SET_MAX_SPEED, {
uint8_t selectedOption = CVarGetInteger("gEnhancements.Minigames.AlwaysWinDoggyRace", 0);
if (selectedOption == ALWAYS_WIN_DOGGY_RACE_ALWAYS || (selectedOption == ALWAYS_WIN_DOGGY_RACE_MASKOFTRUTH &&
(INV_CONTENT(ITEM_MASK_TRUTH) == ITEM_MASK_TRUTH))) {
*should = true;
}
});
}
@@ -0,0 +1,6 @@
#ifndef MINIGAMES_ALWAYS_WIN_DOGGY_RACE_H
#define MINIGAMES_ALWAYS_WIN_DOGGY_RACE_H
void RegisterAlwaysWinDoggyRace();
#endif // MINIGAMES_ALWAYS_WIN_DOGGY_RACE_H
@@ -12,6 +12,8 @@
#include "overlays/actors/ovl_En_Aob_01/z_en_aob_01.h"
#include "overlays/actors/ovl_En_Dg/z_en_dg.h"
#include "Enhancements/GameInteractor/GameInteractor.h"
#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_80000000)
#define THIS ((EnRacedog*)thisx)
@@ -514,7 +516,10 @@ void EnRacedog_UpdateSpeed(EnRacedog* this) {
// The dog that the player has selected has a slightly higher max speed than the other dogs.
if (this->index == this->selectedDogIndex) {
if (this->actor.speed > 7.5f) {
// Cap the speed of the dog, or always max it out with the 'Always Win Doggy Race' enhancement.
bool vanillaCondition = this->actor.speed > 7.5f;
if (GameInteractor_Should(GI_VB_DOGGY_RACE_SET_MAX_SPEED, vanillaCondition, NULL)) {
this->actor.speed = 7.5f;
}
} else {