Gulp missile not triggering on faint fix and added form change type (#4502)

* Cramorant faint fix and add form change type

* Fixed formatting, renamed form change type, changed various to callnative

* Fix oops broke everything except gulp missile

* Improved condition order

* remove extra line

* whitespace and alignment

Co-authored-by: Eduardo Quezada <eduardo602002@gmail.com>

* whitespace and alignment

Co-authored-by: Eduardo Quezada <eduardo602002@gmail.com>

* whitespace and alignment

Co-authored-by: Eduardo Quezada <eduardo602002@gmail.com>

* whitespace and alignment

Co-authored-by: Eduardo Quezada <eduardo602002@gmail.com>

* whitespace and alignment

Co-authored-by: Eduardo Quezada <eduardo602002@gmail.com>

* whitespace and alignment

Co-authored-by: Eduardo Quezada <eduardo602002@gmail.com>

* Added requested changes

---------

Co-authored-by: BlueAnthem37510 <a@a.com>
Co-authored-by: Eduardo Quezada <eduardo602002@gmail.com>
This commit is contained in:
BlueAnthem37510 2024-05-07 11:44:17 +01:00 committed by GitHub
parent eca47fe209
commit 2d7c79e860
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 66 additions and 28 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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)
{

View file

@ -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;

View file

@ -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},

View file

@ -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);