From c2f718d3d35255552fdbe42f237a909a78a821cb Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 12 Jan 2021 14:58:24 -0300 Subject: [PATCH 01/12] 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 4bfef447b8ec..c3ab5b1504fc 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 f4b2ab7a74d5..76eda847206c 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 009590f3a342..bf8700a2505d 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 90766f9d5923..525366df88e4 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 6c34197ca650..69a142f23c9e 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 267b06ece132..0f17a79ed124 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 210f00b2708b..ba3874f51a87 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 872d2a700858081148dfab5e92a02cbef36f87fd Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sat, 25 Sep 2021 22:30:45 -0300 Subject: [PATCH 02/12] 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 e875e01e7f5f..cf3204727f6c 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 03/12] 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 71dcf8b2be8d..d7de92096728 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 cf3204727f6c..381c67a30d04 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 ac4257fe7124..436ac4d1a61d 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 04/12] 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 436ac4d1a61d..556d98e46d7e 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 05/12] 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 556d98e46d7e..6b65c72c6e28 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 06/12] 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 381c67a30d04..0743d21c1214 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 6b65c72c6e28..20e5d91d1ac6 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 07/12] 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 0743d21c1214..3c9397f986ef 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 08/12] 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 12cf20a9c0b2..f39818f7bc1b 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 3c9397f986ef..6324588b2543 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 09/12] 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 5c3f2ecd83d0..25db65f784b6 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 10/12] 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 6324588b2543..f1f5995ffbab 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 ddad6e555e96009f7c7838645852b81832294c41 Mon Sep 17 00:00:00 2001 From: BuffelSaft Date: Sat, 2 Oct 2021 13:11:22 +1300 Subject: [PATCH 11/12] Fix recoil applying when no damage was dealt Checking that damage was not zero should cover all cases where a recoil move shouldn't inflict recoil damage. --- src/battle_script_commands.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index da0aa0d05d7f..b7478df0b547 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -4839,7 +4839,8 @@ static void Cmd_moveend(void) case MOVEEND_RECOIL: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && !(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE) - && IsBattlerAlive(gBattlerAttacker)) + && IsBattlerAlive(gBattlerAttacker) + && gBattleScripting.savedDmg != 0) // Some checks may be redundant alongside this one { switch (gBattleMoves[gCurrentMove].effect) { From d4d1e6e520b237005cebbf2f39c11744128032ac Mon Sep 17 00:00:00 2001 From: BuffelSaft Date: Sat, 2 Oct 2021 14:40:21 +1300 Subject: [PATCH 12/12] Fix Ivy text errors New hidden power change cost is reflected in Ivy's monologue, and she mentions Vitamins as a way to increase IVs. Update version num to 1.7.1. --- .../scripts.inc | 20 ++++++++++--------- src/strings.c | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/data/maps/FallarborTown_MoveRelearnersHouse/scripts.inc b/data/maps/FallarborTown_MoveRelearnersHouse/scripts.inc index d1157b7cb99c..ba73cfc1fdd4 100644 --- a/data/maps/FallarborTown_MoveRelearnersHouse/scripts.inc +++ b/data/maps/FallarborTown_MoveRelearnersHouse/scripts.inc @@ -104,7 +104,7 @@ FallarborTown_Text_AnnoyingIntroPart8: .string "Ivy: And for one Bottle Cap, I'll change\n" .string "one of a Pokémon's IVs to whatever\l" .string "you want.\p" - .string "Also, for five Caps, I'll change all\n" + .string "Also, for three Caps, I'll change all\n" .string "of a Pokémon's IVs to give them a new\l" .string "Hidden Power type.$" @@ -583,7 +583,7 @@ HyperTraining_EventScript_ChangeOneIV:: goto HyperTraining_EventScript_DoHyperTraining HyperTraining_EventScript_ChangeHiddenPower:: - msgbox HyperTraining_Text_ForFiveCapsChangeAllIVs, MSGBOX_DEFAULT + msgbox HyperTraining_Text_ForThreeCapsChangeAllIVs, MSGBOX_DEFAULT copyvar VAR_0x800A, VAR_0x8004 setvar VAR_0x8004, SCROLL_MULTI_HIDDEN_POWER special ShowScrollableMultichoice @@ -679,7 +679,7 @@ HyperTraining_EventScript_ChangeAllIVs:: compare VAR_RESULT, FALSE goto_if_eq HyperTraining_EventScript_NotEnoughCaps special ChangeChosenMonHiddenPower - msgbox HyperTraining_Text_PayFiveCaps, MSGBOX_DEFAULT + msgbox HyperTraining_Text_PayThreeCaps, MSGBOX_DEFAULT removeitem ITEM_BOTTLE_CAP, 3 goto HyperTraining_EventScript_DoHyperTraining @@ -714,15 +714,17 @@ HyperTraining_Text_WantMeExplainIVs: HyperTraining_Text_ExplainIVs: .string "Ivy: IVs are a hidden part of your\n" .string "Pokémon's stats that can only be\l" - .string "changed with special training.\p" + .string "changed with special training,\l" + .string "or raised by giving them Vitamins.\p" .string "They can be any value between\n" .string "0 and 31, and affect things like\l" .string "the type of the move Hidden Power.\p" .string "Higher IVs means higher stats, but\n" .string "higher stats aren't always better!\p" .string "Example: If your Pokémon relies on\n" - .string "Special Attacks, a low Attack IV may\l" - .string "help when it's confused in battle.$" + .string "Special Attacks, a low Attack IV will\l" + .string "reduce the damage it takes if it hits\l" + .string "itself in confusion.$" HyperTraining_Text_LetsTakeALook: .string "OK! Let's take a look at your\n" @@ -761,7 +763,7 @@ HyperTraining_Text_HyperTrainingMadeMonStronger: .string "stronger!\p" .string "Would you like to train some more?$" -HyperTraining_Text_ForFiveCapsChangeAllIVs: +HyperTraining_Text_ForThreeCapsChangeAllIVs: .string "For three Bottle Caps, I can change all\n" .string "of a Pokémon's IVs at once to give them\l" .string "a new Hidden Power type.\p" @@ -786,5 +788,5 @@ HyperTraining_Text_NotEnoughCaps: HyperTraining_Text_PayOneCap: .string "{PLAYER} handed over one Bottle Cap.$" -HyperTraining_Text_PayFiveCaps: - .string "{PLAYER} handed over five Bottle Caps.$" +HyperTraining_Text_PayThreeCaps: + .string "{PLAYER} handed over three Bottle Caps.$" diff --git a/src/strings.c b/src/strings.c index 9e0a05d9eb26..a06f8bbd4d16 100644 --- a/src/strings.c +++ b/src/strings.c @@ -1667,7 +1667,7 @@ const u8 gText_SavingNormalMode[] = _("Normal Mode"); const u8 gText_SavingHardMode[] = _("Hard Mode"); const u8 gText_SavingChallengeMode[] = _("Challenge Mode"); const u8 gText_SavingInsanityMode[] = _("Insanity Mode"); -const u8 gText_SavingVersionNum[] = _("Ver 1.7"); +const u8 gText_SavingVersionNum[] = _("Ver 1.7.1"); const u8 gText_WirelessCommStatus[] = _("Wireless Communication Status"); const u8 gText_PeopleTrading[] = _("People trading:"); const u8 gText_PeopleBattling[] = _("People battling:");