Skip to content

Commit

Permalink
Merge pull request #2150 from Sneed69/weather_forms_fixes
Browse files Browse the repository at this point in the history
Weather forms fixes and config
  • Loading branch information
AsparagusEduardo committed Sep 8, 2022
2 parents f79e9f0 + 47a50b3 commit 0d4455f
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 47 deletions.
4 changes: 2 additions & 2 deletions asm/macros/battle_script.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1186,11 +1186,11 @@
.byte 0xe5
.endm

.macro docastformchangeanimation
.macro doweatherformchangeanimation
.byte 0xe6
.endm

.macro trycastformdatachange
.macro tryweatherformdatachange
.byte 0xe7
.endm

Expand Down
12 changes: 6 additions & 6 deletions data/battle_anim_scripts.s
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ gBattleAnims_StatusConditions::

.align 2
gBattleAnims_General::
.4byte General_CastformChange @ B_ANIM_CASTFORM_CHANGE
.4byte General_WeatherFormChange @ B_ANIM_CASTFORM_CHANGE
.4byte General_StatsChange @ B_ANIM_STATS_CHANGE
.4byte General_SubstituteFade @ B_ANIM_SUBSTITUTE_FADE
.4byte General_SubstituteAppear @ B_ANIM_SUBSTITUTE_APPEAR
Expand Down Expand Up @@ -24247,19 +24247,19 @@ Status_Nightmare:
Status_Powder:
end

General_CastformChange:
General_WeatherFormChange:
createvisualtask AnimTask_IsMonInvisible, 2
jumpreteq TRUE, CastformChangeSkipAnim
goto CastformChangeContinue
CastformChangeContinue:
jumpreteq TRUE, WeatherFormChangeSkipAnim
goto WeatherFormChangeContinue
WeatherFormChangeContinue:
monbg ANIM_ATTACKER
playsewithpan SE_M_TELEPORT, SOUND_PAN_ATTACKER
waitplaysewithpan SE_M_MINIMIZE, SOUND_PAN_ATTACKER, 48
createvisualtask AnimTask_TransformMon, 2, 1, 0
waitforvisualfinish
clearmonbg ANIM_ATTACKER
end
CastformChangeSkipAnim:
WeatherFormChangeSkipAnim:
createvisualtask AnimTask_CastformGfxDataChange, 2, 1
end

Expand Down
29 changes: 18 additions & 11 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -6567,11 +6567,9 @@ BattleScript_LearnMoveReturn::
BattleScript_RainContinuesOrEnds::
printfromtable gRainContinuesStringIds
waitmessage B_WAIT_TIME_LONG
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_RAIN_STOPPED, BattleScript_RainEnds
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_RAIN_STOPPED, BattleScript_RainContinuesOrEndsEnd
playanimation BS_ATTACKER, B_ANIM_RAIN_CONTINUES
end2
BattleScript_RainEnds::
call BattleScript_WeatherFormChanges
BattleScript_RainContinuesOrEndsEnd::
end2

BattleScript_DamagingWeatherContinues::
Expand Down Expand Up @@ -6610,7 +6608,6 @@ BattleScript_DamagingWeatherContinuesEnd::
BattleScript_SandStormHailEnds::
printfromtable gSandStormHailEndStringIds
waitmessage B_WAIT_TIME_LONG
call BattleScript_WeatherFormChanges
end2

BattleScript_SunlightContinues::
Expand All @@ -6622,7 +6619,6 @@ BattleScript_SunlightContinues::
BattleScript_SunlightFaded::
printstring STRINGID_SUNLIGHTFADED
waitmessage B_WAIT_TIME_LONG
call BattleScript_WeatherFormChanges
end2

BattleScript_OverworldWeatherStarts::
Expand Down Expand Up @@ -8228,19 +8224,30 @@ BattleScript_ShedSkinActivates::
BattleScript_WeatherFormChanges::
setbyte sBATTLER, 0
BattleScript_WeatherFormChangesLoop::
trycastformdatachange
tryweatherformdatachange
addbyte sBATTLER, 1
jumpifbytenotequal sBATTLER, gBattlersCount, BattleScript_WeatherFormChangesLoop
return

BattleScript_CastformChange::
call BattleScript_DoCastformChange
BattleScript_WeatherFormChange::
call BattleScript_DoWeatherFormChange
end3

BattleScript_DoCastformChange::
BattleScript_DoWeatherFormChange::
copybyte gBattlerAbility, sBATTLER
.if B_WEATHER_FORMS >= GEN_5
jumpifspecies BS_SCRIPTING, SPECIES_CASTFORM, BattleScript_DoWeatherFormChange_ForecastCheck
BattleScript_DoWeatherFormChange_FlowerGiftCheck:
jumpifability BS_SCRIPTING, ABILITY_FLOWER_GIFT, BattleScript_DoWeatherFormChange_PopUp
goto BattleScript_DoWeatherFormChange_AfterPopUp
.endif
BattleScript_DoWeatherFormChange_ForecastCheck:
jumpifability BS_SCRIPTING, ABILITY_FORECAST, BattleScript_DoWeatherFormChange_PopUp
goto BattleScript_DoWeatherFormChange_AfterPopUp
BattleScript_DoWeatherFormChange_PopUp:
call BattleScript_AbilityPopUp
docastformchangeanimation
BattleScript_DoWeatherFormChange_AfterPopUp:
doweatherformchangeanimation
waitstate
printstring STRINGID_PKMNTRANSFORMED
waitmessage B_WAIT_TIME_LONG
Expand Down
2 changes: 1 addition & 1 deletion include/battle_scripts.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ extern const u8 BattleScript_SandstreamActivates[];
extern const u8 BattleScript_ShedSkinActivates[];
extern const u8 BattleScript_WeatherFormChanges[];
extern const u8 BattleScript_WeatherFormChangesLoop[];
extern const u8 BattleScript_CastformChange[];
extern const u8 BattleScript_WeatherFormChange[];
extern const u8 BattleScript_IntimidateActivatesEnd3[];
extern const u8 BattleScript_IntimidateActivates[];
extern const u8 BattleScript_DroughtActivates[];
Expand Down
2 changes: 1 addition & 1 deletion include/battle_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#define ABILITYEFFECT_MOVE_END_ATTACKER 4
#define ABILITYEFFECT_MOVE_END 5
#define ABILITYEFFECT_IMMUNITY 6
#define ABILITYEFFECT_FORECAST 7
#define ABILITYEFFECT_WEATHER_FORM 7
#define ABILITYEFFECT_SYNCHRONIZE 8
#define ABILITYEFFECT_ATK_SYNCHRONIZE 9
#define ABILITYEFFECT_INTIMIDATE1 10
Expand Down
1 change: 1 addition & 0 deletions include/constants/battle_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
#define B_OBLIVIOUS_TAUNT GEN_LATEST // In Gen6+, Pokémon with Oblivious can't be taunted.
#define B_STURDY GEN_LATEST // In Gen5+, Sturdy causes the Pokémon to have 1 HP remaining if another Pokémon's attack or confusion damage would have brought it from full health to 0 HP.
#define B_PLUS_MINUS_INTERACTION GEN_LATEST // In Gen5+, Plus and Minus can be activated with themselves and the opposite ability. Before, only the opposing ability could activate it.
#define B_WEATHER_FORMS GEN_LATEST // In Gen5+, Castform and Cherrim revert to their base form upon losing their respective ability. Cherrim needs Flower Gift to swap forms.

// Item settings
#define B_HP_BERRIES GEN_LATEST // In Gen4+, berries which restore hp activate immediately after HP drops to half. In Gen3, the effect occurs at the end of the turn.
Expand Down
5 changes: 3 additions & 2 deletions include/constants/battle_script_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,9 @@
#define MOVEEND_PICKPOCKET 27
#define MOVEEND_DANCER 28
#define MOVEEND_EMERGENCY_EXIT 29
#define MOVEEND_CLEAR_BITS 30
#define MOVEEND_COUNT 31
#define MOVEEND_WEATHER_FORM 30
#define MOVEEND_CLEAR_BITS 31
#define MOVEEND_COUNT 32

// switch cases
#define B_SWITCH_NORMAL 0
Expand Down
40 changes: 32 additions & 8 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,8 @@ static void Cmd_switchoutabilities(void);
static void Cmd_jumpifhasnohp(void);
static void Cmd_getsecretpowereffect(void);
static void Cmd_pickup(void);
static void Cmd_docastformchangeanimation(void);
static void Cmd_trycastformdatachange(void);
static void Cmd_doweatherformchangeanimation(void);
static void Cmd_tryweatherformdatachange(void);
static void Cmd_settypebasedhalvers(void);
static void Cmd_jumpifsubstituteblocks(void);
static void Cmd_tryrecycleitem(void);
Expand Down Expand Up @@ -807,8 +807,8 @@ void (* const gBattleScriptingCommandsTable[])(void) =
Cmd_jumpifhasnohp, //0xE3
Cmd_getsecretpowereffect, //0xE4
Cmd_pickup, //0xE5
Cmd_docastformchangeanimation, //0xE6
Cmd_trycastformdatachange, //0xE7
Cmd_doweatherformchangeanimation, //0xE6
Cmd_tryweatherformdatachange, //0xE7
Cmd_settypebasedhalvers, //0xE8
Cmd_jumpifsubstituteblocks, //0xE9
Cmd_tryrecycleitem, //0xEA
Expand Down Expand Up @@ -5742,6 +5742,30 @@ static void Cmd_moveend(void)
}
gBattleScripting.moveendState++;
break;
case MOVEEND_WEATHER_FORM:
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
switch (gBattleMons[i].species)
{
case SPECIES_CASTFORM:
case SPECIES_CHERRIM:
#ifdef POKEMON_EXPANSION
case SPECIES_CASTFORM_RAINY:
case SPECIES_CASTFORM_SNOWY:
case SPECIES_CASTFORM_SUNNY:
case SPECIES_CHERRIM_SUNSHINE:
#endif
effect = TryWeatherFormChange(i);
if (effect)
{
BattleScriptPushCursorAndCallback(BattleScript_WeatherFormChange);
gBattleScripting.battler = i;
gBattleStruct->formToChangeInto = effect - 1;
}
}
}
gBattleScripting.moveendState++;
break;
case MOVEEND_CLEAR_BITS: // Clear/Set bits for things like using a move for all targets and all hits.
if (gSpecialStatuses[gBattlerAttacker].instructedChosenTarget)
*(gBattleStruct->moveTarget + gBattlerAttacker) = gSpecialStatuses[gBattlerAttacker].instructedChosenTarget & 0x3;
Expand Down Expand Up @@ -6571,7 +6595,7 @@ static void Cmd_switchineffects(void)
|| ItemBattleEffects(ITEMEFFECT_ON_SWITCH_IN, gActiveBattler, FALSE)
|| AbilityBattleEffects(ABILITYEFFECT_INTIMIDATE2, 0, 0, 0, 0)
|| AbilityBattleEffects(ABILITYEFFECT_TRACE2, 0, 0, 0, 0)
|| AbilityBattleEffects(ABILITYEFFECT_FORECAST, 0, 0, 0, 0))
|| AbilityBattleEffects(ABILITYEFFECT_WEATHER_FORM, 0, 0, 0, 0))
return;

gSideStatuses[GetBattlerSide(gActiveBattler)] &= ~(SIDE_STATUS_SPIKES_DAMAGED | SIDE_STATUS_TOXIC_SPIKES_DAMAGED | SIDE_STATUS_STEALTH_ROCK_DAMAGED | SIDE_STATUS_STICKY_WEB_DAMAGED);
Expand Down Expand Up @@ -13466,7 +13490,7 @@ static void Cmd_pickup(void)
gBattlescriptCurrInstr++;
}

static void Cmd_docastformchangeanimation(void)
static void Cmd_doweatherformchangeanimation(void)
{
gActiveBattler = gBattleScripting.battler;

Expand All @@ -13479,15 +13503,15 @@ static void Cmd_docastformchangeanimation(void)
gBattlescriptCurrInstr++;
}

static void Cmd_trycastformdatachange(void)
static void Cmd_tryweatherformdatachange(void)
{
u8 form;

gBattlescriptCurrInstr++;
form = TryWeatherFormChange(gBattleScripting.battler);
if (form)
{
BattleScriptPushCursorAndCallback(BattleScript_CastformChange);
BattleScriptPushCursorAndCallback(BattleScript_WeatherFormChange);
*(&gBattleStruct->formToChangeInto) = form - 1;
}
}
Expand Down
Loading

0 comments on commit 0d4455f

Please sign in to comment.