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
40 changes: 38 additions & 2 deletions libultraship/libultraship/SohImGuiImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,44 @@ namespace SohImGui {
EnhancementSliderInt("King Zora Speed: %dx", "##WEEPSPEED", "gMweepSpeed", 1, 5, "");
EnhancementSliderInt("Vine/Ladder Climb speed +%d", "##CLIMBSPEED", "gClimbSpeed", 0, 12, "");

const char* autotunic_cvar = "gAutoTunics";
{
int val = CVar_GetS32(autotunic_cvar, 0);
val = MAX(MIN(val, 3), 0);
int fps = val;
vaguerant marked this conversation as resolved.
Show resolved Hide resolved

if (val == 0)
{
ImGui::Text("Tunic Upgrades: Off");
}
else if (val == 1)
{
ImGui::Text("Tunic Upgrades: Auto-Switch");
}
else if (val == 2)
{
ImGui::Text("Tunic Upgrades: Permanent Upgrade");
}
else if (val == 4)
vaguerant marked this conversation as resolved.
Show resolved Hide resolved
{
ImGui::Text("Tunic Upgrades: Super Tunic");
}

if (ImGui::SliderInt("##AUTOTUNICS", &val, 0, 3, "", ImGuiSliderFlags_AlwaysClamp))
{
CVar_SetS32(autotunic_cvar, val);
needs_save = true;
}

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");
}

EnhancementCheckbox("Auto-Equips", "gAutoEquips");
Tooltip("New equipment (Swords, Shields, Tunics) is automatically equipped when you obtain it");
EnhancementCheckbox("Skip Text", "gSkipText");
Tooltip("Holding down B skips text");
EnhancementCheckbox("Mute Low HP Alarm", "gLowHpAlarm");
Expand Down Expand Up @@ -1085,8 +1123,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("Automatically activates the Infinite Sword glitch, making you constantly swing your sword");
EnhancementCheckbox("Unrestricted Items", "gNoRestrictItems");
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
24 changes: 22 additions & 2 deletions soh/src/code/z_parameter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,7 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) {
s16 i;
s16 slot;
s16 temp;
Player* player = GET_PLAYER(globalCtx);

slot = SLOT(item);
if (item >= ITEM_STICKS_5) {
Expand Down Expand Up @@ -1427,6 +1428,11 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) {
return ITEM_NONE;
} else if ((item >= ITEM_SWORD_KOKIRI) && (item <= ITEM_SWORD_BGS)) {
gSaveContext.inventory.equipment |= gBitFlags[item - ITEM_SWORD_KOKIRI] << gEquipShifts[EQUIP_SWORD];
if (CVar_GetS32("gAutoEquips", 0)) {
gSaveContext.equips.buttonItems[0] = item;
Inventory_ChangeEquipment(EQUIP_SWORD, item - ITEM_SWORD_KOKIRI + 1);
Interface_LoadItemIcon1(globalCtx, 0);
}

if (item == ITEM_SWORD_BGS) {
gSaveContext.swordHealth = 8;
Expand All @@ -1448,9 +1454,17 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) {
return ITEM_NONE;
} else if ((item >= ITEM_SHIELD_DEKU) && (item <= ITEM_SHIELD_MIRROR)) {
gSaveContext.inventory.equipment |= (gBitFlags[item - ITEM_SHIELD_DEKU] << gEquipShifts[EQUIP_SHIELD]);
if (CVar_GetS32("gAutoEquips", 0)) {
Inventory_ChangeEquipment(EQUIP_SHIELD, item - ITEM_SHIELD_DEKU + 1);
Player_SetEquipmentData(globalCtx, player);
}
return ITEM_NONE;
} else if ((item >= ITEM_TUNIC_KOKIRI) && (item <= ITEM_TUNIC_ZORA)) {
gSaveContext.inventory.equipment |= (gBitFlags[item - ITEM_TUNIC_KOKIRI] << gEquipShifts[EQUIP_TUNIC]);
if (CVar_GetS32("gAutoEquips", 0)) {
Inventory_ChangeEquipment(EQUIP_TUNIC, item - ITEM_TUNIC_KOKIRI + 1);
Player_SetEquipmentData(globalCtx, player);
}
return ITEM_NONE;
} else if ((item >= ITEM_BOOTS_KOKIRI) && (item <= ITEM_BOOTS_HOVER)) {
gSaveContext.inventory.equipment |= (gBitFlags[item - ITEM_BOOTS_KOKIRI] << gEquipShifts[EQUIP_BOOTS]);
Expand Down Expand Up @@ -4261,11 +4275,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,19 +624,56 @@ 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 (0) {}

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 @@ -431,6 +431,11 @@ void Sram_OpenSave(SramContext* sramCtx) {
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 @@ -3897,7 +3897,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 @@ -8212,7 +8216,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 @@ -10248,7 +10255,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