From e62f1475d4d31d8766035831c4c2a6ffeb64970c Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 19 Apr 2020 12:07:56 +0200 Subject: [PATCH] Beast Boost and Receiver --- asm/macros/battle_script.inc | 8 +++ data/battle_scripts_1.s | 14 ++++- include/battle_scripts.h | 1 + include/constants/battle_script_commands.h | 2 + include/constants/battle_string_ids.h | 3 +- src/battle_message.c | 2 + src/battle_script_commands.c | 59 ++++++++++++++++++++++ 7 files changed, 86 insertions(+), 3 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 214adcf78f..5a3861a295 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1439,6 +1439,14 @@ various \battler, VARIOUS_TRY_ACTIVATE_MOXIE .endm + .macro tryactivatebeastboost battler:req + various \battler, VARIOUS_TRY_ACTIVATE_BEAST_BOOST + .endm + + .macro tryactivatereceiver battler:req + various \battler, VARIOUS_TRY_ACTIVATE_RECEIVER + .endm + .macro tryactivatesoulheart various BS_ATTACKER, VARIOUS_TRY_ACTIVATE_SOULHEART .endm diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index d07a0b6177..6371114c67 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -4784,6 +4784,7 @@ BattleScript_FaintAttacker:: printstring STRINGID_ATTACKERFAINTED cleareffectsonfaint BS_ATTACKER tryactivatesoulheart + tryactivatereceiver BS_ATTACKER trytrainerslidefirstdownmsg BS_ATTACKER return @@ -4794,9 +4795,11 @@ BattleScript_FaintTarget:: dofaintanimation BS_TARGET printstring STRINGID_TARGETFAINTED cleareffectsonfaint BS_TARGET - tryactivatesoulheart - tryactivatemoxie BS_ATTACKER tryactivatefellstinger BS_ATTACKER + tryactivatesoulheart + tryactivatereceiver BS_TARGET + tryactivatemoxie BS_ATTACKER + tryactivatebeastboost BS_ATTACKER trytrainerslidefirstdownmsg BS_TARGET return @@ -6405,6 +6408,13 @@ BattleScript_TraceActivatesEnd3:: call BattleScript_TraceActivates end3 +BattleScript_ReceiverActivates:: + call BattleScript_AbilityPopUp + printstring STRINGID_RECEIVERABILITYTAKEOVER + waitmessage 0x40 + settracedability BS_ABILITY_BATTLER + return + BattleScript_RainDishActivates:: call BattleScript_AbilityPopUp printstring STRINGID_PKMNSXRESTOREDHPALITTLE2 diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 3256ca82cf..8ba5920d04 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -335,5 +335,6 @@ extern const u8 BattleScript_AnticipationActivates[]; extern const u8 BattleScript_SlowStartEnds[]; extern const u8 BattleScript_HealerActivates[]; extern const u8 BattleScript_ScriptingAbilityStatRaise[]; +extern const u8 BattleScript_ReceiverActivates[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index a02e0e73fe..d1f729eeac 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -150,6 +150,8 @@ #define VARIOUS_JUMP_IF_FULL_HP 87 #define VARIOUS_LOSE_TYPE 88 #define VARIOUS_TRY_ACTIVATE_SOULHEART 89 +#define VARIOUS_TRY_ACTIVATE_RECEIVER 90 +#define VARIOUS_TRY_ACTIVATE_BEAST_BOOST 91 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index c2f87298b6..24cdd4f905 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -544,7 +544,8 @@ #define STRINGID_ATTACKERLOSTFIRETYPE 540 #define STRINGID_HEALERCURE 541 #define STRINGID_SCRIPTINGABILITYSTATRAISE 542 +#define STRINGID_RECEIVERABILITYTAKEOVER 543 -#define BATTLESTRINGS_COUNT 543 +#define BATTLESTRINGS_COUNT 544 #endif // GUARD_CONSTANTS_BATTLE_STRING_IDS_H diff --git a/src/battle_message.c b/src/battle_message.c index c156c7ff1b..f1168fe1bf 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -665,9 +665,11 @@ static const u8 sText_IllusionWoreOff[] = _("{B_DEF_NAME_WITH_PREFIX}'s Illusion static const u8 sText_AttackerCuredTargetStatus[] = _("{B_ATK_NAME_WITH_PREFIX} cured\n{B_DEF_NAME_WITH_PREFIX}'s problem!"); static const u8 sText_AttackerLostFireType[] = _("{B_ATK_NAME_WITH_PREFIX} burned itself out!"); static const u8 sText_HealerCure[] = _("{B_ATK_NAME_WITH_PREFIX}'s {B_LAST_ABILITY}\ncured {B_SCR_ACTIVE_NAME_WITH_PREFIX}'s problem!"); +static const u8 sText_ReceiverAbilityTakeOver[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX}'s {B_SCR_ACTIVE_ABILITY}\nwas taken over!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_RECEIVERABILITYTAKEOVER - 12] = sText_ReceiverAbilityTakeOver, [STRINGID_SCRIPTINGABILITYSTATRAISE - 12] = sText_ScriptingAbilityRaisedStat, [STRINGID_HEALERCURE - 12] = sText_HealerCure, [STRINGID_ATTACKERLOSTFIRETYPE - 12] = sText_AttackerLostFireType, diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index a0f51be2e9..25d011ea7c 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -6759,6 +6759,22 @@ static void RecalcBattlerStats(u32 battler, struct Pokemon *mon) gBattleMons[battler].type2 = gBaseStats[gBattleMons[battler].species].type2; } +static u32 GetHighestStatId(u32 battlerId) +{ + u32 i, highestId = STAT_ATK, highestStat = gBattleMons[battlerId].attack; + + for (i = STAT_DEF; i < NUM_STATS; i++) + { + u16 *statVal = &gBattleMons[battlerId].attack + (i - 1); + if (*statVal > highestStat) + { + highestStat = *statVal; + highestId = i; + } + } + return highestId; +} + static void Cmd_various(void) { struct Pokemon *mon; @@ -6803,6 +6819,7 @@ static void Cmd_various(void) return; case VARIOUS_TRACE_ABILITY: gBattleMons[gActiveBattler].ability = gBattleStruct->tracedAbility[gActiveBattler]; + RecordAbilityBattle(gActiveBattler, gBattleMons[gActiveBattler].ability); break; case VARIOUS_TRY_ILLUSION_OFF: if (GetIllusionMonPtr(gActiveBattler) != NULL) @@ -7124,6 +7141,48 @@ static void Cmd_various(void) return; } break; + case VARIOUS_TRY_ACTIVATE_RECEIVER: // Partner gets fainted's ally ability + gBattlerAbility = BATTLE_PARTNER(gActiveBattler); + i = GetBattlerAbility(gBattlerAbility); + if (IsBattlerAlive(gBattlerAbility) + && (i == ABILITY_RECEIVER || i == ABILITY_POWER_OF_ALCHEMY)) + { + switch (gBattleMons[gActiveBattler].ability) + { // Can't copy these abilities. + case ABILITY_POWER_OF_ALCHEMY: case ABILITY_RECEIVER: + case ABILITY_FORECAST: case ABILITY_MULTITYPE: + case ABILITY_FLOWER_GIFT: case ABILITY_ILLUSION: + case ABILITY_WONDER_GUARD: case ABILITY_ZEN_MODE: + case ABILITY_STANCE_CHANGE: case ABILITY_IMPOSTER: + case ABILITY_POWER_CONSTRUCT: case ABILITY_BATTLE_BOND: + case ABILITY_SCHOOLING: case ABILITY_COMATOSE: + case ABILITY_SHIELDS_DOWN: case ABILITY_DISGUISE: + case ABILITY_RKS_SYSTEM: case ABILITY_TRACE: + break; + default: + gBattleStruct->tracedAbility[gBattlerAbility] = gBattleMons[gActiveBattler].ability; // re-using the variable for trace + gBattleScripting.battler = gActiveBattler; + BattleScriptPush(gBattlescriptCurrInstr + 3); + gBattlescriptCurrInstr = BattleScript_ReceiverActivates; + return; + } + } + break; + case VARIOUS_TRY_ACTIVATE_BEAST_BOOST: + i = GetHighestStatId(gActiveBattler); + if (GetBattlerAbility(gActiveBattler) == ABILITY_BEAST_BOOST + && HasAttackerFaintedTarget() + && !NoAliveMonsForEitherParty() + && gBattleMons[gBattlerAttacker].statStages[i] != 12) + { + gBattleMons[gBattlerAttacker].statStages[i]++; + SET_STATCHANGER(i, 1, FALSE); + PREPARE_STAT_BUFFER(gBattleTextBuff1, i); + BattleScriptPush(gBattlescriptCurrInstr + 3); + gBattlescriptCurrInstr = BattleScript_AttackerAbilityStatRaise; + return; + } + break; case VARIOUS_TRY_ACTIVATE_SOULHEART: while (gBattleStruct->soulheartBattlerId < gBattlersCount) {