Add OneHit KO (#27)

This commit is contained in:
David Chavez 2022-08-27 02:03:50 +02:00 committed by GitHub
parent b57e44afc9
commit af5313d89e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 4 deletions

View File

@ -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<Ship::Console> Console, const std::vector<std::string>& args) {
if ((args.size() != 9) && (args.size() != 3) && (args.size() != 6)) {
@ -631,7 +632,13 @@ static bool OneHitKOHandler(std::shared_ptr<Ship::Console> 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<Ship::Console> Console, const std::vector<std::string>& 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 }
}});

View File

@ -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

View File

@ -10,6 +10,8 @@
#include <assert.h>
#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);

View File

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