Fixes present master merge regression (#9301)

Co-authored-by: PhallenTree <168426989+PhallenTree@users.noreply.github.com>
This commit is contained in:
Alex 2026-02-23 20:46:28 +01:00 committed by GitHub
parent 81a5622b51
commit 7ba87890b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 39 deletions

View File

@ -1230,6 +1230,19 @@ static enum CancelerResult CancelerMoveFailure(struct BattleContext *ctx)
|| gBattleMons[ctx->battlerAtk].volatiles.embargo)
battleScript = BattleScript_ButItFailed;
break;
case EFFECT_PRESENT:
{
u32 rand = RandomUniform(RNG_PRESENT, 0, 0xFF);
if (rand < 102)
gBattleStruct->presentBasePower = 40;
else if (rand < 178)
gBattleStruct->presentBasePower = 80;
else if (rand < 204)
gBattleStruct->presentBasePower = 120;
else
gBattleStruct->presentBasePower = 0; // Healing
}
break;
default:
break;
}
@ -1844,6 +1857,7 @@ static bool32 IsMoveParentalBondAffected(struct BattleContext *ctx)
|| GetMoveEffect(ctx->move) == EFFECT_SEMI_INVULNERABLE
|| GetMoveEffect(ctx->move) == EFFECT_TWO_TURNS_ATTACK
|| GetActiveGimmick(ctx->battlerAtk) == GIMMICK_Z_MOVE
|| (GetMoveEffect(ctx->move) == EFFECT_PRESENT && gBattleStruct->presentBasePower == 0)
|| ctx->move == MOVE_STRUGGLE)
return FALSE;
return TRUE;

View File

@ -9191,46 +9191,10 @@ static void Cmd_presentdamagecalculation(void)
{
CMD_ARGS();
u32 rand = RandomUniform(RNG_PRESENT, 0, 0xFF);
/* Don't reroll present effect/power for the second hit of Parental Bond.
* Not sure if this is the correct behaviour, but bulbapedia states
* that if present heals the foe, it doesn't strike twice, and if it deals
* damage, the second strike will always deal damage too. This is a simple way
* to replicate that effect.
*/
if (gSpecialStatuses[gBattlerAttacker].parentalBondState != PARENTAL_BOND_2ND_HIT)
{
if (rand < 102)
{
gBattleStruct->presentBasePower = 40;
}
else if (rand < 178)
{
gBattleStruct->presentBasePower = 80;
}
else if (rand < 204)
{
gBattleStruct->presentBasePower = 120;
}
else
{
gSpecialStatuses[gBattlerAttacker].parentalBondState = PARENTAL_BOND_OFF;
gSpecialStatuses[gBattlerAttacker].multiHitOn = 0;
gMultiHitCounter = 0;
SetHealAmount(gBattlerTarget, GetNonDynamaxMaxHP(gBattlerTarget) / 4);
gBattleStruct->presentBasePower = 0;
}
}
if (gBattleStruct->presentBasePower)
{
gBattlescriptCurrInstr = BattleScript_HitFromDamageCalc;
}
else if (gBattlerTarget == BATTLE_PARTNER(gBattlerAttacker) && GetBattlerAbility(gBattlerTarget) == ABILITY_TELEPATHY)
{
gBattlescriptCurrInstr = BattleScript_MoveMissedPause;
}
else if (gBattleMons[gBattlerTarget].maxHP == gBattleMons[gBattlerTarget].hp)
{
gBattlescriptCurrInstr = BattleScript_AlreadyAtFullHp;
@ -9238,6 +9202,7 @@ static void Cmd_presentdamagecalculation(void)
else
{
gBattleStruct->moveResultFlags[gBattlerTarget] &= ~(MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE);
SetHealAmount(gBattlerTarget, GetNonDynamaxMaxHP(gBattlerTarget) / 4);
gBattlescriptCurrInstr = BattleScript_PresentHealTarget;
}
}

View File

@ -8277,7 +8277,9 @@ static inline uq4_12_t CalcTypeEffectivenessMultiplierInternal(struct BattleCont
if (ctx->updateFlags && (illusionSpecies = GetIllusionMonSpecies(ctx->battlerDef)))
TryNoticeIllusionInTypeEffectiveness(ctx->move, ctx->moveType, ctx->battlerAtk, ctx->battlerDef, modifier, illusionSpecies);
if (GetMoveCategory(ctx->move) == DAMAGE_CATEGORY_STATUS && ctx->move != MOVE_THUNDER_WAVE)
bool32 isPresentHealing = GetMoveEffect(ctx->move) == EFFECT_PRESENT && gBattleStruct->presentBasePower == 0;
bool32 ignoreTypeCalc = isPresentHealing || GetMoveCategory(ctx->move) == DAMAGE_CATEGORY_STATUS;
if (ignoreTypeCalc && ctx->move != MOVE_THUNDER_WAVE)
{
modifier = UQ_4_12(1.0);
if (B_GLARE_GHOST < GEN_4 && ctx->move == MOVE_GLARE && IS_BATTLER_OF_TYPE(ctx->battlerDef, TYPE_GHOST))
@ -8322,7 +8324,7 @@ static inline uq4_12_t CalcTypeEffectivenessMultiplierInternal(struct BattleCont
modifier = UQ_4_12(1.0);
}
if (((ctx->abilityDef == ABILITY_WONDER_GUARD && modifier <= UQ_4_12(1.0))
if (((ctx->abilityDef == ABILITY_WONDER_GUARD && modifier <= UQ_4_12(1.0) && !isPresentHealing)
|| (ctx->abilityDef == ABILITY_TELEPATHY && ctx->battlerDef == BATTLE_PARTNER(ctx->battlerAtk)))
&& GetMovePower(ctx->move) != 0)
{

View File

@ -8,7 +8,6 @@ ASSUMPTIONS
SINGLE_BATTLE_TEST("Present healing through Wonder Guard is still considered to have affected the target")
{
KNOWN_FAILING;
GIVEN {
ASSUME(GetMoveEffect(MOVE_MIRROR_MOVE) == EFFECT_MIRROR_MOVE);
PLAYER(SPECIES_WOBBUFFET);