mirror of
https://github.com/pret/pokeemerald.git
synced 2026-04-25 07:38:49 -05:00
Renames for struct BattleContext and DamageContext (#8426)
This commit is contained in:
parent
6615310279
commit
0fd0e50d8a
|
|
@ -95,9 +95,9 @@ void SwapTurnOrder(u8 id1, u8 id2);
|
|||
u32 GetBattlerTotalSpeedStat(u32 battler, enum Ability ability, enum HoldEffect holdEffect);
|
||||
s32 GetChosenMovePriority(u32 battler, enum Ability ability);
|
||||
s32 GetBattleMovePriority(u32 battler, enum Ability ability, u32 move);
|
||||
s32 GetWhichBattlerFasterArgs(struct BattleContext *ctx, bool32 ignoreChosenMoves, u32 speedBattler1, u32 speedBattler2, s32 priority1, s32 priority2);
|
||||
s32 GetWhichBattlerFasterOrTies(struct BattleContext *ctx, bool32 ignoreChosenMoves);
|
||||
s32 GetWhichBattlerFaster(struct BattleContext *ctx, bool32 ignoreChosenMoves);
|
||||
s32 GetWhichBattlerFasterArgs(struct BattleCalcValues *calcValues, bool32 ignoreChosenMoves, u32 speedBattler1, u32 speedBattler2, s32 priority1, s32 priority2);
|
||||
s32 GetWhichBattlerFasterOrTies(struct BattleCalcValues *calcValues, bool32 ignoreChosenMoves);
|
||||
s32 GetWhichBattlerFaster(struct BattleCalcValues *calcValues, bool32 ignoreChosenMoves);
|
||||
void RunBattleScriptCommands_PopCallbacksStack(void);
|
||||
void RunBattleScriptCommands(void);
|
||||
enum Type GetDynamicMoveType(struct Pokemon *mon, u32 move, u32 battler, enum MonState monInBattle);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ bool32 CanTerastallize(u32 battler);
|
|||
enum Type GetBattlerTeraType(u32 battler);
|
||||
void ExpendTypeStellarBoost(u32 battler, enum Type type);
|
||||
bool32 IsTypeStellarBoosted(u32 battler, enum Type type);
|
||||
uq4_12_t GetTeraMultiplier(struct DamageContext *ctx);
|
||||
uq4_12_t GetTeraMultiplier(struct BattleContext *ctx);
|
||||
|
||||
u16 GetTeraTypeRGB(enum Type type);
|
||||
|
||||
|
|
|
|||
|
|
@ -156,36 +156,41 @@ enum MoveCanceler
|
|||
|
||||
extern const struct TypePower gNaturalGiftTable[];
|
||||
|
||||
struct DamageContext
|
||||
struct BattleContext
|
||||
{
|
||||
u32 battlerAtk:3;
|
||||
u32 battlerDef:3;
|
||||
u32 move:16;
|
||||
enum Type moveType:5;
|
||||
u32 isCrit:1;
|
||||
u32 randomFactor:1;
|
||||
u32 updateFlags:1;
|
||||
u32 isAnticipation:1;
|
||||
u32 isSelfInflicted:1;
|
||||
u32 weather:16;
|
||||
u32 fixedBasePower:8;
|
||||
u32 aiCalc:1;
|
||||
u32 aiCheckBerryModifier:1; // Flags that KOing through a berry should be checked
|
||||
u32 padding2:6;
|
||||
u32 chosenMove:16; // May be different to 'move', e.g. for Z moves.
|
||||
u32 padding3:16;
|
||||
u32 weather:16;
|
||||
u32 unused:2;
|
||||
|
||||
u32 move:13;
|
||||
u32 chosenMove:13; // May be different to 'move', e.g. for Z moves.
|
||||
enum Type moveType:6;
|
||||
|
||||
uq4_12_t typeEffectivenessModifier;
|
||||
enum Ability abilityAtk;
|
||||
enum Ability abilityDef;
|
||||
enum HoldEffect holdEffectAtk;
|
||||
enum HoldEffect holdEffectDef;
|
||||
|
||||
// Flags
|
||||
u32 isCrit:1;
|
||||
u32 randomFactor:1;
|
||||
u32 updateFlags:1;
|
||||
u32 isAnticipation:1;
|
||||
u32 isSelfInflicted:1;
|
||||
u32 aiCalc:1;
|
||||
u32 aiCheckBerryModifier:1; // Flags that KOing through a berry should be checked
|
||||
u32 padding:25;
|
||||
};
|
||||
|
||||
struct BattleContext
|
||||
// Helper struct to keep the arg list small and prevent constant recalculations of abilities/hold effects.
|
||||
struct BattleCalcValues
|
||||
{
|
||||
u32 battlerAtk:3;
|
||||
u32 battlerDef:3;
|
||||
u32 currentMove:16;
|
||||
u32 move:16;
|
||||
u32 padding:10;
|
||||
enum Ability abilities[MAX_BATTLERS_COUNT];
|
||||
enum HoldEffect holdEffects[MAX_BATTLERS_COUNT];
|
||||
|
|
@ -301,13 +306,13 @@ bool32 IsMoveMakingContact(u32 battlerAtk, u32 battlerDef, enum Ability abilityA
|
|||
bool32 IsBattlerGrounded(u32 battler, enum Ability ability, enum HoldEffect holdEffect);
|
||||
u32 GetMoveSlot(u16 *moves, u32 move);
|
||||
u32 GetBattlerWeight(u32 battler);
|
||||
s32 CalcCritChanceStage(struct DamageContext *ctx);
|
||||
s32 CalcCritChanceStageGen1(struct DamageContext *ctx);
|
||||
s32 CalculateMoveDamage(struct DamageContext *ctx);
|
||||
s32 CalculateMoveDamageVars(struct DamageContext *ctx);
|
||||
s32 DoFixedDamageMoveCalc(struct DamageContext *ctx);
|
||||
s32 ApplyModifiersAfterDmgRoll(struct DamageContext *ctx, s32 dmg);
|
||||
uq4_12_t CalcTypeEffectivenessMultiplier(struct DamageContext *ctx);
|
||||
s32 CalcCritChanceStage(struct BattleContext *ctx);
|
||||
s32 CalcCritChanceStageGen1(struct BattleContext *ctx);
|
||||
s32 CalculateMoveDamage(struct BattleContext *ctx);
|
||||
s32 CalculateMoveDamageVars(struct BattleContext *ctx);
|
||||
s32 DoFixedDamageMoveCalc(struct BattleContext *ctx);
|
||||
s32 ApplyModifiersAfterDmgRoll(struct BattleContext *ctx, s32 dmg);
|
||||
uq4_12_t CalcTypeEffectivenessMultiplier(struct BattleContext *ctx);
|
||||
uq4_12_t CalcPartyMonTypeEffectivenessMultiplier(u16 move, u16 speciesDef, enum Ability abilityDef);
|
||||
uq4_12_t GetTypeModifier(enum Type atkType, enum Type defType);
|
||||
uq4_12_t GetOverworldTypeEffectiveness(struct Pokemon *mon, enum Type moveType);
|
||||
|
|
|
|||
|
|
@ -3025,15 +3025,15 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
|
|||
|
||||
static s32 AI_GetWhichBattlerFasterOrTies(u32 battlerAtk, u32 battlerDef, bool32 ignoreChosenMoves)
|
||||
{
|
||||
struct BattleContext ctx = {0};
|
||||
ctx.battlerAtk = battlerAtk;
|
||||
ctx.battlerDef = battlerDef;
|
||||
ctx.abilities[battlerAtk] = gAiLogicData->abilities[battlerAtk];
|
||||
ctx.abilities[battlerDef] = gAiLogicData->abilities[battlerDef];
|
||||
ctx.holdEffects[battlerAtk] = gAiLogicData->holdEffects[battlerAtk];
|
||||
ctx.holdEffects[battlerDef] = gAiLogicData->holdEffects[battlerDef];
|
||||
struct BattleCalcValues calcValues = {0};
|
||||
calcValues.battlerAtk = battlerAtk;
|
||||
calcValues.battlerDef = battlerDef;
|
||||
calcValues.abilities[battlerAtk] = gAiLogicData->abilities[battlerAtk];
|
||||
calcValues.abilities[battlerDef] = gAiLogicData->abilities[battlerDef];
|
||||
calcValues.holdEffects[battlerAtk] = gAiLogicData->holdEffects[battlerAtk];
|
||||
calcValues.holdEffects[battlerDef] = gAiLogicData->holdEffects[battlerDef];
|
||||
|
||||
return GetWhichBattlerFasterOrTies(&ctx, ignoreChosenMoves);
|
||||
return GetWhichBattlerFasterOrTies(&calcValues, ignoreChosenMoves);
|
||||
}
|
||||
|
||||
static s32 AI_TryToFaint(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
|
||||
|
|
|
|||
|
|
@ -567,7 +567,7 @@ bool32 MovesWithCategoryUnusable(u32 attacker, u32 target, enum DamageCategory c
|
|||
u16 *moves = GetMovesArray(attacker);
|
||||
u32 moveLimitations = gAiLogicData->moveLimitations[attacker];
|
||||
|
||||
struct DamageContext ctx = {0};
|
||||
struct BattleContext ctx = {0};
|
||||
ctx.battlerAtk = attacker;
|
||||
ctx.battlerDef = target;
|
||||
ctx.updateFlags = FALSE;
|
||||
|
|
@ -631,7 +631,7 @@ static inline s32 DmgRoll(s32 dmg)
|
|||
return dmg;
|
||||
}
|
||||
|
||||
bool32 IsDamageMoveUnusable(struct DamageContext *ctx)
|
||||
bool32 IsDamageMoveUnusable(struct BattleContext *ctx)
|
||||
{
|
||||
enum Ability battlerDefAbility;
|
||||
enum Ability partnerDefAbility;
|
||||
|
|
@ -758,7 +758,7 @@ static inline void AI_RestoreBattlerTypes(u32 battlerAtk, enum Type *types)
|
|||
gBattleMons[battlerAtk].types[2] = types[2];
|
||||
}
|
||||
|
||||
static inline void CalcDynamicMoveDamage(struct DamageContext *ctx, u16 *medianDamage, u16 *minimumDamage, u16 *maximumDamage)
|
||||
static inline void CalcDynamicMoveDamage(struct BattleContext *ctx, u16 *medianDamage, u16 *minimumDamage, u16 *maximumDamage)
|
||||
{
|
||||
enum BattleMoveEffects effect = GetMoveEffect(ctx->move);
|
||||
u16 median = *medianDamage;
|
||||
|
|
@ -839,7 +839,7 @@ static inline void CalcDynamicMoveDamage(struct DamageContext *ctx, u16 *medianD
|
|||
*maximumDamage = maximum;
|
||||
}
|
||||
|
||||
static inline bool32 ShouldCalcCritDamage(struct DamageContext *ctx)
|
||||
static inline bool32 ShouldCalcCritDamage(struct BattleContext *ctx)
|
||||
{
|
||||
s32 critChanceIndex = 0;
|
||||
|
||||
|
|
@ -863,7 +863,7 @@ static inline bool32 ShouldCalcCritDamage(struct DamageContext *ctx)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static s32 HandleKOThroughBerryReduction(struct DamageContext *ctx, s32 dmg)
|
||||
static s32 HandleKOThroughBerryReduction(struct BattleContext *ctx, s32 dmg)
|
||||
{
|
||||
if (ctx->aiCheckBerryModifier) // Only set if AI running calcs
|
||||
{
|
||||
|
|
@ -897,7 +897,7 @@ static s32 HandleKOThroughBerryReduction(struct DamageContext *ctx, s32 dmg)
|
|||
return dmg;
|
||||
}
|
||||
|
||||
static s32 AI_ApplyModifiersAfterDmgRoll(struct DamageContext *ctx, s32 dmg)
|
||||
static s32 AI_ApplyModifiersAfterDmgRoll(struct BattleContext *ctx, s32 dmg)
|
||||
{
|
||||
dmg = ApplyModifiersAfterDmgRoll(ctx, dmg);
|
||||
dmg = HandleKOThroughBerryReduction(ctx, dmg);
|
||||
|
|
@ -938,7 +938,7 @@ struct SimulatedDamage AI_CalcDamage(u32 move, u32 battlerAtk, u32 battlerDef, u
|
|||
gBattleStruct->magnitudeBasePower = 70;
|
||||
gBattleStruct->presentBasePower = 80;
|
||||
|
||||
struct DamageContext ctx = {0};
|
||||
struct BattleContext ctx = {0};
|
||||
ctx.aiCalc = TRUE;
|
||||
ctx.aiCheckBerryModifier = FALSE;
|
||||
ctx.battlerAtk = battlerAtk;
|
||||
|
|
@ -1399,7 +1399,7 @@ uq4_12_t AI_GetMoveEffectiveness(u32 move, u32 battlerAtk, u32 battlerDef)
|
|||
|
||||
gBattleStruct->dynamicMoveType = 0;
|
||||
SetTypeBeforeUsingMove(move, battlerAtk);
|
||||
struct DamageContext ctx = {0};
|
||||
struct BattleContext ctx = {0};
|
||||
ctx.battlerAtk = battlerAtk;
|
||||
ctx.battlerDef = battlerDef;
|
||||
ctx.move = ctx.chosenMove = move;
|
||||
|
|
|
|||
|
|
@ -2365,7 +2365,7 @@ static bool32 ShouldShowTypeEffectiveness(u32 targetId)
|
|||
static u32 CheckTypeEffectiveness(u32 battlerAtk, u32 battlerDef)
|
||||
{
|
||||
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[battlerAtk][4]);
|
||||
struct DamageContext ctx = {0};
|
||||
struct BattleContext ctx = {0};
|
||||
ctx.battlerAtk = battlerAtk;
|
||||
ctx.battlerDef = battlerDef;
|
||||
ctx.move = moveInfo->moves[gMoveSelectionCursor[battlerAtk]];
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ static void SetActionsAndBattlersTurnOrder(void);
|
|||
static void UpdateBattlerPartyOrdersOnSwitch(u32 battler);
|
||||
static bool8 AllAtActionConfirmed(void);
|
||||
static void TryChangeTurnOrder(void);
|
||||
static void TryChangingTurnOrderEffects(struct BattleContext *ctx, u32 *quickClawRandom, u32 *quickDrawRandom);
|
||||
static void TryChangingTurnOrderEffects(struct BattleCalcValues *calcValues, u32 *quickClawRandom, u32 *quickDrawRandom);
|
||||
static void CheckChangingTurnOrderEffects(void);
|
||||
static void FreeResetData_ReturnToOvOrDoEvolutions(void);
|
||||
static void ReturnFromBattleToOverworld(void);
|
||||
|
|
@ -4786,7 +4786,7 @@ s32 GetBattleMovePriority(u32 battler, enum Ability ability, u32 move)
|
|||
return priority;
|
||||
}
|
||||
|
||||
s32 GetWhichBattlerFasterArgs(struct BattleContext *ctx, bool32 ignoreChosenMoves, u32 speedBattler1, u32 speedBattler2, s32 priority1, s32 priority2)
|
||||
s32 GetWhichBattlerFasterArgs(struct BattleCalcValues *calcValues, bool32 ignoreChosenMoves, u32 speedBattler1, u32 speedBattler2, s32 priority1, s32 priority2)
|
||||
{
|
||||
u32 strikesFirst = 0;
|
||||
|
||||
|
|
@ -4795,18 +4795,18 @@ s32 GetWhichBattlerFasterArgs(struct BattleContext *ctx, bool32 ignoreChosenMove
|
|||
// Quick Claw / Quick Draw / Custap Berry - always first
|
||||
// Stall / Mycelium Might - last but before Lagging Tail
|
||||
// Lagging Tail - always last
|
||||
bool32 battler1HasQuickEffect = gProtectStructs[ctx->battlerAtk].quickDraw || gProtectStructs[ctx->battlerAtk].usedCustapBerry;
|
||||
bool32 battler2HasQuickEffect = gProtectStructs[ctx->battlerDef].quickDraw || gProtectStructs[ctx->battlerDef].usedCustapBerry;
|
||||
bool32 battler1HasStallingAbility = ctx->abilities[ctx->battlerAtk] == ABILITY_STALL || gProtectStructs[ctx->battlerAtk].myceliumMight;
|
||||
bool32 battler2HasStallingAbility = ctx->abilities[ctx->battlerDef] == ABILITY_STALL || gProtectStructs[ctx->battlerDef].myceliumMight;
|
||||
bool32 battler1HasQuickEffect = gProtectStructs[calcValues->battlerAtk].quickDraw || gProtectStructs[calcValues->battlerAtk].usedCustapBerry;
|
||||
bool32 battler2HasQuickEffect = gProtectStructs[calcValues->battlerDef].quickDraw || gProtectStructs[calcValues->battlerDef].usedCustapBerry;
|
||||
bool32 battler1HasStallingAbility = calcValues->abilities[calcValues->battlerAtk] == ABILITY_STALL || gProtectStructs[calcValues->battlerAtk].myceliumMight;
|
||||
bool32 battler2HasStallingAbility = calcValues->abilities[calcValues->battlerDef] == ABILITY_STALL || gProtectStructs[calcValues->battlerDef].myceliumMight;
|
||||
|
||||
if (battler1HasQuickEffect && !battler2HasQuickEffect)
|
||||
strikesFirst = 1;
|
||||
else if (battler2HasQuickEffect && !battler1HasQuickEffect)
|
||||
strikesFirst = -1;
|
||||
else if (gProtectStructs[ctx->battlerAtk].laggingTail && !gProtectStructs[ctx->battlerDef].laggingTail)
|
||||
else if (gProtectStructs[calcValues->battlerAtk].laggingTail && !gProtectStructs[calcValues->battlerDef].laggingTail)
|
||||
strikesFirst = -1;
|
||||
else if (gProtectStructs[ctx->battlerDef].laggingTail && !gProtectStructs[ctx->battlerAtk].laggingTail)
|
||||
else if (gProtectStructs[calcValues->battlerDef].laggingTail && !gProtectStructs[calcValues->battlerAtk].laggingTail)
|
||||
strikesFirst = 1;
|
||||
else if (battler1HasStallingAbility && !battler2HasStallingAbility)
|
||||
strikesFirst = -1;
|
||||
|
|
@ -4848,22 +4848,22 @@ s32 GetWhichBattlerFasterArgs(struct BattleContext *ctx, bool32 ignoreChosenMove
|
|||
return strikesFirst;
|
||||
}
|
||||
|
||||
s32 GetWhichBattlerFasterOrTies(struct BattleContext *ctx, bool32 ignoreChosenMoves)
|
||||
s32 GetWhichBattlerFasterOrTies(struct BattleCalcValues *calcValues, bool32 ignoreChosenMoves)
|
||||
{
|
||||
s32 priority1 = 0, priority2 = 0;
|
||||
u32 speedBattler1 = GetBattlerTotalSpeedStat(ctx->battlerAtk, ctx->abilities[ctx->battlerAtk], ctx->holdEffects[ctx->battlerAtk]);
|
||||
u32 speedBattler2 = GetBattlerTotalSpeedStat(ctx->battlerDef, ctx->abilities[ctx->battlerDef], ctx->holdEffects[ctx->battlerDef]);
|
||||
u32 speedBattler1 = GetBattlerTotalSpeedStat(calcValues->battlerAtk, calcValues->abilities[calcValues->battlerAtk], calcValues->holdEffects[calcValues->battlerAtk]);
|
||||
u32 speedBattler2 = GetBattlerTotalSpeedStat(calcValues->battlerDef, calcValues->abilities[calcValues->battlerDef], calcValues->holdEffects[calcValues->battlerDef]);
|
||||
|
||||
if (!ignoreChosenMoves)
|
||||
{
|
||||
if (gChosenActionByBattler[ctx->battlerAtk] == B_ACTION_USE_MOVE)
|
||||
priority1 = GetChosenMovePriority(ctx->battlerAtk, ctx->abilities[ctx->battlerAtk]);
|
||||
if (gChosenActionByBattler[ctx->battlerDef] == B_ACTION_USE_MOVE)
|
||||
priority2 = GetChosenMovePriority(ctx->battlerDef, ctx->abilities[ctx->battlerDef]);
|
||||
if (gChosenActionByBattler[calcValues->battlerAtk] == B_ACTION_USE_MOVE)
|
||||
priority1 = GetChosenMovePriority(calcValues->battlerAtk, calcValues->abilities[calcValues->battlerAtk]);
|
||||
if (gChosenActionByBattler[calcValues->battlerDef] == B_ACTION_USE_MOVE)
|
||||
priority2 = GetChosenMovePriority(calcValues->battlerDef, calcValues->abilities[calcValues->battlerDef]);
|
||||
}
|
||||
|
||||
return GetWhichBattlerFasterArgs(
|
||||
ctx,
|
||||
calcValues,
|
||||
ignoreChosenMoves,
|
||||
speedBattler1,
|
||||
speedBattler2,
|
||||
|
|
@ -4902,13 +4902,13 @@ static const u8 sBattlerOrders[24][4] =
|
|||
{ 3, 2, 1, 0 },
|
||||
};
|
||||
|
||||
s32 GetWhichBattlerFaster(struct BattleContext *ctx, bool32 ignoreChosenMoves)
|
||||
s32 GetWhichBattlerFaster(struct BattleCalcValues *calcValues, bool32 ignoreChosenMoves)
|
||||
{
|
||||
s32 strikesFirst = GetWhichBattlerFasterOrTies(ctx, ignoreChosenMoves);
|
||||
s32 strikesFirst = GetWhichBattlerFasterOrTies(calcValues, ignoreChosenMoves);
|
||||
if (strikesFirst == 0)
|
||||
{
|
||||
s32 order1 = sBattlerOrders[gBattleStruct->speedTieBreaks][ctx->battlerAtk];
|
||||
s32 order2 = sBattlerOrders[gBattleStruct->speedTieBreaks][ctx->battlerDef];
|
||||
s32 order1 = sBattlerOrders[gBattleStruct->speedTieBreaks][calcValues->battlerAtk];
|
||||
s32 order2 = sBattlerOrders[gBattleStruct->speedTieBreaks][calcValues->battlerDef];
|
||||
if (order1 < order2)
|
||||
strikesFirst = 1;
|
||||
else
|
||||
|
|
@ -5002,19 +5002,19 @@ static void SetActionsAndBattlersTurnOrder(void)
|
|||
turnOrderId++;
|
||||
}
|
||||
}
|
||||
struct BattleContext ctx = {0};
|
||||
struct BattleCalcValues calcValues = {0};
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
ctx.abilities[i] = GetBattlerAbility(i);
|
||||
ctx.holdEffects[i] = GetBattlerHoldEffect(i);
|
||||
calcValues.abilities[i] = GetBattlerAbility(i);
|
||||
calcValues.holdEffects[i] = GetBattlerHoldEffect(i);
|
||||
}
|
||||
for (i = 0; i < gBattlersCount - 1; i++)
|
||||
{
|
||||
for (j = i + 1; j < gBattlersCount; j++)
|
||||
{
|
||||
ctx.battlerAtk = gBattlerByTurnOrder[i];
|
||||
ctx.battlerDef = gBattlerByTurnOrder[j];
|
||||
TryChangingTurnOrderEffects(&ctx, quickClawRandom, quickDrawRandom);
|
||||
calcValues.battlerAtk = gBattlerByTurnOrder[i];
|
||||
calcValues.battlerDef = gBattlerByTurnOrder[j];
|
||||
TryChangingTurnOrderEffects(&calcValues, quickClawRandom, quickDrawRandom);
|
||||
if (gActionsByTurnOrder[i] != B_ACTION_USE_ITEM
|
||||
&& gActionsByTurnOrder[j] != B_ACTION_USE_ITEM
|
||||
&& gActionsByTurnOrder[i] != B_ACTION_SWITCH
|
||||
|
|
@ -5022,7 +5022,7 @@ static void SetActionsAndBattlersTurnOrder(void)
|
|||
&& gActionsByTurnOrder[i] != B_ACTION_THROW_BALL
|
||||
&& gActionsByTurnOrder[j] != B_ACTION_THROW_BALL)
|
||||
{
|
||||
if (GetWhichBattlerFaster(&ctx, FALSE) == -1)
|
||||
if (GetWhichBattlerFaster(&calcValues, FALSE) == -1)
|
||||
SwapTurnOrder(i, j);
|
||||
}
|
||||
}
|
||||
|
|
@ -5171,37 +5171,37 @@ static void TryChangeTurnOrder(void)
|
|||
{
|
||||
u32 i, j;
|
||||
|
||||
struct BattleContext ctx = {0};
|
||||
struct BattleCalcValues calcValues = {0};
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
ctx.abilities[i] = GetBattlerAbility(i);
|
||||
ctx.holdEffects[i] = GetBattlerHoldEffect(i);
|
||||
calcValues.abilities[i] = GetBattlerAbility(i);
|
||||
calcValues.holdEffects[i] = GetBattlerHoldEffect(i);
|
||||
}
|
||||
for (i = gCurrentTurnActionNumber; i < gBattlersCount - 1; i++)
|
||||
{
|
||||
for (j = i + 1; j < gBattlersCount; j++)
|
||||
{
|
||||
ctx.battlerAtk = gBattlerByTurnOrder[i];
|
||||
ctx.battlerDef = gBattlerByTurnOrder[j];
|
||||
calcValues.battlerAtk = gBattlerByTurnOrder[i];
|
||||
calcValues.battlerDef = gBattlerByTurnOrder[j];
|
||||
|
||||
if (gActionsByTurnOrder[i] == B_ACTION_USE_MOVE
|
||||
&& gActionsByTurnOrder[j] == B_ACTION_USE_MOVE)
|
||||
{
|
||||
if (GetWhichBattlerFaster(&ctx, FALSE) == -1)
|
||||
if (GetWhichBattlerFaster(&calcValues, FALSE) == -1)
|
||||
SwapTurnOrder(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void TryChangingTurnOrderEffects(struct BattleContext *ctx, u32 *quickClawRandom, u32 *quickDrawRandom)
|
||||
static void TryChangingTurnOrderEffects(struct BattleCalcValues *calcValues, u32 *quickClawRandom, u32 *quickDrawRandom)
|
||||
{
|
||||
u32 battler1 = ctx->battlerAtk;
|
||||
u32 battler2 = ctx->battlerDef;
|
||||
enum Ability ability1 = ctx->abilities[ctx->battlerAtk];
|
||||
enum Ability ability2 = ctx->abilities[ctx->battlerDef];
|
||||
enum HoldEffect holdEffectBattler1 = ctx->holdEffects[ctx->battlerAtk];
|
||||
enum HoldEffect holdEffectBattler2 = ctx->holdEffects[ctx->battlerDef];
|
||||
u32 battler1 = calcValues->battlerAtk;
|
||||
u32 battler2 = calcValues->battlerDef;
|
||||
enum Ability ability1 = calcValues->abilities[calcValues->battlerAtk];
|
||||
enum Ability ability2 = calcValues->abilities[calcValues->battlerDef];
|
||||
enum HoldEffect holdEffectBattler1 = calcValues->holdEffects[calcValues->battlerAtk];
|
||||
enum HoldEffect holdEffectBattler2 = calcValues->holdEffects[calcValues->battlerDef];
|
||||
|
||||
// Battler 1
|
||||
// Quick Draw
|
||||
|
|
|
|||
|
|
@ -1120,9 +1120,9 @@ u32 NumFaintedBattlersByAttacker(u32 battlerAtk)
|
|||
|
||||
bool32 IsPowderMoveBlocked(struct BattleContext *ctx)
|
||||
{
|
||||
if (!IsPowderMove(ctx->currentMove)
|
||||
if (!IsPowderMove(ctx->move)
|
||||
|| ctx->battlerAtk == ctx->battlerDef
|
||||
|| IsAffectedByPowderMove(ctx->battlerDef, ctx->abilities[ctx->battlerDef], GetBattlerHoldEffect(ctx->battlerDef)))
|
||||
|| IsAffectedByPowderMove(ctx->battlerDef, ctx->abilityDef, GetBattlerHoldEffect(ctx->battlerDef)))
|
||||
return FALSE;
|
||||
|
||||
gBattlescriptCurrInstr = BattleScript_PowderMoveNoEffect;
|
||||
|
|
@ -1158,9 +1158,10 @@ static void Cmd_attackcanceler(void)
|
|||
struct BattleContext ctx = {0};
|
||||
ctx.battlerAtk = gBattlerAttacker;
|
||||
ctx.battlerDef = gBattlerTarget;
|
||||
ctx.currentMove = gCurrentMove;
|
||||
ctx.move = gCurrentMove;
|
||||
ctx.chosenMove = gChosenMove;
|
||||
|
||||
enum BattleMoveEffects moveEffect = GetMoveEffect(ctx.currentMove);
|
||||
enum BattleMoveEffects moveEffect = GetMoveEffect(ctx.move);
|
||||
|
||||
if (!IsBattlerAlive(gBattlerAttacker) && !IsExplosionEffect(moveEffect))
|
||||
{
|
||||
|
|
@ -1169,15 +1170,14 @@ static void Cmd_attackcanceler(void)
|
|||
return;
|
||||
}
|
||||
|
||||
// With how attackcanceler works right now we only need attacker and target abilities. Might change in the future
|
||||
ctx.abilities[ctx.battlerAtk] = GetBattlerAbility(ctx.battlerAtk);
|
||||
ctx.abilities[ctx.battlerDef] = GetBattlerAbility(ctx.battlerDef);
|
||||
ctx.abilityAtk = GetBattlerAbility(ctx.battlerAtk);
|
||||
ctx.abilityDef = GetBattlerAbility(ctx.battlerDef);
|
||||
|
||||
if (AtkCanceler_MoveSuccessOrder(&ctx) != MOVE_STEP_SUCCESS)
|
||||
return;
|
||||
|
||||
if (gSpecialStatuses[gBattlerAttacker].parentalBondState == PARENTAL_BOND_OFF
|
||||
&& ctx.abilities[ctx.battlerAtk] == ABILITY_PARENTAL_BOND
|
||||
&& ctx.abilityAtk == ABILITY_PARENTAL_BOND
|
||||
&& IsMoveAffectedByParentalBond(gCurrentMove, gBattlerAttacker)
|
||||
&& !(gAbsentBattlerFlags & (1u << gBattlerTarget))
|
||||
&& GetActiveGimmick(gBattlerAttacker) != GIMMICK_Z_MOVE)
|
||||
|
|
@ -1191,20 +1191,20 @@ static void Cmd_attackcanceler(void)
|
|||
if (CanAbilityBlockMove(
|
||||
ctx.battlerAtk,
|
||||
ctx.battlerDef,
|
||||
ctx.abilities[ctx.battlerAtk],
|
||||
ctx.abilities[ctx.battlerDef],
|
||||
ctx.currentMove,
|
||||
ctx.abilityAtk,
|
||||
ctx.abilityDef,
|
||||
ctx.move,
|
||||
RUN_SCRIPT))
|
||||
return;
|
||||
|
||||
if (GetMoveNonVolatileStatus(ctx.currentMove) == MOVE_EFFECT_PARALYSIS)
|
||||
if (GetMoveNonVolatileStatus(ctx.move) == MOVE_EFFECT_PARALYSIS)
|
||||
{
|
||||
if (CanAbilityAbsorbMove(
|
||||
ctx.battlerAtk,
|
||||
ctx.battlerDef,
|
||||
ctx.abilities[ctx.battlerDef],
|
||||
ctx.currentMove,
|
||||
GetBattleMoveType(ctx.currentMove),
|
||||
ctx.abilityDef,
|
||||
ctx.move,
|
||||
GetBattleMoveType(ctx.move),
|
||||
RUN_SCRIPT))
|
||||
return;
|
||||
}
|
||||
|
|
@ -1274,7 +1274,7 @@ static void Cmd_attackcanceler(void)
|
|||
{
|
||||
u32 battler = gBattlerTarget;
|
||||
|
||||
if (ctx.abilities[ctx.battlerDef] == ABILITY_MAGIC_BOUNCE)
|
||||
if (ctx.abilityDef == ABILITY_MAGIC_BOUNCE)
|
||||
{
|
||||
battler = gBattlerTarget;
|
||||
gBattleStruct->bouncedMoveIsUsed = TRUE;
|
||||
|
|
@ -1525,7 +1525,7 @@ static void AccuracyCheck(bool32 recalcDragonDarts, const u8 *nextInstr, const u
|
|||
|
||||
if (GetMovePower(move) != 0)
|
||||
{
|
||||
struct DamageContext ctx = {0};
|
||||
struct BattleContext ctx = {0};
|
||||
ctx.battlerAtk = gBattlerAttacker;
|
||||
ctx.battlerDef = battlerDef;
|
||||
ctx.move = move;
|
||||
|
|
@ -1589,7 +1589,7 @@ static void Cmd_critcalc(void)
|
|||
gBattlescriptCurrInstr = cmd->nextInstr;
|
||||
}
|
||||
|
||||
static inline void CalculateAndSetMoveDamage(struct DamageContext *ctx)
|
||||
static inline void CalculateAndSetMoveDamage(struct BattleContext *ctx)
|
||||
{
|
||||
SetDynamicMoveCategory(gBattlerAttacker, ctx->battlerDef, gCurrentMove);
|
||||
ctx->isCrit = gSpecialStatuses[ctx->battlerDef].criticalHit;
|
||||
|
|
@ -1616,7 +1616,7 @@ static void Cmd_damagecalc(void)
|
|||
|
||||
u32 moveTarget = GetBattlerMoveTargetType(gBattlerAttacker, gCurrentMove);
|
||||
|
||||
struct DamageContext ctx = {0};
|
||||
struct BattleContext ctx = {0};
|
||||
ctx.battlerAtk = gBattlerAttacker;
|
||||
ctx.move = gCurrentMove;
|
||||
ctx.chosenMove = gChosenMove;
|
||||
|
|
@ -1653,7 +1653,7 @@ static void Cmd_typecalc(void)
|
|||
|
||||
if (!IsSpreadMove(GetBattlerMoveTargetType(gBattlerAttacker, gCurrentMove))) // Handled in CANCELER_MULTI_TARGET_MOVES for Spread Moves
|
||||
{
|
||||
struct DamageContext ctx = {0};
|
||||
struct BattleContext ctx = {0};
|
||||
ctx.battlerAtk = gBattlerAttacker;
|
||||
ctx.battlerDef = gBattlerTarget;
|
||||
ctx.move = gCurrentMove;
|
||||
|
|
@ -15120,22 +15120,22 @@ void BS_TryQuash(void)
|
|||
// If the above condition is not true, it means we are faster than the foe, so we can set the quash bit
|
||||
gProtectStructs[gBattlerTarget].quash = TRUE;
|
||||
|
||||
struct BattleContext ctx = {0};
|
||||
struct BattleCalcValues calcValues = {0};
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
ctx.abilities[i] = GetBattlerAbility(i);
|
||||
ctx.holdEffects[i] = GetBattlerHoldEffect(i);
|
||||
calcValues.abilities[i] = GetBattlerAbility(i);
|
||||
calcValues.holdEffects[i] = GetBattlerHoldEffect(i);
|
||||
}
|
||||
// this implementation assumes turn order is correct when using Quash
|
||||
i = GetBattlerTurnOrderNum(gBattlerTarget);
|
||||
for (j = i + 1; j < gBattlersCount; j++)
|
||||
{
|
||||
ctx.battlerAtk = gBattlerByTurnOrder[i];
|
||||
ctx.battlerDef = gBattlerByTurnOrder[j];
|
||||
calcValues.battlerAtk = gBattlerByTurnOrder[i];
|
||||
calcValues.battlerDef = gBattlerByTurnOrder[j];
|
||||
|
||||
// Gen 7- config makes target go last so that the order of quash targets is kept for the correct turn order
|
||||
// Gen 8+ config alters Turn Order of the target according to speed, dynamic speed should handle the rest
|
||||
if (B_QUASH_TURN_ORDER < GEN_8 || GetWhichBattlerFaster(&ctx, FALSE) == -1)
|
||||
if (B_QUASH_TURN_ORDER < GEN_8 || GetWhichBattlerFaster(&calcValues, FALSE) == -1)
|
||||
SwapTurnOrder(i, j);
|
||||
else
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -9,21 +9,21 @@
|
|||
#include "constants/battle.h"
|
||||
#include "constants/moves.h"
|
||||
|
||||
static bool32 FirstEventBlockEvents(struct BattleContext *ctx);
|
||||
static bool32 FirstEventBlockEvents(struct BattleCalcValues *calcValues);
|
||||
static bool32 TryHazardsOnSwitchIn(u32 battler, enum Ability ability, enum HoldEffect holdEffect, enum Hazards hazardType);
|
||||
static bool32 SecondEventBlockEvents(struct BattleContext *ctx);
|
||||
static bool32 SecondEventBlockEvents(struct BattleCalcValues *calcValues);
|
||||
|
||||
bool32 DoSwitchInEvents(void)
|
||||
{
|
||||
u32 battler;
|
||||
|
||||
struct BattleContext ctx = {0};
|
||||
struct BattleCalcValues calcValues = {0};
|
||||
for (battler = 0; battler < gBattlersCount; battler++)
|
||||
{
|
||||
if (!IsBattlerAlive(battler))
|
||||
continue;
|
||||
ctx.abilities[battler] = GetBattlerAbility(battler);
|
||||
ctx.holdEffects[battler] = GetBattlerHoldEffect(battler);
|
||||
calcValues.abilities[battler] = GetBattlerAbility(battler);
|
||||
calcValues.holdEffects[battler] = GetBattlerHoldEffect(battler);
|
||||
}
|
||||
|
||||
switch (gBattleStruct->eventState.switchIn)
|
||||
|
|
@ -41,7 +41,7 @@ bool32 DoSwitchInEvents(void)
|
|||
while (gBattleStruct->switchInBattlerCounter < gBattlersCount)
|
||||
{
|
||||
battler = gBattlersBySpeed[gBattleStruct->switchInBattlerCounter++];
|
||||
if (AbilityBattleEffects(ABILITYEFFECT_TERA_SHIFT, battler, ctx.abilities[battler], 0, gBattleStruct->battlerState[battler].switchIn))
|
||||
if (AbilityBattleEffects(ABILITYEFFECT_TERA_SHIFT, battler, calcValues.abilities[battler], 0, gBattleStruct->battlerState[battler].switchIn))
|
||||
return TRUE;
|
||||
}
|
||||
gBattleStruct->switchInBattlerCounter = 0;
|
||||
|
|
@ -51,7 +51,7 @@ bool32 DoSwitchInEvents(void)
|
|||
while (gBattleStruct->switchInBattlerCounter < gBattlersCount)
|
||||
{
|
||||
battler = gBattlersBySpeed[gBattleStruct->switchInBattlerCounter++];
|
||||
if (AbilityBattleEffects(ABILITYEFFECT_NEUTRALIZINGGAS, battler, ctx.abilities[battler], 0, gBattleStruct->battlerState[battler].switchIn))
|
||||
if (AbilityBattleEffects(ABILITYEFFECT_NEUTRALIZINGGAS, battler, calcValues.abilities[battler], 0, gBattleStruct->battlerState[battler].switchIn))
|
||||
return TRUE;
|
||||
}
|
||||
gBattleStruct->switchInBattlerCounter = 0;
|
||||
|
|
@ -61,7 +61,7 @@ bool32 DoSwitchInEvents(void)
|
|||
while (gBattleStruct->switchInBattlerCounter < gBattlersCount)
|
||||
{
|
||||
battler = gBattlersBySpeed[gBattleStruct->switchInBattlerCounter++];
|
||||
if (AbilityBattleEffects(ABILITYEFFECT_UNNERVE, battler, ctx.abilities[battler], 0, gBattleStruct->battlerState[battler].switchIn))
|
||||
if (AbilityBattleEffects(ABILITYEFFECT_UNNERVE, battler, calcValues.abilities[battler], 0, gBattleStruct->battlerState[battler].switchIn))
|
||||
return TRUE;
|
||||
}
|
||||
gBattleStruct->switchInBattlerCounter = 0;
|
||||
|
|
@ -79,10 +79,10 @@ bool32 DoSwitchInEvents(void)
|
|||
continue;
|
||||
}
|
||||
|
||||
ctx.battlerAtk = battler;
|
||||
calcValues.battlerAtk = battler;
|
||||
while (gBattleStruct->eventState.battlerSwitchIn < FIRST_EVENT_BLOCK_COUNT)
|
||||
{
|
||||
if (FirstEventBlockEvents(&ctx))
|
||||
if (FirstEventBlockEvents(&calcValues))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -104,10 +104,10 @@ bool32 DoSwitchInEvents(void)
|
|||
continue;
|
||||
}
|
||||
|
||||
ctx.battlerAtk = battler;
|
||||
calcValues.battlerAtk = battler;
|
||||
while (gBattleStruct->eventState.battlerSwitchIn < SECOND_EVENT_BLOCK_COUNT)
|
||||
{
|
||||
if (SecondEventBlockEvents(&ctx))
|
||||
if (SecondEventBlockEvents(&calcValues))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -121,7 +121,7 @@ bool32 DoSwitchInEvents(void)
|
|||
while (gBattleStruct->switchInBattlerCounter < gBattlersCount)
|
||||
{
|
||||
u32 battler = gBattlersBySpeed[gBattleStruct->switchInBattlerCounter++];
|
||||
if (ItemBattleEffects(battler, 0, ctx.holdEffects[battler], IsWhiteHerbActivation))
|
||||
if (ItemBattleEffects(battler, 0, calcValues.holdEffects[battler], IsWhiteHerbActivation))
|
||||
return TRUE;
|
||||
}
|
||||
gBattleStruct->switchInBattlerCounter = 0;
|
||||
|
|
@ -131,7 +131,7 @@ bool32 DoSwitchInEvents(void)
|
|||
while (gBattleStruct->switchInBattlerCounter < gBattlersCount)
|
||||
{
|
||||
u32 battler = gBattlersBySpeed[gBattleStruct->switchInBattlerCounter++];
|
||||
if (AbilityBattleEffects(ABILITYEFFECT_OPPORTUNIST, battler, ctx.abilities[battler], 0, TRUE))
|
||||
if (AbilityBattleEffects(ABILITYEFFECT_OPPORTUNIST, battler, calcValues.abilities[battler], 0, TRUE))
|
||||
return TRUE;
|
||||
}
|
||||
gBattleStruct->switchInBattlerCounter = 0;
|
||||
|
|
@ -182,10 +182,10 @@ static bool32 CanBattlerBeHealed(u32 battler)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static bool32 FirstEventBlockEvents(struct BattleContext *ctx)
|
||||
static bool32 FirstEventBlockEvents(struct BattleCalcValues *calcValues)
|
||||
{
|
||||
bool32 effect = FALSE;
|
||||
u32 battler = ctx->battlerAtk;
|
||||
u32 battler = calcValues->battlerAtk;
|
||||
|
||||
switch (gBattleStruct->eventState.battlerSwitchIn)
|
||||
{
|
||||
|
|
@ -245,24 +245,24 @@ static bool32 FirstEventBlockEvents(struct BattleContext *ctx)
|
|||
}
|
||||
else
|
||||
{
|
||||
effect = TryHazardsOnSwitchIn(battler, ctx->abilities[battler], ctx->holdEffects[battler], hazard);
|
||||
effect = TryHazardsOnSwitchIn(battler, calcValues->abilities[battler], calcValues->holdEffects[battler], hazard);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case FIRST_EVENT_BLOCK_GENERAL_ABILITIES:
|
||||
if (TryPrimalReversion(battler)
|
||||
|| AbilityBattleEffects(ABILITYEFFECT_ON_SWITCHIN, battler, ctx->abilities[battler], MOVE_NONE, gBattleStruct->battlerState[battler].switchIn)
|
||||
|| TryClearIllusion(battler, ctx->abilities[battler]))
|
||||
|| AbilityBattleEffects(ABILITYEFFECT_ON_SWITCHIN, battler, calcValues->abilities[battler], MOVE_NONE, gBattleStruct->battlerState[battler].switchIn)
|
||||
|| TryClearIllusion(battler, calcValues->abilities[battler]))
|
||||
effect = TRUE;
|
||||
gBattleStruct->eventState.battlerSwitchIn++;
|
||||
break;
|
||||
case FIRST_EVENT_BLOCK_IMMUNITY_ABILITIES:
|
||||
if (AbilityBattleEffects(ABILITYEFFECT_IMMUNITY, battler, ctx->abilities[battler], MOVE_NONE, TRUE))
|
||||
if (AbilityBattleEffects(ABILITYEFFECT_IMMUNITY, battler, calcValues->abilities[battler], MOVE_NONE, TRUE))
|
||||
effect = TRUE;
|
||||
gBattleStruct->eventState.battlerSwitchIn++;
|
||||
break;
|
||||
case FIRST_EVENT_BLOCK_ITEMS:
|
||||
if (ItemBattleEffects(battler, 0, ctx->holdEffects[battler], IsOnSwitchInActivation))
|
||||
if (ItemBattleEffects(battler, 0, calcValues->holdEffects[battler], IsOnSwitchInActivation))
|
||||
effect = TRUE;
|
||||
gBattleStruct->eventState.battlerSwitchIn++;
|
||||
break;
|
||||
|
|
@ -378,22 +378,22 @@ static bool32 TryHazardsOnSwitchIn(u32 battler, enum Ability ability, enum HoldE
|
|||
return effect;
|
||||
}
|
||||
|
||||
static bool32 SecondEventBlockEvents(struct BattleContext *ctx)
|
||||
static bool32 SecondEventBlockEvents(struct BattleCalcValues *calcValues)
|
||||
{
|
||||
bool32 effect = FALSE;
|
||||
u32 battler = ctx->battlerAtk;
|
||||
u32 battler = calcValues->battlerAtk;
|
||||
|
||||
switch (gBattleStruct->eventState.battlerSwitchIn)
|
||||
{
|
||||
case SECOND_EVENT_ABILITIES:
|
||||
if (AbilityBattleEffects(ABILITYEFFECT_ON_WEATHER, battler, ctx->abilities[battler], MOVE_NONE, TRUE)
|
||||
|| AbilityBattleEffects(ABILITYEFFECT_ON_TERRAIN, battler, ctx->abilities[battler], MOVE_NONE, TRUE)
|
||||
|| AbilityBattleEffects(ABILITYEFFECT_COMMANDER, battler, ctx->abilities[battler], MOVE_NONE, gBattleStruct->battlerState[battler].switchIn))
|
||||
if (AbilityBattleEffects(ABILITYEFFECT_ON_WEATHER, battler, calcValues->abilities[battler], MOVE_NONE, TRUE)
|
||||
|| AbilityBattleEffects(ABILITYEFFECT_ON_TERRAIN, battler, calcValues->abilities[battler], MOVE_NONE, TRUE)
|
||||
|| AbilityBattleEffects(ABILITYEFFECT_COMMANDER, battler, calcValues->abilities[battler], MOVE_NONE, gBattleStruct->battlerState[battler].switchIn))
|
||||
effect = TRUE;
|
||||
gBattleStruct->eventState.battlerSwitchIn++;
|
||||
break;
|
||||
case SECOND_EVENT_BOOSTER_ENERGY:
|
||||
if (ItemBattleEffects(battler, 0, ctx->holdEffects[battler], IsBoosterEnergyActivation))
|
||||
if (ItemBattleEffects(battler, 0, calcValues->holdEffects[battler], IsBoosterEnergyActivation))
|
||||
effect = TRUE;
|
||||
gBattleStruct->eventState.battlerSwitchIn++;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ bool32 IsTypeStellarBoosted(u32 battler, enum Type type)
|
|||
|
||||
// Returns the STAB power multiplier to use when Terastallized.
|
||||
// Power multipliers from Smogon Research thread.
|
||||
uq4_12_t GetTeraMultiplier(struct DamageContext *ctx)
|
||||
uq4_12_t GetTeraMultiplier(struct BattleContext *ctx)
|
||||
{
|
||||
enum Type teraType = GetBattlerTeraType(ctx->battlerAtk);
|
||||
|
||||
|
|
|
|||
|
|
@ -1272,7 +1272,7 @@ static void TrySetBattleSeminarShow(void)
|
|||
powerOverride = 0;
|
||||
if (ShouldCalculateDamage(gCurrentMove, &dmgByMove[i], &powerOverride))
|
||||
{
|
||||
struct DamageContext ctx = {0};
|
||||
struct BattleContext ctx = {0};
|
||||
ctx.battlerAtk = gBattlerAttacker;
|
||||
ctx.battlerDef = gBattlerTarget;
|
||||
ctx.move = ctx.chosenMove = gCurrentMove;
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ static const struct BattleWeatherInfo sBattleWeatherInfo[BATTLE_WEATHER_COUNT] =
|
|||
// This should stay a static function. Ideally everything else is handled through CalcTypeEffectivenessMultiplier just like AI
|
||||
static uq4_12_t CalcTypeEffectivenessMultiplierHelper(u32 move, enum Type moveType, u32 battlerAtk, u32 battlerDef, enum Ability abilityAtk, enum Ability abilityDef, bool32 recordAbilities)
|
||||
{
|
||||
struct DamageContext ctx = {0};
|
||||
struct BattleContext ctx = {0};
|
||||
ctx.battlerAtk = battlerAtk;
|
||||
ctx.battlerDef = battlerDef;
|
||||
ctx.move = ctx.chosenMove = move;
|
||||
|
|
@ -286,7 +286,7 @@ static u32 CalcBeatUpPower(void)
|
|||
}
|
||||
|
||||
// Gen 3/4
|
||||
static s32 CalcBeatUpDamage(struct DamageContext *ctx)
|
||||
static s32 CalcBeatUpDamage(struct BattleContext *ctx)
|
||||
{
|
||||
u32 partyIndex = gBattleStruct->beatUpSpecies[gBattleStruct->beatUpSlot++];
|
||||
struct Pokemon *party = GetBattlerParty(ctx->battlerAtk);
|
||||
|
|
@ -979,33 +979,33 @@ void HandleAction_ActionFinished(void)
|
|||
// i starts at `gCurrentTurnActionNumber` because we don't want to recalculate turn order for mon that have already
|
||||
// taken action. It's been previously increased, which we want in order to not recalculate the turn of the mon that just finished its action
|
||||
|
||||
struct BattleContext ctx = {0};
|
||||
struct BattleCalcValues calcValues = {0};
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
ctx.abilities[i] = GetBattlerAbility(i);
|
||||
ctx.holdEffects[i] = GetBattlerHoldEffect(i);
|
||||
calcValues.abilities[i] = GetBattlerAbility(i);
|
||||
calcValues.holdEffects[i] = GetBattlerHoldEffect(i);
|
||||
}
|
||||
for (i = gCurrentTurnActionNumber; i < gBattlersCount - 1; i++)
|
||||
{
|
||||
for (j = i + 1; j < gBattlersCount; j++)
|
||||
{
|
||||
ctx.battlerAtk = gBattlerByTurnOrder[i];
|
||||
ctx.battlerDef = gBattlerByTurnOrder[j];
|
||||
calcValues.battlerAtk = gBattlerByTurnOrder[i];
|
||||
calcValues.battlerDef = gBattlerByTurnOrder[j];
|
||||
|
||||
if (gProtectStructs[ctx.battlerAtk].quash || gProtectStructs[ctx.battlerDef].quash
|
||||
|| gProtectStructs[ctx.battlerAtk].shellTrap || gProtectStructs[ctx.battlerDef].shellTrap)
|
||||
if (gProtectStructs[calcValues.battlerAtk].quash || gProtectStructs[calcValues.battlerDef].quash
|
||||
|| gProtectStructs[calcValues.battlerAtk].shellTrap || gProtectStructs[calcValues.battlerDef].shellTrap)
|
||||
continue;
|
||||
|
||||
// We recalculate order only for action of the same priority. If any action other than switch/move has been taken, they should
|
||||
// have been executed before. The only recalculation needed is for moves/switch. Mega evolution is handled in src/battle_main.c/TryChangeOrder
|
||||
if ((gActionsByTurnOrder[i] == B_ACTION_USE_MOVE && gActionsByTurnOrder[j] == B_ACTION_USE_MOVE))
|
||||
{
|
||||
if (GetWhichBattlerFaster(&ctx, FALSE) == -1)
|
||||
if (GetWhichBattlerFaster(&calcValues, FALSE) == -1)
|
||||
SwapTurnOrder(i, j);
|
||||
}
|
||||
else if ((gActionsByTurnOrder[i] == B_ACTION_SWITCH && gActionsByTurnOrder[j] == B_ACTION_SWITCH))
|
||||
{
|
||||
if (GetWhichBattlerFaster(&ctx, TRUE) == -1) // If the actions chosen are switching, we recalc order but ignoring the moves
|
||||
if (GetWhichBattlerFaster(&calcValues, TRUE) == -1) // If the actions chosen are switching, we recalc order but ignoring the moves
|
||||
SwapTurnOrder(i, j);
|
||||
}
|
||||
}
|
||||
|
|
@ -1988,7 +1988,7 @@ static enum MoveCanceler CancelerClearFlags(struct BattleContext *ctx)
|
|||
|
||||
static enum MoveCanceler CancelerStanceChangeOne(struct BattleContext *ctx)
|
||||
{
|
||||
if (B_STANCE_CHANGE_FAIL < GEN_7 && gChosenMove == ctx->currentMove && TryFormChangeBeforeMove())
|
||||
if (B_STANCE_CHANGE_FAIL < GEN_7 && gChosenMove == ctx->move && TryFormChangeBeforeMove())
|
||||
return MOVE_STEP_BREAK;
|
||||
return MOVE_STEP_SUCCESS;
|
||||
}
|
||||
|
|
@ -2034,7 +2034,7 @@ static enum MoveCanceler CancelerAsleepOrFrozen(struct BattleContext *ctx)
|
|||
else
|
||||
{
|
||||
u8 toSub;
|
||||
if (IsAbilityAndRecord(ctx->battlerAtk, ctx->abilities[ctx->battlerAtk], ABILITY_EARLY_BIRD))
|
||||
if (IsAbilityAndRecord(ctx->battlerAtk, ctx->abilityAtk, ABILITY_EARLY_BIRD))
|
||||
toSub = 2;
|
||||
else
|
||||
toSub = 1;
|
||||
|
|
@ -2043,7 +2043,7 @@ static enum MoveCanceler CancelerAsleepOrFrozen(struct BattleContext *ctx)
|
|||
else
|
||||
gBattleMons[ctx->battlerAtk].status1 -= toSub;
|
||||
|
||||
enum BattleMoveEffects moveEffect = GetMoveEffect(ctx->currentMove);
|
||||
enum BattleMoveEffects moveEffect = GetMoveEffect(ctx->move);
|
||||
if (gBattleMons[ctx->battlerAtk].status1 & STATUS1_SLEEP)
|
||||
{
|
||||
if (moveEffect != EFFECT_SNORE && moveEffect != EFFECT_SLEEP_TALK)
|
||||
|
|
@ -2064,7 +2064,7 @@ static enum MoveCanceler CancelerAsleepOrFrozen(struct BattleContext *ctx)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (gBattleMons[ctx->battlerAtk].status1 & STATUS1_FREEZE && !MoveThawsUser(ctx->currentMove))
|
||||
else if (gBattleMons[ctx->battlerAtk].status1 & STATUS1_FREEZE && !MoveThawsUser(ctx->move))
|
||||
{
|
||||
if (!RandomPercentage(RNG_FROZEN, 20))
|
||||
{
|
||||
|
|
@ -2102,7 +2102,7 @@ static enum MoveCanceler CancelerObedience(struct BattleContext *ctx)
|
|||
return MOVE_STEP_FAILURE;
|
||||
case DISOBEYS_HITS_SELF:
|
||||
gBattlerTarget = ctx->battlerAtk;
|
||||
struct DamageContext dmgCtx = {0};
|
||||
struct BattleContext dmgCtx = {0};
|
||||
dmgCtx.battlerAtk = dmgCtx.battlerDef = ctx->battlerAtk;
|
||||
dmgCtx.move = dmgCtx.chosenMove = MOVE_NONE;
|
||||
dmgCtx.moveType = TYPE_MYSTERY;
|
||||
|
|
@ -2142,7 +2142,7 @@ static enum MoveCanceler CancelerObedience(struct BattleContext *ctx)
|
|||
static enum MoveCanceler CancelerPowerPoints(struct BattleContext *ctx)
|
||||
{
|
||||
if (gBattleMons[ctx->battlerAtk].pp[gCurrMovePos] == 0
|
||||
&& ctx->currentMove != MOVE_STRUGGLE
|
||||
&& ctx->move != MOVE_STRUGGLE
|
||||
&& !gSpecialStatuses[ctx->battlerAtk].dancerUsedMove
|
||||
&& !gBattleMons[ctx->battlerAtk].volatiles.multipleTurns)
|
||||
{
|
||||
|
|
@ -2178,7 +2178,7 @@ static enum MoveCanceler CancelerFocus(struct BattleContext *ctx)
|
|||
// In Gens 7+, check if chose and is using Focus Punch.
|
||||
if ((gProtectStructs[ctx->battlerAtk].physicalDmg || gProtectStructs[ctx->battlerAtk].specialDmg)
|
||||
&& (focusPunchFailureConfig < GEN_5 || GetMoveEffect(gChosenMoveByBattler[ctx->battlerAtk]) == EFFECT_FOCUS_PUNCH)
|
||||
&& (focusPunchFailureConfig == GEN_5 || focusPunchFailureConfig == GEN_6 || GetMoveEffect(ctx->currentMove) == EFFECT_FOCUS_PUNCH))
|
||||
&& (focusPunchFailureConfig == GEN_5 || focusPunchFailureConfig == GEN_6 || GetMoveEffect(ctx->move) == EFFECT_FOCUS_PUNCH))
|
||||
{
|
||||
CancelMultiTurnMoves(ctx->battlerAtk, SKY_DROP_ATTACKCANCELER_CHECK);
|
||||
gBattlescriptCurrInstr = BattleScript_FocusPunchLostFocus;
|
||||
|
|
@ -2204,7 +2204,7 @@ static enum MoveCanceler CancelerFlinch(struct BattleContext *ctx)
|
|||
static enum MoveCanceler CancelerDisabled(struct BattleContext *ctx)
|
||||
{
|
||||
if (GetActiveGimmick(ctx->battlerAtk) != GIMMICK_Z_MOVE
|
||||
&& gDisableStructs[ctx->battlerAtk].disabledMove == ctx->currentMove
|
||||
&& gDisableStructs[ctx->battlerAtk].disabledMove == ctx->move
|
||||
&& gDisableStructs[ctx->battlerAtk].disabledMove != MOVE_NONE)
|
||||
{
|
||||
gProtectStructs[ctx->battlerAtk].unableToUseMove = TRUE;
|
||||
|
|
@ -2221,7 +2221,7 @@ static enum MoveCanceler CancelerVolatileBlocked(struct BattleContext *ctx)
|
|||
{
|
||||
if (GetActiveGimmick(ctx->battlerAtk) != GIMMICK_Z_MOVE
|
||||
&& gBattleMons[ctx->battlerAtk].volatiles.healBlock
|
||||
&& IsHealBlockPreventingMove(ctx->battlerAtk, ctx->currentMove))
|
||||
&& IsHealBlockPreventingMove(ctx->battlerAtk, ctx->move))
|
||||
{
|
||||
gProtectStructs[ctx->battlerAtk].unableToUseMove = TRUE;
|
||||
gBattleScripting.battler = ctx->battlerAtk;
|
||||
|
|
@ -2230,7 +2230,7 @@ static enum MoveCanceler CancelerVolatileBlocked(struct BattleContext *ctx)
|
|||
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
|
||||
return MOVE_STEP_FAILURE;
|
||||
}
|
||||
else if (gFieldStatuses & STATUS_FIELD_GRAVITY && IsGravityPreventingMove(ctx->currentMove))
|
||||
else if (gFieldStatuses & STATUS_FIELD_GRAVITY && IsGravityPreventingMove(ctx->move))
|
||||
{
|
||||
gProtectStructs[ctx->battlerAtk].unableToUseMove = TRUE;
|
||||
gBattleScripting.battler = ctx->battlerAtk;
|
||||
|
|
@ -2239,7 +2239,7 @@ static enum MoveCanceler CancelerVolatileBlocked(struct BattleContext *ctx)
|
|||
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
|
||||
return MOVE_STEP_FAILURE;
|
||||
}
|
||||
else if (GetActiveGimmick(ctx->battlerAtk) != GIMMICK_Z_MOVE && gDisableStructs[ctx->battlerAtk].throatChopTimer > 0 && IsSoundMove(ctx->currentMove))
|
||||
else if (GetActiveGimmick(ctx->battlerAtk) != GIMMICK_Z_MOVE && gDisableStructs[ctx->battlerAtk].throatChopTimer > 0 && IsSoundMove(ctx->move))
|
||||
{
|
||||
gProtectStructs[ctx->battlerAtk].unableToUseMove = TRUE;
|
||||
CancelMultiTurnMoves(ctx->battlerAtk, SKY_DROP_ATTACKCANCELER_CHECK);
|
||||
|
|
@ -2252,7 +2252,7 @@ static enum MoveCanceler CancelerVolatileBlocked(struct BattleContext *ctx)
|
|||
|
||||
static enum MoveCanceler CancelerTaunted(struct BattleContext *ctx)
|
||||
{
|
||||
if (GetActiveGimmick(ctx->battlerAtk) != GIMMICK_Z_MOVE && gDisableStructs[ctx->battlerAtk].tauntTimer && IsBattleMoveStatus(ctx->currentMove))
|
||||
if (GetActiveGimmick(ctx->battlerAtk) != GIMMICK_Z_MOVE && gDisableStructs[ctx->battlerAtk].tauntTimer && IsBattleMoveStatus(ctx->move))
|
||||
{
|
||||
gProtectStructs[ctx->battlerAtk].unableToUseMove = TRUE;
|
||||
CancelMultiTurnMoves(ctx->battlerAtk, SKY_DROP_ATTACKCANCELER_CHECK);
|
||||
|
|
@ -2265,7 +2265,7 @@ static enum MoveCanceler CancelerTaunted(struct BattleContext *ctx)
|
|||
|
||||
static enum MoveCanceler CancelerImprisoned(struct BattleContext *ctx)
|
||||
{
|
||||
if (GetActiveGimmick(ctx->battlerAtk) != GIMMICK_Z_MOVE && GetImprisonedMovesCount(ctx->battlerAtk, ctx->currentMove))
|
||||
if (GetActiveGimmick(ctx->battlerAtk) != GIMMICK_Z_MOVE && GetImprisonedMovesCount(ctx->battlerAtk, ctx->move))
|
||||
{
|
||||
gProtectStructs[ctx->battlerAtk].unableToUseMove = TRUE;
|
||||
CancelMultiTurnMoves(ctx->battlerAtk, SKY_DROP_ATTACKCANCELER_CHECK);
|
||||
|
|
@ -2288,7 +2288,7 @@ static enum MoveCanceler CancelerConfused(struct BattleContext *ctx)
|
|||
if (RandomPercentage(RNG_CONFUSION, (GetGenConfig(GEN_CONFIG_CONFUSION_SELF_DMG_CHANCE) >= GEN_7 ? 33 : 50)))
|
||||
{
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = TRUE;
|
||||
struct DamageContext dmgCtx = {0};
|
||||
struct BattleContext dmgCtx = {0};
|
||||
dmgCtx.battlerAtk = dmgCtx.battlerDef = ctx->battlerAtk;
|
||||
dmgCtx.move = dmgCtx.chosenMove = MOVE_NONE;
|
||||
dmgCtx.moveType = TYPE_MYSTERY;
|
||||
|
|
@ -2322,7 +2322,7 @@ static enum MoveCanceler CancelerConfused(struct BattleContext *ctx)
|
|||
static enum MoveCanceler CancelerParalyzed(struct BattleContext *ctx)
|
||||
{
|
||||
if (gBattleMons[ctx->battlerAtk].status1 & STATUS1_PARALYSIS
|
||||
&& !(B_MAGIC_GUARD == GEN_4 && IsAbilityAndRecord(ctx->battlerAtk, ctx->abilities[ctx->battlerAtk], ABILITY_MAGIC_GUARD))
|
||||
&& !(B_MAGIC_GUARD == GEN_4 && IsAbilityAndRecord(ctx->battlerAtk, ctx->abilityAtk, ABILITY_MAGIC_GUARD))
|
||||
&& !RandomPercentage(RNG_PARALYSIS, 75))
|
||||
{
|
||||
gProtectStructs[ctx->battlerAtk].nonVolatileStatusImmobility = TRUE;
|
||||
|
|
@ -2398,7 +2398,7 @@ static enum MoveCanceler CancelerZMoves(struct BattleContext *ctx)
|
|||
SetGimmickAsActivated(ctx->battlerAtk, GIMMICK_Z_MOVE);
|
||||
|
||||
gBattleScripting.battler = ctx->battlerAtk;
|
||||
if (GetMoveCategory(ctx->currentMove) == DAMAGE_CATEGORY_STATUS)
|
||||
if (GetMoveCategory(ctx->move) == DAMAGE_CATEGORY_STATUS)
|
||||
BattleScriptCall(BattleScript_ZMoveActivateStatus);
|
||||
else
|
||||
BattleScriptCall(BattleScript_ZMoveActivateDamaging);
|
||||
|
|
@ -2415,7 +2415,7 @@ static enum MoveCanceler CancelerChoiceLock(struct BattleContext *ctx)
|
|||
|
||||
if (gChosenMove != MOVE_STRUGGLE
|
||||
&& (*choicedMoveAtk == MOVE_NONE || *choicedMoveAtk == MOVE_UNAVAILABLE)
|
||||
&& (IsHoldEffectChoice(holdEffect) || ctx->abilities[ctx->battlerAtk] == ABILITY_GORILLA_TACTICS))
|
||||
&& (IsHoldEffectChoice(holdEffect) || ctx->abilityAtk == ABILITY_GORILLA_TACTICS))
|
||||
*choicedMoveAtk = gChosenMove;
|
||||
|
||||
u32 moveIndex;
|
||||
|
|
@ -2438,7 +2438,7 @@ static enum MoveCanceler CancelerCallSubmove(struct BattleContext *ctx)
|
|||
const u8 *battleScript = NULL;
|
||||
battleScript = BattleScript_SubmoveAttackstring;
|
||||
|
||||
switch(GetMoveEffect(ctx->currentMove))
|
||||
switch(GetMoveEffect(ctx->move))
|
||||
{
|
||||
case EFFECT_MIRROR_MOVE:
|
||||
calledMove = GetMirrorMoveMove();
|
||||
|
|
@ -2479,7 +2479,7 @@ static enum MoveCanceler CancelerCallSubmove(struct BattleContext *ctx)
|
|||
{
|
||||
if (GetActiveGimmick(ctx->battlerAtk) == GIMMICK_Z_MOVE && !IsBattleMoveStatus(calledMove))
|
||||
calledMove = GetTypeBasedZMove(calledMove);
|
||||
if (GetMoveEffect(ctx->currentMove) == EFFECT_COPYCAT && IsMaxMove(calledMove))
|
||||
if (GetMoveEffect(ctx->move) == EFFECT_COPYCAT && IsMaxMove(calledMove))
|
||||
calledMove = gBattleStruct->dynamax.lastUsedBaseMove;
|
||||
|
||||
gBattleStruct->submoveAnnouncement = SUBMOVE_SUCCESS;
|
||||
|
|
@ -2496,7 +2496,7 @@ static enum MoveCanceler CancelerThaw(struct BattleContext *ctx)
|
|||
{
|
||||
if (gBattleMons[ctx->battlerAtk].status1 & STATUS1_FREEZE)
|
||||
{
|
||||
if (!(IsMoveEffectRemoveSpeciesType(ctx->currentMove, MOVE_EFFECT_REMOVE_ARG_TYPE, TYPE_FIRE) && !IS_BATTLER_OF_TYPE(ctx->battlerAtk, TYPE_FIRE)))
|
||||
if (!(IsMoveEffectRemoveSpeciesType(ctx->move, MOVE_EFFECT_REMOVE_ARG_TYPE, TYPE_FIRE) && !IS_BATTLER_OF_TYPE(ctx->battlerAtk, TYPE_FIRE)))
|
||||
{
|
||||
gBattleMons[ctx->battlerAtk].status1 &= ~STATUS1_FREEZE;
|
||||
BattleScriptCall(BattleScript_MoveUsedUnfroze);
|
||||
|
|
@ -2504,9 +2504,9 @@ static enum MoveCanceler CancelerThaw(struct BattleContext *ctx)
|
|||
}
|
||||
return MOVE_STEP_REMOVES_STATUS;
|
||||
}
|
||||
if (gBattleMons[ctx->battlerAtk].status1 & STATUS1_FROSTBITE && MoveThawsUser(ctx->currentMove))
|
||||
if (gBattleMons[ctx->battlerAtk].status1 & STATUS1_FROSTBITE && MoveThawsUser(ctx->move))
|
||||
{
|
||||
if (!(IsMoveEffectRemoveSpeciesType(ctx->currentMove, MOVE_EFFECT_REMOVE_ARG_TYPE, TYPE_FIRE) && !IS_BATTLER_OF_TYPE(ctx->battlerAtk, TYPE_FIRE)))
|
||||
if (!(IsMoveEffectRemoveSpeciesType(ctx->move, MOVE_EFFECT_REMOVE_ARG_TYPE, TYPE_FIRE) && !IS_BATTLER_OF_TYPE(ctx->battlerAtk, TYPE_FIRE)))
|
||||
{
|
||||
gBattleMons[ctx->battlerAtk].status1 &= ~STATUS1_FROSTBITE;
|
||||
BattleScriptCall(BattleScript_MoveUsedUnfrostbite);
|
||||
|
|
@ -2519,7 +2519,7 @@ static enum MoveCanceler CancelerThaw(struct BattleContext *ctx)
|
|||
|
||||
static enum MoveCanceler CancelerStanceChangeTwo(struct BattleContext *ctx)
|
||||
{
|
||||
if (B_STANCE_CHANGE_FAIL >= GEN_7 && gChosenMove == ctx->currentMove && TryFormChangeBeforeMove())
|
||||
if (B_STANCE_CHANGE_FAIL >= GEN_7 && gChosenMove == ctx->move && TryFormChangeBeforeMove())
|
||||
return MOVE_STEP_BREAK;
|
||||
return MOVE_STEP_SUCCESS;
|
||||
}
|
||||
|
|
@ -2536,11 +2536,11 @@ static enum MoveCanceler CancelerPPDeduction(struct BattleContext *ctx)
|
|||
{
|
||||
if (gBattleMons[ctx->battlerAtk].volatiles.multipleTurns
|
||||
|| gSpecialStatuses[ctx->battlerAtk].dancerUsedMove
|
||||
|| ctx->currentMove == MOVE_STRUGGLE)
|
||||
|| ctx->move == MOVE_STRUGGLE)
|
||||
return MOVE_STEP_SUCCESS;
|
||||
|
||||
s32 ppToDeduct = 1;
|
||||
u32 moveTarget = GetBattlerMoveTargetType(ctx->battlerAtk, ctx->currentMove);
|
||||
u32 moveTarget = GetBattlerMoveTargetType(ctx->battlerAtk, ctx->move);
|
||||
u32 movePosition = gCurrMovePos;
|
||||
|
||||
if (gBattleStruct->submoveAnnouncement == SUBMOVE_SUCCESS)
|
||||
|
|
@ -2549,7 +2549,7 @@ static enum MoveCanceler CancelerPPDeduction(struct BattleContext *ctx)
|
|||
if (moveTarget == MOVE_TARGET_BOTH
|
||||
|| moveTarget == MOVE_TARGET_FOES_AND_ALLY
|
||||
|| moveTarget == MOVE_TARGET_ALL_BATTLERS
|
||||
|| MoveForcesPressure(ctx->currentMove))
|
||||
|| MoveForcesPressure(ctx->move))
|
||||
{
|
||||
for (u32 i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
|
|
@ -2559,12 +2559,12 @@ static enum MoveCanceler CancelerPPDeduction(struct BattleContext *ctx)
|
|||
}
|
||||
else if (moveTarget != MOVE_TARGET_OPPONENTS_FIELD)
|
||||
{
|
||||
if (ctx->battlerAtk != ctx->battlerDef && ctx->abilities[ctx->battlerDef] == ABILITY_PRESSURE)
|
||||
if (ctx->battlerAtk != ctx->battlerDef && ctx->abilityDef == ABILITY_PRESSURE)
|
||||
ppToDeduct++;
|
||||
}
|
||||
|
||||
// For item Metronome, echoed voice
|
||||
if (ctx->currentMove != gLastResultingMoves[ctx->battlerAtk] || WasUnableToUseMove(ctx->battlerAtk))
|
||||
if (ctx->move != gLastResultingMoves[ctx->battlerAtk] || WasUnableToUseMove(ctx->battlerAtk))
|
||||
gDisableStructs[ctx->battlerAtk].metronomeItemCounter = 0;
|
||||
|
||||
if (gBattleMons[ctx->battlerAtk].pp[movePosition] > ppToDeduct)
|
||||
|
|
@ -2600,14 +2600,14 @@ static enum MoveCanceler CancelerPPDeduction(struct BattleContext *ctx)
|
|||
else
|
||||
{
|
||||
gBattleStruct->submoveAnnouncement = SUBMOVE_NO_EFFECT;
|
||||
gBattlerTarget = GetBattleMoveTarget(ctx->currentMove, NO_TARGET_OVERRIDE);
|
||||
gBattlerTarget = GetBattleMoveTarget(ctx->move, NO_TARGET_OVERRIDE);
|
||||
gBattleScripting.animTurn = 0;
|
||||
gBattleScripting.animTargetsHit = 0;
|
||||
|
||||
// Possibly better to just move type setting and redirection to attackcanceler as a new case at this point
|
||||
SetTypeBeforeUsingMove(ctx->currentMove, ctx->battlerAtk);
|
||||
SetTypeBeforeUsingMove(ctx->move, ctx->battlerAtk);
|
||||
HandleMoveTargetRedirection();
|
||||
gBattlescriptCurrInstr = GetMoveBattleScript(ctx->currentMove);
|
||||
gBattlescriptCurrInstr = GetMoveBattleScript(ctx->move);
|
||||
return MOVE_STEP_BREAK;
|
||||
}
|
||||
}
|
||||
|
|
@ -2618,10 +2618,10 @@ static enum MoveCanceler CancelerPPDeduction(struct BattleContext *ctx)
|
|||
static enum MoveCanceler CancelerWeatherPrimal(struct BattleContext *ctx)
|
||||
{
|
||||
enum MoveCanceler effect = MOVE_STEP_SUCCESS;
|
||||
if (HasWeatherEffect() && GetMovePower(ctx->currentMove) > 0)
|
||||
if (HasWeatherEffect() && GetMovePower(ctx->move) > 0)
|
||||
{
|
||||
enum Type moveType = GetBattleMoveType(ctx->currentMove);
|
||||
if (moveType == TYPE_FIRE && (gBattleWeather & B_WEATHER_RAIN_PRIMAL) && (GetGenConfig(GEN_CONFIG_POWDER_STATUS_HEAVY_RAIN) >= GEN_7 || !TryActivatePowderStatus(ctx->currentMove)))
|
||||
enum Type moveType = GetBattleMoveType(ctx->move);
|
||||
if (moveType == TYPE_FIRE && (gBattleWeather & B_WEATHER_RAIN_PRIMAL) && (GetGenConfig(GEN_CONFIG_POWDER_STATUS_HEAVY_RAIN) >= GEN_7 || !TryActivatePowderStatus(ctx->move)))
|
||||
{
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_PRIMAL_WEATHER_FIZZLED_BY_RAIN;
|
||||
effect = MOVE_STEP_FAILURE;
|
||||
|
|
@ -2646,10 +2646,10 @@ static enum MoveCanceler CancelerMoveFailure(struct BattleContext *ctx)
|
|||
{
|
||||
const u8 *battleScript = NULL;
|
||||
|
||||
switch (GetMoveEffect(ctx->currentMove))
|
||||
switch (GetMoveEffect(ctx->move))
|
||||
{
|
||||
case EFFECT_FAIL_IF_NOT_ARG_TYPE:
|
||||
if (!IS_BATTLER_OF_TYPE(ctx->battlerAtk, GetMoveArgType(ctx->currentMove)))
|
||||
if (!IS_BATTLER_OF_TYPE(ctx->battlerAtk, GetMoveArgType(ctx->move)))
|
||||
battleScript = BattleScript_ButItFailed;
|
||||
break;
|
||||
case EFFECT_AURA_WHEEL:
|
||||
|
|
@ -2705,7 +2705,7 @@ static enum MoveCanceler CancelerMoveFailure(struct BattleContext *ctx)
|
|||
case EFFECT_POLTERGEIST:
|
||||
if (gBattleMons[ctx->battlerDef].item == ITEM_NONE
|
||||
|| gFieldStatuses & STATUS_FIELD_MAGIC_ROOM
|
||||
|| ctx->abilities[ctx->battlerDef] == ABILITY_KLUTZ)
|
||||
|| ctx->abilityDef == ABILITY_KLUTZ)
|
||||
battleScript = BattleScript_ButItFailed;
|
||||
break;
|
||||
case EFFECT_PROTECT:
|
||||
|
|
@ -2713,13 +2713,13 @@ static enum MoveCanceler CancelerMoveFailure(struct BattleContext *ctx)
|
|||
break;
|
||||
case EFFECT_REST:
|
||||
if (gBattleMons[ctx->battlerAtk].status1 & STATUS1_SLEEP
|
||||
|| ctx->abilities[ctx->battlerAtk] == ABILITY_COMATOSE)
|
||||
|| ctx->abilityAtk == ABILITY_COMATOSE)
|
||||
battleScript = BattleScript_RestIsAlreadyAsleep;
|
||||
else if (gBattleMons[ctx->battlerAtk].hp == gBattleMons[ctx->battlerAtk].maxHP)
|
||||
battleScript = BattleScript_AlreadyAtFullHp;
|
||||
else if (ctx->abilities[ctx->battlerAtk] == ABILITY_INSOMNIA
|
||||
|| ctx->abilities[ctx->battlerAtk] == ABILITY_VITAL_SPIRIT
|
||||
|| ctx->abilities[ctx->battlerAtk] == ABILITY_PURIFYING_SALT)
|
||||
else if (ctx->abilityAtk == ABILITY_INSOMNIA
|
||||
|| ctx->abilityAtk == ABILITY_VITAL_SPIRIT
|
||||
|| ctx->abilityAtk == ABILITY_PURIFYING_SALT)
|
||||
battleScript = BattleScript_InsomniaProtects;
|
||||
break;
|
||||
case EFFECT_SUCKER_PUNCH:
|
||||
|
|
@ -2729,7 +2729,7 @@ static enum MoveCanceler CancelerMoveFailure(struct BattleContext *ctx)
|
|||
break;
|
||||
case EFFECT_UPPER_HAND:
|
||||
{
|
||||
u32 prio = GetChosenMovePriority(ctx->battlerDef, ctx->abilities[ctx->battlerDef]);
|
||||
u32 prio = GetChosenMovePriority(ctx->battlerDef, ctx->abilityDef);
|
||||
if (prio < 1 || prio > 3 // Fails if priority is less than 1 or greater than 3, if target already moved, or if using a status
|
||||
|| HasBattlerActedThisTurn(ctx->battlerDef)
|
||||
|| gChosenMoveByBattler[ctx->battlerDef] == MOVE_NONE
|
||||
|
|
@ -2739,7 +2739,7 @@ static enum MoveCanceler CancelerMoveFailure(struct BattleContext *ctx)
|
|||
}
|
||||
case EFFECT_SNORE:
|
||||
if (!(gBattleMons[ctx->battlerAtk].status1 & STATUS1_SLEEP)
|
||||
&& ctx->abilities[ctx->battlerAtk] != ABILITY_COMATOSE)
|
||||
&& ctx->abilityAtk != ABILITY_COMATOSE)
|
||||
battleScript = BattleScript_ButItFailed;
|
||||
break;
|
||||
case EFFECT_STEEL_ROLLER:
|
||||
|
|
@ -2783,9 +2783,9 @@ static enum MoveCanceler CancelerMoveFailure(struct BattleContext *ctx)
|
|||
|
||||
static enum MoveCanceler CancelerPowderStatus(struct BattleContext *ctx)
|
||||
{
|
||||
if (TryActivatePowderStatus(ctx->currentMove))
|
||||
if (TryActivatePowderStatus(ctx->move))
|
||||
{
|
||||
if (!IsAbilityAndRecord(ctx->battlerAtk, ctx->abilities[ctx->battlerAtk], ABILITY_MAGIC_GUARD))
|
||||
if (!IsAbilityAndRecord(ctx->battlerAtk, ctx->abilityAtk, ABILITY_MAGIC_GUARD))
|
||||
SetPassiveDamageAmount(ctx->battlerAtk, GetNonDynamaxMaxHP(ctx->battlerAtk) / 4);
|
||||
|
||||
// This might be incorrect
|
||||
|
|
@ -2813,16 +2813,16 @@ bool32 IsDazzlingAbility(enum Ability ability)
|
|||
static enum MoveCanceler CancelerPriorityBlock(struct BattleContext *ctx)
|
||||
{
|
||||
bool32 effect = FALSE;
|
||||
s32 priority = GetChosenMovePriority(ctx->battlerAtk, ctx->abilities[ctx->battlerAtk]);
|
||||
s32 priority = GetChosenMovePriority(ctx->battlerAtk, ctx->abilityAtk);
|
||||
u32 blockAbility = ABILITY_NONE; // ability of battler who is blocking
|
||||
u32 blockedByBattler = ctx->battlerDef;
|
||||
|
||||
if (priority <= 0 || IsBattlerAlly(ctx->battlerAtk, ctx->battlerDef))
|
||||
return MOVE_STEP_SUCCESS;
|
||||
|
||||
if (IsDazzlingAbility(ctx->abilities[ctx->battlerDef]))
|
||||
if (IsDazzlingAbility(ctx->abilityDef))
|
||||
{
|
||||
blockAbility = ctx->abilities[ctx->battlerDef];
|
||||
blockAbility = ctx->abilityDef;
|
||||
effect = TRUE;
|
||||
}
|
||||
else if (IsDoubleBattle() && IsBattlerAlive(BATTLE_PARTNER(ctx->battlerDef)))
|
||||
|
|
@ -2851,8 +2851,8 @@ static enum MoveCanceler CancelerPriorityBlock(struct BattleContext *ctx)
|
|||
|
||||
static enum MoveCanceler CancelerProtean(struct BattleContext *ctx)
|
||||
{
|
||||
enum Type moveType = GetBattleMoveType(ctx->currentMove);
|
||||
if (ProteanTryChangeType(ctx->battlerAtk, ctx->abilities[ctx->battlerAtk], ctx->currentMove, moveType))
|
||||
enum Type moveType = GetBattleMoveType(ctx->move);
|
||||
if (ProteanTryChangeType(ctx->battlerAtk, ctx->abilityAtk, ctx->move, moveType))
|
||||
{
|
||||
if (GetGenConfig(GEN_PROTEAN_LIBERO) >= GEN_9)
|
||||
gDisableStructs[ctx->battlerAtk].usedProteanLibero = TRUE;
|
||||
|
|
@ -2869,7 +2869,7 @@ static enum MoveCanceler CancelerProtean(struct BattleContext *ctx)
|
|||
static enum MoveCanceler CancelerExplodingDamp(struct BattleContext *ctx)
|
||||
{
|
||||
u32 dampBattler = IsAbilityOnField(ABILITY_DAMP);
|
||||
if (dampBattler && IsMoveDampBanned(ctx->currentMove))
|
||||
if (dampBattler && IsMoveDampBanned(ctx->move))
|
||||
{
|
||||
gBattleScripting.battler = dampBattler - 1;
|
||||
gBattlescriptCurrInstr = BattleScript_DampStopsExplosion;
|
||||
|
|
@ -2881,18 +2881,18 @@ static enum MoveCanceler CancelerExplodingDamp(struct BattleContext *ctx)
|
|||
|
||||
static enum MoveCanceler CancelerMultihitMoves(struct BattleContext *ctx)
|
||||
{
|
||||
if (IsMultiHitMove(ctx->currentMove))
|
||||
if (IsMultiHitMove(ctx->move))
|
||||
{
|
||||
enum Ability ability = ctx->abilities[ctx->battlerAtk];
|
||||
enum Ability ability = ctx->abilityAtk;
|
||||
|
||||
if (ability == ABILITY_SKILL_LINK)
|
||||
{
|
||||
gMultiHitCounter = 5;
|
||||
}
|
||||
else if (GetMoveEffect(ctx->currentMove) == EFFECT_SPECIES_POWER_OVERRIDE
|
||||
&& gBattleMons[ctx->battlerAtk].species == GetMoveSpeciesPowerOverride_Species(ctx->currentMove))
|
||||
else if (GetMoveEffect(ctx->move) == EFFECT_SPECIES_POWER_OVERRIDE
|
||||
&& gBattleMons[ctx->battlerAtk].species == GetMoveSpeciesPowerOverride_Species(ctx->move))
|
||||
{
|
||||
gMultiHitCounter = GetMoveSpeciesPowerOverride_NumOfHits(ctx->currentMove);
|
||||
gMultiHitCounter = GetMoveSpeciesPowerOverride_NumOfHits(ctx->move);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -2901,18 +2901,18 @@ static enum MoveCanceler CancelerMultihitMoves(struct BattleContext *ctx)
|
|||
|
||||
PREPARE_BYTE_NUMBER_BUFFER(gBattleScripting.multihitString, 1, 0)
|
||||
}
|
||||
else if (GetMoveStrikeCount(ctx->currentMove) > 1)
|
||||
else if (GetMoveStrikeCount(ctx->move) > 1)
|
||||
{
|
||||
if (GetMoveEffect(ctx->currentMove) == EFFECT_POPULATION_BOMB && GetBattlerHoldEffect(ctx->battlerAtk) == HOLD_EFFECT_LOADED_DICE)
|
||||
if (GetMoveEffect(ctx->move) == EFFECT_POPULATION_BOMB && GetBattlerHoldEffect(ctx->battlerAtk) == HOLD_EFFECT_LOADED_DICE)
|
||||
{
|
||||
gMultiHitCounter = RandomUniform(RNG_LOADED_DICE, 4, 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
gMultiHitCounter = GetMoveStrikeCount(ctx->currentMove);
|
||||
gMultiHitCounter = GetMoveStrikeCount(ctx->move);
|
||||
|
||||
if (GetMoveEffect(ctx->currentMove) == EFFECT_DRAGON_DARTS
|
||||
&& !IsAffectedByFollowMe(ctx->battlerAtk, GetBattlerSide(ctx->battlerDef), ctx->currentMove)
|
||||
if (GetMoveEffect(ctx->move) == EFFECT_DRAGON_DARTS
|
||||
&& !IsAffectedByFollowMe(ctx->battlerAtk, GetBattlerSide(ctx->battlerDef), ctx->move)
|
||||
&& CanTargetPartner(ctx->battlerAtk, ctx->battlerDef)
|
||||
&& TargetFullyImmuneToCurrMove(ctx->battlerAtk, ctx->battlerDef))
|
||||
gBattlerTarget = BATTLE_PARTNER(ctx->battlerDef);
|
||||
|
|
@ -2920,7 +2920,7 @@ static enum MoveCanceler CancelerMultihitMoves(struct BattleContext *ctx)
|
|||
|
||||
PREPARE_BYTE_NUMBER_BUFFER(gBattleScripting.multihitString, 3, 0)
|
||||
}
|
||||
else if (GetMoveEffect(ctx->currentMove) == EFFECT_BEAT_UP)
|
||||
else if (GetMoveEffect(ctx->move) == EFFECT_BEAT_UP)
|
||||
{
|
||||
struct Pokemon* party = GetBattlerParty(ctx->battlerAtk);
|
||||
int i;
|
||||
|
|
@ -2956,8 +2956,8 @@ static enum MoveCanceler CancelerMultihitMoves(struct BattleContext *ctx)
|
|||
|
||||
static enum MoveCanceler CancelerMultiTargetMoves(struct BattleContext *ctx)
|
||||
{
|
||||
u32 moveTarget = GetBattlerMoveTargetType(ctx->battlerAtk, ctx->currentMove);
|
||||
enum Ability abilityAtk = ctx->abilities[ctx->battlerAtk];
|
||||
u32 moveTarget = GetBattlerMoveTargetType(ctx->battlerAtk, ctx->move);
|
||||
enum Ability abilityAtk = ctx->abilityAtk;
|
||||
|
||||
if (IsSpreadMove(moveTarget))
|
||||
{
|
||||
|
|
@ -2970,26 +2970,26 @@ static enum MoveCanceler CancelerMultiTargetMoves(struct BattleContext *ctx)
|
|||
|
||||
if (ctx->battlerAtk == battlerDef
|
||||
|| !IsBattlerAlive(battlerDef)
|
||||
|| (GetMoveEffect(ctx->currentMove) == EFFECT_SYNCHRONOISE && !DoBattlersShareType(ctx->battlerAtk, battlerDef))
|
||||
|| (GetMoveEffect(ctx->move) == EFFECT_SYNCHRONOISE && !DoBattlersShareType(ctx->battlerAtk, battlerDef))
|
||||
|| (moveTarget == MOVE_TARGET_BOTH && ctx->battlerAtk == BATTLE_PARTNER(battlerDef))
|
||||
|| IsBattlerProtected(ctx->battlerAtk, battlerDef, ctx->currentMove)) // Missing Invulnerable check
|
||||
|| IsBattlerProtected(ctx->battlerAtk, battlerDef, ctx->move)) // Missing Invulnerable check
|
||||
{
|
||||
gBattleStruct->moveResultFlags[battlerDef] = MOVE_RESULT_NO_EFFECT;
|
||||
gBattleStruct->noResultString[battlerDef] = WILL_FAIL;
|
||||
}
|
||||
else if (CanAbilityBlockMove(ctx->battlerAtk, battlerDef, abilityAtk, abilityDef, ctx->currentMove, CHECK_TRIGGER))
|
||||
else if (CanAbilityBlockMove(ctx->battlerAtk, battlerDef, abilityAtk, abilityDef, ctx->move, CHECK_TRIGGER))
|
||||
{
|
||||
gBattleStruct->moveResultFlags[battlerDef] = 0;
|
||||
gBattleStruct->noResultString[battlerDef] = WILL_FAIL;
|
||||
}
|
||||
else if (CanAbilityAbsorbMove(ctx->battlerAtk, battlerDef, abilityDef, ctx->currentMove, GetBattleMoveType(gCurrentMove), CHECK_TRIGGER))
|
||||
else if (CanAbilityAbsorbMove(ctx->battlerAtk, battlerDef, abilityDef, ctx->move, GetBattleMoveType(gCurrentMove), CHECK_TRIGGER))
|
||||
{
|
||||
gBattleStruct->moveResultFlags[battlerDef] = 0;
|
||||
gBattleStruct->noResultString[battlerDef] = CHECK_ACCURACY;
|
||||
}
|
||||
else
|
||||
{
|
||||
CalcTypeEffectivenessMultiplierHelper(ctx->currentMove, GetBattleMoveType(ctx->currentMove), ctx->battlerAtk, battlerDef, abilityAtk, abilityDef, TRUE); // Sets moveResultFlags
|
||||
CalcTypeEffectivenessMultiplierHelper(ctx->move, GetBattleMoveType(ctx->move), ctx->battlerAtk, battlerDef, abilityAtk, abilityDef, TRUE); // Sets moveResultFlags
|
||||
gBattleStruct->noResultString[battlerDef] = CAN_DAMAGE;
|
||||
}
|
||||
}
|
||||
|
|
@ -4119,7 +4119,7 @@ u32 AbilityBattleEffects(enum AbilityEffect caseID, u32 battler, enum Ability ab
|
|||
case ABILITY_ANTICIPATION:
|
||||
if (shouldAbilityTrigger)
|
||||
{
|
||||
struct DamageContext ctx = {0};
|
||||
struct BattleContext ctx = {0};
|
||||
uq4_12_t modifier = UQ_4_12(1.0);
|
||||
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
|
||||
{
|
||||
|
|
@ -6792,7 +6792,7 @@ u32 CountBattlerStatIncreases(u32 battler, bool32 countEvasionAcc)
|
|||
return count;
|
||||
}
|
||||
|
||||
u32 GetMoveTargetCount(struct DamageContext *ctx)
|
||||
u32 GetMoveTargetCount(struct BattleContext *ctx)
|
||||
{
|
||||
u32 battlerAtk = ctx->battlerAtk;
|
||||
u32 battlerDef = ctx->battlerDef;
|
||||
|
|
@ -6968,7 +6968,7 @@ static inline u32 IsFieldWaterSportAffected(enum Type moveType)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static inline u32 CalcMoveBasePower(struct DamageContext *ctx)
|
||||
static inline u32 CalcMoveBasePower(struct BattleContext *ctx)
|
||||
{
|
||||
u32 battlerAtk = ctx->battlerAtk;
|
||||
u32 battlerDef = ctx->battlerDef;
|
||||
|
|
@ -7236,7 +7236,7 @@ static inline u32 CalcMoveBasePower(struct DamageContext *ctx)
|
|||
return basePower;
|
||||
}
|
||||
|
||||
static inline u32 CalcMoveBasePowerAfterModifiers(struct DamageContext *ctx)
|
||||
static inline u32 CalcMoveBasePowerAfterModifiers(struct BattleContext *ctx)
|
||||
{
|
||||
u32 holdEffectParamAtk;
|
||||
u32 basePower = CalcMoveBasePower(ctx);
|
||||
|
|
@ -7590,7 +7590,7 @@ static inline uq4_12_t ApplyDefensiveBadgeBoost(uq4_12_t modifier, u32 battler,
|
|||
return modifier;
|
||||
}
|
||||
|
||||
static inline u32 CalcAttackStat(struct DamageContext *ctx)
|
||||
static inline u32 CalcAttackStat(struct BattleContext *ctx)
|
||||
{
|
||||
u8 atkStage;
|
||||
u32 atkStat;
|
||||
|
|
@ -7886,7 +7886,7 @@ static bool32 CanEvolve(u32 species)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static inline u32 CalcDefenseStat(struct DamageContext *ctx)
|
||||
static inline u32 CalcDefenseStat(struct BattleContext *ctx)
|
||||
{
|
||||
bool32 usesDefStat;
|
||||
u8 defStage;
|
||||
|
|
@ -8055,7 +8055,7 @@ static inline s32 CalculateBaseDamage(u32 power, u32 userFinalAttack, u32 level,
|
|||
return power * userFinalAttack * (2 * level / 5 + 2) / targetFinalDefense / 50 + 2;
|
||||
}
|
||||
|
||||
static inline uq4_12_t GetTargetDamageModifier(struct DamageContext *ctx)
|
||||
static inline uq4_12_t GetTargetDamageModifier(struct BattleContext *ctx)
|
||||
{
|
||||
if (IsDoubleBattle() && GetMoveTargetCount(ctx) >= 2)
|
||||
return B_MULTIPLE_TARGETS_DMG >= GEN_4 ? UQ_4_12(0.75) : UQ_4_12(0.5);
|
||||
|
|
@ -8069,7 +8069,7 @@ static inline uq4_12_t GetParentalBondModifier(u32 battlerAtk)
|
|||
return B_PARENTAL_BOND_DMG >= GEN_7 ? UQ_4_12(0.25) : UQ_4_12(0.5);
|
||||
}
|
||||
|
||||
static inline uq4_12_t GetSameTypeAttackBonusModifier(struct DamageContext *ctx)
|
||||
static inline uq4_12_t GetSameTypeAttackBonusModifier(struct BattleContext *ctx)
|
||||
{
|
||||
if (ctx->moveType == TYPE_MYSTERY)
|
||||
return UQ_4_12(1.0);
|
||||
|
|
@ -8081,7 +8081,7 @@ static inline uq4_12_t GetSameTypeAttackBonusModifier(struct DamageContext *ctx)
|
|||
}
|
||||
|
||||
// Utility Umbrella holders take normal damage from what would be rain- and sun-weakened attacks.
|
||||
static uq4_12_t GetWeatherDamageModifier(struct DamageContext *ctx)
|
||||
static uq4_12_t GetWeatherDamageModifier(struct BattleContext *ctx)
|
||||
{
|
||||
if (ctx->weather == B_WEATHER_NONE)
|
||||
return UQ_4_12(1.0);
|
||||
|
|
@ -8105,7 +8105,7 @@ static uq4_12_t GetWeatherDamageModifier(struct DamageContext *ctx)
|
|||
return UQ_4_12(1.0);
|
||||
}
|
||||
|
||||
static inline uq4_12_t GetBurnOrFrostBiteModifier(struct DamageContext *ctx)
|
||||
static inline uq4_12_t GetBurnOrFrostBiteModifier(struct BattleContext *ctx)
|
||||
{
|
||||
enum BattleMoveEffects moveEffect = GetMoveEffect(ctx->move);
|
||||
|
||||
|
|
@ -8135,7 +8135,7 @@ static inline uq4_12_t GetGlaiveRushModifier(u32 battlerDef)
|
|||
return UQ_4_12(1.0);
|
||||
}
|
||||
|
||||
static inline uq4_12_t GetZMaxMoveAgainstProtectionModifier(struct DamageContext *ctx)
|
||||
static inline uq4_12_t GetZMaxMoveAgainstProtectionModifier(struct BattleContext *ctx)
|
||||
{
|
||||
if (!IsZMove(ctx->move) && !IsMaxMove(ctx->move))
|
||||
return UQ_4_12(1.0);
|
||||
|
|
@ -8174,7 +8174,7 @@ static inline uq4_12_t GetAirborneModifier(u32 move, u32 battlerDef)
|
|||
return UQ_4_12(1.0);
|
||||
}
|
||||
|
||||
static inline uq4_12_t GetScreensModifier(struct DamageContext *ctx)
|
||||
static inline uq4_12_t GetScreensModifier(struct BattleContext *ctx)
|
||||
{
|
||||
u32 sideStatus = gSideStatuses[GetBattlerSide(ctx->battlerDef)];
|
||||
bool32 lightScreen = (sideStatus & SIDE_STATUS_LIGHTSCREEN) && IsBattleMoveSpecial(ctx->move);
|
||||
|
|
@ -8227,7 +8227,7 @@ static inline uq4_12_t GetAttackerAbilitiesModifier(u32 battlerAtk, uq4_12_t typ
|
|||
return UQ_4_12(1.0);
|
||||
}
|
||||
|
||||
static inline uq4_12_t GetDefenderAbilitiesModifier(struct DamageContext *ctx)
|
||||
static inline uq4_12_t GetDefenderAbilitiesModifier(struct BattleContext *ctx)
|
||||
{
|
||||
bool32 recordAbility = FALSE;
|
||||
uq4_12_t modifier = UQ_4_12(1.0);
|
||||
|
|
@ -8329,7 +8329,7 @@ static inline uq4_12_t GetAttackerItemsModifier(u32 battlerAtk, uq4_12_t typeEff
|
|||
return UQ_4_12(1.0);
|
||||
}
|
||||
|
||||
static inline uq4_12_t GetDefenderItemsModifier(struct DamageContext *ctx)
|
||||
static inline uq4_12_t GetDefenderItemsModifier(struct BattleContext *ctx)
|
||||
{
|
||||
switch (ctx->holdEffectDef)
|
||||
{
|
||||
|
|
@ -8361,7 +8361,7 @@ static inline uq4_12_t GetDefenderItemsModifier(struct DamageContext *ctx)
|
|||
// https://bulbapedia.bulbagarden.net/wiki/Damage#Generation_V_onward
|
||||
// Please Note: Fixed Point Multiplication is not associative.
|
||||
// The order of operations is relevant.
|
||||
static inline uq4_12_t GetOtherModifiers(struct DamageContext *ctx)
|
||||
static inline uq4_12_t GetOtherModifiers(struct BattleContext *ctx)
|
||||
{
|
||||
uq4_12_t finalModifier = UQ_4_12(1.0);
|
||||
u32 battlerDefPartner = BATTLE_PARTNER(ctx->battlerDef);
|
||||
|
|
@ -8401,7 +8401,7 @@ static inline uq4_12_t GetOtherModifiers(struct DamageContext *ctx)
|
|||
dmg = uq4_12_multiply_by_int_half_down(modifier, dmg); \
|
||||
} while (0)
|
||||
|
||||
static inline s32 DoMoveDamageCalcVars(struct DamageContext *ctx)
|
||||
static inline s32 DoMoveDamageCalcVars(struct BattleContext *ctx)
|
||||
{
|
||||
s32 dmg;
|
||||
u32 userFinalAttack;
|
||||
|
|
@ -8441,7 +8441,7 @@ static inline s32 DoMoveDamageCalcVars(struct DamageContext *ctx)
|
|||
return dmg;
|
||||
}
|
||||
|
||||
s32 ApplyModifiersAfterDmgRoll(struct DamageContext *ctx, s32 dmg)
|
||||
s32 ApplyModifiersAfterDmgRoll(struct BattleContext *ctx, s32 dmg)
|
||||
{
|
||||
if (GetActiveGimmick(ctx->battlerAtk) == GIMMICK_TERA)
|
||||
DAMAGE_APPLY_MODIFIER(GetTeraMultiplier(ctx));
|
||||
|
|
@ -8455,7 +8455,7 @@ s32 ApplyModifiersAfterDmgRoll(struct DamageContext *ctx, s32 dmg)
|
|||
return dmg;
|
||||
}
|
||||
|
||||
s32 DoFixedDamageMoveCalc(struct DamageContext *ctx)
|
||||
s32 DoFixedDamageMoveCalc(struct BattleContext *ctx)
|
||||
{
|
||||
s32 dmg = 0;
|
||||
s32 randDamage;
|
||||
|
|
@ -8496,7 +8496,7 @@ s32 DoFixedDamageMoveCalc(struct DamageContext *ctx)
|
|||
return dmg;
|
||||
}
|
||||
|
||||
static inline s32 DoMoveDamageCalc(struct DamageContext *ctx)
|
||||
static inline s32 DoMoveDamageCalc(struct BattleContext *ctx)
|
||||
{
|
||||
if (ctx->typeEffectivenessModifier == UQ_4_12(0.0))
|
||||
return 0;
|
||||
|
|
@ -8508,7 +8508,7 @@ static inline s32 DoMoveDamageCalc(struct DamageContext *ctx)
|
|||
return DoMoveDamageCalcVars(ctx);
|
||||
}
|
||||
|
||||
static inline s32 DoFutureSightAttackDamageCalcVars(struct DamageContext *ctx)
|
||||
static inline s32 DoFutureSightAttackDamageCalcVars(struct BattleContext *ctx)
|
||||
{
|
||||
s32 dmg;
|
||||
u32 userFinalAttack;
|
||||
|
|
@ -8553,7 +8553,7 @@ static inline s32 DoFutureSightAttackDamageCalcVars(struct DamageContext *ctx)
|
|||
return dmg;
|
||||
}
|
||||
|
||||
static inline s32 DoFutureSightAttackDamageCalc(struct DamageContext *ctx)
|
||||
static inline s32 DoFutureSightAttackDamageCalc(struct BattleContext *ctx)
|
||||
{
|
||||
if (ctx->typeEffectivenessModifier == UQ_4_12(0.0))
|
||||
return 0;
|
||||
|
|
@ -8640,7 +8640,7 @@ static inline u32 GetHoldEffectCritChanceIncrease(u32 battler, enum HoldEffect h
|
|||
return critStageIncrease;
|
||||
}
|
||||
|
||||
s32 CalcCritChanceStage(struct DamageContext *ctx)
|
||||
s32 CalcCritChanceStage(struct BattleContext *ctx)
|
||||
{
|
||||
s32 critChance = 0;
|
||||
|
||||
|
|
@ -8689,7 +8689,7 @@ s32 CalcCritChanceStage(struct DamageContext *ctx)
|
|||
// Threshold = Base Speed / 2
|
||||
// High crit move = 8 * (Base Speed / 2)
|
||||
// Focus Energy = 4 * (Base Speed / 2)
|
||||
s32 CalcCritChanceStageGen1(struct DamageContext *ctx)
|
||||
s32 CalcCritChanceStageGen1(struct BattleContext *ctx)
|
||||
{
|
||||
s32 critChance = 0;
|
||||
s32 moveCritStage = GetMoveCriticalHitStage(ctx->move);
|
||||
|
|
@ -8741,7 +8741,7 @@ s32 CalcCritChanceStageGen1(struct DamageContext *ctx)
|
|||
return critChance;
|
||||
}
|
||||
|
||||
static bool32 IsCriticalHit(struct DamageContext *ctx)
|
||||
static bool32 IsCriticalHit(struct BattleContext *ctx)
|
||||
{
|
||||
bool32 isCrit = FALSE;
|
||||
s32 critChance = 0;
|
||||
|
|
@ -8776,7 +8776,7 @@ static bool32 IsCriticalHit(struct DamageContext *ctx)
|
|||
return isCrit;
|
||||
}
|
||||
|
||||
s32 CalculateMoveDamage(struct DamageContext *ctx)
|
||||
s32 CalculateMoveDamage(struct BattleContext *ctx)
|
||||
{
|
||||
ctx->weather = GetWeather();
|
||||
ctx->abilityAtk = GetBattlerAbility(ctx->battlerAtk);
|
||||
|
|
@ -8795,7 +8795,7 @@ s32 CalculateMoveDamage(struct DamageContext *ctx)
|
|||
}
|
||||
|
||||
// for AI so that typeEffectivenessModifier, weather, abilities and holdEffects are calculated only once
|
||||
s32 CalculateMoveDamageVars(struct DamageContext *ctx)
|
||||
s32 CalculateMoveDamageVars(struct BattleContext *ctx)
|
||||
{
|
||||
s32 dmg = DoFixedDamageMoveCalc(ctx);
|
||||
if (dmg != INT32_MAX)
|
||||
|
|
@ -8804,7 +8804,7 @@ s32 CalculateMoveDamageVars(struct DamageContext *ctx)
|
|||
return DoMoveDamageCalcVars(ctx);
|
||||
}
|
||||
|
||||
static inline void MulByTypeEffectiveness(struct DamageContext *ctx, uq4_12_t *modifier, enum Type defType)
|
||||
static inline void MulByTypeEffectiveness(struct BattleContext *ctx, uq4_12_t *modifier, enum Type defType)
|
||||
{
|
||||
uq4_12_t mod = GetTypeModifier(ctx->moveType, defType);
|
||||
|
||||
|
|
@ -8862,7 +8862,7 @@ static inline void TryNoticeIllusionInTypeEffectiveness(u32 move, enum Type move
|
|||
// Check if the type effectiveness would've been different if the pokemon really had the types as the disguise.
|
||||
uq4_12_t presumedModifier = UQ_4_12(1.0);
|
||||
|
||||
struct DamageContext ctx = {0};
|
||||
struct BattleContext ctx = {0};
|
||||
ctx.battlerAtk = battlerAtk;
|
||||
ctx.battlerDef = battlerDef;
|
||||
ctx.move = ctx.chosenMove = move;
|
||||
|
|
@ -8905,7 +8905,7 @@ void UpdateMoveResultFlags(uq4_12_t modifier, u16 *resultFlags)
|
|||
}
|
||||
}
|
||||
|
||||
static inline uq4_12_t CalcTypeEffectivenessMultiplierInternal(struct DamageContext *ctx, uq4_12_t modifier)
|
||||
static inline uq4_12_t CalcTypeEffectivenessMultiplierInternal(struct BattleContext *ctx, uq4_12_t modifier)
|
||||
{
|
||||
u32 illusionSpecies;
|
||||
enum Type types[3];
|
||||
|
|
@ -8985,7 +8985,7 @@ static inline uq4_12_t CalcTypeEffectivenessMultiplierInternal(struct DamageCont
|
|||
return modifier;
|
||||
}
|
||||
|
||||
uq4_12_t CalcTypeEffectivenessMultiplier(struct DamageContext *ctx)
|
||||
uq4_12_t CalcTypeEffectivenessMultiplier(struct BattleContext *ctx)
|
||||
{
|
||||
uq4_12_t modifier = UQ_4_12(1.0);
|
||||
|
||||
|
|
@ -9011,7 +9011,7 @@ uq4_12_t CalcPartyMonTypeEffectivenessMultiplier(u16 move, u16 speciesDef, enum
|
|||
|
||||
if (move != MOVE_STRUGGLE && moveType != TYPE_MYSTERY)
|
||||
{
|
||||
struct DamageContext ctx = {0};
|
||||
struct BattleContext ctx = {0};
|
||||
ctx.move = ctx.chosenMove = move;
|
||||
ctx.moveType = moveType;
|
||||
ctx.updateFlags = FALSE;
|
||||
|
|
@ -9056,7 +9056,7 @@ uq4_12_t GetOverworldTypeEffectiveness(struct Pokemon *mon, enum Type moveType)
|
|||
if (moveType == TYPE_MYSTERY)
|
||||
return modifier;
|
||||
|
||||
struct DamageContext ctx = {0};
|
||||
struct BattleContext ctx = {0};
|
||||
ctx.move = ctx.chosenMove = MOVE_POUND;
|
||||
ctx.moveType = moveType;
|
||||
ctx.updateFlags = FALSE;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user