From 686d42709a6281c5baed0e5a6d8aad34b6b642a5 Mon Sep 17 00:00:00 2001 From: PSF Date: Tue, 28 Mar 2023 15:50:58 -0700 Subject: [PATCH 1/3] Added documentation on resetting battle flags and vars Added Overworld_ResetBattleFlagsAndVars to Overworld_ResetStateAfterWhiteOut --- include/config/battle.h | 2 ++ src/overworld.c | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/include/config/battle.h b/include/config/battle.h index 4a3d6382f..c6bca6de8 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -143,6 +143,7 @@ // Flag settings // 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. +// Once these features are turned on within the game, they will remain on until they are explcitily turned off or until the player whites out. This can be turned off by disabling Overworld_ResetBattleFlagsAndVars. #define B_FLAG_INVERSE_BATTLE 0 // If this flag is set, the battle's type effectiveness are inversed. For example, fire is super effective against water. #define B_FLAG_FORCE_DOUBLE_WILD 0 // If this flag is set, all land and surfing wild battles will be double battles. #define B_SMART_WILD_AI_FLAG 0 // If not 0, you can set this flag in a script to enable smart wild pokemon @@ -152,6 +153,7 @@ // Var Settings // To use the following features in scripting, replace the 0s with the var ID you're assigning it to. // Eg: Replace with VAR_UNUSED_0x40F7 so you can use VAR_TERRAIN for that feature. +// Once these features are turned on within the game, they will remain on until they are explcitily turned off or until the player whites out. This can be turned off by disabling Overworld_ResetBattleFlagsAndVars. #define VAR_TERRAIN 0 // If this var has a value, assigning a STATUS_FIELD_xx_TERRAIN to it before battle causes the battle to start with that terrain active #define B_VAR_WILD_AI_FLAGS 0 // If not 0, you can use this var to add to default wild AI flags. NOT usable with flags above (1 << 15) diff --git a/src/overworld.c b/src/overworld.c index 6b63a60d5..9fabe3ed9 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -401,6 +401,23 @@ void Overworld_ResetStateAfterDigEscRope(void) FlagClear(FLAG_SYS_USE_FLASH); } +void Overworld_ResetBattleFlagsAndVars(void) +{ +#if VAR_TERRAIN != 0 + VarSet(VAR_TERRAIN, 0); +#endif + +#if B_VAR_WILD_AI_FLAGS != 0 + VarSet(B_VAR_WILD_AI_FLAGS,0); +#endif + + FlagClear(B_FLAG_INVERSE_BATTLE); + FlagClear(B_FLAG_FORCE_DOUBLE_WILD); + FlagClear(B_SMART_WILD_AI_FLAG); + FlagClear(B_FLAG_NO_BAG_USE); + FlagClear(B_FLAG_NO_CATCHING); +} + static void Overworld_ResetStateAfterWhiteOut(void) { ResetInitialPlayerAvatarState(); @@ -409,9 +426,7 @@ static void Overworld_ResetStateAfterWhiteOut(void) FlagClear(FLAG_SYS_SAFARI_MODE); FlagClear(FLAG_SYS_USE_STRENGTH); FlagClear(FLAG_SYS_USE_FLASH); -#if VAR_TERRAIN != 0 - VarSet(VAR_TERRAIN, 0); -#endif + Overworld_ResetBattleFlagsAndVars(); // If you were defeated by Kyogre/Groudon and the step counter has // maxed out, end the abnormal weather. if (VarGet(VAR_SHOULD_END_ABNORMAL_WEATHER) == 1) From 24df9823e8f1c20e723b2b9b8b2ab01ee84db379 Mon Sep 17 00:00:00 2001 From: PSF Date: Thu, 30 Mar 2023 06:35:38 -0700 Subject: [PATCH 2/3] In response to PR discussion, added new preproc config for developers to toggle Overworld_ResetBattleFlagsAndVars --- include/config/battle.h | 5 +++-- src/overworld.c | 18 +++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/include/config/battle.h b/include/config/battle.h index c6bca6de8..77e0e0f4d 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -143,7 +143,6 @@ // Flag settings // 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. -// Once these features are turned on within the game, they will remain on until they are explcitily turned off or until the player whites out. This can be turned off by disabling Overworld_ResetBattleFlagsAndVars. #define B_FLAG_INVERSE_BATTLE 0 // If this flag is set, the battle's type effectiveness are inversed. For example, fire is super effective against water. #define B_FLAG_FORCE_DOUBLE_WILD 0 // If this flag is set, all land and surfing wild battles will be double battles. #define B_SMART_WILD_AI_FLAG 0 // If not 0, you can set this flag in a script to enable smart wild pokemon @@ -153,10 +152,12 @@ // Var Settings // To use the following features in scripting, replace the 0s with the var ID you're assigning it to. // Eg: Replace with VAR_UNUSED_0x40F7 so you can use VAR_TERRAIN for that feature. -// Once these features are turned on within the game, they will remain on until they are explcitily turned off or until the player whites out. This can be turned off by disabling Overworld_ResetBattleFlagsAndVars. #define VAR_TERRAIN 0 // If this var has a value, assigning a STATUS_FIELD_xx_TERRAIN to it before battle causes the battle to start with that terrain active #define B_VAR_WILD_AI_FLAGS 0 // If not 0, you can use this var to add to default wild AI flags. NOT usable with flags above (1 << 15) +//Flag and Var settings +#define B_RESET_FLAGS_VARS_AFTER_WHITEOUT TRUE // If set to TRUE, Flag and Var settings (B_FLAG_INVERSE_BATTLE,B_FLAG_FORCE_DOUBLE_WILD,B_SMART_WILD_AI_FLAG,B_FLAG_NO_BAG_USE,B_FLAG_NO_CATCHING,B_VAR_WILD_AI_FLAGS, and VAR_TERRAIN) will be reset when the player whites out. + // Terrain settings #define B_TERRAIN_BG_CHANGE TRUE // If set to TRUE, terrain moves permanently change the default battle background until the effect fades. #define B_THUNDERSTORM_TERRAIN TRUE // If TRUE, overworld Thunderstorm generates Rain and Electric Terrain as in Gen 8. diff --git a/src/overworld.c b/src/overworld.c index 9fabe3ed9..3af1cfd6d 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -401,15 +401,16 @@ void Overworld_ResetStateAfterDigEscRope(void) FlagClear(FLAG_SYS_USE_FLASH); } -void Overworld_ResetBattleFlagsAndVars(void) +#if B_RESET_FLAGS_VARS_AFTER_WHITEOUT == TRUE + void Overworld_ResetBattleFlagsAndVars(void) { -#if VAR_TERRAIN != 0 - VarSet(VAR_TERRAIN, 0); -#endif + #if VAR_TERRAIN != 0 + VarSet(VAR_TERRAIN, 0); + #endif -#if B_VAR_WILD_AI_FLAGS != 0 - VarSet(B_VAR_WILD_AI_FLAGS,0); -#endif + #if B_VAR_WILD_AI_FLAGS != 0 + VarSet(B_VAR_WILD_AI_FLAGS,0); + #endif FlagClear(B_FLAG_INVERSE_BATTLE); FlagClear(B_FLAG_FORCE_DOUBLE_WILD); @@ -417,6 +418,7 @@ void Overworld_ResetBattleFlagsAndVars(void) FlagClear(B_FLAG_NO_BAG_USE); FlagClear(B_FLAG_NO_CATCHING); } +#endif static void Overworld_ResetStateAfterWhiteOut(void) { @@ -426,7 +428,9 @@ static void Overworld_ResetStateAfterWhiteOut(void) FlagClear(FLAG_SYS_SAFARI_MODE); FlagClear(FLAG_SYS_USE_STRENGTH); FlagClear(FLAG_SYS_USE_FLASH); +#if B_RESET_FLAGS_VARS_AFTER_WHITEOUT == TRUE Overworld_ResetBattleFlagsAndVars(); +#endif // If you were defeated by Kyogre/Groudon and the step counter has // maxed out, end the abnormal weather. if (VarGet(VAR_SHOULD_END_ABNORMAL_WEATHER) == 1) From 59dfc7c3ad513ee2bc05b43e80eedf7dfccb43ee Mon Sep 17 00:00:00 2001 From: psf <77138753+pkmnsnfrn@users.noreply.github.com> Date: Fri, 7 Apr 2023 06:07:12 -0700 Subject: [PATCH 3/3] Update include/config/battle.h Took suggestions from https://github.com/rh-hideout/pokeemerald-expansion/pull/2875#discussion_r1160574308 Co-authored-by: LOuroboros --- include/config/battle.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/config/battle.h b/include/config/battle.h index 77e0e0f4d..790ad78cc 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -155,8 +155,8 @@ #define VAR_TERRAIN 0 // If this var has a value, assigning a STATUS_FIELD_xx_TERRAIN to it before battle causes the battle to start with that terrain active #define B_VAR_WILD_AI_FLAGS 0 // If not 0, you can use this var to add to default wild AI flags. NOT usable with flags above (1 << 15) -//Flag and Var settings -#define B_RESET_FLAGS_VARS_AFTER_WHITEOUT TRUE // If set to TRUE, Flag and Var settings (B_FLAG_INVERSE_BATTLE,B_FLAG_FORCE_DOUBLE_WILD,B_SMART_WILD_AI_FLAG,B_FLAG_NO_BAG_USE,B_FLAG_NO_CATCHING,B_VAR_WILD_AI_FLAGS, and VAR_TERRAIN) will be reset when the player whites out. +// Flag and Var settings +#define B_RESET_FLAGS_VARS_AFTER_WHITEOUT TRUE // If TRUE, Overworld_ResetBattleFlagsAndVars will reset battle-related Flags and Vars when the player whites out. // Terrain settings #define B_TERRAIN_BG_CHANGE TRUE // If set to TRUE, terrain moves permanently change the default battle background until the effect fades.