Add Surge Abilities

This commit is contained in:
DizzyEggg 2019-02-09 14:30:16 +01:00
parent 872389b15c
commit 3d616dfffe
7 changed files with 139 additions and 34 deletions

View File

@ -678,6 +678,10 @@ gBattleAnims_General::
.4byte General_IngrainHeal
.4byte General_WishHeal
.4byte General_MegaEvolution
.4byte General_TerrainMisty
.4byte General_TerrainGrassy
.4byte General_TerrainElectric
.4byte General_TerrainPsychic
.align 2
gBattleAnims_Special::
@ -12791,6 +12795,18 @@ General_MegaEvolution:
clearmonbg ANIM_ATTACKER
end
General_TerrainMisty:
end
General_TerrainGrassy:
end
General_TerrainElectric:
end
General_TerrainPsychic:
end
AnimScript_82D85A3:
createvisualtask sub_8172E9C, 2
jumpreteq 1, AnimScript_82D85B4

View File

@ -1602,7 +1602,7 @@ BattleScript_EffectHitEscape:
setbyte sMOVEEND_STATE, 0x0
moveend 0x0, 0x0
jumpifbattleend BattleScript_HitEscapeEnd
jumpifbyte CMP_NOT_EQUAL gBattleOutcome 0 BattleScript_HitEscapeEnd
jumpifbyte CMP_NOT_EQUAL gBattleOutcome 0, BattleScript_HitEscapeEnd
jumpifcantswitch ATK4F_DONT_CHECK_STATUSES | BS_ATTACKER, BattleScript_HitEscapeEnd
openpartyscreen 0x1, BattleScript_HitEscapeEnd
switchoutabilities BS_ATTACKER
@ -5880,6 +5880,38 @@ BattleScript_SnowWarningActivates::
call BattleScript_WeatherFormChanges
end3
BattleScript_ElectricSurgeActivates::
pause 0x20
call BattleScript_AbilityPopUp
printstring STRINGID_TERRAINBECOMESELECTRIC
waitstate
playanimation BS_SCRIPTING, B_ANIM_TERRAIN_ELECTRIC, NULL
end3
BattleScript_MistySurgeActivates::
pause 0x20
call BattleScript_AbilityPopUp
printstring STRINGID_TERRAINBECOMESMISTY
waitstate
playanimation BS_SCRIPTING, B_ANIM_TERRAIN_MISTY, NULL
end3
BattleScript_GrassySurgeActivates::
pause 0x20
call BattleScript_AbilityPopUp
printstring STRINGID_TERRAINBECOMESGRASSY
waitstate
playanimation BS_SCRIPTING, B_ANIM_TERRAIN_GRASSY, NULL
end3
BattleScript_PsychicSurgeActivates::
pause 0x20
call BattleScript_AbilityPopUp
printstring STRINGID_TERRAINBECOMESPSYCHIC
waitstate
playanimation BS_SCRIPTING, B_ANIM_TERRAIN_PSYCHIC, NULL
end3
BattleScript_BadDreamsActivates::
setbyte gBattlerTarget, 0
call BattleScript_AbilityPopUp

View File

@ -289,5 +289,9 @@ extern const u8 BattleScript_MoveUsedPsychicTerrainPrevents[];
extern const u8 BattleScript_MoveUsedPowder[];
extern const u8 BattleScript_SelectingNotAllowedBelch[];
extern const u8 BattleScript_SelectingNotAllowedBelchInPalace[];
extern const u8 BattleScript_PsychicSurgeActivates[];
extern const u8 BattleScript_GrassySurgeActivates[];
extern const u8 BattleScript_MistySurgeActivates[];
extern const u8 BattleScript_ElectricSurgeActivates[];
#endif // GUARD_BATTLE_SCRIPTS_H

View File

@ -374,6 +374,10 @@
#define B_ANIM_INGRAIN_HEAL 0x15
#define B_ANIM_WISH_HEAL 0x16
#define B_ANIM_MEGA_EVOLUTION 0x17
#define B_ANIM_TERRAIN_MISTY 0x18
#define B_ANIM_TERRAIN_GRASSY 0x19
#define B_ANIM_TERRAIN_ELECTRIC 0x1A
#define B_ANIM_TERRAIN_PSYCHIC 0x1B
// special animations table
#define B_ANIM_LVL_UP 0x0

View File

@ -114,6 +114,7 @@
// Gen7 hold effects
#define HOLD_EFFECT_PROTECTIVE_PADS 149
#define HOLD_EFFECT_TERRAIN_EXTENDER 150
#define HOLD_EFFECT_CHOICE(holdEffect)((holdEffect == HOLD_EFFECT_CHOICE_BAND || holdEffect == HOLD_EFFECT_CHOICE_SCARF || holdEffect == HOLD_EFFECT_CHOICE_SPECS))

View File

@ -6245,8 +6245,11 @@ static void HandleTerrainMove(u32 moveEffect)
}
else
{
gFieldStatuses &= ~(STATUS_FIELD_MISTY_TERRAIN | STATUS_FIELD_GRASSY_TERRAIN | EFFECT_ELECTRIC_TERRAIN | EFFECT_PSYCHIC_TERRAIN);
gFieldStatuses &= ~(STATUS_FIELD_MISTY_TERRAIN | STATUS_FIELD_GRASSY_TERRAIN | STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_PSYCHIC_TERRAIN);
gFieldStatuses |= statusFlag;
if (GetBattlerHoldEffect(gBattlerAttacker, TRUE) == HOLD_EFFECT_TERRAIN_EXTENDER)
*timer = 8;
else
*timer = 5;
gBattlescriptCurrInstr += 7;
}

View File

@ -2568,10 +2568,27 @@ bool32 TryChangeBattleWeather(u8 battler, u32 weatherEnumId, bool32 viaAbility)
return TRUE;
}
else
{
return FALSE;
}
static bool32 TryChangeBattleTerrain(u32 battler, u32 statusFlag, u8 *timer)
{
if (!(gFieldStatuses & statusFlag))
{
gFieldStatuses &= ~(STATUS_FIELD_MISTY_TERRAIN | STATUS_FIELD_GRASSY_TERRAIN | EFFECT_ELECTRIC_TERRAIN | EFFECT_PSYCHIC_TERRAIN);
gFieldStatuses |= statusFlag;
if (GetBattlerHoldEffect(battler, TRUE) == HOLD_EFFECT_TERRAIN_EXTENDER)
*timer = 8;
else
*timer = 5;
gBattlerAttacker = gBattleScripting.battler = battler;
return TRUE;
}
return FALSE;
}
u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveArg)
@ -2780,6 +2797,34 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
effect++;
}
break;
case ABILITY_ELECTRIC_SURGE:
if (TryChangeBattleTerrain(battler, STATUS_FIELD_ELECTRIC_TERRAIN, &gFieldTimers.electricTerrainTimer))
{
BattleScriptPushCursorAndCallback(BattleScript_ElectricSurgeActivates);
effect++;
}
break;
case ABILITY_GRASSY_SURGE:
if (TryChangeBattleTerrain(battler, STATUS_FIELD_GRASSY_TERRAIN, &gFieldTimers.grassyTerrainTimer))
{
BattleScriptPushCursorAndCallback(BattleScript_GrassySurgeActivates);
effect++;
}
break;
case ABILITY_MISTY_SURGE:
if (TryChangeBattleTerrain(battler, STATUS_FIELD_MISTY_TERRAIN, &gFieldTimers.mistyTerrainTimer))
{
BattleScriptPushCursorAndCallback(BattleScript_MistySurgeActivates);
effect++;
}
break;
case ABILITY_PSYCHIC_SURGE:
if (TryChangeBattleTerrain(battler, STATUS_FIELD_PSYCHIC_TERRAIN, &gFieldTimers.psychicTerrainTimer))
{
BattleScriptPushCursorAndCallback(BattleScript_PsychicSurgeActivates);
effect++;
}
break;
case ABILITY_INTIMIDATE:
if (!(gSpecialStatuses[battler].intimidatedMon))
{
@ -3454,7 +3499,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
{
BattleScriptPushCursorAndCallback(BattleScript_TraceActivates);
gStatuses3[i] &= ~(STATUS3_TRACE);
gBattleScripting.battler = i;
gBattlerAbility = gBattleScripting.battler = i;
PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gActiveBattler, gBattlerPartyIndexes[gActiveBattler])
PREPARE_ABILITY_BUFFER(gBattleTextBuff2, gLastUsedAbility)