Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Battle Weather Refactor #5833

Merged
merged 16 commits into from
Jan 4, 2025
70 changes: 19 additions & 51 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ BattleScript_EffectChillyReception::
jumpifhalfword CMP_COMMON_BITS, gBattleWeather, B_WEATHER_RAIN_PRIMAL, BattleScript_EffectChillyReceptionBlockedByPrimalRain
jumpifhalfword CMP_COMMON_BITS, gBattleWeather, B_WEATHER_STRONG_WINDS, BattleScript_EffectChillyReceptionBlockedByStrongWinds
call BattleScript_EffectChillyReceptionPlayAnimation
setfieldweather ENUM_WEATHER_SNOW
setfieldweather BATTLE_WEATHER_SNOW
call BattleScript_MoveWeatherChangeRet
goto BattleScript_MoveSwitch
BattleScript_EffectChillyReceptionPlayAnimation:
Expand Down Expand Up @@ -4273,7 +4273,7 @@ BattleScript_EffectSandstorm::
attackstring
ppreduce
call BattleScript_CheckPrimalWeather
setfieldweather ENUM_WEATHER_SANDSTORM
setfieldweather BATTLE_WEATHER_SANDSTORM
goto BattleScript_MoveWeatherChange

BattleScript_EffectRollout::
Expand Down Expand Up @@ -4439,7 +4439,7 @@ BattleScript_EffectRainDance::
attackstring
ppreduce
call BattleScript_CheckPrimalWeather
setfieldweather ENUM_WEATHER_RAIN
setfieldweather BATTLE_WEATHER_RAIN
BattleScript_MoveWeatherChange::
attackanimation
waitanimation
Expand All @@ -4457,7 +4457,7 @@ BattleScript_EffectSunnyDay::
attackstring
ppreduce
call BattleScript_CheckPrimalWeather
setfieldweather ENUM_WEATHER_SUN
setfieldweather BATTLE_WEATHER_SUN
goto BattleScript_MoveWeatherChange

BattleScript_ExtremelyHarshSunlightWasNotLessened:
Expand Down Expand Up @@ -4816,7 +4816,7 @@ BattleScript_EffectHail::
attackstring
ppreduce
call BattleScript_CheckPrimalWeather
setfieldweather ENUM_WEATHER_HAIL
setfieldweather BATTLE_WEATHER_HAIL
goto BattleScript_MoveWeatherChange

BattleScript_EffectTorment::
Expand Down Expand Up @@ -5822,20 +5822,18 @@ BattleScript_LearnedNewMove::
BattleScript_LearnMoveReturn::
return

BattleScript_RainContinuesOrEnds::
printfromtable gRainContinuesStringIds
BattleScript_WeatherContinues::
printfromtable gWeatherTurnStringIds
waitmessage B_WAIT_TIME_LONG
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_RAIN_STOPPED, BattleScript_RainContinuesOrEndsEnd
playanimation BS_ATTACKER, B_ANIM_RAIN_CONTINUES
BattleScript_RainContinuesOrEndsEnd::
playanimation_var BS_ATTACKER, sB_ANIM_ARG1
setbyte gBattleCommunication, 0
call BattleScript_ActivateWeatherAbilities
end2

BattleScript_DamagingWeatherContinues::
printfromtable gSandStormHailSnowContinuesStringIds
BattleScript_WeatherFaded::
printfromtable gWeatherEndsStringIds
waitmessage B_WAIT_TIME_LONG
playanimation_var BS_ATTACKER, sB_ANIM_ARG1
setbyte gBattleCommunication, 0
call BattleScript_ActivateWeatherAbilities
end2

BattleScript_DamagingWeather::
Expand All @@ -5845,6 +5843,12 @@ BattleScript_DamagingWeather::
hitanimation BS_SCRIPTING
goto BattleScript_DoTurnDmg

BattleScript_FogEnded_Ret::
printstring STRINGID_FOGLIFTED
waitmessage B_WAIT_TIME_LONG
call BattleScript_ActivateWeatherAbilities
return

BattleScript_IceBodyHeal::
call BattleScript_AbilityPopUpScripting
playanimation BS_SCRIPTING, B_ANIM_SIMPLE_HEAL
Expand All @@ -5854,42 +5858,6 @@ BattleScript_IceBodyHeal::
waitmessage B_WAIT_TIME_LONG
end2

BattleScript_SandStormHailSnowEnds::
printfromtable gSandStormHailSnowEndStringIds
waitmessage B_WAIT_TIME_LONG
call BattleScript_ActivateWeatherAbilities
end2

BattleScript_SunlightContinues::
printstring STRINGID_SUNLIGHTSTRONG
waitmessage B_WAIT_TIME_LONG
playanimation BS_ATTACKER, B_ANIM_SUN_CONTINUES
call BattleScript_ActivateWeatherAbilities
end2

BattleScript_SunlightFaded::
printstring STRINGID_SUNLIGHTFADED
waitmessage B_WAIT_TIME_LONG
call BattleScript_ActivateWeatherAbilities
end2

BattleScript_FogContinues::
printstring STRINGID_FOGISDEEP
waitmessage B_WAIT_TIME_LONG
playanimation BS_ATTACKER, B_ANIM_FOG_CONTINUES
call BattleScript_ActivateWeatherAbilities
end2

BattleScript_FogEnded_Ret::
printstring STRINGID_FOGLIFTED
waitmessage B_WAIT_TIME_LONG
call BattleScript_ActivateWeatherAbilities
return

BattleScript_FogEnded::
call BattleScript_FogEnded_Ret
end2

BattleScript_OverworldStatusStarts::
printfromtable gStartingStatusStringIds
waitmessage B_WAIT_TIME_LONG
Expand Down Expand Up @@ -10049,7 +10017,7 @@ BattleScript_EffectSnow::
attackstring
ppreduce
call BattleScript_CheckPrimalWeather
setfieldweather ENUM_WEATHER_SNOW
setfieldweather BATTLE_WEATHER_SNOW
goto BattleScript_MoveWeatherChange

BattleScript_SleepClauseBlocked::
Expand Down
11 changes: 3 additions & 8 deletions include/battle_scripts.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,12 @@ extern const u8 BattleScript_DoSwitchOut[];
extern const u8 BattleScript_MoveSwitchOpenPartyScreen[];
extern const u8 BattleScript_Pausex20[];
extern const u8 BattleScript_LevelUp[];
extern const u8 BattleScript_RainContinuesOrEnds[];
extern const u8 BattleScript_SnowContinuesOrEnds[];
extern const u8 BattleScript_WeatherContinues[];
extern const u8 BattleScript_WeatherFaded[];
extern const u8 BattleScript_DamagingWeatherContinues[];
extern const u8 BattleScript_DamagingWeather[];
extern const u8 BattleScript_IceBodyHeal[];
extern const u8 BattleScript_SandStormHailSnowEnds[];
extern const u8 BattleScript_SunlightContinues[];
extern const u8 BattleScript_SunlightFaded[];
extern const u8 BattleScript_FogContinues[];
extern const u8 BattleScript_FogEnded_Ret[];
extern const u8 BattleScript_FogEnded[];
extern const u8 BattleScript_IceBodyHeal[];
extern const u8 BattleScript_OverworldStatusStarts[];
extern const u8 BattleScript_OverworldWeatherStarts[];
extern const u8 BattleScript_OverworldTerrain[];
Expand Down
2 changes: 1 addition & 1 deletion include/battle_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void TryClearRageAndFuryCutter(void);
u32 AtkCanceller_MoveSuccessOrder(void);
void SetAtkCancellerForCalledMove(void);
bool32 HasNoMonsToSwitch(u32 battler, u8 r1, u8 r2);
bool32 TryChangeBattleWeather(u32 battler, u32 weatherEnumId, bool32 viaAbility);
bool32 TryChangeBattleWeather(u32 battler, u32 battleWeatherId, bool32 viaAbility);
u32 CanAbilityBlockMove(u32 battlerAtk, u32 battlerDef, u32 move, u32 abilityDef);
u32 CanPartnerAbilityBlockMove(u32 battlerAtk, u32 battlerDef, u32 move, u32 abilityDef);
u32 CanAbilityAbsorbMove(u32 battlerAtk, u32 battlerDef, u32 abilityDef, u32 move, u32 moveType);
Expand Down
68 changes: 31 additions & 37 deletions include/constants/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,44 +283,38 @@
#define MOVE_RESULT_FOE_ENDURED_AFFECTION (1 << 9)
#define MOVE_RESULT_NO_EFFECT (MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE | MOVE_RESULT_FAILED)

enum BattleWeather
ghoulslash marked this conversation as resolved.
Show resolved Hide resolved
{
BATTLE_WEATHER_RAIN,
BATTLE_WEATHER_RAIN_PRIMAL,
BATTLE_WEATHER_RAIN_DOWNPOUR,
BATTLE_WEATHER_SUN,
BATTLE_WEATHER_SUN_PRIMAL,
BATTLE_WEATHER_SANDSTORM,
BATTLE_WEATHER_HAIL,
BATTLE_WEATHER_SNOW,
BATTLE_WEATHER_FOG,
BATTLE_WEATHER_STRONG_WINDS,
BATTLE_WEATHER_COUNT,
};

// Battle Weather flags
#define B_WEATHER_NONE 0
#define B_WEATHER_RAIN_TEMPORARY (1 << 0)
#define B_WEATHER_RAIN_DOWNPOUR (1 << 1) // unused
#define B_WEATHER_RAIN_PERMANENT (1 << 2)
#define B_WEATHER_RAIN_PRIMAL (1 << 3)
#define B_WEATHER_RAIN (B_WEATHER_RAIN_TEMPORARY | B_WEATHER_RAIN_DOWNPOUR | B_WEATHER_RAIN_PERMANENT | B_WEATHER_RAIN_PRIMAL)
#define B_WEATHER_SANDSTORM_TEMPORARY (1 << 4)
#define B_WEATHER_SANDSTORM_PERMANENT (1 << 5)
#define B_WEATHER_SANDSTORM (B_WEATHER_SANDSTORM_TEMPORARY | B_WEATHER_SANDSTORM_PERMANENT)
#define B_WEATHER_SUN_TEMPORARY (1 << 6)
#define B_WEATHER_SUN_PERMANENT (1 << 7)
#define B_WEATHER_SUN_PRIMAL (1 << 8)
#define B_WEATHER_SUN (B_WEATHER_SUN_TEMPORARY | B_WEATHER_SUN_PERMANENT | B_WEATHER_SUN_PRIMAL)
#define B_WEATHER_HAIL_TEMPORARY (1 << 9)
#define B_WEATHER_HAIL_PERMANENT (1 << 10)
#define B_WEATHER_HAIL (B_WEATHER_HAIL_TEMPORARY | B_WEATHER_HAIL_PERMANENT)
#define B_WEATHER_STRONG_WINDS (1 << 11)
#define B_WEATHER_ANY (B_WEATHER_RAIN | B_WEATHER_SANDSTORM | B_WEATHER_SUN | B_WEATHER_HAIL | B_WEATHER_STRONG_WINDS | B_WEATHER_SNOW | B_WEATHER_FOG)
#define B_WEATHER_PRIMAL_ANY (B_WEATHER_RAIN_PRIMAL | B_WEATHER_SUN_PRIMAL | B_WEATHER_STRONG_WINDS)
#define B_WEATHER_SNOW_TEMPORARY (1 << 12)
#define B_WEATHER_SNOW_PERMANENT (1 << 13)
#define B_WEATHER_SNOW (B_WEATHER_SNOW_TEMPORARY | B_WEATHER_SNOW_PERMANENT)
#define B_WEATHER_FOG_TEMPORARY (1 << 14)
#define B_WEATHER_FOG_PERMANENT (1 << 15)
#define B_WEATHER_FOG (B_WEATHER_FOG_TEMPORARY | B_WEATHER_FOG_PERMANENT)

// Battle Weather as enum
#define ENUM_WEATHER_NONE 0
#define ENUM_WEATHER_RAIN 1
#define ENUM_WEATHER_SUN 2
#define ENUM_WEATHER_SANDSTORM 3
#define ENUM_WEATHER_HAIL 4
#define ENUM_WEATHER_SUN_PRIMAL 5
#define ENUM_WEATHER_RAIN_PRIMAL 6
#define ENUM_WEATHER_STRONG_WINDS 7
#define ENUM_WEATHER_SNOW 8
#define ENUM_WEATHER_FOG 9
#define B_WEATHER_NONE 0
#define B_WEATHER_RAIN_NORMAL (1 << BATTLE_WEATHER_RAIN)
#define B_WEATHER_RAIN_PRIMAL (1 << BATTLE_WEATHER_RAIN_PRIMAL)
#define B_WEATHER_RAIN_DOWNPOUR (1 << BATTLE_WEATHER_RAIN_DOWNPOUR) // unused
#define B_WEATHER_RAIN (B_WEATHER_RAIN_NORMAL | B_WEATHER_RAIN_PRIMAL | B_WEATHER_RAIN_DOWNPOUR)
#define B_WEATHER_SUN_NORMAL (1 << BATTLE_WEATHER_SUN)
#define B_WEATHER_SUN_PRIMAL (1 << BATTLE_WEATHER_SUN_PRIMAL)
#define B_WEATHER_SUN (B_WEATHER_SUN_NORMAL | B_WEATHER_SUN_PRIMAL)
#define B_WEATHER_SANDSTORM (1 << BATTLE_WEATHER_SANDSTORM)
#define B_WEATHER_HAIL (1 << BATTLE_WEATHER_HAIL)
#define B_WEATHER_SNOW (1 << BATTLE_WEATHER_SNOW)
#define B_WEATHER_FOG (1 << BATTLE_WEATHER_FOG)
#define B_WEATHER_STRONG_WINDS (1 << BATTLE_WEATHER_STRONG_WINDS)

#define B_WEATHER_ANY (B_WEATHER_RAIN | B_WEATHER_SANDSTORM | B_WEATHER_SUN | B_WEATHER_HAIL | B_WEATHER_STRONG_WINDS | B_WEATHER_SNOW | B_WEATHER_FOG)
#define B_WEATHER_PRIMAL_ANY (B_WEATHER_RAIN_PRIMAL | B_WEATHER_SUN_PRIMAL | B_WEATHER_STRONG_WINDS)

// Move Effects
#define MOVE_EFFECT_SLEEP 1
Expand Down
21 changes: 16 additions & 5 deletions include/constants/battle_string_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -784,14 +784,25 @@

// gWeatherEndsStringIds
#define B_MSG_WEATHER_END_RAIN 0
#define B_MSG_WEATHER_END_SANDSTORM 1
#define B_MSG_WEATHER_END_SUN 2
#define B_MSG_WEATHER_END_SUN 1
#define B_MSG_WEATHER_END_SANDSTORM 2
#define B_MSG_WEATHER_END_HAIL 3
#define B_MSG_WEATHER_END_STRONG_WINDS 4
#define B_MSG_WEATHER_END_SNOW 5
#define B_MSG_WEATHER_END_FOG 6
#define B_MSG_WEATHER_END_SNOW 4
#define B_MSG_WEATHER_END_FOG 5
#define B_MSG_WEATHER_END_STRONG_WINDS 6
#define B_MSG_WEATHER_END_COUNT 7

// gWeatherTurnStringIds
#define B_MSG_WEATHER_TURN_RAIN 0
#define B_MSG_WEATHER_TURN_DOWNPOUR 1
#define B_MSG_WEATHER_TURN_SUN 2
#define B_MSG_WEATHER_TURN_SANDSTORM 3
#define B_MSG_WEATHER_TURN_HAIL 4
#define B_MSG_WEATHER_TURN_SNOW 5
#define B_MSG_WEATHER_TURN_FOG 6
#define B_MSG_WEATHER_TURN_STRONG_WINDS 7
#define B_MSG_WEATHER_TURN_COUNT 8

// gRainContinuesStringIds
#define B_MSG_RAIN_CONTINUES 0
#define B_MSG_DOWNPOUR_CONTINUES 1
Expand Down
8 changes: 4 additions & 4 deletions src/battle_dynamax.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,19 +587,19 @@ void BS_SetMaxMoveEffect(void)
switch (maxEffect)
{
case MAX_EFFECT_SUN:
weather = ENUM_WEATHER_SUN;
weather = BATTLE_WEATHER_SUN;
msg = B_MSG_STARTED_SUNLIGHT;
break;
case MAX_EFFECT_RAIN:
weather = ENUM_WEATHER_RAIN;
weather = BATTLE_WEATHER_RAIN;
msg = B_MSG_STARTED_RAIN;
break;
case MAX_EFFECT_SANDSTORM:
weather = ENUM_WEATHER_SANDSTORM;
weather = BATTLE_WEATHER_SANDSTORM;
msg = B_MSG_STARTED_SANDSTORM;
break;
case MAX_EFFECT_HAIL:
weather = ENUM_WEATHER_HAIL;
weather = BATTLE_WEATHER_HAIL;
msg = B_MSG_STARTED_HAIL;
break;
}
Expand Down
39 changes: 15 additions & 24 deletions src/battle_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -1013,20 +1013,25 @@ const u16 gMoveWeatherChangeStringIds[] =

const u16 gWeatherEndsStringIds[B_MSG_WEATHER_END_COUNT] =
{
[B_MSG_WEATHER_END_RAIN] = STRINGID_RAINSTOPPED,
[B_MSG_WEATHER_END_SANDSTORM] = STRINGID_SANDSTORMSUBSIDED,
[B_MSG_WEATHER_END_SUN] = STRINGID_SUNLIGHTFADED,
[B_MSG_WEATHER_END_HAIL] = STRINGID_HAILSTOPPED,
[B_MSG_WEATHER_END_RAIN] = STRINGID_RAINSTOPPED,
[B_MSG_WEATHER_END_SUN] = STRINGID_SUNLIGHTFADED,
[B_MSG_WEATHER_END_SANDSTORM] = STRINGID_SANDSTORMSUBSIDED,
[B_MSG_WEATHER_END_HAIL] = STRINGID_HAILSTOPPED,
[B_MSG_WEATHER_END_SNOW] = STRINGID_SNOWSTOPPED,
[B_MSG_WEATHER_END_FOG] = STRINGID_FOGLIFTED,
[B_MSG_WEATHER_END_STRONG_WINDS] = STRINGID_STRONGWINDSDISSIPATED,
[B_MSG_WEATHER_END_SNOW] = STRINGID_SNOWSTOPPED,
[B_MSG_WEATHER_END_FOG] = STRINGID_FOGLIFTED,
};

const u16 gSandStormHailSnowContinuesStringIds[] =
const u16 gWeatherTurnStringIds[] =
{
[B_MSG_SANDSTORM] = STRINGID_SANDSTORMRAGES,
[B_MSG_HAIL] = STRINGID_HAILCONTINUES,
[B_MSG_SNOW] = STRINGID_SNOWCONTINUES,
[B_MSG_WEATHER_TURN_RAIN] = STRINGID_RAINCONTINUES,
[B_MSG_WEATHER_TURN_DOWNPOUR] = STRINGID_DOWNPOURCONTINUES,
[B_MSG_WEATHER_TURN_SUN] = STRINGID_SUNLIGHTSTRONG,
[B_MSG_WEATHER_TURN_SANDSTORM] = STRINGID_SANDSTORMRAGES,
[B_MSG_WEATHER_TURN_HAIL] = STRINGID_HAILCONTINUES,
[B_MSG_WEATHER_TURN_SNOW] = STRINGID_SNOWCONTINUES,
[B_MSG_WEATHER_TURN_FOG] = STRINGID_FOGISDEEP,
[B_MSG_WEATHER_TURN_STRONG_WINDS] = STRINGID_MYSTERIOUSAIRCURRENTBLOWSON,
};

const u16 gSandStormHailDmgStringIds[] =
Expand All @@ -1035,20 +1040,6 @@ const u16 gSandStormHailDmgStringIds[] =
[B_MSG_HAIL] = STRINGID_PKMNPELTEDBYHAIL
};

const u16 gSandStormHailSnowEndStringIds[] =
{
[B_MSG_SANDSTORM] = STRINGID_SANDSTORMSUBSIDED,
[B_MSG_HAIL] = STRINGID_HAILSTOPPED,
[B_MSG_SNOW] = STRINGID_SNOWSTOPPED,
};

const u16 gRainContinuesStringIds[] =
{
[B_MSG_RAIN_CONTINUES] = STRINGID_RAINCONTINUES,
[B_MSG_DOWNPOUR_CONTINUES] = STRINGID_DOWNPOURCONTINUES,
[B_MSG_RAIN_STOPPED] = STRINGID_RAINSTOPPED
};

const u16 gProtectLikeUsedStringIds[] =
{
[B_MSG_PROTECTED_ITSELF] = STRINGID_PKMNPROTECTEDITSELF2,
Expand Down
16 changes: 8 additions & 8 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -11589,31 +11589,31 @@ static void Cmd_setfieldweather(void)
{
CMD_ARGS(u8 weather);

u8 weather = cmd->weather;
u8 battleWeatherId = cmd->weather;

if (!TryChangeBattleWeather(gBattlerAttacker, weather, FALSE))
if (!TryChangeBattleWeather(gBattlerAttacker, battleWeatherId, FALSE))
{
gBattleStruct->moveResultFlags[gBattlerTarget] |= MOVE_RESULT_MISSED;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_WEATHER_FAILED;
gBattlescriptCurrInstr = cmd->nextInstr;
return;
}

switch (weather)
switch (battleWeatherId)
{
case ENUM_WEATHER_RAIN:
case BATTLE_WEATHER_RAIN:
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STARTED_RAIN;
break;
case ENUM_WEATHER_SUN:
case BATTLE_WEATHER_SUN:
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STARTED_SUNLIGHT;
break;
case ENUM_WEATHER_SANDSTORM:
case BATTLE_WEATHER_SANDSTORM:
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STARTED_SANDSTORM;
break;
case ENUM_WEATHER_HAIL:
case BATTLE_WEATHER_HAIL:
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STARTED_HAIL;
break;
case ENUM_WEATHER_SNOW:
case BATTLE_WEATHER_SNOW:
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STARTED_SNOW;
break;
}
Expand Down
Loading
Loading