From dfee8a4759c65bc222abf77c2371ccda0815d638 Mon Sep 17 00:00:00 2001 From: Bassoonian Date: Thu, 6 Apr 2023 00:26:52 +0200 Subject: [PATCH 1/2] OW Poison configs --- include/config/overworld.h | 3 +++ include/strings.h | 1 + src/field_control_avatar.c | 2 ++ src/field_poison.c | 14 ++++++++++++++ src/strings.c | 1 + 5 files changed, 21 insertions(+) diff --git a/include/config/overworld.h b/include/config/overworld.h index 7831858d27..f62588b5fd 100644 --- a/include/config/overworld.h +++ b/include/config/overworld.h @@ -4,6 +4,9 @@ // Movement config #define OW_RUNNING_INDOORS GEN_LATEST // In Gen4+, players are allowed to run indoors. +// Other settings +#define OW_POISON_DAMAGE GEN_LATEST // In Gen4, Pokémon no longer faint from Poison in the overworld. In Gen5+, they no longer take damage at all. + // Overworld flags // To use the following features in scripting, replace the 0s with the flag ID you're assigning it to. // Eg: Replace with FLAG_UNUSED_0x264 so you can use that flag to toggle the feature. diff --git a/include/strings.h b/include/strings.h index 959bb8c22d..984247b218 100644 --- a/include/strings.h +++ b/include/strings.h @@ -180,6 +180,7 @@ extern const u8 gText_Confirm3[]; extern const u8 gText_Cancel4[]; extern const u8 gText_IsThisTheCorrectTime[]; extern const u8 gText_PkmnFainted_FldPsn[]; +extern const u8 gText_PkmnSurvived_FldPsn[]; extern const u8 gText_Coins[]; extern const u8 gText_Silver[]; extern const u8 gText_Gold[]; diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index 96e9173c9b..b784a2ab86 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -565,11 +565,13 @@ static bool8 TryStartStepCountScript(u16 metatileBehavior) if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_FORCED_MOVE) && !MetatileBehavior_IsForcedMovementTile(metatileBehavior)) { + #if OW_POISON_DAMAGE < GEN_5 if (UpdatePoisonStepCounter() == TRUE) { ScriptContext_SetupScript(EventScript_FieldPoison); return TRUE; } + #endif if (ShouldEggHatch()) { IncrementGameStat(GAME_STAT_HATCHED_EGGS); diff --git a/src/field_poison.c b/src/field_poison.c index f254a6d142..89463a1e3f 100644 --- a/src/field_poison.c +++ b/src/field_poison.c @@ -44,7 +44,9 @@ static void FaintFromFieldPoison(u8 partyIdx) struct Pokemon *pokemon = &gPlayerParty[partyIdx]; u32 status = STATUS1_NONE; +#if OW_POISON_DAMAGE < GEN_4 AdjustFriendship(pokemon, FRIENDSHIP_EVENT_FAINT_FIELD_PSN); +#endif SetMonData(pokemon, MON_DATA_STATUS, &status); GetMonData(pokemon, MON_DATA_NICKNAME, gStringVar1); StringGet_Nickname(gStringVar1); @@ -53,7 +55,11 @@ static void FaintFromFieldPoison(u8 partyIdx) static bool32 MonFaintedFromPoison(u8 partyIdx) { struct Pokemon *pokemon = &gPlayerParty[partyIdx]; +#if OW_POISON_DAMAGE < GEN_4 if (IsMonValidSpecies(pokemon) && GetMonData(pokemon, MON_DATA_HP) == 0 && GetAilmentFromStatus(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN) +#else + if (IsMonValidSpecies(pokemon) && GetMonData(pokemon, MON_DATA_HP) == 1 && GetAilmentFromStatus(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN) +#endif return TRUE; return FALSE; @@ -73,7 +79,11 @@ static void Task_TryFieldPoisonWhiteOut(u8 taskId) if (MonFaintedFromPoison(tPartyIdx)) { FaintFromFieldPoison(tPartyIdx); + #if OW_POISON_DAMAGE < GEN_4 ShowFieldMessage(gText_PkmnFainted_FldPsn); + #else + ShowFieldMessage(gText_PkmnSurvived_FldPsn); + #endif tState++; return; } @@ -127,7 +137,11 @@ s32 DoPoisonFieldEffect(void) { // Apply poison damage hp = GetMonData(pokemon, MON_DATA_HP); + #if OW_POISON_DAMAGE < GEN_4 if (hp == 0 || --hp == 0) + #else + if (hp == 1 || --hp == 1) + #endif numFainted++; SetMonData(pokemon, MON_DATA_HP, &hp); diff --git a/src/strings.c b/src/strings.c index 8815212e05..d297c45352 100644 --- a/src/strings.c +++ b/src/strings.c @@ -1192,6 +1192,7 @@ const u8 gText_IcePunch48BP[] = _("ICE PUNCH{CLEAR_TO 0x4E}48BP"); const u8 gText_ThunderPunch48BP[] = _("THUNDERPUNCH{CLEAR_TO 0x4E}48BP"); const u8 gText_FirePunch48BP[] = _("FIRE PUNCH{CLEAR_TO 0x4E}48BP"); const u8 gText_PkmnFainted_FldPsn[] = _("{STR_VAR_1} fainted…\p\n"); +const u8 gText_PkmnSurvived_FldPsn[] = _("{STR_VAR_1} survived the poisoning.\nThe poison faded away!\p"); const u8 gText_Marco[] = _("MARCO"); const u8 gText_TrainerCardName[] = _("NAME: "); const u8 gText_TrainerCardIDNo[] = _("IDNo."); From 50b5dba6559c6804c5cb3e760243058c6a6321ad Mon Sep 17 00:00:00 2001 From: Bassoonian Date: Thu, 6 Apr 2023 10:13:32 +0200 Subject: [PATCH 2/2] Fix string issue as requested by Jaizu --- include/strings.h | 1 - src/field_poison.c | 4 ---- src/strings.c | 5 ++++- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/include/strings.h b/include/strings.h index 984247b218..959bb8c22d 100644 --- a/include/strings.h +++ b/include/strings.h @@ -180,7 +180,6 @@ extern const u8 gText_Confirm3[]; extern const u8 gText_Cancel4[]; extern const u8 gText_IsThisTheCorrectTime[]; extern const u8 gText_PkmnFainted_FldPsn[]; -extern const u8 gText_PkmnSurvived_FldPsn[]; extern const u8 gText_Coins[]; extern const u8 gText_Silver[]; extern const u8 gText_Gold[]; diff --git a/src/field_poison.c b/src/field_poison.c index 89463a1e3f..da162e4134 100644 --- a/src/field_poison.c +++ b/src/field_poison.c @@ -79,11 +79,7 @@ static void Task_TryFieldPoisonWhiteOut(u8 taskId) if (MonFaintedFromPoison(tPartyIdx)) { FaintFromFieldPoison(tPartyIdx); - #if OW_POISON_DAMAGE < GEN_4 ShowFieldMessage(gText_PkmnFainted_FldPsn); - #else - ShowFieldMessage(gText_PkmnSurvived_FldPsn); - #endif tState++; return; } diff --git a/src/strings.c b/src/strings.c index d297c45352..847b2849a6 100644 --- a/src/strings.c +++ b/src/strings.c @@ -1191,8 +1191,11 @@ const u8 gText_PsychUp48BP[] = _("PSYCH UP{CLEAR_TO 0x4E}48BP"); const u8 gText_IcePunch48BP[] = _("ICE PUNCH{CLEAR_TO 0x4E}48BP"); const u8 gText_ThunderPunch48BP[] = _("THUNDERPUNCH{CLEAR_TO 0x4E}48BP"); const u8 gText_FirePunch48BP[] = _("FIRE PUNCH{CLEAR_TO 0x4E}48BP"); +#if OW_POISON_DAMAGE < GEN_4 const u8 gText_PkmnFainted_FldPsn[] = _("{STR_VAR_1} fainted…\p\n"); -const u8 gText_PkmnSurvived_FldPsn[] = _("{STR_VAR_1} survived the poisoning.\nThe poison faded away!\p"); +#else +const u8 gText_PkmnFainted_FldPsn[] = _("{STR_VAR_1} survived the poisoning.\nThe poison faded away!\p"); +#endif const u8 gText_Marco[] = _("MARCO"); const u8 gText_TrainerCardName[] = _("NAME: "); const u8 gText_TrainerCardIDNo[] = _("IDNo.");