add overwrittenAbilities field
This commit is contained in:
parent
ba9f085782
commit
c22671d2a2
5 changed files with 22 additions and 14 deletions
|
@ -646,6 +646,7 @@ struct BattleStruct
|
||||||
// When using a move which hits multiple opponents which is then bounced by a target, we need to make sure, the move hits both opponents, the one with bounce, and the one without.
|
// When using a move which hits multiple opponents which is then bounced by a target, we need to make sure, the move hits both opponents, the one with bounce, and the one without.
|
||||||
u8 attackerBeforeBounce:2;
|
u8 attackerBeforeBounce:2;
|
||||||
u8 targetsDone[MAX_BATTLERS_COUNT]; // Each battler as a bit.
|
u8 targetsDone[MAX_BATTLERS_COUNT]; // Each battler as a bit.
|
||||||
|
u16 overwrittenAbilities[MAX_BATTLERS_COUNT]; // abilities overwritten during battle (keep separate from battle history in case of switching)
|
||||||
};
|
};
|
||||||
|
|
||||||
#define F_DYNAMIC_TYPE_1 (1 << 6)
|
#define F_DYNAMIC_TYPE_1 (1 << 6)
|
||||||
|
|
|
@ -1163,6 +1163,10 @@ s32 AI_GetAbility(u32 battlerId)
|
||||||
{
|
{
|
||||||
u32 knownAbility = GetBattlerAbility(battlerId);
|
u32 knownAbility = GetBattlerAbility(battlerId);
|
||||||
|
|
||||||
|
// We've had ability overwritten by e.g. Worry Seed. It is not part of AI_PARTY in case of switching
|
||||||
|
if (gBattleStruct->overwrittenAbilities[battlerId])
|
||||||
|
return gBattleStruct->overwrittenAbilities[battlerId];
|
||||||
|
|
||||||
// The AI knows its own ability.
|
// The AI knows its own ability.
|
||||||
if (IsBattlerAIControlled(battlerId))
|
if (IsBattlerAIControlled(battlerId))
|
||||||
return knownAbility;
|
return knownAbility;
|
||||||
|
|
|
@ -2940,6 +2940,7 @@ static void BattleStartClearSetData(void)
|
||||||
gBattleStruct->lastTakenMoveFrom[i][3] = MOVE_NONE;
|
gBattleStruct->lastTakenMoveFrom[i][3] = MOVE_NONE;
|
||||||
gBattleStruct->AI_monToSwitchIntoId[i] = PARTY_SIZE;
|
gBattleStruct->AI_monToSwitchIntoId[i] = PARTY_SIZE;
|
||||||
gBattleStruct->skyDropTargets[i] = 0xFF;
|
gBattleStruct->skyDropTargets[i] = 0xFF;
|
||||||
|
gBattleStruct->overwrittenAbilities[i] = ABILITY_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gLastUsedMove = 0;
|
gLastUsedMove = 0;
|
||||||
|
@ -3126,6 +3127,8 @@ void SwitchInClearSetData(void)
|
||||||
// Reset damage to prevent things like red card activating if the switched-in mon is holding it
|
// Reset damage to prevent things like red card activating if the switched-in mon is holding it
|
||||||
gSpecialStatuses[gActiveBattler].physicalDmg = 0;
|
gSpecialStatuses[gActiveBattler].physicalDmg = 0;
|
||||||
gSpecialStatuses[gActiveBattler].specialDmg = 0;
|
gSpecialStatuses[gActiveBattler].specialDmg = 0;
|
||||||
|
|
||||||
|
gBattleStruct->overwrittenAbilities[gActiveBattler] = ABILITY_NONE;
|
||||||
|
|
||||||
Ai_UpdateSwitchInData(gActiveBattler);
|
Ai_UpdateSwitchInData(gActiveBattler);
|
||||||
}
|
}
|
||||||
|
@ -3228,6 +3231,8 @@ void FaintClearSetData(void)
|
||||||
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
|
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
|
||||||
UndoMegaEvolution(gBattlerPartyIndexes[gActiveBattler]);
|
UndoMegaEvolution(gBattlerPartyIndexes[gActiveBattler]);
|
||||||
|
|
||||||
|
gBattleStruct->overwrittenAbilities[gActiveBattler] = ABILITY_NONE;
|
||||||
|
|
||||||
// If the fainted mon was involved in a Sky Drop
|
// If the fainted mon was involved in a Sky Drop
|
||||||
if (gBattleStruct->skyDropTargets[gActiveBattler] != 0xFF)
|
if (gBattleStruct->skyDropTargets[gActiveBattler] != 0xFF)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8081,8 +8081,7 @@ static void Cmd_various(void)
|
||||||
gBattlescriptCurrInstr += 8;
|
gBattlescriptCurrInstr += 8;
|
||||||
return;
|
return;
|
||||||
case VARIOUS_TRACE_ABILITY:
|
case VARIOUS_TRACE_ABILITY:
|
||||||
gBattleMons[gActiveBattler].ability = gBattleStruct->tracedAbility[gActiveBattler];
|
gBattleMons[gActiveBattler].ability = gBattleStruct->overwrittenAbilities[gActiveBattler] = gBattleStruct->tracedAbility[gActiveBattler];
|
||||||
RecordAbilityBattle(gActiveBattler, gBattleMons[gActiveBattler].ability);
|
|
||||||
break;
|
break;
|
||||||
case VARIOUS_TRY_ILLUSION_OFF:
|
case VARIOUS_TRY_ILLUSION_OFF:
|
||||||
if (GetIllusionMonPtr(gActiveBattler) != NULL)
|
if (GetIllusionMonPtr(gActiveBattler) != NULL)
|
||||||
|
@ -8557,7 +8556,7 @@ static void Cmd_various(void)
|
||||||
if (gBattleMons[gBattlerTarget].ability == ABILITY_NEUTRALIZING_GAS)
|
if (gBattleMons[gBattlerTarget].ability == ABILITY_NEUTRALIZING_GAS)
|
||||||
gSpecialStatuses[gBattlerTarget].neutralizingGasRemoved = TRUE;
|
gSpecialStatuses[gBattlerTarget].neutralizingGasRemoved = TRUE;
|
||||||
|
|
||||||
gBattleMons[gBattlerTarget].ability = ABILITY_SIMPLE;
|
gBattleMons[gBattlerTarget].ability = gBattleStruct->overwrittenAbilities[gBattlerTarget] = ABILITY_SIMPLE;
|
||||||
gBattlescriptCurrInstr += 7;
|
gBattlescriptCurrInstr += 7;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -8575,7 +8574,7 @@ static void Cmd_various(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gBattleMons[gBattlerTarget].ability = gBattleMons[gBattlerAttacker].ability;
|
gBattleMons[gBattlerTarget].ability = gBattleStruct->overwrittenAbilities[gBattlerTarget] = gBattleMons[gBattlerAttacker].ability;
|
||||||
gBattlescriptCurrInstr += 7;
|
gBattlescriptCurrInstr += 7;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -11388,7 +11387,8 @@ static void Cmd_transformdataexecution(void)
|
||||||
|
|
||||||
for (i = 0; i < offsetof(struct BattlePokemon, pp); i++)
|
for (i = 0; i < offsetof(struct BattlePokemon, pp); i++)
|
||||||
battleMonAttacker[i] = battleMonTarget[i];
|
battleMonAttacker[i] = battleMonTarget[i];
|
||||||
|
|
||||||
|
gBattleStruct->overwrittenAbilities[gBattlerAttacker] = GetBattlerAbility(gBattlerTarget);
|
||||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||||
{
|
{
|
||||||
if (gBattleMoves[gBattleMons[gBattlerAttacker].moves[i]].pp < 5)
|
if (gBattleMoves[gBattleMons[gBattlerAttacker].moves[i]].pp < 5)
|
||||||
|
@ -12912,7 +12912,7 @@ static void Cmd_trycopyability(void)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gBattleScripting.abilityPopupOverwrite = gBattleMons[gBattlerAttacker].ability;
|
gBattleScripting.abilityPopupOverwrite = gBattleMons[gBattlerAttacker].ability;
|
||||||
gBattleMons[gBattlerAttacker].ability = defAbility;
|
gBattleMons[gBattlerAttacker].ability = gBattleStruct->overwrittenAbilities[gBattlerAttacker] = defAbility;
|
||||||
gLastUsedAbility = defAbility;
|
gLastUsedAbility = defAbility;
|
||||||
gBattlescriptCurrInstr += 5;
|
gBattlescriptCurrInstr += 5;
|
||||||
}
|
}
|
||||||
|
@ -13078,8 +13078,8 @@ static void Cmd_tryswapabilities(void)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
u16 abilityAtk = gBattleMons[gBattlerAttacker].ability;
|
u16 abilityAtk = gBattleMons[gBattlerAttacker].ability;
|
||||||
gBattleMons[gBattlerAttacker].ability = gBattleMons[gBattlerTarget].ability;
|
gBattleMons[gBattlerAttacker].ability = gBattleStruct->overwrittenAbilities[gBattlerAttacker] = gBattleMons[gBattlerTarget].ability;
|
||||||
gBattleMons[gBattlerTarget].ability = abilityAtk;
|
gBattleMons[gBattlerTarget].ability = gBattleStruct->overwrittenAbilities[gBattlerTarget] = abilityAtk;
|
||||||
|
|
||||||
gBattlescriptCurrInstr += 5;
|
gBattlescriptCurrInstr += 5;
|
||||||
}
|
}
|
||||||
|
@ -14457,7 +14457,7 @@ static void Cmd_tryworryseed(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gBattleMons[gBattlerTarget].ability = ABILITY_INSOMNIA;
|
gBattleMons[gBattlerTarget].ability = gBattleStruct->overwrittenAbilities[gBattlerTarget] = ABILITY_INSOMNIA;
|
||||||
gBattlescriptCurrInstr += 5;
|
gBattlescriptCurrInstr += 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5294,7 +5294,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
|
||||||
case ABILITY_STANCE_CHANGE:
|
case ABILITY_STANCE_CHANGE:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
gLastUsedAbility = gBattleMons[gBattlerAttacker].ability = ABILITY_MUMMY;
|
gLastUsedAbility = gBattleMons[gBattlerAttacker].ability = gBattleStruct->overwrittenAbilities[gBattlerAttacker] = ABILITY_MUMMY;
|
||||||
BattleScriptPushCursor();
|
BattleScriptPushCursor();
|
||||||
gBattlescriptCurrInstr = BattleScript_MummyActivates;
|
gBattlescriptCurrInstr = BattleScript_MummyActivates;
|
||||||
effect++;
|
effect++;
|
||||||
|
@ -5326,10 +5326,8 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
gLastUsedAbility = gBattleMons[gBattlerAttacker].ability;
|
gLastUsedAbility = gBattleMons[gBattlerAttacker].ability;
|
||||||
gBattleMons[gBattlerAttacker].ability = gBattleMons[gBattlerTarget].ability;
|
gBattleMons[gBattlerAttacker].ability = gBattleStruct->overwrittenAbilities[gBattlerAttacker] = gBattleMons[gBattlerTarget].ability;
|
||||||
gBattleMons[gBattlerTarget].ability = gLastUsedAbility;
|
gBattleMons[gBattlerTarget].ability = gBattleStruct->overwrittenAbilities[gBattlerTarget] = gLastUsedAbility;
|
||||||
RecordAbilityBattle(gBattlerAttacker, gBattleMons[gBattlerAttacker].ability);
|
|
||||||
RecordAbilityBattle(gBattlerTarget, gBattleMons[gBattlerTarget].ability);
|
|
||||||
BattleScriptPushCursor();
|
BattleScriptPushCursor();
|
||||||
gBattlescriptCurrInstr = BattleScript_WanderingSpiritActivates;
|
gBattlescriptCurrInstr = BattleScript_WanderingSpiritActivates;
|
||||||
effect++;
|
effect++;
|
||||||
|
|
Loading…
Reference in a new issue