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

Combine weather set commands #4434

Merged
merged 4 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions asm/macros/battle_script.inc
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,9 @@
.byte 0x7c
.endm

.macro setrain
.macro setfieldweather weather:req
.byte 0x7d
.byte \weather
.endm

.macro setreflect
Expand Down Expand Up @@ -833,7 +834,7 @@
.byte 0x94
.endm

.macro setsandstorm
.macro unused_95
.byte 0x95
.endm

Expand Down Expand Up @@ -1005,7 +1006,7 @@
.4byte \jumpInstr
.endm

.macro setsunny
.macro unused_bb
.byte 0xbb
.endm

Expand Down Expand Up @@ -1080,7 +1081,7 @@
.byte 0xc7
.endm

.macro sethail
.macro unused_c8
.byte 0xc8
.endm

Expand Down Expand Up @@ -1409,10 +1410,6 @@
callnative BS_TryRevertWeatherForm
.endm

.macro setsnow
callnative BS_SetSnow
.endm

.macro applysaltcure battler:req
callnative BS_ApplySaltCure
.byte \battler
Expand Down
12 changes: 6 additions & 6 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,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
setsnow
setfieldweather ENUM_WEATHER_SNOW
call BattleScript_MoveWeatherChangeRet
goto BattleScript_MoveSwitch
BattleScript_EffectChillyReceptionPlayAnimation:
Expand Down Expand Up @@ -4307,7 +4307,7 @@ BattleScript_EffectSandstorm::
attackstring
ppreduce
call BattleScript_CheckPrimalWeather
setsandstorm
setfieldweather ENUM_WEATHER_SANDSTORM
goto BattleScript_MoveWeatherChange

BattleScript_EffectRollout::
Expand Down Expand Up @@ -4473,7 +4473,7 @@ BattleScript_EffectRainDance::
attackstring
ppreduce
call BattleScript_CheckPrimalWeather
setrain
setfieldweather ENUM_WEATHER_RAIN
BattleScript_MoveWeatherChange::
attackanimation
waitanimation
Expand All @@ -4491,7 +4491,7 @@ BattleScript_EffectSunnyDay::
attackstring
ppreduce
call BattleScript_CheckPrimalWeather
setsunny
setfieldweather ENUM_WEATHER_SUN
goto BattleScript_MoveWeatherChange

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

BattleScript_EffectTorment::
Expand Down Expand Up @@ -9968,5 +9968,5 @@ BattleScript_EffectSnow::
attackstring
ppreduce
call BattleScript_CheckPrimalWeather
setsnow
setfieldweather ENUM_WEATHER_SNOW
goto BattleScript_MoveWeatherChange
107 changes: 36 additions & 71 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ static void Cmd_setatkhptozero(void);
static void Cmd_jumpifnexttargetvalid(void);
static void Cmd_tryhealhalfhealth(void);
static void Cmd_trymirrormove(void);
static void Cmd_setrain(void);
static void Cmd_setfieldweather(void);
static void Cmd_setreflect(void);
static void Cmd_setseeded(void);
static void Cmd_manipulatedamage(void);
Expand All @@ -476,7 +476,7 @@ static void Cmd_givepaydaymoney(void);
static void Cmd_setlightscreen(void);
static void Cmd_tryKO(void);
static void Cmd_damagetohalftargethp(void);
static void Cmd_setsandstorm(void);
static void Cmd_unused_95(void);
static void Cmd_weatherdamage(void);
static void Cmd_tryinfatuating(void);
static void Cmd_updatestatusicon(void);
Expand Down Expand Up @@ -514,7 +514,7 @@ static void Cmd_presentdamagecalculation(void);
static void Cmd_setsafeguard(void);
static void Cmd_magnitudedamagecalculation(void);
static void Cmd_jumpifnopursuitswitchdmg(void);
static void Cmd_setsunny(void);
static void Cmd_unused_bb(void);
static void Cmd_halvehp(void);
static void Cmd_copyfoestats(void);
static void Cmd_rapidspinfree(void);
Expand All @@ -527,7 +527,7 @@ static void Cmd_trydobeatup(void);
static void Cmd_setsemiinvulnerablebit(void);
static void Cmd_tryfiretwoturnmovenowbyeffect(void);
static void Cmd_setminimize(void);
static void Cmd_sethail(void);
static void Cmd_unused_c8(void);
static void Cmd_trymemento(void);
static void Cmd_setforcedtarget(void);
static void Cmd_setcharge(void);
Expand Down Expand Up @@ -650,7 +650,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
Cmd_end, //0x3D
Cmd_end2, //0x3E
Cmd_end3, //0x3F
Cmd_unused5, //0x40
Cmd_unused5, //0x40
Cmd_call, //0x41
Cmd_setroost, //0x42
Cmd_jumpifabilitypresent, //0x43
Expand Down Expand Up @@ -711,7 +711,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
Cmd_jumpifnexttargetvalid, //0x7A
Cmd_tryhealhalfhealth, //0x7B
Cmd_trymirrormove, //0x7C
Cmd_setrain, //0x7D
Cmd_setfieldweather, //0x7D
Cmd_setreflect, //0x7E
Cmd_setseeded, //0x7F
Cmd_manipulatedamage, //0x80
Expand All @@ -735,7 +735,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
Cmd_setlightscreen, //0x92
Cmd_tryKO, //0x93
Cmd_damagetohalftargethp, //0x94
Cmd_setsandstorm, //0x95
Cmd_unused_95, //0x95
Cmd_weatherdamage, //0x96
Cmd_tryinfatuating, //0x97
Cmd_updatestatusicon, //0x98
Expand Down Expand Up @@ -773,7 +773,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
Cmd_setsafeguard, //0xB8
Cmd_magnitudedamagecalculation, //0xB9
Cmd_jumpifnopursuitswitchdmg, //0xBA
Cmd_setsunny, //0xBB
Cmd_unused_bb, //0xBB
Cmd_halvehp, //0xBC
Cmd_copyfoestats, //0xBD
Cmd_rapidspinfree, //0xBE
Expand All @@ -786,7 +786,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
Cmd_setsemiinvulnerablebit, //0xC5
Cmd_tryfiretwoturnmovenowbyeffect, //0xC6
Cmd_setminimize, //0xC7
Cmd_sethail, //0xC8
Cmd_unused_c8, //0xC8
Cmd_trymemento, //0xC9
Cmd_setforcedtarget, //0xCA
Cmd_setcharge, //0xCB
Expand Down Expand Up @@ -11074,19 +11074,39 @@ static void Cmd_trymirrormove(void)
}
}

static void Cmd_setrain(void)
static void Cmd_setfieldweather(void)
{
CMD_ARGS();
CMD_ARGS(u8 weather);

u8 weather = cmd->weather;

if (!TryChangeBattleWeather(gBattlerAttacker, ENUM_WEATHER_RAIN, FALSE))
if (!TryChangeBattleWeather(gBattlerAttacker, weather, FALSE))
{
gMoveResultFlags |= MOVE_RESULT_MISSED;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_WEATHER_FAILED;
gBattlescriptCurrInstr = cmd->nextInstr;
return;
}
else

switch (weather)
{
case ENUM_WEATHER_RAIN:
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STARTED_RAIN;
break;
case ENUM_WEATHER_SUN:
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STARTED_SUNLIGHT;
break;
case ENUM_WEATHER_SANDSTORM:
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STARTED_SANDSTORM;
break;
case ENUM_WEATHER_HAIL:
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STARTED_HAIL;
break;
case ENUM_WEATHER_SNOW:
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STARTED_SNOW;
break;
}

gBattlescriptCurrInstr = cmd->nextInstr;
}

Expand Down Expand Up @@ -12283,20 +12303,8 @@ static void Cmd_damagetohalftargethp(void)
gBattlescriptCurrInstr = cmd->nextInstr;
}

static void Cmd_setsandstorm(void)
static void Cmd_unused_95(void)
{
CMD_ARGS();

if (!TryChangeBattleWeather(gBattlerAttacker, ENUM_WEATHER_SANDSTORM, FALSE))
{
gMoveResultFlags |= MOVE_RESULT_MISSED;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_WEATHER_FAILED;
}
else
{
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STARTED_SANDSTORM;
}
gBattlescriptCurrInstr = cmd->nextInstr;
}

static void Cmd_weatherdamage(void)
Expand Down Expand Up @@ -13494,21 +13502,8 @@ static void Cmd_jumpifnopursuitswitchdmg(void)
}
}

static void Cmd_setsunny(void)
static void Cmd_unused_bb(void)
{
CMD_ARGS();

if (!TryChangeBattleWeather(gBattlerAttacker, ENUM_WEATHER_SUN, FALSE))
{
gMoveResultFlags |= MOVE_RESULT_MISSED;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_WEATHER_FAILED;
}
else
{
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STARTED_SUNLIGHT;
}

gBattlescriptCurrInstr = cmd->nextInstr;
}

// Belly Drum, Fillet Away
Expand Down Expand Up @@ -13825,21 +13820,8 @@ static void Cmd_setminimize(void)
gBattlescriptCurrInstr = cmd->nextInstr;
}

static void Cmd_sethail(void)
static void Cmd_unused_c8(void)
{
CMD_ARGS();

if (!TryChangeBattleWeather(gBattlerAttacker, ENUM_WEATHER_HAIL, FALSE))
{
gMoveResultFlags |= MOVE_RESULT_MISSED;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_WEATHER_FAILED;
}
else
{
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STARTED_HAIL;
}

gBattlescriptCurrInstr = cmd->nextInstr;
}

static void Cmd_trymemento(void)
Expand Down Expand Up @@ -16187,23 +16169,6 @@ void BS_TryRevertWeatherForm(void)
gBattlescriptCurrInstr = cmd->nextInstr;
}

void BS_SetSnow(void)
{
NATIVE_ARGS();

if (!TryChangeBattleWeather(gBattlerAttacker, ENUM_WEATHER_SNOW, FALSE))
{
gMoveResultFlags |= MOVE_RESULT_MISSED;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_WEATHER_FAILED;

}
else
{
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STARTED_SNOW;
}
gBattlescriptCurrInstr = cmd->nextInstr;
}

void BS_HandleMegaEvolution(void)
{
NATIVE_ARGS(u8 battler, u8 caseId);
Expand Down
24 changes: 24 additions & 0 deletions test/battle/weather/hail.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,27 @@ SINGLE_BATTLE_TEST("Hail damage does not affect Ice-type Pokémon")
NOT MESSAGE("Foe Glalie is pelted by HAIL!");
}
}

SINGLE_BATTLE_TEST("Hail fails if Desolate Land or Primordial Sea are active")
{
u32 species;
u32 item;

PARAMETRIZE { species = SPECIES_WOBBUFFET; item = ITEM_NONE; }
PARAMETRIZE { species = SPECIES_GROUDON; item = ITEM_RED_ORB; }
PARAMETRIZE { species = SPECIES_KYOGRE; item = ITEM_BLUE_ORB; }

GIVEN {
PLAYER(species) { Item(item); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, MOVE_HAIL); }
} SCENE {
if (item == ITEM_RED_ORB || item == ITEM_BLUE_ORB) {
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_PRIMAL_REVERSION, player);
NOT ANIMATION(ANIM_TYPE_MOVE, MOVE_HAIL, opponent);
} else {
ANIMATION(ANIM_TYPE_MOVE, MOVE_HAIL, opponent);
}
}
}
22 changes: 22 additions & 0 deletions test/battle/weather/rain.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,25 @@ SINGLE_BATTLE_TEST("Rain multiplies the power of Water-type moves by 1.5x", s16
EXPECT_MUL_EQ(results[0].damage, Q_4_12(1.5), results[1].damage);
}
}

SINGLE_BATTLE_TEST("Drizzle fails if Desolate Land is active")
{
u32 item;

PARAMETRIZE { item = ITEM_NONE; }
PARAMETRIZE { item = ITEM_RED_ORB; }

GIVEN {
PLAYER(SPECIES_GROUDON) { Item(item); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, MOVE_RAIN_DANCE); }
} SCENE {
if (item == ITEM_RED_ORB) {
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_PRIMAL_REVERSION, player);
NOT ANIMATION(ANIM_TYPE_MOVE, MOVE_RAIN_DANCE, opponent);
} else {
ANIMATION(ANIM_TYPE_MOVE, MOVE_RAIN_DANCE, opponent);
}
}
}
24 changes: 24 additions & 0 deletions test/battle/weather/snow.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,27 @@ SINGLE_BATTLE_TEST("Snow multiplies the defense of Ice-types by 1.5x", s16 damag
EXPECT_MUL_EQ(results[0].damage, Q_4_12(1.5), results[1].damage);
}
}

SINGLE_BATTLE_TEST("Snowscape fails if Desolate Land or Primordial Sea are active")
{
u32 species;
u32 item;

PARAMETRIZE { species = SPECIES_WOBBUFFET; item = ITEM_NONE; }
PARAMETRIZE { species = SPECIES_GROUDON; item = ITEM_RED_ORB; }
PARAMETRIZE { species = SPECIES_KYOGRE; item = ITEM_BLUE_ORB; }

GIVEN {
PLAYER(species) { Item(item); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, MOVE_SNOWSCAPE); }
} SCENE {
if (item == ITEM_RED_ORB || item == ITEM_BLUE_ORB) {
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_PRIMAL_REVERSION, player);
NOT ANIMATION(ANIM_TYPE_MOVE, MOVE_SNOWSCAPE, opponent);
} else {
ANIMATION(ANIM_TYPE_MOVE, MOVE_SNOWSCAPE, opponent);
}
}
}
Loading
Loading