mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 19:47:35 +01:00
Merge pull request #2262 from LOuroboros/becomingAHero
Fixed Mega Evolved Pokémon being able to get Friendship effects in battle
This commit is contained in:
commit
2ce340e8e1
@ -202,6 +202,6 @@ bool32 CanBeParalyzed(u8 battlerId);
|
||||
bool32 CanBeFrozen(u8 battlerId);
|
||||
bool32 CanBeConfused(u8 battlerId);
|
||||
bool32 IsBattlerTerrainAffected(u8 battlerId, u32 terrainFlag);
|
||||
u32 GetMonFriendshipScore(struct Pokemon *pokemon);
|
||||
u32 GetBattlerFriendshipScore(u8 battlerId);
|
||||
|
||||
#endif // GUARD_BATTLE_UTIL_H
|
||||
|
@ -565,5 +565,6 @@ u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *mon, u16 method, u32 arg
|
||||
u16 MonTryLearningNewMoveEvolution(struct Pokemon *mon, bool8 firstMove);
|
||||
bool32 ShouldShowFemaleDifferences(u16 species, u32 personality);
|
||||
void TryToSetBattleFormChangeMoves(struct Pokemon *mon);
|
||||
u32 GetMonFriendshipScore(struct Pokemon *pokemon);
|
||||
|
||||
#endif // GUARD_POKEMON_H
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "constants/hold_effects.h"
|
||||
#include "constants/items.h"
|
||||
#include "constants/pokemon.h"
|
||||
#include "battle_util.h"
|
||||
|
||||
// function declarations
|
||||
static void SpriteCB_SpriteToCentreOfSide(struct Sprite *sprite);
|
||||
@ -7899,6 +7900,6 @@ void AnimTask_AffectionHangedOn(u8 taskId)
|
||||
int side = GetBattlerSide(gBattleAnimTarget);
|
||||
struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
|
||||
|
||||
gBattleAnimArgs[0] = GetMonFriendshipScore(&party[gBattlerPartyIndexes[gBattleAnimTarget]]);
|
||||
gBattleAnimArgs[0] = GetBattlerFriendshipScore(gBattleAnimTarget);
|
||||
DestroyAnimVisualTask(taskId);
|
||||
}
|
||||
|
@ -1760,7 +1760,7 @@ u32 GetTotalAccuracy(u32 battlerAtk, u32 battlerDef, u32 move, u32 atkAbility, u
|
||||
#if B_AFFECTION_MECHANICS == TRUE
|
||||
// With high affection/friendship there's a chance to evade a move by substracting 10% of its accuracy.
|
||||
// I can't find exact information about that chance, so I'm just gonna write it as a 20% chance for now.
|
||||
if (GetMonFriendshipScore(&gPlayerParty[gBattlerPartyIndexes[battlerDef]]) >= FRIENDSHIP_150_TO_199 && (Random() % 100) <= 20)
|
||||
if (GetBattlerFriendshipScore(battlerDef) >= FRIENDSHIP_150_TO_199 && (Random() % 100) <= 20)
|
||||
calc = (calc * 90) / 100;
|
||||
#endif
|
||||
|
||||
@ -1933,7 +1933,7 @@ s32 CalcCritChanceStage(u8 battlerAtk, u8 battlerDef, u32 move, bool32 recordAbi
|
||||
+ 2 * (holdEffectAtk == HOLD_EFFECT_LUCKY_PUNCH && gBattleMons[gBattlerAttacker].species == SPECIES_CHANSEY)
|
||||
+ 2 * BENEFITS_FROM_LEEK(battlerAtk, holdEffectAtk)
|
||||
#if B_AFFECTION_MECHANICS == TRUE
|
||||
+ 2 * (GetMonFriendshipScore(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]]) >= FRIENDSHIP_200_TO_254)
|
||||
+ 2 * (GetBattlerFriendshipScore(gBattlerAttacker) >= FRIENDSHIP_200_TO_254)
|
||||
#endif
|
||||
+ (abilityAtk == ABILITY_SUPER_LUCK);
|
||||
|
||||
@ -2003,7 +2003,7 @@ static void Cmd_adjustdamage(void)
|
||||
{
|
||||
u8 holdEffect, param;
|
||||
u32 moveType;
|
||||
u32 friendshipScore = GetMonFriendshipScore(&gPlayerParty[gBattlerPartyIndexes[gBattlerTarget]]);
|
||||
u32 friendshipScore = GetBattlerFriendshipScore(gBattlerTarget);
|
||||
u32 rand = Random() % 100;
|
||||
|
||||
GET_MOVE_TYPE(gCurrentMove, moveType);
|
||||
@ -4113,7 +4113,7 @@ static void Cmd_getexp(void)
|
||||
}
|
||||
#endif
|
||||
#if B_AFFECTION_MECHANICS == TRUE
|
||||
if (GetMonFriendshipScore(&gPlayerParty[gBattleStruct->expGetterMonId]) >= FRIENDSHIP_50_TO_99)
|
||||
if (GetBattlerFriendshipScore(gBattleStruct->expGetterMonId) >= FRIENDSHIP_50_TO_99)
|
||||
gBattleMoveDamage = (gBattleMoveDamage * 120) / 100;
|
||||
#endif
|
||||
|
||||
|
@ -2105,24 +2105,23 @@ void TryToRevertMimicry(void)
|
||||
}
|
||||
}
|
||||
|
||||
u32 GetMonFriendshipScore(struct Pokemon *pokemon)
|
||||
u32 GetBattlerFriendshipScore(u8 battlerId)
|
||||
{
|
||||
u32 friendshipScore = GetMonData(pokemon, MON_DATA_FRIENDSHIP);
|
||||
u8 side = GetBattlerSide(battlerId);
|
||||
struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
|
||||
u16 species = GetMonData(&party[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
|
||||
|
||||
if (friendshipScore == MAX_FRIENDSHIP)
|
||||
return FRIENDSHIP_MAX;
|
||||
if (friendshipScore >= 200)
|
||||
return FRIENDSHIP_200_TO_254;
|
||||
if (friendshipScore >= 150)
|
||||
return FRIENDSHIP_150_TO_199;
|
||||
if (friendshipScore >= 100)
|
||||
return FRIENDSHIP_100_TO_149;
|
||||
if (friendshipScore >= 50)
|
||||
return FRIENDSHIP_50_TO_99;
|
||||
if (friendshipScore >= 1)
|
||||
return FRIENDSHIP_1_TO_49;
|
||||
if (side != B_SIDE_PLAYER)
|
||||
return FRIENDSHIP_NONE;
|
||||
else if (gBaseStats[species].flags & SPECIES_FLAG_MEGA_EVOLUTION
|
||||
|| (gBattleTypeFlags & (BATTLE_TYPE_EREADER_TRAINER
|
||||
| BATTLE_TYPE_FRONTIER
|
||||
| BATTLE_TYPE_LINK
|
||||
| BATTLE_TYPE_RECORDED_LINK
|
||||
| BATTLE_TYPE_SECRET_BASE)))
|
||||
return FRIENDSHIP_NONE;
|
||||
|
||||
return FRIENDSHIP_NONE;
|
||||
return GetMonFriendshipScore(&party[gBattlerPartyIndexes[battlerId]]);
|
||||
}
|
||||
|
||||
enum
|
||||
@ -2611,7 +2610,7 @@ u8 DoFieldEndTurnEffects(void)
|
||||
{
|
||||
#if B_AFFECTION_MECHANICS == TRUE
|
||||
if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER
|
||||
&& GetMonFriendshipScore(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]]) >= FRIENDSHIP_150_TO_199
|
||||
&& GetBattlerFriendshipScore(gBattlerAttacker) >= FRIENDSHIP_150_TO_199
|
||||
&& (Random() % 100 < 20))
|
||||
{
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = 1;
|
||||
|
@ -8513,3 +8513,23 @@ void TryToSetBattleFormChangeMoves(struct Pokemon *mon)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u32 GetMonFriendshipScore(struct Pokemon *pokemon)
|
||||
{
|
||||
u32 friendshipScore = GetMonData(pokemon, MON_DATA_FRIENDSHIP, NULL);
|
||||
|
||||
if (friendshipScore == MAX_FRIENDSHIP)
|
||||
return FRIENDSHIP_MAX;
|
||||
if (friendshipScore >= 200)
|
||||
return FRIENDSHIP_200_TO_254;
|
||||
if (friendshipScore >= 150)
|
||||
return FRIENDSHIP_150_TO_199;
|
||||
if (friendshipScore >= 100)
|
||||
return FRIENDSHIP_100_TO_149;
|
||||
if (friendshipScore >= 50)
|
||||
return FRIENDSHIP_50_TO_99;
|
||||
if (friendshipScore >= 1)
|
||||
return FRIENDSHIP_1_TO_49;
|
||||
|
||||
return FRIENDSHIP_NONE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user