diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 260257fc61..34aea69998 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1635,7 +1635,11 @@ .macro trygulpmissile callnative BS_TryGulpMissile .endm - + + .macro tryactivategulpmissile + callnative BS_TryActivateGulpMissile + .endm + .macro tryquash failInstr:req callnative BS_TryQuash .4byte \failInstr diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 788b5225f0..79ee6b4017 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -5458,6 +5458,7 @@ BattleScript_EffectCamouflage:: BattleScript_FaintAttacker:: tryillusionoff BS_ATTACKER + tryactivategulpmissile playfaintcry BS_ATTACKER pause B_WAIT_TIME_LONG dofaintanimation BS_ATTACKER @@ -5470,6 +5471,7 @@ BattleScript_FaintAttacker:: BattleScript_FaintTarget:: tryillusionoff BS_TARGET + tryactivategulpmissile playfaintcry BS_TARGET pause B_WAIT_TIME_LONG dofaintanimation BS_TARGET diff --git a/include/constants/form_change_types.h b/include/constants/form_change_types.h index 51325baf25..30bb54d027 100644 --- a/include/constants/form_change_types.h +++ b/include/constants/form_change_types.h @@ -120,4 +120,7 @@ // param1: status #define FORM_CHANGE_STATUS 20 +// Form change that activates after move is used. Currently only used for activating Gulp Missile. +#define FORM_CHANGE_HIT_BY_MOVE 21 + #endif // GUARD_CONSTANTS_FORM_CHANGE_TYPES_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index f80bebd8a2..6f57f87e31 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -16880,6 +16880,39 @@ void BS_TryGulpMissile(void) gBattlescriptCurrInstr = cmd->nextInstr; } +void BS_TryActivateGulpMissile(void) +{ + NATIVE_ARGS(); + + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && !gProtectStructs[gBattlerAttacker].confusionSelfDmg + && TARGET_TURN_DAMAGED + && gBattleMons[gBattlerTarget].species != SPECIES_CRAMORANT + && GetBattlerAbility(gBattlerTarget) == ABILITY_GULP_MISSILE) + { + if (GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD) + { + gBattleMoveDamage = GetNonDynamaxMaxHP(gBattlerAttacker) / 4; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + } + + switch(gBattleMons[gBattlerTarget].species) + { + case SPECIES_CRAMORANT_GORGING: + BattleScriptPushCursor(); + TryBattleFormChange(gBattlerTarget, FORM_CHANGE_HIT_BY_MOVE); + gBattlescriptCurrInstr = BattleScript_GulpMissileGorging; + return; + case SPECIES_CRAMORANT_GULPING: + BattleScriptPushCursor(); + TryBattleFormChange(gBattlerTarget, FORM_CHANGE_HIT_BY_MOVE); + gBattlescriptCurrInstr = BattleScript_GulpMissileGulping; + return; + } + } + gBattlescriptCurrInstr = cmd->nextInstr; +} void BS_TryQuash(void) { diff --git a/src/battle_util.c b/src/battle_util.c index efa1a3ecf7..c1f0ac89bf 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5583,34 +5583,30 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32 if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && !gProtectStructs[gBattlerAttacker].confusionSelfDmg && TARGET_TURN_DAMAGED - && IsBattlerAlive(battler)) + && IsBattlerAlive(battler) + && gBattleMons[gBattlerTarget].species != SPECIES_CRAMORANT) { - // TODO: Convert this to a proper FORM_CHANGE type. - if (gBattleMons[gBattlerTarget].species == SPECIES_CRAMORANT_GORGING) + if (GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD) { - gBattleMons[gBattlerTarget].species = SPECIES_CRAMORANT; - if (GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD) - { - gBattleMoveDamage = GetNonDynamaxMaxHP(gBattlerAttacker) / 4; - if (gBattleMoveDamage == 0) - gBattleMoveDamage = 1; - } - BattleScriptPushCursor(); - gBattlescriptCurrInstr = BattleScript_GulpMissileGorging; - effect++; + gBattleMoveDamage = GetNonDynamaxMaxHP(gBattlerAttacker) / 4; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; } - else if (gBattleMons[gBattlerTarget].species == SPECIES_CRAMORANT_GULPING) + + switch(gBattleMons[gBattlerTarget].species) { - gBattleMons[gBattlerTarget].species = SPECIES_CRAMORANT; - if (GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD) - { - gBattleMoveDamage = GetNonDynamaxMaxHP(gBattlerAttacker) / 4; - if (gBattleMoveDamage == 0) - gBattleMoveDamage = 1; - } - BattleScriptPushCursor(); - gBattlescriptCurrInstr = BattleScript_GulpMissileGulping; - effect++; + case SPECIES_CRAMORANT_GORGING: + TryBattleFormChange(battler, FORM_CHANGE_HIT_BY_MOVE); + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_GulpMissileGorging; + effect++; + break; + case SPECIES_CRAMORANT_GULPING: + TryBattleFormChange(battler, FORM_CHANGE_HIT_BY_MOVE); + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_GulpMissileGulping; + effect++; + break; } } break; @@ -10480,6 +10476,7 @@ u16 GetBattleFormChangeTargetSpecies(u32 battler, u16 method) } break; case FORM_CHANGE_BATTLE_TURN_END: + case FORM_CHANGE_HIT_BY_MOVE: if (formChanges[i].param1 == GetBattlerAbility(battler)) targetSpecies = formChanges[i].targetSpecies; break; diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index 5edd6f42b5..8eb96e04b0 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -1098,6 +1098,7 @@ static const struct FormChange sSandacondaFormChangeTable[] = static const struct FormChange sCramorantFormChangeTable[] = { {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_CRAMORANT_GULPING, ABILITY_GULP_MISSILE, HP_HIGHER_THAN, 50}, {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_CRAMORANT_GORGING, ABILITY_GULP_MISSILE, HP_LOWER_EQ_THAN, 50}, + {FORM_CHANGE_HIT_BY_MOVE, SPECIES_CRAMORANT, ABILITY_GULP_MISSILE}, {FORM_CHANGE_BATTLE_SWITCH, SPECIES_CRAMORANT}, {FORM_CHANGE_FAINT, SPECIES_CRAMORANT}, {FORM_CHANGE_END_BATTLE, SPECIES_CRAMORANT}, diff --git a/test/battle/ability/gulp_missile.c b/test/battle/ability/gulp_missile.c index 680208506d..2ec9acc61b 100644 --- a/test/battle/ability/gulp_missile.c +++ b/test/battle/ability/gulp_missile.c @@ -116,9 +116,7 @@ SINGLE_BATTLE_TEST("(Gulp Missile) Cramorant in Gorging paralyzes the target if } SINGLE_BATTLE_TEST("(Gulp Missile) triggers even if the user is fainted by opposing mon") -{ - // See: https://github.com/rh-hideout/pokeemerald-expansion/issues/4143 - KNOWN_FAILING; +{ GIVEN { PLAYER(SPECIES_CRAMORANT) { HP(1); MaxHP(250); Ability(ABILITY_GULP_MISSILE); } PLAYER(SPECIES_WOBBUFFET);