From 831816e9b2b32f262d42968d388d1014568b2fce Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 22 Jul 2018 22:21:47 +0200 Subject: [PATCH] Switch-in abilities with a message --- data/battle_scripts_1.s | 5 ++ include/battle.h | 1 + include/battle_scripts.h | 1 + include/constants/battle_string_ids.h | 20 +++++++- src/battle_message.c | 41 +++++++++++++++++ src/battle_script_commands.c | 1 + src/battle_util.c | 66 +++++++++++++++++++++++---- 7 files changed, 124 insertions(+), 11 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index a2b1bbee4..c2116784e 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -4645,6 +4645,11 @@ BattleScript_AttackerAbilityStatRaise:: BattleScript_AttackerAbilityStatRaiseEnd3:: call BattleScript_AttackerAbilityStatRaise end3 + +BattleScript_SwitchInAbilityMsg:: + printfromtable gSwitchInAbilityStringIds + waitmessage 0x40 + end3 BattleScript_RoughSkinActivates:: orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 diff --git a/include/battle.h b/include/battle.h index 7ad418626..4dd462930 100644 --- a/include/battle.h +++ b/include/battle.h @@ -231,6 +231,7 @@ struct SpecialStatus u8 focusSashed:1; u8 sturdied:1; u8 stormDrainRedirected:1; + u8 switchInAbilityDone:1; s32 dmg; s32 physicalDmg; s32 specialDmg; diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 0971b1182..f07670c51 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -313,5 +313,6 @@ extern const u8 BattleScript_AttackerAbilityStatRaise[]; extern const u8 BattleScript_AttackerAbilityStatRaiseEnd3[]; extern const u8 BattleScript_PoisonHealActivates[]; extern const u8 BattleScript_BadDreamsActivates[]; +extern const u8 BattleScript_SwitchInAbilityMsg[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index 80c57af87..a3d6cb8f8 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -455,7 +455,25 @@ #define STRINGID_ATTACKERABILITYSTATRAISE 452 #define STRINGID_POISONHEALHPUP 453 #define STRINGID_BADDREAMSDMG 454 +#define STRINGID_MOLDBREAKERENTERS 455 +#define STRINGID_TERAVOLTENTERS 456 +#define STRINGID_TURBOBLAZEENTERS 457 +#define STRINGID_SLOWSTARTENTERS 458 +#define STRINGID_SLOWSTARTEND 459 +#define STRINGID_SOLARPOWERHPDROP 460 +#define STRINGID_AFTERMATHDMG 461 +#define STRINGID_ANTICIPATIONACTIVATES 462 +#define STRINGID_FOREWARNACTIVATES 463 +#define STRINGID_ICEBODYHPGAIN 464 +#define STRINGID_SNOWWARNINGHAIL 465 +#define STRINGID_FRISKACTIVATES 466 +#define STRINGID_UNNERVEENTERS 467 +#define STRINGID_HARVESTBERRY 468 +#define STRINGID_MOXIEATKRISE 469 +#define STRINGID_MAGICBOUNCEACTIVATES 470 +#define STRINGID_PROTEANTYPECHANGE 471 +#define STRINGID_SYMBIOSISITEMPASS 472 -#define BATTLESTRINGS_COUNT 443 +#define BATTLESTRINGS_COUNT 463 #endif // GUARD_CONSTANTS_BATTLE_STRING_IDS_H diff --git a/src/battle_message.c b/src/battle_message.c index 43e845b3e..9265c2156 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -598,6 +598,24 @@ static const u8 sText_GrassyTerrainEnds[] = _(""); static const u8 sText_AngryPointActivates[] = _(""); static const u8 sText_PoisonHealHpUp[] = _(""); static const u8 sText_BadDreamsDmg[] = _(""); +static const u8 sText_MoldBreakerEnters[] = _(""); +static const u8 sText_TeravoltEnters[] = _(""); +static const u8 sText_TurboblazeEnters[] = _(""); +static const u8 sText_SlowStartEnters[] = _(""); +static const u8 sText_SlowStartEnd[] = _(""); +static const u8 sText_SolarPowerHpDrop[] = _(""); +static const u8 sText_AftermathDmg[] = _(""); +static const u8 sText_AnticipationActivates[] = _(""); +static const u8 sText_ForewarnActivates[] = _(""); +static const u8 sText_IceBodyHpGain[] = _(""); +static const u8 sText_SnowWarningHail[] = _(""); +static const u8 sText_FriskActivates[] = _(""); +static const u8 sText_UnnerveEnters[] = _(""); +static const u8 sText_HarvestBerry[] = _(""); +static const u8 sText_MoxieAtkRise[] = _(""); +static const u8 sText_MagicBounceActivates[] = _(""); +static const u8 sText_ProteanTypeChange[] = _(""); +static const u8 sText_SymbiosisItemPass[] = _(""); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { @@ -1045,6 +1063,29 @@ const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = sText_AttackerAbilityRaisedStat, // 452 sText_PoisonHealHpUp, // 453 sText_BadDreamsDmg, // 454 + sText_MoldBreakerEnters, + sText_TeravoltEnters, + sText_TurboblazeEnters, + sText_SlowStartEnters, + sText_SlowStartEnd, + sText_SolarPowerHpDrop, + sText_AftermathDmg, + sText_AnticipationActivates, + sText_ForewarnActivates, + sText_IceBodyHpGain, + sText_SnowWarningHail, + sText_FriskActivates, + sText_UnnerveEnters, + sText_HarvestBerry, + sText_MoxieAtkRise, + sText_MagicBounceActivates, + sText_ProteanTypeChange, + sText_SymbiosisItemPass, +}; + +const u16 gSwitchInAbilityStringIds[] = +{ + STRINGID_MOLDBREAKERENTERS, STRINGID_TERAVOLTENTERS, STRINGID_TURBOBLAZEENTERS, STRINGID_SLOWSTARTENTERS, STRINGID_UNNERVEENTERS }; const u16 gMissStringIds[] = diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 7205cfb47..5306822ed 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -6386,6 +6386,7 @@ static void atk76_various(void) case VARIOUS_RESET_INTIMIDATE_TRACE_BITS: gSpecialStatuses[gActiveBattler].intimidatedMon = 0; gSpecialStatuses[gActiveBattler].traced = 0; + gSpecialStatuses[gActiveBattler].switchInAbilityDone = 0; break; case VARIOUS_UPDATE_CHOICE_MOVE_ON_LVL_UP: if (gBattlerPartyIndexes[0] == gBattleStruct->expGetterMonId || gBattlerPartyIndexes[2] == gBattleStruct->expGetterMonId) diff --git a/src/battle_util.c b/src/battle_util.c index 6ef1c1dd8..0c7dfcf9e 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2380,7 +2380,53 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA BattleScriptPushCursorAndCallback(BattleScript_OverworldWeatherStarts); } break; + case ABILITY_MOLD_BREAKER: + if (!gSpecialStatuses[battler].switchInAbilityDone) + { + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + gSpecialStatuses[battler].switchInAbilityDone = 1; + BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); + effect++; + } + break; + case ABILITY_TERAVOLT: + if (!gSpecialStatuses[battler].switchInAbilityDone) + { + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + gSpecialStatuses[battler].switchInAbilityDone = 1; + BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); + effect++; + } + break; + case ABILITY_TURBOBLAZE: + if (!gSpecialStatuses[battler].switchInAbilityDone) + { + gBattleCommunication[MULTISTRING_CHOOSER] = 2; + gSpecialStatuses[battler].switchInAbilityDone = 1; + BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); + effect++; + } + break; + case ABILITY_SLOW_START: + if (!gSpecialStatuses[battler].switchInAbilityDone) + { + gBattleCommunication[MULTISTRING_CHOOSER] = 3; + gSpecialStatuses[battler].switchInAbilityDone = 1; + BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); + effect++; + } + break; + case ABILITY_UNNERVE: + if (!gSpecialStatuses[battler].switchInAbilityDone) + { + gBattleCommunication[MULTISTRING_CHOOSER] = 4; + gSpecialStatuses[battler].switchInAbilityDone = 1; + BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); + effect++; + } + break; case ABILITY_DOWNLOAD: + if (!gSpecialStatuses[battler].switchInAbilityDone) { u8 statId; u32 opposingBattler = BATTLE_OPPOSITE(battler); @@ -2407,6 +2453,8 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA else statId = STAT_ATK; + gSpecialStatuses[battler].switchInAbilityDone = 1; + if (gBattleMons[battler].statStages[statId] != 0xC) { gBattleMons[battler].statStages[statId]++; @@ -2469,18 +2517,16 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA break; case ABILITY_CLOUD_NINE: case ABILITY_AIR_LOCK: + // that's a weird choice for a variable, why not use i or battler? + for (target1 = 0; target1 < gBattlersCount; target1++) { - // that's a weird choice for a variable, why not use i or battler? - for (target1 = 0; target1 < gBattlersCount; target1++) + effect = CastformDataTypeChange(target1); + if (effect != 0) { - effect = CastformDataTypeChange(target1); - if (effect != 0) - { - BattleScriptPushCursorAndCallback(BattleScript_CastformChange); - gBattleScripting.battler = target1; - *(&gBattleStruct->formToChangeInto) = effect - 1; - break; - } + BattleScriptPushCursorAndCallback(BattleScript_CastformChange); + gBattleScripting.battler = target1; + *(&gBattleStruct->formToChangeInto) = effect - 1; + break; } } break;