Fixes Cheek Pouch mutating damage (#6466)
This commit is contained in:
parent
051adbdce2
commit
b93976c980
@ -815,7 +815,8 @@ struct BattleStruct
|
||||
u8 monCausingSleepClause[NUM_BATTLE_SIDES]; // Stores which pokemon on a given side is causing Sleep Clause to be active as the mon's index in the party
|
||||
u8 additionalEffectsCounter:4; // A counter for the additionalEffects applied by the current move in Cmd_setadditionaleffects
|
||||
u8 redCardActivates:1;
|
||||
u8 padding2:2; // padding in the middle so pursuit fields are together
|
||||
u8 cheekPouchActivated:1;
|
||||
u8 padding2:1; // padding in the middle so pursuit fields are together
|
||||
u8 pursuitStoredSwitch; // Stored id for the Pursuit target's switch
|
||||
s32 battlerExpReward;
|
||||
u16 prevTurnSpecies[MAX_BATTLERS_COUNT]; // Stores species the AI has in play at start of turn
|
||||
|
||||
@ -345,6 +345,7 @@ static u32 GetNextTarget(u32 moveTarget, bool32 excludeCurrent);
|
||||
static void TryUpdateEvolutionTracker(u32 evolutionMethod, u32 upAmount, u16 usedMove);
|
||||
static void AccuracyCheck(bool32 recalcDragonDarts, const u8 *nextInstr, const u8 *failInstr, u16 move);
|
||||
static void ResetValuesForCalledMove(void);
|
||||
static void TryRestoreDamageAfterCheeckPouch(u32 battler);
|
||||
|
||||
static void Cmd_attackcanceler(void);
|
||||
static void Cmd_accuracycheck(void);
|
||||
@ -2669,6 +2670,7 @@ static void Cmd_datahpupdate(void)
|
||||
}
|
||||
}
|
||||
|
||||
TryRestoreDamageAfterCheeckPouch(battler);
|
||||
gBattlescriptCurrInstr = cmd->nextInstr;
|
||||
}
|
||||
|
||||
@ -8929,6 +8931,8 @@ static bool32 TryCheekPouch(u32 battler, u32 itemId)
|
||||
&& gBattleStruct->ateBerry[GetBattlerSide(battler)] & (1u << gBattlerPartyIndexes[battler])
|
||||
&& !IsBattlerAtMaxHp(battler))
|
||||
{
|
||||
gBattleStruct->cheekPouchActivated = TRUE;
|
||||
gBattleScripting.savedDmg = gBattleStruct->moveDamage[battler];
|
||||
gBattleStruct->moveDamage[battler] = GetNonDynamaxMaxHP(battler) / 3;
|
||||
if (gBattleStruct->moveDamage[battler] == 0)
|
||||
gBattleStruct->moveDamage[battler] = 1;
|
||||
@ -8941,6 +8945,16 @@ static bool32 TryCheekPouch(u32 battler, u32 itemId)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// When Cheek Pouch activates mid-battle it overwrites the current damage, so restore it
|
||||
static void TryRestoreDamageAfterCheeckPouch(u32 battler)
|
||||
{
|
||||
if (gBattleStruct->cheekPouchActivated)
|
||||
{
|
||||
gBattleStruct->moveDamage[battler] = gBattleScripting.savedDmg;
|
||||
gBattleStruct->cheekPouchActivated = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// Used by Bestow and Symbiosis to take an item from one battler and give to another.
|
||||
static void BestowItem(u32 battlerAtk, u32 battlerDef)
|
||||
{
|
||||
|
||||
21
test/battle/ability/cheeck_pouch.c
Normal file
21
test/battle/ability/cheeck_pouch.c
Normal file
@ -0,0 +1,21 @@
|
||||
#include "global.h"
|
||||
#include "test/battle.h"
|
||||
|
||||
SINGLE_BATTLE_TEST("Cheek Pouch activation doesn't mutate damage when restoring HP mid battle")
|
||||
{
|
||||
s16 damage;
|
||||
s16 healing;
|
||||
|
||||
GIVEN {
|
||||
PLAYER(SPECIES_GREEDENT) { Ability(ABILITY_CHEEK_POUCH); Item(ITEM_CHOPLE_BERRY); HP(100); }
|
||||
OPPONENT(SPECIES_WOBBUFFET);
|
||||
} WHEN {
|
||||
TURN { MOVE(opponent, MOVE_KARATE_CHOP); }
|
||||
ABILITY_POPUP(player, ABILITY_CHEEK_POUCH);
|
||||
HP_BAR(player, captureDamage: &healing);
|
||||
HP_BAR(player, captureDamage: &damage);
|
||||
} THEN {
|
||||
EXPECT_LT(healing, 0);
|
||||
EXPECT_GT(damage, 0);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user