Streamlined ability-on-weather changes

Also renamed activateweatherabilities and activateterrainabilities.
This commit is contained in:
LOuroboros 2023-01-02 14:30:16 -03:00
parent e8dfb66c30
commit ca32d43433
5 changed files with 25 additions and 44 deletions

View File

@ -2010,12 +2010,12 @@
.4byte \ptr .4byte \ptr
.endm .endm
.macro activateweatherabilities battler:req .macro activateweatherchangeabilities battler:req
various \battler, VARIOUS_ACTIVATE_WEATHER_ABILITIES various \battler, VARIOUS_ACTIVATE_WEATHER_CHANGE_ABILITIES
.endm .endm
.macro activateterrainabilities battler:req .macro activateterrainchangeabilities battler:req
various \battler, VARIOUS_ACTIVATE_TERRAIN_ABILITIES various \battler, VARIOUS_ACTIVATE_TERRAIN_CHANGE_ABILITIES
.endm .endm
@ helpful macros @ helpful macros

View File

@ -4976,20 +4976,8 @@ BattleScript_MoveWeatherChange::
printfromtable gMoveWeatherChangeStringIds printfromtable gMoveWeatherChangeStringIds
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
call BattleScript_WeatherFormChanges call BattleScript_WeatherFormChanges
call BattleScript_ActivateWeatherAbilities
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_ActivateWeatherAbilities:
copybyte sBATTLER, gBattlerAttacker
setbyte gBattlerAttacker, 0
BattleScript_ActivateWeatherAbilities_Loop:
activateweatherabilities BS_ATTACKER
BattleScript_ActivateWeatherAbilities_Increment:
addbyte gBattlerAttacker, 1
jumpifbytenotequal gBattlerAttacker, gBattlersCount, BattleScript_ActivateWeatherAbilities_Loop
copybyte gBattlerAttacker, sBATTLER
return
BattleScript_EffectSunnyDay:: BattleScript_EffectSunnyDay::
attackcanceler attackcanceler
attackstring attackstring
@ -8180,7 +8168,6 @@ BattleScript_DrizzleActivates::
waitstate waitstate
playanimation BS_BATTLER_0, B_ANIM_RAIN_CONTINUES playanimation BS_BATTLER_0, B_ANIM_RAIN_CONTINUES
call BattleScript_WeatherFormChanges call BattleScript_WeatherFormChanges
call BattleScript_ActivateWeatherAbilities
end3 end3
BattleScript_AbilityRaisesDefenderStat:: BattleScript_AbilityRaisesDefenderStat::
@ -8341,7 +8328,6 @@ BattleScript_SandstreamActivates::
waitstate waitstate
playanimation BS_BATTLER_0, B_ANIM_SANDSTORM_CONTINUES playanimation BS_BATTLER_0, B_ANIM_SANDSTORM_CONTINUES
call BattleScript_WeatherFormChanges call BattleScript_WeatherFormChanges
call BattleScript_ActivateWeatherAbilities
end3 end3
BattleScript_SandSpitActivates:: BattleScript_SandSpitActivates::
@ -8351,7 +8337,6 @@ BattleScript_SandSpitActivates::
waitstate waitstate
playanimation BS_BATTLER_0, B_ANIM_SANDSTORM_CONTINUES playanimation BS_BATTLER_0, B_ANIM_SANDSTORM_CONTINUES
call BattleScript_WeatherFormChanges call BattleScript_WeatherFormChanges
call BattleScript_ActivateWeatherAbilities
return return
BattleScript_ShedSkinActivates:: BattleScript_ShedSkinActivates::
@ -8365,6 +8350,7 @@ BattleScript_WeatherFormChanges::
setbyte sBATTLER, 0 setbyte sBATTLER, 0
BattleScript_WeatherFormChangesLoop:: BattleScript_WeatherFormChangesLoop::
tryweatherformdatachange tryweatherformdatachange
activateweatherchangeabilities BS_SCRIPTING
addbyte sBATTLER, 1 addbyte sBATTLER, 1
jumpifbytenotequal sBATTLER, gBattlersCount, BattleScript_WeatherFormChangesLoop jumpifbytenotequal sBATTLER, gBattlersCount, BattleScript_WeatherFormChangesLoop
return return
@ -8470,7 +8456,6 @@ BattleScript_DroughtActivates::
waitstate waitstate
playanimation BS_BATTLER_0, B_ANIM_SUN_CONTINUES playanimation BS_BATTLER_0, B_ANIM_SUN_CONTINUES
call BattleScript_WeatherFormChanges call BattleScript_WeatherFormChanges
call BattleScript_ActivateWeatherAbilities
end3 end3
BattleScript_DesolateLandActivates:: BattleScript_DesolateLandActivates::
@ -8480,7 +8465,6 @@ BattleScript_DesolateLandActivates::
waitstate waitstate
playanimation BS_BATTLER_0, B_ANIM_SUN_CONTINUES playanimation BS_BATTLER_0, B_ANIM_SUN_CONTINUES
call BattleScript_WeatherFormChanges call BattleScript_WeatherFormChanges
call BattleScript_ActivateWeatherAbilities
end3 end3
BattleScript_DesolateLandEvaporatesWaterTypeMoves:: BattleScript_DesolateLandEvaporatesWaterTypeMoves::
@ -8501,7 +8485,6 @@ BattleScript_PrimordialSeaActivates::
waitstate waitstate
playanimation BS_BATTLER_0, B_ANIM_RAIN_CONTINUES playanimation BS_BATTLER_0, B_ANIM_RAIN_CONTINUES
call BattleScript_WeatherFormChanges call BattleScript_WeatherFormChanges
call BattleScript_ActivateWeatherAbilities
end3 end3
BattleScript_PrimordialSeaFizzlesOutFireTypeMoves:: BattleScript_PrimordialSeaFizzlesOutFireTypeMoves::
@ -8572,7 +8555,6 @@ BattleScript_SnowWarningActivates::
waitstate waitstate
playanimation BS_BATTLER_0, B_ANIM_HAIL_CONTINUES playanimation BS_BATTLER_0, B_ANIM_HAIL_CONTINUES
call BattleScript_WeatherFormChanges call BattleScript_WeatherFormChanges
call BattleScript_ActivateWeatherAbilities
end3 end3
BattleScript_TerrainSeedLoop: BattleScript_TerrainSeedLoop:
@ -8603,7 +8585,7 @@ BattleScript_ActivateTerrainAbilities:
copybyte sBATTLER, gBattlerAttacker copybyte sBATTLER, gBattlerAttacker
setbyte gBattlerAttacker, 0 setbyte gBattlerAttacker, 0
BattleScript_ActivateTerrainAbilities_Loop: BattleScript_ActivateTerrainAbilities_Loop:
activateterrainabilities BS_ATTACKER activateterrainchangeabilities BS_ATTACKER
BattleScript_ActivateTerrainAbilities_Increment: BattleScript_ActivateTerrainAbilities_Increment:
addbyte gBattlerAttacker, 1 addbyte gBattlerAttacker, 1
jumpifbytenotequal gBattlerAttacker, gBattlersCount, BattleScript_ActivateTerrainAbilities_Loop jumpifbytenotequal gBattlerAttacker, gBattlersCount, BattleScript_ActivateTerrainAbilities_Loop
@ -9756,7 +9738,6 @@ BattleScript_AnnounceAirLockCloudNine::
printstring STRINGID_AIRLOCKACTIVATES printstring STRINGID_AIRLOCKACTIVATES
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
call BattleScript_WeatherFormChanges call BattleScript_WeatherFormChanges
call BattleScript_ActivateWeatherAbilities
end3 end3
BattleScript_QuickClawActivation:: BattleScript_QuickClawActivation::

View File

@ -248,8 +248,8 @@
#define VARIOUS_CHECK_PARENTAL_BOND_COUNTER 157 #define VARIOUS_CHECK_PARENTAL_BOND_COUNTER 157
#define VARIOUS_SWAP_STATS 158 #define VARIOUS_SWAP_STATS 158
#define VARIOUS_TRY_WIND_RIDER_POWER 159 #define VARIOUS_TRY_WIND_RIDER_POWER 159
#define VARIOUS_ACTIVATE_WEATHER_ABILITIES 160 #define VARIOUS_ACTIVATE_WEATHER_CHANGE_ABILITIES 160
#define VARIOUS_ACTIVATE_TERRAIN_ABILITIES 161 #define VARIOUS_ACTIVATE_TERRAIN_CHANGE_ABILITIES 161
// Cmd_manipulatedamage // Cmd_manipulatedamage
#define DMG_CHANGE_SIGN 0 #define DMG_CHANGE_SIGN 0

View File

@ -10116,11 +10116,11 @@ static void Cmd_various(void)
} }
} }
return; return;
case VARIOUS_ACTIVATE_WEATHER_ABILITIES: case VARIOUS_ACTIVATE_WEATHER_CHANGE_ABILITIES:
gBattlescriptCurrInstr += 3; gBattlescriptCurrInstr += 3;
AbilityBattleEffects(ABILITYEFFECT_ON_WEATHER, gActiveBattler, 0, 0, 0); AbilityBattleEffects(ABILITYEFFECT_ON_WEATHER, gActiveBattler, 0, 0, 0);
return; return;
case VARIOUS_ACTIVATE_TERRAIN_ABILITIES: case VARIOUS_ACTIVATE_TERRAIN_CHANGE_ABILITIES:
gBattlescriptCurrInstr += 3; gBattlescriptCurrInstr += 3;
AbilityBattleEffects(ABILITYEFFECT_ON_TERRAIN, gActiveBattler, 0, 0, 0); AbilityBattleEffects(ABILITYEFFECT_ON_TERRAIN, gActiveBattler, 0, 0, 0);
return; return;

View File

@ -4798,19 +4798,6 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
effect++; effect++;
} }
break; break;
case ABILITY_FORECAST:
#if B_WEATHER_FORMS >= GEN_5
case ABILITY_FLOWER_GIFT:
#else
TRY_WEATHER_FORM:
#endif
effect = TryWeatherFormChange(battler);
if (effect != 0)
{
BattleScriptPushCursorAndCallback(BattleScript_WeatherFormChange);
*(&gBattleStruct->formToChangeInto) = effect - 1;
}
break;
case ABILITY_TRACE: case ABILITY_TRACE:
if (!(gSpecialStatuses[battler].traced)) if (!(gSpecialStatuses[battler].traced))
{ {
@ -6252,9 +6239,22 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
} }
break; break;
case ABILITYEFFECT_ON_WEATHER: // For ability effects that activate when the battle weather changes. case ABILITYEFFECT_ON_WEATHER: // For ability effects that activate when the battle weather changes.
gBattleScripting.battler = gBattlerAbility = battler; battler = gBattlerAbility = gBattlerAttacker = gBattleScripting.battler;
switch (GetBattlerAbility(battler)) switch (GetBattlerAbility(battler))
{ {
case ABILITY_FORECAST:
#if B_WEATHER_FORMS >= GEN_5
case ABILITY_FLOWER_GIFT:
#else
TRY_WEATHER_FORM:
#endif
effect = TryWeatherFormChange(battler);
if (effect != 0)
{
BattleScriptPushCursorAndCallback(BattleScript_WeatherFormChange);
*(&gBattleStruct->formToChangeInto) = effect - 1;
}
break;
case ABILITY_PROTOSYNTHESIS: case ABILITY_PROTOSYNTHESIS:
if (IsBattlerWeatherAffected(battler, B_WEATHER_SUN)) if (IsBattlerWeatherAffected(battler, B_WEATHER_SUN))
{ {
@ -6266,7 +6266,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
} }
break; break;
case ABILITYEFFECT_ON_TERRAIN: // For ability effects that activate when the field terrain changes. case ABILITYEFFECT_ON_TERRAIN: // For ability effects that activate when the field terrain changes.
gBattleScripting.battler = gBattlerAbility = battler; battler = gBattlerAbility = gBattlerAttacker = gBattleScripting.battler;
switch (GetBattlerAbility(battler)) switch (GetBattlerAbility(battler))
{ {
case ABILITY_QUARK_DRIVE: case ABILITY_QUARK_DRIVE: