diff --git a/soh/soh/Enhancements/debugconsole.cpp b/soh/soh/Enhancements/debugconsole.cpp index 5962c82d047..253a57741cd 100644 --- a/soh/soh/Enhancements/debugconsole.cpp +++ b/soh/soh/Enhancements/debugconsole.cpp @@ -36,6 +36,7 @@ uint32_t minishLink; uint32_t gravityLevel; uint32_t resetLinkScale; uint32_t invisibleLink; +uint32_t oneHitKO; static bool ActorSpawnHandler(std::shared_ptr Console, const std::vector& args) { if ((args.size() != 9) && (args.size() != 3) && (args.size() != 6)) { @@ -631,7 +632,13 @@ static bool OneHitKOHandler(std::shared_ptr Console, const std::v return CMD_FAILED; } - // TODO: Implement + try { + oneHitKO = std::stoi(args[1], nullptr, 10) == 0 ? 0 : 1; + return CMD_SUCCESS; + } catch (std::invalid_argument const& ex) { + SohImGui::console->SendErrorMessage("[SOH] One-hit KO value must be a number."); + return CMD_FAILED; + } } static bool PacifistHandler(std::shared_ptr Console, const std::vector& args) { @@ -975,7 +982,7 @@ void DebugConsole_Init(void) { { "value", Ship::ArgumentType::NUMBER } }}); - CMD_REGISTER("ohko", { OneHitKOHandler, "Activates one hit KO.", { + CMD_REGISTER("ohko", { OneHitKOHandler, "Activates one hit KO. Any damage kills Link and he cannot gain health in this mode.", { { "value", Ship::ArgumentType::NUMBER } }}); diff --git a/soh/soh/Enhancements/debugconsole.h b/soh/soh/Enhancements/debugconsole.h index 9a3c3c72b35..2ffe2f4329d 100644 --- a/soh/soh/Enhancements/debugconsole.h +++ b/soh/soh/Enhancements/debugconsole.h @@ -10,6 +10,7 @@ extern uint32_t minishLink; extern uint32_t gravityLevel; extern uint32_t resetLinkScale; extern uint32_t invisibleLink; +extern uint32_t oneHitKO; #ifdef __cplusplus } #endif diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index 046729a065d..8e43bcf7f1a 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -10,6 +10,8 @@ #include #endif +#include "soh/Enhancements/debugconsole.h" + static uint16_t _doActionTexWidth, _doActionTexHeight = -1; static uint16_t DO_ACTION_TEX_WIDTH() { @@ -2641,6 +2643,14 @@ s32 Health_ChangeBy(GlobalContext* globalCtx, s16 healthChange) { osSyncPrintf("***** 増減=%d (now=%d, max=%d) ***", healthChange, gSaveContext.health, gSaveContext.healthCapacity); + // If one-hit ko mode is on, any damage kills you and you cannot gain health. + if (oneHitKO) { + if (healthChange < 0) + gSaveContext.health = 0; + + return 0; + } + // clang-format off if (healthChange > 0) { Audio_PlaySoundGeneral(NA_SE_SY_HP_RECOVER, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); 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 3f7c7b4f894..d9994bed606 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -3607,8 +3607,7 @@ s32 func_80837B18_modified(GlobalContext* globalCtx, Player* this, s32 damage, u } s32 modifiedDamage = damage; - if (modified) - { + if (modified) { modifiedDamage *= (1 << CVar_GetS32("gDamageMul", 0)); }