From 6078cd3e15362fe99fdb42db2559fb39af3e4ffe Mon Sep 17 00:00:00 2001 From: Eduardo Alvaro Quezada D'Ottone Date: Sat, 11 Apr 2020 06:24:25 -0400 Subject: [PATCH] Anticipation ability (#282) --- data/battle_scripts_1.s | 7 +++++++ include/battle_scripts.h | 1 + src/battle_message.c | 5 +++-- src/battle_util.c | 43 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 2 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 994679d837..2d0a530444 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -5880,6 +5880,13 @@ BattleScript_IllusionOff:: waitmessage 0x40 return +BattleScript_AnticipationActivates:: + pause 0x5 + call BattleScript_AbilityPopUp + printstring STRINGID_ANTICIPATIONACTIVATES + waitmessage 0x40 + return + BattleScript_AftermathDmg:: pause 0x20 call BattleScript_AbilityPopUp diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 93f4e3b099..f30cec0255 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -330,5 +330,6 @@ extern const u8 BattleScript_DancerActivates[]; extern const u8 BattleScript_AftermathDmg[]; extern const u8 BattleScript_StanceChangeActivates[]; extern const u8 BattleScript_DisguiseBustedActivates[]; +extern const u8 BattleScript_AnticipationActivates[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/src/battle_message.c b/src/battle_message.c index bd2b64b60a..13d8a82c89 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -587,7 +587,7 @@ static const u8 sText_SlowStartEnters[] = _("{B_ATK_NAME_WITH_PREFIX} can't get static const u8 sText_SlowStartEnd[] = _("{B_ATK_NAME_WITH_PREFIX} finally got its act together!"); static const u8 sText_SolarPowerHpDrop[] = _("The {B_ATK_NAME_WITH_PREFIX}'s {B_ATK_ABILITY}\ntakes its toll!"); static const u8 sText_AftermathDmg[] = _("{B_ATK_NAME_WITH_PREFIX} is hurt!"); -static const u8 sText_AnticipationActivates[] = _("The {B_ATK_NAME_WITH_PREFIX} shuddered in {B_ATK_ABILITY}!"); +static const u8 sText_AnticipationActivates[] = _("The {B_ATK_NAME_WITH_PREFIX} shuddered\nin anticipation!"); static const u8 sText_ForewarnActivates[] = _("{B_ATK_ABILITY} alerted the {B_ATK_NAME_WITH_PREFIX} to the\n{B_DEF_NAME_WITH_PREFIX}'s {B_BUFF1}!"); static const u8 sText_IceBodyHpGain[] = _("{B_ATK_NAME_WITH_PREFIX}'s {B_ATK_ABILITY}\nhealed it a little bit!"); static const u8 sText_SnowWarningHail[] = _("It started to hail!"); @@ -1220,7 +1220,8 @@ const u16 gDmgHazardsStringIds[] = const u16 gSwitchInAbilityStringIds[] = { - STRINGID_MOLDBREAKERENTERS, STRINGID_TERAVOLTENTERS, STRINGID_TURBOBLAZEENTERS, STRINGID_SLOWSTARTENTERS, STRINGID_UNNERVEENTERS + STRINGID_MOLDBREAKERENTERS, STRINGID_TERAVOLTENTERS, STRINGID_TURBOBLAZEENTERS, + STRINGID_SLOWSTARTENTERS, STRINGID_UNNERVEENTERS, STRINGID_ANTICIPATIONACTIVATES }; const u16 gMissStringIds[] = diff --git a/src/battle_util.c b/src/battle_util.c index ea46e3fd49..a1567bc814 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2863,6 +2863,49 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA effect++; } break; + case ABILITY_ANTICIPATION: + { + bool16 shudders = FALSE; + u8 side = (GetBattlerPosition(battler) ^ BIT_SIDE) & BIT_SIDE; // side of the opposing pokemon + u8 target1 = GetBattlerAtPosition(side); + u8 target2 = GetBattlerAtPosition(side + BIT_FLANK); + + if (IsBattlerAlive(target1)) + { + for(i = 0; i < MAX_MON_MOVES; i++) + { + move = gBattleMons[target1].moves[i]; + GET_MOVE_TYPE(move, moveType); + if(CalcTypeEffectivenessMultiplier(move, moveType, target1, battler, FALSE) >= UQ_4_12(2.0)) + { + shudders = TRUE; + break; + } + } + } + + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && IsBattlerAlive(target2)) + { + for(i = 0; i < MAX_MON_MOVES; i++) + { + move = gBattleMons[target2].moves[i]; + GET_MOVE_TYPE(move, moveType); + if(CalcTypeEffectivenessMultiplier(move, moveType, target2, battler, FALSE) >= UQ_4_12(2.0)) + { + shudders = TRUE; + break; + } + } + } + if (!gSpecialStatuses[battler].switchInAbilityDone && shudders) + { + gBattleCommunication[MULTISTRING_CHOOSER] = 5; + gSpecialStatuses[battler].switchInAbilityDone = 1; + BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); + effect++; + } + } + break; case ABILITY_DOWNLOAD: if (!gSpecialStatuses[battler].switchInAbilityDone) {