unify JoinLocationCannotUseItems and IsClientOrTeamBase

This commit is contained in:
DizzyEggg 2024-09-14 23:01:20 +02:00
parent b7ae9ecf24
commit 193594e585
4 changed files with 8 additions and 95 deletions

View File

@ -736,17 +736,6 @@ void sub_80487CC(Entity *pokemon, Entity * target, u32 param_3, u32 param_4)
sub_8078B5C(pokemon, target, param_3, param_4, 1);
}
static inline bool8 JoinLocationCannotUseItems_1(EntityInfo *pokemonInfo)
{
if (pokemonInfo->joinedAt.joinedAt == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON)
return TRUE;
if (pokemonInfo->joinedAt.joinedAt == DUNGEON_RESCUE_TEAM_BASE)
return TRUE;
return FALSE;
}
void HandleGummiItemAction(Entity *pokemon, Entity *target, u8 gummiIndex)
{
s32 iVar3;
@ -764,7 +753,7 @@ void HandleGummiItemAction(Entity *pokemon, Entity *target, u8 gummiIndex)
gUnknown_810A808[targetInfo->types[0]][gummiIndex] +
gUnknown_810A808[targetInfo->types[1]][gummiIndex],0,1);
if (!targetInfo->isNotTeamMember) {
if (!JoinLocationCannotUseItems_1(targetInfo)) {
if (!IsClientOrTeamBase(targetInfo->joinedAt.joinedAt)) {
baseIQ = targetInfo->IQ;
targetInfo->IQ += gummiBoost;
currIQ = baseIQ + gummiBoost;
@ -820,19 +809,6 @@ void ZincItemAction(Entity *pokemon, Entity *target)
void nullsub_94(Entity *pokemon, Entity *target, u8 r2)
{}
static inline bool8 JoinLocationCannotUseItems_2(EntityInfo *pokemonInfo)
{
if (pokemonInfo->joinedAt.joinedAt == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON)
{
return TRUE;
}
if (pokemonInfo->joinedAt.joinedAt == DUNGEON_RESCUE_TEAM_BASE)
{
return TRUE;
}
return FALSE;
}
bool8 sub_8048950(Entity *param_1,Item *item)
{
u8 flag;
@ -865,7 +841,7 @@ bool8 sub_8048950(Entity *param_1,Item *item)
if (entityInfo->clientType == CLIENT_TYPE_CLIENT) {
flag = FALSE;
}
if (JoinLocationCannotUseItems_2(entityInfo)) {
if (IsClientOrTeamBase(entityInfo->joinedAt.joinedAt)) {
flag = FALSE;
}
entityInfo->unk157 = flag;
@ -885,19 +861,6 @@ bool8 sub_8048950(Entity *param_1,Item *item)
return FALSE;
}
static inline bool8 JoinLocationCannotUseItems_3(EntityInfo *pokemonInfo)
{
if (pokemonInfo->joinedAt.joinedAt == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON)
{
return TRUE;
}
if (pokemonInfo->joinedAt.joinedAt == DUNGEON_RESCUE_TEAM_BASE)
{
return TRUE;
}
return FALSE;
}
bool8 sub_8048A68(Entity *param_1,Item *item)
{
u8 flag;
@ -940,7 +903,7 @@ bool8 sub_8048A68(Entity *param_1,Item *item)
if (pEVar6->clientType == CLIENT_TYPE_CLIENT) {
flag = FALSE;
}
if (JoinLocationCannotUseItems_3(pEVar6)) {
if (IsClientOrTeamBase(pEVar6->joinedAt.joinedAt)) {
flag = FALSE;
}
if (pEVar6->isTeamLeader) {
@ -962,19 +925,6 @@ bool8 sub_8048A68(Entity *param_1,Item *item)
return FALSE;
}
static inline bool8 JoinLocationCannotUseItems_4(EntityInfo *pokemonInfo)
{
if (pokemonInfo->joinedAt.joinedAt == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON)
{
return TRUE;
}
if (pokemonInfo->joinedAt.joinedAt == DUNGEON_RESCUE_TEAM_BASE)
{
return TRUE;
}
return FALSE;
}
// TODO: should be bool8
bool32 sub_8048B9C(Entity *entity,Item *param_2)
{
@ -1016,7 +966,7 @@ bool32 sub_8048B9C(Entity *entity,Item *param_2)
{
flag = FALSE;
}
if(JoinLocationCannotUseItems_4(entity1Info))
if(IsClientOrTeamBase(entity1Info->joinedAt.joinedAt))
{
flag = FALSE;
}

View File

@ -130,21 +130,6 @@ void sub_8071B48(void)
}
}
static inline bool8 JoinLocationCannotUseItems(EntityInfo *pokemonInfo)
{
if (pokemonInfo->joinedAt.joinedAt == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON)
{
return TRUE;
}
if (pokemonInfo->joinedAt.joinedAt == DUNGEON_RESCUE_TEAM_BASE)
{
return TRUE;
}
return FALSE;
}
void sub_8071D4C(Entity *pokemon, Entity *target, s32 exp)
{
s32 newExp;
@ -153,7 +138,7 @@ void sub_8071D4C(Entity *pokemon, Entity *target, s32 exp)
info = target->info;
if (info->level != 100) {
if (!JoinLocationCannotUseItems(info)) {
if (!IsClientOrTeamBase(info->joinedAt.joinedAt)) {
newExp = info->exp + exp;
if (9999998 < newExp) {
newExp = 9999999;

View File

@ -526,19 +526,6 @@ u8 GetTreatmentBetweenMonsters(Entity *pokemon, Entity *targetPokemon, bool8 ign
return gTreatmentData[targetingDecoy][pokemonIsEnemy][targetIsEnemy][targetIsDecoy];
}
static inline bool8 JoinLocationCannotUseItems_1(EntityInfo *pokemonInfo)
{
if (pokemonInfo->joinedAt.joinedAt == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON)
{
return TRUE;
}
if (pokemonInfo->joinedAt.joinedAt == DUNGEON_RESCUE_TEAM_BASE)
{
return TRUE;
}
return FALSE;
}
u8 sub_807167C(Entity * pokemon, Entity * target)
{
bool8 cannotUseItems;
@ -548,9 +535,9 @@ u8 sub_807167C(Entity * pokemon, Entity * target)
pokemonEntityData = pokemon->info;
targetEntityInfo = target->info;
if (pokemonEntityData->clientType != CLIENT_TYPE_CLIENT) {
cannotUseItems = JoinLocationCannotUseItems_1(pokemonEntityData);
cannotUseItems = IsClientOrTeamBase(pokemonEntityData->joinedAt.joinedAt);
if (!cannotUseItems && (pokemonEntityData->shopkeeper == SHOPKEEPER_MODE_NORMAL) && (targetEntityInfo->clientType != CLIENT_TYPE_CLIENT)) {
cannotUseItems = JoinLocationCannotUseItems_1(targetEntityInfo);
cannotUseItems = IsClientOrTeamBase(targetEntityInfo->joinedAt.joinedAt);
if (cannotUseItems || (targetEntityInfo->shopkeeper != SHOPKEEPER_MODE_NORMAL)) {
error:
return TREATMENT_IGNORE;

View File

@ -77,21 +77,12 @@ bool8 sub_8070BC0(Entity* entity)
return FALSE;
}
static inline bool8 JoinLocationCannotUseItems(EntityInfo *pokemonInfo)
{
if (pokemonInfo->joinedAt.joinedAt == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON)
return TRUE;
if (pokemonInfo->joinedAt.joinedAt == DUNGEON_RESCUE_TEAM_BASE)
return TRUE;
return FALSE;
}
bool8 CheckVariousConditions(Entity *pokemon)
{
EntityInfo *pokemonInfo = pokemon->info;
if (pokemonInfo->clientType == CLIENT_TYPE_CLIENT
|| JoinLocationCannotUseItems(pokemonInfo)
|| IsClientOrTeamBase(pokemonInfo->joinedAt.joinedAt)
|| (!pokemonInfo->isTeamLeader && ShouldMonsterRunAway(pokemon))
|| CheckVariousStatuses2(pokemon, FALSE)
|| CheckVariousStatuses(pokemon))