Edited pointless or useless Primal Reversion code
Also added an equivalent to GetMegaEvolutionSpecies and GetWishMegaEvolutionSpecies for Primal Reversion. Also also modified how CanBattlerGetOrLoseItem checks for Primal Reversion. Also also also rewrote the check that triggers Primal Reversion in TryDoEventsBeforeFirstTurn.
This commit is contained in:
parent
f2dd7bce99
commit
19af517bbb
5 changed files with 31 additions and 20 deletions
|
@ -475,7 +475,6 @@ struct MegaEvolutionData
|
|||
bool8 playerSelect;
|
||||
u8 triggerSpriteId;
|
||||
bool8 isWishMegaEvo;
|
||||
bool8 isPrimalReversion;
|
||||
};
|
||||
|
||||
struct Illusion
|
||||
|
|
|
@ -127,6 +127,7 @@ u16 CalcPartyMonTypeEffectivenessMultiplier(u16 move, u16 speciesDef, u16 abilit
|
|||
u16 GetTypeModifier(u8 atkType, u8 defType);
|
||||
s32 GetStealthHazardDamage(u8 hazardType, u8 battlerId);
|
||||
u16 GetMegaEvolutionSpecies(u16 preEvoSpecies, u16 heldItemId);
|
||||
u16 GetPrimalReversionSpecies(u16 preEvoSpecies, u16 heldItemId);
|
||||
u16 GetWishMegaEvolutionSpecies(u16 preEvoSpecies, u16 moveId1, u16 moveId2, u16 moveId3, u16 moveId4);
|
||||
bool32 CanMegaEvolve(u8 battlerId);
|
||||
void UndoMegaEvolution(u32 monId);
|
||||
|
|
|
@ -64,6 +64,8 @@
|
|||
#include "constants/trainers.h"
|
||||
#include "cable_club.h"
|
||||
|
||||
extern struct Evolution gEvolutionTable[][EVOS_PER_MON];
|
||||
|
||||
extern struct MusicPlayerInfo gMPlayInfo_SE1;
|
||||
extern struct MusicPlayerInfo gMPlayInfo_SE2;
|
||||
|
||||
|
@ -3541,12 +3543,18 @@ static void TryDoEventsBeforeFirstTurn(void)
|
|||
// Primal Reversion
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
if (CanMegaEvolve(i)
|
||||
&& GetBattlerHoldEffect(i, TRUE) == HOLD_EFFECT_PRIMAL_ORB)
|
||||
if (GetBattlerHoldEffect(i, TRUE) == HOLD_EFFECT_PRIMAL_ORB)
|
||||
{
|
||||
gBattlerAttacker = i;
|
||||
BattleScriptExecute(BattleScript_PrimalReversion);
|
||||
return;
|
||||
for (j = 0; j < EVOS_PER_MON; j++)
|
||||
{
|
||||
if (gEvolutionTable[gBattleMons[i].species][j].targetSpecies != SPECIES_NONE
|
||||
&& gEvolutionTable[gBattleMons[i].species][j].method == EVO_PRIMAL_REVERSION)
|
||||
{
|
||||
gBattlerAttacker = i;
|
||||
BattleScriptExecute(BattleScript_PrimalReversion);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8331,7 +8331,7 @@ static void Cmd_various(void)
|
|||
gBattleStruct->mega.playerPrimalRevertedSpecies = gBattleStruct->mega.primalRevertedSpecies[gActiveBattler];
|
||||
}
|
||||
// Checks Primal Reversion
|
||||
primalSpecies = GetMegaEvolutionSpecies(gBattleStruct->mega.primalRevertedSpecies[gActiveBattler], gBattleMons[gActiveBattler].item);
|
||||
primalSpecies = GetPrimalReversionSpecies(gBattleStruct->mega.primalRevertedSpecies[gActiveBattler], gBattleMons[gActiveBattler].item);
|
||||
|
||||
gBattleMons[gActiveBattler].species = primalSpecies;
|
||||
PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gActiveBattler].species);
|
||||
|
|
|
@ -9081,8 +9081,20 @@ u16 GetMegaEvolutionSpecies(u16 preEvoSpecies, u16 heldItemId)
|
|||
|
||||
for (i = 0; i < EVOS_PER_MON; i++)
|
||||
{
|
||||
if ((gEvolutionTable[preEvoSpecies][i].method == EVO_MEGA_EVOLUTION
|
||||
|| gEvolutionTable[preEvoSpecies][i].method == EVO_PRIMAL_REVERSION)
|
||||
if (gEvolutionTable[preEvoSpecies][i].method == EVO_MEGA_EVOLUTION
|
||||
&& gEvolutionTable[preEvoSpecies][i].param == heldItemId)
|
||||
return gEvolutionTable[preEvoSpecies][i].targetSpecies;
|
||||
}
|
||||
return SPECIES_NONE;
|
||||
}
|
||||
|
||||
u16 GetPrimalReversionSpecies(u16 preEvoSpecies, u16 heldItemId)
|
||||
{
|
||||
u32 i;
|
||||
|
||||
for (i = 0; i < EVOS_PER_MON; i++)
|
||||
{
|
||||
if (gEvolutionTable[preEvoSpecies][i].method == EVO_PRIMAL_REVERSION
|
||||
&& gEvolutionTable[preEvoSpecies][i].param == heldItemId)
|
||||
return gEvolutionTable[preEvoSpecies][i].targetSpecies;
|
||||
}
|
||||
|
@ -9153,14 +9165,6 @@ bool32 CanMegaEvolve(u8 battlerId)
|
|||
gBattleStruct->mega.isWishMegaEvo = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Can undergo Primal Reversion.
|
||||
if (holdEffect == HOLD_EFFECT_PRIMAL_ORB)
|
||||
{
|
||||
gBattleStruct->mega.isWishMegaEvo = FALSE;
|
||||
gBattleStruct->mega.isPrimalReversion = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if there is an entry in the evolution table for Wish Mega Evolution.
|
||||
|
@ -9264,9 +9268,8 @@ bool32 CanBattlerGetOrLoseItem(u8 battlerId, u16 itemId)
|
|||
// Mail can be stolen now
|
||||
if (itemId == ITEM_ENIGMA_BERRY)
|
||||
return FALSE;
|
||||
else if (GET_BASE_SPECIES_ID(species) == SPECIES_KYOGRE && itemId == ITEM_BLUE_ORB) // includes primal
|
||||
return FALSE;
|
||||
else if (GET_BASE_SPECIES_ID(species) == SPECIES_GROUDON && itemId == ITEM_RED_ORB) // includes primal
|
||||
// Primal Reversion inducing items cannot be lost if pokemon's base species can undergo primal reversion with it.
|
||||
else if (holdEffect == HOLD_EFFECT_PRIMAL_ORB && (GetPrimalReversionSpecies(GET_BASE_SPECIES_ID(species), itemId) != SPECIES_NONE))
|
||||
return FALSE;
|
||||
// Mega stone cannot be lost if pokemon's base species can mega evolve with it.
|
||||
else if (holdEffect == HOLD_EFFECT_MEGA_STONE && (GetMegaEvolutionSpecies(GET_BASE_SPECIES_ID(species), itemId) != SPECIES_NONE))
|
||||
|
|
Loading…
Reference in a new issue