From 653364fd71c7e8925b61b2f025e541cafa2bbb98 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Fri, 2 Dec 2022 23:01:22 -0300 Subject: [PATCH 01/36] Added the basic data for the Gen. 9 Abilities --- include/constants/abilities.h | 37 +++++++++- src/battle_debug.c | 2 +- src/data/text/abilities.h | 124 ++++++++++++++++++++++++++++++++++ 3 files changed, 161 insertions(+), 2 deletions(-) diff --git a/include/constants/abilities.h b/include/constants/abilities.h index 23b9fe2b7..94e5986f7 100644 --- a/include/constants/abilities.h +++ b/include/constants/abilities.h @@ -292,6 +292,41 @@ #define ABILITIES_COUNT_GEN8 268 -#define ABILITIES_COUNT ABILITIES_COUNT_GEN8 +// Gen 9 +#define ABILITY_LINGERING_AROMA 268 +#define ABILITY_SEED_SOWER 269 +#define ABILITY_THERMAL_EXCHANGE 270 +#define ABILITY_ANGER_SHELL 271 +#define ABILITY_PURIFYING_SALT 272 +#define ABILITY_WELL_BAKED_BODY 273 +#define ABILITY_WIND_RIDER 274 +#define ABILITY_GUARD_DOG 275 +#define ABILITY_ROCKY_PAYLOAD 276 +#define ABILITY_WIND_POWER 277 +#define ABILITY_ZERO_TO_HERO 278 +#define ABILITY_COMMANDER 279 +#define ABILITY_ELECTROMORPHOSIS 280 +#define ABILITY_PROTOSYNTHESIS 281 +#define ABILITY_QUARK_DRIVE 282 +#define ABILITY_GOOD_AS_GOLD 283 +#define ABILITY_VESSEL_OF_RUIN 284 +#define ABILITY_SWORD_OF_RUIN 285 +#define ABILITY_TABLETS_OF_RUIN 286 +#define ABILITY_BEADS_OF_RUIN 287 +#define ABILITY_ORICHALCUM_PULSE 288 +#define ABILITY_HADRON_ENGINE 289 +#define ABILITY_OPPORTUNIST 290 +#define ABILITY_CUD_CHEW 291 +#define ABILITY_SHARPNESS 292 +#define ABILITY_SUPREME_OVERLORD 293 +#define ABILITY_COSTAR 294 +#define ABILITY_TOXIC_DEBRIS 295 +#define ABILITY_ARMOR_TAIL 296 +#define ABILITY_EARTH_EATER 297 +#define ABILITY_MYCELIUM_MIGHT 298 + +#define ABILITIES_COUNT_GEN9 299 + +#define ABILITIES_COUNT ABILITIES_COUNT_GEN9 #endif // GUARD_CONSTANTS_ABILITIES_H diff --git a/src/battle_debug.c b/src/battle_debug.c index 568b9a96e..a8f975096 100644 --- a/src/battle_debug.c +++ b/src/battle_debug.c @@ -1759,7 +1759,7 @@ static void SetUpModifyArrows(struct BattleDebugMenu *data) { case LIST_ITEM_ABILITY: data->modifyArrows.minValue = 0; - data->modifyArrows.maxValue = ABILITIES_COUNT_GEN8 - 1; + data->modifyArrows.maxValue = ABILITIES_COUNT - 1; data->modifyArrows.maxDigits = 3; data->modifyArrows.modifiedValPtr = &gBattleMons[data->battlerId].ability; data->modifyArrows.typeOfVal = VAL_U16; diff --git a/src/data/text/abilities.h b/src/data/text/abilities.h index ac11b9de8..96407c340 100644 --- a/src/data/text/abilities.h +++ b/src/data/text/abilities.h @@ -254,6 +254,37 @@ static const u8 sChillingNeighDescription[] = _("KOs boost Attack stat."); static const u8 sGrimNeighDescription[] = _("KOs boost Sp. Atk stat."); static const u8 sAsOneIceRiderDescription[] = _("Unnerve and Chilling Neigh."); static const u8 sAsOneShadowRiderDescription[] = _("Unnerve and Grim Neigh."); +static const u8 sLingeringAromaDescription[] = _("Spreads with contact."); +static const u8 sSeedSowerDescription[] = _("Affects terrain when hit."); +static const u8 sThermalExchangeDescription[] = _("Fire hits up Attack."); +static const u8 sAngerShellDescription[] = _("Gets angry at half HP."); +static const u8 sPurifyingSaltDescription[] = _("Protected by pure salts."); +static const u8 sWellBakedBodyDescription[] = _("Strengthened by Fire."); +static const u8 sWindRiderDescription[] = _("Ups Attack if hit by wind."); +static const u8 sGuardDogDescription[] = _("Cannot be intimidated."); +static const u8 sRockyPayloadDescription[] = _("Powers up Rock moves."); +static const u8 sWindPowerDescription[] = _("Gets charged by wind."); +static const u8 sZeroToHeroDescription[] = _("Changes form on switch out."); +static const u8 sCommanderDescription[] = _("Commands from Dondozo."); +static const u8 sElectromorphosisDescription[] = _("Gets Charged on contact."); +static const u8 sProtosynthesisDescription[] = _("Sun boosts best stat."); +static const u8 sQuarkDriveDescription[] = _("Elec. field ups best stat."); +static const u8 sGoodAsGoldDescription[] = _("Avoids status problems."); +static const u8 sVesselOfRuinDescription[] = _("Lowers foes' sp. damage."); +static const u8 sSwordOfRuinDescription[] = _("Lowers foes' defense."); +static const u8 sTabletsOfRuinDescription[] = _("Lowers foes' damage."); +static const u8 sBeadsOfRuinDescription[] = _("Lowers foes' sp. defense."); +static const u8 sOrichalcumPulseDescription[] = _("Summons sunlight in battle."); +static const u8 sHadronEngineDescription[] = _("Field becomes Electric."); +static const u8 sOpportunistDescription[] = _("Copies foe's stat change."); +static const u8 sCudChewDescription[] = _("Eats a used berry again."); +static const u8 sSharpnessDescription[] = _("Strengthens cutting moves."); +static const u8 sSupremeOverlordDescription[] = _("Inherits fallen's strength."); +static const u8 sCostarDescription[] = _("Copies ally's stat changes."); +static const u8 sToxicDebrisDescription[] = _("Throws poison spikes if hit."); +static const u8 sArmorTailDescription[] = _("Protects from priority."); +static const u8 sEarthEaterDescription[] = _("Eats ground to heal HP."); +static const u8 sMyceliumMightDescription[] = _("Status moves never fail."); #if B_EXPANDED_ABILITY_NAMES == TRUE const u8 gAbilityNames[ABILITIES_COUNT][ABILITY_NAME_LENGTH + 1] = @@ -526,6 +557,37 @@ const u8 gAbilityNames[ABILITIES_COUNT][ABILITY_NAME_LENGTH + 1] = [ABILITY_GRIM_NEIGH] = _("Grim Neigh"), [ABILITY_AS_ONE_ICE_RIDER] = _("As One"), [ABILITY_AS_ONE_SHADOW_RIDER] = _("As One"), + [ABILITY_LINGERING_AROMA] = _("Lingering Aroma"), + [ABILITY_SEED_SOWER] = _("Seed Sower"), + [ABILITY_THERMAL_EXCHANGE] = _("Thermal Exchange"), + [ABILITY_ANGER_SHELL] = _("Anger Shell"), + [ABILITY_PURIFYING_SALT] = _("Purifying Salt"), + [ABILITY_WELL_BAKED_BODY] = _("Well-Baked Body"), + [ABILITY_WIND_RIDER] = _("Wind Rider"), + [ABILITY_GUARD_DOG] = _("Guard Dog"), + [ABILITY_ROCKY_PAYLOAD] = _("Rocky Payload"), + [ABILITY_WIND_POWER] = _("Wind Power"), + [ABILITY_ZERO_TO_HERO] = _("Zero to Hero"), + [ABILITY_COMMANDER] = _("Commander"), + [ABILITY_ELECTROMORPHOSIS] = _("Electromorphosis"), + [ABILITY_PROTOSYNTHESIS] = _("Protosynthesis"), + [ABILITY_QUARK_DRIVE] = _("Quark Drive"), + [ABILITY_GOOD_AS_GOLD] = _("Good as Gold"), + [ABILITY_VESSEL_OF_RUIN] = _("Vessel of Ruin"), + [ABILITY_SWORD_OF_RUIN] = _("Sword of Ruin"), + [ABILITY_TABLETS_OF_RUIN] = _("Tablets of Ruin"), + [ABILITY_BEADS_OF_RUIN] = _("Beads of Ruin"), + [ABILITY_ORICHALCUM_PULSE] = _("Orichalcum Pulse"), + [ABILITY_HADRON_ENGINE] = _("Hadron Engine"), + [ABILITY_OPPORTUNIST] = _("Opportunist"), + [ABILITY_CUD_CHEW] = _("Cud Chew"), + [ABILITY_SHARPNESS] = _("Sharpness"), + [ABILITY_SUPREME_OVERLORD] = _("Supreme Overlord"), + [ABILITY_COSTAR] = _("Costar"), + [ABILITY_TOXIC_DEBRIS] = _("Toxic Debris"), + [ABILITY_ARMOR_TAIL] = _("Armor Tail"), + [ABILITY_EARTH_EATER] = _("Earth Eater"), + [ABILITY_MYCELIUM_MIGHT] = _("Mycelium Might"), }; #else // 12 characters const u8 gAbilityNames[ABILITIES_COUNT][ABILITY_NAME_LENGTH + 1] = @@ -798,6 +860,37 @@ const u8 gAbilityNames[ABILITIES_COUNT][ABILITY_NAME_LENGTH + 1] = [ABILITY_GRIM_NEIGH] = _("Grim Neigh"), [ABILITY_AS_ONE_ICE_RIDER] = _("As One"), [ABILITY_AS_ONE_SHADOW_RIDER] = _("As One"), + [ABILITY_LINGERING_AROMA] = _("LngerngAroma"), + [ABILITY_SEED_SOWER] = _("Seed Sower"), + [ABILITY_THERMAL_EXCHANGE] = _("ThrmlExchnge"), + [ABILITY_ANGER_SHELL] = _("Anger Shell"), + [ABILITY_PURIFYING_SALT] = _("PurfyingSalt"), + [ABILITY_WELL_BAKED_BODY] = _("WellBakedBdy"), + [ABILITY_WIND_RIDER] = _("Wind Rider"), + [ABILITY_GUARD_DOG] = _("Guard Dog"), + [ABILITY_ROCKY_PAYLOAD] = _("RockyPayload"), + [ABILITY_WIND_POWER] = _("Wind Power"), + [ABILITY_ZERO_TO_HERO] = _("Zero to Hero"), + [ABILITY_COMMANDER] = _("Commander"), + [ABILITY_ELECTROMORPHOSIS] = _("Elecmrphosis"), + [ABILITY_PROTOSYNTHESIS] = _("Protosnthsis"), + [ABILITY_QUARK_DRIVE] = _("Quark Drive"), + [ABILITY_GOOD_AS_GOLD] = _("Good as Gold"), + [ABILITY_VESSEL_OF_RUIN] = _("VesselOfRuin"), + [ABILITY_SWORD_OF_RUIN] = _("SwordOfRuin"), + [ABILITY_TABLETS_OF_RUIN] = _("TabltsOfRuin"), + [ABILITY_BEADS_OF_RUIN] = _("BeadsOfRuin"), + [ABILITY_ORICHALCUM_PULSE] = _("OrchlcumPlse"), + [ABILITY_HADRON_ENGINE] = _("HadronEngine"), + [ABILITY_OPPORTUNIST] = _("Opportunist"), + [ABILITY_CUD_CHEW] = _("Cud Chew"), + [ABILITY_SHARPNESS] = _("Sharpness"), + [ABILITY_SUPREME_OVERLORD] = _("SuprmeOvrlrd"), + [ABILITY_COSTAR] = _("Costar"), + [ABILITY_TOXIC_DEBRIS] = _("Toxic Debris"), + [ABILITY_ARMOR_TAIL] = _("Armor Tail"), + [ABILITY_EARTH_EATER] = _("Earth Eater"), + [ABILITY_MYCELIUM_MIGHT] = _("MceliumMight"), }; #endif @@ -1071,4 +1164,35 @@ const u8 *const gAbilityDescriptionPointers[ABILITIES_COUNT] = [ABILITY_GRIM_NEIGH] = sGrimNeighDescription, [ABILITY_AS_ONE_ICE_RIDER] = sAsOneIceRiderDescription, [ABILITY_AS_ONE_SHADOW_RIDER] = sAsOneShadowRiderDescription, + [ABILITY_LINGERING_AROMA] = sLingeringAromaDescription, + [ABILITY_SEED_SOWER] = sSeedSowerDescription, + [ABILITY_THERMAL_EXCHANGE] = sThermalExchangeDescription, + [ABILITY_ANGER_SHELL] = sAngerShellDescription, + [ABILITY_PURIFYING_SALT] = sPurifyingSaltDescription, + [ABILITY_WELL_BAKED_BODY] = sWellBakedBodyDescription, + [ABILITY_WIND_RIDER] = sWindRiderDescription, + [ABILITY_GUARD_DOG] = sGuardDogDescription, + [ABILITY_ROCKY_PAYLOAD] = sRockyPayloadDescription, + [ABILITY_WIND_POWER] = sWindPowerDescription, + [ABILITY_ZERO_TO_HERO] = sZeroToHeroDescription, + [ABILITY_COMMANDER] = sCommanderDescription, + [ABILITY_ELECTROMORPHOSIS] = sElectromorphosisDescription, + [ABILITY_PROTOSYNTHESIS] = sProtosynthesisDescription, + [ABILITY_QUARK_DRIVE] = sQuarkDriveDescription, + [ABILITY_GOOD_AS_GOLD] = sGoodAsGoldDescription, + [ABILITY_VESSEL_OF_RUIN] = sVesselOfRuinDescription, + [ABILITY_SWORD_OF_RUIN] = sSwordOfRuinDescription, + [ABILITY_TABLETS_OF_RUIN] = sTabletsOfRuinDescription, + [ABILITY_BEADS_OF_RUIN] = sBeadsOfRuinDescription, + [ABILITY_ORICHALCUM_PULSE] = sOrichalcumPulseDescription, + [ABILITY_HADRON_ENGINE] = sHadronEngineDescription, + [ABILITY_OPPORTUNIST] = sOpportunistDescription, + [ABILITY_CUD_CHEW] = sCudChewDescription, + [ABILITY_SHARPNESS] = sSharpnessDescription, + [ABILITY_SUPREME_OVERLORD] = sSupremeOverlordDescription, + [ABILITY_COSTAR] = sCostarDescription, + [ABILITY_TOXIC_DEBRIS] = sToxicDebrisDescription, + [ABILITY_ARMOR_TAIL] = sArmorTailDescription, + [ABILITY_EARTH_EATER] = sEarthEaterDescription, + [ABILITY_MYCELIUM_MIGHT] = sMyceliumMightDescription, }; From 8dd3fd025fce25e417cbcfbe85d4d1a3daf7452d Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Fri, 2 Dec 2022 23:04:10 -0300 Subject: [PATCH 02/36] Implemented Lingering Aroma's effect And took the chance to tweak Mummy's. --- src/battle_message.c | 2 +- src/battle_util.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/battle_message.c b/src/battle_message.c index 9503fbaaf..c243e3041 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -616,7 +616,7 @@ static const u8 sText_HealingWishCameTrue[] = _("The healing wish came true\nfor static const u8 sText_HealingWishHealed[] = _("{B_ATK_NAME_WITH_PREFIX} regained health!"); static const u8 sText_LunarDanceCameTrue[] = _("{B_ATK_NAME_WITH_PREFIX} became cloaked\nin mystical moonlight!"); static const u8 sText_CursedBodyDisabled[] = _("{B_ATK_NAME_WITH_PREFIX}'s {B_BUFF1} was disabled\nby {B_DEF_NAME_WITH_PREFIX}'s {B_DEF_ABILITY}!"); -static const u8 sText_AttackerAquiredAbility[] = _("{B_ATK_NAME_WITH_PREFIX} acquired {B_LAST_ABILITY}!"); +static const u8 sText_AttackerAquiredAbility[] = _("{B_ATK_NAME_WITH_PREFIX} acquired\n{B_LAST_ABILITY}!"); static const u8 sText_TargetStatWontGoHigher[] = _("{B_DEF_NAME_WITH_PREFIX}'s {B_BUFF1}\nwon't go higher!"); static const u8 sText_PkmnMoveBouncedViaAbility[] = _("{B_ATK_NAME_WITH_PREFIX}'s {B_CURRENT_MOVE} was\nbounced back by {B_DEF_NAME_WITH_PREFIX}'s\l{B_DEF_ABILITY}!"); static const u8 sText_ImposterTransform[] = _("{B_ATK_NAME_WITH_PREFIX} transformed into\n{B_DEF_NAME_WITH_PREFIX} using {B_LAST_ABILITY}!"); diff --git a/src/battle_util.c b/src/battle_util.c index b629c8322..72b26417c 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5354,11 +5354,13 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; + case ABILITY_LINGERING_AROMA: case ABILITY_MUMMY: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && IsBattlerAlive(gBattlerAttacker) && TARGET_TURN_DAMAGED - && (IsMoveMakingContact(move, gBattlerAttacker))) + && IsMoveMakingContact(move, gBattlerAttacker) + && gBattleStruct->overwrittenAbilities[gBattlerAttacker] != GetBattlerAbility(gBattlerTarget)) { switch (gBattleMons[gBattlerAttacker].ability) { @@ -5374,7 +5376,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move case ABILITY_STANCE_CHANGE: break; default: - gLastUsedAbility = gBattleMons[gBattlerAttacker].ability = gBattleStruct->overwrittenAbilities[gBattlerAttacker] = ABILITY_MUMMY; + gLastUsedAbility = gBattleMons[gBattlerAttacker].ability = gBattleStruct->overwrittenAbilities[gBattlerAttacker] = gBattleMons[gBattlerTarget].ability; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_MummyActivates; effect++; From b0027cb78b52cdc7ba749a01b17df796bd90e827 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Fri, 2 Dec 2022 23:07:25 -0300 Subject: [PATCH 03/36] Implemented Seed Sower's effect --- data/battle_scripts_1.s | 9 +++++++++ include/battle_scripts.h | 1 + src/battle_util.c | 12 ++++++++++++ 3 files changed, 22 insertions(+) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 6b8067721..d807f5610 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7023,6 +7023,15 @@ BattleScript_GulpMissileGorgingTargetDefenseCantGoLower: waitmessage B_WAIT_TIME_LONG return +BattleScript_SeedSowerActivates:: + pause B_WAIT_TIME_SHORT + call BattleScript_AbilityPopUp + printstring STRINGID_TERRAINBECOMESGRASSY + waitmessage B_WAIT_TIME_LONG + playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG + call BattleScript_TerrainSeedLoop + return + BattleScript_PerishSongCountGoesDown:: printstring STRINGID_PKMNPERISHCOUNTFELL waitmessage B_WAIT_TIME_LONG diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 23f18e3be..d9dafe5df 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -433,6 +433,7 @@ extern const u8 BattleScript_SymbiosisActivates[]; extern const u8 BattleScript_MultiHitPrintStrings[]; extern const u8 BattleScript_BurnUpRemoveType[]; extern const u8 BattleScript_TargetAbilityStatRaiseRet[]; +extern const u8 BattleScript_SeedSowerActivates[]; // zmoves extern const u8 BattleScript_ZMoveActivateDamaging[]; diff --git a/src/battle_util.c b/src/battle_util.c index 72b26417c..e0b3f4b1b 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5723,6 +5723,18 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move } } break; + case ABILITY_SEED_SOWER: + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && !gProtectStructs[gBattlerAttacker].confusionSelfDmg + && TARGET_TURN_DAMAGED + && IsBattlerAlive(gBattlerTarget) + && TryChangeBattleTerrain(gBattlerTarget, STATUS_FIELD_GRASSY_TERRAIN, &gFieldTimers.terrainTimer)) + { + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_SeedSowerActivates; + effect++; + } + break; } break; case ABILITYEFFECT_MOVE_END_ATTACKER: // Same as above, but for attacker From be71c4ca9907fdc968e15a28b7e20dea5c8b90a6 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sat, 3 Dec 2022 01:07:49 -0300 Subject: [PATCH 04/36] Implemented Thermal Exchange's effect --- src/battle_util.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/battle_util.c b/src/battle_util.c index e0b3f4b1b..d3275be0d 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5735,6 +5735,20 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; + case ABILITY_THERMAL_EXCHANGE: + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && TARGET_TURN_DAMAGED + && IsBattlerAlive(gBattlerTarget) + && CompareStat(gBattlerTarget, STAT_ATK, MAX_STAT_STAGE, CMP_LESS_THAN) + && moveType == TYPE_FIRE) + { + gEffectBattler = gBattlerTarget; + SET_STATCHANGER(STAT_ATK, 1, FALSE); + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_TargetAbilityStatRaiseRet; + effect++; + } + break; } break; case ABILITYEFFECT_MOVE_END_ATTACKER: // Same as above, but for attacker @@ -6317,6 +6331,7 @@ bool32 CanBeBurned(u8 battlerId) || ability == ABILITY_WATER_VEIL || ability == ABILITY_WATER_BUBBLE || ability == ABILITY_COMATOSE + || ability == ABILITY_THERMAL_EXCHANGE || IsAbilityStatusProtected(battlerId) || IsBattlerTerrainAffected(battlerId, STATUS_FIELD_MISTY_TERRAIN)) return FALSE; From acb9c31bd4d7747656531e7f5230ed12f0ec1cd1 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sat, 3 Dec 2022 01:17:22 -0300 Subject: [PATCH 05/36] Implemented Anger Shell's effect --- data/battle_scripts_1.s | 44 ++++++++++++++++++++++++++++++++++++++++ include/battle.h | 1 + include/battle_scripts.h | 1 + src/battle_util.c | 14 +++++++++++++ 4 files changed, 60 insertions(+) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index d807f5610..964a6d8a3 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7032,6 +7032,50 @@ BattleScript_SeedSowerActivates:: call BattleScript_TerrainSeedLoop return +BattleScript_AngerShellActivates:: + call BattleScript_AbilityPopUp + jumpifstat BS_TARGET, CMP_LESS_THAN, STAT_ATK, MAX_STAT_STAGE, BattleScript_AngerShellTryDef + jumpifstat BS_TARGET, CMP_LESS_THAN, STAT_SPATK, MAX_STAT_STAGE, BattleScript_AngerShellTryDef + jumpifstat BS_TARGET, CMP_LESS_THAN, STAT_SPEED, MAX_STAT_STAGE, BattleScript_AngerShellTryDef + jumpifstat BS_TARGET, CMP_GREATER_THAN, STAT_DEF, MIN_STAT_STAGE, BattleScript_AngerShellTryDef + jumpifstat BS_TARGET, CMP_EQUAL, STAT_SPDEF, MIN_STAT_STAGE, BattleScript_ButItFailed +BattleScript_AngerShellTryDef:: + setbyte sSTAT_ANIM_PLAYED, FALSE + playstatchangeanimation BS_TARGET, BIT_DEF | BIT_SPDEF, STAT_CHANGE_NEGATIVE | STAT_CHANGE_CANT_PREVENT + setstatchanger STAT_DEF, 1, TRUE + statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR | MOVE_EFFECT_CERTAIN, BattleScript_AngerShellTrySpDef + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_AngerShellTrySpDef + printfromtable gStatUpStringIds + waitmessage B_WAIT_TIME_LONG +BattleScript_AngerShellTrySpDef: + setstatchanger STAT_SPDEF, 1, TRUE + statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR | MOVE_EFFECT_CERTAIN, BattleScript_AngerShellTryAttack + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_AngerShellTryAttack + printfromtable gStatUpStringIds + waitmessage B_WAIT_TIME_LONG +BattleScript_AngerShellTryAttack: + setbyte sSTAT_ANIM_PLAYED, FALSE + playstatchangeanimation BS_TARGET, BIT_SPATK | BIT_ATK | BIT_SPEED, STAT_CHANGE_BY_TWO + setstatchanger STAT_ATK, 1, FALSE + statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_AngerShellTrySpAtk + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_AngerShellTrySpAtk + printfromtable gStatUpStringIds + waitmessage B_WAIT_TIME_LONG +BattleScript_AngerShellTrySpAtk: + setstatchanger STAT_SPATK, 1, FALSE + statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_AngerShellTrySpeed + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_AngerShellTrySpeed + printfromtable gStatUpStringIds + waitmessage B_WAIT_TIME_LONG +BattleScript_AngerShellTrySpeed: + setstatchanger STAT_SPEED, 1, FALSE + statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_AngerShellRet + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_AngerShellRet + printfromtable gStatUpStringIds + waitmessage B_WAIT_TIME_LONG +BattleScript_AngerShellRet: + return + BattleScript_PerishSongCountGoesDown:: printstring STRINGID_PKMNPERISHCOUNTFELL waitmessage B_WAIT_TIME_LONG diff --git a/include/battle.h b/include/battle.h index ebc8be057..14037b72c 100644 --- a/include/battle.h +++ b/include/battle.h @@ -652,6 +652,7 @@ struct BattleStruct u8 attackerBeforeBounce:2; u8 targetsDone[MAX_BATTLERS_COUNT]; // Each battler as a bit. u16 overwrittenAbilities[MAX_BATTLERS_COUNT]; // abilities overwritten during battle (keep separate from battle history in case of switching) + bool8 endturnAbilityDone[PARTY_SIZE][2]; // For some reason, adding a switchInAbilityDone equivalent in SpecialStatus didn't work. }; #define F_DYNAMIC_TYPE_1 (1 << 6) diff --git a/include/battle_scripts.h b/include/battle_scripts.h index d9dafe5df..462da38db 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -434,6 +434,7 @@ extern const u8 BattleScript_MultiHitPrintStrings[]; extern const u8 BattleScript_BurnUpRemoveType[]; extern const u8 BattleScript_TargetAbilityStatRaiseRet[]; extern const u8 BattleScript_SeedSowerActivates[]; +extern const u8 BattleScript_AngerShellActivates[]; // zmoves extern const u8 BattleScript_ZMoveActivateDamaging[]; diff --git a/src/battle_util.c b/src/battle_util.c index d3275be0d..ed425dd49 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5749,6 +5749,20 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; + case ABILITY_ANGER_SHELL: + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && !gProtectStructs[gBattlerAttacker].confusionSelfDmg + && TARGET_TURN_DAMAGED + && (gBattleMons[gBattlerTarget].hp <= gBattleMons[gBattlerTarget].maxHP / 2) + && !gBattleStruct->endturnAbilityDone[gBattlerPartyIndexes[gBattlerTarget]][GetBattlerSide(gBattlerTarget)]) + { + gBattleStruct->endturnAbilityDone[gBattlerPartyIndexes[gBattlerTarget]][GetBattlerSide(gBattlerTarget)] = TRUE; + gBattlerAttacker = gBattlerTarget; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_AngerShellActivates; + effect++; + } + break; } break; case ABILITYEFFECT_MOVE_END_ATTACKER: // Same as above, but for attacker From eb082cd1a249b553e32c6d8673bd6082ca263b60 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sat, 3 Dec 2022 01:51:11 -0300 Subject: [PATCH 06/36] Implemented Purifying Salt's effect --- data/battle_scripts_1.s | 6 ++++++ src/battle_util.c | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 964a6d8a3..cf686fec9 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -3033,6 +3033,7 @@ BattleScript_EffectSleep:: jumpifstatus BS_TARGET, STATUS1_SLEEP, BattleScript_AlreadyAsleep jumpifcantmakeasleep BattleScript_CantMakeAsleep jumpifability BS_TARGET, ABILITY_COMATOSE, BattleScript_LeafGuardProtects + jumpifability BS_TARGET, ABILITY_PURIFYING_SALT, BattleScript_LeafGuardProtects jumpifflowerveil BattleScript_FlowerVeilProtects jumpifability BS_TARGET_SIDE, ABILITY_SWEET_VEIL, BattleScript_SweetVeilProtects jumpifleafguardprotected BS_TARGET, BattleScript_LeafGuardProtects @@ -3622,6 +3623,7 @@ BattleScript_EffectToxic:: ppreduce jumpifability BS_TARGET, ABILITY_IMMUNITY, BattleScript_ImmunityProtected jumpifability BS_TARGET, ABILITY_COMATOSE, BattleScript_LeafGuardProtects + jumpifability BS_TARGET, ABILITY_PURIFYING_SALT, BattleScript_LeafGuardProtects jumpifability BS_TARGET_SIDE, ABILITY_PASTEL_VEIL, BattleScript_PastelVeilProtects jumpifflowerveil BattleScript_FlowerVeilProtects jumpifleafguardprotected BS_TARGET, BattleScript_LeafGuardProtects @@ -3960,6 +3962,7 @@ BattleScript_EffectPoison:: ppreduce jumpifability BS_TARGET, ABILITY_IMMUNITY, BattleScript_ImmunityProtected jumpifability BS_TARGET, ABILITY_COMATOSE, BattleScript_LeafGuardProtects + jumpifability BS_TARGET, ABILITY_PURIFYING_SALT, BattleScript_LeafGuardProtects jumpifability BS_TARGET_SIDE, ABILITY_PASTEL_VEIL, BattleScript_PastelVeilProtects jumpifflowerveil BattleScript_FlowerVeilProtects jumpifleafguardprotected BS_TARGET, BattleScript_LeafGuardProtects @@ -3986,6 +3989,7 @@ BattleScript_EffectParalyze: ppreduce jumpifability BS_TARGET, ABILITY_LIMBER, BattleScript_LimberProtected jumpifability BS_TARGET, ABILITY_COMATOSE, BattleScript_LeafGuardProtects + jumpifability BS_TARGET, ABILITY_PURIFYING_SALT, BattleScript_LeafGuardProtects jumpifflowerveil BattleScript_FlowerVeilProtects jumpifleafguardprotected BS_TARGET, BattleScript_LeafGuardProtects jumpifshieldsdown BS_TARGET, BattleScript_LeafGuardProtects @@ -5409,6 +5413,7 @@ BattleScript_EffectWillOWisp:: jumpifability BS_TARGET, ABILITY_WATER_VEIL, BattleScript_WaterVeilPrevents jumpifability BS_TARGET, ABILITY_WATER_BUBBLE, BattleScript_WaterVeilPrevents jumpifability BS_TARGET, ABILITY_COMATOSE, BattleScript_LeafGuardProtects + jumpifability BS_TARGET, ABILITY_PURIFYING_SALT, BattleScript_LeafGuardProtects jumpifflowerveil BattleScript_FlowerVeilProtects jumpifleafguardprotected BS_TARGET, BattleScript_LeafGuardProtects jumpifshieldsdown BS_TARGET, BattleScript_LeafGuardProtects @@ -5701,6 +5706,7 @@ BattleScript_EffectYawn:: jumpifability BS_TARGET, ABILITY_VITAL_SPIRIT, BattleScript_PrintBankAbilityMadeIneffective jumpifability BS_TARGET, ABILITY_INSOMNIA, BattleScript_PrintBankAbilityMadeIneffective jumpifability BS_TARGET, ABILITY_COMATOSE, BattleScript_PrintBankAbilityMadeIneffective + jumpifability BS_TARGET, ABILITY_PURIFYING_SALT, BattleScript_LeafGuardProtects jumpifflowerveil BattleScript_FlowerVeilProtects jumpifleafguardprotected BS_TARGET, BattleScript_LeafGuardProtects jumpifshieldsdown BS_TARGET, BattleScript_LeafGuardProtects diff --git a/src/battle_util.c b/src/battle_util.c index ed425dd49..fd6374e74 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -8896,7 +8896,7 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe #define TERRAIN_TYPE_BOOST UQ_4_12(1.5) #endif - // various effecs + // various effects if (gProtectStructs[battlerAtk].helpingHand) MulModifier(&modifier, UQ_4_12(1.5)); if (gStatuses3[battlerAtk] & STATUS3_CHARGED_UP && moveType == TYPE_ELECTRIC) @@ -9226,6 +9226,10 @@ static u32 CalcDefenseStat(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType, if (gBattleMoves[move].flags & FLAG_SOUND) MulModifier(&modifier, UQ_4_12(2.0)); break; + case ABILITY_PURIFYING_SALT: + if (gBattleMoves[move].type == TYPE_GHOST) + MulModifier(&modifier, UQ_4_12(2.0)); + break; } // ally's abilities From ca656b63b935e17de1b14f8b6de3952df6ae74c3 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sat, 3 Dec 2022 02:04:33 -0300 Subject: [PATCH 07/36] Added Well Baked Body's effect and misc. changes -Added a modifybattlerstatstage macro to handle stat stages in battle. -Rewrote the checks inside the case ABILITYEFFECT_MOVES_BLOCK of AbilityBattleEffects. --- asm/macros/battle_script.inc | 31 ++++++++++++++++ data/battle_scripts_1.s | 12 +++++++ include/battle_scripts.h | 1 + src/battle_util.c | 68 +++++++++++++++++++----------------- 4 files changed, 80 insertions(+), 32 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 27c5a86c4..72ca567dc 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -2157,3 +2157,34 @@ .macro trysymbiosis various BS_ATTACKER, VARIOUS_TRY_SYMBIOSIS .endm + + @ Tries to increase or decrease a battler's stat's stat stage by a specified amount. If impossible, jumps to \script. + .macro modifybattlerstatstage battler:req, stat:req, mode:req, amount:req, script:req, animation:req, customString + + @ \mode parameters + INCREASE = FALSE + DECREASE = TRUE + + @ \animation parameters + ANIM_OFF = FALSE + ANIM_ON = TRUE + + setstatchanger \stat, \amount, \mode + statbuffchange STAT_CHANGE_ALLOW_PTR, \script + setgraphicalstatchangevalues + .if \animation == TRUE + playanimation \battler, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 + .endif + .ifnb \customString + printstring \customString + .else + .if \mode == DECREASE + printfromtable gStatDownStringIds + .else + .if \mode == INCREASE + printfromtable gStatUpStringIds + .endif + .endif + .endif + waitmessage B_WAIT_TIME_LONG + .endm diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index cf686fec9..d7aa7f53f 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -9800,6 +9800,18 @@ BattleScript_DarkTypePreventsPrankster:: orhalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT goto BattleScript_MoveEnd +BattleScript_WellBakedBodyActivates:: + attackstring + ppreduce + showabilitypopup BS_TARGET + pause B_WAIT_TIME_MED + printstring STRINGID_ITDOESNTAFFECT + waitmessage B_WAIT_TIME_MED + orhalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT + modifybattlerstatstage BS_TARGET, STAT_DEF, INCREASE, 1, BattleScript_WellBakedBodyEnd, ANIM_ON +BattleScript_WellBakedBodyEnd: + goto BattleScript_MoveEnd + BattleScript_PastelVeilActivates:: setbyte gBattleCommunication, 0 setbyte gBattleCommunication + 1, 0 diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 462da38db..b909b9711 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -435,6 +435,7 @@ extern const u8 BattleScript_BurnUpRemoveType[]; extern const u8 BattleScript_TargetAbilityStatRaiseRet[]; extern const u8 BattleScript_SeedSowerActivates[]; extern const u8 BattleScript_AngerShellActivates[]; +extern const u8 BattleScript_WellBakedBodyActivates[]; // zmoves extern const u8 BattleScript_ZMoveActivateDamaging[]; diff --git a/src/battle_util.c b/src/battle_util.c index fd6374e74..8746dbbf0 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5079,40 +5079,44 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move } break; case ABILITYEFFECT_MOVES_BLOCK: // 2 - { - u16 moveTarget = GetBattlerMoveTargetType(battler, move); + { + u16 moveTarget = GetBattlerMoveTargetType(battler, move); + u16 battlerAbility = GetBattlerAbility(battler); + u16 targetAbility = GetBattlerAbility(gBattlerTarget); - if ((gLastUsedAbility == ABILITY_SOUNDPROOF && gBattleMoves[move].flags & FLAG_SOUND && !(moveTarget & MOVE_TARGET_USER)) - || (gLastUsedAbility == ABILITY_BULLETPROOF && gBattleMoves[move].flags & FLAG_BALLISTIC)) - { - if (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS) - gHitMarker |= HITMARKER_NO_PPDEDUCT; - gBattlescriptCurrInstr = BattleScript_SoundproofProtected; - effect = 1; + if ((gLastUsedAbility == ABILITY_SOUNDPROOF && gBattleMoves[move].flags & FLAG_SOUND && !(moveTarget & MOVE_TARGET_USER)) + || (gLastUsedAbility == ABILITY_BULLETPROOF && gBattleMoves[move].flags & FLAG_BALLISTIC)) + { + if (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS) + gHitMarker |= HITMARKER_NO_PPDEDUCT; + gBattlescriptCurrInstr = BattleScript_SoundproofProtected; + effect = 1; + } + else if ((gLastUsedAbility == ABILITY_DAZZLING || gLastUsedAbility == ABILITY_QUEENLY_MAJESTY || IsBattlerAlive(battler ^= BIT_FLANK)) + && (battlerAbility == ABILITY_DAZZLING || battlerAbility == ABILITY_QUEENLY_MAJESTY) + && GetChosenMovePriority(gBattlerAttacker) > 0 + && GetBattlerSide(gBattlerAttacker) != GetBattlerSide(battler)) + { + if (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS) + gHitMarker |= HITMARKER_NO_PPDEDUCT; + gBattlescriptCurrInstr = BattleScript_DazzlingProtected; + effect = 1; + } + else if (BlocksPrankster(move, gBattlerAttacker, gBattlerTarget, TRUE) && !(IS_MOVE_STATUS(move) && targetAbility == ABILITY_MAGIC_BOUNCE)) + { + if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE) || !(moveTarget & (MOVE_TARGET_BOTH | MOVE_TARGET_FOES_AND_ALLY))) + CancelMultiTurnMoves(gBattlerAttacker); // Don't cancel moves that can hit two targets bc one target might not be protected + gBattleScripting.battler = gBattlerAbility = gBattlerTarget; + gBattlescriptCurrInstr = BattleScript_DarkTypePreventsPrankster; + effect = 1; + } + else if (targetAbility == ABILITY_WELL_BAKED_BODY && gBattleMoves[gCurrentMove].type == TYPE_FIRE) + { + gBattlescriptCurrInstr = BattleScript_WellBakedBodyActivates; + effect = 1; + } + break; } - else if ((((gLastUsedAbility == ABILITY_DAZZLING || gLastUsedAbility == ABILITY_QUEENLY_MAJESTY - || (IsBattlerAlive(battler ^= BIT_FLANK) - && ((GetBattlerAbility(battler) == ABILITY_DAZZLING) || GetBattlerAbility(battler) == ABILITY_QUEENLY_MAJESTY))) - )) - && GetChosenMovePriority(gBattlerAttacker) > 0 - && GetBattlerSide(gBattlerAttacker) != GetBattlerSide(battler)) - { - if (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS) - gHitMarker |= HITMARKER_NO_PPDEDUCT; - gBattlescriptCurrInstr = BattleScript_DazzlingProtected; - effect = 1; - } - else if (BlocksPrankster(move, gBattlerAttacker, gBattlerTarget, TRUE) - && !(IS_MOVE_STATUS(move) && GetBattlerAbility(gBattlerTarget) == ABILITY_MAGIC_BOUNCE)) - { - if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE) || !(moveTarget & (MOVE_TARGET_BOTH | MOVE_TARGET_FOES_AND_ALLY))) - CancelMultiTurnMoves(gBattlerAttacker); // Don't cancel moves that can hit two targets bc one target might not be protected - gBattleScripting.battler = gBattlerAbility = gBattlerTarget; - gBattlescriptCurrInstr = BattleScript_DarkTypePreventsPrankster; - effect = 1; - } - break; - } case ABILITYEFFECT_ABSORBING: // 3 if (move != MOVE_NONE) { From 4dc44150c53855df72a70c76fa71bbbad2a041b4 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sat, 3 Dec 2022 06:21:01 -0300 Subject: [PATCH 08/36] Implemented Wind Rider's effect --- data/battle_scripts_1.s | 31 +++++++++++++++++++++++++++++++ include/battle_scripts.h | 2 ++ include/constants/pokemon.h | 1 + src/battle_util.c | 10 ++++++++++ src/data/battle_moves.h | 32 ++++++++++++++++---------------- 5 files changed, 60 insertions(+), 16 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index d7aa7f53f..a9e196ae8 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -6589,6 +6589,26 @@ BattleScript_TailwindEnds:: waitmessage B_WAIT_TIME_LONG end2 +BattleScript_WindRiderActivatesEnd2:: + setbyte gBattlerTarget, 0 +BattleScript_WindRiderLoop: + printstring STRINGID_EMPTYSTRING3 + jumpifability BS_TARGET, ABILITY_WIND_RIDER, BattleScript_WindRiderLoop_Cont + goto BattleScript_WindRiderIncrement +BattleScript_WindRiderLoop_Cont: + jumpifsideaffecting BS_TARGET, SIDE_STATUS_TAILWIND, BattleScript_WindRider_Activate + goto BattleScript_WindRiderIncrement +BattleScript_WindRider_Activate: + call BattleScript_AbilityPopUp + pause B_WAIT_TIME_MED + modifybattlerstatstage BS_TARGET, STAT_ATK, INCREASE, 1, BattleScript_WindRiderIncrement, ANIM_ON +BattleScript_WindRiderIncrement: + addbyte gBattlerTarget, 1 + jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_WindRiderLoop +BattleScript_WindRiderEnd: + destroyabilitypopup + end2 + BattleScript_TrickRoomEnds:: printstring STRINGID_TRICKROOMENDS waitmessage B_WAIT_TIME_LONG @@ -9812,6 +9832,17 @@ BattleScript_WellBakedBodyActivates:: BattleScript_WellBakedBodyEnd: goto BattleScript_MoveEnd +BattleScript_WindRiderActivatesMoveEnd:: + attackstring + ppreduce + showabilitypopup BS_TARGET + pause B_WAIT_TIME_MED + orhalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT + printstring STRINGID_EMPTYSTRING3 + modifybattlerstatstage BS_TARGET, STAT_ATK, INCREASE, 1, BattleScript_WindRiderActivatesMoveEnd_End, ANIM_ON +BattleScript_WindRiderActivatesMoveEnd_End: + goto BattleScript_MoveEnd + BattleScript_PastelVeilActivates:: setbyte gBattleCommunication, 0 setbyte gBattleCommunication + 1, 0 diff --git a/include/battle_scripts.h b/include/battle_scripts.h index b909b9711..4d1d750df 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -436,6 +436,8 @@ extern const u8 BattleScript_TargetAbilityStatRaiseRet[]; extern const u8 BattleScript_SeedSowerActivates[]; extern const u8 BattleScript_AngerShellActivates[]; extern const u8 BattleScript_WellBakedBodyActivates[]; +extern const u8 BattleScript_WindRiderActivatesEnd2[]; +extern const u8 BattleScript_WindRiderActivatesMoveEnd[]; // zmoves extern const u8 BattleScript_ZMoveActivateDamaging[]; diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 006e2a703..8d637af30 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -235,6 +235,7 @@ #define FLAG_THAW_USER (1 << 25) #define FLAG_HIT_IN_SUBSTITUTE (1 << 26) // Hyperspace Fury #define FLAG_TWO_STRIKES (1 << 27) // A move with this flag will strike twice, and may apply its effect on each hit +#define FLAG_WIND_MOVE (1 << 28) // Split defines. #define SPLIT_PHYSICAL 0x0 diff --git a/src/battle_util.c b/src/battle_util.c index 8746dbbf0..45eecf1a1 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2373,6 +2373,11 @@ u8 DoFieldEndTurnEffects(void) BattleScriptExecute(BattleScript_TailwindEnds); effect++; } + if (IsAbilityOnSide(gActiveBattler, ABILITY_WIND_RIDER)) + { + BattleScriptExecute(BattleScript_WindRiderActivatesEnd2); + effect++; + } } gBattleStruct->turnSideTracker++; if (effect != 0) @@ -5115,6 +5120,11 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move gBattlescriptCurrInstr = BattleScript_WellBakedBodyActivates; effect = 1; } + else if (targetAbility == ABILITY_WIND_RIDER && gBattleMoves[gCurrentMove].flags & FLAG_WIND_MOVE && !(moveTarget & MOVE_TARGET_USER)) + { + gBattlescriptCurrInstr = BattleScript_WindRiderActivatesMoveEnd; + effect = 1; + } break; } case ABILITYEFFECT_ABSORBING: // 3 diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 346309c55..37ba7aaff 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -272,7 +272,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DMG_2X_IN_AIR, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DMG_2X_IN_AIR | FLAG_WIND_MOVE, .split = SPLIT_SPECIAL, .zMovePower = 100, .zMoveEffect = Z_EFFECT_NONE, @@ -298,7 +298,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = { #if B_UPDATED_MOVE_DATA >= GEN_6 .accuracy = 0, - .flags = FLAG_MAGIC_COAT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED, + .flags = FLAG_MAGIC_COAT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_WIND_MOVE, #elif B_UPDATED_MOVE_DATA == GEN_5 .accuracy = 100, .flags = FLAG_PROTECT_AFFECTED | FLAG_MAGIC_COAT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED, @@ -1073,7 +1073,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 10, .target = MOVE_TARGET_BOTH, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_WIND_MOVE, .split = SPLIT_SPECIAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -3531,7 +3531,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 100, .target = MOVE_TARGET_BOTH, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_WIND_MOVE, .split = SPLIT_SPECIAL, .zMovePower = 100, .zMoveEffect = Z_EFFECT_NONE, @@ -3633,7 +3633,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, - .flags = 0, + .flags = FLAG_WIND_MOVE, .split = SPLIT_STATUS, .zMovePower = 0, .zMoveEffect = Z_EFFECT_SPD_UP_1, @@ -4290,7 +4290,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_TWISTER] = { #if B_UPDATED_MOVE_DATA >= GEN_5 - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_DMG_2X_IN_AIR, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_DMG_2X_IN_AIR | FLAG_WIND_MOVE, #else .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_DMG_2X_IN_AIR, #endif @@ -4663,7 +4663,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 10, .target = MOVE_TARGET_BOTH, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_WIND_MOVE, .split = SPLIT_SPECIAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -5656,7 +5656,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_BOTH, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_HIGH_CRIT, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_HIGH_CRIT | FLAG_WIND_MOVE, .split = SPLIT_SPECIAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -6613,7 +6613,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_USER, .priority = 0, - .flags = FLAG_SNATCH_AFFECTED, + .flags = FLAG_SNATCH_AFFECTED | FLAG_WIND_MOVE, .split = SPLIT_STATUS, .zMovePower = 0, .zMoveEffect = Z_EFFECT_BOOST_CRITS, @@ -9691,7 +9691,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 30, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_DMG_IN_AIR, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_DMG_IN_AIR | FLAG_WIND_MOVE, .split = SPLIT_SPECIAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -10201,7 +10201,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_FOES_AND_ALLY, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_WIND_MOVE, .split = SPLIT_PHYSICAL, .zMovePower = 175, .zMoveEffect = Z_EFFECT_NONE, @@ -10400,7 +10400,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_WIND_MOVE, .split = SPLIT_SPECIAL, .zMovePower = 100, .zMoveEffect = Z_EFFECT_NONE, @@ -13308,7 +13308,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 30, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_WIND_MOVE, .split = SPLIT_SPECIAL, .zMovePower = 175, .zMoveEffect = Z_EFFECT_NONE, @@ -13548,7 +13548,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_WIND_MOVE, .split = SPLIT_SPECIAL, .zMovePower = 175, .zMoveEffect = Z_EFFECT_NONE, @@ -13564,7 +13564,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_WIND_MOVE, .split = SPLIT_SPECIAL, .zMovePower = 175, .zMoveEffect = Z_EFFECT_NONE, @@ -13580,7 +13580,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_WIND_MOVE, .split = SPLIT_SPECIAL, .zMovePower = 175, .zMoveEffect = Z_EFFECT_NONE, From c43060fbfdd2df9943c84e177d52a09663b2d0b6 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sat, 3 Dec 2022 20:41:20 -0300 Subject: [PATCH 09/36] Tweaked BattleScript_WellBakedBodyActivates and BattleScript_WindRiderActivatesMoveEnd --- data/battle_scripts_1.s | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index a9e196ae8..a70ec7cf2 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -9823,10 +9823,8 @@ BattleScript_DarkTypePreventsPrankster:: BattleScript_WellBakedBodyActivates:: attackstring ppreduce + pause B_WAIT_TIME_SHORT showabilitypopup BS_TARGET - pause B_WAIT_TIME_MED - printstring STRINGID_ITDOESNTAFFECT - waitmessage B_WAIT_TIME_MED orhalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT modifybattlerstatstage BS_TARGET, STAT_DEF, INCREASE, 1, BattleScript_WellBakedBodyEnd, ANIM_ON BattleScript_WellBakedBodyEnd: @@ -9835,10 +9833,9 @@ BattleScript_WellBakedBodyEnd: BattleScript_WindRiderActivatesMoveEnd:: attackstring ppreduce + pause B_WAIT_TIME_SHORT showabilitypopup BS_TARGET - pause B_WAIT_TIME_MED orhalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT - printstring STRINGID_EMPTYSTRING3 modifybattlerstatstage BS_TARGET, STAT_ATK, INCREASE, 1, BattleScript_WindRiderActivatesMoveEnd_End, ANIM_ON BattleScript_WindRiderActivatesMoveEnd_End: goto BattleScript_MoveEnd From c1e232cbf694056a6566a616f0403f07495207ff Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sat, 3 Dec 2022 20:47:30 -0300 Subject: [PATCH 10/36] Implemented Rocky Payload's effect --- src/battle_util.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/battle_util.c b/src/battle_util.c index 45eecf1a1..cdaf67b59 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -8726,6 +8726,10 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe if (IS_MOVE_PHYSICAL(move)) MulModifier(&modifier, UQ_4_12(1.5)); break; + case ABILITY_ROCKY_PAYLOAD: + if (moveType == TYPE_ROCK) + MulModifier(&modifier, UQ_4_12(1.5)); + break; } // field abilities From 88cae380d0f2b325463e3a4e0c6d276fe62c76b0 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sat, 3 Dec 2022 21:20:34 -0300 Subject: [PATCH 11/36] Implemented Wind Power's effect --- data/battle_scripts_1.s | 30 +++++++++++++++++++++++++++ include/battle_scripts.h | 2 ++ include/constants/battle_string_ids.h | 3 ++- src/battle_message.c | 3 ++- src/battle_util.c | 19 +++++++++++++++++ 5 files changed, 55 insertions(+), 2 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index a70ec7cf2..f1e3902b4 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -6609,6 +6609,27 @@ BattleScript_WindRiderEnd: destroyabilitypopup end2 +BattleScript_WindPowerActivatesEnd2:: + setbyte gBattlerAttacker, 0 +BattleScript_WindPowerLoop: + printstring STRINGID_EMPTYSTRING3 + jumpifability BS_ATTACKER, ABILITY_WIND_POWER, BattleScript_WindPowerLoop_Cont + goto BattleScript_WindPowerIncrement +BattleScript_WindPowerLoop_Cont: + jumpifstatus3 BS_ATTACKER, STATUS3_CHARGED_UP, BattleScript_WindPowerIncrement + goto BattleScript_WindPower_Activate +BattleScript_WindPower_Activate: + call BattleScript_AbilityPopUp + setcharge + printstring STRINGID_BEINGHITCHARGEDPKMNWITHPOWER + waitmessage B_WAIT_TIME_LONG +BattleScript_WindPowerIncrement: + addbyte gBattlerAttacker, 1 + jumpifbytenotequal gBattlerAttacker, gBattlersCount, BattleScript_WindPowerLoop +BattleScript_WindPowerEnd: + destroyabilitypopup + end2 + BattleScript_TrickRoomEnds:: printstring STRINGID_TRICKROOMENDS waitmessage B_WAIT_TIME_LONG @@ -7102,6 +7123,15 @@ BattleScript_AngerShellTrySpeed: BattleScript_AngerShellRet: return +BattleScript_WindPowerActivates:: + jumpifstatus3 BS_ATTACKER, STATUS3_CHARGED_UP, BattleScript_WindPowerActivates_Ret + call BattleScript_AbilityPopUp + setcharge + printstring STRINGID_BEINGHITCHARGEDPKMNWITHPOWER + waitmessage B_WAIT_TIME_LONG +BattleScript_WindPowerActivates_Ret: + return + BattleScript_PerishSongCountGoesDown:: printstring STRINGID_PKMNPERISHCOUNTFELL waitmessage B_WAIT_TIME_LONG diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 4d1d750df..5953a8c76 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -438,6 +438,8 @@ extern const u8 BattleScript_AngerShellActivates[]; extern const u8 BattleScript_WellBakedBodyActivates[]; extern const u8 BattleScript_WindRiderActivatesEnd2[]; extern const u8 BattleScript_WindRiderActivatesMoveEnd[]; +extern const u8 BattleScript_WindPowerActivates[]; +extern const u8 BattleScript_WindPowerActivatesEnd2[]; // zmoves extern const u8 BattleScript_ZMoveActivateDamaging[]; diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index 4bce51a45..70841dd9a 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -630,8 +630,9 @@ #define STRINGID_ATTACKERHEALEDITSBURN 628 #define STRINGID_ATTACKERMELTEDTHEICE 629 #define STRINGID_TARGETTOUGHEDITOUT 630 +#define STRINGID_BEINGHITCHARGEDPKMNWITHPOWER 631 -#define BATTLESTRINGS_COUNT 631 +#define BATTLESTRINGS_COUNT 632 // 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 c243e3041..b4f2c80f0 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -759,10 +759,11 @@ static const u8 sText_AttackerBrokeThroughParalysis[] = _("{B_ATK_NAME_WITH_PREF static const u8 sText_AttackerHealedItsBurn[] = _("{B_ATK_NAME_WITH_PREFIX} healed its burn with\nits sheer determination!"); static const u8 sText_AttackerMeltedTheIce[] = _("{B_ATK_NAME_WITH_PREFIX} melted the ice with\nits fiery determination!"); static const u8 sText_TargetToughedItOut[] = _("{B_DEF_NAME_WITH_PREFIX} toughed it out\nto show you its best side!"); - +static const u8 sText_BeingHitChargedPkmnWithPower[] = _("Being hit by {B_CURRENT_MOVE}\ncharged {B_ATK_NAME_WITH_PREFIX} with power!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_BEINGHITCHARGEDPKMNWITHPOWER - BATTLESTRINGS_TABLE_START] = sText_BeingHitChargedPkmnWithPower, [STRINGID_TARGETTOUGHEDITOUT - BATTLESTRINGS_TABLE_START] = sText_TargetToughedItOut, [STRINGID_ATTACKERMELTEDTHEICE - BATTLESTRINGS_TABLE_START] = sText_AttackerMeltedTheIce, [STRINGID_ATTACKERHEALEDITSBURN - BATTLESTRINGS_TABLE_START] = sText_AttackerHealedItsBurn, diff --git a/src/battle_util.c b/src/battle_util.c index cdaf67b59..e12612fa8 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2378,6 +2378,12 @@ u8 DoFieldEndTurnEffects(void) BattleScriptExecute(BattleScript_WindRiderActivatesEnd2); effect++; } + if (IsAbilityOnSide(gActiveBattler, ABILITY_WIND_POWER)) + { + gCurrentMove = MOVE_TAILWIND; + BattleScriptExecute(BattleScript_WindPowerActivatesEnd2); + effect++; + } } gBattleStruct->turnSideTracker++; if (effect != 0) @@ -5777,6 +5783,19 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; + case ABILITY_WIND_POWER: + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && !gProtectStructs[gBattlerAttacker].confusionSelfDmg + && TARGET_TURN_DAMAGED + && gBattleMoves[gCurrentMove].flags & FLAG_WIND_MOVE + && IsBattlerAlive(gBattlerTarget)) + { + gBattlerAttacker = gBattlerTarget; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_WindPowerActivates; + effect++; + } + break; } break; case ABILITYEFFECT_MOVE_END_ATTACKER: // Same as above, but for attacker From 34cafa746ce99fcf4efe6f1513ef51e9a694d6cc Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 4 Dec 2022 18:55:37 -0300 Subject: [PATCH 12/36] =?UTF-8?q?Implemented=20Electromorphosis'=20effect?= =?UTF-8?q?=20Also=20added=20a=20battle=20preproc=20config=20to=20check=20?= =?UTF-8?q?if=20the=20STATUS3=5FCHARGED=5FUP=20was=20already=20applied.=20?= =?UTF-8?q?Pok=C3=A9mon=20Scarlet=20and=20Violet=20don't=20check=20if=20th?= =?UTF-8?q?is=20status=20flag=20was=20already=20applied=20on=20the=20targe?= =?UTF-8?q?t=20of=20abilities=20like=20Electromorphosis=20(and=20Wind=20Po?= =?UTF-8?q?wer=20until=20proven=20otherwise.)=20As=20a=20result,=20the=20g?= =?UTF-8?q?ame=20will=20trigger=20the=20ability=20multiple=20times=20if=20?= =?UTF-8?q?they're=20hit=20by=20a=20multihit=20move.=20This=20directive=20?= =?UTF-8?q?makes=20the=20code=20end=20the=20ability=20effect=20preemptivel?= =?UTF-8?q?y=20if=20the=20target=20does=20have=20the=20status=20flag=20app?= =?UTF-8?q?lied.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/battle_scripts_1.s | 2 ++ include/config/battle.h | 1 + src/battle_util.c | 1 + 3 files changed, 4 insertions(+) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index f1e3902b4..01c0df71a 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7124,7 +7124,9 @@ BattleScript_AngerShellRet: return BattleScript_WindPowerActivates:: +.if B_CHECK_IF_CHARGED_UP == TRUE jumpifstatus3 BS_ATTACKER, STATUS3_CHARGED_UP, BattleScript_WindPowerActivates_Ret +.endif call BattleScript_AbilityPopUp setcharge printstring STRINGID_BEINGHITCHARGEDPKMNWITHPOWER diff --git a/include/config/battle.h b/include/config/battle.h index 644f9955c..3f359a6f2 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -109,6 +109,7 @@ #define B_PLUS_MINUS_INTERACTION GEN_LATEST // In Gen5+, Plus and Minus can be activated with themselves and the opposite ability. Before, only the opposing ability could activate it. #define B_WEATHER_FORMS GEN_LATEST // In Gen5+, Castform and Cherrim revert to their base form upon losing their respective ability. Cherrim needs Flower Gift to swap forms. #define B_SYMBIOSIS_GEMS GEN_LATEST // In Gen7+, Symbiosis passes an item after a gem-boosted attack. Previously, items are passed before the gem-boosted attack hits, making the item effect apply. +#define B_CHECK_IF_CHARGED_UP TRUE // If set to TRUE, certain abilities such as Electromorphosis WILL check if the STATUS3_CHARGED_UP status flag is applied. // Item settings #define B_HP_BERRIES GEN_LATEST // In Gen4+, berries which restore hp activate immediately after HP drops to half. In Gen3, the effect occurs at the end of the turn. diff --git a/src/battle_util.c b/src/battle_util.c index e12612fa8..e79947b09 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5784,6 +5784,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move } break; case ABILITY_WIND_POWER: + case ABILITY_ELECTROMORPHOSIS: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && !gProtectStructs[gBattlerAttacker].confusionSelfDmg && TARGET_TURN_DAMAGED From a328088122ff3a93b5edaa59c82010b37e93a03d Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 4 Dec 2022 19:18:41 -0300 Subject: [PATCH 13/36] Implemented Protosynthesis' effect Also turned GetHighestStatId into a global function since Protosynthesis' effect uses it. --- data/battle_scripts_1.s | 8 +++++++ include/battle_script_commands.h | 1 + include/battle_scripts.h | 1 + include/constants/battle_string_ids.h | 4 +++- src/battle_main.c | 3 +++ src/battle_message.c | 4 ++++ src/battle_script_commands.c | 2 +- src/battle_util.c | 34 +++++++++++++++++++++------ 8 files changed, 48 insertions(+), 9 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 01c0df71a..3b8f69d7b 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -8410,6 +8410,14 @@ BattleScript_DeltaStreamActivates:: playanimation BS_ATTACKER, B_ANIM_STRONG_WINDS end3 +BattleScript_ProtosynthesisActivates:: + call BattleScript_AbilityPopUp + printstring STRINGID_SUNLIGHTACTIVATEDABILITY + waitmessage B_WAIT_TIME_MED + printstring STRINGID_STATWASHEIGHTENED + waitmessage B_WAIT_TIME_MED + end3 + BattleScript_AttackWeakenedByStrongWinds:: pause B_WAIT_TIME_SHORT printstring STRINGID_ATTACKWEAKENEDBSTRONGWINDS diff --git a/include/battle_script_commands.h b/include/battle_script_commands.h index 44185a11a..60fd9b156 100644 --- a/include/battle_script_commands.h +++ b/include/battle_script_commands.h @@ -43,6 +43,7 @@ u16 GetNaturePowerMove(void); u16 GetSecretPowerMoveEffect(void); void StealTargetItem(u8 battlerStealer, u8 battlerItem); u8 GetCatchingBattler(void); +u32 GetHighestStatId(u32 battlerId); extern void (* const gBattleScriptingCommandsTable[])(void); extern const u8 gBattlePalaceNatureToMoveGroupLikelihood[NUM_NATURES][4]; diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 5953a8c76..c614e4b67 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -440,6 +440,7 @@ extern const u8 BattleScript_WindRiderActivatesEnd2[]; extern const u8 BattleScript_WindRiderActivatesMoveEnd[]; extern const u8 BattleScript_WindPowerActivates[]; extern const u8 BattleScript_WindPowerActivatesEnd2[]; +extern const u8 BattleScript_ProtosynthesisActivates[]; // zmoves extern const u8 BattleScript_ZMoveActivateDamaging[]; diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index 70841dd9a..d4525572f 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -631,8 +631,10 @@ #define STRINGID_ATTACKERMELTEDTHEICE 629 #define STRINGID_TARGETTOUGHEDITOUT 630 #define STRINGID_BEINGHITCHARGEDPKMNWITHPOWER 631 +#define STRINGID_SUNLIGHTACTIVATEDABILITY 632 +#define STRINGID_STATWASHEIGHTENED 633 -#define BATTLESTRINGS_COUNT 632 +#define BATTLESTRINGS_COUNT 634 // 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_main.c b/src/battle_main.c index 392e53268..f78822247 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4482,6 +4482,7 @@ u32 GetBattlerTotalSpeedStat(u8 battlerId) u32 speed = gBattleMons[battlerId].speed; u32 ability = GetBattlerAbility(battlerId); u32 holdEffect = GetBattlerHoldEffect(battlerId, TRUE); + u32 highestStat = GetHighestStatId(battlerId); // weather abilities if (WEATHER_HAS_EFFECT) @@ -4503,6 +4504,8 @@ u32 GetBattlerTotalSpeedStat(u8 battlerId) speed *= 2; else if (ability == ABILITY_SLOW_START && gDisableStructs[battlerId].slowStartTimer != 0) speed /= 2; + else if (ability == ABILITY_PROTOSYNTHESIS && gBattleWeather & B_WEATHER_SUN && highestStat == STAT_SPEED) + speed = (speed * 150) / 100; // stat stages speed *= gStatStageRatios[gBattleMons[battlerId].statStages[STAT_SPEED]][0]; diff --git a/src/battle_message.c b/src/battle_message.c index b4f2c80f0..e8af7d625 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -760,9 +760,13 @@ static const u8 sText_AttackerHealedItsBurn[] = _("{B_ATK_NAME_WITH_PREFIX} heal static const u8 sText_AttackerMeltedTheIce[] = _("{B_ATK_NAME_WITH_PREFIX} melted the ice with\nits fiery determination!"); static const u8 sText_TargetToughedItOut[] = _("{B_DEF_NAME_WITH_PREFIX} toughed it out\nto show you its best side!"); static const u8 sText_BeingHitChargedPkmnWithPower[] = _("Being hit by {B_CURRENT_MOVE}\ncharged {B_ATK_NAME_WITH_PREFIX} with power!"); +static const u8 sText_SunlightActivatedAbility[] = _("The harsh sunlight activated\n{B_DEF_NAME_WITH_PREFIX}'s {B_DEF_ABILITY}!"); +static const u8 sText_StatWasHeightened[] = _("{B_DEF_NAME_WITH_PREFIX}'s {B_BUFF1} was heightened!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_STATWASHEIGHTENED - BATTLESTRINGS_TABLE_START] = sText_StatWasHeightened, + [STRINGID_SUNLIGHTACTIVATEDABILITY - BATTLESTRINGS_TABLE_START] = sText_SunlightActivatedAbility, [STRINGID_BEINGHITCHARGEDPKMNWITHPOWER - BATTLESTRINGS_TABLE_START] = sText_BeingHitChargedPkmnWithPower, [STRINGID_TARGETTOUGHEDITOUT - BATTLESTRINGS_TABLE_START] = sText_TargetToughedItOut, [STRINGID_ATTACKERMELTEDTHEICE - BATTLESTRINGS_TABLE_START] = sText_AttackerMeltedTheIce, diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 09ef738df..6196ab37b 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8098,7 +8098,7 @@ static void RecalcBattlerStats(u32 battler, struct Pokemon *mon) gBattleMons[battler].type2 = gSpeciesInfo[gBattleMons[battler].species].type2; } -static u32 GetHighestStatId(u32 battlerId) +u32 GetHighestStatId(u32 battlerId) { u32 i, highestId = STAT_ATK, highestStat = gBattleMons[battlerId].attack; diff --git a/src/battle_util.c b/src/battle_util.c index e79947b09..13c581730 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4883,6 +4883,15 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; + case ABILITY_PROTOSYNTHESIS: + if (!gSpecialStatuses[battler].switchInAbilityDone && gBattleWeather & B_WEATHER_SUN) + { + gSpecialStatuses[battler].switchInAbilityDone = TRUE; + PREPARE_STAT_BUFFER(gBattleTextBuff1, GetHighestStatId(battler)); + BattleScriptPushCursorAndCallback(BattleScript_ProtosynthesisActivates); + effect++; + } + break; #if B_WEATHER_FORMS < GEN_5 default: if (gBattleMons[battler].species == SPECIES_CHERRIM) @@ -8632,15 +8641,19 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef) static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType, bool32 updateFlags) { - u32 i, ability; + u32 i; u32 holdEffectAtk, holdEffectParamAtk; u16 basePower = CalcMoveBasePower(move, battlerAtk, battlerDef); u16 holdEffectModifier; u16 modifier = UQ_4_12(1.0); u32 atkSide = GET_BATTLER_SIDE(battlerAtk); + u16 atkAbility = GetBattlerAbility(battlerAtk); + u16 defAbility = GetBattlerAbility(battlerDef); + u8 atkHighestStat = GetHighestStatId(battlerAtk); + u8 defHighestStat = GetHighestStatId(battlerDef); // attacker's abilities - switch (GetBattlerAbility(battlerAtk)) + switch (atkAbility) { case ABILITY_TECHNICIAN: if (basePower <= 60) @@ -8750,11 +8763,15 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe if (moveType == TYPE_ROCK) MulModifier(&modifier, UQ_4_12(1.5)); break; + case ABILITY_PROTOSYNTHESIS: + if (gBattleWeather & B_WEATHER_SUN && WEATHER_HAS_EFFECT && (atkHighestStat == STAT_ATK || atkHighestStat == STAT_SPATK)) + MulModifier(&modifier, UQ_4_12(1.3)); + break; } // field abilities if ((IsAbilityOnField(ABILITY_DARK_AURA) && moveType == TYPE_DARK) - || (IsAbilityOnField(ABILITY_FAIRY_AURA) && moveType == TYPE_FAIRY)) + || (IsAbilityOnField(ABILITY_FAIRY_AURA) && moveType == TYPE_FAIRY)) { if (IsAbilityOnField(ABILITY_AURA_BREAK)) MulModifier(&modifier, UQ_4_12(0.75)); @@ -8782,8 +8799,7 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe } // target's abilities - ability = GetBattlerAbility(battlerDef); - switch (ability) + switch (defAbility) { case ABILITY_HEATPROOF: case ABILITY_WATER_BUBBLE: @@ -8791,7 +8807,7 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe { MulModifier(&modifier, UQ_4_12(0.5)); if (updateFlags) - RecordAbilityBattle(battlerDef, ability); + RecordAbilityBattle(battlerDef, defAbility); } break; case ABILITY_DRY_SKIN: @@ -8803,11 +8819,15 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe { MulModifier(&modifier, UQ_4_12(0.5)); if (updateFlags) - RecordAbilityBattle(battlerDef, ability); + RecordAbilityBattle(battlerDef, defAbility); } if (moveType == TYPE_FIRE) MulModifier(&modifier, UQ_4_12(2.0)); break; + case ABILITY_PROTOSYNTHESIS: + if (gBattleWeather & B_WEATHER_SUN && WEATHER_HAS_EFFECT && (defHighestStat == STAT_DEF || defHighestStat == STAT_SPDEF)) + MulModifier(&modifier, UQ_4_12(0.3)); + break; } holdEffectAtk = GetBattlerHoldEffect(battlerAtk, TRUE); From e25f843db3ac947fdfa179e2b24d7e886249f94f Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 4 Dec 2022 19:35:51 -0300 Subject: [PATCH 14/36] Implemented Quark Drive's effect Also tweaked STRINGID_SUNLIGHTACTIVATEDABILITY and STRINGID_STATWASHEIGHTENED. --- data/battle_scripts_1.s | 8 ++++++++ include/battle_scripts.h | 1 + include/constants/battle_string_ids.h | 3 ++- src/battle_main.c | 2 ++ src/battle_message.c | 6 ++++-- src/battle_util.c | 17 +++++++++++++++++ 6 files changed, 34 insertions(+), 3 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 3b8f69d7b..2f2e6f1a8 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -8418,6 +8418,14 @@ BattleScript_ProtosynthesisActivates:: waitmessage B_WAIT_TIME_MED end3 +BattleScript_QuarkDriveActivates:: + call BattleScript_AbilityPopUp + printstring STRINGID_ELECTRICTERRAINACTIVATEDABILITY + waitmessage B_WAIT_TIME_MED + printstring STRINGID_STATWASHEIGHTENED + waitmessage B_WAIT_TIME_MED + end3 + BattleScript_AttackWeakenedByStrongWinds:: pause B_WAIT_TIME_SHORT printstring STRINGID_ATTACKWEAKENEDBSTRONGWINDS diff --git a/include/battle_scripts.h b/include/battle_scripts.h index c614e4b67..519c72fc4 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -441,6 +441,7 @@ extern const u8 BattleScript_WindRiderActivatesMoveEnd[]; extern const u8 BattleScript_WindPowerActivates[]; extern const u8 BattleScript_WindPowerActivatesEnd2[]; extern const u8 BattleScript_ProtosynthesisActivates[]; +extern const u8 BattleScript_QuarkDriveActivates[]; // zmoves extern const u8 BattleScript_ZMoveActivateDamaging[]; diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index d4525572f..9606c5f59 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -633,8 +633,9 @@ #define STRINGID_BEINGHITCHARGEDPKMNWITHPOWER 631 #define STRINGID_SUNLIGHTACTIVATEDABILITY 632 #define STRINGID_STATWASHEIGHTENED 633 +#define STRINGID_ELECTRICTERRAINACTIVATEDABILITY 634 -#define BATTLESTRINGS_COUNT 634 +#define BATTLESTRINGS_COUNT 635 // 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_main.c b/src/battle_main.c index f78822247..42de8ac3a 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4506,6 +4506,8 @@ u32 GetBattlerTotalSpeedStat(u8 battlerId) speed /= 2; else if (ability == ABILITY_PROTOSYNTHESIS && gBattleWeather & B_WEATHER_SUN && highestStat == STAT_SPEED) speed = (speed * 150) / 100; + else if (ability == ABILITY_QUARK_DRIVE && gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN && highestStat == STAT_SPEED) + speed = (speed * 150) / 100; // stat stages speed *= gStatStageRatios[gBattleMons[battlerId].statStages[STAT_SPEED]][0]; diff --git a/src/battle_message.c b/src/battle_message.c index e8af7d625..00275fa45 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -760,11 +760,13 @@ static const u8 sText_AttackerHealedItsBurn[] = _("{B_ATK_NAME_WITH_PREFIX} heal static const u8 sText_AttackerMeltedTheIce[] = _("{B_ATK_NAME_WITH_PREFIX} melted the ice with\nits fiery determination!"); static const u8 sText_TargetToughedItOut[] = _("{B_DEF_NAME_WITH_PREFIX} toughed it out\nto show you its best side!"); static const u8 sText_BeingHitChargedPkmnWithPower[] = _("Being hit by {B_CURRENT_MOVE}\ncharged {B_ATK_NAME_WITH_PREFIX} with power!"); -static const u8 sText_SunlightActivatedAbility[] = _("The harsh sunlight activated\n{B_DEF_NAME_WITH_PREFIX}'s {B_DEF_ABILITY}!"); -static const u8 sText_StatWasHeightened[] = _("{B_DEF_NAME_WITH_PREFIX}'s {B_BUFF1} was heightened!"); +static const u8 sText_SunlightActivatedAbility[] = _("The harsh sunlight activated\n{B_ATK_NAME_WITH_PREFIX}'s {B_ATK_ABILITY}!"); +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}!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_ELECTRICTERRAINACTIVATEDABILITY - BATTLESTRINGS_TABLE_START] = sText_ElectricTerrainActivatedAbility, [STRINGID_STATWASHEIGHTENED - BATTLESTRINGS_TABLE_START] = sText_StatWasHeightened, [STRINGID_SUNLIGHTACTIVATEDABILITY - BATTLESTRINGS_TABLE_START] = sText_SunlightActivatedAbility, [STRINGID_BEINGHITCHARGEDPKMNWITHPOWER - BATTLESTRINGS_TABLE_START] = sText_BeingHitChargedPkmnWithPower, diff --git a/src/battle_util.c b/src/battle_util.c index 13c581730..aa00f1df7 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4892,6 +4892,15 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; + case ABILITY_QUARK_DRIVE: + if (!gSpecialStatuses[battler].switchInAbilityDone && gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN) + { + gSpecialStatuses[battler].switchInAbilityDone = TRUE; + PREPARE_STAT_BUFFER(gBattleTextBuff1, GetHighestStatId(battler)); + BattleScriptPushCursorAndCallback(BattleScript_QuarkDriveActivates); + effect++; + } + break; #if B_WEATHER_FORMS < GEN_5 default: if (gBattleMons[battler].species == SPECIES_CHERRIM) @@ -8767,6 +8776,10 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe if (gBattleWeather & B_WEATHER_SUN && WEATHER_HAS_EFFECT && (atkHighestStat == STAT_ATK || atkHighestStat == STAT_SPATK)) MulModifier(&modifier, UQ_4_12(1.3)); break; + case ABILITY_QUARK_DRIVE: + if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN && (atkHighestStat == STAT_ATK || atkHighestStat == STAT_SPATK)) + MulModifier(&modifier, UQ_4_12(1.3)); + break; } // field abilities @@ -8828,6 +8841,10 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe if (gBattleWeather & B_WEATHER_SUN && WEATHER_HAS_EFFECT && (defHighestStat == STAT_DEF || defHighestStat == STAT_SPDEF)) MulModifier(&modifier, UQ_4_12(0.3)); break; + case ABILITY_QUARK_DRIVE: + if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN && (defHighestStat == STAT_DEF || defHighestStat == STAT_SPDEF)) + MulModifier(&modifier, UQ_4_12(0.3)); + break; } holdEffectAtk = GetBattlerHoldEffect(battlerAtk, TRUE); From de05c4dd56e2c16dd39185a959902f233009417e Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 4 Dec 2022 20:17:14 -0300 Subject: [PATCH 15/36] Implemented Good as Gold's effect --- data/battle_scripts_1.s | 9 +++++++++ include/battle_scripts.h | 1 + src/battle_util.c | 9 +++++++++ 3 files changed, 19 insertions(+) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 2f2e6f1a8..6cf62d2f9 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -9888,6 +9888,15 @@ BattleScript_WindRiderActivatesMoveEnd:: BattleScript_WindRiderActivatesMoveEnd_End: goto BattleScript_MoveEnd +BattleScript_GoodAsGoldActivates:: + attackstring + ppreduce + showabilitypopup BS_TARGET + pause B_WAIT_TIME_SHORT + printstring STRINGID_ITDOESNTAFFECT + waitmessage B_WAIT_TIME_MED + goto BattleScript_MoveEnd + BattleScript_PastelVeilActivates:: setbyte gBattleCommunication, 0 setbyte gBattleCommunication + 1, 0 diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 519c72fc4..960262cba 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -442,6 +442,7 @@ extern const u8 BattleScript_WindPowerActivates[]; extern const u8 BattleScript_WindPowerActivatesEnd2[]; extern const u8 BattleScript_ProtosynthesisActivates[]; extern const u8 BattleScript_QuarkDriveActivates[]; +extern const u8 BattleScript_GoodAsGoldActivates[]; // zmoves extern const u8 BattleScript_ZMoveActivateDamaging[]; diff --git a/src/battle_util.c b/src/battle_util.c index aa00f1df7..6c69183d0 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5149,6 +5149,15 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move gBattlescriptCurrInstr = BattleScript_WindRiderActivatesMoveEnd; effect = 1; } + else if (GetBattlerAbility(gBattlerTarget) == ABILITY_GOOD_AS_GOLD + && IS_MOVE_STATUS(gCurrentMove) + && !(moveTarget & MOVE_TARGET_USER) + && !(moveTarget & MOVE_TARGET_OPPONENTS_FIELD) + && !(moveTarget & MOVE_TARGET_ALL_BATTLERS)) + { + gBattlescriptCurrInstr = BattleScript_GoodAsGoldActivates; + effect = 1; + } break; } case ABILITYEFFECT_ABSORBING: // 3 From 24465858a7d3506cc66b724bf7dc6eda85e8c7a6 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 4 Dec 2022 20:24:35 -0300 Subject: [PATCH 16/36] Implemented the 4 Ruin Abilities --- data/battle_scripts_1.s | 6 ++++ include/battle_scripts.h | 1 + include/constants/battle_string_ids.h | 3 +- src/battle_message.c | 2 ++ src/battle_util.c | 48 +++++++++++++++++++++++++++ 5 files changed, 59 insertions(+), 1 deletion(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 6cf62d2f9..746d83230 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -8426,6 +8426,12 @@ BattleScript_QuarkDriveActivates:: waitmessage B_WAIT_TIME_MED end3 +BattleScript_RuinAbilityActivates:: + call BattleScript_AbilityPopUp + printstring STRINGID_ABILITYWEAKENEDFSURROUNDINGMONSSTAT + 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 960262cba..33138189b 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -443,6 +443,7 @@ extern const u8 BattleScript_WindPowerActivatesEnd2[]; extern const u8 BattleScript_ProtosynthesisActivates[]; extern const u8 BattleScript_QuarkDriveActivates[]; extern const u8 BattleScript_GoodAsGoldActivates[]; +extern const u8 BattleScript_RuinAbilityActivates[]; // zmoves extern const u8 BattleScript_ZMoveActivateDamaging[]; diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index 9606c5f59..9c0965bb5 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -634,8 +634,9 @@ #define STRINGID_SUNLIGHTACTIVATEDABILITY 632 #define STRINGID_STATWASHEIGHTENED 633 #define STRINGID_ELECTRICTERRAINACTIVATEDABILITY 634 +#define STRINGID_ABILITYWEAKENEDFSURROUNDINGMONSSTAT 635 -#define BATTLESTRINGS_COUNT 635 +#define BATTLESTRINGS_COUNT 636 // 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 00275fa45..d109e0f4e 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -763,9 +763,11 @@ static const u8 sText_BeingHitChargedPkmnWithPower[] = _("Being hit by {B_CURREN static const u8 sText_SunlightActivatedAbility[] = _("The harsh sunlight activated\n{B_ATK_NAME_WITH_PREFIX}'s {B_ATK_ABILITY}!"); 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"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_ABILITYWEAKENEDFSURROUNDINGMONSSTAT - BATTLESTRINGS_TABLE_START] = sText_AbilityWeakenedSurroundingMonsStat, [STRINGID_ELECTRICTERRAINACTIVATEDABILITY - BATTLESTRINGS_TABLE_START] = sText_ElectricTerrainActivatedAbility, [STRINGID_STATWASHEIGHTENED - BATTLESTRINGS_TABLE_START] = sText_StatWasHeightened, [STRINGID_SUNLIGHTACTIVATEDABILITY - BATTLESTRINGS_TABLE_START] = sText_SunlightActivatedAbility, diff --git a/src/battle_util.c b/src/battle_util.c index 6c69183d0..e89ea26b1 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4901,6 +4901,42 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; + case ABILITY_VESSEL_OF_RUIN: + if (!gSpecialStatuses[battler].switchInAbilityDone) + { + PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_SPATK); + gSpecialStatuses[battler].switchInAbilityDone = TRUE; + BattleScriptPushCursorAndCallback(BattleScript_RuinAbilityActivates); + effect++; + } + break; + case ABILITY_SWORD_OF_RUIN: + if (!gSpecialStatuses[battler].switchInAbilityDone) + { + PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_DEF); + gSpecialStatuses[battler].switchInAbilityDone = TRUE; + BattleScriptPushCursorAndCallback(BattleScript_RuinAbilityActivates); + effect++; + } + break; + case ABILITY_TABLETS_OF_RUIN: + if (!gSpecialStatuses[battler].switchInAbilityDone) + { + PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_ATK); + gSpecialStatuses[battler].switchInAbilityDone = TRUE; + BattleScriptPushCursorAndCallback(BattleScript_RuinAbilityActivates); + effect++; + } + break; + case ABILITY_BEADS_OF_RUIN: + if (!gSpecialStatuses[battler].switchInAbilityDone) + { + PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_SPDEF); + gSpecialStatuses[battler].switchInAbilityDone = TRUE; + BattleScriptPushCursorAndCallback(BattleScript_RuinAbilityActivates); + effect++; + } + break; #if B_WEATHER_FORMS < GEN_5 default: if (gBattleMons[battler].species == SPECIES_CHERRIM) @@ -8801,6 +8837,18 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe MulModifier(&modifier, UQ_4_12(1.33)); } + if (IsAbilityOnField(ABILITY_VESSEL_OF_RUIN) && atkAbility != ABILITY_VESSEL_OF_RUIN && IS_MOVE_SPECIAL(gCurrentMove)) + MulModifier(&modifier, UQ_4_12(0.25)); + + if (IsAbilityOnField(ABILITY_SWORD_OF_RUIN) && defAbility != ABILITY_SWORD_OF_RUIN && IS_MOVE_PHYSICAL(gCurrentMove)) + MulModifier(&modifier, UQ_4_12(0.25)); + + if (IsAbilityOnField(ABILITY_TABLETS_OF_RUIN) && atkAbility != ABILITY_TABLETS_OF_RUIN && IS_MOVE_PHYSICAL(gCurrentMove)) + MulModifier(&modifier, UQ_4_12(0.25)); + + if (IsAbilityOnField(ABILITY_BEADS_OF_RUIN) && defAbility != ABILITY_BEADS_OF_RUIN && IS_MOVE_SPECIAL(gCurrentMove)) + MulModifier(&modifier, UQ_4_12(0.25)); + // attacker partner's abilities if (IsBattlerAlive(BATTLE_PARTNER(battlerAtk))) { From dd90ab1911a270720b2b39a4637ff7b0567611f6 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 4 Dec 2022 20:39:23 -0300 Subject: [PATCH 17/36] Implemented Orichalcum Pulse's effect --- src/battle_util.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/battle_util.c b/src/battle_util.c index e89ea26b1..f4fe58ae1 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4937,6 +4937,13 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; + case ABILITY_ORICHALCUM_PULSE: + if (TryChangeBattleWeather(battler, ENUM_WEATHER_SUN, TRUE)) + { + BattleScriptPushCursorAndCallback(BattleScript_DroughtActivates); + effect++; + } + break; #if B_WEATHER_FORMS < GEN_5 default: if (gBattleMons[battler].species == SPECIES_CHERRIM) @@ -8825,6 +8832,10 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN && (atkHighestStat == STAT_ATK || atkHighestStat == STAT_SPATK)) MulModifier(&modifier, UQ_4_12(1.3)); break; + case ABILITY_ORICHALCUM_PULSE: + if (gBattleWeather & B_WEATHER_SUN && WEATHER_HAS_EFFECT) + MulModifier(&modifier, UQ_4_12(1.3)); + break; } // field abilities From 18c30be8384008b63f2903d4a0ca087530c8c03a Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 4 Dec 2022 20:40:34 -0300 Subject: [PATCH 18/36] Implemented Hadron Engine's effect --- src/battle_util.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/battle_util.c b/src/battle_util.c index f4fe58ae1..38504e1bb 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4944,6 +4944,13 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; + case ABILITY_HADRON_ENGINE: + if (TryChangeBattleTerrain(battler, STATUS_FIELD_ELECTRIC_TERRAIN, &gFieldTimers.terrainTimer)) + { + BattleScriptPushCursorAndCallback(BattleScript_ElectricSurgeActivates); + effect++; + } + break; #if B_WEATHER_FORMS < GEN_5 default: if (gBattleMons[battler].species == SPECIES_CHERRIM) @@ -8836,6 +8843,10 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe if (gBattleWeather & B_WEATHER_SUN && WEATHER_HAS_EFFECT) MulModifier(&modifier, UQ_4_12(1.3)); break; + case ABILITY_HADRON_ENGINE: + if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN) + MulModifier(&modifier, UQ_4_12(1.3)); + break; } // field abilities From 7c67f1ac27ad698d76754b88653e8e98739f6a29 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Mon, 5 Dec 2022 23:24:27 -0300 Subject: [PATCH 19/36] Activated Switch In abilities during weather and terrain change Abilities such as Protosynthesis and Quark Drive demand it. --- data/battle_scripts_1.s | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 746d83230..785625e32 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -4886,6 +4886,7 @@ BattleScript_MoveWeatherChange:: printfromtable gMoveWeatherChangeStringIds waitmessage B_WAIT_TIME_LONG call BattleScript_WeatherFormChanges + call BattleScript_ActivateSwitchInAbilities goto BattleScript_MoveEnd BattleScript_EffectSunnyDay:: @@ -8458,6 +8459,18 @@ BattleScript_TerrainSeedLoop_NextBattler: addbyte gBattlerTarget, 0x1 jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_TerrainSeedLoopIter restoretarget + call BattleScript_ActivateSwitchInAbilities + return + +BattleScript_ActivateSwitchInAbilities: + copybyte sBATTLER, gBattlerAttacker + setbyte gBattlerAttacker, 0 +BattleScript_ActivateSwitchInAbilities_Loop: + switchinabilities BS_ATTACKER +BattleScript_ActivateSwitchInAbilities_Increment: + addbyte gBattlerAttacker, 1 + jumpifbytenotequal gBattlerAttacker, gBattlersCount, BattleScript_ActivateSwitchInAbilities_Loop + copybyte gBattlerAttacker, sBATTLER return BattleScript_ElectricSurgeActivates:: From f96137eb5e55dbc3bba9c59f6f34218b63f09d95 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Mon, 5 Dec 2022 23:36:18 -0300 Subject: [PATCH 20/36] Implemented Cud Chew's effect --- data/battle_scripts_1.s | 11 +++++++++++ include/battle.h | 1 + include/battle_scripts.h | 1 + src/battle_util.c | 15 +++++++++++++++ 4 files changed, 28 insertions(+) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 785625e32..00fb0ba27 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7656,6 +7656,17 @@ BattleScript_BallFetch:: waitmessage B_WAIT_TIME_LONG end3 +BattleScript_CudChewActivates:: + pause B_WAIT_TIME_SHORTEST + call BattleScript_AbilityPopUp + setbyte sBERRY_OVERRIDE, 1 @ override the requirements for eating berries + consumeberry BS_TARGET, FALSE + orword gHitMarker, HITMARKER_SKIP_DMG_TRACK | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE + healthbarupdate BS_ATTACKER + datahpupdate BS_ATTACKER + setbyte sBERRY_OVERRIDE, 0 + end3 + BattleScript_TargetFormChange:: pause 5 copybyte gBattlerAbility, gBattlerTarget diff --git a/include/battle.h b/include/battle.h index 14037b72c..4b33062d3 100644 --- a/include/battle.h +++ b/include/battle.h @@ -104,6 +104,7 @@ struct DisableStruct u8 noRetreat:1; u8 tarShot:1; u8 octolock:1; + u8 cudChew:1; }; struct ProtectStruct diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 33138189b..13fa5a4a6 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -444,6 +444,7 @@ extern const u8 BattleScript_ProtosynthesisActivates[]; extern const u8 BattleScript_QuarkDriveActivates[]; extern const u8 BattleScript_GoodAsGoldActivates[]; extern const u8 BattleScript_RuinAbilityActivates[]; +extern const u8 BattleScript_CudChewActivates[]; // zmoves extern const u8 BattleScript_ZMoveActivateDamaging[]; diff --git a/src/battle_util.c b/src/battle_util.c index 38504e1bb..7fdd63eb4 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2696,6 +2696,7 @@ enum ENDTURN_THROAT_CHOP, ENDTURN_SLOW_START, ENDTURN_PLASMA_FISTS, + ENDTURN_CUD_CHEW, ENDTURN_BATTLER_COUNT }; @@ -3238,6 +3239,11 @@ u8 DoBattlerEndTurnEffects(void) gStatuses4[i] &= ~STATUS4_PLASMA_FISTS; gBattleStruct->turnEffectsTracker++; break; + case ENDTURN_CUD_CHEW: + if (GetBattlerAbility(gActiveBattler) == ABILITY_CUD_CHEW && !gDisableStructs[gActiveBattler].cudChew && GetUsedHeldItem(gActiveBattler) != ITEM_NONE) + gDisableStructs[gActiveBattler].cudChew = TRUE; + gBattleStruct->turnEffectsTracker++; + break; case ENDTURN_BATTLER_COUNT: // done gBattleStruct->turnEffectsTracker = 0; gBattleStruct->turnEffectsBattlerId++; @@ -5154,6 +5160,15 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; + case ABILITY_CUD_CHEW: + if (ItemId_GetPocket(GetUsedHeldItem(battler)) == POCKET_BERRIES && gDisableStructs[gActiveBattler].cudChew == TRUE) + { + gLastUsedItem = gBattleStruct->usedHeldItems[battler][GetBattlerSide(battler)]; + gBattleStruct->usedHeldItems[battler][GetBattlerSide(battler)] = ITEM_NONE; + BattleScriptPushCursorAndCallback(BattleScript_CudChewActivates); + effect++; + } + break; } } break; From 3c30e6bdc360e9949bfbeb2e7e938deb1bbf3e3f Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 6 Dec 2022 01:41:06 -0300 Subject: [PATCH 21/36] Implemented Sharpness' effect --- include/constants/pokemon.h | 1 + src/battle_util.c | 4 ++++ src/data/battle_moves.h | 36 ++++++++++++++++++------------------ 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 8d637af30..35eca5bbc 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -236,6 +236,7 @@ #define FLAG_HIT_IN_SUBSTITUTE (1 << 26) // Hyperspace Fury #define FLAG_TWO_STRIKES (1 << 27) // A move with this flag will strike twice, and may apply its effect on each hit #define FLAG_WIND_MOVE (1 << 28) +#define FLAG_SLICING_MOVE (1 << 29) // Split defines. #define SPLIT_PHYSICAL 0x0 diff --git a/src/battle_util.c b/src/battle_util.c index 7fdd63eb4..2362a3fff 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -8862,6 +8862,10 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN) MulModifier(&modifier, UQ_4_12(1.3)); break; + case ABILITY_SHARPNESS: + if (gBattleMoves[move].flags & FLAG_SLICING_MOVE) + MulModifier(&modifier, UQ_4_12(1.5)); + break; } // field abilities diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 37ba7aaff..b9603b882 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -256,7 +256,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SLICING_MOVE, .split = SPLIT_PHYSICAL, .zMovePower = 100, .zMoveEffect = Z_EFFECT_NONE, @@ -1354,7 +1354,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_BOTH, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_HIGH_CRIT, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_HIGH_CRIT | FLAG_SLICING_MOVE, .split = SPLIT_PHYSICAL, .zMovePower = 100, .zMoveEffect = Z_EFFECT_NONE, @@ -2922,7 +2922,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_HIGH_CRIT, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_HIGH_CRIT | FLAG_SLICING_MOVE, .split = SPLIT_PHYSICAL, .zMovePower = 140, .zMoveEffect = Z_EFFECT_NONE, @@ -3805,7 +3805,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SLICING_MOVE, .split = SPLIT_PHYSICAL, .zMovePower = 100, .zMoveEffect = Z_EFFECT_NONE, @@ -5656,7 +5656,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_BOTH, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_HIGH_CRIT | FLAG_WIND_MOVE, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_HIGH_CRIT | FLAG_SLICING_MOVE | FLAG_WIND_MOVE, .split = SPLIT_SPECIAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -5989,7 +5989,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SLICING_MOVE, .split = SPLIT_PHYSICAL, .zMovePower = 120, .zMoveEffect = Z_EFFECT_NONE, @@ -6286,7 +6286,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_HIGH_CRIT, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_HIGH_CRIT | FLAG_SLICING_MOVE, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -7217,7 +7217,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_HIGH_CRIT, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_HIGH_CRIT | FLAG_SLICING_MOVE, .split = SPLIT_PHYSICAL, .zMovePower = 140, .zMoveEffect = Z_EFFECT_NONE, @@ -7259,7 +7259,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = { #if B_UPDATED_MOVE_DATA >= GEN_6 .pp = 15, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_SLICING_MOVE, #elif B_UPDATED_MOVE_DATA == GEN_5 .pp = 20, .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST, @@ -7289,7 +7289,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SLICING_MOVE, .split = SPLIT_PHYSICAL, .zMovePower = 160, .zMoveEffect = Z_EFFECT_NONE, @@ -7699,7 +7699,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_HIGH_CRIT, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_HIGH_CRIT | FLAG_SLICING_MOVE, .split = SPLIT_PHYSICAL, .zMovePower = 140, .zMoveEffect = Z_EFFECT_NONE, @@ -7921,7 +7921,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 10, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_HIGH_CRIT | FLAG_SHEER_FORCE_BOOST, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_HIGH_CRIT | FLAG_SHEER_FORCE_BOOST | FLAG_SLICING_MOVE, .split = SPLIT_PHYSICAL, .zMovePower = 140, .zMoveEffect = Z_EFFECT_NONE, @@ -9537,7 +9537,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_STAT_STAGES_IGNORED, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_STAT_STAGES_IGNORED | FLAG_SLICING_MOVE, .split = SPLIT_PHYSICAL, .zMovePower = 175, .zMoveEffect = Z_EFFECT_NONE, @@ -9553,7 +9553,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 50, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_SLICING_MOVE, .split = SPLIT_PHYSICAL, .zMovePower = 140, .zMoveEffect = Z_EFFECT_NONE, @@ -11182,7 +11182,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SLICING_MOVE, .split = SPLIT_PHYSICAL, .zMovePower = 190, .zMoveEffect = Z_EFFECT_NONE, @@ -12509,7 +12509,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SLICING_MOVE, .split = SPLIT_PHYSICAL, .zMovePower = 180, .zMoveEffect = Z_EFFECT_NONE, @@ -13292,7 +13292,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_USER, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SLICING_MOVE, .split = SPLIT_PHYSICAL, .zMovePower = 120, .zMoveEffect = Z_EFFECT_NONE, @@ -13532,7 +13532,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SLICING_MOVE, .split = SPLIT_PHYSICAL, .zMovePower = 120, .zMoveEffect = Z_EFFECT_NONE, From 7a52404fd301933302d4d63e8a63299ed90a7314 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 6 Dec 2022 02:51:13 -0300 Subject: [PATCH 22/36] 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 From aa051dab02328b4f58fd6570621ce588d2760ae5 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 6 Dec 2022 05:03:07 -0300 Subject: [PATCH 23/36] Implemented Costar's effect --- data/battle_scripts_1.s | 7 +++++++ include/battle_scripts.h | 1 + include/battle_util.h | 1 + src/battle_util.c | 14 ++++++++++++++ 4 files changed, 23 insertions(+) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 11f819c06..d6e0499ba 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -8451,6 +8451,13 @@ BattleScript_SupremeOverlordActivates:: waitmessage B_WAIT_TIME_LONG end3 +BattleScript_CostarActivates:: + pause B_WAIT_TIME_SHORT + call BattleScript_AbilityPopUp + printstring STRINGID_PKMNCOPIEDSTATCHANGES + 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 72db7e1f9..20575a5b6 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -446,6 +446,7 @@ extern const u8 BattleScript_GoodAsGoldActivates[]; extern const u8 BattleScript_RuinAbilityActivates[]; extern const u8 BattleScript_CudChewActivates[]; extern const u8 BattleScript_SupremeOverlordActivates[]; +extern const u8 BattleScript_CostarActivates[]; // zmoves extern const u8 BattleScript_ZMoveActivateDamaging[]; diff --git a/include/battle_util.h b/include/battle_util.h index 3f516daba..8922cd842 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -204,5 +204,6 @@ bool32 CanBeFrozen(u8 battlerId); bool32 CanBeConfused(u8 battlerId); bool32 IsBattlerTerrainAffected(u8 battlerId, u32 terrainFlag); u32 GetBattlerFriendshipScore(u8 battlerId); +u32 CountBattlerStatIncreases(u8 battlerId, bool32 countEvasionAcc); #endif // GUARD_BATTLE_UTIL_H diff --git a/src/battle_util.c b/src/battle_util.c index 36120a756..9bc5e24d4 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4965,6 +4965,20 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; + case ABILITY_COSTAR: + if (!gSpecialStatuses[battler].switchInAbilityDone + && IsDoubleBattle() + && IsBattlerAlive(BATTLE_PARTNER(battler)) + && CountBattlerStatIncreases(BATTLE_PARTNER(battler), FALSE)) + { + gSpecialStatuses[battler].switchInAbilityDone = TRUE; + for (i = 0; i < NUM_BATTLE_STATS; i++) + gBattleMons[battler].statStages[i] = gBattleMons[BATTLE_PARTNER(battler)].statStages[i]; + gBattlerTarget = BATTLE_PARTNER(battler); + BattleScriptPushCursorAndCallback(BattleScript_CostarActivates); + effect++; + } + break; #if B_WEATHER_FORMS < GEN_5 default: if (gBattleMons[battler].species == SPECIES_CHERRIM) From a961980e0f007fbd620a954dd7d235de15fc2d38 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 6 Dec 2022 05:14:05 -0300 Subject: [PATCH 24/36] Implemented Toxic Debris' effect --- data/battle_scripts_1.s | 9 +++++++++ include/battle_scripts.h | 1 + src/battle_util.c | 14 ++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index d6e0499ba..d1249e384 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7135,6 +7135,15 @@ BattleScript_WindPowerActivates:: BattleScript_WindPowerActivates_Ret: return +BattleScript_ToxicDebrisActivates:: + call BattleScript_AbilityPopUp + pause B_WAIT_TIME_SHORT + settoxicspikes BattleScript_ToxicDebrisRet + printstring STRINGID_POISONSPIKESSCATTERED + waitmessage B_WAIT_TIME_LONG +BattleScript_ToxicDebrisRet: + return + BattleScript_PerishSongCountGoesDown:: printstring STRINGID_PKMNPERISHCOUNTFELL waitmessage B_WAIT_TIME_LONG diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 20575a5b6..2faf22260 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -447,6 +447,7 @@ extern const u8 BattleScript_RuinAbilityActivates[]; extern const u8 BattleScript_CudChewActivates[]; extern const u8 BattleScript_SupremeOverlordActivates[]; extern const u8 BattleScript_CostarActivates[]; +extern const u8 BattleScript_ToxicDebrisActivates[]; // zmoves extern const u8 BattleScript_ZMoveActivateDamaging[]; diff --git a/src/battle_util.c b/src/battle_util.c index 9bc5e24d4..13bd933f9 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5911,6 +5911,20 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; + case ABILITY_TOXIC_DEBRIS: + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && !gProtectStructs[gBattlerAttacker].confusionSelfDmg + && IS_MOVE_PHYSICAL(gCurrentMove) + && TARGET_TURN_DAMAGED + && !(gSideStatuses[gBattlerAttacker] & SIDE_STATUS_TOXIC_SPIKES) + && IsBattlerAlive(gBattlerTarget)) + { + gBattlerTarget = gBattlerAttacker; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_ToxicDebrisActivates; + effect++; + } + break; } break; case ABILITYEFFECT_MOVE_END_ATTACKER: // Same as above, but for attacker From fa78e3b2c4a849b1367be95d7970764f6e5a3c88 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 6 Dec 2022 05:26:30 -0300 Subject: [PATCH 25/36] Implemented Armor Tail's effect --- src/battle_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index 13bd933f9..aa70bd323 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5208,8 +5208,8 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move gBattlescriptCurrInstr = BattleScript_SoundproofProtected; effect = 1; } - else if ((gLastUsedAbility == ABILITY_DAZZLING || gLastUsedAbility == ABILITY_QUEENLY_MAJESTY || IsBattlerAlive(battler ^= BIT_FLANK)) - && (battlerAbility == ABILITY_DAZZLING || battlerAbility == ABILITY_QUEENLY_MAJESTY) + else if ((gLastUsedAbility == ABILITY_DAZZLING || gLastUsedAbility == ABILITY_QUEENLY_MAJESTY || gLastUsedAbility == ABILITY_ARMOR_TAIL || IsBattlerAlive(battler ^= BIT_FLANK)) + && (battlerAbility == ABILITY_DAZZLING || battlerAbility == ABILITY_QUEENLY_MAJESTY || battlerAbility == ABILITY_ARMOR_TAIL) && GetChosenMovePriority(gBattlerAttacker) > 0 && GetBattlerSide(gBattlerAttacker) != GetBattlerSide(battler)) { From d6b9f076817ede74d08cef6503acf0e535c16d27 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 6 Dec 2022 05:29:26 -0300 Subject: [PATCH 26/36] Implemented Earth Eater's effect --- data/battle_scripts_1.s | 12 ++++++++++++ include/battle_scripts.h | 1 + src/battle_util.c | 12 ++++++++++++ 3 files changed, 25 insertions(+) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index d1249e384..67ae04374 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7144,6 +7144,18 @@ BattleScript_ToxicDebrisActivates:: BattleScript_ToxicDebrisRet: return +BattleScript_EarthEaterActivates:: + call BattleScript_AbilityPopUp + pause B_WAIT_TIME_LONG + tryhealquarterhealth BS_TARGET, BattleScript_EarthEaterRet + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE + healthbarupdate BS_TARGET + datahpupdate BS_TARGET + printstring STRINGID_PKMNREGAINEDHEALTH + waitmessage B_WAIT_TIME_LONG +BattleScript_EarthEaterRet: + return + BattleScript_PerishSongCountGoesDown:: printstring STRINGID_PKMNPERISHCOUNTFELL waitmessage B_WAIT_TIME_LONG diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 2faf22260..093bc61c0 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -448,6 +448,7 @@ extern const u8 BattleScript_CudChewActivates[]; extern const u8 BattleScript_SupremeOverlordActivates[]; extern const u8 BattleScript_CostarActivates[]; extern const u8 BattleScript_ToxicDebrisActivates[]; +extern const u8 BattleScript_EarthEaterActivates[]; // zmoves extern const u8 BattleScript_ZMoveActivateDamaging[]; diff --git a/src/battle_util.c b/src/battle_util.c index aa70bd323..d8068ef30 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5925,6 +5925,18 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; + case ABILITY_EARTH_EATER: + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && !gProtectStructs[gBattlerAttacker].confusionSelfDmg + && gBattleMoves[gCurrentMove].type == TYPE_GROUND + && TARGET_TURN_DAMAGED + && IsBattlerAlive(gBattlerTarget)) + { + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_EarthEaterActivates; + effect++; + } + break; } break; case ABILITYEFFECT_MOVE_END_ATTACKER: // Same as above, but for attacker From 107ace784b16575f80aa0169a58c6b7bdad15ae2 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 6 Dec 2022 06:18:18 -0300 Subject: [PATCH 27/36] Implemented Mycelium Might's effect --- include/battle_util.h | 1 + src/battle_main.c | 4 ++++ src/battle_util.c | 16 ++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/include/battle_util.h b/include/battle_util.h index 8922cd842..6d6361fc7 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -205,5 +205,6 @@ bool32 CanBeConfused(u8 battlerId); bool32 IsBattlerTerrainAffected(u8 battlerId, u32 terrainFlag); u32 GetBattlerFriendshipScore(u8 battlerId); u32 CountBattlerStatIncreases(u8 battlerId, bool32 countEvasionAcc); +bool32 IsMyceliumMightOnField(void); #endif // GUARD_BATTLE_UTIL_H diff --git a/src/battle_main.c b/src/battle_main.c index 42de8ac3a..e9a88ecb6 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4673,6 +4673,10 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves) strikesFirst = 1; else if (ability2 == ABILITY_STALL && ability1 != ABILITY_STALL) strikesFirst = 0; + else if (ability1 == ABILITY_MYCELIUM_MIGHT && ability2 != ABILITY_MYCELIUM_MIGHT && IS_MOVE_STATUS(gCurrentMove)) + strikesFirst = 1; + else if (ability2 == ABILITY_MYCELIUM_MIGHT && ability1 != ABILITY_MYCELIUM_MIGHT && IS_MOVE_STATUS(gCurrentMove)) + strikesFirst = 0; else { if (speedBattler1 == speedBattler2 && Random() & 1) diff --git a/src/battle_util.c b/src/battle_util.c index d8068ef30..527fbd5d0 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -6338,6 +6338,19 @@ bool32 IsNeutralizingGasOnField(void) return FALSE; } +bool32 IsMyceliumMightOnField(void) +{ + u32 i; + + for (i = 0; i < gBattlersCount; i++) + { + if (IsBattlerAlive(i) && gBattleMons[i].ability == ABILITY_MYCELIUM_MIGHT && IS_MOVE_STATUS(gCurrentMove)) + return TRUE; + } + + return FALSE; +} + u32 GetBattlerAbility(u8 battlerId) { if (gStatuses3[battlerId] & STATUS3_GASTRO_ACID) @@ -6346,6 +6359,9 @@ u32 GetBattlerAbility(u8 battlerId) if (IsNeutralizingGasOnField() && !IsNeutralizingGasBannedAbility(gBattleMons[battlerId].ability)) return ABILITY_NONE; + if (IsMyceliumMightOnField()) + return ABILITY_NONE; + if ((((gBattleMons[gBattlerAttacker].ability == ABILITY_MOLD_BREAKER || gBattleMons[gBattlerAttacker].ability == ABILITY_TERAVOLT || gBattleMons[gBattlerAttacker].ability == ABILITY_TURBOBLAZE) From c287f4f016c707f0fab6ebf4bf8ce498e935c2ea Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 6 Dec 2022 06:22:02 -0300 Subject: [PATCH 28/36] Updated sAbilitiesAffectedByMoldBreaker --- src/battle_util.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/battle_util.c b/src/battle_util.c index 527fbd5d0..823a40181 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -1064,6 +1064,11 @@ static const u8 sAbilitiesAffectedByMoldBreaker[] = [ABILITY_ICE_SCALES] = 1, [ABILITY_ICE_FACE] = 1, [ABILITY_PASTEL_VEIL] = 1, + [ABILITY_ARMOR_TAIL] = 1, + [ABILITY_EARTH_EATER] = 1, + [ABILITY_GOOD_AS_GOLD] = 1, + [ABILITY_PURIFYING_SALT] = 1, + [ABILITY_WELL_BAKED_BODY] = 1, }; static const u8 sAbilitiesNotTraced[ABILITIES_COUNT] = From a3e58b05c14e478b7e50597e520b5c0132874415 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Mon, 12 Dec 2022 20:30:25 -0300 Subject: [PATCH 29/36] Implemented Guard Dog's effect --- data/battle_scripts_1.s | 10 ++++++++++ src/battle_script_commands.c | 14 ++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index af368ec36..61392433d 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2967,6 +2967,7 @@ BattleScript_EffectHitEscape: jumpifmovehadnoeffect BattleScript_MoveEnd seteffectwithchance tryfaintmon BS_TARGET + jumpifability BS_TARGET, ABILITY_GUARD_DOG, BattleScript_MoveEnd moveendto MOVEEND_ATTACKER_VISIBLE moveendfrom MOVEEND_TARGET_VISIBLE jumpifbattleend BattleScript_HitEscapeEnd @@ -8421,6 +8422,7 @@ BattleScript_IntimidateLoop: jumpifability BS_TARGET, ABILITY_OWN_TEMPO, BattleScript_IntimidatePrevented jumpifability BS_TARGET, ABILITY_OBLIVIOUS, BattleScript_IntimidatePrevented .endif + jumpifability BS_TARGET, ABILITY_GUARD_DOG, BattleScript_IntimidateInReverse BattleScript_IntimidateEffect: copybyte sBATTLER, gBattlerTarget statbuffchange STAT_CHANGE_NOT_PROTECT_AFFECTED | MOVE_EFFECT_CERTAIN, NULL @@ -8447,6 +8449,14 @@ BattleScript_IntimidatePrevented: call BattleScript_TryAdrenalineOrb goto BattleScript_IntimidateLoopIncrement +BattleScript_IntimidateInReverse: + copybyte sBATTLER, gBattlerTarget + call BattleScript_AbilityPopUp + pause B_WAIT_TIME_SHORT + modifybattlerstatstage BS_TARGET, STAT_ATK, INCREASE, 1, BattleScript_IntimidateLoopIncrement, ANIM_ON + call BattleScript_TryAdrenalineOrb + goto BattleScript_IntimidateLoopIncrement + BattleScript_DroughtActivates:: pause B_WAIT_TIME_SHORT call BattleScript_AbilityPopUp diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 8f616fc3f..98cee311b 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -5760,7 +5760,8 @@ static void Cmd_moveend(void) if (gCurrentMove != MOVE_DRAGON_TAIL && gCurrentMove != MOVE_CIRCLE_THROW && IsBattlerAlive(gBattlerAttacker) - && !TestSheerForceFlag(gBattlerAttacker, gCurrentMove)) + && !TestSheerForceFlag(gBattlerAttacker, gCurrentMove) + && GetBattlerAbility(gBattlerAttacker) != ABILITY_GUARD_DOG) { // Since we check if battler was damaged, we don't need to check move result. // In fact, doing so actually prevents multi-target moves from activating red card properly @@ -9135,9 +9136,10 @@ static void Cmd_various(void) break; case VARIOUS_TRY_HIT_SWITCH_TARGET: if (IsBattlerAlive(gBattlerAttacker) - && IsBattlerAlive(gBattlerTarget) - && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && TARGET_TURN_DAMAGED) + && IsBattlerAlive(gBattlerTarget) + && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && TARGET_TURN_DAMAGED + && GetBattlerAbility(gBattlerTarget) != ABILITY_GUARD_DOG) { gBattleScripting.switchCase = B_SWITCH_HIT; gBattlescriptCurrInstr = BattleScript_ForceRandomSwitch; @@ -11236,8 +11238,8 @@ static void Cmd_forcerandomswitch(void) } else { - // In normal wild doubles, Roar will always fail if the user's level is less than the target's. - if (gBattleMons[gBattlerAttacker].level >= gBattleMons[gBattlerTarget].level) + // In normal wild doubles, Roar will always fail if the user's level is less than the target's or if the target's ability is Guard Dog. + if (gBattleMons[gBattlerAttacker].level >= gBattleMons[gBattlerTarget].level && GetBattlerAbility(gBattlerTarget) != ABILITY_GUARD_DOG) gBattlescriptCurrInstr = BattleScript_RoarSuccessEndBattle; else gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); From c8abf00cac0a56cf722355f2751ed7fbe2957386 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 20 Dec 2022 05:21:16 -0300 Subject: [PATCH 30/36] Applied corrections Anger Shell: -Made it print a string from the gStatDownStringIds table while lowering Def and Sp. Def -Made it use the shiny new modifybattlerstatstage macro. -Made it activate multiple times per battle, as it should. Well-Baked Body: -Turned it into an absorbing ability. Wind Rider: -Turned it into an absorbing ability. -For its Tailwind interaction, I made it activate only when Tailwind kicks in successfully, instead of whenever it's active at the end of a turn. Guard Dog: -Updated its check inside BattleScript_EffectHitEscape. -Moved it from Cmd_forcerandomswitch to BattleScript_EffectRoar. Wind Power: -Split off its move end effect from Electromorphosis'. Electromorphosis: -Split off its move end effect from Wind Power's. Hadron Engine: -Merged its Switch In effect with Electric Surge's. Protosynthesis: -Fixed its stat boost. Quark Drive: -Fixed its stat boost. Cud Chew: -Updated its ENDTURN effect's berry check. Supreme Overlord: -Tweaked the looping i variable's data type, the order of the variables and the checks inside ApplySupremeOverlordModifier. Earth Eater: -Turned it into an absorbing ability. Misc changes: -Added a variable to set the amount of stat stages raised inside AbilityMoveEffects' case ABILITYEFFECT_ABSORBING. -Added a preproc config to update the text string that they print. -Limited the scope of atkHighestStat and defHighestStat in CalcMoveBasePowerAfterModifiers to Protosynthesis's and Quark Drive's effects. --- data/battle_scripts_1.s | 62 ++++++++++---------- include/battle.h | 1 - include/config/battle.h | 3 +- src/battle_script_commands.c | 4 +- src/battle_util.c | 107 ++++++++++++++++++----------------- 5 files changed, 92 insertions(+), 85 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 61392433d..af0352e68 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2876,8 +2876,25 @@ BattleScript_EffectTailwind: waitanimation printstring STRINGID_TAILWINDBLEW waitmessage B_WAIT_TIME_LONG + call TryActivateWindRiderLoop goto BattleScript_MoveEnd +TryActivateWindRiderLoop: + savetarget + setbyte gBattlerTarget, 0 +BattleScript_WindRiderLoop_Iter: + jumpifability BS_TARGET, ABILITY_WIND_RIDER, BattleScript_WindRiderLoop_Activate + goto BattleScript_WindRiderLoop_Increment +BattleScript_WindRiderLoop_Activate: + call BattleScript_AbilityPopUp + modifybattlerstatstage BS_TARGET, STAT_ATK, INCREASE, 1, BattleScript_WindRiderLoop_Increment, ANIM_ON +BattleScript_WindRiderLoop_Increment: + addbyte gBattlerTarget, 0x1 + jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_WindRiderLoop_Iter +BattleScript_WindRiderLoop_Ret: + restoretarget + return + BattleScript_EffectMircleEye: attackcanceler accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE @@ -2965,9 +2982,9 @@ BattleScript_EffectHitEscape: resultmessage waitmessage B_WAIT_TIME_LONG jumpifmovehadnoeffect BattleScript_MoveEnd + jumpifability BS_TARGET, ABILITY_GUARD_DOG, BattleScript_MoveEnd seteffectwithchance tryfaintmon BS_TARGET - jumpifability BS_TARGET, ABILITY_GUARD_DOG, BattleScript_MoveEnd moveendto MOVEEND_ATTACKER_VISIBLE moveendfrom MOVEEND_TARGET_VISIBLE jumpifbattleend BattleScript_HitEscapeEnd @@ -3557,6 +3574,7 @@ BattleScript_EffectRoar:: attackstring ppreduce jumpifroarfails BattleScript_ButItFailed + jumpifability BS_TARGET, ABILITY_GUARD_DOG, BattleScript_ButItFailed jumpifability BS_TARGET, ABILITY_SUCTION_CUPS, BattleScript_AbilityPreventsPhasingOut jumpifstatus3 BS_TARGET, STATUS3_ROOTED, BattleScript_PrintMonIsRooted accuracycheck BattleScript_ButItFailed, NO_ACC_CALC_CHECK_LOCK_ON @@ -7151,38 +7169,16 @@ BattleScript_AngerShellActivates:: jumpifstat BS_TARGET, CMP_EQUAL, STAT_SPDEF, MIN_STAT_STAGE, BattleScript_ButItFailed BattleScript_AngerShellTryDef:: setbyte sSTAT_ANIM_PLAYED, FALSE - playstatchangeanimation BS_TARGET, BIT_DEF | BIT_SPDEF, STAT_CHANGE_NEGATIVE | STAT_CHANGE_CANT_PREVENT - setstatchanger STAT_DEF, 1, TRUE - statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR | MOVE_EFFECT_CERTAIN, BattleScript_AngerShellTrySpDef - jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_AngerShellTrySpDef - printfromtable gStatUpStringIds - waitmessage B_WAIT_TIME_LONG + modifybattlerstatstage BS_ATTACKER, STAT_DEF, DECREASE, 1, BattleScript_AngerShellTrySpDef, ANIM_ON BattleScript_AngerShellTrySpDef: - setstatchanger STAT_SPDEF, 1, TRUE - statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR | MOVE_EFFECT_CERTAIN, BattleScript_AngerShellTryAttack - jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_AngerShellTryAttack - printfromtable gStatUpStringIds - waitmessage B_WAIT_TIME_LONG + modifybattlerstatstage BS_ATTACKER, STAT_SPDEF, DECREASE, 1, BattleScript_AngerShellTryAttack, ANIM_ON BattleScript_AngerShellTryAttack: setbyte sSTAT_ANIM_PLAYED, FALSE - playstatchangeanimation BS_TARGET, BIT_SPATK | BIT_ATK | BIT_SPEED, STAT_CHANGE_BY_TWO - setstatchanger STAT_ATK, 1, FALSE - statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_AngerShellTrySpAtk - jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_AngerShellTrySpAtk - printfromtable gStatUpStringIds - waitmessage B_WAIT_TIME_LONG + modifybattlerstatstage BS_ATTACKER, STAT_ATK, INCREASE, 1, BattleScript_AngerShellTrySpAtk, ANIM_ON BattleScript_AngerShellTrySpAtk: - setstatchanger STAT_SPATK, 1, FALSE - statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_AngerShellTrySpeed - jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_AngerShellTrySpeed - printfromtable gStatUpStringIds - waitmessage B_WAIT_TIME_LONG + modifybattlerstatstage BS_ATTACKER, STAT_SPATK, INCREASE, 1, BattleScript_AngerShellTrySpeed, ANIM_ON BattleScript_AngerShellTrySpeed: - setstatchanger STAT_SPEED, 1, FALSE - statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_AngerShellRet - jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_AngerShellRet - printfromtable gStatUpStringIds - waitmessage B_WAIT_TIME_LONG + modifybattlerstatstage BS_ATTACKER, STAT_SPEED, INCREASE, 1, BattleScript_AngerShellRet, ANIM_ON BattleScript_AngerShellRet: return @@ -7210,7 +7206,7 @@ BattleScript_EarthEaterActivates:: call BattleScript_AbilityPopUp pause B_WAIT_TIME_LONG tryhealquarterhealth BS_TARGET, BattleScript_EarthEaterRet - orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE + orword gHitMarker, HITMARKER_SKIP_DMG_TRACK | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE healthbarupdate BS_TARGET datahpupdate BS_TARGET printstring STRINGID_PKMNREGAINEDHEALTH @@ -8451,6 +8447,7 @@ BattleScript_IntimidatePrevented: BattleScript_IntimidateInReverse: copybyte sBATTLER, gBattlerTarget + copybyte gBattlerAbility, gBattlerTarget call BattleScript_AbilityPopUp pause B_WAIT_TIME_SHORT modifybattlerstatstage BS_TARGET, STAT_ATK, INCREASE, 1, BattleScript_IntimidateLoopIncrement, ANIM_ON @@ -8703,8 +8700,15 @@ BattleScript_MoveStatDrain:: setgraphicalstatchangevalues playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 waitanimation +.if B_ABSORBING_ABILITY_STRING >= GEN_5 + statbuffchange STAT_CHANGE_ALLOW_PTR, BattleScript_MoveStatDrain_Cont + printfromtable gStatUpStringIds + waitmessage B_WAIT_TIME_LONG +.else printstring STRINGID_TARGETABILITYSTATRAISE waitmessage B_WAIT_TIME_LONG +.endif +BattleScript_MoveStatDrain_Cont: clearsemiinvulnerablebit tryfaintmon BS_ATTACKER goto BattleScript_MoveEnd diff --git a/include/battle.h b/include/battle.h index 317995333..883b70d26 100644 --- a/include/battle.h +++ b/include/battle.h @@ -653,7 +653,6 @@ struct BattleStruct u8 attackerBeforeBounce:2; u8 targetsDone[MAX_BATTLERS_COUNT]; // Each battler as a bit. u16 overwrittenAbilities[MAX_BATTLERS_COUNT]; // abilities overwritten during battle (keep separate from battle history in case of switching) - bool8 endturnAbilityDone[PARTY_SIZE][2]; // For some reason, adding a switchInAbilityDone equivalent in SpecialStatus didn't work. }; #define F_DYNAMIC_TYPE_1 (1 << 6) diff --git a/include/config/battle.h b/include/config/battle.h index 3f359a6f2..3f06f54da 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -110,6 +110,7 @@ #define B_WEATHER_FORMS GEN_LATEST // In Gen5+, Castform and Cherrim revert to their base form upon losing their respective ability. Cherrim needs Flower Gift to swap forms. #define B_SYMBIOSIS_GEMS GEN_LATEST // In Gen7+, Symbiosis passes an item after a gem-boosted attack. Previously, items are passed before the gem-boosted attack hits, making the item effect apply. #define B_CHECK_IF_CHARGED_UP TRUE // If set to TRUE, certain abilities such as Electromorphosis WILL check if the STATUS3_CHARGED_UP status flag is applied. +#define B_ABSORBING_ABILITY_STRING GEN_LATEST // In Gen5+, the abilities that absorb moves of a certain type use a generic string for stat increases and decreases. // Item settings #define B_HP_BERRIES GEN_LATEST // In Gen4+, berries which restore hp activate immediately after HP drops to half. In Gen3, the effect occurs at the end of the turn. @@ -174,7 +175,7 @@ #define B_LAST_USED_BALL_BUTTON R_BUTTON // If last used ball is implemented, this button (or button combo) will trigger throwing the last used ball. // Other settings -#define B_DOUBLE_WILD_CHANCE 0 // % chance of encountering two Pokémon in a Wild Encounter. +#define B_DOUBLE_WILD_CHANCE 100 // % chance of encountering two Pokémon in a Wild Encounter. #define B_MULTI_BATTLE_WHITEOUT GEN_LATEST // In Gen4+, multi battles end when the Player and also their Partner don't have any more Pokémon to fight. #define B_EVOLUTION_AFTER_WHITEOUT GEN_LATEST // In Gen6+, Pokemon that qualify for evolution after battle will evolve even if the player loses. #define B_WILD_NATURAL_ENEMIES TRUE // If set to TRUE, certain wild mon species will attack other species when partnered in double wild battles (eg. Zangoose vs Seviper) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 98cee311b..ab7e144f7 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -11238,8 +11238,8 @@ static void Cmd_forcerandomswitch(void) } else { - // In normal wild doubles, Roar will always fail if the user's level is less than the target's or if the target's ability is Guard Dog. - if (gBattleMons[gBattlerAttacker].level >= gBattleMons[gBattlerTarget].level && GetBattlerAbility(gBattlerTarget) != ABILITY_GUARD_DOG) + // In normal wild doubles, Roar will always fail if the user's level is less than the target's. + if (gBattleMons[gBattlerAttacker].level >= gBattleMons[gBattlerTarget].level) gBattlescriptCurrInstr = BattleScript_RoarSuccessEndBattle; else gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); diff --git a/src/battle_util.c b/src/battle_util.c index df16999eb..9556c8fc3 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2378,11 +2378,6 @@ u8 DoFieldEndTurnEffects(void) BattleScriptExecute(BattleScript_TailwindEnds); effect++; } - if (IsAbilityOnSide(gActiveBattler, ABILITY_WIND_RIDER)) - { - BattleScriptExecute(BattleScript_WindRiderActivatesEnd2); - effect++; - } if (IsAbilityOnSide(gActiveBattler, ABILITY_WIND_POWER)) { gCurrentMove = MOVE_TAILWIND; @@ -3245,7 +3240,7 @@ u8 DoBattlerEndTurnEffects(void) gBattleStruct->turnEffectsTracker++; break; case ENDTURN_CUD_CHEW: - if (GetBattlerAbility(gActiveBattler) == ABILITY_CUD_CHEW && !gDisableStructs[gActiveBattler].cudChew && GetUsedHeldItem(gActiveBattler) != ITEM_NONE) + if (GetBattlerAbility(gActiveBattler) == ABILITY_CUD_CHEW && !gDisableStructs[gActiveBattler].cudChew && ItemId_GetPocket(GetUsedHeldItem(gActiveBattler)) == POCKET_BERRIES) gDisableStructs[gActiveBattler].cudChew = TRUE; gBattleStruct->turnEffectsTracker++; break; @@ -4773,6 +4768,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move } break; case ABILITY_ELECTRIC_SURGE: + case ABILITY_HADRON_ENGINE: if (TryChangeBattleTerrain(battler, STATUS_FIELD_ELECTRIC_TERRAIN, &gFieldTimers.terrainTimer)) { BattleScriptPushCursorAndCallback(BattleScript_ElectricSurgeActivates); @@ -4957,13 +4953,6 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; - case ABILITY_HADRON_ENGINE: - if (TryChangeBattleTerrain(battler, STATUS_FIELD_ELECTRIC_TERRAIN, &gFieldTimers.terrainTimer)) - { - BattleScriptPushCursorAndCallback(BattleScript_ElectricSurgeActivates); - effect++; - } - break; case ABILITY_SUPREME_OVERLORD: if (!gSpecialStatuses[battler].switchInAbilityDone && CountUsablePartyMons(battler) < PARTY_SIZE) { @@ -5233,16 +5222,6 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move gBattlescriptCurrInstr = BattleScript_DarkTypePreventsPrankster; effect = 1; } - else if (targetAbility == ABILITY_WELL_BAKED_BODY && gBattleMoves[gCurrentMove].type == TYPE_FIRE) - { - gBattlescriptCurrInstr = BattleScript_WellBakedBodyActivates; - effect = 1; - } - else if (targetAbility == ABILITY_WIND_RIDER && gBattleMoves[gCurrentMove].flags & FLAG_WIND_MOVE && !(moveTarget & MOVE_TARGET_USER)) - { - gBattlescriptCurrInstr = BattleScript_WindRiderActivatesMoveEnd; - effect = 1; - } else if (GetBattlerAbility(gBattlerTarget) == ABILITY_GOOD_AS_GOLD && IS_MOVE_STATUS(gCurrentMove) && !(moveTarget & MOVE_TARGET_USER) @@ -5258,6 +5237,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move if (move != MOVE_NONE) { u8 statId; + u8 statAmount = 1; switch (gLastUsedAbility) { case ABILITY_VOLT_ABSORB: @@ -5315,6 +5295,18 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move } } break; + case ABILITY_WELL_BAKED_BODY: + if (moveType == TYPE_FIRE) + effect = 2, statId = STAT_DEF, statAmount = 2; + break; + case ABILITY_WIND_RIDER: + if (gBattleMoves[gCurrentMove].flags & FLAG_WIND_MOVE && !(GetBattlerMoveTargetType(gBattlerAttacker, gCurrentMove) & MOVE_TARGET_USER)) + effect = 2, statId = STAT_ATK; + break; + case ABILITY_EARTH_EATER: + if (moveType == TYPE_GROUND) + effect = 1; + break; } if (effect == 1) // Drain Hp ability. @@ -5359,9 +5351,11 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move else gBattlescriptCurrInstr = BattleScript_MoveStatDrain_PPLoss; - SET_STATCHANGER(statId, 1, FALSE); + SET_STATCHANGER(statId, statAmount, FALSE); + #if B_ABSORBING_ABILITY_STRING < GEN_5 gBattleMons[battler].statStages[statId]++; PREPARE_STAT_BUFFER(gBattleTextBuff1, statId); + #endif } } } @@ -5894,10 +5888,8 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && !gProtectStructs[gBattlerAttacker].confusionSelfDmg && TARGET_TURN_DAMAGED - && (gBattleMons[gBattlerTarget].hp <= gBattleMons[gBattlerTarget].maxHP / 2) - && !gBattleStruct->endturnAbilityDone[gBattlerPartyIndexes[gBattlerTarget]][GetBattlerSide(gBattlerTarget)]) + && (gBattleMons[gBattlerTarget].hp <= gBattleMons[gBattlerTarget].maxHP / 2)) { - gBattleStruct->endturnAbilityDone[gBattlerPartyIndexes[gBattlerTarget]][GetBattlerSide(gBattlerTarget)] = TRUE; gBattlerAttacker = gBattlerTarget; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_AngerShellActivates; @@ -5905,7 +5897,6 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move } break; case ABILITY_WIND_POWER: - case ABILITY_ELECTROMORPHOSIS: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && !gProtectStructs[gBattlerAttacker].confusionSelfDmg && TARGET_TURN_DAMAGED @@ -5918,6 +5909,18 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; + case ABILITY_ELECTROMORPHOSIS: + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && !gProtectStructs[gBattlerAttacker].confusionSelfDmg + && TARGET_TURN_DAMAGED + && IsBattlerAlive(gBattlerTarget)) + { + gBattlerAttacker = gBattlerTarget; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_WindPowerActivates; + effect++; + } + break; case ABILITY_TOXIC_DEBRIS: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && !gProtectStructs[gBattlerAttacker].confusionSelfDmg @@ -5932,18 +5935,6 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; - case ABILITY_EARTH_EATER: - if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && !gProtectStructs[gBattlerAttacker].confusionSelfDmg - && gBattleMoves[gCurrentMove].type == TYPE_GROUND - && TARGET_TURN_DAMAGED - && IsBattlerAlive(gBattlerTarget)) - { - BattleScriptPushCursor(); - gBattlescriptCurrInstr = BattleScript_EarthEaterActivates; - effect++; - } - break; } break; case ABILITYEFFECT_MOVE_END_ATTACKER: // Same as above, but for attacker @@ -8773,15 +8764,17 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef) // The first ally adds a x1.2 boost, and subsequent allies add an extra x0.1 boost each. static u16 ApplySupremeOverlordModifier(u8 battlerId) { + u32 i; 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) + if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE + && !GetMonData(&party[i], MON_DATA_IS_EGG) + && GetMonData(&party[i], MON_DATA_HP) == 0) modifier += (!appliedFirstBoost) ? UQ_4_12(0.2) : UQ_4_12(0.1); appliedFirstBoost = TRUE; } @@ -8799,8 +8792,6 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe u32 atkSide = GET_BATTLER_SIDE(battlerAtk); u16 atkAbility = GetBattlerAbility(battlerAtk); u16 defAbility = GetBattlerAbility(battlerDef); - u8 atkHighestStat = GetHighestStatId(battlerAtk); - u8 defHighestStat = GetHighestStatId(battlerDef); // attacker's abilities switch (atkAbility) @@ -8914,12 +8905,18 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe MulModifier(&modifier, UQ_4_12(1.5)); break; case ABILITY_PROTOSYNTHESIS: - if (gBattleWeather & B_WEATHER_SUN && WEATHER_HAS_EFFECT && (atkHighestStat == STAT_ATK || atkHighestStat == STAT_SPATK)) - MulModifier(&modifier, UQ_4_12(1.3)); + { + u8 atkHighestStat = GetHighestStatId(battlerAtk); + if (gBattleWeather & B_WEATHER_SUN && WEATHER_HAS_EFFECT && (atkHighestStat == STAT_ATK || atkHighestStat == STAT_SPATK)) + MulModifier(&modifier, UQ_4_12(1.3)); + } break; case ABILITY_QUARK_DRIVE: - if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN && (atkHighestStat == STAT_ATK || atkHighestStat == STAT_SPATK)) - MulModifier(&modifier, UQ_4_12(1.3)); + { + u8 atkHighestStat = GetHighestStatId(battlerAtk); + if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN && (atkHighestStat == STAT_ATK || atkHighestStat == STAT_SPATK)) + MulModifier(&modifier, UQ_4_12(1.3)); + } break; case ABILITY_ORICHALCUM_PULSE: if (gBattleWeather & B_WEATHER_SUN && WEATHER_HAS_EFFECT) @@ -9006,12 +9003,18 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe MulModifier(&modifier, UQ_4_12(2.0)); break; case ABILITY_PROTOSYNTHESIS: - if (gBattleWeather & B_WEATHER_SUN && WEATHER_HAS_EFFECT && (defHighestStat == STAT_DEF || defHighestStat == STAT_SPDEF)) - MulModifier(&modifier, UQ_4_12(0.3)); + { + u8 defHighestStat = GetHighestStatId(battlerDef); + if (gBattleWeather & B_WEATHER_SUN && WEATHER_HAS_EFFECT && (defHighestStat == STAT_DEF || defHighestStat == STAT_SPDEF)) + MulModifier(&modifier, UQ_4_12(0.7)); + } break; case ABILITY_QUARK_DRIVE: - if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN && (defHighestStat == STAT_DEF || defHighestStat == STAT_SPDEF)) - MulModifier(&modifier, UQ_4_12(0.3)); + { + u8 defHighestStat = GetHighestStatId(battlerDef); + if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN && (defHighestStat == STAT_DEF || defHighestStat == STAT_SPDEF)) + MulModifier(&modifier, UQ_4_12(0.7)); + } break; } From d943f891c5fa790fef9f8c3847302a213c0e9361 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 21 Dec 2022 10:08:16 -0300 Subject: [PATCH 31/36] Applied Wind Power and Wind Rider correction -Renamed TryActivateWindRiderLoop to BattleScript_TryTailwindAbilitiesLoop -Modified how it handles the check for Wind Rider by using a various and incorporated Wind Power into the mix because that ability is affected by Tailwind as well. --- asm/macros/battle_script.inc | 5 +++++ data/battle_scripts_1.s | 18 ++++++++---------- include/constants/battle_script_commands.h | 1 + src/battle_script_commands.c | 17 +++++++++++++++++ src/battle_util.c | 6 ------ 5 files changed, 31 insertions(+), 16 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index ee001e244..994cf4d52 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -2005,6 +2005,11 @@ .byte \stat .endm + .macro trywindriderpower battler:req, ptr:req + various \battler, VARIOUS_TRY_WIND_RIDER_POWER + .4byte \ptr + .endm + @ helpful macros .macro setstatchanger stat:req, stages:req, down:req setbyte sSTATCHANGER, \stat | \stages << 3 | \down << 7 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 615017713..0f5f2d3a5 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2876,22 +2876,20 @@ BattleScript_EffectTailwind: waitanimation printstring STRINGID_TAILWINDBLEW waitmessage B_WAIT_TIME_LONG - call TryActivateWindRiderLoop + call BattleScript_TryTailwindAbilitiesLoop goto BattleScript_MoveEnd -TryActivateWindRiderLoop: +BattleScript_TryTailwindAbilitiesLoop: savetarget setbyte gBattlerTarget, 0 -BattleScript_WindRiderLoop_Iter: - jumpifability BS_TARGET, ABILITY_WIND_RIDER, BattleScript_WindRiderLoop_Activate - goto BattleScript_WindRiderLoop_Increment -BattleScript_WindRiderLoop_Activate: +BattleScript_TryTailwindAbilitiesLoop_Iter: + trywindriderpower BS_TARGET, BattleScript_TryTailwindAbilitiesLoop_Increment call BattleScript_AbilityPopUp - modifybattlerstatstage BS_TARGET, STAT_ATK, INCREASE, 1, BattleScript_WindRiderLoop_Increment, ANIM_ON -BattleScript_WindRiderLoop_Increment: + modifybattlerstatstage BS_TARGET, STAT_ATK, INCREASE, 1, BattleScript_TryTailwindAbilitiesLoop_Increment, ANIM_ON +BattleScript_TryTailwindAbilitiesLoop_Increment: addbyte gBattlerTarget, 0x1 - jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_WindRiderLoop_Iter -BattleScript_WindRiderLoop_Ret: + jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_TryTailwindAbilitiesLoop_Iter +BattleScript_TryTailwindAbilitiesLoop_Ret: restoretarget return diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 0fcb2bbb0..3aba0144d 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -247,6 +247,7 @@ #define VARIOUS_GET_BATTLER_SIDE 156 #define VARIOUS_CHECK_PARENTAL_BOND_COUNTER 157 #define VARIOUS_SWAP_STATS 158 +#define VARIOUS_TRY_WIND_RIDER_POWER 159 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 089585d5a..807cafa28 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -10099,6 +10099,23 @@ static void Cmd_various(void) PREPARE_STAT_BUFFER(gBattleTextBuff1, statId); } break; + case VARIOUS_TRY_WIND_RIDER_POWER: + { + u16 ability = GetBattlerAbility(gActiveBattler); + if (GetBattlerSide(gActiveBattler) == GetBattlerSide(gBattlerAttacker) + && (ability == ABILITY_WIND_RIDER || ability == ABILITY_WIND_POWER)) + { + gLastUsedAbility = ability; + RecordAbilityBattle(gActiveBattler, gLastUsedAbility); + gBattlerAbility = gBattleScripting.battler = gActiveBattler; + gBattlescriptCurrInstr += 7; + } + else + { + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); + } + } + return; } // End of switch (gBattlescriptCurrInstr[2]) gBattlescriptCurrInstr += 3; diff --git a/src/battle_util.c b/src/battle_util.c index ba26128f3..b11a10e52 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2378,12 +2378,6 @@ u8 DoFieldEndTurnEffects(void) BattleScriptExecute(BattleScript_TailwindEnds); effect++; } - if (IsAbilityOnSide(gActiveBattler, ABILITY_WIND_POWER)) - { - gCurrentMove = MOVE_TAILWIND; - BattleScriptExecute(BattleScript_WindPowerActivatesEnd2); - effect++; - } } gBattleStruct->turnSideTracker++; if (effect != 0) From 31cd076f9dbc3053936370c69126289811ce25df Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 21 Dec 2022 11:14:59 -0300 Subject: [PATCH 32/36] Oopsie. Wind Power doesn't boost Attack lol --- data/battle_scripts_1.s | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 0f5f2d3a5..4cb11f183 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2884,8 +2884,8 @@ BattleScript_TryTailwindAbilitiesLoop: setbyte gBattlerTarget, 0 BattleScript_TryTailwindAbilitiesLoop_Iter: trywindriderpower BS_TARGET, BattleScript_TryTailwindAbilitiesLoop_Increment - call BattleScript_AbilityPopUp - modifybattlerstatstage BS_TARGET, STAT_ATK, INCREASE, 1, BattleScript_TryTailwindAbilitiesLoop_Increment, ANIM_ON + jumpifability BS_TARGET, ABILITY_WIND_RIDER, BattleScript_TryTailwindAbilitiesLoop_WindRider + jumpifability BS_TARGET, ABILITY_WIND_POWER, BattleScript_TryTailwindAbilitiesLoop_WindPower BattleScript_TryTailwindAbilitiesLoop_Increment: addbyte gBattlerTarget, 0x1 jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_TryTailwindAbilitiesLoop_Iter @@ -2893,6 +2893,21 @@ BattleScript_TryTailwindAbilitiesLoop_Ret: restoretarget return +BattleScript_TryTailwindAbilitiesLoop_WindRider: + call BattleScript_AbilityPopUp + modifybattlerstatstage BS_TARGET, STAT_ATK, INCREASE, 1, BattleScript_TryTailwindAbilitiesLoop_Increment, ANIM_ON + goto BattleScript_TryTailwindAbilitiesLoop_Increment + +BattleScript_TryTailwindAbilitiesLoop_WindPower: + call BattleScript_AbilityPopUp + copybyte sSAVED_BATTLER, gBattlerAttacker + copybyte gBattlerAttacker, gBattlerTarget + setcharge + printstring STRINGID_BEINGHITCHARGEDPKMNWITHPOWER + waitmessage B_WAIT_TIME_LONG + copybyte gBattlerAttacker, sSAVED_BATTLER + goto BattleScript_TryTailwindAbilitiesLoop_Increment + BattleScript_EffectMircleEye: attackcanceler accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE From c40e15f8c5cf393b68a9b40c6bb49acc3edb40da Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 21 Dec 2022 19:43:41 -0300 Subject: [PATCH 33/36] Added Sheer Force check to Anger Shell --- src/battle_util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/battle_util.c b/src/battle_util.c index b11a10e52..ac34d5360 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5881,7 +5881,8 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && !gProtectStructs[gBattlerAttacker].confusionSelfDmg && TARGET_TURN_DAMAGED - && (gBattleMons[gBattlerTarget].hp <= gBattleMons[gBattlerTarget].maxHP / 2)) + && (gBattleMons[gBattlerTarget].hp <= gBattleMons[gBattlerTarget].maxHP / 2) + && !(TestSheerForceFlag(gBattlerAttacker, gCurrentMove))) { gBattlerAttacker = gBattlerTarget; BattleScriptPushCursor(); From 0ef148dfbbd9391aec26f32d5d1dee7e994fb5e4 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 28 Dec 2022 08:50:15 -0300 Subject: [PATCH 34/36] Applied more corrections -Removed BattleScript_WindRiderActivatesEnd2 -Tweaked the condition of Wind Power in AbilityBattleEffects -Renamed ApplySupremeOverlordModifier to GetSupremeOverlordModifier --- data/battle_scripts_1.s | 20 -------------------- include/battle_scripts.h | 1 - src/battle_util.c | 19 +++++-------------- 3 files changed, 5 insertions(+), 35 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 4cb11f183..01ef1fdd3 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -6683,26 +6683,6 @@ BattleScript_TailwindEnds:: waitmessage B_WAIT_TIME_LONG end2 -BattleScript_WindRiderActivatesEnd2:: - setbyte gBattlerTarget, 0 -BattleScript_WindRiderLoop: - printstring STRINGID_EMPTYSTRING3 - jumpifability BS_TARGET, ABILITY_WIND_RIDER, BattleScript_WindRiderLoop_Cont - goto BattleScript_WindRiderIncrement -BattleScript_WindRiderLoop_Cont: - jumpifsideaffecting BS_TARGET, SIDE_STATUS_TAILWIND, BattleScript_WindRider_Activate - goto BattleScript_WindRiderIncrement -BattleScript_WindRider_Activate: - call BattleScript_AbilityPopUp - pause B_WAIT_TIME_MED - modifybattlerstatstage BS_TARGET, STAT_ATK, INCREASE, 1, BattleScript_WindRiderIncrement, ANIM_ON -BattleScript_WindRiderIncrement: - addbyte gBattlerTarget, 1 - jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_WindRiderLoop -BattleScript_WindRiderEnd: - destroyabilitypopup - end2 - BattleScript_WindPowerActivatesEnd2:: setbyte gBattlerAttacker, 0 BattleScript_WindPowerLoop: diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 5fc55cc65..d79566a44 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -436,7 +436,6 @@ extern const u8 BattleScript_DoubleShockRemoveType[]; extern const u8 BattleScript_SeedSowerActivates[]; extern const u8 BattleScript_AngerShellActivates[]; extern const u8 BattleScript_WellBakedBodyActivates[]; -extern const u8 BattleScript_WindRiderActivatesEnd2[]; extern const u8 BattleScript_WindRiderActivatesMoveEnd[]; extern const u8 BattleScript_WindPowerActivates[]; extern const u8 BattleScript_WindPowerActivatesEnd2[]; diff --git a/src/battle_util.c b/src/battle_util.c index ac34d5360..c1d112d19 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5891,18 +5891,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move } break; case ABILITY_WIND_POWER: - if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && !gProtectStructs[gBattlerAttacker].confusionSelfDmg - && TARGET_TURN_DAMAGED - && gBattleMoves[gCurrentMove].flags & FLAG_WIND_MOVE - && IsBattlerAlive(gBattlerTarget)) - { - gBattlerAttacker = gBattlerTarget; - BattleScriptPushCursor(); - gBattlescriptCurrInstr = BattleScript_WindPowerActivates; - effect++; - } - break; + if (!(gBattleMoves[gCurrentMove].flags & FLAG_WIND_MOVE)) + break; + // fall through case ABILITY_ELECTROMORPHOSIS: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && !gProtectStructs[gBattlerAttacker].confusionSelfDmg @@ -8756,7 +8747,7 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef) // 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) +static u16 GetSupremeOverlordModifier(u8 battlerId) { u32 i; u8 side = GetBattlerSide(battlerId); @@ -8925,7 +8916,7 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe MulModifier(&modifier, UQ_4_12(1.5)); break; case ABILITY_SUPREME_OVERLORD: - MulModifier(&modifier, ApplySupremeOverlordModifier(battlerAtk)); + MulModifier(&modifier, GetSupremeOverlordModifier(battlerAtk)); break; } From e8dfb66c309dc7166ec3cd12ce30de86b1c44fe0 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Thu, 29 Dec 2022 01:32:24 -0300 Subject: [PATCH 35/36] Adding ability effect triggers for terrains and weather A new, probably better way to handle the announcement trigger that abilities such as Protosynthesis and Quark Drive have, when the battle weather or the field terrain change. Misc. changes: -EFFECT_DAMAGE_SET_TERRAIN -> EFFECT_HIT_SET_REMOVE_TERRAIN -It's more appropriate as the effect can be used to force set a terrain or simply to remove an active terrain, after all. -The main reason for the rename was the inconsistency with the battle script's label. -Reverted accidentally committed change to B_DOUBLE_WILD_CHANCE, performed back in c8abf00c. --- asm/macros/battle_script.inc | 8 ++++ data/battle_scripts_1.s | 44 ++++++++++++++++++++-- include/battle_util.h | 2 + include/constants/battle_move_effects.h | 2 +- include/constants/battle_script_commands.h | 2 + src/battle_script_commands.c | 10 ++++- src/battle_tv.c | 2 +- src/battle_util.c | 28 ++++++++++++++ src/data/battle_moves.h | 12 +++--- 9 files changed, 97 insertions(+), 13 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 994cf4d52..a882a0315 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -2010,6 +2010,14 @@ .4byte \ptr .endm + .macro activateweatherabilities battler:req + various \battler, VARIOUS_ACTIVATE_WEATHER_ABILITIES + .endm + + .macro activateterrainabilities battler:req + various \battler, VARIOUS_ACTIVATE_TERRAIN_ABILITIES + .endm + @ helpful macros .macro setstatchanger stat:req, stages:req, down:req setbyte sSTATCHANGER, \stat | \stages << 3 | \down << 7 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 01ef1fdd3..722619c3b 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -410,7 +410,7 @@ gBattleScriptsForMoveEffects:: .4byte BattleScript_EffectCourtChange @ EFFECT_COURT_CHANGE .4byte BattleScript_EffectSteelBeam @ EFFECT_STEEL_BEAM .4byte BattleScript_EffectExtremeEvoboost @ EFFECT_EXTREME_EVOBOOST - .4byte BattleScript_EffectTerrainHit @ EFFECT_DAMAGE_SET_TERRAIN + .4byte BattleScript_EffectHitSetRemoveTerrain @ EFFECT_HIT_SET_REMOVE_TERRAIN .4byte BattleScript_EffectDarkVoid @ EFFECT_DARK_VOID .4byte BattleScript_EffectSleepHit @ EFFECT_SLEEP_HIT .4byte BattleScript_EffectDoubleShock @ EFFECT_DOUBLE_SHOCK @@ -2456,6 +2456,7 @@ BattleScript_EffectPsychicTerrain: printfromtable gTerrainStringIds waitmessage B_WAIT_TIME_LONG playanimation BS_ATTACKER, B_ANIM_RESTORE_BG + call BattleScript_ActivateTerrainAbilities call BattleScript_TerrainSeedLoop jumpifabilitypresent ABILITY_MIMICRY, BattleScript_ApplyMimicry goto BattleScript_MoveEnd @@ -4975,9 +4976,20 @@ BattleScript_MoveWeatherChange:: printfromtable gMoveWeatherChangeStringIds waitmessage B_WAIT_TIME_LONG call BattleScript_WeatherFormChanges - call BattleScript_ActivateSwitchInAbilities + call BattleScript_ActivateWeatherAbilities goto BattleScript_MoveEnd +BattleScript_ActivateWeatherAbilities: + copybyte sBATTLER, gBattlerAttacker + setbyte gBattlerAttacker, 0 +BattleScript_ActivateWeatherAbilities_Loop: + activateweatherabilities BS_ATTACKER +BattleScript_ActivateWeatherAbilities_Increment: + addbyte gBattlerAttacker, 1 + jumpifbytenotequal gBattlerAttacker, gBattlersCount, BattleScript_ActivateWeatherAbilities_Loop + copybyte gBattlerAttacker, sBATTLER + return + BattleScript_EffectSunnyDay:: attackcanceler attackstring @@ -7150,6 +7162,7 @@ BattleScript_SeedSowerActivates:: printstring STRINGID_TERRAINBECOMESGRASSY waitmessage B_WAIT_TIME_LONG playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG + call BattleScript_ActivateTerrainAbilities call BattleScript_TerrainSeedLoop return @@ -8167,6 +8180,7 @@ BattleScript_DrizzleActivates:: waitstate playanimation BS_BATTLER_0, B_ANIM_RAIN_CONTINUES call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities end3 BattleScript_AbilityRaisesDefenderStat:: @@ -8327,6 +8341,7 @@ BattleScript_SandstreamActivates:: waitstate playanimation BS_BATTLER_0, B_ANIM_SANDSTORM_CONTINUES call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities end3 BattleScript_SandSpitActivates:: @@ -8336,6 +8351,7 @@ BattleScript_SandSpitActivates:: waitstate playanimation BS_BATTLER_0, B_ANIM_SANDSTORM_CONTINUES call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities return BattleScript_ShedSkinActivates:: @@ -8454,6 +8470,7 @@ BattleScript_DroughtActivates:: waitstate playanimation BS_BATTLER_0, B_ANIM_SUN_CONTINUES call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities end3 BattleScript_DesolateLandActivates:: @@ -8463,6 +8480,7 @@ BattleScript_DesolateLandActivates:: waitstate playanimation BS_BATTLER_0, B_ANIM_SUN_CONTINUES call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities end3 BattleScript_DesolateLandEvaporatesWaterTypeMoves:: @@ -8483,6 +8501,7 @@ BattleScript_PrimordialSeaActivates:: waitstate playanimation BS_BATTLER_0, B_ANIM_RAIN_CONTINUES call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities end3 BattleScript_PrimordialSeaFizzlesOutFireTypeMoves:: @@ -8553,6 +8572,7 @@ BattleScript_SnowWarningActivates:: waitstate playanimation BS_BATTLER_0, B_ANIM_HAIL_CONTINUES call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities end3 BattleScript_TerrainSeedLoop: @@ -8566,7 +8586,6 @@ BattleScript_TerrainSeedLoop_NextBattler: addbyte gBattlerTarget, 0x1 jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_TerrainSeedLoopIter restoretarget - call BattleScript_ActivateSwitchInAbilities return BattleScript_ActivateSwitchInAbilities: @@ -8580,12 +8599,24 @@ BattleScript_ActivateSwitchInAbilities_Increment: copybyte gBattlerAttacker, sBATTLER return +BattleScript_ActivateTerrainAbilities: + copybyte sBATTLER, gBattlerAttacker + setbyte gBattlerAttacker, 0 +BattleScript_ActivateTerrainAbilities_Loop: + activateterrainabilities BS_ATTACKER +BattleScript_ActivateTerrainAbilities_Increment: + addbyte gBattlerAttacker, 1 + jumpifbytenotequal gBattlerAttacker, gBattlersCount, BattleScript_ActivateTerrainAbilities_Loop + copybyte gBattlerAttacker, sBATTLER + return + BattleScript_ElectricSurgeActivates:: pause B_WAIT_TIME_SHORT call BattleScript_AbilityPopUp printstring STRINGID_TERRAINBECOMESELECTRIC waitmessage B_WAIT_TIME_LONG playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG + call BattleScript_ActivateTerrainAbilities call BattleScript_TerrainSeedLoop end3 @@ -8595,6 +8626,7 @@ BattleScript_MistySurgeActivates:: printstring STRINGID_TERRAINBECOMESMISTY waitmessage B_WAIT_TIME_LONG playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG + call BattleScript_ActivateTerrainAbilities call BattleScript_TerrainSeedLoop end3 @@ -8604,6 +8636,7 @@ BattleScript_GrassySurgeActivates:: printstring STRINGID_TERRAINBECOMESGRASSY waitmessage B_WAIT_TIME_LONG playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG + call BattleScript_ActivateTerrainAbilities call BattleScript_TerrainSeedLoop end3 @@ -8613,6 +8646,7 @@ BattleScript_PsychicSurgeActivates:: printstring STRINGID_TERRAINBECOMESPSYCHIC waitmessage B_WAIT_TIME_LONG playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG + call BattleScript_ActivateTerrainAbilities call BattleScript_TerrainSeedLoop end3 @@ -9722,6 +9756,7 @@ BattleScript_AnnounceAirLockCloudNine:: printstring STRINGID_AIRLOCKACTIVATES waitmessage B_WAIT_TIME_LONG call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities end3 BattleScript_QuickClawActivation:: @@ -9881,7 +9916,7 @@ BattleScript_ExtremeEvoboostSpDef:: BattleScript_ExtremeEvoboostEnd:: goto BattleScript_MoveEnd -BattleScript_EffectTerrainHit: +BattleScript_EffectHitSetRemoveTerrain: attackcanceler accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE attackstring @@ -9903,6 +9938,7 @@ BattleScript_EffectTerrainHit: setterrain BattleScript_TryFaint playanimation BS_ATTACKER, B_ANIM_RESTORE_BG printfromtable gTerrainStringIds + call BattleScript_ActivateTerrainAbilities BattleScript_TryFaint: tryfaintmon BS_TARGET goto BattleScript_MoveEnd diff --git a/include/battle_util.h b/include/battle_util.h index 5f5f0b902..18af25c68 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -34,6 +34,8 @@ #define ABILITYEFFECT_MOVE_END_OTHER 12 #define ABILITYEFFECT_NEUTRALIZINGGAS 13 #define ABILITYEFFECT_FIELD_SPORT 14 // Only used if B_SPORT_TURNS < GEN_6 +#define ABILITYEFFECT_ON_WEATHER 15 +#define ABILITYEFFECT_ON_TERRAIN 16 // Special cases #define ABILITYEFFECT_MUD_SPORT 252 // Only used if B_SPORT_TURNS < GEN_6 #define ABILITYEFFECT_WATER_SPORT 253 // Only used if B_SPORT_TURNS < GEN_6 diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index 5af1017a9..122660c05 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -391,7 +391,7 @@ #define EFFECT_COURT_CHANGE 385 #define EFFECT_STEEL_BEAM 386 #define EFFECT_EXTREME_EVOBOOST 387 -#define EFFECT_DAMAGE_SET_TERRAIN 388 // genesis supernova +#define EFFECT_HIT_SET_REMOVE_TERRAIN 388 #define EFFECT_DARK_VOID 389 #define EFFECT_SLEEP_HIT 390 #define EFFECT_DOUBLE_SHOCK 391 diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 3aba0144d..74d7a0be2 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -248,6 +248,8 @@ #define VARIOUS_CHECK_PARENTAL_BOND_COUNTER 157 #define VARIOUS_SWAP_STATS 158 #define VARIOUS_TRY_WIND_RIDER_POWER 159 +#define VARIOUS_ACTIVATE_WEATHER_ABILITIES 160 +#define VARIOUS_ACTIVATE_TERRAIN_ABILITIES 161 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 807cafa28..e08a61c2f 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -7941,7 +7941,7 @@ static void HandleTerrainMove(u16 move) statusFlag = STATUS_FIELD_PSYCHIC_TERRAIN, timer = &gFieldTimers.terrainTimer; gBattleCommunication[MULTISTRING_CHOOSER] = 3; break; - case EFFECT_DAMAGE_SET_TERRAIN: + case EFFECT_HIT_SET_REMOVE_TERRAIN: switch (gBattleMoves[move].argument) { case 0: //genesis supernova @@ -10116,6 +10116,14 @@ static void Cmd_various(void) } } return; + case VARIOUS_ACTIVATE_WEATHER_ABILITIES: + gBattlescriptCurrInstr += 3; + AbilityBattleEffects(ABILITYEFFECT_ON_WEATHER, gActiveBattler, 0, 0, 0); + return; + case VARIOUS_ACTIVATE_TERRAIN_ABILITIES: + gBattlescriptCurrInstr += 3; + AbilityBattleEffects(ABILITYEFFECT_ON_TERRAIN, gActiveBattler, 0, 0, 0); + return; } // End of switch (gBattlescriptCurrInstr[2]) gBattlescriptCurrInstr += 3; diff --git a/src/battle_tv.c b/src/battle_tv.c index 9d2ec244e..33483da06 100644 --- a/src/battle_tv.c +++ b/src/battle_tv.c @@ -476,7 +476,7 @@ static const u16 sPoints_MoveEffect[NUM_BATTLE_MOVE_EFFECTS] = [EFFECT_COURT_CHANGE] = 0, // TODO: Assign points [EFFECT_STEEL_BEAM] = 0, // TODO: Assign points [EFFECT_EXTREME_EVOBOOST] = 0, // TODO: Assign points - [EFFECT_DAMAGE_SET_TERRAIN] = 0, // TODO: Assign points + [EFFECT_HIT_SET_REMOVE_TERRAIN] = 0, // TODO: Assign points [EFFECT_DARK_VOID] = 0, // TODO: Assign points [EFFECT_SLEEP_HIT] = 1, [EFFECT_DOUBLE_SHOCK] = 0, // TODO: Assign points diff --git a/src/battle_util.c b/src/battle_util.c index c1d112d19..c31ee5069 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -6251,6 +6251,34 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move break; } break; + case ABILITYEFFECT_ON_WEATHER: // For ability effects that activate when the battle weather changes. + gBattleScripting.battler = gBattlerAbility = battler; + switch (GetBattlerAbility(battler)) + { + case ABILITY_PROTOSYNTHESIS: + if (IsBattlerWeatherAffected(battler, B_WEATHER_SUN)) + { + PREPARE_STAT_BUFFER(gBattleTextBuff1, GetHighestStatId(battler)); + BattleScriptPushCursorAndCallback(BattleScript_ProtosynthesisActivates); + effect++; + } + break; + } + break; + case ABILITYEFFECT_ON_TERRAIN: // For ability effects that activate when the field terrain changes. + gBattleScripting.battler = gBattlerAbility = battler; + switch (GetBattlerAbility(battler)) + { + case ABILITY_QUARK_DRIVE: + if (IsBattlerTerrainAffected(battler, STATUS_FIELD_ELECTRIC_TERRAIN)) + { + PREPARE_STAT_BUFFER(gBattleTextBuff1, GetHighestStatId(battler)); + BattleScriptPushCursorAndCallback(BattleScript_QuarkDriveActivates); + effect++; + } + break; + } + break; } if (effect && gLastUsedAbility != 0xFF) diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index b633010e7..e5d3306ce 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -13872,7 +13872,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_ICE_SPINNER] = { - .effect = EFFECT_DAMAGE_SET_TERRAIN, + .effect = EFFECT_HIT_SET_REMOVE_TERRAIN, .power = 80, .type = TYPE_ICE, .accuracy = 100, @@ -13884,7 +13884,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .split = SPLIT_PHYSICAL, .zMovePower = 160, .zMoveEffect = Z_EFFECT_NONE, - .argument = 1, //remove terrain + .argument = 1, // Remove the active field terrain if there is one. }, [MOVE_GLAIVE_RUSH] = @@ -14839,7 +14839,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = }, [MOVE_GENESIS_SUPERNOVA] = { - .effect = EFFECT_DAMAGE_SET_TERRAIN, + .effect = EFFECT_HIT_SET_REMOVE_TERRAIN, .power = 185, .type = TYPE_PSYCHIC, .accuracy = 0, @@ -14850,7 +14850,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .flags = 0, .zMovePower = 0, .split = SPLIT_SPECIAL, - .argument = 0, //psychic terrain + .argument = 0, // Set Psychic Terrain. If there's a different field terrain active, overwrite it. .zMoveEffect = 0 }, [MOVE_SINISTER_ARROW_RAID] = @@ -14900,7 +14900,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = }, [MOVE_SPLINTERED_STORMSHARDS] = { - .effect = EFFECT_DAMAGE_SET_TERRAIN, + .effect = EFFECT_HIT_SET_REMOVE_TERRAIN, .power = 190, .type = TYPE_ROCK, .accuracy = 0, @@ -14911,7 +14911,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .flags = 0, .zMovePower = 0, .split = SPLIT_PHYSICAL, - .argument = 1, //remove terrain + .argument = 1, // Remove the active field terrain if there is one. .zMoveEffect = 0 }, [MOVE_LETS_SNUGGLE_FOREVER] = From ca32d43433b027342157aed02d576b675c34d941 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Mon, 2 Jan 2023 14:30:16 -0300 Subject: [PATCH 36/36] Streamlined ability-on-weather changes Also renamed activateweatherabilities and activateterrainabilities. --- asm/macros/battle_script.inc | 8 +++--- data/battle_scripts_1.s | 23 ++--------------- include/constants/battle_script_commands.h | 4 +-- src/battle_script_commands.c | 4 +-- src/battle_util.c | 30 +++++++++++----------- 5 files changed, 25 insertions(+), 44 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index a882a0315..69e45ddea 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -2010,12 +2010,12 @@ .4byte \ptr .endm - .macro activateweatherabilities battler:req - various \battler, VARIOUS_ACTIVATE_WEATHER_ABILITIES + .macro activateweatherchangeabilities battler:req + various \battler, VARIOUS_ACTIVATE_WEATHER_CHANGE_ABILITIES .endm - .macro activateterrainabilities battler:req - various \battler, VARIOUS_ACTIVATE_TERRAIN_ABILITIES + .macro activateterrainchangeabilities battler:req + various \battler, VARIOUS_ACTIVATE_TERRAIN_CHANGE_ABILITIES .endm @ helpful macros diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 722619c3b..9d307b8b9 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -4976,20 +4976,8 @@ BattleScript_MoveWeatherChange:: printfromtable gMoveWeatherChangeStringIds waitmessage B_WAIT_TIME_LONG call BattleScript_WeatherFormChanges - call BattleScript_ActivateWeatherAbilities goto BattleScript_MoveEnd -BattleScript_ActivateWeatherAbilities: - copybyte sBATTLER, gBattlerAttacker - setbyte gBattlerAttacker, 0 -BattleScript_ActivateWeatherAbilities_Loop: - activateweatherabilities BS_ATTACKER -BattleScript_ActivateWeatherAbilities_Increment: - addbyte gBattlerAttacker, 1 - jumpifbytenotequal gBattlerAttacker, gBattlersCount, BattleScript_ActivateWeatherAbilities_Loop - copybyte gBattlerAttacker, sBATTLER - return - BattleScript_EffectSunnyDay:: attackcanceler attackstring @@ -8180,7 +8168,6 @@ BattleScript_DrizzleActivates:: waitstate playanimation BS_BATTLER_0, B_ANIM_RAIN_CONTINUES call BattleScript_WeatherFormChanges - call BattleScript_ActivateWeatherAbilities end3 BattleScript_AbilityRaisesDefenderStat:: @@ -8341,7 +8328,6 @@ BattleScript_SandstreamActivates:: waitstate playanimation BS_BATTLER_0, B_ANIM_SANDSTORM_CONTINUES call BattleScript_WeatherFormChanges - call BattleScript_ActivateWeatherAbilities end3 BattleScript_SandSpitActivates:: @@ -8351,7 +8337,6 @@ BattleScript_SandSpitActivates:: waitstate playanimation BS_BATTLER_0, B_ANIM_SANDSTORM_CONTINUES call BattleScript_WeatherFormChanges - call BattleScript_ActivateWeatherAbilities return BattleScript_ShedSkinActivates:: @@ -8365,6 +8350,7 @@ BattleScript_WeatherFormChanges:: setbyte sBATTLER, 0 BattleScript_WeatherFormChangesLoop:: tryweatherformdatachange + activateweatherchangeabilities BS_SCRIPTING addbyte sBATTLER, 1 jumpifbytenotequal sBATTLER, gBattlersCount, BattleScript_WeatherFormChangesLoop return @@ -8470,7 +8456,6 @@ BattleScript_DroughtActivates:: waitstate playanimation BS_BATTLER_0, B_ANIM_SUN_CONTINUES call BattleScript_WeatherFormChanges - call BattleScript_ActivateWeatherAbilities end3 BattleScript_DesolateLandActivates:: @@ -8480,7 +8465,6 @@ BattleScript_DesolateLandActivates:: waitstate playanimation BS_BATTLER_0, B_ANIM_SUN_CONTINUES call BattleScript_WeatherFormChanges - call BattleScript_ActivateWeatherAbilities end3 BattleScript_DesolateLandEvaporatesWaterTypeMoves:: @@ -8501,7 +8485,6 @@ BattleScript_PrimordialSeaActivates:: waitstate playanimation BS_BATTLER_0, B_ANIM_RAIN_CONTINUES call BattleScript_WeatherFormChanges - call BattleScript_ActivateWeatherAbilities end3 BattleScript_PrimordialSeaFizzlesOutFireTypeMoves:: @@ -8572,7 +8555,6 @@ BattleScript_SnowWarningActivates:: waitstate playanimation BS_BATTLER_0, B_ANIM_HAIL_CONTINUES call BattleScript_WeatherFormChanges - call BattleScript_ActivateWeatherAbilities end3 BattleScript_TerrainSeedLoop: @@ -8603,7 +8585,7 @@ BattleScript_ActivateTerrainAbilities: copybyte sBATTLER, gBattlerAttacker setbyte gBattlerAttacker, 0 BattleScript_ActivateTerrainAbilities_Loop: - activateterrainabilities BS_ATTACKER + activateterrainchangeabilities BS_ATTACKER BattleScript_ActivateTerrainAbilities_Increment: addbyte gBattlerAttacker, 1 jumpifbytenotequal gBattlerAttacker, gBattlersCount, BattleScript_ActivateTerrainAbilities_Loop @@ -9756,7 +9738,6 @@ BattleScript_AnnounceAirLockCloudNine:: printstring STRINGID_AIRLOCKACTIVATES waitmessage B_WAIT_TIME_LONG call BattleScript_WeatherFormChanges - call BattleScript_ActivateWeatherAbilities end3 BattleScript_QuickClawActivation:: diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 74d7a0be2..61f69587c 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -248,8 +248,8 @@ #define VARIOUS_CHECK_PARENTAL_BOND_COUNTER 157 #define VARIOUS_SWAP_STATS 158 #define VARIOUS_TRY_WIND_RIDER_POWER 159 -#define VARIOUS_ACTIVATE_WEATHER_ABILITIES 160 -#define VARIOUS_ACTIVATE_TERRAIN_ABILITIES 161 +#define VARIOUS_ACTIVATE_WEATHER_CHANGE_ABILITIES 160 +#define VARIOUS_ACTIVATE_TERRAIN_CHANGE_ABILITIES 161 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index e08a61c2f..a979400ab 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -10116,11 +10116,11 @@ static void Cmd_various(void) } } return; - case VARIOUS_ACTIVATE_WEATHER_ABILITIES: + case VARIOUS_ACTIVATE_WEATHER_CHANGE_ABILITIES: gBattlescriptCurrInstr += 3; AbilityBattleEffects(ABILITYEFFECT_ON_WEATHER, gActiveBattler, 0, 0, 0); return; - case VARIOUS_ACTIVATE_TERRAIN_ABILITIES: + case VARIOUS_ACTIVATE_TERRAIN_CHANGE_ABILITIES: gBattlescriptCurrInstr += 3; AbilityBattleEffects(ABILITYEFFECT_ON_TERRAIN, gActiveBattler, 0, 0, 0); return; diff --git a/src/battle_util.c b/src/battle_util.c index c31ee5069..4eb44daa7 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4798,19 +4798,6 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; - case ABILITY_FORECAST: -#if B_WEATHER_FORMS >= GEN_5 - case ABILITY_FLOWER_GIFT: -#else - TRY_WEATHER_FORM: -#endif - effect = TryWeatherFormChange(battler); - if (effect != 0) - { - BattleScriptPushCursorAndCallback(BattleScript_WeatherFormChange); - *(&gBattleStruct->formToChangeInto) = effect - 1; - } - break; case ABILITY_TRACE: if (!(gSpecialStatuses[battler].traced)) { @@ -6252,9 +6239,22 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move } break; case ABILITYEFFECT_ON_WEATHER: // For ability effects that activate when the battle weather changes. - gBattleScripting.battler = gBattlerAbility = battler; + battler = gBattlerAbility = gBattlerAttacker = gBattleScripting.battler; switch (GetBattlerAbility(battler)) { + case ABILITY_FORECAST: +#if B_WEATHER_FORMS >= GEN_5 + case ABILITY_FLOWER_GIFT: +#else + TRY_WEATHER_FORM: +#endif + effect = TryWeatherFormChange(battler); + if (effect != 0) + { + BattleScriptPushCursorAndCallback(BattleScript_WeatherFormChange); + *(&gBattleStruct->formToChangeInto) = effect - 1; + } + break; case ABILITY_PROTOSYNTHESIS: if (IsBattlerWeatherAffected(battler, B_WEATHER_SUN)) { @@ -6266,7 +6266,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move } break; case ABILITYEFFECT_ON_TERRAIN: // For ability effects that activate when the field terrain changes. - gBattleScripting.battler = gBattlerAbility = battler; + battler = gBattlerAbility = gBattlerAttacker = gBattleScripting.battler; switch (GetBattlerAbility(battler)) { case ABILITY_QUARK_DRIVE: