mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 19:54:21 +01:00
Merge pull request #1328 from GriffinRichards/doc-pokeuseitem
Document PokemonUseItemEffects
This commit is contained in:
commit
fc3d6eb178
@ -31,7 +31,7 @@
|
||||
#define ITEM4_EV_HP 0x1
|
||||
#define ITEM4_EV_ATK 0x2
|
||||
#define ITEM4_HEAL_HP 0x4
|
||||
#define ITEM4_HEAL_PP_ALL 0x8
|
||||
#define ITEM4_HEAL_PP 0x8
|
||||
#define ITEM4_HEAL_PP_ONE 0x10
|
||||
#define ITEM4_PP_UP 0x20
|
||||
#define ITEM4_REVIVE 0x40
|
||||
@ -50,11 +50,15 @@
|
||||
#define ITEM5_FRIENDSHIP_ALL (ITEM5_FRIENDSHIP_LOW | ITEM5_FRIENDSHIP_MID | ITEM5_FRIENDSHIP_HIGH)
|
||||
|
||||
// fields 6 and onwards are item-specific arguments
|
||||
#define ITEM_EFFECT_ARG_START 6
|
||||
|
||||
// Special HP recovery amounts for ITEM4_HEAL_HP
|
||||
#define ITEM6_HEAL_FULL ((u8) -1)
|
||||
#define ITEM6_HEAL_HALF ((u8) -2)
|
||||
#define ITEM6_HEAL_LVL_UP ((u8) -3)
|
||||
#define ITEM6_HEAL_HP_FULL ((u8) -1)
|
||||
#define ITEM6_HEAL_HP_HALF ((u8) -2)
|
||||
#define ITEM6_HEAL_HP_LVL_UP ((u8) -3)
|
||||
|
||||
// Special PP recovery amounts for ITEM4_HEAL_PP
|
||||
#define ITEM6_HEAL_PP_FULL 0x7F
|
||||
|
||||
// Amount of EV modified by ITEM4_EV_HP, ITEM4_EV_ATK, ITEM5_EV_DEF, ITEM5_EV_SPEED, ITEM5_EV_SPDEF and ITEM5_EV_SPATK
|
||||
#define ITEM6_ADD_EV 10
|
||||
|
@ -290,6 +290,12 @@
|
||||
|
||||
#define EVOS_PER_MON 5
|
||||
|
||||
// Evolution 'modes,' for GetEvolutionTargetSpecies
|
||||
#define EVO_MODE_NORMAL 0
|
||||
#define EVO_MODE_TRADE 1
|
||||
#define EVO_MODE_ITEM_USE 2
|
||||
#define EVO_MODE_ITEM_CHECK 3 // If an Everstone is being held, still want to show that the stone *could* be used on that Pokémon to evolve
|
||||
|
||||
#define NUM_MALE_LINK_FACILITY_CLASSES 8
|
||||
#define NUM_FEMALE_LINK_FACILITY_CLASSES 8
|
||||
|
||||
|
@ -5105,7 +5105,7 @@ static void TryEvolvePokemon(void)
|
||||
levelUpBits &= ~(gBitTable[i]);
|
||||
gLeveledUpInBattle = levelUpBits;
|
||||
|
||||
species = GetEvolutionTargetSpecies(&gPlayerParty[i], 0, levelUpBits);
|
||||
species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_NORMAL, levelUpBits);
|
||||
if (species != SPECIES_NONE)
|
||||
{
|
||||
FreeAllWindowBuffers();
|
||||
|
@ -6245,7 +6245,7 @@ static void Cmd_hpthresholds2(void)
|
||||
static void Cmd_useitemonopponent(void)
|
||||
{
|
||||
gBattlerInMenuId = gBattlerAttacker;
|
||||
PokemonUseItemEffects(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker]], gLastUsedItem, gBattlerPartyIndexes[gBattlerAttacker], 0, 1);
|
||||
PokemonUseItemEffects(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker]], gLastUsedItem, gBattlerPartyIndexes[gBattlerAttacker], 0, TRUE);
|
||||
gBattlescriptCurrInstr += 1;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
const u8 gItemEffect_Potion[7] = {
|
||||
[4] = ITEM4_HEAL_HP,
|
||||
[6] = 20,
|
||||
[6] = 20, // Amount of HP to recover
|
||||
};
|
||||
|
||||
const u8 gItemEffect_Antidote[6] = {
|
||||
@ -26,22 +26,22 @@ const u8 gItemEffect_ParalyzeHeal[6] = {
|
||||
const u8 gItemEffect_FullRestore[7] = {
|
||||
[3] = ITEM3_STATUS_ALL,
|
||||
[4] = ITEM4_HEAL_HP,
|
||||
[6] = ITEM6_HEAL_FULL,
|
||||
[6] = ITEM6_HEAL_HP_FULL,
|
||||
};
|
||||
|
||||
const u8 gItemEffect_MaxPotion[7] = {
|
||||
[4] = ITEM4_HEAL_HP,
|
||||
[6] = ITEM6_HEAL_FULL,
|
||||
[6] = ITEM6_HEAL_HP_FULL,
|
||||
};
|
||||
|
||||
const u8 gItemEffect_HyperPotion[7] = {
|
||||
[4] = ITEM4_HEAL_HP,
|
||||
[6] = 200,
|
||||
[6] = 200, // Amount of HP to recover
|
||||
};
|
||||
|
||||
const u8 gItemEffect_SuperPotion[7] = {
|
||||
[4] = ITEM4_HEAL_HP,
|
||||
[6] = 50,
|
||||
[6] = 50, // Amount of HP to recover
|
||||
};
|
||||
|
||||
const u8 gItemEffect_FullHeal[6] = {
|
||||
@ -50,87 +50,87 @@ const u8 gItemEffect_FullHeal[6] = {
|
||||
|
||||
const u8 gItemEffect_Revive[7] = {
|
||||
[4] = ITEM4_REVIVE | ITEM4_HEAL_HP,
|
||||
[6] = ITEM6_HEAL_HALF,
|
||||
[6] = ITEM6_HEAL_HP_HALF,
|
||||
};
|
||||
|
||||
const u8 gItemEffect_MaxRevive[7] = {
|
||||
[4] = ITEM4_REVIVE | ITEM4_HEAL_HP,
|
||||
[6] = ITEM6_HEAL_FULL,
|
||||
[6] = ITEM6_HEAL_HP_FULL,
|
||||
};
|
||||
|
||||
const u8 gItemEffect_FreshWater[7] = {
|
||||
[4] = ITEM4_HEAL_HP,
|
||||
[6] = 50,
|
||||
[6] = 50, // Amount of HP to recover
|
||||
};
|
||||
|
||||
const u8 gItemEffect_SodaPop[7] = {
|
||||
[4] = ITEM4_HEAL_HP,
|
||||
[6] = 60,
|
||||
[6] = 60, // Amount of HP to recover
|
||||
};
|
||||
|
||||
const u8 gItemEffect_Lemonade[7] = {
|
||||
[4] = ITEM4_HEAL_HP,
|
||||
[6] = 80,
|
||||
[6] = 80, // Amount of HP to recover
|
||||
};
|
||||
|
||||
const u8 gItemEffect_MoomooMilk[7] = {
|
||||
[4] = ITEM4_HEAL_HP,
|
||||
[6] = 100,
|
||||
[6] = 100, // Amount of HP to recover
|
||||
};
|
||||
|
||||
const u8 gItemEffect_EnergyPowder[10] = {
|
||||
[4] = ITEM4_HEAL_HP,
|
||||
[5] = ITEM5_FRIENDSHIP_ALL,
|
||||
[6] = 50,
|
||||
[7] = -5,
|
||||
[8] = -5,
|
||||
[9] = -10,
|
||||
[6] = 50, // Amount of HP to recover
|
||||
[7] = -5, // Friendship change, low
|
||||
[8] = -5, // Friendship change, mid
|
||||
[9] = -10, // Friendship change, high
|
||||
};
|
||||
|
||||
const u8 gItemEffect_EnergyRoot[10] = {
|
||||
[4] = ITEM4_HEAL_HP,
|
||||
[5] = ITEM5_FRIENDSHIP_ALL,
|
||||
[6] = 200,
|
||||
[7] = -10,
|
||||
[8] = -10,
|
||||
[9] = -15,
|
||||
[6] = 200, // Amount of HP to recover
|
||||
[7] = -10, // Friendship change, low
|
||||
[8] = -10, // Friendship change, mid
|
||||
[9] = -15, // Friendship change, high
|
||||
};
|
||||
|
||||
const u8 gItemEffect_HealPowder[9] = {
|
||||
[3] = ITEM3_STATUS_ALL,
|
||||
[5] = ITEM5_FRIENDSHIP_ALL,
|
||||
[6] = -5,
|
||||
[7] = -5,
|
||||
[8] = -10,
|
||||
[6] = -5, // Friendship change, low
|
||||
[7] = -5, // Friendship change, mid
|
||||
[8] = -10, // Friendship change, high
|
||||
};
|
||||
|
||||
const u8 gItemEffect_RevivalHerb[10] = {
|
||||
[4] = ITEM4_REVIVE | ITEM4_HEAL_HP,
|
||||
[5] = ITEM5_FRIENDSHIP_ALL,
|
||||
[6] = ITEM6_HEAL_FULL,
|
||||
[7] = -15,
|
||||
[8] = -15,
|
||||
[9] = -20,
|
||||
[6] = ITEM6_HEAL_HP_FULL,
|
||||
[7] = -15, // Friendship change, low
|
||||
[8] = -15, // Friendship change, mid
|
||||
[9] = -20, // Friendship change, high
|
||||
};
|
||||
|
||||
const u8 gItemEffect_Ether[7] = {
|
||||
[4] = ITEM4_HEAL_PP_ONE | ITEM4_HEAL_PP_ALL,
|
||||
[4] = ITEM4_HEAL_PP_ONE | ITEM4_HEAL_PP,
|
||||
[6] = 10,
|
||||
};
|
||||
|
||||
const u8 gItemEffect_MaxEther[7] = {
|
||||
[4] = ITEM4_HEAL_PP_ONE | ITEM4_HEAL_PP_ALL,
|
||||
[6] = 0x7F,
|
||||
[4] = ITEM4_HEAL_PP_ONE | ITEM4_HEAL_PP,
|
||||
[6] = ITEM6_HEAL_PP_FULL,
|
||||
};
|
||||
|
||||
const u8 gItemEffect_Elixir[7] = {
|
||||
[4] = ITEM4_HEAL_PP_ALL,
|
||||
[6] = 10,
|
||||
[4] = ITEM4_HEAL_PP,
|
||||
[6] = 10, // Amount of PP to recover
|
||||
};
|
||||
|
||||
const u8 gItemEffect_MaxElixir[7] = {
|
||||
[4] = ITEM4_HEAL_PP_ALL,
|
||||
[6] = 0x7F,
|
||||
[4] = ITEM4_HEAL_PP,
|
||||
[6] = ITEM6_HEAL_PP_FULL,
|
||||
};
|
||||
|
||||
const u8 gItemEffect_LavaCookie[6] = {
|
||||
@ -151,137 +151,125 @@ const u8 gItemEffect_RedFlute[6] = {
|
||||
|
||||
const u8 gItemEffect_BerryJuice[7] = {
|
||||
[4] = ITEM4_HEAL_HP,
|
||||
[6] = 20,
|
||||
[6] = 20, // Amount of HP to recover
|
||||
};
|
||||
|
||||
const u8 gItemEffect_SacredAsh[7] = {
|
||||
[0] = ITEM0_SACRED_ASH,
|
||||
[4] = ITEM4_REVIVE | ITEM4_HEAL_HP,
|
||||
[6] = ITEM6_HEAL_FULL,
|
||||
[6] = ITEM6_HEAL_HP_FULL,
|
||||
};
|
||||
|
||||
#define VITAMIN_FRIENDSHIP_CHANGE(i) \
|
||||
[(i) + 0] = 5, /* Friendship change, low */ \
|
||||
[(i) + 1] = 3, /* Friendship change, mid */ \
|
||||
[(i) + 2] = 2 /* Friendship change, high */
|
||||
|
||||
const u8 gItemEffect_HPUp[10] = {
|
||||
[4] = ITEM4_EV_HP,
|
||||
[5] = ITEM5_FRIENDSHIP_ALL,
|
||||
[6] = ITEM6_ADD_EV,
|
||||
[7] = 5,
|
||||
[8] = 3,
|
||||
[9] = 2,
|
||||
VITAMIN_FRIENDSHIP_CHANGE(7),
|
||||
};
|
||||
|
||||
const u8 gItemEffect_Protein[10] = {
|
||||
[4] = ITEM4_EV_ATK,
|
||||
[5] = ITEM5_FRIENDSHIP_ALL,
|
||||
[6] = ITEM6_ADD_EV,
|
||||
[7] = 5,
|
||||
[8] = 3,
|
||||
[9] = 2,
|
||||
VITAMIN_FRIENDSHIP_CHANGE(7),
|
||||
};
|
||||
|
||||
const u8 gItemEffect_Iron[10] = {
|
||||
[5] = ITEM5_EV_DEF | ITEM5_FRIENDSHIP_ALL,
|
||||
[6] = ITEM6_ADD_EV,
|
||||
[7] = 5,
|
||||
[8] = 3,
|
||||
[9] = 2,
|
||||
VITAMIN_FRIENDSHIP_CHANGE(7),
|
||||
};
|
||||
|
||||
const u8 gItemEffect_Carbos[10] = {
|
||||
[5] = ITEM5_EV_SPEED | ITEM5_FRIENDSHIP_ALL,
|
||||
[6] = ITEM6_ADD_EV,
|
||||
[7] = 5,
|
||||
[8] = 3,
|
||||
[9] = 2,
|
||||
VITAMIN_FRIENDSHIP_CHANGE(7),
|
||||
};
|
||||
|
||||
const u8 gItemEffect_Calcium[10] = {
|
||||
[5] = ITEM5_EV_SPATK | ITEM5_FRIENDSHIP_ALL,
|
||||
[6] = ITEM6_ADD_EV,
|
||||
[7] = 5,
|
||||
[8] = 3,
|
||||
[9] = 2,
|
||||
VITAMIN_FRIENDSHIP_CHANGE(7),
|
||||
};
|
||||
|
||||
const u8 gItemEffect_RareCandy[10] = {
|
||||
[3] = ITEM3_LEVEL_UP,
|
||||
[4] = ITEM4_REVIVE | ITEM4_HEAL_HP,
|
||||
[5] = ITEM5_FRIENDSHIP_ALL,
|
||||
[6] = ITEM6_HEAL_LVL_UP,
|
||||
[7] = 5,
|
||||
[8] = 3,
|
||||
[9] = 2,
|
||||
[6] = ITEM6_HEAL_HP_LVL_UP,
|
||||
VITAMIN_FRIENDSHIP_CHANGE(7),
|
||||
};
|
||||
|
||||
const u8 gItemEffect_PPUp[9] = {
|
||||
[4] = ITEM4_PP_UP,
|
||||
[5] = ITEM5_FRIENDSHIP_ALL,
|
||||
[6] = 5,
|
||||
[7] = 3,
|
||||
[8] = 2,
|
||||
VITAMIN_FRIENDSHIP_CHANGE(6),
|
||||
};
|
||||
|
||||
const u8 gItemEffect_Zinc[10] = {
|
||||
[5] = ITEM5_EV_SPDEF | ITEM5_FRIENDSHIP_ALL,
|
||||
[6] = ITEM6_ADD_EV,
|
||||
[7] = 5,
|
||||
[8] = 3,
|
||||
[9] = 2,
|
||||
VITAMIN_FRIENDSHIP_CHANGE(7),
|
||||
};
|
||||
|
||||
const u8 gItemEffect_PPMax[9] = {
|
||||
[5] = ITEM5_PP_MAX | ITEM5_FRIENDSHIP_ALL,
|
||||
[6] = 5,
|
||||
[7] = 3,
|
||||
[8] = 2,
|
||||
VITAMIN_FRIENDSHIP_CHANGE(6),
|
||||
};
|
||||
|
||||
#define STAT_BOOST_FRIENDSHIP_CHANGE \
|
||||
[6] = 1, /* Friendship change, low */ \
|
||||
[7] = 1 /* Friendship change, mid */
|
||||
|
||||
const u8 gItemEffect_GuardSpec[8] = {
|
||||
[3] = ITEM3_GUARD_SPEC,
|
||||
[5] = ITEM5_FRIENDSHIP_LOW | ITEM5_FRIENDSHIP_MID,
|
||||
[6] = 1,
|
||||
[7] = 1,
|
||||
STAT_BOOST_FRIENDSHIP_CHANGE,
|
||||
};
|
||||
|
||||
// The first item effect value for the stat boost items
|
||||
// only uses the least significant bit of its full mask.
|
||||
// The full constant is commented next to it
|
||||
|
||||
const u8 gItemEffect_DireHit[8] = {
|
||||
[0] = 2 << 4,
|
||||
[0] = 1 << 5, // ITEM0_DIRE_HIT
|
||||
[5] = ITEM5_FRIENDSHIP_LOW | ITEM5_FRIENDSHIP_MID,
|
||||
[6] = 1,
|
||||
[7] = 1,
|
||||
STAT_BOOST_FRIENDSHIP_CHANGE,
|
||||
};
|
||||
|
||||
const u8 gItemEffect_XAttack[8] = {
|
||||
[0] = 1,
|
||||
[0] = 1, // ITEM0_X_ATTACK
|
||||
[5] = ITEM5_FRIENDSHIP_LOW | ITEM5_FRIENDSHIP_MID,
|
||||
[6] = 1,
|
||||
[7] = 1,
|
||||
STAT_BOOST_FRIENDSHIP_CHANGE,
|
||||
};
|
||||
|
||||
const u8 gItemEffect_XDefend[8] = {
|
||||
[1] = 1 << 4,
|
||||
[1] = 1 << 4, /// ITEM1_X_DEFEND
|
||||
[5] = ITEM5_FRIENDSHIP_LOW | ITEM5_FRIENDSHIP_MID,
|
||||
[6] = 1,
|
||||
[7] = 1,
|
||||
STAT_BOOST_FRIENDSHIP_CHANGE,
|
||||
};
|
||||
|
||||
const u8 gItemEffect_XSpeed[8] = {
|
||||
[1] = 1,
|
||||
[1] = 1, // ITEM1_X_SPEED
|
||||
[5] = ITEM5_FRIENDSHIP_LOW | ITEM5_FRIENDSHIP_MID,
|
||||
[6] = 1,
|
||||
[7] = 1,
|
||||
STAT_BOOST_FRIENDSHIP_CHANGE,
|
||||
};
|
||||
|
||||
const u8 gItemEffect_XAccuracy[8] = {
|
||||
[2] = 1 << 4,
|
||||
[2] = 1 << 4, // ITEM2_X_ACCURACY
|
||||
[5] = ITEM5_FRIENDSHIP_LOW | ITEM5_FRIENDSHIP_MID,
|
||||
[6] = 1,
|
||||
[7] = 1,
|
||||
STAT_BOOST_FRIENDSHIP_CHANGE,
|
||||
};
|
||||
|
||||
const u8 gItemEffect_XSpecial[8] = {
|
||||
[2] = 1,
|
||||
[2] = 1, // ITEM2_X_SPATK
|
||||
[5] = ITEM5_FRIENDSHIP_LOW | ITEM5_FRIENDSHIP_MID,
|
||||
[6] = 1,
|
||||
[7] = 1,
|
||||
STAT_BOOST_FRIENDSHIP_CHANGE,
|
||||
};
|
||||
|
||||
const u8 gItemEffect_SunStone[6] = {
|
||||
@ -329,13 +317,13 @@ const u8 gItemEffect_AspearBerry[6] = {
|
||||
};
|
||||
|
||||
const u8 gItemEffect_LeppaBerry[7] = {
|
||||
[4] = ITEM4_HEAL_PP_ONE | ITEM4_HEAL_PP_ALL,
|
||||
[6] = 10,
|
||||
[4] = ITEM4_HEAL_PP_ONE | ITEM4_HEAL_PP,
|
||||
[6] = 10, // Amount of PP to recover
|
||||
};
|
||||
|
||||
const u8 gItemEffect_OranBerry[7] = {
|
||||
[4] = ITEM4_HEAL_HP,
|
||||
[6] = 10,
|
||||
[6] = 10, // Amount of HP to recover
|
||||
};
|
||||
|
||||
const u8 gItemEffect_PersimBerry[6] = {
|
||||
@ -348,57 +336,50 @@ const u8 gItemEffect_LumBerry[6] = {
|
||||
|
||||
const u8 gItemEffect_SitrusBerry[7] = {
|
||||
[4] = ITEM4_HEAL_HP,
|
||||
[6] = 30,
|
||||
[6] = 30, // Amount of HP to recover
|
||||
};
|
||||
|
||||
#define EV_BERRY_FRIENDSHIP_CHANGE \
|
||||
[7] = 10, /* Friendship change, low */ \
|
||||
[8] = 5, /* Friendship change, mid */ \
|
||||
[9] = 2 /* Friendship change, high */
|
||||
|
||||
const u8 gItemEffect_PomegBerry[10] = {
|
||||
[4] = ITEM4_EV_HP,
|
||||
[5] = ITEM5_FRIENDSHIP_ALL,
|
||||
[6] = ITEM6_SUBTRACT_EV,
|
||||
[7] = 10,
|
||||
[8] = 5,
|
||||
[9] = 2,
|
||||
EV_BERRY_FRIENDSHIP_CHANGE,
|
||||
};
|
||||
|
||||
const u8 gItemEffect_KelpsyBerry[10] = {
|
||||
[4] = ITEM4_EV_ATK,
|
||||
[5] = ITEM5_FRIENDSHIP_ALL,
|
||||
[6] = ITEM6_SUBTRACT_EV,
|
||||
[7] = 10,
|
||||
[8] = 5,
|
||||
[9] = 2,
|
||||
EV_BERRY_FRIENDSHIP_CHANGE,
|
||||
};
|
||||
|
||||
const u8 gItemEffect_QualotBerry[10] = {
|
||||
[5] = ITEM5_EV_DEF | ITEM5_FRIENDSHIP_ALL,
|
||||
[6] = ITEM6_SUBTRACT_EV,
|
||||
[7] = 10,
|
||||
[8] = 5,
|
||||
[9] = 2,
|
||||
EV_BERRY_FRIENDSHIP_CHANGE,
|
||||
};
|
||||
|
||||
const u8 gItemEffect_HondewBerry[10] = {
|
||||
[5] = ITEM5_EV_SPATK | ITEM5_FRIENDSHIP_ALL,
|
||||
[6] = ITEM6_SUBTRACT_EV,
|
||||
[7] = 10,
|
||||
[8] = 5,
|
||||
[9] = 2,
|
||||
EV_BERRY_FRIENDSHIP_CHANGE,
|
||||
};
|
||||
|
||||
const u8 gItemEffect_GrepaBerry[10] = {
|
||||
[5] = ITEM5_EV_SPDEF | ITEM5_FRIENDSHIP_ALL,
|
||||
[6] = ITEM6_SUBTRACT_EV,
|
||||
[7] = 10,
|
||||
[8] = 5,
|
||||
[9] = 2,
|
||||
EV_BERRY_FRIENDSHIP_CHANGE,
|
||||
};
|
||||
|
||||
const u8 gItemEffect_TamatoBerry[10] = {
|
||||
[5] = ITEM5_EV_SPEED | ITEM5_FRIENDSHIP_ALL,
|
||||
[6] = ITEM6_SUBTRACT_EV,
|
||||
[7] = 10,
|
||||
[8] = 5,
|
||||
[9] = 2,
|
||||
EV_BERRY_FRIENDSHIP_CHANGE,
|
||||
};
|
||||
|
||||
const u8 *const gItemEffectTable[] =
|
||||
|
@ -915,7 +915,7 @@ static bool8 DisplayPartyPokemonDataForMoveTutorOrEvolutionItem(u8 slot)
|
||||
DisplayPartyPokemonDataToTeachMove(slot, item, 0);
|
||||
break;
|
||||
case 2: // Evolution stone
|
||||
if (!GetMonData(currentPokemon, MON_DATA_IS_EGG) && GetEvolutionTargetSpecies(currentPokemon, 3, item) != SPECIES_NONE)
|
||||
if (!GetMonData(currentPokemon, MON_DATA_IS_EGG) && GetEvolutionTargetSpecies(currentPokemon, EVO_MODE_ITEM_CHECK, item) != SPECIES_NONE)
|
||||
return FALSE;
|
||||
DisplayPartyPokemonDescriptionData(slot, PARTYBOX_DESC_NO_USE);
|
||||
break;
|
||||
@ -5018,13 +5018,13 @@ static void Task_TryLearningNextMove(u8 taskId)
|
||||
static void PartyMenuTryEvolution(u8 taskId)
|
||||
{
|
||||
struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId];
|
||||
u16 targetSpecies = GetEvolutionTargetSpecies(mon, 0, 0);
|
||||
u16 targetSpecies = GetEvolutionTargetSpecies(mon, EVO_MODE_NORMAL, ITEM_NONE);
|
||||
|
||||
if (targetSpecies != SPECIES_NONE)
|
||||
{
|
||||
FreePartyPointers();
|
||||
gCB2_AfterEvolution = gPartyMenu.exitCallback;
|
||||
BeginEvolutionScene(mon, targetSpecies, 1, gPartyMenu.slotId);
|
||||
BeginEvolutionScene(mon, targetSpecies, TRUE, gPartyMenu.slotId);
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
else
|
||||
@ -5232,7 +5232,7 @@ u8 GetItemEffectType(u16 item)
|
||||
return ITEM_EFFECT_PP_UP;
|
||||
else if (itemEffect[5] & ITEM5_PP_MAX)
|
||||
return ITEM_EFFECT_PP_MAX;
|
||||
else if (itemEffect[4] & (ITEM4_HEAL_PP_ALL | ITEM4_HEAL_PP_ONE))
|
||||
else if (itemEffect[4] & (ITEM4_HEAL_PP | ITEM4_HEAL_PP_ONE))
|
||||
return ITEM_EFFECT_HEAL_PP;
|
||||
else
|
||||
return ITEM_EFFECT_NONE;
|
||||
|
554
src/pokemon.c
554
src/pokemon.c
@ -4640,29 +4640,56 @@ void CopyPlayerPartyMonToBattleData(u8 battlerId, u8 partyIndex)
|
||||
|
||||
bool8 ExecuteTableBasedItemEffect(struct Pokemon *mon, u16 item, u8 partyIndex, u8 moveIndex)
|
||||
{
|
||||
return PokemonUseItemEffects(mon, item, partyIndex, moveIndex, 0);
|
||||
return PokemonUseItemEffects(mon, item, partyIndex, moveIndex, FALSE);
|
||||
}
|
||||
|
||||
bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 moveIndex, u8 e)
|
||||
#define UPDATE_FRIENDSHIP_FROM_ITEM \
|
||||
{ \
|
||||
if ((retVal == 0 || friendshipOnly) && !ShouldSkipFriendshipChange() && friendshipChange == 0) \
|
||||
{ \
|
||||
friendshipChange = itemEffect[itemEffectParam]; \
|
||||
friendship = GetMonData(mon, MON_DATA_FRIENDSHIP, NULL); \
|
||||
if (friendshipChange > 0 && holdEffect == HOLD_EFFECT_HAPPINESS_UP) \
|
||||
friendship += 150 * friendshipChange / 100; \
|
||||
else \
|
||||
friendship += friendshipChange; \
|
||||
if (friendshipChange > 0) \
|
||||
{ \
|
||||
if (GetMonData(mon, MON_DATA_POKEBALL, NULL) == ITEM_LUXURY_BALL) \
|
||||
friendship++; \
|
||||
if (GetMonData(mon, MON_DATA_MET_LOCATION, NULL) == GetCurrentRegionMapSectionId()) \
|
||||
friendship++; \
|
||||
} \
|
||||
if (friendship < 0) \
|
||||
friendship = 0; \
|
||||
if (friendship > MAX_FRIENDSHIP) \
|
||||
friendship = MAX_FRIENDSHIP; \
|
||||
SetMonData(mon, MON_DATA_FRIENDSHIP, &friendship); \
|
||||
retVal = FALSE; \
|
||||
} \
|
||||
}
|
||||
|
||||
// Returns TRUE if the item has no effect on the Pokémon, FALSE otherwise
|
||||
bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 moveIndex, bool8 usedByAI)
|
||||
{
|
||||
u32 dataUnsigned;
|
||||
s32 dataSigned;
|
||||
s32 friendship;
|
||||
s32 cmdIndex;
|
||||
s32 i;
|
||||
bool8 retVal = TRUE;
|
||||
const u8 *itemEffect;
|
||||
u8 var_3C = 6;
|
||||
u32 var_38;
|
||||
s8 var_34 = 0;
|
||||
u8 itemEffectParam = ITEM_EFFECT_ARG_START;
|
||||
u32 temp1, temp2;
|
||||
s8 friendshipChange = 0;
|
||||
u8 holdEffect;
|
||||
u8 battlerId = 4;
|
||||
u32 var_28 = 0;
|
||||
u8 battlerId = MAX_BATTLERS_COUNT;
|
||||
u32 friendshipOnly = FALSE;
|
||||
u16 heldItem;
|
||||
u8 r10;
|
||||
u32 r5;
|
||||
s8 r2;
|
||||
u8 effectFlags;
|
||||
s8 evChange;
|
||||
u16 evCount;
|
||||
|
||||
// Get item hold effect
|
||||
heldItem = GetMonData(mon, MON_DATA_HELD_ITEM, NULL);
|
||||
if (heldItem == ITEM_ENIGMA_BERRY)
|
||||
{
|
||||
@ -4676,19 +4703,20 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov
|
||||
holdEffect = ItemId_GetHoldEffect(heldItem);
|
||||
}
|
||||
|
||||
// Get battler id (if relevant)
|
||||
gPotentialItemEffectBattler = gBattlerInMenuId;
|
||||
if (gMain.inBattle)
|
||||
{
|
||||
gActiveBattler = gBattlerInMenuId;
|
||||
cmdIndex = (GetBattlerSide(gActiveBattler) != B_SIDE_PLAYER);
|
||||
while (cmdIndex < gBattlersCount)
|
||||
i = (GetBattlerSide(gActiveBattler) != B_SIDE_PLAYER);
|
||||
while (i < gBattlersCount)
|
||||
{
|
||||
if (gBattlerPartyIndexes[cmdIndex] == partyIndex)
|
||||
if (gBattlerPartyIndexes[i] == partyIndex)
|
||||
{
|
||||
battlerId = cmdIndex;
|
||||
battlerId = i;
|
||||
break;
|
||||
}
|
||||
cmdIndex += 2;
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -4697,11 +4725,13 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov
|
||||
battlerId = MAX_BATTLERS_COUNT;
|
||||
}
|
||||
|
||||
// Skip using the item if it won't do anything
|
||||
if (!ITEM_HAS_EFFECT(item))
|
||||
return TRUE;
|
||||
if (gItemEffectTable[item - ITEM_POTION] == NULL && item != ITEM_ENIGMA_BERRY)
|
||||
return TRUE;
|
||||
|
||||
// Get item effect
|
||||
if (item == ITEM_ENIGMA_BERRY)
|
||||
{
|
||||
if (gMain.inBattle)
|
||||
@ -4714,79 +4744,98 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov
|
||||
itemEffect = gItemEffectTable[item - ITEM_POTION];
|
||||
}
|
||||
|
||||
for (cmdIndex = 0; cmdIndex < 6; cmdIndex++)
|
||||
// Do item effect
|
||||
for (i = 0; i < ITEM_EFFECT_ARG_START; i++)
|
||||
{
|
||||
switch (cmdIndex)
|
||||
switch (i)
|
||||
{
|
||||
// infatuation heal, x attack, sacred ash and dire hit
|
||||
|
||||
// Handle ITEM0 effects (infatuation, Dire Hit, X Attack). ITEM0_SACRED_ASH is handled in party_menu.c
|
||||
case 0:
|
||||
if ((itemEffect[cmdIndex] & ITEM0_INFATUATION)
|
||||
// Cure infatuation
|
||||
if ((itemEffect[i] & ITEM0_INFATUATION)
|
||||
&& gMain.inBattle && battlerId != MAX_BATTLERS_COUNT && (gBattleMons[battlerId].status2 & STATUS2_INFATUATION))
|
||||
{
|
||||
gBattleMons[battlerId].status2 &= ~STATUS2_INFATUATION;
|
||||
retVal = FALSE;
|
||||
}
|
||||
if ((itemEffect[cmdIndex] & ITEM0_DIRE_HIT)
|
||||
|
||||
// Dire Hit
|
||||
if ((itemEffect[i] & ITEM0_DIRE_HIT)
|
||||
&& !(gBattleMons[gActiveBattler].status2 & STATUS2_FOCUS_ENERGY))
|
||||
{
|
||||
gBattleMons[gActiveBattler].status2 |= STATUS2_FOCUS_ENERGY;
|
||||
retVal = FALSE;
|
||||
}
|
||||
if ((itemEffect[cmdIndex] & ITEM0_X_ATTACK)
|
||||
|
||||
// X Attack
|
||||
if ((itemEffect[i] & ITEM0_X_ATTACK)
|
||||
&& gBattleMons[gActiveBattler].statStages[STAT_ATK] < MAX_STAT_STAGE)
|
||||
{
|
||||
gBattleMons[gActiveBattler].statStages[STAT_ATK] += itemEffect[cmdIndex] & ITEM0_X_ATTACK;
|
||||
gBattleMons[gActiveBattler].statStages[STAT_ATK] += itemEffect[i] & ITEM0_X_ATTACK;
|
||||
if (gBattleMons[gActiveBattler].statStages[STAT_ATK] > MAX_STAT_STAGE)
|
||||
gBattleMons[gActiveBattler].statStages[STAT_ATK] = MAX_STAT_STAGE;
|
||||
retVal = FALSE;
|
||||
}
|
||||
break;
|
||||
// in-battle stat boosting effects
|
||||
|
||||
// Handle ITEM1 effects (in-battle stat boosting effects)
|
||||
case 1:
|
||||
if ((itemEffect[cmdIndex] & ITEM1_X_DEFEND)
|
||||
// X Defend
|
||||
if ((itemEffect[i] & ITEM1_X_DEFEND)
|
||||
&& gBattleMons[gActiveBattler].statStages[STAT_DEF] < MAX_STAT_STAGE)
|
||||
{
|
||||
gBattleMons[gActiveBattler].statStages[STAT_DEF] += (itemEffect[cmdIndex] & ITEM1_X_DEFEND) >> 4;
|
||||
gBattleMons[gActiveBattler].statStages[STAT_DEF] += (itemEffect[i] & ITEM1_X_DEFEND) >> 4;
|
||||
if (gBattleMons[gActiveBattler].statStages[STAT_DEF] > MAX_STAT_STAGE)
|
||||
gBattleMons[gActiveBattler].statStages[STAT_DEF] = MAX_STAT_STAGE;
|
||||
retVal = FALSE;
|
||||
}
|
||||
if ((itemEffect[cmdIndex] & ITEM1_X_SPEED)
|
||||
|
||||
// X Speed
|
||||
if ((itemEffect[i] & ITEM1_X_SPEED)
|
||||
&& gBattleMons[gActiveBattler].statStages[STAT_SPEED] < MAX_STAT_STAGE)
|
||||
{
|
||||
gBattleMons[gActiveBattler].statStages[STAT_SPEED] += itemEffect[cmdIndex] & ITEM1_X_SPEED;
|
||||
gBattleMons[gActiveBattler].statStages[STAT_SPEED] += itemEffect[i] & ITEM1_X_SPEED;
|
||||
if (gBattleMons[gActiveBattler].statStages[STAT_SPEED] > MAX_STAT_STAGE)
|
||||
gBattleMons[gActiveBattler].statStages[STAT_SPEED] = MAX_STAT_STAGE;
|
||||
retVal = FALSE;
|
||||
}
|
||||
break;
|
||||
// more stat boosting effects
|
||||
// Handle ITEM2 effects (more stat boosting effects)
|
||||
case 2:
|
||||
if ((itemEffect[cmdIndex] & ITEM2_X_ACCURACY)
|
||||
// X Accuracy
|
||||
if ((itemEffect[i] & ITEM2_X_ACCURACY)
|
||||
&& gBattleMons[gActiveBattler].statStages[STAT_ACC] < MAX_STAT_STAGE)
|
||||
{
|
||||
gBattleMons[gActiveBattler].statStages[STAT_ACC] += (itemEffect[cmdIndex] & ITEM2_X_ACCURACY) >> 4;
|
||||
gBattleMons[gActiveBattler].statStages[STAT_ACC] += (itemEffect[i] & ITEM2_X_ACCURACY) >> 4;
|
||||
if (gBattleMons[gActiveBattler].statStages[STAT_ACC] > MAX_STAT_STAGE)
|
||||
gBattleMons[gActiveBattler].statStages[STAT_ACC] = MAX_STAT_STAGE;
|
||||
retVal = FALSE;
|
||||
}
|
||||
if ((itemEffect[cmdIndex] & ITEM2_X_SPATK)
|
||||
|
||||
// X Sp Attack
|
||||
if ((itemEffect[i] & ITEM2_X_SPATK)
|
||||
&& gBattleMons[gActiveBattler].statStages[STAT_SPATK] < MAX_STAT_STAGE)
|
||||
{
|
||||
gBattleMons[gActiveBattler].statStages[STAT_SPATK] += itemEffect[cmdIndex] & ITEM2_X_SPATK;
|
||||
gBattleMons[gActiveBattler].statStages[STAT_SPATK] += itemEffect[i] & ITEM2_X_SPATK;
|
||||
if (gBattleMons[gActiveBattler].statStages[STAT_SPATK] > MAX_STAT_STAGE)
|
||||
gBattleMons[gActiveBattler].statStages[STAT_SPATK] = MAX_STAT_STAGE;
|
||||
retVal = FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
// Handle ITEM3 effects (Guard Spec, Rare Candy, cure status)
|
||||
case 3:
|
||||
if ((itemEffect[cmdIndex] & ITEM3_GUARD_SPEC)
|
||||
// Guard Spec
|
||||
if ((itemEffect[i] & ITEM3_GUARD_SPEC)
|
||||
&& gSideTimers[GetBattlerSide(gActiveBattler)].mistTimer == 0)
|
||||
{
|
||||
gSideTimers[GetBattlerSide(gActiveBattler)].mistTimer = 5;
|
||||
retVal = FALSE;
|
||||
}
|
||||
if ((itemEffect[cmdIndex] & ITEM3_LEVEL_UP)
|
||||
|
||||
// Rare Candy
|
||||
if ((itemEffect[i] & ITEM3_LEVEL_UP)
|
||||
&& GetMonData(mon, MON_DATA_LEVEL, NULL) != MAX_LEVEL)
|
||||
{
|
||||
dataUnsigned = gExperienceTables[gBaseStats[GetMonData(mon, MON_DATA_SPECIES, NULL)].growthRate][GetMonData(mon, MON_DATA_LEVEL, NULL) + 1];
|
||||
@ -4794,106 +4843,120 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov
|
||||
CalculateMonStats(mon);
|
||||
retVal = FALSE;
|
||||
}
|
||||
if ((itemEffect[cmdIndex] & ITEM3_SLEEP)
|
||||
&& HealStatusConditions(mon, partyIndex, 7, battlerId) == 0)
|
||||
|
||||
// Cure status
|
||||
if ((itemEffect[i] & ITEM3_SLEEP)
|
||||
&& HealStatusConditions(mon, partyIndex, STATUS1_SLEEP, battlerId) == 0)
|
||||
{
|
||||
if (battlerId != 4)
|
||||
if (battlerId != MAX_BATTLERS_COUNT)
|
||||
gBattleMons[battlerId].status2 &= ~STATUS2_NIGHTMARE;
|
||||
retVal = FALSE;
|
||||
}
|
||||
if ((itemEffect[cmdIndex] & ITEM3_POISON) && HealStatusConditions(mon, partyIndex, STATUS1_PSN_ANY | STATUS1_TOXIC_COUNTER, battlerId) == 0)
|
||||
if ((itemEffect[i] & ITEM3_POISON) && HealStatusConditions(mon, partyIndex, STATUS1_PSN_ANY | STATUS1_TOXIC_COUNTER, battlerId) == 0)
|
||||
retVal = FALSE;
|
||||
if ((itemEffect[cmdIndex] & ITEM3_BURN) && HealStatusConditions(mon, partyIndex, STATUS1_BURN, battlerId) == 0)
|
||||
if ((itemEffect[i] & ITEM3_BURN) && HealStatusConditions(mon, partyIndex, STATUS1_BURN, battlerId) == 0)
|
||||
retVal = FALSE;
|
||||
if ((itemEffect[cmdIndex] & ITEM3_FREEZE) && HealStatusConditions(mon, partyIndex, STATUS1_FREEZE, battlerId) == 0)
|
||||
if ((itemEffect[i] & ITEM3_FREEZE) && HealStatusConditions(mon, partyIndex, STATUS1_FREEZE, battlerId) == 0)
|
||||
retVal = FALSE;
|
||||
if ((itemEffect[cmdIndex] & ITEM3_PARALYSIS) && HealStatusConditions(mon, partyIndex, STATUS1_PARALYSIS, battlerId) == 0)
|
||||
if ((itemEffect[i] & ITEM3_PARALYSIS) && HealStatusConditions(mon, partyIndex, STATUS1_PARALYSIS, battlerId) == 0)
|
||||
retVal = FALSE;
|
||||
if ((itemEffect[cmdIndex] & ITEM3_CONFUSION) // heal confusion
|
||||
if ((itemEffect[i] & ITEM3_CONFUSION) // heal confusion
|
||||
&& gMain.inBattle && battlerId != MAX_BATTLERS_COUNT && (gBattleMons[battlerId].status2 & STATUS2_CONFUSION))
|
||||
{
|
||||
gBattleMons[battlerId].status2 &= ~STATUS2_CONFUSION;
|
||||
retVal = FALSE;
|
||||
}
|
||||
break;
|
||||
// EV, HP, and PP raising effects
|
||||
|
||||
// Handle ITEM4 effects (Change HP/Atk EVs, HP heal, PP heal, PP up, Revive, and evolution stones)
|
||||
case 4:
|
||||
r10 = itemEffect[cmdIndex];
|
||||
if (r10 & ITEM4_PP_UP)
|
||||
effectFlags = itemEffect[i];
|
||||
|
||||
// PP Up
|
||||
if (effectFlags & ITEM4_PP_UP)
|
||||
{
|
||||
r10 &= ~ITEM4_PP_UP;
|
||||
effectFlags &= ~ITEM4_PP_UP;
|
||||
dataUnsigned = (GetMonData(mon, MON_DATA_PP_BONUSES, NULL) & gPPUpGetMask[moveIndex]) >> (moveIndex * 2);
|
||||
var_38 = CalculatePPWithBonus(GetMonData(mon, MON_DATA_MOVE1 + moveIndex, NULL), GetMonData(mon, MON_DATA_PP_BONUSES, NULL), moveIndex);
|
||||
if (dataUnsigned <= 2 && var_38 > 4)
|
||||
temp1 = CalculatePPWithBonus(GetMonData(mon, MON_DATA_MOVE1 + moveIndex, NULL), GetMonData(mon, MON_DATA_PP_BONUSES, NULL), moveIndex);
|
||||
if (dataUnsigned <= 2 && temp1 > 4)
|
||||
{
|
||||
dataUnsigned = GetMonData(mon, MON_DATA_PP_BONUSES, NULL) + gPPUpAddMask[moveIndex];
|
||||
SetMonData(mon, MON_DATA_PP_BONUSES, &dataUnsigned);
|
||||
|
||||
dataUnsigned = CalculatePPWithBonus(GetMonData(mon, MON_DATA_MOVE1 + moveIndex, NULL), dataUnsigned, moveIndex) - var_38;
|
||||
dataUnsigned = CalculatePPWithBonus(GetMonData(mon, MON_DATA_MOVE1 + moveIndex, NULL), dataUnsigned, moveIndex) - temp1;
|
||||
dataUnsigned = GetMonData(mon, MON_DATA_PP1 + moveIndex, NULL) + dataUnsigned;
|
||||
SetMonData(mon, MON_DATA_PP1 + moveIndex, &dataUnsigned);
|
||||
retVal = FALSE;
|
||||
}
|
||||
}
|
||||
var_38 = 0;
|
||||
while (r10 != 0)
|
||||
temp1 = 0;
|
||||
|
||||
// Loop through and try each of the remaining ITEM4 effects
|
||||
while (effectFlags != 0)
|
||||
{
|
||||
if (r10 & 1)
|
||||
if (effectFlags & 1)
|
||||
{
|
||||
switch (var_38)
|
||||
switch (temp1)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
// ev raise
|
||||
case 0: // ITEM4_EV_HP
|
||||
case 1: // ITEM4_EV_ATK
|
||||
evCount = GetMonEVCount(mon);
|
||||
r5 = itemEffect[var_3C];
|
||||
dataSigned = GetMonData(mon, sGetMonDataEVConstants[var_38], NULL);
|
||||
r2 = r5;
|
||||
if (r2 > 0)
|
||||
temp2 = itemEffect[itemEffectParam];
|
||||
dataSigned = GetMonData(mon, sGetMonDataEVConstants[temp1], NULL);
|
||||
evChange = temp2;
|
||||
|
||||
if (evChange > 0) // Increasing EV (HP or Atk)
|
||||
{
|
||||
// Has EV increase limit already been reached?
|
||||
if (evCount >= MAX_TOTAL_EVS)
|
||||
return TRUE;
|
||||
if (dataSigned >= EV_ITEM_RAISE_LIMIT)
|
||||
break;
|
||||
|
||||
if (dataSigned + r2 > EV_ITEM_RAISE_LIMIT)
|
||||
r5 = EV_ITEM_RAISE_LIMIT - (dataSigned + r2) + r2;
|
||||
// Limit the increase
|
||||
if (dataSigned + evChange > EV_ITEM_RAISE_LIMIT)
|
||||
temp2 = EV_ITEM_RAISE_LIMIT - (dataSigned + evChange) + evChange;
|
||||
else
|
||||
r5 = r2;
|
||||
temp2 = evChange;
|
||||
|
||||
if (evCount + r5 > MAX_TOTAL_EVS)
|
||||
r5 += MAX_TOTAL_EVS - (evCount + r5);
|
||||
dataSigned += r5;
|
||||
if (evCount + temp2 > MAX_TOTAL_EVS)
|
||||
temp2 += MAX_TOTAL_EVS - (evCount + temp2);
|
||||
|
||||
dataSigned += temp2;
|
||||
}
|
||||
else
|
||||
else // Decreasing EV (HP or Atk)
|
||||
{
|
||||
if (dataSigned == 0)
|
||||
{
|
||||
var_28 = 1;
|
||||
var_3C++;
|
||||
// No EVs to lose, but make sure friendship updates anyway
|
||||
friendshipOnly = TRUE;
|
||||
itemEffectParam++;
|
||||
break;
|
||||
}
|
||||
dataSigned += r2;
|
||||
dataSigned += evChange;
|
||||
if (dataSigned < 0)
|
||||
dataSigned = 0;
|
||||
}
|
||||
SetMonData(mon, sGetMonDataEVConstants[var_38], &dataSigned);
|
||||
|
||||
// Update EVs and stats
|
||||
SetMonData(mon, sGetMonDataEVConstants[temp1], &dataSigned);
|
||||
CalculateMonStats(mon);
|
||||
var_3C++;
|
||||
itemEffectParam++;
|
||||
retVal = FALSE;
|
||||
break;
|
||||
case 2:
|
||||
// revive
|
||||
if (r10 & 0x10)
|
||||
|
||||
case 2: // ITEM4_HEAL_HP
|
||||
// If Revive, update number of times revive has been used
|
||||
if (effectFlags & (ITEM4_REVIVE >> 2))
|
||||
{
|
||||
if (GetMonData(mon, MON_DATA_HP, NULL) != 0)
|
||||
{
|
||||
var_3C++;
|
||||
itemEffectParam++;
|
||||
break;
|
||||
}
|
||||
if (gMain.inBattle)
|
||||
{
|
||||
if (battlerId != 4)
|
||||
if (battlerId != MAX_BATTLERS_COUNT)
|
||||
{
|
||||
gAbsentBattlerFlags &= ~gBitTable[battlerId];
|
||||
CopyPlayerPartyMonToBattleData(battlerId, GetPartyIdFromBattlePartyId(gBattlerPartyIndexes[battlerId]));
|
||||
@ -4912,48 +4975,53 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov
|
||||
{
|
||||
if (GetMonData(mon, MON_DATA_HP, NULL) == 0)
|
||||
{
|
||||
var_3C++;
|
||||
itemEffectParam++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Get amount of HP to restore
|
||||
dataUnsigned = itemEffect[var_3C++];
|
||||
dataUnsigned = itemEffect[itemEffectParam++];
|
||||
switch (dataUnsigned)
|
||||
{
|
||||
case ITEM6_HEAL_FULL:
|
||||
case ITEM6_HEAL_HP_FULL:
|
||||
dataUnsigned = GetMonData(mon, MON_DATA_MAX_HP, NULL) - GetMonData(mon, MON_DATA_HP, NULL);
|
||||
break;
|
||||
case ITEM6_HEAL_HALF:
|
||||
case ITEM6_HEAL_HP_HALF:
|
||||
dataUnsigned = GetMonData(mon, MON_DATA_MAX_HP, NULL) / 2;
|
||||
if (dataUnsigned == 0)
|
||||
dataUnsigned = 1;
|
||||
break;
|
||||
case ITEM6_HEAL_LVL_UP:
|
||||
case ITEM6_HEAL_HP_LVL_UP:
|
||||
dataUnsigned = gBattleScripting.levelUpHP;
|
||||
break;
|
||||
}
|
||||
|
||||
// Only restore HP if not at max health
|
||||
if (GetMonData(mon, MON_DATA_MAX_HP, NULL) != GetMonData(mon, MON_DATA_HP, NULL))
|
||||
{
|
||||
if (e == 0)
|
||||
if (!usedByAI)
|
||||
{
|
||||
// Restore HP
|
||||
dataUnsigned = GetMonData(mon, MON_DATA_HP, NULL) + dataUnsigned;
|
||||
if (dataUnsigned > GetMonData(mon, MON_DATA_MAX_HP, NULL))
|
||||
dataUnsigned = GetMonData(mon, MON_DATA_MAX_HP, NULL);
|
||||
SetMonData(mon, MON_DATA_HP, &dataUnsigned);
|
||||
if (gMain.inBattle && battlerId != 4)
|
||||
|
||||
// Update battler (if applicable)
|
||||
if (gMain.inBattle && battlerId != MAX_BATTLERS_COUNT)
|
||||
{
|
||||
gBattleMons[battlerId].hp = dataUnsigned;
|
||||
if (!(r10 & 0x10) && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
|
||||
if (!(effectFlags & (ITEM4_REVIVE >> 2)) && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
|
||||
{
|
||||
if (gBattleResults.numHealingItemsUsed < 255)
|
||||
gBattleResults.numHealingItemsUsed++;
|
||||
// I have to re-use this variable to match.
|
||||
r5 = gActiveBattler;
|
||||
|
||||
temp2 = gActiveBattler;
|
||||
gActiveBattler = battlerId;
|
||||
BtlController_EmitGetMonData(0, REQUEST_ALL_BATTLE, 0);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
gActiveBattler = r5;
|
||||
gActiveBattler = temp2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4963,227 +5031,197 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov
|
||||
}
|
||||
retVal = FALSE;
|
||||
}
|
||||
r10 &= 0xEF;
|
||||
effectFlags &= ~(ITEM4_REVIVE >> 2);
|
||||
break;
|
||||
case 3:
|
||||
// Heal pp in all moves.
|
||||
if (!(r10 & 2))
|
||||
|
||||
case 3: // ITEM4_HEAL_PP
|
||||
if (!(effectFlags & (ITEM4_HEAL_PP_ONE >> 3)))
|
||||
{
|
||||
for (r5 = 0; (signed)(r5) < (signed)(4); r5++)
|
||||
// Heal PP for all moves
|
||||
for (temp2 = 0; (signed)(temp2) < (signed)(MAX_MON_MOVES); temp2++)
|
||||
{
|
||||
u16 moveId;
|
||||
|
||||
dataUnsigned = GetMonData(mon, MON_DATA_PP1 + r5, NULL);
|
||||
moveId = GetMonData(mon, MON_DATA_MOVE1 + r5, NULL);
|
||||
if (dataUnsigned != CalculatePPWithBonus(moveId, GetMonData(mon, MON_DATA_PP_BONUSES, NULL), r5))
|
||||
dataUnsigned = GetMonData(mon, MON_DATA_PP1 + temp2, NULL);
|
||||
moveId = GetMonData(mon, MON_DATA_MOVE1 + temp2, NULL);
|
||||
if (dataUnsigned != CalculatePPWithBonus(moveId, GetMonData(mon, MON_DATA_PP_BONUSES, NULL), temp2))
|
||||
{
|
||||
dataUnsigned += itemEffect[var_3C];
|
||||
moveId = GetMonData(mon, MON_DATA_MOVE1 + r5, NULL);
|
||||
if (dataUnsigned > CalculatePPWithBonus(moveId, GetMonData(mon, MON_DATA_PP_BONUSES, NULL), r5))
|
||||
dataUnsigned += itemEffect[itemEffectParam];
|
||||
moveId = GetMonData(mon, MON_DATA_MOVE1 + temp2, NULL); // Redundant
|
||||
if (dataUnsigned > CalculatePPWithBonus(moveId, GetMonData(mon, MON_DATA_PP_BONUSES, NULL), temp2))
|
||||
{
|
||||
moveId = GetMonData(mon, MON_DATA_MOVE1 + r5, NULL);
|
||||
dataUnsigned = CalculatePPWithBonus(moveId, GetMonData(mon, MON_DATA_PP_BONUSES, NULL), r5);
|
||||
moveId = GetMonData(mon, MON_DATA_MOVE1 + temp2, NULL); // Redundant
|
||||
dataUnsigned = CalculatePPWithBonus(moveId, GetMonData(mon, MON_DATA_PP_BONUSES, NULL), temp2);
|
||||
}
|
||||
SetMonData(mon, MON_DATA_PP1 + r5, &dataUnsigned);
|
||||
SetMonData(mon, MON_DATA_PP1 + temp2, &dataUnsigned);
|
||||
|
||||
// Heal battler PP too (if applicable)
|
||||
if (gMain.inBattle
|
||||
&& battlerId != MAX_BATTLERS_COUNT && !(gBattleMons[battlerId].status2 & STATUS2_TRANSFORMED)
|
||||
&& !(gDisableStructs[battlerId].mimickedMoves & gBitTable[r5]))
|
||||
gBattleMons[battlerId].pp[r5] = dataUnsigned;
|
||||
&& !(gDisableStructs[battlerId].mimickedMoves & gBitTable[temp2]))
|
||||
gBattleMons[battlerId].pp[temp2] = dataUnsigned;
|
||||
|
||||
retVal = FALSE;
|
||||
}
|
||||
}
|
||||
var_3C++;
|
||||
itemEffectParam++;
|
||||
}
|
||||
// Heal pp in one move.
|
||||
else
|
||||
{
|
||||
// Heal PP for one move
|
||||
u16 moveId;
|
||||
|
||||
dataUnsigned = GetMonData(mon, MON_DATA_PP1 + moveIndex, NULL);
|
||||
moveId = GetMonData(mon, MON_DATA_MOVE1 + moveIndex, NULL);
|
||||
if (dataUnsigned != CalculatePPWithBonus(moveId, GetMonData(mon, MON_DATA_PP_BONUSES, NULL), moveIndex))
|
||||
{
|
||||
dataUnsigned += itemEffect[var_3C++];
|
||||
moveId = GetMonData(mon, MON_DATA_MOVE1 + moveIndex, NULL);
|
||||
dataUnsigned += itemEffect[itemEffectParam++];
|
||||
moveId = GetMonData(mon, MON_DATA_MOVE1 + moveIndex, NULL); // Redundant
|
||||
if (dataUnsigned > CalculatePPWithBonus(moveId, GetMonData(mon, MON_DATA_PP_BONUSES, NULL), moveIndex))
|
||||
{
|
||||
moveId = GetMonData(mon, MON_DATA_MOVE1 + moveIndex, NULL);
|
||||
moveId = GetMonData(mon, MON_DATA_MOVE1 + moveIndex, NULL); // Redundant
|
||||
dataUnsigned = CalculatePPWithBonus(moveId, GetMonData(mon, MON_DATA_PP_BONUSES, NULL), moveIndex);
|
||||
}
|
||||
SetMonData(mon, MON_DATA_PP1 + moveIndex, &dataUnsigned);
|
||||
|
||||
// Heal battler PP too (if applicable)
|
||||
if (gMain.inBattle
|
||||
&& battlerId != 4 && !(gBattleMons[battlerId].status2 & STATUS2_TRANSFORMED)
|
||||
&& battlerId != MAX_BATTLERS_COUNT && !(gBattleMons[battlerId].status2 & STATUS2_TRANSFORMED)
|
||||
&& !(gDisableStructs[battlerId].mimickedMoves & gBitTable[moveIndex]))
|
||||
gBattleMons[battlerId].pp[moveIndex] = dataUnsigned;
|
||||
|
||||
retVal = FALSE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
// Evolution stone
|
||||
case 7:
|
||||
|
||||
// cases 4-6 are ITEM4_HEAL_PP_ONE, ITEM4_PP_UP, and ITEM4_REVIVE, which
|
||||
// are already handled above by other cases or before the loop
|
||||
|
||||
case 7: // ITEM4_EVO_STONE
|
||||
{
|
||||
u16 targetSpecies = GetEvolutionTargetSpecies(mon, 2, item);
|
||||
u16 targetSpecies = GetEvolutionTargetSpecies(mon, EVO_MODE_ITEM_USE, item);
|
||||
|
||||
if (targetSpecies != SPECIES_NONE)
|
||||
{
|
||||
BeginEvolutionScene(mon, targetSpecies, 0, partyIndex);
|
||||
BeginEvolutionScene(mon, targetSpecies, FALSE, partyIndex);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
var_38++;
|
||||
r10 >>= 1;
|
||||
temp1++;
|
||||
effectFlags >>= 1;
|
||||
}
|
||||
break;
|
||||
// EV and friendship
|
||||
|
||||
// Handle ITEM5 effects (Change Def/SpDef/SpAtk/Speed EVs, PP Max, and friendship changes)
|
||||
case 5:
|
||||
r10 = itemEffect[cmdIndex];
|
||||
var_38 = 0;
|
||||
while (r10 != 0)
|
||||
effectFlags = itemEffect[i];
|
||||
temp1 = 0;
|
||||
|
||||
// Loop through and try each of the ITEM5 effects
|
||||
while (effectFlags != 0)
|
||||
{
|
||||
if (r10 & 1)
|
||||
if (effectFlags & 1)
|
||||
{
|
||||
switch (var_38)
|
||||
switch (temp1)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 0: // ITEM5_EV_DEF
|
||||
case 1: // ITEM5_EV_SPEED
|
||||
case 2: // ITEM5_EV_SPDEF
|
||||
case 3: // ITEM5_EV_SPATK
|
||||
evCount = GetMonEVCount(mon);
|
||||
r5 = itemEffect[var_3C];
|
||||
dataSigned = GetMonData(mon, sGetMonDataEVConstants[var_38 + 2], NULL);
|
||||
r2 = r5;
|
||||
if (r2 > 0)
|
||||
temp2 = itemEffect[itemEffectParam];
|
||||
dataSigned = GetMonData(mon, sGetMonDataEVConstants[temp1 + 2], NULL);
|
||||
evChange = temp2;
|
||||
if (evChange > 0) // Increasing EV
|
||||
{
|
||||
// Has EV increase limit already been reached?
|
||||
if (evCount >= MAX_TOTAL_EVS)
|
||||
return TRUE;
|
||||
if (dataSigned >= EV_ITEM_RAISE_LIMIT)
|
||||
break;
|
||||
|
||||
if (dataSigned + r2 > EV_ITEM_RAISE_LIMIT)
|
||||
r5 = EV_ITEM_RAISE_LIMIT - (dataSigned + r2) + r2;
|
||||
// Limit the increase
|
||||
if (dataSigned + evChange > EV_ITEM_RAISE_LIMIT)
|
||||
temp2 = EV_ITEM_RAISE_LIMIT - (dataSigned + evChange) + evChange;
|
||||
else
|
||||
r5 = r2;
|
||||
temp2 = evChange;
|
||||
|
||||
if (evCount + r5 > MAX_TOTAL_EVS)
|
||||
r5 += MAX_TOTAL_EVS - (evCount + r5);
|
||||
dataSigned += r5;
|
||||
if (evCount + temp2 > MAX_TOTAL_EVS)
|
||||
temp2 += MAX_TOTAL_EVS - (evCount + temp2);
|
||||
|
||||
dataSigned += temp2;
|
||||
}
|
||||
else
|
||||
else // Decreasing EV
|
||||
{
|
||||
if (dataSigned == 0)
|
||||
{
|
||||
var_28 = 1;
|
||||
var_3C++;
|
||||
// No EVs to lose, but make sure friendship updates anyway
|
||||
friendshipOnly = TRUE;
|
||||
itemEffectParam++;
|
||||
break;
|
||||
}
|
||||
dataSigned += r2;
|
||||
dataSigned += evChange;
|
||||
if (dataSigned < 0)
|
||||
dataSigned = 0;
|
||||
}
|
||||
SetMonData(mon, sGetMonDataEVConstants[var_38 + 2], &dataSigned);
|
||||
|
||||
// Update EVs and stats
|
||||
SetMonData(mon, sGetMonDataEVConstants[temp1 + 2], &dataSigned);
|
||||
CalculateMonStats(mon);
|
||||
retVal = FALSE;
|
||||
var_3C++;
|
||||
itemEffectParam++;
|
||||
break;
|
||||
case 4:
|
||||
|
||||
case 4: // ITEM5_PP_MAX
|
||||
dataUnsigned = (GetMonData(mon, MON_DATA_PP_BONUSES, NULL) & gPPUpGetMask[moveIndex]) >> (moveIndex * 2);
|
||||
r5 = CalculatePPWithBonus(GetMonData(mon, MON_DATA_MOVE1 + moveIndex, NULL), GetMonData(mon, MON_DATA_PP_BONUSES, NULL), moveIndex);
|
||||
if (dataUnsigned < 3 && r5 > 4)
|
||||
temp2 = CalculatePPWithBonus(GetMonData(mon, MON_DATA_MOVE1 + moveIndex, NULL), GetMonData(mon, MON_DATA_PP_BONUSES, NULL), moveIndex);
|
||||
if (dataUnsigned < 3 && temp2 > 4)
|
||||
{
|
||||
dataUnsigned = GetMonData(mon, MON_DATA_PP_BONUSES, NULL);
|
||||
dataUnsigned &= gPPUpSetMask[moveIndex];
|
||||
dataUnsigned += gPPUpAddMask[moveIndex] * 3;
|
||||
|
||||
SetMonData(mon, MON_DATA_PP_BONUSES, &dataUnsigned);
|
||||
dataUnsigned = CalculatePPWithBonus(GetMonData(mon, MON_DATA_MOVE1 + moveIndex, NULL), dataUnsigned, moveIndex) - r5;
|
||||
dataUnsigned = CalculatePPWithBonus(GetMonData(mon, MON_DATA_MOVE1 + moveIndex, NULL), dataUnsigned, moveIndex) - temp2;
|
||||
dataUnsigned = GetMonData(mon, MON_DATA_PP1 + moveIndex, NULL) + dataUnsigned;
|
||||
SetMonData(mon, MON_DATA_PP1 + moveIndex, &dataUnsigned);
|
||||
retVal = FALSE;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if (GetMonData(mon, MON_DATA_FRIENDSHIP, NULL) < 100 && (retVal == 0 || var_28 != 0) && !ShouldSkipFriendshipChange() && var_34 == 0)
|
||||
|
||||
case 5: // ITEM5_FRIENDSHIP_LOW
|
||||
// Changes to friendship are given differently depending on
|
||||
// how much friendship the Pokémon already has.
|
||||
// In general, Pokémon with lower friendship receive more,
|
||||
// and Pokémon with higher friendship receive less.
|
||||
if (GetMonData(mon, MON_DATA_FRIENDSHIP, NULL) < 100)
|
||||
{
|
||||
var_34 = itemEffect[var_3C];
|
||||
friendship = GetMonData(mon, MON_DATA_FRIENDSHIP, NULL);
|
||||
if (var_34 > 0 && holdEffect == HOLD_EFFECT_HAPPINESS_UP)
|
||||
friendship += 150 * var_34 / 100;
|
||||
else
|
||||
friendship += var_34;
|
||||
if (var_34 > 0)
|
||||
{
|
||||
if (GetMonData(mon, MON_DATA_POKEBALL, NULL) == ITEM_LUXURY_BALL)
|
||||
friendship++;
|
||||
if (GetMonData(mon, MON_DATA_MET_LOCATION, NULL) == GetCurrentRegionMapSectionId())
|
||||
friendship++;
|
||||
UPDATE_FRIENDSHIP_FROM_ITEM;
|
||||
}
|
||||
if (friendship < 0)
|
||||
friendship = 0;
|
||||
if (friendship > MAX_FRIENDSHIP)
|
||||
friendship = MAX_FRIENDSHIP;
|
||||
SetMonData(mon, MON_DATA_FRIENDSHIP, &friendship);
|
||||
retVal = FALSE;
|
||||
}
|
||||
var_3C++;
|
||||
itemEffectParam++;
|
||||
break;
|
||||
case 6:
|
||||
if (GetMonData(mon, MON_DATA_FRIENDSHIP, NULL) >= 100 && GetMonData(mon, MON_DATA_FRIENDSHIP, NULL) < 200
|
||||
&& (retVal == 0 || var_28 != 0) && !ShouldSkipFriendshipChange() && var_34 == 0)
|
||||
|
||||
case 6: // ITEM5_FRIENDSHIP_MID
|
||||
if (GetMonData(mon, MON_DATA_FRIENDSHIP, NULL) >= 100 && GetMonData(mon, MON_DATA_FRIENDSHIP, NULL) < 200)
|
||||
{
|
||||
var_34 = itemEffect[var_3C];
|
||||
friendship = GetMonData(mon, MON_DATA_FRIENDSHIP, NULL);
|
||||
if ((s8)(var_34) > 0 && holdEffect == HOLD_EFFECT_HAPPINESS_UP)
|
||||
friendship += 150 * var_34 / 100;
|
||||
else
|
||||
friendship += var_34;
|
||||
if (var_34 > 0)
|
||||
{
|
||||
if (GetMonData(mon, MON_DATA_POKEBALL, NULL) == ITEM_LUXURY_BALL)
|
||||
friendship++;
|
||||
if (GetMonData(mon, MON_DATA_MET_LOCATION, NULL) == GetCurrentRegionMapSectionId())
|
||||
friendship++;
|
||||
UPDATE_FRIENDSHIP_FROM_ITEM;
|
||||
}
|
||||
if (friendship < 0)
|
||||
friendship = 0;
|
||||
if (friendship > MAX_FRIENDSHIP)
|
||||
friendship = MAX_FRIENDSHIP;
|
||||
SetMonData(mon, MON_DATA_FRIENDSHIP, &friendship);
|
||||
retVal = FALSE;
|
||||
}
|
||||
var_3C++;
|
||||
itemEffectParam++;
|
||||
break;
|
||||
case 7:
|
||||
if (GetMonData(mon, MON_DATA_FRIENDSHIP, NULL) >= 200 && (retVal == 0 || var_28 != 0) && !ShouldSkipFriendshipChange() && var_34 == 0)
|
||||
|
||||
case 7: // ITEM5_FRIENDSHIP_HIGH
|
||||
if (GetMonData(mon, MON_DATA_FRIENDSHIP, NULL) >= 200)
|
||||
{
|
||||
var_34 = itemEffect[var_3C];
|
||||
friendship = GetMonData(mon, MON_DATA_FRIENDSHIP, NULL);
|
||||
if ((s8)(var_34) > 0 && holdEffect == HOLD_EFFECT_HAPPINESS_UP)
|
||||
friendship += 150 * var_34 / 100;
|
||||
else
|
||||
friendship += var_34;
|
||||
if (var_34 > 0)
|
||||
{
|
||||
if (GetMonData(mon, MON_DATA_POKEBALL, NULL) == ITEM_LUXURY_BALL)
|
||||
friendship++;
|
||||
if (GetMonData(mon, MON_DATA_MET_LOCATION, NULL) == GetCurrentRegionMapSectionId())
|
||||
friendship++;
|
||||
UPDATE_FRIENDSHIP_FROM_ITEM;
|
||||
}
|
||||
if (friendship < 0)
|
||||
friendship = 0;
|
||||
if (friendship > MAX_FRIENDSHIP)
|
||||
friendship = MAX_FRIENDSHIP;
|
||||
SetMonData(mon, MON_DATA_FRIENDSHIP, &friendship);
|
||||
retVal = FALSE;
|
||||
}
|
||||
var_3C++;
|
||||
itemEffectParam++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var_38++;
|
||||
r10 >>= 1;
|
||||
temp1++;
|
||||
effectFlags >>= 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -5216,9 +5254,9 @@ u8 GetItemEffectParamOffset(u16 itemId, u8 effectByte, u8 effectBit)
|
||||
u8 offset;
|
||||
int i;
|
||||
u8 j;
|
||||
u8 val;
|
||||
u8 effectFlags;
|
||||
|
||||
offset = 6;
|
||||
offset = ITEM_EFFECT_ARG_START;
|
||||
|
||||
temp = gItemEffectTable[itemId - ITEM_POTION];
|
||||
|
||||
@ -5232,7 +5270,7 @@ u8 GetItemEffectParamOffset(u16 itemId, u8 effectByte, u8 effectBit)
|
||||
|
||||
itemEffect = temp;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
for (i = 0; i < ITEM_EFFECT_ARG_START; i++)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
@ -5244,74 +5282,75 @@ u8 GetItemEffectParamOffset(u16 itemId, u8 effectByte, u8 effectBit)
|
||||
return 0;
|
||||
break;
|
||||
case 4:
|
||||
val = itemEffect[4];
|
||||
if (val & ITEM4_PP_UP)
|
||||
val &= ~(ITEM4_PP_UP);
|
||||
effectFlags = itemEffect[4];
|
||||
if (effectFlags & ITEM4_PP_UP)
|
||||
effectFlags &= ~(ITEM4_PP_UP);
|
||||
j = 0;
|
||||
while (val)
|
||||
while (effectFlags)
|
||||
{
|
||||
if (val & 1)
|
||||
if (effectFlags & 1)
|
||||
{
|
||||
switch (j)
|
||||
{
|
||||
case 2:
|
||||
if (val & 0x10)
|
||||
val &= 0xEF;
|
||||
case 0:
|
||||
if (i == effectByte && (val & effectBit))
|
||||
case 2: // ITEM4_HEAL_HP
|
||||
if (effectFlags & (ITEM4_REVIVE >> 2))
|
||||
effectFlags &= ~(ITEM4_REVIVE >> 2);
|
||||
// fallthrough
|
||||
case 0: // ITEM4_EV_HP
|
||||
if (i == effectByte && (effectFlags & effectBit))
|
||||
return offset;
|
||||
offset++;
|
||||
break;
|
||||
case 1:
|
||||
if (i == effectByte && (val & effectBit))
|
||||
case 1: // ITEM4_EV_ATK
|
||||
if (i == effectByte && (effectFlags & effectBit))
|
||||
return offset;
|
||||
offset++;
|
||||
break;
|
||||
case 3:
|
||||
if (i == effectByte && (val & effectBit))
|
||||
case 3: // ITEM4_HEAL_PP
|
||||
if (i == effectByte && (effectFlags & effectBit))
|
||||
return offset;
|
||||
offset++;
|
||||
break;
|
||||
case 7:
|
||||
case 7: // ITEM4_EVO_STONE
|
||||
if (i == effectByte)
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
j++;
|
||||
val >>= 1;
|
||||
effectFlags >>= 1;
|
||||
if (i == effectByte)
|
||||
effectBit >>= 1;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
val = itemEffect[5];
|
||||
effectFlags = itemEffect[5];
|
||||
j = 0;
|
||||
while (val)
|
||||
while (effectFlags)
|
||||
{
|
||||
if (val & 1)
|
||||
if (effectFlags & 1)
|
||||
{
|
||||
switch (j)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
if (i == effectByte && (val & effectBit))
|
||||
case 0: // ITEM5_EV_DEF
|
||||
case 1: // ITEM5_EV_SPEED
|
||||
case 2: // ITEM5_EV_SPDEF
|
||||
case 3: // ITEM5_EV_SPATK
|
||||
case 4: // ITEM5_PP_MAX
|
||||
case 5: // ITEM5_FRIENDSHIP_LOW
|
||||
case 6: // ITEM5_FRIENDSHIP_MID
|
||||
if (i == effectByte && (effectFlags & effectBit))
|
||||
return offset;
|
||||
offset++;
|
||||
break;
|
||||
case 7:
|
||||
case 7: // ITEM5_FRIENDSHIP_HIGH
|
||||
if (i == effectByte)
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
j++;
|
||||
val >>= 1;
|
||||
effectFlags >>= 1;
|
||||
if (i == effectByte)
|
||||
effectBit >>= 1;
|
||||
}
|
||||
@ -5387,7 +5426,7 @@ u8 GetNatureFromPersonality(u32 personality)
|
||||
return personality % NUM_NATURES;
|
||||
}
|
||||
|
||||
u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 type, u16 evolutionItem)
|
||||
u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 mode, u16 evolutionItem)
|
||||
{
|
||||
int i;
|
||||
u16 targetSpecies = 0;
|
||||
@ -5405,12 +5444,13 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 type, u16 evolutionItem)
|
||||
else
|
||||
holdEffect = ItemId_GetHoldEffect(heldItem);
|
||||
|
||||
if (holdEffect == HOLD_EFFECT_PREVENT_EVOLVE && type != 3)
|
||||
// Prevent evolution with Everstone, unless we're just viewing the party menu with an evolution item
|
||||
if (holdEffect == HOLD_EFFECT_PREVENT_EVOLVE && mode != EVO_MODE_ITEM_CHECK)
|
||||
return SPECIES_NONE;
|
||||
|
||||
switch (type)
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
case EVO_MODE_NORMAL:
|
||||
level = GetMonData(mon, MON_DATA_LEVEL, 0);
|
||||
friendship = GetMonData(mon, MON_DATA_FRIENDSHIP, 0);
|
||||
|
||||
@ -5470,7 +5510,7 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 type, u16 evolutionItem)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
case EVO_MODE_TRADE:
|
||||
for (i = 0; i < EVOS_PER_MON; i++)
|
||||
{
|
||||
switch (gEvolutionTable[species][i].method)
|
||||
@ -5489,8 +5529,8 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 type, u16 evolutionItem)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
case EVO_MODE_ITEM_USE:
|
||||
case EVO_MODE_ITEM_CHECK:
|
||||
for (i = 0; i < EVOS_PER_MON; i++)
|
||||
{
|
||||
if (gEvolutionTable[species][i].method == EVO_ITEM
|
||||
|
@ -3735,7 +3735,7 @@ static bool8 AnimateTradeSequenceCable(void)
|
||||
case 72: // Only if in-game trade
|
||||
TradeMons(gSpecialVar_0x8005, 0);
|
||||
gCB2_AfterEvolution = CB2_UpdateInGameTrade;
|
||||
evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], TRUE, ITEM_NONE);
|
||||
evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], EVO_MODE_TRADE, ITEM_NONE);
|
||||
if (evoTarget != SPECIES_NONE)
|
||||
{
|
||||
TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->pokePicSpriteIdxs[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]);
|
||||
@ -4250,7 +4250,7 @@ static bool8 AnimateTradeSequenceWireless(void)
|
||||
case 72: // Only if in-game trade
|
||||
TradeMons(gSpecialVar_0x8005, 0);
|
||||
gCB2_AfterEvolution = CB2_UpdateInGameTrade;
|
||||
evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], TRUE, ITEM_NONE);
|
||||
evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], EVO_MODE_TRADE, ITEM_NONE);
|
||||
if (evoTarget != SPECIES_NONE)
|
||||
{
|
||||
TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->pokePicSpriteIdxs[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]);
|
||||
@ -4293,7 +4293,7 @@ static void CB2_TryTradeEvolution(void)
|
||||
break;
|
||||
case 4:
|
||||
gCB2_AfterEvolution = CB2_SaveAndEndTrade;
|
||||
evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], TRUE, ITEM_NONE);
|
||||
evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], EVO_MODE_TRADE, ITEM_NONE);
|
||||
if (evoTarget != SPECIES_NONE)
|
||||
TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->pokePicSpriteIdxs[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]);
|
||||
else if (IsWirelessTrade())
|
||||
|
Loading…
Reference in New Issue
Block a user