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
38 changes: 28 additions & 10 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,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 @@ -4292,7 +4292,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 @@ -4458,7 +4458,7 @@ BattleScript_EffectRainDance::
attackstring
ppreduce
call BattleScript_CheckPrimalWeather
setfieldweather ENUM_WEATHER_RAIN
setfieldweather BATTLE_WEATHER_RAIN
BattleScript_MoveWeatherChange::
attackanimation
waitanimation
Expand All @@ -4476,7 +4476,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 @@ -4835,7 +4835,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 @@ -5841,8 +5841,26 @@ BattleScript_LearnedNewMove::
BattleScript_LearnMoveReturn::
return

@@@ === NEW WEATHER SCRIPT

BattleScript_WeatherContinues::
printfromtable gWeatherTurnStringIds
waitmessage B_WAIT_TIME_LONG
playanimation_var BS_ATTACKER, sB_ANIM_ARG1
setbyte gBattleCommunication, 0
call BattleScript_ActivateWeatherAbilities
end2

BattleScript_WeatherFaded::
printfromtable gWeatherEndsStringIds
waitmessage B_WAIT_TIME_LONG
call BattleScript_ActivateWeatherAbilities
end2

@@@ === NEW WEATHER SCRIPT

BattleScript_RainContinuesOrEnds::
printfromtable gRainContinuesStringIds
@printfromtable gRainContinuesStringIds
AlexOn1ine marked this conversation as resolved.
Show resolved Hide resolved
waitmessage B_WAIT_TIME_LONG
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_RAIN_STOPPED, BattleScript_RainContinuesOrEndsEnd
playanimation BS_ATTACKER, B_ANIM_RAIN_CONTINUES
Expand All @@ -5851,14 +5869,14 @@ BattleScript_RainContinuesOrEndsEnd::
end2

BattleScript_DamagingWeatherContinues::
printfromtable gSandStormHailSnowContinuesStringIds
@printfromtable gSandStormHailSnowContinuesStringIds
waitmessage B_WAIT_TIME_LONG
playanimation_var BS_ATTACKER, sB_ANIM_ARG1
setbyte gBattleCommunication, 0
end2

BattleScript_DamagingWeather::
printfromtable gSandStormHailDmgStringIds
@printfromtable gSandStormHailDmgStringIds
waitmessage B_WAIT_TIME_LONG
effectivenesssound
hitanimation BS_SCRIPTING
Expand All @@ -5874,7 +5892,7 @@ BattleScript_IceBodyHeal::
end2

BattleScript_SandStormHailSnowEnds::
printfromtable gSandStormHailSnowEndStringIds
@printfromtable gSandStormHailSnowEndStringIds
waitmessage B_WAIT_TIME_LONG
call BattleScript_ActivateWeatherAbilities
end2
Expand Down Expand Up @@ -10069,7 +10087,7 @@ BattleScript_EffectSnow::
attackstring
ppreduce
call BattleScript_CheckPrimalWeather
setfieldweather ENUM_WEATHER_SNOW
setfieldweather BATTLE_WEATHER_SNOW
goto BattleScript_MoveWeatherChange

BattleScript_SleepClauseBlocked::
Expand Down
4 changes: 4 additions & 0 deletions include/battle_scripts.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ extern const u8 BattleScript_DoSwitchOut[];
extern const u8 BattleScript_MoveSwitchOpenPartyScreen[];
extern const u8 BattleScript_Pausex20[];
extern const u8 BattleScript_LevelUp[];

extern const u8 BattleScript_WeatherContinues[];
extern const u8 BattleScript_WeatherFaded[];

extern const u8 BattleScript_RainContinuesOrEnds[];
extern const u8 BattleScript_SnowContinuesOrEnds[];
extern const u8 BattleScript_DamagingWeatherContinues[];
Expand Down
2 changes: 1 addition & 1 deletion include/battle_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ u8 AtkCanceller_UnableToUseMove(u32 moveType);
void SetAtkCancellerForCalledMove(void);
u8 AtkCanceller_UnableToUseMove2(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
67 changes: 30 additions & 37 deletions include/constants/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,44 +283,37 @@
#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_SANDSTORM,
BATTLE_WEATHER_SUN,
BATTLE_WEATHER_SUN_PRIMAL,
BATTLE_WEATHER_HAIL,
BATTLE_WEATHER_SNOW,
BATTLE_WEATHER_FOG,
BATTLE_WEATHER_STRONG_WINDS,
};

// 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_SANDSTORM (1 << BATTLE_WEATHER_SANDSTORM)
#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_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
2 changes: 1 addition & 1 deletion src/battle_ai_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -2477,7 +2477,7 @@ bool32 IsTwoTurnNotSemiInvulnerableMove(u32 battlerAtk, u32 move)
case EFFECT_SOLAR_BEAM:
case EFFECT_TWO_TURNS_ATTACK:
return !(AI_DATA->holdEffects[battlerAtk] == HOLD_EFFECT_POWER_HERB
|| (AI_GetWeather(AI_DATA) & gMovesInfo[move].argument));
|| (AI_GetWeather(AI_DATA) & gMovesInfo[move].argument));
default:
return FALSE;
}
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
10 changes: 5 additions & 5 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -11577,19 +11577,19 @@ static void Cmd_setfieldweather(void)

switch (weather)
{
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