From 7a52404fd301933302d4d63e8a63299ed90a7314 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 6 Dec 2022 02:51:13 -0300 Subject: [PATCH] Implemented Supreme Overlord's effect --- data/battle_scripts_1.s | 7 ++++++ include/battle_scripts.h | 1 + include/constants/battle_string_ids.h | 3 ++- src/battle_message.c | 2 ++ src/battle_util.c | 31 +++++++++++++++++++++++++++ 5 files changed, 43 insertions(+), 1 deletion(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 00fb0ba27..11f819c06 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -8444,6 +8444,13 @@ BattleScript_RuinAbilityActivates:: waitmessage B_WAIT_TIME_LONG end3 +BattleScript_SupremeOverlordActivates:: + pause B_WAIT_TIME_SHORT + call BattleScript_AbilityPopUp + printstring STRINGID_ATTACKERGAINEDSTRENGTHFROMTHEFALLEN + waitmessage B_WAIT_TIME_LONG + end3 + BattleScript_AttackWeakenedByStrongWinds:: pause B_WAIT_TIME_SHORT printstring STRINGID_ATTACKWEAKENEDBSTRONGWINDS diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 13fa5a4a6..72db7e1f9 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -445,6 +445,7 @@ extern const u8 BattleScript_QuarkDriveActivates[]; extern const u8 BattleScript_GoodAsGoldActivates[]; extern const u8 BattleScript_RuinAbilityActivates[]; extern const u8 BattleScript_CudChewActivates[]; +extern const u8 BattleScript_SupremeOverlordActivates[]; // zmoves extern const u8 BattleScript_ZMoveActivateDamaging[]; diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index 9c0965bb5..39022d167 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -635,8 +635,9 @@ #define STRINGID_STATWASHEIGHTENED 633 #define STRINGID_ELECTRICTERRAINACTIVATEDABILITY 634 #define STRINGID_ABILITYWEAKENEDFSURROUNDINGMONSSTAT 635 +#define STRINGID_ATTACKERGAINEDSTRENGTHFROMTHEFALLEN 636 -#define BATTLESTRINGS_COUNT 636 +#define BATTLESTRINGS_COUNT 637 // This is the string id that gBattleStringsTable starts with. // String ids before this (e.g. STRINGID_INTROMSG) are not in the table, diff --git a/src/battle_message.c b/src/battle_message.c index d109e0f4e..7466ffa91 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -764,9 +764,11 @@ static const u8 sText_SunlightActivatedAbility[] = _("The harsh sunlight activat static const u8 sText_StatWasHeightened[] = _("{B_ATK_NAME_WITH_PREFIX}'s {B_BUFF1} was heightened!"); static const u8 sText_ElectricTerrainActivatedAbility[] = _("The Electric Terrain activated\n{B_ATK_NAME_WITH_PREFIX}'s {B_ATK_ABILITY}!"); static const u8 sText_AbilityWeakenedSurroundingMonsStat[] = _("{B_ATK_NAME_WITH_PREFIX}'s {B_ATK_ABILITY}\nweakened the {B_BUFF1} of\lall surrounding Pokémon!\p"); +static const u8 sText_AttackerGainedStrengthFromTheFallen[] = _("{B_ATK_NAME_WITH_PREFIX} gained strength\nfrom the fallen!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_ATTACKERGAINEDSTRENGTHFROMTHEFALLEN - BATTLESTRINGS_TABLE_START] = sText_AttackerGainedStrengthFromTheFallen, [STRINGID_ABILITYWEAKENEDFSURROUNDINGMONSSTAT - BATTLESTRINGS_TABLE_START] = sText_AbilityWeakenedSurroundingMonsStat, [STRINGID_ELECTRICTERRAINACTIVATEDABILITY - BATTLESTRINGS_TABLE_START] = sText_ElectricTerrainActivatedAbility, [STRINGID_STATWASHEIGHTENED - BATTLESTRINGS_TABLE_START] = sText_StatWasHeightened, diff --git a/src/battle_util.c b/src/battle_util.c index 2362a3fff..36120a756 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4957,6 +4957,14 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; + case ABILITY_SUPREME_OVERLORD: + if (!gSpecialStatuses[battler].switchInAbilityDone && CountUsablePartyMons(battler) < PARTY_SIZE) + { + gSpecialStatuses[battler].switchInAbilityDone = TRUE; + BattleScriptPushCursorAndCallback(BattleScript_SupremeOverlordActivates); + effect++; + } + break; #if B_WEATHER_FORMS < GEN_5 default: if (gBattleMons[battler].species == SPECIES_CHERRIM) @@ -8722,6 +8730,26 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef) return basePower; } +// Supreme Overlord adds a damage boost for each fainted ally. +// The first ally adds a x1.2 boost, and subsequent allies add an extra x0.1 boost each. +static u16 ApplySupremeOverlordModifier(u8 battlerId) +{ + u8 side = GetBattlerSide(battlerId); + struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; + u8 i; + u16 modifier = UQ_4_12(1.0); + bool8 appliedFirstBoost = FALSE; + + for (i = 0; i < PARTY_SIZE; i++) + { + if (GetMonData(&party[i], MON_DATA_HP) == 0) + modifier += (!appliedFirstBoost) ? UQ_4_12(0.2) : UQ_4_12(0.1); + appliedFirstBoost = TRUE; + } + + return modifier; +} + static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType, bool32 updateFlags) { u32 i; @@ -8866,6 +8894,9 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe if (gBattleMoves[move].flags & FLAG_SLICING_MOVE) MulModifier(&modifier, UQ_4_12(1.5)); break; + case ABILITY_SUPREME_OVERLORD: + MulModifier(&modifier, ApplySupremeOverlordModifier(battlerAtk)); + break; } // field abilities