From 36b9b9519d8393dfd550d98c0870c9c07e3ba944 Mon Sep 17 00:00:00 2001 From: earthcrafterman Date: Mon, 20 Jun 2022 13:51:59 -0400 Subject: [PATCH] Added three sliders for multiplying damage (#478) * Added three sliders for multiplying damage: 1) Generic Slider, includes everything not multiplied by other sliders 2) Fall Damage Slider, includes all fall damage 3) Void Damage Slider, includes all void out damage * Included tooltips * Modified func_80837B18 to handle the modified flag the same as Player_InflictDamage does * hotfix of a dumb oversight * Fixed an oversight that led to compile failure on Linux and probably more things that weren't noticeable in unit testing * I keep missing dumb mistakes. I keep missing dumb mistakes. Is this the last dumb mistake I've missed? * Oh crud it's because I declared func_80837B18_modified after func_80837B18 isn't it? I am the ultimate dumbus. --- libultraship/libultraship/SohImGuiImpl.cpp | 6 +++++ .../actors/ovl_player_actor/z_player.c | 25 +++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/libultraship/libultraship/SohImGuiImpl.cpp b/libultraship/libultraship/SohImGuiImpl.cpp index 12cf8ca6e..1bdd2b875 100644 --- a/libultraship/libultraship/SohImGuiImpl.cpp +++ b/libultraship/libultraship/SohImGuiImpl.cpp @@ -879,6 +879,12 @@ namespace SohImGui { EnhancementSliderInt("Text Speed: %dx", "##TEXTSPEED", "gTextSpeed", 1, 5, ""); EnhancementSliderInt("King Zora Speed: %dx", "##WEEPSPEED", "gMweepSpeed", 1, 5, ""); EnhancementSliderInt("Vine/Ladder Climb speed +%d", "##CLIMBSPEED", "gClimbSpeed", 0, 12, ""); + EnhancementSliderInt("Damage Multiplier %dx", "##DAMAGEMUL", "gDamageMul", 1, 4, ""); + Tooltip("Modifies all sources of damage not affected by other sliders"); + EnhancementSliderInt("Fall Damage Multiplier %dx", "##FALLDAMAGEMUL", "gFallDamageMul", 1, 4, ""); + Tooltip("Modifies all fall damage"); + EnhancementSliderInt("Void Damage Multiplier %dx", "##VOIDDAMAGEMUL", "gVoidDamageMul", 1, 4, ""); + Tooltip("Modifies all void out damage"); EnhancementCheckbox("Skip Text", "gSkipText"); Tooltip("Holding down B skips text"); diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index 3e0af840c..dbdace551 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -351,6 +351,7 @@ s32 func_80852F38(GlobalContext* globalCtx, Player* this); s32 func_80852FFC(GlobalContext* globalCtx, Actor* actor, s32 csMode); void func_80853080(Player* this, GlobalContext* globalCtx); s32 Player_InflictDamage(GlobalContext* globalCtx, s32 damage); +s32 Player_InflictDamageModified(GlobalContext* globalCtx, s32 damage, u8 modified); void func_80853148(GlobalContext* globalCtx, Actor* actor); // .bss part 1 @@ -3516,12 +3517,22 @@ void func_80837AFC(Player* this, s32 timer) { this->unk_88F = 0; } -s32 func_80837B18(GlobalContext* globalCtx, Player* this, s32 damage) { +s32 func_80837B18_modified(GlobalContext* globalCtx, Player* this, s32 damage, u8 modified) { if ((this->invincibilityTimer != 0) || (this->actor.category != ACTORCAT_PLAYER)) { return 1; } - return Health_ChangeBy(globalCtx, damage); + s32 modifiedDamage = damage; + if (modified) + { + modifiedDamage *= CVar_GetS32("gDamageMul", 1); + } + + return Health_ChangeBy(globalCtx, modifiedDamage); +} + +s32 func_80837B18(GlobalContext* globalCtx, Player* this, s32 damage) { + return func_80837B18_modified(globalCtx, this, damage, true); } void func_80837B60(Player* this) { @@ -3747,7 +3758,7 @@ s32 func_808382DC(Player* this, GlobalContext* globalCtx) { if (this->unk_A86 != 0) { if (!Player_InBlockingCsMode(globalCtx, this)) { - Player_InflictDamage(globalCtx, -16); + Player_InflictDamageModified(globalCtx, -16 * CVar_GetS32("gVoidDamageMul", 1), false); this->unk_A86 = 0; } } @@ -8284,7 +8295,7 @@ s32 func_80843E64(GlobalContext* globalCtx, Player* this) { impactInfo = &D_80854600[impactIndex]; - if (Player_InflictDamage(globalCtx, impactInfo->damage)) { + if (Player_InflictDamageModified(globalCtx, impactInfo->damage * CVar_GetS32("gFallDamageMul", 1), false)) { return -1; } @@ -14834,9 +14845,13 @@ void func_80853080(Player* this, GlobalContext* globalCtx) { } s32 Player_InflictDamage(GlobalContext* globalCtx, s32 damage) { + return Player_InflictDamageModified(globalCtx, damage, true); +} + +s32 Player_InflictDamageModified(GlobalContext* globalCtx, s32 damage, u8 modified) { Player* this = GET_PLAYER(globalCtx); - if (!Player_InBlockingCsMode(globalCtx, this) && !func_80837B18(globalCtx, this, damage)) { + if (!Player_InBlockingCsMode(globalCtx, this) && !func_80837B18_modified(globalCtx, this, damage, modified)) { this->stateFlags2 &= ~PLAYER_STATE2_7; return 1; }