fixed potential G-Max Chi Strike, Court Change bugs

This commit is contained in:
AgustinGDLV 2023-03-07 11:18:19 -08:00
parent 7c853ef45e
commit e937482c27
4 changed files with 12 additions and 5 deletions

View file

@ -677,7 +677,7 @@ struct BattleStruct
u8 battleBondTransformed[NUM_BATTLE_SIDES]; // Bitfield for each party.
u8 storedHealingWish:4; // Each battler as a bit.
u8 storedLunarDance:4; // Each battler as a bit.
u8 sideCritStages[NUM_BATTLE_SIDES]; // G-Max Chi Strike boosts crit stages of allies.
u8 bonusCritStages[MAX_BATTLERS_COUNT]; // G-Max Chi Strike boosts crit stages of allies.
};
#define F_DYNAMIC_TYPE_1 (1 << 6)

View file

@ -512,7 +512,8 @@ u16 SetMaxMoveEffect(u16 move)
effect++;
break;
case MAX_EFFECT_CRIT_PLUS:
gBattleStruct->sideCritStages[GetBattlerSide(gBattlerAttacker)]++;
gBattleStruct->bonusCritStages[gBattlerAttacker]++;
gBattleStruct->bonusCritStages[BATTLE_PARTNER(gBattlerAttacker)]++;
BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_EffectRaiseCritAlliesAnim;
effect++;

View file

@ -3166,6 +3166,9 @@ void SwitchInClearSetData(void)
gSpecialStatuses[gActiveBattler].physicalDmg = 0;
gSpecialStatuses[gActiveBattler].specialDmg = 0;
// Reset G-Max Chi Strike boosts.
gBattleStruct->bonusCritStages[gActiveBattler] = 0;
gBattleStruct->overwrittenAbilities[gActiveBattler] = ABILITY_NONE;
Ai_UpdateSwitchInData(gActiveBattler);

View file

@ -2055,7 +2055,7 @@ s32 CalcCritChanceStage(u8 battlerAtk, u8 battlerDef, u32 move, bool32 recordAbi
+ 2 * (GetBattlerFriendshipScore(gBattlerAttacker) >= FRIENDSHIP_200_TO_254)
#endif
+ (abilityAtk == ABILITY_SUPER_LUCK)
+ gBattleStruct->sideCritStages[GetBattlerSide(gBattlerAttacker)];
+ gBattleStruct->bonusCritStages[gBattlerAttacker];
if (critChance >= ARRAY_COUNT(sCriticalHitChance))
critChance = ARRAY_COUNT(sCriticalHitChance) - 1;
@ -8614,7 +8614,6 @@ static bool32 CourtChangeSwapSideStatuses(void)
u32 temp;
// TODO: add Pledge-related effects
// TODO: add Gigantamax-related effects
// Swap timers and statuses
COURTCHANGE_SWAP(SIDE_STATUS_REFLECT, reflectTimer, temp)
@ -8629,7 +8628,8 @@ static bool32 CourtChangeSwapSideStatuses(void)
COURTCHANGE_SWAP(SIDE_STATUS_STEALTH_ROCK, stealthRockAmount, temp);
COURTCHANGE_SWAP(SIDE_STATUS_TOXIC_SPIKES, toxicSpikesAmount, temp);
COURTCHANGE_SWAP(SIDE_STATUS_STICKY_WEB, stickyWebAmount, temp);
COURTCHANGE_SWAP(SIDE_STATUS_STEELSURGE, stickyWebAmount, temp);
COURTCHANGE_SWAP(SIDE_STATUS_STEELSURGE, steelsurgeAmount, temp);
COURTCHANGE_SWAP(SIDE_STATUS_DAMAGE_NON_TYPES, damageNonTypesTimer, temp);
// Change battler IDs of swapped effects. Needed for the correct string when they expire
// E.g. "Foe's Reflect wore off!"
@ -8646,6 +8646,9 @@ static bool32 CourtChangeSwapSideStatuses(void)
// Track which side originally set the Sticky Web
SWAP(sideTimerPlayer->stickyWebBattlerSide, sideTimerOpp->stickyWebBattlerSide, temp);
// Swap what type set the Gigantamax damage over time effect
SWAP(sideTimerPlayer->damageNonTypesType, sideTimerOpp->damageNonTypesType, temp);
}
static bool32 CanTeleport(u8 battlerId)