Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cheat: tunic upgrades #501

Closed
wants to merge 10 commits into from
16 changes: 14 additions & 2 deletions libultraship/libultraship/ImGuiImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ namespace SohImGui {
"Hexaquinquagintiducentuple (256x)"
};

const char* tunicUpgrades[4] = {
"Off",
"Auto-Switch",
"Permanent Upgrade",
"Super Tunic"
};

std::map<std::string, std::vector<std::string>> hiddenwindowCategories;
std::map<std::string, std::vector<std::string>> windowCategories;
std::map<std::string, CustomWindow> customWindows;
Expand Down Expand Up @@ -1330,8 +1337,6 @@ namespace SohImGui {
Tooltip("Makes every surface in the game climbable");
EnhancementCheckbox("Moon Jump on L", "gMoonJumpOnL");
Tooltip("Holding L makes you float into the air");
EnhancementCheckbox("Super Tunic", "gSuperTunic");
Tooltip("Makes every tunic have the effects of every other tunic");
EnhancementCheckbox("Easy ISG", "gEzISG");
Tooltip("Passive Infinite Sword Glitch\nIt makes your sword's swing effect and hitbox stay active indefinitely");
EnhancementCheckbox("Unrestricted Items", "gNoRestrictItems");
Expand All @@ -1344,6 +1349,13 @@ namespace SohImGui {
Tooltip("Prevents the Deku Shield from burning on contact with fire");
EnhancementCheckbox("Shield with Two-Handed Weapons", "gShieldTwoHanded");
Tooltip("This allows you to put up your shield with any two-handed weapon in hand\nexcept for Deku Sticks");
ImGui::Text("Tunic Upgrades");
Tooltip("Select a variety of upgrades for tunic behavior.\n"
"Off: No upgrades\n"
"Auto-Switch: Automatically switch to your best tunic for the current situation\n"
"Permanent Upgrade: Treat owned tunics like upgrades that are always active once you have them\n"
"Super Tunic: Makes every tunic have the effects of every other tunic\n");
EnhancementCombobox("gAutoTunics", tunicUpgrades, 4, 0);

ImGui::EndMenu();
}
Expand Down
5 changes: 5 additions & 0 deletions soh/src/code/z_game_over.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ void GameOver_Update(GlobalContext* globalCtx) {
}
}

if ((CVar_GetS32("gAutoTunics", 0) == 1) && (CVar_GetS32("gNoRestrictAge", 0) || LINK_IS_ADULT) &&
(gSaveContext.inventory.equipment & gBitFlags[PLAYER_TUNIC_GORON] << gEquipShifts[EQUIP_TUNIC])) {
Inventory_ChangeEquipment(EQUIP_TUNIC, PLAYER_TUNIC_GORON + 1);
}

gSaveContext.nayrusLoveTimer = 2000;
gSaveContext.naviTimer = 0;
gSaveContext.seqId = (u8)NA_BGM_DISABLED;
Expand Down
10 changes: 8 additions & 2 deletions soh/src/code/z_parameter.c
Original file line number Diff line number Diff line change
Expand Up @@ -5615,11 +5615,17 @@ void Interface_Update(GlobalContext* globalCtx) {
D_80125A58 = func_8008F2F8(globalCtx);

if (D_80125A58 == 1) {
if (CUR_EQUIP_VALUE(EQUIP_TUNIC) == 2 || CVar_GetS32("gSuperTunic", 0) != 0) {
if (CUR_EQUIP_VALUE(EQUIP_TUNIC) == PLAYER_TUNIC_GORON + 1 || CVar_GetS32("gAutoTunics", 0) == 3 ||
(CVar_GetS32("gAutoTunics", 0) == 2 && (CVar_GetS32("gNoRestrictAge", 0) || LINK_IS_ADULT) &&
(gSaveContext.inventory.equipment &
gBitFlags[PLAYER_TUNIC_GORON] << gEquipShifts[EQUIP_TUNIC]))) {
D_80125A58 = 0;
}
} else if ((func_8008F2F8(globalCtx) >= 2) && (func_8008F2F8(globalCtx) < 5)) {
if (CUR_EQUIP_VALUE(EQUIP_TUNIC) == 3 || CVar_GetS32("gSuperTunic", 0) != 0) {
if (CUR_EQUIP_VALUE(EQUIP_TUNIC) == PLAYER_TUNIC_ZORA + 1 || CVar_GetS32("gAutoTunics", 0) == 3 ||
(CVar_GetS32("gAutoTunics", 0) == 2 && (CVar_GetS32("gNoRestrictAge", 0) || LINK_IS_ADULT) &&
(gSaveContext.inventory.equipment &
gBitFlags[PLAYER_TUNIC_ZORA] << gEquipShifts[EQUIP_TUNIC]))) {
D_80125A58 = 0;
}
}
Expand Down
48 changes: 43 additions & 5 deletions soh/src/code/z_player_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ s32 func_8008F2F8(GlobalContext* globalCtx) {
Player* this = GET_PLAYER(globalCtx);
TextTriggerEntry* triggerEntry;
s32 var;
static bool isSafe = true;

if (globalCtx->roomCtx.curRoom.unk_02 == 3) { // Room is hot
var = 0;
Expand All @@ -623,17 +624,54 @@ s32 func_8008F2F8(GlobalContext* globalCtx) {
} else if (this->stateFlags1 & 0x8000000) { // Swimming
var = 2;
} else {
if (!Player_InCsMode(globalCtx)) {
if ((CVar_GetS32("gAutoTunics", 0) == 1) && (CVar_GetS32("gNoRestrictAge", 0) ||
LINK_IS_ADULT) && !isSafe && (this->currentTunic != PLAYER_TUNIC_GORON) &&
(gSaveContext.inventory.equipment &
gBitFlags[PLAYER_TUNIC_GORON] << gEquipShifts[EQUIP_TUNIC])) {
isSafe = true;
Inventory_ChangeEquipment(EQUIP_TUNIC, PLAYER_TUNIC_GORON + 1);
Player_SetEquipmentData(globalCtx, this);
func_808328EC(this, NA_SE_PL_CHANGE_ARMS);
}
}
return 0;
}

// Trigger general textboxes under certain conditions, like "It's so hot in here!"
if (!Player_InCsMode(globalCtx)) {
if (CVar_GetS32("gAutoTunics", 0) == 1 &&
(CVar_GetS32("gNoRestrictAge", 0) || LINK_IS_ADULT) && isSafe &&
((!var && (this->currentTunic != PLAYER_TUNIC_GORON) &&
(gSaveContext.inventory.equipment &
gBitFlags[PLAYER_TUNIC_GORON] << gEquipShifts[EQUIP_TUNIC])) ||
(var && (this->currentTunic != PLAYER_TUNIC_ZORA) &&
(gSaveContext.inventory.equipment &
gBitFlags[PLAYER_TUNIC_ZORA] << gEquipShifts[EQUIP_TUNIC])))) {
isSafe = false;
Inventory_ChangeEquipment(EQUIP_TUNIC,
!var ? PLAYER_TUNIC_GORON + 1 : PLAYER_TUNIC_ZORA + 1);
Player_SetEquipmentData(globalCtx, this);
func_808328EC(this, NA_SE_PL_CHANGE_ARMS);
}

// Trigger general textboxes under certain conditions, like "It's so hot in here!"
triggerEntry = &sTextTriggers[var];

if ((triggerEntry->flag != 0) && !(gSaveContext.textTriggerFlags & triggerEntry->flag) &&
(((var == 0) && (this->currentTunic != PLAYER_TUNIC_GORON && CVar_GetS32("gSuperTunic", 0) == 0)) ||
(((var == 1) || (var == 3)) && (this->currentBoots == PLAYER_BOOTS_IRON) &&
(this->currentTunic != PLAYER_TUNIC_ZORA && CVar_GetS32("gSuperTunic", 0) == 0)))) {
if (CVar_GetS32("gAutoTunics", 0) != 3 && (triggerEntry->flag != 0) &&
!(gSaveContext.textTriggerFlags & triggerEntry->flag) &&
((var == 0) &&
((this->currentTunic != PLAYER_TUNIC_GORON) &&
!((CVar_GetS32("gAutoTunics", 0) == 2) &&
(CVar_GetS32("gNoRestrictAge", 0) || LINK_IS_ADULT) &&
(gSaveContext.inventory.equipment &
gBitFlags[PLAYER_TUNIC_GORON] << gEquipShifts[EQUIP_TUNIC]))) ||
((var == 1) || (var == 3)) &&
(this->currentBoots == PLAYER_BOOTS_IRON) &&
((this->currentTunic != PLAYER_TUNIC_ZORA) &&
!((CVar_GetS32("gAutoTunics", 0) == 2) &&
(CVar_GetS32("gNoRestrictAge", 0) || LINK_IS_ADULT) &&
(gSaveContext.inventory.equipment &
gBitFlags[PLAYER_TUNIC_ZORA] << gEquipShifts[EQUIP_TUNIC]))))) {
Message_StartTextbox(globalCtx, triggerEntry->textId, NULL);
gSaveContext.textTriggerFlags |= triggerEntry->flag;
}
Expand Down
5 changes: 5 additions & 0 deletions soh/src/code/z_sram.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,11 @@ void Sram_OpenSave() {
gSaveContext.equips.equipment |= 2;
}

if (CVar_GetS32("gAutoTunics", 0) == 1 && (CVar_GetS32("gNoRestrictAge", 0) || LINK_IS_ADULT) &&
(gSaveContext.inventory.equipment & gBitFlags[PLAYER_TUNIC_GORON] << gEquipShifts[EQUIP_TUNIC])) {
Inventory_ChangeEquipment(EQUIP_TUNIC, PLAYER_TUNIC_GORON + 1);
}

for (i = 0; i < ARRAY_COUNT(gSpoilingItems); i++) {
if (INV_CONTENT(ITEM_TRADE_ADULT) == gSpoilingItems[i]) {
INV_CONTENT(gSpoilingItemReverts[i]) = gSpoilingItemReverts[i];
Expand Down
16 changes: 13 additions & 3 deletions soh/src/overlays/actors/ovl_player_actor/z_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -3989,7 +3989,11 @@ s32 func_808382DC(Player* this, GlobalContext* globalCtx) {
SurfaceType_IsWallDamage(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) &&
(this->unk_A79 >= D_808544F4[sp48])) ||
((sp48 >= 0) &&
((this->currentTunic != PLAYER_TUNIC_GORON && CVar_GetS32("gSuperTunic", 0) == 0) || (this->unk_A79 >= D_808544F4[sp48])))) {
((this->currentTunic != PLAYER_TUNIC_GORON && !(CVar_GetS32("gAutoTunics", 0) == 3 ||
(CVar_GetS32("gAutoTunics", 0) == 2 && (CVar_GetS32("gNoRestrictAge", 0) || LINK_IS_ADULT) &&
(gSaveContext.inventory.equipment &
gBitFlags[PLAYER_TUNIC_GORON] << gEquipShifts[EQUIP_TUNIC])))) ||
(this->unk_A79 >= D_808544F4[sp48])))) {
this->unk_A79 = 0;
this->actor.colChkInfo.damage = 4;
func_80837C0C(globalCtx, this, 0, 4.0f, 5.0f, this->actor.shape.rot.y, 20);
Expand Down Expand Up @@ -8361,7 +8365,10 @@ static struct_80832924 D_808545F0[] = {
};

void func_80843CEC(Player* this, GlobalContext* globalCtx) {
if (this->currentTunic != PLAYER_TUNIC_GORON && CVar_GetS32("gSuperTunic", 0) == 0) {
if (this->currentTunic != PLAYER_TUNIC_GORON && (!(CVar_GetS32("gAutoTunics", 0) == 3) ||
!(CVar_GetS32("gAutoTunics", 0) == 2 && (CVar_GetS32("gNoRestrictAge", 0) || LINK_IS_ADULT) &&
(gSaveContext.inventory.equipment &
gBitFlags[PLAYER_TUNIC_GORON] << gEquipShifts[EQUIP_TUNIC])))) {
if ((globalCtx->roomCtx.curRoom.unk_02 == 3) || (D_808535E4 == 9) ||
((func_80838144(D_808535E4) >= 0) &&
!SurfaceType_IsWallDamage(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId))) {
Expand Down Expand Up @@ -10423,7 +10430,10 @@ void func_80848C74(GlobalContext* globalCtx, Player* this) {
s32 sp58;
s32 sp54;

if (this->currentTunic == PLAYER_TUNIC_GORON || CVar_GetS32("gSuperTunic", 0) != 0) {
if (this->currentTunic == PLAYER_TUNIC_GORON || CVar_GetS32("gAutoTunics", 0) == 3 ||
(CVar_GetS32("gAutoTunics", 0) == 2 && (CVar_GetS32("gNoRestrictAge", 0) || LINK_IS_ADULT) &&
(gSaveContext.inventory.equipment &
gBitFlags[PLAYER_TUNIC_GORON] << gEquipShifts[EQUIP_TUNIC]))) {
sp54 = 20;
}
else {
Expand Down