summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/battle_main.c12
-rw-r--r--src/battle_script_commands.c2
-rw-r--r--src/pokemon_item_effect.c283
-rw-r--r--src/tv.c8
4 files changed, 155 insertions, 150 deletions
diff --git a/src/battle_main.c b/src/battle_main.c
index 69c8fd36f..7e200adfe 100644
--- a/src/battle_main.c
+++ b/src/battle_main.c
@@ -3490,11 +3490,11 @@ void BattleStartClearSetData(void)
gBattleResults.battleTurnCounter = 0;
gBattleResults.playerFaintCounter = 0;
gBattleResults.opponentFaintCounter = 0;
- gBattleResults.unk2 = 0;
- gBattleResults.unk3 = 0;
- gBattleResults.unk4 = 0;
+ gBattleResults.totalMonSwitchCounter = 0;
+ gBattleResults.playerHealInBattleCount = 0;
+ gBattleResults.reviveCount = 0;
gBattleResults.playerMonWasDamaged = 0;
- gBattleResults.unk5_1 = 0;
+ gBattleResults.usedMasterBall = 0;
gBattleResults.lastOpponentSpecies = 0;
gBattleResults.lastUsedMove = 0;
gBattleResults.opponentMove = 0;
@@ -5367,8 +5367,8 @@ void HandleAction_Switch(void)
gBattlescriptCurrInstr = BattleScript_ActionSwitch;
gCurrentActionFuncId = B_ACTION_EXEC_SCRIPT;
- if (gBattleResults.unk2 < 255)
- gBattleResults.unk2++;
+ if (gBattleResults.totalMonSwitchCounter < 255)
+ gBattleResults.totalMonSwitchCounter++;
}
void HandleAction_UseItem(void)
diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c
index f1c1726a1..f6a730fb0 100644
--- a/src/battle_script_commands.c
+++ b/src/battle_script_commands.c
@@ -13428,7 +13428,7 @@ void atkEF_handleballthrow(void)
{
if (gLastUsedItem == ITEM_MASTER_BALL)
{
- gBattleResults.unk5_1 = 1;
+ gBattleResults.usedMasterBall = 1;
}
else
{
diff --git a/src/pokemon_item_effect.c b/src/pokemon_item_effect.c
index b84f69878..2a2e73dc0 100644
--- a/src/pokemon_item_effect.c
+++ b/src/pokemon_item_effect.c
@@ -14,6 +14,7 @@
#include "rom_8077ABC.h"
#include "rom_8094928.h"
#include "util.h"
+#include "constants/item_effects.h"
extern s32 gBattleMoveDamage;
extern u8 gAbsentBattlerFlags;
@@ -53,14 +54,14 @@ bool8 PokemonUseItemEffects(struct Pokemon *pkmn, u16 item, u8 partyIndex, u8 mo
s32 cmdIndex;
bool8 retVal = TRUE;
const u8 *itemEffect;
- u8 sp24 = 6;
- u32 sp28;
- s8 sp2C = 0;
+ u8 paramIdx = ITEM_EFFECT_ARG_START;
+ u32 data2;
+ s8 friendshipMod = 0;
u8 holdEffect;
- u8 sp34 = 4;
+ u8 battleId = 4; // Not active
u16 heldItem;
- u8 r10;
- u32 r4;
+ u8 effect4;
+ u32 evChange;
heldItem = GetMonData(pkmn, MON_DATA_HELD_ITEM, NULL);
if (heldItem == ITEM_ENIGMA_BERRY)
@@ -84,7 +85,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *pkmn, u16 item, u8 partyIndex, u8 mo
{
if (gBattlerPartyIndexes[cmdIndex] == partyIndex)
{
- sp34 = cmdIndex;
+ battleId = cmdIndex;
break;
}
cmdIndex += 2;
@@ -93,7 +94,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *pkmn, u16 item, u8 partyIndex, u8 mo
else
{
gActiveBattler = 0;
- sp34 = 4;
+ battleId = 4;
}
if (!ITEM_HAS_EFFECT(item))
@@ -119,22 +120,22 @@ bool8 PokemonUseItemEffects(struct Pokemon *pkmn, u16 item, u8 partyIndex, u8 mo
{
// status healing effects
case 0:
- if ((itemEffect[cmdIndex] & 0x80)
- && gMain.inBattle && sp34 != 4 && (gBattleMons[sp34].status2 & STATUS2_INFATUATION))
+ if ((itemEffect[cmdIndex] & ITEM0_INFATUATION)
+ && gMain.inBattle && battleId != 4 && (gBattleMons[battleId].status2 & STATUS2_INFATUATION))
{
- gBattleMons[sp34].status2 &= ~STATUS2_INFATUATION;
+ gBattleMons[battleId].status2 &= ~STATUS2_INFATUATION;
retVal = FALSE;
}
- if ((itemEffect[cmdIndex] & 0x30)
+ if ((itemEffect[cmdIndex] & ITEM0_DIRE_HIT)
&& !(gBattleMons[gActiveBattler].status2 & STATUS2_FOCUS_ENERGY))
{
gBattleMons[gActiveBattler].status2 |= STATUS2_FOCUS_ENERGY;
retVal = FALSE;
}
- if ((itemEffect[cmdIndex] & 0xF)
+ if ((itemEffect[cmdIndex] & ITEM0_X_ATTACK)
&& gBattleMons[gActiveBattler].statStages[STAT_STAGE_ATK] < 12)
{
- gBattleMons[gActiveBattler].statStages[STAT_STAGE_ATK] += itemEffect[cmdIndex] & 0xF;
+ gBattleMons[gActiveBattler].statStages[STAT_STAGE_ATK] += itemEffect[cmdIndex] & ITEM0_X_ATTACK;
if (gBattleMons[gActiveBattler].statStages[STAT_STAGE_ATK] > 12)
gBattleMons[gActiveBattler].statStages[STAT_STAGE_ATK] = 12;
retVal = FALSE;
@@ -142,18 +143,18 @@ bool8 PokemonUseItemEffects(struct Pokemon *pkmn, u16 item, u8 partyIndex, u8 mo
break;
// in-battle stat boosting effects?
case 1:
- if ((itemEffect[cmdIndex] & 0xF0)
+ if ((itemEffect[cmdIndex] & ITEM1_X_DEFEND)
&& gBattleMons[gActiveBattler].statStages[STAT_STAGE_DEF] < 12)
{
- gBattleMons[gActiveBattler].statStages[STAT_STAGE_DEF] += (itemEffect[cmdIndex] & 0xF0) >> 4;
+ gBattleMons[gActiveBattler].statStages[STAT_STAGE_DEF] += (itemEffect[cmdIndex] & ITEM1_X_DEFEND) >> 4;
if (gBattleMons[gActiveBattler].statStages[STAT_STAGE_DEF] > 12)
gBattleMons[gActiveBattler].statStages[STAT_STAGE_DEF] = 12;
retVal = FALSE;
}
- if ((itemEffect[cmdIndex] & 0xF)
+ if ((itemEffect[cmdIndex] & ITEM1_X_SPEED)
&& gBattleMons[gActiveBattler].statStages[STAT_STAGE_SPEED] < 12)
{
- gBattleMons[gActiveBattler].statStages[STAT_STAGE_SPEED] += itemEffect[cmdIndex] & 0xF;
+ gBattleMons[gActiveBattler].statStages[STAT_STAGE_SPEED] += itemEffect[cmdIndex] & ITEM1_X_SPEED;
if (gBattleMons[gActiveBattler].statStages[STAT_STAGE_SPEED] > 12)
gBattleMons[gActiveBattler].statStages[STAT_STAGE_SPEED] = 12;
retVal = FALSE;
@@ -161,31 +162,31 @@ bool8 PokemonUseItemEffects(struct Pokemon *pkmn, u16 item, u8 partyIndex, u8 mo
break;
// more stat boosting effects?
case 2:
- if ((itemEffect[cmdIndex] & 0xF0)
+ if ((itemEffect[cmdIndex] & ITEM2_X_ACCURACY)
&& gBattleMons[gActiveBattler].statStages[STAT_STAGE_ACC] < 12)
{
- gBattleMons[gActiveBattler].statStages[STAT_STAGE_ACC] += (itemEffect[cmdIndex] & 0xF0) >> 4;
+ gBattleMons[gActiveBattler].statStages[STAT_STAGE_ACC] += (itemEffect[cmdIndex] & ITEM2_X_ACCURACY) >> 4;
if (gBattleMons[gActiveBattler].statStages[STAT_STAGE_ACC] > 12)
gBattleMons[gActiveBattler].statStages[STAT_STAGE_ACC] = 12;
retVal = FALSE;
}
- if ((itemEffect[cmdIndex] & 0xF)
+ if ((itemEffect[cmdIndex] & ITEM2_X_SPATK)
&& gBattleMons[gActiveBattler].statStages[STAT_STAGE_SPATK] < 12)
{
- gBattleMons[gActiveBattler].statStages[STAT_STAGE_SPATK] += itemEffect[cmdIndex] & 0xF;
+ gBattleMons[gActiveBattler].statStages[STAT_STAGE_SPATK] += itemEffect[cmdIndex] & ITEM2_X_SPATK;
if (gBattleMons[gActiveBattler].statStages[STAT_STAGE_SPATK] > 12)
gBattleMons[gActiveBattler].statStages[STAT_STAGE_SPATK] = 12;
retVal = FALSE;
}
break;
case 3:
- if ((itemEffect[cmdIndex] & 0x80)
+ if ((itemEffect[cmdIndex] & ITEM3_GUARD_SPEC)
&& gSideTimers[GetBattlerSide(gActiveBattler)].mistTimer == 0)
{
gSideTimers[GetBattlerSide(gActiveBattler)].mistTimer = 5;
retVal = FALSE;
}
- if ((itemEffect[cmdIndex] & 0x40) // raise level
+ if ((itemEffect[cmdIndex] & ITEM3_LEVEL_UP) // raise level
&& GetMonData(pkmn, MON_DATA_LEVEL, NULL) != 100)
{
data = gExperienceTables[gBaseStats[GetMonData(pkmn, MON_DATA_SPECIES, NULL)].growthRate][GetMonData(pkmn, MON_DATA_LEVEL, NULL) + 1];
@@ -193,101 +194,101 @@ bool8 PokemonUseItemEffects(struct Pokemon *pkmn, u16 item, u8 partyIndex, u8 mo
CalculateMonStats(pkmn);
retVal = FALSE;
}
- if ((itemEffect[cmdIndex] & 0x20)
- && HealStatusConditions(pkmn, partyIndex, 7, sp34) == 0)
+ if ((itemEffect[cmdIndex] & ITEM3_SLEEP)
+ && HealStatusConditions(pkmn, partyIndex, 7, battleId) == 0)
{
- if (sp34 != 4)
- gBattleMons[sp34].status2 &= ~STATUS2_NIGHTMARE;
+ if (battleId != 4)
+ gBattleMons[battleId].status2 &= ~STATUS2_NIGHTMARE;
retVal = FALSE;
}
- if ((itemEffect[cmdIndex] & 0x10) && HealStatusConditions(pkmn, partyIndex, 0xF88, sp34) == 0)
+ if ((itemEffect[cmdIndex] & ITEM3_POISON) && HealStatusConditions(pkmn, partyIndex, (STATUS1_PSN_ANY | STATUS1_TOXIC_COUNTER), battleId) == 0)
retVal = FALSE;
- if ((itemEffect[cmdIndex] & 8) && HealStatusConditions(pkmn, partyIndex, 16, sp34) == 0)
+ if ((itemEffect[cmdIndex] & ITEM3_BURN) && HealStatusConditions(pkmn, partyIndex, STATUS1_BURN, battleId) == 0)
retVal = FALSE;
- if ((itemEffect[cmdIndex] & 4) && HealStatusConditions(pkmn, partyIndex, 32, sp34) == 0)
+ if ((itemEffect[cmdIndex] & ITEM3_FREEZE) && HealStatusConditions(pkmn, partyIndex, STATUS1_FREEZE, battleId) == 0)
retVal = FALSE;
- if ((itemEffect[cmdIndex] & 2) && HealStatusConditions(pkmn, partyIndex, 64, sp34) == 0)
+ if ((itemEffect[cmdIndex] & ITEM3_PARALYSIS) && HealStatusConditions(pkmn, partyIndex, STATUS1_PARALYSIS, battleId) == 0)
retVal = FALSE;
- if ((itemEffect[cmdIndex] & 1) // heal confusion
- && gMain.inBattle && sp34 != 4 && (gBattleMons[sp34].status2 & STATUS2_CONFUSION))
+ if ((itemEffect[cmdIndex] & ITEM3_CONFUSION) // heal confusion
+ && gMain.inBattle && battleId != 4 && (gBattleMons[battleId].status2 & STATUS2_CONFUSION))
{
- gBattleMons[sp34].status2 &= ~STATUS2_CONFUSION;
+ gBattleMons[battleId].status2 &= ~STATUS2_CONFUSION;
retVal = FALSE;
}
break;
// EV, HP, and PP raising effects
case 4:
- r10 = itemEffect[cmdIndex];
- if (r10 & 0x20)
+ effect4 = itemEffect[cmdIndex];
+ if (effect4 & ITEM4_PP_UP)
{
- r10 &= ~0x20;
+ effect4 &= ~ITEM4_PP_UP;
data = (GetMonData(pkmn, MON_DATA_PP_BONUSES, NULL) & gPPUpReadMasks[moveIndex]) >> (moveIndex * 2);
- sp28 = CalculatePPWithBonus(GetMonData(pkmn, MON_DATA_MOVE1 + moveIndex, NULL), GetMonData(pkmn, MON_DATA_PP_BONUSES, NULL), moveIndex);
- if (data < 3 && sp28 > 4)
+ data2 = CalculatePPWithBonus(GetMonData(pkmn, MON_DATA_MOVE1 + moveIndex, NULL), GetMonData(pkmn, MON_DATA_PP_BONUSES, NULL), moveIndex);
+ if (data < 3 && data2 > 4)
{
data = GetMonData(pkmn, MON_DATA_PP_BONUSES, NULL) + gPPUpValues[moveIndex];
SetMonData(pkmn, MON_DATA_PP_BONUSES, &data);
- data = CalculatePPWithBonus(GetMonData(pkmn, MON_DATA_MOVE1 + moveIndex, NULL), data, moveIndex) - sp28;
+ data = CalculatePPWithBonus(GetMonData(pkmn, MON_DATA_MOVE1 + moveIndex, NULL), data, moveIndex) - data2;
data = GetMonData(pkmn, MON_DATA_PP1 + moveIndex, NULL) + data;
SetMonData(pkmn, MON_DATA_PP1 + moveIndex, &data);
retVal = FALSE;
}
}
- sp28 = 0;
- while (r10 != 0)
+ data2 = 0;
+ while (effect4 != 0)
{
- if (r10 & 1)
+ if (effect4 & 1)
{
u16 evCount;
s32 r5;
- switch (sp28)
+ switch (data2)
{
- case 0:
- case 1:
+ case 0: // EV_HP
+ case 1: // EV_ATK
evCount = GetMonEVCount(pkmn);
if (evCount >= 510)
return TRUE;
- data = GetMonData(pkmn, sGetMonDataEVConstants[sp28], NULL);
+ data = GetMonData(pkmn, sGetMonDataEVConstants[data2], NULL);
if (data < 100)
{
- if (data + itemEffect[sp24] > 100)
- r4 = 100 - (data + itemEffect[sp24]) + itemEffect[sp24];
+ if (data + itemEffect[paramIdx] > 100)
+ evChange = 100 - (data + itemEffect[paramIdx]) + itemEffect[paramIdx];
else
- r4 = itemEffect[sp24];
- if (evCount + r4 > 510)
- r4 += 510 - (evCount + r4);
- data += r4;
- SetMonData(pkmn, sGetMonDataEVConstants[sp28], &data);
+ evChange = itemEffect[paramIdx];
+ if (evCount + evChange > 510)
+ evChange += 510 - (evCount + evChange);
+ data += evChange;
+ SetMonData(pkmn, sGetMonDataEVConstants[data2], &data);
CalculateMonStats(pkmn);
- sp24++;
+ paramIdx++;
retVal = FALSE;
}
break;
- case 2:
+ case 2: // HEAL_HP
// revive?
- if (r10 & 0x10)
+ if (effect4 & (ITEM4_REVIVE >> 2))
{
if (GetMonData(pkmn, MON_DATA_HP, NULL) != 0)
{
- sp24++;
+ paramIdx++;
break;
}
if (gMain.inBattle)
{
- if (sp34 != 4)
+ if (battleId != 4)
{
- gAbsentBattlerFlags &= ~gBitTable[sp34];
- CopyPlayerPartyMonToBattleData(sp34, pokemon_order_func(gBattlerPartyIndexes[sp34]));
- if (GetBattlerSide(gActiveBattler) == 0 && gBattleResults.unk4 < 255)
- gBattleResults.unk4++;
+ gAbsentBattlerFlags &= ~gBitTable[battleId];
+ CopyPlayerPartyMonToBattleData(battleId, pokemon_order_func(gBattlerPartyIndexes[battleId]));
+ if (GetBattlerSide(gActiveBattler) == 0 && gBattleResults.reviveCount < 255)
+ gBattleResults.reviveCount++;
}
else
{
gAbsentBattlerFlags &= ~gBitTable[gActiveBattler ^ 2];
- if (GetBattlerSide(gActiveBattler) == 0 && gBattleResults.unk4 < 255)
- gBattleResults.unk4++;
+ if (GetBattlerSide(gActiveBattler) == 0 && gBattleResults.reviveCount < 255)
+ gBattleResults.reviveCount++;
}
}
}
@@ -295,22 +296,22 @@ bool8 PokemonUseItemEffects(struct Pokemon *pkmn, u16 item, u8 partyIndex, u8 mo
{
if (GetMonData(pkmn, MON_DATA_HP, NULL) == 0)
{
- sp24++;
+ paramIdx++;
break;
}
}
- data = itemEffect[sp24++];
+ data = itemEffect[paramIdx++];
switch (data)
{
- case 0xFF:
+ case ITEM6_HEAL_HP_FULL:
data = GetMonData(pkmn, MON_DATA_MAX_HP, NULL) - GetMonData(pkmn, MON_DATA_HP, NULL);
break;
- case 0xFE:
+ case ITEM6_HEAL_HP_HALF:
data = GetMonData(pkmn, MON_DATA_MAX_HP, NULL) / 2;
if (data == 0)
data = 1;
break;
- case 0xFD:
+ case ITEM6_HEAL_HP_LVL_UP:
data = gBattleStruct->levelUpHP;
break;
}
@@ -322,16 +323,16 @@ bool8 PokemonUseItemEffects(struct Pokemon *pkmn, u16 item, u8 partyIndex, u8 mo
if (data > GetMonData(pkmn, MON_DATA_MAX_HP, NULL))
data = GetMonData(pkmn, MON_DATA_MAX_HP, NULL);
SetMonData(pkmn, MON_DATA_HP, &data);
- if (gMain.inBattle && sp34 != 4)
+ if (gMain.inBattle && battleId != 4)
{
- gBattleMons[sp34].hp = data;
- if (!(r10 & 0x10) && GetBattlerSide(gActiveBattler) == 0)
+ gBattleMons[battleId].hp = data;
+ if (!(effect4 & (ITEM4_REVIVE >> 2)) && GetBattlerSide(gActiveBattler) == 0)
{
- if (gBattleResults.unk3 < 255)
- gBattleResults.unk3++;
+ if (gBattleResults.playerHealInBattleCount < 255)
+ gBattleResults.playerHealInBattleCount++;
// I have to re-use this variable to match.
r5 = gActiveBattler;
- gActiveBattler = sp34;
+ gActiveBattler = battleId;
BtlController_EmitGetMonData(0, 0, 0);
MarkBattlerForControllerExec(gActiveBattler);
gActiveBattler = r5;
@@ -344,10 +345,10 @@ bool8 PokemonUseItemEffects(struct Pokemon *pkmn, u16 item, u8 partyIndex, u8 mo
}
retVal = FALSE;
}
- r10 &= 0xEF;
+ effect4 &= ~(ITEM4_REVIVE >> 2);
break;
- case 3:
- if (!(r10 & 2))
+ case 3: // HEAL_PP
+ if (!(effect4 & (ITEM4_HEAL_PP_ONE >> 3)))
{
for (r5 = 0; r5 < 4; r5++)
{
@@ -357,7 +358,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *pkmn, u16 item, u8 partyIndex, u8 mo
r4 = GetMonData(pkmn, MON_DATA_MOVE1 + r5, NULL);
if (data != CalculatePPWithBonus(r4, GetMonData(pkmn, MON_DATA_PP_BONUSES, NULL), r5))
{
- data += itemEffect[sp24];
+ data += itemEffect[paramIdx];
r4 = GetMonData(pkmn, MON_DATA_MOVE1 + r5, NULL);
if (data > CalculatePPWithBonus(r4, GetMonData(pkmn, MON_DATA_PP_BONUSES, NULL), r5))
{
@@ -366,13 +367,13 @@ bool8 PokemonUseItemEffects(struct Pokemon *pkmn, u16 item, u8 partyIndex, u8 mo
}
SetMonData(pkmn, MON_DATA_PP1 + r5, &data);
if (gMain.inBattle
- && sp34 != 4 && !(gBattleMons[sp34].status2 & 0x200000)
- && !(gDisableStructs[sp34].mimickedMoves & gBitTable[r5]))
- gBattleMons[sp34].pp[r5] = data;
+ && battleId != 4 && !(gBattleMons[battleId].status2 & STATUS2_TRANSFORMED)
+ && !(gDisableStructs[battleId].mimickedMoves & gBitTable[r5]))
+ gBattleMons[battleId].pp[r5] = data;
retVal = FALSE;
}
}
- sp24++;
+ paramIdx++;
}
else
{
@@ -382,7 +383,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *pkmn, u16 item, u8 partyIndex, u8 mo
r4 = GetMonData(pkmn, MON_DATA_MOVE1 + moveIndex, NULL);
if (data != CalculatePPWithBonus(r4, GetMonData(pkmn, MON_DATA_PP_BONUSES, NULL), moveIndex))
{
- data += itemEffect[sp24++];
+ data += itemEffect[paramIdx++];
r4 = GetMonData(pkmn, MON_DATA_MOVE1 + moveIndex, NULL);
if (data > CalculatePPWithBonus(r4, GetMonData(pkmn, MON_DATA_PP_BONUSES, NULL), moveIndex))
{
@@ -391,14 +392,14 @@ bool8 PokemonUseItemEffects(struct Pokemon *pkmn, u16 item, u8 partyIndex, u8 mo
}
SetMonData(pkmn, MON_DATA_PP1 + moveIndex, &data);
if (gMain.inBattle
- && sp34 != 4 && !(gBattleMons[sp34].status2 & 0x200000)
- && !(gDisableStructs[sp34].mimickedMoves & gBitTable[moveIndex]))
- gBattleMons[sp34].pp[moveIndex] = data;
+ && battleId != 4 && !(gBattleMons[battleId].status2 & STATUS2_TRANSFORMED)
+ && !(gDisableStructs[battleId].mimickedMoves & gBitTable[moveIndex]))
+ gBattleMons[battleId].pp[moveIndex] = data;
retVal = FALSE;
}
}
break;
- case 7:
+ case 7: // EVO_STONE
{
u16 targetSpecies = GetEvolutionTargetSpecies(pkmn, 2, item);
@@ -411,70 +412,72 @@ bool8 PokemonUseItemEffects(struct Pokemon *pkmn, u16 item, u8 partyIndex, u8 mo
break;
}
}
- sp28++;
- r10 >>= 1;
+ data2++;
+ effect4 >>= 1;
}
break;
case 5:
- r10 = itemEffect[cmdIndex];
- sp28 = 0;
- while (r10 != 0)
+ effect4 = itemEffect[cmdIndex];
+ data2 = 0;
+ while (effect4 != 0)
{
- if (r10 & 1)
+ if (effect4 & 1)
{
u16 evCount;
- switch (sp28)
+ switch (data2)
{
- case 0:
- case 1:
- case 2:
- case 3:
+ case 0: // EV_DEF
+ case 1: // EV_SPEED
+ case 2: // EV_SPDEF
+ case 3: // EV_SPATK
evCount = GetMonEVCount(pkmn);
if (evCount >= 510)
return TRUE;
- data = GetMonData(pkmn, sGetMonDataEVConstants[sp28 + 2], NULL);
+ data = GetMonData(pkmn, sGetMonDataEVConstants[data2 + 2], NULL);
if (data < 100)
{
- if (data + itemEffect[sp24] > 100)
- r4 = 100 - (data + itemEffect[sp24]) + itemEffect[sp24];
+ if (data + itemEffect[paramIdx] > 100)
+ evChange = 100 - (data + itemEffect[paramIdx]) + itemEffect[paramIdx];
else
- r4 = itemEffect[sp24];
- if (evCount + r4 > 510)
- r4 += 510 - (evCount + r4);
- data += r4;
- SetMonData(pkmn, sGetMonDataEVConstants[sp28 + 2], &data);
+ evChange = itemEffect[paramIdx];
+ if (evCount + evChange > 510)
+ evChange += 510 - (evCount + evChange);
+ data += evChange;
+ SetMonData(pkmn, sGetMonDataEVConstants[data2 + 2], &data);
CalculateMonStats(pkmn);
retVal = FALSE;
- sp24++;
+ paramIdx++;
}
break;
- case 4:
+ case 4: // PP_MAX
data = (GetMonData(pkmn, MON_DATA_PP_BONUSES, NULL) & gPPUpReadMasks[moveIndex]) >> (moveIndex * 2);
if (data < 3)
{
- r4 = CalculatePPWithBonus(GetMonData(pkmn, MON_DATA_MOVE1 + moveIndex, NULL), GetMonData(pkmn, MON_DATA_PP_BONUSES, NULL), moveIndex);
+ evChange = CalculatePPWithBonus(GetMonData(pkmn, MON_DATA_MOVE1 + moveIndex, NULL), GetMonData(pkmn, MON_DATA_PP_BONUSES, NULL), moveIndex);
data = GetMonData(pkmn, MON_DATA_PP_BONUSES, NULL);
data &= gPPUpWriteMasks[moveIndex];
data += gPPUpValues[moveIndex] * 3;
SetMonData(pkmn, MON_DATA_PP_BONUSES, &data);
- data = CalculatePPWithBonus(GetMonData(pkmn, MON_DATA_MOVE1 + moveIndex, NULL), data, moveIndex) - r4;
+ data = CalculatePPWithBonus(GetMonData(pkmn, MON_DATA_MOVE1 + moveIndex, NULL), data, moveIndex) -
+ evChange;
data = GetMonData(pkmn, MON_DATA_PP1 + moveIndex, NULL) + data;
SetMonData(pkmn, MON_DATA_PP1 + moveIndex, &data);
retVal = FALSE;
}
break;
- case 5:
- if (GetMonData(pkmn, MON_DATA_FRIENDSHIP, NULL) < 100 && retVal == 0 && sp2C == 0)
+ case 5: // FRIENDSHIP_LOW
+ if (GetMonData(pkmn, MON_DATA_FRIENDSHIP, NULL) < 100 && retVal == 0 &&
+ friendshipMod == 0)
{
- sp2C = itemEffect[sp24];
+ friendshipMod = itemEffect[paramIdx];
friendship = GetMonData(pkmn, MON_DATA_FRIENDSHIP, NULL);
- if (sp2C > 0 && holdEffect == HOLD_EFFECT_HAPPINESS_UP)
- friendship += 150 * sp2C / 100;
+ if (friendshipMod > 0 && holdEffect == HOLD_EFFECT_HAPPINESS_UP)
+ friendship += 150 * friendshipMod / 100;
else
- friendship += sp2C;
- if (sp2C > 0)
+ friendship += friendshipMod;
+ if (friendshipMod > 0)
{
if (GetMonData(pkmn, MON_DATA_POKEBALL, NULL) == 11)
friendship++;
@@ -487,19 +490,20 @@ bool8 PokemonUseItemEffects(struct Pokemon *pkmn, u16 item, u8 partyIndex, u8 mo
friendship = 255;
SetMonData(pkmn, MON_DATA_FRIENDSHIP, &friendship);
}
- sp24++;
+ paramIdx++;
break;
- case 6:
+ case 6: // FRIENDSHIP_MID
if (GetMonData(pkmn, MON_DATA_FRIENDSHIP, NULL) >= 100 && GetMonData(pkmn, MON_DATA_FRIENDSHIP, NULL) < 200
- && retVal == 0 && sp2C == 0)
+ && retVal == 0 &&
+ friendshipMod == 0)
{
- sp2C = itemEffect[sp24];
+ friendshipMod = itemEffect[paramIdx];
friendship = GetMonData(pkmn, MON_DATA_FRIENDSHIP, NULL);
- if (sp2C > 0 && holdEffect == HOLD_EFFECT_HAPPINESS_UP)
- friendship += 150 * sp2C / 100;
+ if (friendshipMod > 0 && holdEffect == HOLD_EFFECT_HAPPINESS_UP)
+ friendship += 150 * friendshipMod / 100;
else
- friendship += sp2C;
- if (sp2C > 0)
+ friendship += friendshipMod;
+ if (friendshipMod > 0)
{
if (GetMonData(pkmn, MON_DATA_POKEBALL, NULL) == 11)
friendship++;
@@ -512,18 +516,19 @@ bool8 PokemonUseItemEffects(struct Pokemon *pkmn, u16 item, u8 partyIndex, u8 mo
friendship = 255;
SetMonData(pkmn, MON_DATA_FRIENDSHIP, &friendship);
}
- sp24++;
+ paramIdx++;
break;
- case 7:
- if (GetMonData(pkmn, MON_DATA_FRIENDSHIP, NULL) >= 200 && retVal == 0 && sp2C == 0)
+ case 7: // FRIENDSHIP_HIGH
+ if (GetMonData(pkmn, MON_DATA_FRIENDSHIP, NULL) >= 200 && retVal == 0 &&
+ friendshipMod == 0)
{
- sp2C = itemEffect[sp24];
+ friendshipMod = itemEffect[paramIdx];
friendship = GetMonData(pkmn, MON_DATA_FRIENDSHIP, NULL);
- if (sp2C > 0 && holdEffect == HOLD_EFFECT_HAPPINESS_UP)
- friendship += 150 * sp2C / 100;
+ if (friendshipMod > 0 && holdEffect == HOLD_EFFECT_HAPPINESS_UP)
+ friendship += 150 * friendshipMod / 100;
else
- friendship += sp2C;
- if (sp2C > 0)
+ friendship += friendshipMod;
+ if (friendshipMod > 0)
{
if (GetMonData(pkmn, MON_DATA_POKEBALL, NULL) == 11)
friendship++;
@@ -536,12 +541,12 @@ bool8 PokemonUseItemEffects(struct Pokemon *pkmn, u16 item, u8 partyIndex, u8 mo
friendship = 255;
SetMonData(pkmn, MON_DATA_FRIENDSHIP, &friendship);
}
- sp24++;
+ paramIdx++;
break;
}
}
- sp28++;
- r10 >>= 1;
+ data2++;
+ effect4 >>= 1;
}
break;
}
diff --git a/src/tv.c b/src/tv.c
index 9381a592b..e12232fba 100644
--- a/src/tv.c
+++ b/src/tv.c
@@ -643,12 +643,12 @@ void GabbyAndTyBeforeInterview(void)
else
gSaveBlock1.gabbyAndTyData.valA_1 = 0;
- if (gBattleResults.unk3)
+ if (gBattleResults.playerHealInBattleCount)
gSaveBlock1.gabbyAndTyData.valA_2 = 1;
else
gSaveBlock1.gabbyAndTyData.valA_2 = 0;
- if (!gBattleResults.unk5_1)
+ if (!gBattleResults.usedMasterBall)
{
for (i=0; i<11; i++)
{
@@ -818,7 +818,7 @@ void PutPokemonTodayCaughtOnAir(void)
{
for (i = 0; i < 11; i++)
total += gBattleResults.usedBalls[i];
- if (total != 0 || gBattleResults.unk5_1 != 0)
+ if (total != 0 || gBattleResults.usedMasterBall != 0)
{
struct TVShowPokemonToday *pokemonToday;
@@ -826,7 +826,7 @@ void PutPokemonTodayCaughtOnAir(void)
pokemonToday = &gSaveBlock1.tvShows[gUnknown_03005D38.var0].pokemonToday;
pokemonToday->kind = TVSHOW_POKEMON_TODAY_CAUGHT;
pokemonToday->active = total;
- if (gBattleResults.unk5_1 != 0)
+ if (gBattleResults.usedMasterBall != 0)
{
total = 1;
item = ITEM_MASTER_BALL;