From c2f718d3d35255552fdbe42f237a909a78a821cb Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 12 Jan 2021 14:58:24 -0300 Subject: [PATCH 01/35] Implemented Cramorant's Gulp Missile form change --- data/battle_anim_scripts.s | 17 +++++++++++ data/battle_scripts_1.s | 36 +++++++++++++++++++++++ include/battle_scripts.h | 2 ++ include/constants/battle_anim.h | 1 + include/constants/battle_config.h | 3 ++ src/battle_interface.c | 1 + src/battle_util.c | 47 +++++++++++++++++++++++++++++++ 7 files changed, 107 insertions(+) diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s index 4bfef447b..c3ab5b150 100644 --- a/data/battle_anim_scripts.s +++ b/data/battle_anim_scripts.s @@ -826,6 +826,7 @@ gBattleAnims_General:: .4byte General_SlideOffScreen .4byte General_RestoreBg .4byte General_TotemFlare + .4byte General_GulpMissile .align 2 gBattleAnims_Special:: @@ -24420,6 +24421,22 @@ General_TotemFlare:: clearmonbg ANIM_ATTACKER end +General_GulpMissile: @ Modified Tackle anim (placeholder) + loadspritegfx ANIM_TAG_IMPACT + monbg ANIM_ATTACKER + setalpha 12, 8 + createsprite gHorizontalLungeSpriteTemplate, ANIM_TARGET, 2, 4, 4 + delay 6 + createsprite gBasicHitSplatSpriteTemplate, ANIM_TARGET, 2, 0, 0, ANIM_ATTACKER, 2 + createvisualtask AnimTask_ShakeMon, 2, ANIM_ATTACKER, 3, 0, 6, 1 + playsewithpan SE_M_COMET_PUNCH, SOUND_PAN_ATTACKER + waitforvisualfinish + delay 10 + playse SE_EFFECTIVE + clearmonbg ANIM_ATTACKER + blendoff + end + RainbowEndureEffect: launchtemplate gBlueEndureEnergySpriteTemplate 0x2 0x4 0x0 0xffe8 0x1a 0x2 delay 0x3 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index f4b2ab7a7..76eda8472 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -5761,6 +5761,42 @@ BattleScript_PerishBodyActivates:: orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 return +BattleScript_GulpMissileGorging:: + call BattleScript_AbilityPopUp + playanimation BS_ATTACKER, B_ANIM_GULP_MISSILE, NULL + waitanimation + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 + healthbarupdate BS_ATTACKER + datahpupdate BS_ATTACKER + tryfaintmon BS_ATTACKER, FALSE, NULL + handleformchange BS_TARGET, 0 + playanimation BS_TARGET, B_ANIM_FORM_CHANGE, NULL + waitanimation + swapattackerwithtarget + setmoveeffect MOVE_EFFECT_PARALYSIS + seteffectprimary + swapattackerwithtarget + return + +BattleScript_GulpMissileGulping:: + call BattleScript_AbilityPopUp + playanimation BS_ATTACKER, B_ANIM_GULP_MISSILE, NULL + waitanimation + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 + healthbarupdate BS_ATTACKER + datahpupdate BS_ATTACKER + tryfaintmon BS_ATTACKER, FALSE, NULL + handleformchange BS_TARGET, 0 + playanimation BS_TARGET, B_ANIM_FORM_CHANGE, NULL + waitanimation + statbuffchange STAT_BUFF_NOT_PROTECT_AFFECTED | MOVE_EFFECT_CERTAIN, NULL + setgraphicalstatchangevalues + playanimation BS_ATTACKER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 + waitanimation + printstring STRINGID_PKMNSSTATCHANGED + waitmessage 0x40 + return + BattleScript_PerishSongCountGoesDown:: printstring STRINGID_PKMNPERISHCOUNTFELL waitmessage 0x40 diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 009590f3a..bf8700a25 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -357,5 +357,7 @@ extern const u8 BattleScript_CottonDownActivates[]; extern const u8 BattleScript_BallFetch[]; extern const u8 BattleScript_SandSpitActivates[]; extern const u8 BattleScript_PerishBodyActivates[]; +extern const u8 BattleScript_GulpMissileGorging[]; +extern const u8 BattleScript_GulpMissileGulping[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/constants/battle_anim.h b/include/constants/battle_anim.h index 90766f9d5..525366df8 100644 --- a/include/constants/battle_anim.h +++ b/include/constants/battle_anim.h @@ -527,6 +527,7 @@ #define B_ANIM_SLIDE_OFFSCREEN 0x1E // for Emergency Exit #define B_ANIM_RESTORE_BG 0x1F // for Terrain Endings #define B_ANIM_TOTEM_FLARE 0x20 // Totem boosts aura flare +#define B_ANIM_GULP_MISSILE 0x21 // special animations table #define B_ANIM_LVL_UP 0x0 diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 6c34197ca..69a142f23 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -35,6 +35,9 @@ #define SPECIES_ZYGARDE 0 // 50% #define SPECIES_ZYGARDE_10 10011 // 10 % #define SPECIES_ZYGARDE_COMPLETE 10012 // 100 % + #define SPECIES_CRAMORANT 0 + #define SPECIES_CRAMORANT_GORGING 10013 + #define SPECIES_CRAMORANT_GULPING 10014 #endif // Items with peculiar battle effects. diff --git a/src/battle_interface.c b/src/battle_interface.c index 267b06ece..0f17a79ed 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -969,6 +969,7 @@ static void TryToggleHealboxVisibility(u8 priority, u8 healthboxLeftSpriteId, u8 case B_ANIM_TERRAIN_GRASSY: case B_ANIM_TERRAIN_ELECTRIC: case B_ANIM_TERRAIN_PSYCHIC: + case B_ANIM_GULP_MISSILE: break; } return; //all other special anims dont hide diff --git a/src/battle_util.c b/src/battle_util.c index 210f00b27..ba3874f51 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -3488,6 +3488,8 @@ static bool32 ShouldChangeFormHpBased(u32 battler) {ABILITY_SHIELDS_DOWN, SPECIES_MINIOR_METEOR_VIOLET, SPECIES_MINIOR_CORE_VIOLET, 2}, {ABILITY_SHIELDS_DOWN, SPECIES_MINIOR_METEOR_YELLOW, SPECIES_MINIOR_CORE_YELLOW, 2}, {ABILITY_SCHOOLING, SPECIES_WISHIWASHI_SCHOOL, SPECIES_WISHIWASHI, 4}, + {ABILITY_GULP_MISSILE, SPECIES_CRAMORANT, SPECIES_CRAMORANT_GORGING, 2}, + {ABILITY_GULP_MISSILE, SPECIES_CRAMORANT, SPECIES_CRAMORANT_GULPING, 1}, }; u32 i; @@ -4689,6 +4691,39 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; + case ABILITY_GULP_MISSILE: + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && !gProtectStructs[gBattlerAttacker].confusionSelfDmg + && TARGET_TURN_DAMAGED + && IsBattlerAlive(battler) + && gBattleMons[battler].species == SPECIES_CRAMORANT_GORGING) + { + gBattleStruct->changedSpecies[gBattlerPartyIndexes[battler]] = gBattleMons[battler].species; + gBattleMons[battler].species = SPECIES_CRAMORANT; + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 4; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_GulpMissileGorging; + effect++; + } + else if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && !gProtectStructs[gBattlerAttacker].confusionSelfDmg + && TARGET_TURN_DAMAGED + && IsBattlerAlive(battler) + && gBattleMons[battler].species == SPECIES_CRAMORANT_GULPING) + { + gBattleStruct->changedSpecies[gBattlerPartyIndexes[battler]] = gBattleMons[battler].species; + gBattleMons[battler].species = SPECIES_CRAMORANT; + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 4; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + SET_STATCHANGER(STAT_DEF, 1, TRUE); + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_GulpMissileGulping; + effect++; + } + break; } break; case ABILITYEFFECT_MOVE_END_ATTACKER: // Same as above, but for attacker @@ -4714,6 +4749,16 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; + case ABILITY_GULP_MISSILE: + if ((effect = ShouldChangeFormHpBased(battler)) + && (gCurrentMove == MOVE_SURF + || gStatuses3[battler] & STATUS3_UNDERWATER)) + { + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_AttackerFormChange; + effect++; + } + break; } break; case ABILITYEFFECT_MOVE_END_OTHER: // Abilities that activate on *another* battler's moveend: Dancer, Soul-Heart, Receiver, Symbiosis @@ -7798,6 +7843,8 @@ void UndoFormChange(u32 monId, u32 side) {SPECIES_MINIOR_METEOR_VIOLET, SPECIES_MINIOR_CORE_VIOLET}, {SPECIES_MINIOR_METEOR_YELLOW, SPECIES_MINIOR_CORE_YELLOW}, {SPECIES_WISHIWASHI_SCHOOL, SPECIES_WISHIWASHI}, + {SPECIES_CRAMORANT_GORGING, SPECIES_CRAMORANT}, + {SPECIES_CRAMORANT_GULPING, SPECIES_CRAMORANT}, }; currSpecies = GetMonData(&party[monId], MON_DATA_SPECIES, NULL); From 1f3983cb05fc91945004c5dd75507def95e01c05 Mon Sep 17 00:00:00 2001 From: BuffelSaft Date: Sat, 7 Aug 2021 20:38:35 +1200 Subject: [PATCH 02/35] Shields Down protects all meteor form Minior This was only working with red core minior. --- src/battle_script_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index de7105a27..104c528b8 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -7138,7 +7138,7 @@ u32 IsLeafGuardProtected(u32 battler) bool32 IsShieldsDownProtected(u32 battler) { return (gBattleMons[battler].ability == ABILITY_SHIELDS_DOWN - && gBattleMons[battler].species == SPECIES_MINIOR); + && GetFormIdFromFormSpeciesId(gBattleMons[battler].species) < 6); // Minior is not in core form } u32 IsAbilityStatusProtected(u32 battler) From 872d2a700858081148dfab5e92a02cbef36f87fd Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sat, 25 Sep 2021 22:30:45 -0300 Subject: [PATCH 03/35] Made this build again --- data/battle_scripts_1.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index e875e01e7..cf3204727 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -6032,7 +6032,7 @@ BattleScript_GulpMissileGulping:: setgraphicalstatchangevalues playanimation BS_ATTACKER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 waitanimation - printstring STRINGID_PKMNSSTATCHANGED + printstring STRINGID_ATTACKERSSTATROSE waitmessage 0x40 return From a49ea33dd063618a6d6375ef945ed5019e63704c Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 26 Sep 2021 19:59:56 -0300 Subject: [PATCH 04/35] A lot of fixes -Fixed Gulp Missile's activation. Its effects were happening even if the conditions weren't actually met in battle. -Fixed Gulp Missile activating if the only/last target has already fainted. -Fixed Gulp Missile's Gorging animation, though it still uses Tackle's. -Fixed Gulp Missile's Gorging attack affecting an opponent with Magic Guard. -Fixed Gulp Missile changing Cramorant's form if Surf failed. --- data/battle_anim_scripts.s | 10 ++++----- data/battle_scripts_1.s | 10 +++++++++ src/battle_util.c | 43 +++++++++++++++++++++++--------------- 3 files changed, 40 insertions(+), 23 deletions(-) diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s index 71dcf8b2b..d7de92096 100644 --- a/data/battle_anim_scripts.s +++ b/data/battle_anim_scripts.s @@ -24398,18 +24398,16 @@ General_TotemFlare:: clearmonbg ANIM_ATTACKER end -General_GulpMissile: @ Modified Tackle anim (placeholder) +General_GulpMissile: @ Tackle anim (placeholder) loadspritegfx ANIM_TAG_IMPACT monbg ANIM_ATTACKER setalpha 12, 8 - createsprite gHorizontalLungeSpriteTemplate, ANIM_TARGET, 2, 4, 4 + createsprite gHorizontalLungeSpriteTemplate, ANIM_ATTACKER, 2, 4, 4 delay 6 - createsprite gBasicHitSplatSpriteTemplate, ANIM_TARGET, 2, 0, 0, ANIM_ATTACKER, 2 + createsprite gBasicHitSplatSpriteTemplate, ANIM_ATTACKER, 2, 0, 0, ANIM_ATTACKER, 2 createvisualtask AnimTask_ShakeMon, 2, ANIM_ATTACKER, 3, 0, 6, 1 - playsewithpan SE_M_COMET_PUNCH, SOUND_PAN_ATTACKER + playsewithpan SE_M_COMET_PUNCH, SOUND_PAN_TARGET waitforvisualfinish - delay 10 - playse SE_EFFECTIVE clearmonbg ANIM_ATTACKER blendoff end diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index cf3204727..381c67a30 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -6005,9 +6005,14 @@ BattleScript_GulpMissileGorging:: playanimation BS_ATTACKER, B_ANIM_GULP_MISSILE, NULL waitanimation orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 + effectivenesssound + hitanimation BS_ATTACKER + waitstate + jumpifability BS_ATTACKER, ABILITY_MAGIC_GUARD, BattleScript_GulpMissileNoDmgGorging healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER tryfaintmon BS_ATTACKER, FALSE, NULL +BattleScript_GulpMissileNoDmgGorging: handleformchange BS_TARGET, 0 playanimation BS_TARGET, B_ANIM_FORM_CHANGE, NULL waitanimation @@ -6022,9 +6027,14 @@ BattleScript_GulpMissileGulping:: playanimation BS_ATTACKER, B_ANIM_GULP_MISSILE, NULL waitanimation orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 + effectivenesssound + hitanimation BS_ATTACKER + waitstate + jumpifability BS_ATTACKER, ABILITY_MAGIC_GUARD, BattleScript_GulpMissileNoDmgGulping healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER tryfaintmon BS_ATTACKER, FALSE, NULL +BattleScript_GulpMissileNoDmgGulping: handleformchange BS_TARGET, 0 playanimation BS_TARGET, B_ANIM_FORM_CHANGE, NULL waitanimation diff --git a/src/battle_util.c b/src/battle_util.c index ac4257fe7..436ac4d1a 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4985,17 +4985,22 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move } break; case ABILITY_GULP_MISSILE: + gBattlerAttacker = battler; + gBattlerTarget = BATTLE_OPPOSITE(battler); if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && !gProtectStructs[gBattlerAttacker].confusionSelfDmg && TARGET_TURN_DAMAGED - && IsBattlerAlive(battler) - && gBattleMons[battler].species == SPECIES_CRAMORANT_GORGING) + && IsBattlerAlive(gBattlerAttacker) + && gBattleMons[gBattlerTarget].species == SPECIES_CRAMORANT_GORGING) { - gBattleStruct->changedSpecies[gBattlerPartyIndexes[battler]] = gBattleMons[battler].species; - gBattleMons[battler].species = SPECIES_CRAMORANT; - gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 4; - if (gBattleMoveDamage == 0) - gBattleMoveDamage = 1; + gBattleStruct->changedSpecies[gBattlerPartyIndexes[gBattlerTarget]] = gBattleMons[gBattlerTarget].species; + gBattleMons[gBattlerTarget].species = SPECIES_CRAMORANT; + if (GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD) + { + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 4; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + } BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_GulpMissileGorging; effect++; @@ -5003,14 +5008,17 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move else if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && !gProtectStructs[gBattlerAttacker].confusionSelfDmg && TARGET_TURN_DAMAGED - && IsBattlerAlive(battler) - && gBattleMons[battler].species == SPECIES_CRAMORANT_GULPING) + && IsBattlerAlive(gBattlerAttacker) + && gBattleMons[gBattlerTarget].species == SPECIES_CRAMORANT_GULPING) { - gBattleStruct->changedSpecies[gBattlerPartyIndexes[battler]] = gBattleMons[battler].species; - gBattleMons[battler].species = SPECIES_CRAMORANT; - gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 4; - if (gBattleMoveDamage == 0) - gBattleMoveDamage = 1; + gBattleStruct->changedSpecies[gBattlerPartyIndexes[gBattlerTarget]] = gBattleMons[gBattlerTarget].species; + gBattleMons[gBattlerTarget].species = SPECIES_CRAMORANT; + if (GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD) + { + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 4; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + } SET_STATCHANGER(STAT_DEF, 1, TRUE); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_GulpMissileGulping; @@ -5054,9 +5062,10 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move } break; case ABILITY_GULP_MISSILE: - if ((effect = ShouldChangeFormHpBased(battler)) - && (gCurrentMove == MOVE_SURF - || gStatuses3[battler] & STATUS3_UNDERWATER)) + if ((effect = ShouldChangeFormHpBased(gBattlerAttacker)) + && (gCurrentMove == MOVE_SURF || gStatuses3[gBattlerAttacker] & STATUS3_UNDERWATER) + && TARGET_TURN_DAMAGED + && IsBattlerAlive(gBattlerAttacker)) { BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_AttackerFormChange; From ceffaa4e7635c82713d96676263eb3c22a4f0887 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Mon, 27 Sep 2021 19:53:42 -0300 Subject: [PATCH 05/35] Another condition fix I accidentally broke Gulp Missile's interaction with the user's Dive, lol. --- src/battle_util.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index 436ac4d1a..556d98e46 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5063,9 +5063,8 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move break; case ABILITY_GULP_MISSILE: if ((effect = ShouldChangeFormHpBased(gBattlerAttacker)) - && (gCurrentMove == MOVE_SURF || gStatuses3[gBattlerAttacker] & STATUS3_UNDERWATER) - && TARGET_TURN_DAMAGED - && IsBattlerAlive(gBattlerAttacker)) + && ((gCurrentMove == MOVE_SURF && TARGET_TURN_DAMAGED) || gStatuses3[gBattlerAttacker] & STATUS3_UNDERWATER) + && IsBattlerAlive(gBattlerTarget)) { BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_AttackerFormChange; From e783cde3873916206b89297b51a72033f22d438f Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Mon, 27 Sep 2021 21:31:42 -0300 Subject: [PATCH 06/35] Another small condition fix and small optimization -Checking for IsBattlerAlive is incorrect because Gulp Missile's counterattack should happen even if Cramorant faints. -Made the code a bit more readable. --- src/battle_util.c | 57 +++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index 556d98e46..6b65c72c6 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4985,44 +4985,39 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move } break; case ABILITY_GULP_MISSILE: - gBattlerAttacker = battler; - gBattlerTarget = BATTLE_OPPOSITE(battler); if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && !gProtectStructs[gBattlerAttacker].confusionSelfDmg - && TARGET_TURN_DAMAGED - && IsBattlerAlive(gBattlerAttacker) - && gBattleMons[gBattlerTarget].species == SPECIES_CRAMORANT_GORGING) + && TARGET_TURN_DAMAGED) { - gBattleStruct->changedSpecies[gBattlerPartyIndexes[gBattlerTarget]] = gBattleMons[gBattlerTarget].species; - gBattleMons[gBattlerTarget].species = SPECIES_CRAMORANT; - if (GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD) + if (gBattleMons[gBattlerTarget].species == SPECIES_CRAMORANT_GORGING) { - gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 4; - if (gBattleMoveDamage == 0) - gBattleMoveDamage = 1; + gBattleStruct->changedSpecies[gBattlerPartyIndexes[gBattlerTarget]] = gBattleMons[gBattlerTarget].species; + gBattleMons[gBattlerTarget].species = SPECIES_CRAMORANT; + if (GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD) + { + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 4; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + } + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_GulpMissileGorging; + effect++; } - BattleScriptPushCursor(); - gBattlescriptCurrInstr = BattleScript_GulpMissileGorging; - effect++; - } - else if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && !gProtectStructs[gBattlerAttacker].confusionSelfDmg - && TARGET_TURN_DAMAGED - && IsBattlerAlive(gBattlerAttacker) - && gBattleMons[gBattlerTarget].species == SPECIES_CRAMORANT_GULPING) - { - gBattleStruct->changedSpecies[gBattlerPartyIndexes[gBattlerTarget]] = gBattleMons[gBattlerTarget].species; - gBattleMons[gBattlerTarget].species = SPECIES_CRAMORANT; - if (GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD) + else if (gBattleMons[gBattlerTarget].species == SPECIES_CRAMORANT_GULPING) { - gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 4; - if (gBattleMoveDamage == 0) - gBattleMoveDamage = 1; + gBattleStruct->changedSpecies[gBattlerPartyIndexes[gBattlerTarget]] = gBattleMons[gBattlerTarget].species; + gBattleMons[gBattlerTarget].species = SPECIES_CRAMORANT; + if (GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD) + { + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 4; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + } + SET_STATCHANGER(STAT_DEF, 1, TRUE); + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_GulpMissileGulping; + effect++; } - SET_STATCHANGER(STAT_DEF, 1, TRUE); - BattleScriptPushCursor(); - gBattlescriptCurrInstr = BattleScript_GulpMissileGulping; - effect++; } break; } From 0389dbf9f239025b27f9250f113c9acfa742dc0a Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 29 Sep 2021 06:13:56 -0300 Subject: [PATCH 07/35] More fixes -Removed IsBattlerAlive check for case ABILITY_GULP_MISSILE in ABILITYEFFECT_MOVE_END_ATTACKER. Turns out Cramorant can change form even on single wild battles. -Added a check for IsBattlerAlive in the case ABILITY_GULP_MISSILE of ABILITYEFFECT_MOVE_END, because otherwise, for whatever reason, the user was trying to trigger the Gulping effect even in its base form. -Set the stat to change for the Gulping effect from within the battle script. The rest of the effect is handled there, so may as well. -Fixed the check for case ABILITY_GULP_MISSILE in ABILITYEFFECT_MOVE_END_ATTACKER. Apparently, a silent species change was happening because of the order of the checks. Thanks to AsparagusEduardo for pointing this one out. -Fixed the secondary effect of a target's Gulp Missile affecting an attacker that has fainted. -Fixed the Defense reduction of the Gulping effect bypassing Clear Body. --- data/battle_scripts_1.s | 15 +++++++++++++++ src/battle_util.c | 9 ++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 381c67a30..0743d21c1 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -6012,6 +6012,7 @@ BattleScript_GulpMissileGorging:: healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER tryfaintmon BS_ATTACKER, FALSE, NULL + jumpifbyteequal gBattlerFainted, gBattlerAttacker, BattleScript_GulpMissileNoSecondEffectGorging BattleScript_GulpMissileNoDmgGorging: handleformchange BS_TARGET, 0 playanimation BS_TARGET, B_ANIM_FORM_CHANGE, NULL @@ -6021,6 +6022,11 @@ BattleScript_GulpMissileNoDmgGorging: seteffectprimary swapattackerwithtarget return +BattleScript_GulpMissileNoSecondEffectGorging: + handleformchange BS_TARGET, 0 + playanimation BS_TARGET, B_ANIM_FORM_CHANGE, NULL + waitanimation + return BattleScript_GulpMissileGulping:: call BattleScript_AbilityPopUp @@ -6034,10 +6040,13 @@ BattleScript_GulpMissileGulping:: healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER tryfaintmon BS_ATTACKER, FALSE, NULL + jumpifbyteequal gBattlerFainted, gBattlerAttacker, BattleScript_GulpMissileNoSecondEffectGulping + jumpifability BS_ATTACKER, ABILITY_CLEAR_BODY, BattleScript_GulpMissileGulpingRet BattleScript_GulpMissileNoDmgGulping: handleformchange BS_TARGET, 0 playanimation BS_TARGET, B_ANIM_FORM_CHANGE, NULL waitanimation + setstatchanger STAT_DEF, 1, TRUE statbuffchange STAT_BUFF_NOT_PROTECT_AFFECTED | MOVE_EFFECT_CERTAIN, NULL setgraphicalstatchangevalues playanimation BS_ATTACKER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 @@ -6045,6 +6054,12 @@ BattleScript_GulpMissileNoDmgGulping: printstring STRINGID_ATTACKERSSTATROSE waitmessage 0x40 return +BattleScript_GulpMissileNoSecondEffectGulping: + handleformchange BS_TARGET, 0 + playanimation BS_TARGET, B_ANIM_FORM_CHANGE, NULL + waitanimation +BattleScript_GulpMissileGulpingRet: + return BattleScript_PerishSongCountGoesDown:: printstring STRINGID_PKMNPERISHCOUNTFELL diff --git a/src/battle_util.c b/src/battle_util.c index 6b65c72c6..20e5d91d1 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4987,7 +4987,8 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move case ABILITY_GULP_MISSILE: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && !gProtectStructs[gBattlerAttacker].confusionSelfDmg - && TARGET_TURN_DAMAGED) + && TARGET_TURN_DAMAGED + && IsBattlerAlive(battler)) { if (gBattleMons[gBattlerTarget].species == SPECIES_CRAMORANT_GORGING) { @@ -5013,7 +5014,6 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; } - SET_STATCHANGER(STAT_DEF, 1, TRUE); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_GulpMissileGulping; effect++; @@ -5057,9 +5057,8 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move } break; case ABILITY_GULP_MISSILE: - if ((effect = ShouldChangeFormHpBased(gBattlerAttacker)) - && ((gCurrentMove == MOVE_SURF && TARGET_TURN_DAMAGED) || gStatuses3[gBattlerAttacker] & STATUS3_UNDERWATER) - && IsBattlerAlive(gBattlerTarget)) + if (((gCurrentMove == MOVE_SURF && TARGET_TURN_DAMAGED) || gStatuses3[gBattlerAttacker] & STATUS3_UNDERWATER) + && (effect = ShouldChangeFormHpBased(gBattlerAttacker))) { BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_AttackerFormChange; From d7e651696b86dd02965b922709d1e34539a05460 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Thu, 30 Sep 2021 10:30:46 -0300 Subject: [PATCH 08/35] Even more fixes -Changed the way in which Gulp Missile checks for a fainted opponent, just in case the reason why the attacker's defense wasn't being lowered is that the script was falling into BattleScript_GulpMissileNoSecondEffectGulping -Took into account max Defense stat stage, because I forgot to do that too. -Slightly changed the Defense reduction code, just in case. -Fixed the text string that was printed. Gulp Missile doesn't raise a stat, after all. -Fixed the script that was being called if the attacker has Clear Body, and also added jumps for Full Metal Body, White Smoke and Flower Veil. --- data/battle_scripts_1.s | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 0743d21c1..3c9397f98 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -6012,7 +6012,8 @@ BattleScript_GulpMissileGorging:: healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER tryfaintmon BS_ATTACKER, FALSE, NULL - jumpifbyteequal gBattlerFainted, gBattlerAttacker, BattleScript_GulpMissileNoSecondEffectGorging + getbattlerfainted BS_ATTACKER + jumpifbyte CMP_EQUAL, gBattleCommunication, TRUE, BattleScript_GulpMissileNoSecondEffectGorging BattleScript_GulpMissileNoDmgGorging: handleformchange BS_TARGET, 0 playanimation BS_TARGET, B_ANIM_FORM_CHANGE, NULL @@ -6040,25 +6041,30 @@ BattleScript_GulpMissileGulping:: healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER tryfaintmon BS_ATTACKER, FALSE, NULL - jumpifbyteequal gBattlerFainted, gBattlerAttacker, BattleScript_GulpMissileNoSecondEffectGulping - jumpifability BS_ATTACKER, ABILITY_CLEAR_BODY, BattleScript_GulpMissileGulpingRet + getbattlerfainted BS_ATTACKER + jumpifbyte CMP_EQUAL, gBattleCommunication, TRUE, BattleScript_GulpMissileNoSecondEffectGulping + jumpifability BS_ATTACKER, ABILITY_CLEAR_BODY, BattleScript_GulpMissileNoSecondEffectGulping + jumpifability BS_ATTACKER, ABILITY_FULL_METAL_BODY, BattleScript_GulpMissileNoSecondEffectGulping + jumpifability BS_ATTACKER, ABILITY_WHITE_SMOKE, BattleScript_GulpMissileNoSecondEffectGulping + jumpifability BS_ATTACKER, ABILITY_FLOWER_VEIL, BattleScript_GulpMissileNoSecondEffectGulping BattleScript_GulpMissileNoDmgGulping: handleformchange BS_TARGET, 0 playanimation BS_TARGET, B_ANIM_FORM_CHANGE, NULL waitanimation + playstatchangeanimation BS_ATTACKER, BIT_DEF, STAT_CHANGE_CANT_PREVENT | STAT_CHANGE_NEGATIVE setstatchanger STAT_DEF, 1, TRUE - statbuffchange STAT_BUFF_NOT_PROTECT_AFFECTED | MOVE_EFFECT_CERTAIN, NULL - setgraphicalstatchangevalues - playanimation BS_ATTACKER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 - waitanimation - printstring STRINGID_ATTACKERSSTATROSE - waitmessage 0x40 + statbuffchange STAT_BUFF_NOT_PROTECT_AFFECTED, BattleScript_GulpMissileGorgingTargetDefenseCantGoLower + printstring STRINGID_ATTACKERSSTATFELL + waitmessage B_WAIT_TIME_LONG return BattleScript_GulpMissileNoSecondEffectGulping: handleformchange BS_TARGET, 0 playanimation BS_TARGET, B_ANIM_FORM_CHANGE, NULL waitanimation -BattleScript_GulpMissileGulpingRet: + return +BattleScript_GulpMissileGorgingTargetDefenseCantGoLower: + printstring STRINGID_STATSWONTDECREASE + waitmessage B_WAIT_TIME_LONG return BattleScript_PerishSongCountGoesDown:: From a506bf03c6a1b8af80e0ad34127e03db99c9bbde Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Fri, 1 Oct 2021 02:14:46 -0300 Subject: [PATCH 09/35] Corrected Flower Veil check --- asm/macros/battle_script.inc | 6 ++++++ data/battle_scripts_1.s | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 12cf20a9c..f39818f7b 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1925,6 +1925,12 @@ 1: .endm + .macro jumpifflowerveilattacker jumpptr:req + jumpifnottype BS_ATTACKER, TYPE_GRASS, 1f + jumpifability BS_ATTACKER_SIDE, ABILITY_FLOWER_VEIL, \jumpptr + 1: + .endm + .macro setallytonexttarget jumpptr:req jumpifbyte CMP_GREATER_THAN, gBattlerTarget, 0x1, 1f addbyte gBattlerTarget, 0x2 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 3c9397f98..6324588b2 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -6046,7 +6046,7 @@ BattleScript_GulpMissileGulping:: jumpifability BS_ATTACKER, ABILITY_CLEAR_BODY, BattleScript_GulpMissileNoSecondEffectGulping jumpifability BS_ATTACKER, ABILITY_FULL_METAL_BODY, BattleScript_GulpMissileNoSecondEffectGulping jumpifability BS_ATTACKER, ABILITY_WHITE_SMOKE, BattleScript_GulpMissileNoSecondEffectGulping - jumpifability BS_ATTACKER, ABILITY_FLOWER_VEIL, BattleScript_GulpMissileNoSecondEffectGulping + jumpifflowerveilattacker BattleScript_GulpMissileNoSecondEffectGulping BattleScript_GulpMissileNoDmgGulping: handleformchange BS_TARGET, 0 playanimation BS_TARGET, B_ANIM_FORM_CHANGE, NULL From 43e73ac576fa67769f8d86dbd7674b6aee15c466 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Fri, 1 Oct 2021 05:25:25 -0300 Subject: [PATCH 10/35] Fixed Safari Zone --- src/battle_main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/battle_main.c b/src/battle_main.c index 5c3f2ecd8..25db65f78 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3465,10 +3465,13 @@ static void TryDoEventsBeforeFirstTurn(void) return; // Set invalid mons as absent(for example when starting a double battle with only one pokemon). - for (i = 0; i < gBattlersCount; i++) + if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI)) { - if (gBattleMons[i].hp == 0 || gBattleMons[i].species == SPECIES_NONE) - gAbsentBattlerFlags |= gBitTable[i]; + for (i = 0; i < gBattlersCount; i++) + { + if (gBattleMons[i].hp == 0 || gBattleMons[i].species == SPECIES_NONE) + gAbsentBattlerFlags |= gBitTable[i]; + } } if (gBattleStruct->switchInAbilitiesCounter == 0) From f6917696474272a5a8fddd380ac4b26acbaf13ee Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Fri, 1 Oct 2021 06:29:21 -0300 Subject: [PATCH 11/35] Fixed Def stat reduction --- data/battle_scripts_1.s | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 6324588b2..f1f5995ff 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -6051,11 +6051,14 @@ BattleScript_GulpMissileNoDmgGulping: handleformchange BS_TARGET, 0 playanimation BS_TARGET, B_ANIM_FORM_CHANGE, NULL waitanimation - playstatchangeanimation BS_ATTACKER, BIT_DEF, STAT_CHANGE_CANT_PREVENT | STAT_CHANGE_NEGATIVE + swapattackerwithtarget @ to make gStatDownStringIds down below print the right battler setstatchanger STAT_DEF, 1, TRUE statbuffchange STAT_BUFF_NOT_PROTECT_AFFECTED, BattleScript_GulpMissileGorgingTargetDefenseCantGoLower - printstring STRINGID_ATTACKERSSTATFELL + setgraphicalstatchangevalues + playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 + printfromtable gStatDownStringIds waitmessage B_WAIT_TIME_LONG + swapattackerwithtarget @ restore the battlers, just in case return BattleScript_GulpMissileNoSecondEffectGulping: handleformchange BS_TARGET, 0 From f3ded43a88fb5561a0a52ce7d6ea98f5703a7f96 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Fri, 1 Oct 2021 22:32:48 -0300 Subject: [PATCH 12/35] Implemented Battle Bond --- data/battle_scripts_1.s | 13 +++++++++++++ include/battle_scripts.h | 1 + include/constants/battle_config.h | 2 ++ include/constants/battle_string_ids.h | 4 +++- src/battle_message.c | 5 ++++- src/battle_util.c | 20 ++++++++++++++++++++ 6 files changed, 43 insertions(+), 2 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index f1f5995ff..f6f3d63cb 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7711,6 +7711,19 @@ BattleScript_AbilityStatusEffect:: seteffectsecondary return +BattleScript_BattleBondActivatesOnMoveEndAttacker:: + pause 5 + copybyte gBattlerAbility, gBattlerAttacker + call BattleScript_AbilityPopUp + printstring STRINGID_ATTACKERBECAMEFULLYCHARGED + handleformchange BS_ATTACKER, 0 + handleformchange BS_ATTACKER, 1 + playanimation BS_ATTACKER, B_ANIM_FORM_CHANGE, NULL + waitanimation + handleformchange BS_ATTACKER, 2 + printstring STRINGID_ATTACKERBECAMEASHGRENINJA + return + BattleScript_DancerActivates:: call BattleScript_AbilityPopUp waitmessage B_WAIT_TIME_SHORT diff --git a/include/battle_scripts.h b/include/battle_scripts.h index fbae42e24..203be6519 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -388,5 +388,6 @@ extern const u8 BattleScript_ElectricTerrainPrevents[]; extern const u8 BattleScript_DarkTypePreventsPrankster[]; extern const u8 BattleScript_GulpMissileGorging[]; extern const u8 BattleScript_GulpMissileGulping[]; +extern const u8 BattleScript_BattleBondActivatesOnMoveEndAttacker[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 26007ff9f..93202bed7 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -43,6 +43,8 @@ #define SPECIES_CRAMORANT 0 #define SPECIES_CRAMORANT_GORGING 10015 #define SPECIES_CRAMORANT_GULPING 10016 + #define SPECIES_GRENINJA_BATTLE_BOND 0 + #define SPECIES_GRENINJA_ASH 10017 #endif // Items with peculiar battle effects. diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index e32fd5778..144081974 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -578,8 +578,10 @@ #define STRINGID_ATKGOTOVERINFATUATION 574 #define STRINGID_TORMENTEDNOMORE 575 #define STRINGID_HEALBLOCKEDNOMORE 576 +#define STRINGID_ATTACKERBECAMEFULLYCHARGED 577 +#define STRINGID_ATTACKERBECAMEASHGRENINJA 578 -#define BATTLESTRINGS_COUNT 577 +#define BATTLESTRINGS_COUNT 579 // The below IDs are all indexes into battle message tables, // used to determine which of a set of messages to print. diff --git a/src/battle_message.c b/src/battle_message.c index ab10ceff0..cc8920141 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -704,10 +704,13 @@ static const u8 sText_EjectButtonActivate[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} static const u8 sText_AttackerGotOverInfatuation[] =_("{B_ATK_NAME_WITH_PREFIX} got over\nits infatuation!"); static const u8 sText_TormentedNoMore[] = _("{B_ATK_NAME_WITH_PREFIX} is\ntormented no more!"); static const u8 sText_HealBlockedNoMore[] = _("{B_ATK_NAME_WITH_PREFIX} is cured of\nits heal block!"); - +static const u8 sText_AttackerBecameFullyCharged[] = _("{B_ATK_NAME_WITH_PREFIX} became fully charged\ndue to its bond with its trainer!\p"); +static const u8 sText_AttackerBecameAshGreninja[] = _("{B_ATK_NAME_WITH_PREFIX} became Ash-{B_ATK_NAME_WITH_PREFIX}!\p"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_ATTACKERBECAMEASHGRENINJA - 12] = sText_AttackerBecameAshGreninja, + [STRINGID_ATTACKERBECAMEFULLYCHARGED - 12] = sText_AttackerBecameFullyCharged, [STRINGID_HEALBLOCKEDNOMORE - 12] = sText_HealBlockedNoMore, [STRINGID_TORMENTEDNOMORE - 12] = sText_TormentedNoMore, [STRINGID_ATKGOTOVERINFATUATION - 12] = sText_AttackerGotOverInfatuation, diff --git a/src/battle_util.c b/src/battle_util.c index 20e5d91d1..8898da5d7 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5065,6 +5065,16 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; + case ABILITY_BATTLE_BOND: + if (gBattleMons[gBattlerAttacker].species == SPECIES_GRENINJA_BATTLE_BOND + && gBattleResults.opponentFaintCounter != 0) + { + gBattleStruct->changedSpecies[gBattlerPartyIndexes[gBattlerAttacker]] = gBattleMons[gBattlerAttacker].species; + gBattleMons[gBattlerAttacker].species = SPECIES_GRENINJA_ASH; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_BattleBondActivatesOnMoveEndAttacker; + } + break; } break; case ABILITYEFFECT_MOVE_END_OTHER: // Abilities that activate on *another* battler's moveend: Dancer, Soul-Heart, Receiver, Symbiosis @@ -7562,6 +7572,15 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef) break; } + // move-specific base power changes + switch (move) + { + case MOVE_WATER_SHURIKEN: + if (gBattleMons[battlerAtk].species == SPECIES_GRENINJA_ASH) + basePower = 20; + break; + } + if (basePower == 0) basePower = 1; return basePower; @@ -8726,6 +8745,7 @@ void UndoFormChange(u32 monId, u32 side, bool32 isSwitchingOut) {SPECIES_WISHIWASHI_SCHOOL, SPECIES_WISHIWASHI}, {SPECIES_CRAMORANT_GORGING, SPECIES_CRAMORANT}, {SPECIES_CRAMORANT_GULPING, SPECIES_CRAMORANT}, + {SPECIES_GRENINJA_ASH, SPECIES_GRENINJA_BATTLE_BOND}, }; if (isSwitchingOut) // Don't revert Mimikyu Busted when switching out From c464b1b5dd88936df6edb54061a44dee2d64449a Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Fri, 1 Oct 2021 23:12:07 -0300 Subject: [PATCH 13/35] STRINGID_ATTACKERBECAMEASHGRENINJA -> STRINGID_ATTACKERBECAMEASHSPECIES --- data/battle_scripts_1.s | 2 +- include/constants/battle_string_ids.h | 2 +- src/battle_message.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index f6f3d63cb..5a9aec525 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7721,7 +7721,7 @@ BattleScript_BattleBondActivatesOnMoveEndAttacker:: playanimation BS_ATTACKER, B_ANIM_FORM_CHANGE, NULL waitanimation handleformchange BS_ATTACKER, 2 - printstring STRINGID_ATTACKERBECAMEASHGRENINJA + printstring STRINGID_ATTACKERBECAMEASHSPECIES return BattleScript_DancerActivates:: diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index 144081974..ff5eb5366 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -579,7 +579,7 @@ #define STRINGID_TORMENTEDNOMORE 575 #define STRINGID_HEALBLOCKEDNOMORE 576 #define STRINGID_ATTACKERBECAMEFULLYCHARGED 577 -#define STRINGID_ATTACKERBECAMEASHGRENINJA 578 +#define STRINGID_ATTACKERBECAMEASHSPECIES 578 #define BATTLESTRINGS_COUNT 579 diff --git a/src/battle_message.c b/src/battle_message.c index cc8920141..b0ca25c95 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -705,11 +705,11 @@ static const u8 sText_AttackerGotOverInfatuation[] =_("{B_ATK_NAME_WITH_PREFIX} static const u8 sText_TormentedNoMore[] = _("{B_ATK_NAME_WITH_PREFIX} is\ntormented no more!"); static const u8 sText_HealBlockedNoMore[] = _("{B_ATK_NAME_WITH_PREFIX} is cured of\nits heal block!"); static const u8 sText_AttackerBecameFullyCharged[] = _("{B_ATK_NAME_WITH_PREFIX} became fully charged\ndue to its bond with its trainer!\p"); -static const u8 sText_AttackerBecameAshGreninja[] = _("{B_ATK_NAME_WITH_PREFIX} became Ash-{B_ATK_NAME_WITH_PREFIX}!\p"); +static const u8 sText_AttackerBecameAshSpecies[] = _("{B_ATK_NAME_WITH_PREFIX} became Ash-{B_ATK_NAME_WITH_PREFIX}!\p"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { - [STRINGID_ATTACKERBECAMEASHGRENINJA - 12] = sText_AttackerBecameAshGreninja, + [STRINGID_ATTACKERBECAMEASHSPECIES - 12] = sText_AttackerBecameAshSpecies, [STRINGID_ATTACKERBECAMEFULLYCHARGED - 12] = sText_AttackerBecameFullyCharged, [STRINGID_HEALBLOCKEDNOMORE - 12] = sText_HealBlockedNoMore, [STRINGID_TORMENTEDNOMORE - 12] = sText_TormentedNoMore, From 611da31ae3d269a4f716f0fca7e4986aa53f1c95 Mon Sep 17 00:00:00 2001 From: BuffelSaft Date: Sat, 2 Oct 2021 15:51:16 +1300 Subject: [PATCH 14/35] Fix form ID check The six here should be a seven, and replacing it with this function call is better than hard-coding it. --- src/battle_script_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index a74cb3aaa..fc9e9a66e 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -7137,7 +7137,7 @@ u32 IsLeafGuardProtected(u32 battler) bool32 IsShieldsDownProtected(u32 battler) { return (gBattleMons[battler].ability == ABILITY_SHIELDS_DOWN - && GetFormIdFromFormSpeciesId(gBattleMons[battler].species) < 6); // Minior is not in core form + && GetFormIdFromFormSpeciesId(gBattleMons[battler].species) < GetFormIdFromFormSpeciesId(SPECIES_MINIOR_CORE_RED)); // Minior is not in core form } u32 IsAbilityStatusProtected(u32 battler) From 16d032e99d48ee58da7effba05d639f37e88acf8 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 2 Oct 2021 02:01:34 -0300 Subject: [PATCH 15/35] Fix Unnerve not canceling out type resist berries. --- src/battle_util.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/battle_util.c b/src/battle_util.c index 20e5d91d1..197bd6a25 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -8203,6 +8203,7 @@ static u32 CalcFinalDmg(u32 dmg, u16 move, u8 battlerAtk, u8 battlerDef, u8 move u32 abilityDef = GetBattlerAbility(battlerDef); u32 defSide = GET_BATTLER_SIDE(battlerDef); u16 finalModifier = UQ_4_12(1.0); + u16 itemDef = gBattleMons[battlerDef].item; // check multiple targets in double battle if (GetMoveTargetCount(move, battlerAtk, battlerDef) >= 2) @@ -8323,7 +8324,8 @@ static u32 CalcFinalDmg(u32 dmg, u16 move, u8 battlerAtk, u8 battlerDef, u8 move // berries reducing dmg case HOLD_EFFECT_RESIST_BERRY: if (moveType == GetBattlerHoldEffectParam(battlerDef) - && (moveType == TYPE_NORMAL || typeEffectivenessModifier >= UQ_4_12(2.0))) + && (moveType == TYPE_NORMAL || typeEffectivenessModifier >= UQ_4_12(2.0)) + && !UnnerveOn(battlerDef, itemDef)) { if (abilityDef == ABILITY_RIPEN) MulModifier(&finalModifier, UQ_4_12(0.25)); From 63c6e73eb89714c56b8358c705fbe6830bd1aa21 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 2 Oct 2021 09:38:43 -0300 Subject: [PATCH 16/35] Fixed Sleep talk being canceled by the user being asleep.. --- src/battle_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_util.c b/src/battle_util.c index 20e5d91d1..e4bb55045 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -3131,7 +3131,7 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleMons[gBattlerAttacker].status1 -= toSub; if (gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP) { - if (gCurrentMove != MOVE_SNORE && gCurrentMove != MOVE_SLEEP_TALK) + if (gChosenMove != MOVE_SNORE && gChosenMove != MOVE_SLEEP_TALK) { gBattlescriptCurrInstr = BattleScript_MoveUsedIsAsleep; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; From a18b9c5b3228ec2a39d514d40f4c67a5029f4d4c Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sat, 2 Oct 2021 10:39:29 -0300 Subject: [PATCH 17/35] Quick tweaks -Use the species name for sText_AttackerBecameAshSpecies -Make Battle Bond not activate if the opposing party doesn't have 2 members or more. --- src/battle_message.c | 2 +- src/battle_script_commands.c | 3 ++- src/battle_util.c | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/battle_message.c b/src/battle_message.c index b0ca25c95..69829a731 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -705,7 +705,7 @@ static const u8 sText_AttackerGotOverInfatuation[] =_("{B_ATK_NAME_WITH_PREFIX} static const u8 sText_TormentedNoMore[] = _("{B_ATK_NAME_WITH_PREFIX} is\ntormented no more!"); static const u8 sText_HealBlockedNoMore[] = _("{B_ATK_NAME_WITH_PREFIX} is cured of\nits heal block!"); static const u8 sText_AttackerBecameFullyCharged[] = _("{B_ATK_NAME_WITH_PREFIX} became fully charged\ndue to its bond with its trainer!\p"); -static const u8 sText_AttackerBecameAshSpecies[] = _("{B_ATK_NAME_WITH_PREFIX} became Ash-{B_ATK_NAME_WITH_PREFIX}!\p"); +static const u8 sText_AttackerBecameAshSpecies[] = _("{B_ATK_NAME_WITH_PREFIX} became Ash-{B_BUFF1}!\p"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 40d84767e..18302cba3 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8139,7 +8139,8 @@ static void Cmd_various(void) // Change species. if (gBattlescriptCurrInstr[3] == 0) { - PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gActiveBattler].species); + if (!gBattleTextBuff1) + PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gActiveBattler].species); BtlController_EmitSetMonData(0, REQUEST_SPECIES_BATTLE, gBitTable[gBattlerPartyIndexes[gActiveBattler]], 2, &gBattleMons[gActiveBattler].species); MarkBattlerForControllerExec(gActiveBattler); } diff --git a/src/battle_util.c b/src/battle_util.c index 8898da5d7..d5c588e21 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5067,8 +5067,10 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move break; case ABILITY_BATTLE_BOND: if (gBattleMons[gBattlerAttacker].species == SPECIES_GRENINJA_BATTLE_BOND - && gBattleResults.opponentFaintCounter != 0) + && gBattleResults.opponentFaintCounter != 0 + && CalculateEnemyPartyCount() > 1) { + PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gBattlerAttacker].species); gBattleStruct->changedSpecies[gBattlerPartyIndexes[gBattlerAttacker]] = gBattleMons[gBattlerAttacker].species; gBattleMons[gBattlerAttacker].species = SPECIES_GRENINJA_ASH; BattleScriptPushCursor(); From 57ea20bc6d7d951f42ac3535d70196471c5ecb0e Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 2 Oct 2021 13:32:36 -0300 Subject: [PATCH 18/35] Implemented modern effect of struggle with config --- data/battle_scripts_1.s | 7 +++++++ include/constants/battle.h | 3 ++- include/constants/battle_move_effects.h | 3 ++- src/battle_script_commands.c | 8 ++++++++ src/data/battle_moves.h | 3 ++- 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index f1f5995ff..92a03a55a 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -379,6 +379,7 @@ gBattleScriptsForMoveEffects:: .4byte BattleScript_EffectDecorate @ EFFECT_DECORATE .4byte BattleScript_EffectHit @ EFFECT_SNIPE_SHOT .4byte BattleScript_EffectTripleHit @ EFFECT_TRIPLE_HIT + .4byte BattleScript_EffectRecoilHP25 @ EFFECT_RECOIL_HP_25 BattleScript_EffectDecorate: attackcanceler @@ -4911,6 +4912,12 @@ BattleScript_EffectRecoil50: setmoveeffect MOVE_EFFECT_RECOIL_50 | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN goto BattleScript_EffectHit +BattleScript_EffectRecoilHP25: + setmoveeffect MOVE_EFFECT_RECOIL_HP_25 | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN + jumpifnotmove MOVE_STRUGGLE, BattleScript_EffectHit + incrementgamestat GAME_STAT_USED_STRUGGLE + goto BattleScript_EffectHit + BattleScript_EffectTeeterDance:: attackcanceler attackstring diff --git a/include/constants/battle.h b/include/constants/battle.h index e88bb66dd..bf6403a18 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -347,7 +347,8 @@ #define MOVE_EFFECT_THROAT_CHOP 0x43 #define MOVE_EFFECT_INCINERATE 0x44 #define MOVE_EFFECT_BUG_BITE 0x45 -#define NUM_MOVE_EFFECTS 0x46 +#define MOVE_EFFECT_RECOIL_HP_25 0x46 +#define NUM_MOVE_EFFECTS 0x47 #define MOVE_EFFECT_AFFECTS_USER 0x4000 #define MOVE_EFFECT_CERTAIN 0x8000 diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index 440e6e76b..5038b52c3 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -363,7 +363,8 @@ #define EFFECT_DECORATE 357 #define EFFECT_SNIPE_SHOT 358 #define EFFECT_TRIPLE_HIT 359 +#define EFFECT_RECOIL_HP_25 360 -#define NUM_BATTLE_MOVE_EFFECTS 360 +#define NUM_BATTLE_MOVE_EFFECTS 361 #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 1393a8d8c..0eb1086af 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3177,6 +3177,14 @@ void SetMoveEffect(bool32 primary, u32 certain) BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_MoveEffectRecoilWithStatus; break; + case MOVE_EFFECT_RECOIL_HP_25: // Struggle + gBattleMoveDamage = (gBattleMons[gEffectBattler].maxHP) / 4; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_MoveEffectRecoil; + break; case MOVE_EFFECT_THRASH: if (gBattleMons[gEffectBattler].status2 & STATUS2_LOCK_CONFUSE) { diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index a7a2752e0..f63ef27fc 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -2599,11 +2599,12 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = #if B_UPDATED_MOVE_DATA >= GEN_4 .accuracy = 0, .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .effect = EFFECT_RECOIL_HP_25, #else .accuracy = 100, .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .effect = EFFECT_RECOIL_25, #endif - .effect = EFFECT_RECOIL_25, .power = 50, .type = TYPE_NORMAL, .pp = 1, From 9aee8cbea501aaebf0f7bf12adf2db60d63f98b6 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 2 Oct 2021 14:47:38 -0300 Subject: [PATCH 19/35] Fixed Sticky Hold not being negated by Gastro Acid when stealing and switching items --- src/battle_script_commands.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 1393a8d8c..feff90aa4 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3067,7 +3067,7 @@ void SetMoveEffect(bool32 primary, u32 certain) gBattlescriptCurrInstr++; } else if (gBattleMons[gBattlerTarget].item - && gBattleMons[gBattlerTarget].ability == ABILITY_STICKY_HOLD) + && GetBattlerAbility(gBattlerTarget) == ABILITY_STICKY_HOLD) { BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_NoItemSteal; @@ -11615,7 +11615,7 @@ static void Cmd_tryswapitems(void) // trick gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); } // check if ability prevents swapping - else if (gBattleMons[gBattlerTarget].ability == ABILITY_STICKY_HOLD) + else if (GetBattlerAbility(gBattlerTarget) == ABILITY_STICKY_HOLD) { gBattlescriptCurrInstr = BattleScript_StickyHoldActivates; gLastUsedAbility = gBattleMons[gBattlerTarget].ability; From 6208995606442d51bd7fc8fbf0b1f0598f69f873 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 2 Oct 2021 15:52:55 -0300 Subject: [PATCH 20/35] Fixed Run Away. --- src/battle_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_main.c b/src/battle_main.c index 25db65f78..62662d1e4 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3685,7 +3685,7 @@ u8 IsRunningFromBattleImpossible(void) return 0; if (gBattleTypeFlags & BATTLE_TYPE_LINK) return 0; - if (gBattleMons[gActiveBattler].ability == ABILITY_RUN_AWAY) + if (GetBattlerAbility(gActiveBattler) == ABILITY_RUN_AWAY) return 0; if ((i = IsAbilityPreventingEscape(gActiveBattler))) From 5abb0c0dfeff902fe60656072d24106a0f9f2598 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 2 Oct 2021 16:48:45 -0300 Subject: [PATCH 21/35] Fixed perish song + soundproof + gastro acid --- src/battle_script_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index feff90aa4..88157273a 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -10899,7 +10899,7 @@ static void Cmd_trysetperishsong(void) for (i = 0; i < gBattlersCount; i++) { if (gStatuses3[i] & STATUS3_PERISH_SONG - || gBattleMons[i].ability == ABILITY_SOUNDPROOF + || GetBattlerAbility(i) == ABILITY_SOUNDPROOF || BlocksPrankster(gCurrentMove, gBattlerAttacker, i)) { notAffectedCount++; From 8d54e5666d5b6fa943fbc24cf86755ca5c4e599a Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 2 Oct 2021 17:05:23 -0300 Subject: [PATCH 22/35] Fixed waking up from uproar --- src/battle_script_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 88157273a..88851909b 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9121,7 +9121,7 @@ bool8 UproarWakeUpCheck(u8 battlerId) for (i = 0; i < gBattlersCount; i++) { - if (!(gBattleMons[i].status2 & STATUS2_UPROAR) || gBattleMons[battlerId].ability == ABILITY_SOUNDPROOF) + if (!(gBattleMons[i].status2 & STATUS2_UPROAR) || GetBattlerAbility(battlerId) == ABILITY_SOUNDPROOF) continue; gBattleScripting.battler = i; From ebe5e039986b2197f1b8bfbc8f4c949df0f78f64 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 2 Oct 2021 17:07:29 -0300 Subject: [PATCH 23/35] Added Gen 8 abilities affected by Mold Breaker --- src/battle_util.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/battle_util.c b/src/battle_util.c index 20e5d91d1..ae18d0a7d 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -983,6 +983,11 @@ static const u8 sAbilitiesAffectedByMoldBreaker[] = [ABILITY_FLUFFY] = 1, [ABILITY_QUEENLY_MAJESTY] = 1, [ABILITY_WATER_BUBBLE] = 1, + [ABILITY_MIRROR_ARMOR] = 1, + [ABILITY_PUNK_ROCK] = 1, + [ABILITY_ICE_SCALES] = 1, + [ABILITY_ICE_FACE] = 1, + [ABILITY_PASTEL_VEIL] = 1, }; static const u8 sAbilitiesNotTraced[ABILITIES_COUNT] = From b29f5c801fc793545088b5336964127ca0550e6d Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 2 Oct 2021 18:16:14 -0300 Subject: [PATCH 24/35] Fixed Gastro Acid's effect on Early Bird --- src/battle_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_util.c b/src/battle_util.c index ae18d0a7d..a34611886 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -3126,7 +3126,7 @@ u8 AtkCanceller_UnableToUseMove(void) else { u8 toSub; - if (gBattleMons[gBattlerAttacker].ability == ABILITY_EARLY_BIRD) + if (GetBattlerAbility(gBattlerAttacker) == ABILITY_EARLY_BIRD) toSub = 2; else toSub = 1; From a22a456268445be038cf3b35dbb0cfa0b1e1a921 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 2 Oct 2021 18:21:02 -0300 Subject: [PATCH 25/35] Fixed heal bell + soundproof + gastro acid --- src/battle_script_commands.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 88851909b..713101765 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -10770,7 +10770,7 @@ static void Cmd_healpartystatus(void) else party = gEnemyParty; - if (gBattleMons[gBattlerAttacker].ability != ABILITY_SOUNDPROOF) + if (GetBattlerAbility(gBattlerAttacker) != ABILITY_SOUNDPROOF) { gBattleMons[gBattlerAttacker].status1 = 0; gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_NIGHTMARE); @@ -10786,7 +10786,7 @@ static void Cmd_healpartystatus(void) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && !(gAbsentBattlerFlags & gBitTable[gActiveBattler])) { - if (gBattleMons[gActiveBattler].ability != ABILITY_SOUNDPROOF) + if (GetBattlerAbility(gActiveBattler) != ABILITY_SOUNDPROOF) { gBattleMons[gActiveBattler].status1 = 0; gBattleMons[gActiveBattler].status2 &= ~(STATUS2_NIGHTMARE); From 9d64a26625f66b238735c9b8c15c641dd82326ab Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 2 Oct 2021 18:31:09 -0300 Subject: [PATCH 26/35] Fix preasure + Gastro Acid --- src/battle_util.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index a34611886..be88bda67 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -1268,7 +1268,7 @@ void PressurePPLose(u8 target, u8 attacker, u16 move) { int moveIndex; - if (gBattleMons[target].ability != ABILITY_PRESSURE) + if (GetBattlerAbility(target) != ABILITY_PRESSURE) return; for (moveIndex = 0; moveIndex < MAX_MON_MOVES; moveIndex++) @@ -1300,7 +1300,7 @@ void PressurePPLoseOnUsingImprison(u8 attacker) for (i = 0; i < gBattlersCount; i++) { - if (atkSide != GetBattlerSide(i) && gBattleMons[i].ability == ABILITY_PRESSURE) + if (atkSide != GetBattlerSide(i) && GetBattlerAbility(i) == ABILITY_PRESSURE) { for (j = 0; j < MAX_MON_MOVES; j++) { @@ -1333,7 +1333,7 @@ void PressurePPLoseOnUsingPerishSong(u8 attacker) for (i = 0; i < gBattlersCount; i++) { - if (gBattleMons[i].ability == ABILITY_PRESSURE && i != attacker) + if (GetBattlerAbility(i) == ABILITY_PRESSURE && i != attacker) { for (j = 0; j < MAX_MON_MOVES; j++) { From 2d5da7852cf396ad181da7bb4d7d9a0fcf93f646 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 2 Oct 2021 18:44:04 -0300 Subject: [PATCH 27/35] Fixed Yawn + Vital Spirit + Gastro Acid --- 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 be88bda67..5c2de28c3 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2728,8 +2728,8 @@ u8 DoBattlerEndTurnEffects(void) { gStatuses3[gActiveBattler] -= STATUS3_YAWN_TURN(1); if (!(gStatuses3[gActiveBattler] & STATUS3_YAWN) && !(gBattleMons[gActiveBattler].status1 & STATUS1_ANY) - && gBattleMons[gActiveBattler].ability != ABILITY_VITAL_SPIRIT - && gBattleMons[gActiveBattler].ability != ABILITY_INSOMNIA && !UproarWakeUpCheck(gActiveBattler) + && GetBattlerAbility(gActiveBattler) != ABILITY_VITAL_SPIRIT + && GetBattlerAbility(gActiveBattler) != ABILITY_INSOMNIA && !UproarWakeUpCheck(gActiveBattler) && !IsLeafGuardProtected(gActiveBattler)) { CancelMultiTurnMoves(gActiveBattler); From 978f73475b462def6c39320630ad2d0c6c988239 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 2 Oct 2021 19:01:11 -0300 Subject: [PATCH 28/35] Config for Shadow Tag vs Shadow Tag --- include/constants/battle_config.h | 1 + src/battle_util.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 26007ff9f..b2c821513 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -127,6 +127,7 @@ #define B_GALE_WINGS GEN_7 // In Gen7+ requires full HP to trigger. #define B_STANCE_CHANGE_FAIL GEN_7 // In Gen7+, Stance Change fails if the Pokémon is unable to use a move because of confusion, paralysis, etc. In Gen6, it doesn't. #define B_GHOSTS_ESCAPE GEN_7 // In Gen6+, Ghost-type Pokémon can escape even when blocked by abilities such as Shadow Tag. +#define B_SHADOW_TAG_ESCAPE GEN_7 // In Gen4+, if both sides have a Pokémon with Shadow Tag, all battlers can escape. Before, neither side could escape this situation. #define B_MOODY_ACC_EVASION GEN_8 // In Gen8, Moody CANNOT raise Accuracy and Evasion anymore. #define B_FLASH_FIRE_FROZEN GEN_7 // In Gen5+, Flash Fire can trigger even when frozen, when it couldn't before. #define B_SYNCHRONIZE_NATURE GEN_8 // In Gen8, if the Pokémon with Synchronize is leading the party, it's 100% guaranteed that wild Pokémon will have the same ability, as opposed to 50% previously. diff --git a/src/battle_util.c b/src/battle_util.c index 20e5d91d1..d95a3fa83 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5387,11 +5387,15 @@ u32 IsAbilityOnFieldExcept(u32 battlerId, u32 ability) u32 IsAbilityPreventingEscape(u32 battlerId) { u32 id; - - if (B_GHOSTS_ESCAPE >= GEN_6 && IS_BATTLER_OF_TYPE(battlerId, TYPE_GHOST)) - return 0; - - if ((id = IsAbilityOnOpposingSide(battlerId, ABILITY_SHADOW_TAG)) && gBattleMons[battlerId].ability != ABILITY_SHADOW_TAG) + #if B_GHOSTS_ESCAPE >= GEN_6 + if (IS_BATTLER_OF_TYPE(battlerId, TYPE_GHOST)) + return 0; + #endif + #if B_SHADOW_TAG_ESCAPE >= GEN_4 + if ((id = IsAbilityOnOpposingSide(battlerId, ABILITY_SHADOW_TAG)) && gBattleMons[battlerId].ability != ABILITY_SHADOW_TAG) + #else + if (id = IsAbilityOnOpposingSide(battlerId, ABILITY_SHADOW_TAG)) + #endif return id; if ((id = IsAbilityOnOpposingSide(battlerId, ABILITY_ARENA_TRAP)) && IsBattlerGrounded(battlerId)) return id; From 76bdbf164efe67bada54003b7d9a07d2d4df22a3 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 2 Oct 2021 20:00:00 -0300 Subject: [PATCH 29/35] Updated sound flags for Howl and Heal Bell --- src/data/battle_moves.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index a7a2752e0..dea104b24 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -3424,6 +3424,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = [MOVE_HEAL_BELL] = { + #if B_UPDATED_MOVE_DATA != GEN_5 + .flags = FLAG_SNATCH_AFFECTED | FLAG_SOUND, + #else + .flags = FLAG_SNATCH_AFFECTED, + #endif .effect = EFFECT_HEAL_BELL, .power = 0, .type = TYPE_NORMAL, @@ -3432,7 +3437,6 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .secondaryEffectChance = 0, .target = MOVE_TARGET_USER, .priority = 0, - .flags = FLAG_SNATCH_AFFECTED | FLAG_SOUND, .split = SPLIT_STATUS, }, @@ -5338,6 +5342,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = [MOVE_HOWL] = { + #if B_UPDATED_MOVE_DATA >= GEN_8 + .flags = FLAG_SNATCH_AFFECTED | FLAG_SOUND, + #else + .flags = FLAG_SNATCH_AFFECTED, + #endif .effect = EFFECT_ATTACK_UP, .power = 0, .type = TYPE_NORMAL, @@ -5346,7 +5355,6 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .secondaryEffectChance = 0, .target = MOVE_TARGET_USER, .priority = 0, - .flags = FLAG_SNATCH_AFFECTED | FLAG_SOUND, .split = SPLIT_STATUS, }, From 1e0ae9a1546c2d77a626324926d5b993ae1d29e8 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 2 Oct 2021 20:54:04 -0300 Subject: [PATCH 30/35] Tabs to spaces. --- data/battle_scripts_1.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 92a03a55a..47a034ce1 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -379,7 +379,7 @@ gBattleScriptsForMoveEffects:: .4byte BattleScript_EffectDecorate @ EFFECT_DECORATE .4byte BattleScript_EffectHit @ EFFECT_SNIPE_SHOT .4byte BattleScript_EffectTripleHit @ EFFECT_TRIPLE_HIT - .4byte BattleScript_EffectRecoilHP25 @ EFFECT_RECOIL_HP_25 + .4byte BattleScript_EffectRecoilHP25 @ EFFECT_RECOIL_HP_25 BattleScript_EffectDecorate: attackcanceler From b3167b7d53cb4478b9f6d54e1745a188132169f0 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Mon, 4 Oct 2021 19:40:36 -0300 Subject: [PATCH 31/35] Fixed Trump Card's damage check --- src/battle_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_util.c b/src/battle_util.c index 462b58bd4..71a9a3130 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7489,7 +7489,7 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef) if (gBattleMons[battlerAtk].pp[i] >= ARRAY_COUNT(sTrumpCardPowerTable)) basePower = sTrumpCardPowerTable[ARRAY_COUNT(sTrumpCardPowerTable) - 1]; else - basePower = sTrumpCardPowerTable[i]; + basePower = sTrumpCardPowerTable[gBattleMons[battlerAtk].pp[i]]; } break; case EFFECT_ACROBATICS: From 4ab8c95207b679a92e713a2a35a26c0121e611be Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Mon, 4 Oct 2021 20:17:43 -0300 Subject: [PATCH 32/35] Fixed Heat Crash's power table name --- src/battle_util.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index 462b58bd4..09a2ae0ae 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7317,7 +7317,7 @@ static const u16 sWeightToDamageTable[] = }; static const u8 sSpeedDiffPowerTable[] = {40, 60, 80, 120, 150}; -static const u8 sHeatCrushPowerTable[] = {40, 40, 60, 80, 100, 120}; +static const u8 sHeatCrashPowerTable[] = {40, 40, 60, 80, 100, 120}; static const u8 sTrumpCardPowerTable[] = {200, 80, 60, 50, 40}; const struct TypePower gNaturalGiftTable[] = @@ -7512,10 +7512,10 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef) break; case EFFECT_HEAT_CRASH: weight = GetBattlerWeight(battlerAtk) / GetBattlerWeight(battlerDef); - if (weight >= ARRAY_COUNT(sHeatCrushPowerTable)) - basePower = sHeatCrushPowerTable[ARRAY_COUNT(sHeatCrushPowerTable) - 1]; + if (weight >= ARRAY_COUNT(sHeatCrashPowerTable)) + basePower = sHeatCrashPowerTable[ARRAY_COUNT(sHeatCrashPowerTable) - 1]; else - basePower = sHeatCrushPowerTable[i]; + basePower = sHeatCrashPowerTable[i]; break; case EFFECT_PUNISHMENT: basePower = 60 + (CountBattlerStatIncreases(battlerDef, FALSE) * 20); From 92f0f6f82013329fcc133cc47fa6bb206c03a72c Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Mon, 4 Oct 2021 20:20:00 -0300 Subject: [PATCH 33/35] Fixed Psychic Fangs power --- src/data/battle_moves.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index a7a2752e0..84ba59f24 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -10226,7 +10226,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = [MOVE_PSYCHIC_FANGS] = { .effect = EFFECT_BRICK_BREAK, - .power = 75, + .power = 85, .type = TYPE_PSYCHIC, .accuracy = 100, .pp = 15, From a6198e5d4682d284a6259467505ffd947280cbcb Mon Sep 17 00:00:00 2001 From: BuffelSaft Date: Wed, 6 Oct 2021 15:30:52 +1300 Subject: [PATCH 34/35] Fix Simple Beam - No longer freezes the game - Now fails if the target already has simple - Explicitly checks and changes the target's ability instead of gActiveBattler's ability --- src/battle_script_commands.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 8d6dd5bdb..ead08479a 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -7910,15 +7910,15 @@ static void Cmd_various(void) gBattlescriptCurrInstr += 7; return; case VARIOUS_SET_SIMPLE_BEAM: - if (IsEntrainmentTargetOrSimpleBeamBannedAbility(gBattleMons[gActiveBattler].ability)) + if (IsEntrainmentTargetOrSimpleBeamBannedAbility(gBattleMons[gBattlerTarget].ability) + || gBattleMons[gBattlerTarget].ability == ABILITY_SIMPLE) { gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); } else { - gBattleMons[gActiveBattler].ability = ABILITY_SIMPLE; + gBattleMons[gBattlerTarget].ability = ABILITY_SIMPLE; gBattlescriptCurrInstr += 7; - break; } return; case VARIOUS_TRY_ENTRAINMENT: From 38b816ccdd8b7ac345c628ee93a8bb62aa9b2c92 Mon Sep 17 00:00:00 2001 From: BuffelSaft Date: Wed, 6 Oct 2021 21:53:30 +1300 Subject: [PATCH 35/35] AI handles dynamic move types This will make the AI account for the type of moves like Weather Ball, Hidden Power and Revelation Dance when considering abilities that make the useless. E.g. Water-type Hidden Power vs. Storm Drain. --- src/battle_ai_main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index 03472271d..42b8b9d40 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -520,6 +520,9 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) u32 i; u16 predictedMove = gLastMoves[battlerDef]; // TODO better move prediction + SetTypeBeforeUsingMove(move, battlerAtk); + GET_MOVE_TYPE(move, moveType); + if (IsTargetingPartner(battlerAtk, battlerDef)) return score; @@ -2472,7 +2475,10 @@ static s16 AI_DoubleBattle(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) bool32 attackerHasBadAbility = (GetAbilityRating(AI_DATA->atkAbility) < 0); bool32 partnerHasBadAbility = (GetAbilityRating(atkPartnerAbility) < 0); u16 predictedMove = gLastMoves[battlerDef]; //for now - + + SetTypeBeforeUsingMove(move, battlerAtk); + GET_MOVE_TYPE(move, moveType); + // check what effect partner is using if (AI_DATA->partnerMove != 0) { @@ -4751,7 +4757,10 @@ static s16 AI_HPAware(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) { u16 effect = gBattleMoves[move].effect; u8 moveType = gBattleMoves[move].type; - + + SetTypeBeforeUsingMove(move, battlerAtk); + GET_MOVE_TYPE(move, moveType); + if (IsTargetingPartner(battlerAtk, battlerDef)) { if ((effect == EFFECT_HEAL_PULSE || effect == EFFECT_HIT_ENEMY_HEAL_ALLY)