mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-27 04:04:17 +01:00
Use friendship event constants
This commit is contained in:
parent
c859fe3606
commit
27c4329e45
@ -203,15 +203,16 @@
|
||||
#define MON_FEMALE 0xFE
|
||||
#define MON_GENDERLESS 0xFF
|
||||
|
||||
// Constants for AdjustFriendship
|
||||
#define FRIENDSHIP_EVENT_GROW_LEVEL 0
|
||||
#define FRIENDSHIP_EVENT_VITAMIN 1 // unused
|
||||
#define FRIENDSHIP_EVENT_BATTLE_ITEM 2 // unused
|
||||
#define FRIENDSHIP_EVENT_VITAMIN 1 // unused, handled by PokemonUseItemEffects
|
||||
#define FRIENDSHIP_EVENT_BATTLE_ITEM 2 // unused, handled by PokemonUseItemEffects
|
||||
#define FRIENDSHIP_EVENT_LEAGUE_BATTLE 3
|
||||
#define FRIENDSHIP_EVENT_LEARN_TMHM 4
|
||||
#define FRIENDSHIP_EVENT_WALKING 5
|
||||
#define FRIENDSHIP_EVENT_FAINT_SMALL 6
|
||||
#define FRIENDSHIP_EVENT_FAINT_OUTSIDE_BATTLE 7
|
||||
#define FRIENDSHIP_EVENT_FAINT_LARGE 8
|
||||
#define FRIENDSHIP_EVENT_FAINT_FIELD_PSN 7
|
||||
#define FRIENDSHIP_EVENT_FAINT_LARGE 8 // If opponent was >= 30 levels higher. See AdjustFriendshipOnBattleFaint
|
||||
|
||||
#define MAX_FRIENDSHIP 0xFF
|
||||
|
||||
|
@ -413,7 +413,6 @@ void HandleSetPokedexFlag(u16 nationalNum, u8 caseId, u32 personality);
|
||||
const u8 *GetTrainerClassNameFromId(u16 trainerId);
|
||||
const u8 *GetTrainerNameFromId(u16 trainerId);
|
||||
bool8 HasTwoFramesAnimation(u16 species);
|
||||
bool8 sub_806F104(void);
|
||||
struct Unknown_806F160_Struct *sub_806F2AC(u8 id, u8 arg1);
|
||||
void sub_806F47C(u8 id);
|
||||
u8 *sub_806F4F8(u8 id, u8 arg1);
|
||||
|
@ -718,7 +718,7 @@ static void CB2_InitBattleInternal(void)
|
||||
gSaveBlock2Ptr->frontier.disableRecordBattle = FALSE;
|
||||
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
AdjustFriendship(&gPlayerParty[i], 3);
|
||||
AdjustFriendship(&gPlayerParty[i], FRIENDSHIP_EVENT_LEAGUE_BATTLE);
|
||||
|
||||
gBattleCommunication[MULTIUSE_STATE] = 0;
|
||||
}
|
||||
|
@ -3434,7 +3434,7 @@ static void Cmd_getexp(void)
|
||||
gLeveledUpInBattle |= gBitTable[gBattleStruct->expGetterMonId];
|
||||
gBattlescriptCurrInstr = BattleScript_LevelUp;
|
||||
gBattleMoveDamage = (gBattleBufferB[gActiveBattler][2] | (gBattleBufferB[gActiveBattler][3] << 8));
|
||||
AdjustFriendship(&gPlayerParty[gBattleStruct->expGetterMonId], 0);
|
||||
AdjustFriendship(&gPlayerParty[gBattleStruct->expGetterMonId], FRIENDSHIP_EVENT_GROW_LEVEL);
|
||||
|
||||
// update battle mon structure after level up
|
||||
if (gBattlerPartyIndexes[0] == gBattleStruct->expGetterMonId && gBattleMons[0].hp)
|
||||
|
@ -92,13 +92,13 @@ void AdjustFriendshipOnBattleFaint(u8 battlerId)
|
||||
if (gBattleMons[opposingBattlerId].level > gBattleMons[battlerId].level)
|
||||
{
|
||||
if (gBattleMons[opposingBattlerId].level - gBattleMons[battlerId].level > 29)
|
||||
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[battlerId]], 8);
|
||||
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[battlerId]], FRIENDSHIP_EVENT_FAINT_LARGE);
|
||||
else
|
||||
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[battlerId]], 6);
|
||||
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[battlerId]], FRIENDSHIP_EVENT_FAINT_SMALL);
|
||||
}
|
||||
else
|
||||
{
|
||||
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[battlerId]], 6);
|
||||
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[battlerId]], FRIENDSHIP_EVENT_FAINT_SMALL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ static void FaintFromFieldPoison(u8 partyIdx)
|
||||
struct Pokemon *pokemon = gPlayerParty + partyIdx;
|
||||
u32 status = STATUS1_NONE;
|
||||
|
||||
AdjustFriendship(pokemon, 0x07);
|
||||
AdjustFriendship(pokemon, FRIENDSHIP_EVENT_FAINT_FIELD_PSN);
|
||||
SetMonData(pokemon, MON_DATA_STATUS, &status);
|
||||
GetMonData(pokemon, MON_DATA_NICKNAME, gStringVar1);
|
||||
StringGetEnd10(gStringVar1);
|
||||
|
@ -4701,7 +4701,7 @@ static void Task_LearnedMove(u8 taskId)
|
||||
|
||||
if (move[1] == 0)
|
||||
{
|
||||
AdjustFriendship(mon, 4);
|
||||
AdjustFriendship(mon, FRIENDSHIP_EVENT_LEARN_TMHM);
|
||||
if (item < ITEM_HM01_CUT)
|
||||
RemoveBagItem(item, 1);
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ static void DecryptBoxMon(struct BoxPokemon *boxMon);
|
||||
static void sub_806E6CC(u8 taskId);
|
||||
static bool8 ShouldGetStatBadgeBoost(u16 flagId, u8 battlerId);
|
||||
static u16 GiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move);
|
||||
static bool8 ShouldSkipFriendshipChange(void);
|
||||
|
||||
// EWRAM vars
|
||||
EWRAM_DATA static u8 sLearningMoveTableID = 0;
|
||||
@ -1886,12 +1887,12 @@ const u8 gStatStageRatios[][2] =
|
||||
|
||||
static const u16 sDeoxysBaseStats[] =
|
||||
{
|
||||
50, // Hp
|
||||
95, // Attack
|
||||
90, // Defense
|
||||
180, // Speed
|
||||
95, // Sp.Attack
|
||||
90, // Sp.Defense
|
||||
[STAT_HP] = 50,
|
||||
[STAT_ATK] = 95,
|
||||
[STAT_DEF] = 90,
|
||||
[STAT_SPEED] = 180,
|
||||
[STAT_SPATK] = 95,
|
||||
[STAT_SPDEF] = 90,
|
||||
};
|
||||
|
||||
const u16 gLinkPlayerFacilityClasses[] =
|
||||
@ -2063,17 +2064,19 @@ static const u8 sStatsToRaise[] =
|
||||
STAT_ATK, STAT_ATK, STAT_SPEED, STAT_DEF, STAT_SPATK, STAT_ACC
|
||||
};
|
||||
|
||||
static const s8 gUnknown_08329ECE[][3] =
|
||||
// 3 modifiers each for how much to change friendship for different ranges
|
||||
// 0-99, 100-199, 200+
|
||||
static const s8 sFriendshipEventModifiers[][3] =
|
||||
{
|
||||
{ 5, 3, 2},
|
||||
{ 5, 3, 2},
|
||||
{ 1, 1, 0},
|
||||
{ 3, 2, 1},
|
||||
{ 1, 1, 0},
|
||||
{ 1, 1, 1},
|
||||
{-1, -1, -1},
|
||||
{-5, -5, -10},
|
||||
{-5, -5, -10},
|
||||
[FRIENDSHIP_EVENT_GROW_LEVEL] = { 5, 3, 2},
|
||||
[FRIENDSHIP_EVENT_VITAMIN] = { 5, 3, 2},
|
||||
[FRIENDSHIP_EVENT_BATTLE_ITEM] = { 1, 1, 0},
|
||||
[FRIENDSHIP_EVENT_LEAGUE_BATTLE] = { 3, 2, 1},
|
||||
[FRIENDSHIP_EVENT_LEARN_TMHM] = { 1, 1, 0},
|
||||
[FRIENDSHIP_EVENT_WALKING] = { 1, 1, 1},
|
||||
[FRIENDSHIP_EVENT_FAINT_SMALL] = {-1, -1, -1},
|
||||
[FRIENDSHIP_EVENT_FAINT_FIELD_PSN] = {-5, -5, -10},
|
||||
[FRIENDSHIP_EVENT_FAINT_LARGE] = {-5, -5, -10},
|
||||
};
|
||||
|
||||
static const u16 sHMMoves[] =
|
||||
@ -5083,7 +5086,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if (GetMonData(mon, MON_DATA_FRIENDSHIP, NULL) < 100 && (retVal == 0 || var_28 != 0) && !sub_806F104() && var_34 == 0)
|
||||
if (GetMonData(mon, MON_DATA_FRIENDSHIP, NULL) < 100 && (retVal == 0 || var_28 != 0) && !ShouldSkipFriendshipChange() && var_34 == 0)
|
||||
{
|
||||
var_34 = itemEffect[var_3C];
|
||||
friendship = GetMonData(mon, MON_DATA_FRIENDSHIP, NULL);
|
||||
@ -5109,7 +5112,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov
|
||||
break;
|
||||
case 6:
|
||||
if (GetMonData(mon, MON_DATA_FRIENDSHIP, NULL) >= 100 && GetMonData(mon, MON_DATA_FRIENDSHIP, NULL) < 200
|
||||
&& (retVal == 0 || var_28 != 0) && !sub_806F104() && var_34 == 0)
|
||||
&& (retVal == 0 || var_28 != 0) && !ShouldSkipFriendshipChange() && var_34 == 0)
|
||||
{
|
||||
var_34 = itemEffect[var_3C];
|
||||
friendship = GetMonData(mon, MON_DATA_FRIENDSHIP, NULL);
|
||||
@ -5134,7 +5137,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov
|
||||
var_3C++;
|
||||
break;
|
||||
case 7:
|
||||
if (GetMonData(mon, MON_DATA_FRIENDSHIP, NULL) >= 200 && (retVal == 0 || var_28 != 0) && !sub_806F104() && var_34 == 0)
|
||||
if (GetMonData(mon, MON_DATA_FRIENDSHIP, NULL) >= 200 && (retVal == 0 || var_28 != 0) && !ShouldSkipFriendshipChange() && var_34 == 0)
|
||||
{
|
||||
var_34 = itemEffect[var_3C];
|
||||
friendship = GetMonData(mon, MON_DATA_FRIENDSHIP, NULL);
|
||||
@ -5752,12 +5755,18 @@ u16 ModifyStatByNature(u8 nature, u16 n, u8 statIndex)
|
||||
return n;
|
||||
}
|
||||
|
||||
#define IS_LEAGUE_BATTLE \
|
||||
((gBattleTypeFlags & BATTLE_TYPE_TRAINER) \
|
||||
&& (gTrainers[gTrainerBattleOpponent_A].trainerClass == TRAINER_CLASS_ELITE_FOUR \
|
||||
|| gTrainers[gTrainerBattleOpponent_A].trainerClass == TRAINER_CLASS_LEADER \
|
||||
|| gTrainers[gTrainerBattleOpponent_A].trainerClass == TRAINER_CLASS_CHAMPION)) \
|
||||
|
||||
void AdjustFriendship(struct Pokemon *mon, u8 event)
|
||||
{
|
||||
u16 species, heldItem;
|
||||
u8 holdEffect;
|
||||
|
||||
if (sub_806F104())
|
||||
if (ShouldSkipFriendshipChange())
|
||||
return;
|
||||
|
||||
species = GetMonData(mon, MON_DATA_SPECIES2, 0);
|
||||
@ -5779,18 +5788,16 @@ void AdjustFriendship(struct Pokemon *mon, u8 event)
|
||||
{
|
||||
u8 friendshipLevel = 0;
|
||||
s16 friendship = GetMonData(mon, MON_DATA_FRIENDSHIP, 0);
|
||||
|
||||
if (friendship > 99)
|
||||
friendshipLevel++;
|
||||
if (friendship > 199)
|
||||
friendshipLevel++;
|
||||
if ((event != 5 || !(Random() & 1))
|
||||
&& (event != 3
|
||||
|| ((gBattleTypeFlags & BATTLE_TYPE_TRAINER)
|
||||
&& (gTrainers[gTrainerBattleOpponent_A].trainerClass == TRAINER_CLASS_ELITE_FOUR
|
||||
|| gTrainers[gTrainerBattleOpponent_A].trainerClass == TRAINER_CLASS_LEADER
|
||||
|| gTrainers[gTrainerBattleOpponent_A].trainerClass == TRAINER_CLASS_CHAMPION))))
|
||||
|
||||
if ((event != FRIENDSHIP_EVENT_WALKING || !(Random() & 1))
|
||||
&& (event != FRIENDSHIP_EVENT_LEAGUE_BATTLE || IS_LEAGUE_BATTLE))
|
||||
{
|
||||
s8 mod = gUnknown_08329ECE[event][friendshipLevel];
|
||||
s8 mod = sFriendshipEventModifiers[event][friendshipLevel];
|
||||
if (mod > 0 && holdEffect == HOLD_EFFECT_HAPPINESS_UP)
|
||||
mod = (150 * mod) / 100;
|
||||
friendship += mod;
|
||||
@ -6782,7 +6789,7 @@ bool8 HasTwoFramesAnimation(u16 species)
|
||||
&& species != SPECIES_UNOWN);
|
||||
}
|
||||
|
||||
bool8 sub_806F104(void)
|
||||
static bool8 ShouldSkipFriendshipChange(void)
|
||||
{
|
||||
if (gMain.inBattle && gBattleTypeFlags & (BATTLE_TYPE_FRONTIER))
|
||||
return TRUE;
|
||||
|
Loading…
Reference in New Issue
Block a user