diff --git a/asm/code_8040094.s b/asm/code_8040094.s index 8078324de..b728bf652 100644 --- a/asm/code_8040094.s +++ b/asm/code_8040094.s @@ -1663,7 +1663,7 @@ _08040E24: adds r6, r7, 0 _08040E26: adds r0, r6, 0 - bl EntityExists + bl EntityIsValid lsls r0, 24 cmp r0, 0 bne _08040E34 @@ -2104,7 +2104,7 @@ _0804118A: movs r2, 0 str r2, [sp, 0x14] adds r0, r6, 0 - bl EntityExists + bl EntityIsValid lsls r0, 24 cmp r0, 0 beq _080411CA @@ -2137,7 +2137,7 @@ _080411D0: cmp r5, r0 beq _08041216 adds r0, r6, 0 - bl EntityExists + bl EntityIsValid lsls r0, 24 cmp r0, 0 beq _08041216 @@ -2452,7 +2452,7 @@ sub_804143C: cmp r0, 0xED bne _08041476 adds r0, r4, 0 - bl EntityExists + bl EntityIsValid lsls r0, 24 cmp r0, 0 beq _080414A4 @@ -2613,7 +2613,7 @@ sub_8041550: lsls r0, 24 lsrs r6, r0, 24 adds r0, r7, 0 - bl EntityExists + bl EntityIsValid lsls r0, 24 cmp r0, 0 beq _0804159C diff --git a/asm/code_8044210.s b/asm/code_8044210.s index 401a8741d..cbe1f205e 100644 --- a/asm/code_8044210.s +++ b/asm/code_8044210.s @@ -30,7 +30,7 @@ _08044592: adds r0, r1 ldr r5, [r0] adds r0, r5, 0 - bl EntityExists + bl EntityIsValid lsls r0, 24 cmp r0, 0 beq _080446A4 @@ -110,7 +110,7 @@ _08044644: adds r0, r5, 0 bl TickStatusHeal adds r0, r5, 0 - bl EntityExists + bl EntityIsValid lsls r0, 24 cmp r0, 0 beq _080446A4 @@ -181,7 +181,7 @@ _080446D4: adds r0, r1 ldr r4, [r0] adds r0, r4, 0 - bl EntityExists + bl EntityIsValid lsls r0, 24 cmp r0, 0 beq _08044760 @@ -273,7 +273,7 @@ _0804476A: movs r0, 0 bl sub_8043ED0 adds r0, r4, 0 - bl EntityExists + bl EntityIsValid _080447A0: ldr r5, [r5, 0x4] cmp r5, 0 @@ -295,7 +295,7 @@ _080447B8: adds r0, r1 ldr r4, [r0] adds r0, r4, 0 - bl EntityExists + bl EntityIsValid lsls r0, 24 cmp r0, 0 beq _080447FC @@ -309,7 +309,7 @@ _080447B8: adds r0, r4, 0 bl sub_8074094 adds r0, r4, 0 - bl EntityExists + bl EntityIsValid lsls r0, 24 cmp r0, 0 beq _080447FC diff --git a/asm/code_8045A00.s b/asm/code_8045A00.s index 74dd85a19..86e17e07e 100644 --- a/asm/code_8045A00.s +++ b/asm/code_8045A00.s @@ -493,7 +493,7 @@ _0804618A: adds r0, r2 adds r0, r1 ldr r0, [r0] - bl EntityExists + bl EntityIsValid lsls r0, 24 adds r1, r4, 0x1 cmp r0, 0 @@ -597,7 +597,7 @@ _08046258: adds r0, r2 adds r0, r1 ldr r0, [r0] - bl EntityExists + bl EntityIsValid lsls r0, 24 adds r1, r4, 0x1 cmp r0, 0 @@ -659,7 +659,7 @@ sub_80462AC: movs r0, 0 str r0, [sp, 0x4] adds r0, r4, 0 - bl EntityExists + bl EntityIsValid lsls r0, 24 cmp r0, 0 bne _080462E4 @@ -1792,7 +1792,7 @@ _08046BAA: adds r4, r5 adds r4, 0x4 adds r0, r4, 0 - bl EntityExists + bl EntityIsValid lsls r0, 24 cmp r0, 0 beq _08046C06 diff --git a/asm/code_805D8C8.s b/asm/code_805D8C8.s index b90239e08..4f4389569 100644 --- a/asm/code_805D8C8.s +++ b/asm/code_805D8C8.s @@ -1995,7 +1995,7 @@ _080629FC: adds r0, r1 ldr r4, [r0] adds r0, r4, 0 - bl EntityExists + bl EntityIsValid lsls r0, 24 cmp r0, 0 beq _08062A5A @@ -5467,7 +5467,7 @@ sub_806455C: movs r3, 0 bl PrintStringOnWindow ldr r0, [r4, 0x14] - bl EntityExists + bl EntityIsValid lsls r0, 24 cmp r0, 0 beq _080645C0 diff --git a/asm/code_805D8C8_1.s b/asm/code_805D8C8_1.s index f2259e3f7..c06b39a17 100644 --- a/asm/code_805D8C8_1.s +++ b/asm/code_805D8C8_1.s @@ -944,7 +944,7 @@ _08069044: cmp r4, 0 beq _08069072 adds r0, r4, 0 - bl EntityExists + bl EntityIsValid lsls r0, 24 cmp r0, 0 beq _08069072 @@ -1149,7 +1149,7 @@ _080691FE: adds r0, r1 ldr r4, [r0] adds r0, r4, 0 - bl EntityExists + bl EntityIsValid lsls r0, 24 cmp r0, 0 beq _080691FC diff --git a/asm/code_8066D04.s b/asm/code_8066D04.s index 2449ee99a..4bbf2e6d6 100644 --- a/asm/code_8066D04.s +++ b/asm/code_8066D04.s @@ -821,7 +821,7 @@ _080674BC: bl sub_8047190 _080674D0: adds r0, r6, 0 - bl EntityExists + bl EntityIsValid lsls r0, 24 cmp r0, 0 beq _080674F8 @@ -1332,7 +1332,7 @@ _080678C6: cmp r0, 0 bne _080678F6 adds r0, r5, 0 - bl EntityExists + bl EntityIsValid lsls r0, 24 cmp r0, 0 beq _080678F0 @@ -1443,7 +1443,7 @@ _0806798E: movs r3, 0 bl TryUseChosenMove adds r0, r5, 0 - bl EntityExists + bl EntityIsValid lsls r0, 24 cmp r0, 0 beq _080679DE @@ -1462,7 +1462,7 @@ _080679D2: blt _0806798E _080679DE: adds r0, r5, 0 - bl EntityExists + bl EntityIsValid lsls r0, 24 cmp r0, 0 beq _08067A56 diff --git a/asm/code_8072CF4.s b/asm/code_8072CF4.s index eafd54dcf..bad448c7a 100644 --- a/asm/code_8072CF4.s +++ b/asm/code_8072CF4.s @@ -24,7 +24,7 @@ _080732FE: adds r0, r1 ldr r0, [r0] mov r8, r0 - bl EntityExists + bl EntityIsValid lsls r0, 24 adds r4, 0x1 str r4, [sp, 0x10] @@ -236,7 +236,7 @@ _0807349E: adds r0, r1 ldr r7, [r0] adds r0, r7, 0 - bl EntityExists + bl EntityIsValid lsls r0, 24 adds r4, 0x1 str r4, [sp, 0x10] diff --git a/asm/code_8083654.s b/asm/code_8083654.s index 203bf7dfc..854bf5259 100644 --- a/asm/code_8083654.s +++ b/asm/code_8083654.s @@ -491,7 +491,7 @@ _080839DA: _08083A00: ldr r4, [r5] adds r0, r4, 0 - bl EntityExists + bl EntityIsValid lsls r0, 24 cmp r0, 0 beq _08083A32 diff --git a/asm/code_808417C.s b/asm/code_808417C.s index e23e6dcab..a23fae6b2 100644 --- a/asm/code_808417C.s +++ b/asm/code_808417C.s @@ -548,7 +548,7 @@ _08084632: adds r0, r1 ldr r4, [r0] adds r0, r4, 0 - bl EntityExists + bl EntityIsValid lsls r0, 24 cmp r0, 0 beq _0808466E diff --git a/asm/code_80848F0.s b/asm/code_80848F0.s index 03ea894cd..454fbbc46 100644 --- a/asm/code_80848F0.s +++ b/asm/code_80848F0.s @@ -161,7 +161,7 @@ _0808538E: adds r0, r1 ldr r4, [r0] adds r0, r4, 0 - bl EntityExists + bl EntityIsValid lsls r0, 24 cmp r0, 0 beq _080853BE diff --git a/include/constants/status.h b/include/constants/status.h index 32ab62db7..c6acb0384 100644 --- a/include/constants/status.h +++ b/include/constants/status.h @@ -47,7 +47,7 @@ #define STATUS_CHARGING 11 #define STATUS_ENRAGED 12 -// ReflectClassStatus statuses +// Reflect class statuses #define STATUS_REFLECT 1 #define STATUS_SAFEGUARD 2 #define STATUS_LIGHT_SCREEN 3 diff --git a/include/dungeon_util.h b/include/dungeon_util.h index 845a2ec51..9d8e7fe91 100644 --- a/include/dungeon_util.h +++ b/include/dungeon_util.h @@ -9,7 +9,7 @@ extern const DungeonPos gAdjacentTileOffsets[NUM_DIRECTIONS]; -bool8 EntityExists(Entity *pokemon); +bool8 EntityIsValid(Entity *pokemon); u32 GetEntityType(Entity *entity); u8 GetEntityRoom(Entity *entity); Tile *GetTileAtEntitySafe(Entity *entity); diff --git a/include/items.h b/include/items.h index bdae533f7..1dd09dd99 100644 --- a/include/items.h +++ b/include/items.h @@ -29,7 +29,7 @@ u8 GetItemPalette(u8 id); u32 GetItemActionType(u8 id); u32 GetSpawnAmountRange(u8 id, u32 r1); u8 *GetItemDescription(u8 id); -bool8 GetItemAIFlag(u8 id, u32 r1); +bool8 TestItemAIFlag(u8 id, u32 aiFlag); void BufferItemName(u8 *, u8 id, unkStruct_8090F58 *); void sub_8090E14(u8 *ext_buffer, Item *slot, const unkStruct_8090F58 *); bool8 AddItemToInventory(const Item* slot); diff --git a/include/structs/dungeon_entity.h b/include/structs/dungeon_entity.h index 542d72370..2bd92ba32 100644 --- a/include/structs/dungeon_entity.h +++ b/include/structs/dungeon_entity.h @@ -30,11 +30,11 @@ #define STAT_STAGE_EVASION 1 // size: 0x8 -typedef struct unkStruct_8044CC8 +typedef struct ActionParameter { /* 0x0 */ u8 actionUseIndex; - /* 0x4 */ DungeonPos lastItemThrowPosition; -} unkStruct_8044CC8; + /* 0x4 */ DungeonPos itemPos; +} ActionParameter; // size: 0x18 typedef struct ActionContainer @@ -43,7 +43,7 @@ typedef struct ActionContainer /* 0x2 */ u8 direction; u8 unk3; // Additional parameter alongside actionIndex. Used for things like indicating which move a Pokémon should use from its moveset. - /* 0x4 */ unkStruct_8044CC8 unk4[2]; + /* 0x4 */ ActionParameter actionParameters[2]; // Position of the target that the Pokémon wants throw an item at. /* 0x14 */ DungeonPos itemTargetPosition; } ActionContainer; diff --git a/src/code_803E724.c b/src/code_803E724.c index fd7ce16ef..e05868484 100644 --- a/src/code_803E724.c +++ b/src/code_803E724.c @@ -348,7 +348,7 @@ void sub_803EDF0(void) if (gUnknown_202EDE8.unk0 == 0) return; - if (!EntityExists(gUnknown_202EDE8.unk4)) { + if (!EntityIsValid(gUnknown_202EDE8.unk4)) { gUnknown_202EDE8.unk0 = 0; return; } @@ -935,7 +935,7 @@ void sub_803F580(u8 a0) UnkDungeonGlobal_unk181E8_sub *strPtr = &gDungeon->unk181e8; Entity *cameraTarget = strPtr->cameraTarget; - if (cameraTarget != NULL && EntityExists(cameraTarget)) { + if (cameraTarget != NULL && EntityIsValid(cameraTarget)) { s32 i; u32 before, unk18214; EntityInfo *info = GetEntInfo(cameraTarget); @@ -1036,7 +1036,7 @@ void sub_803F580(u8 a0) if (strPtr->cameraPos.x != strPtr->cameraPosMirror.x || strPtr->cameraPos.y != strPtr->cameraPosMirror.y) { for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { Entity *mon = gDungeon->activePokemon[i]; - if (EntityExists(mon)) { + if (EntityIsValid(mon)) { sub_80402AC(mon->pos.x, mon->pos.y); } } diff --git a/src/code_8041AD0.c b/src/code_8041AD0.c index 0df115287..e1818434f 100644 --- a/src/code_8041AD0.c +++ b/src/code_8041AD0.c @@ -156,7 +156,7 @@ void sub_8041888(u8 param_1) for(index = 0; index < DUNGEON_MAX_POKEMON; index++) { entity = gDungeon->activePokemon[index]; - if(EntityExists(entity)) + if(EntityIsValid(entity)) { entityInfo = GetEntInfo(entity); if(param_1) @@ -176,7 +176,7 @@ void EntityUpdateStatusSprites(Entity *entity) u32 spriteStatus; u8 temp; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { entityInfo = GetEntInfo(entity); spriteStatus = 0; flag = TRUE; diff --git a/src/code_804267C.c b/src/code_804267C.c index 6bc3c29a2..91b909f22 100644 --- a/src/code_804267C.c +++ b/src/code_804267C.c @@ -104,7 +104,7 @@ void sub_80427AC(void) for (i = 0; i < 20; i++) { entity = gDungeon->activePokemon[i]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { enInfo = GetEntInfo(entity); if (enInfo->unkF3) { enInfo->unkF3 = FALSE; diff --git a/src/code_8042B34.c b/src/code_8042B34.c index a12e44564..e470c875c 100644 --- a/src/code_8042B34.c +++ b/src/code_8042B34.c @@ -731,7 +731,7 @@ void xxx_dungeon_8042F6C(struct UnkStruct_xxx_dungeon_8042F6C *r8) } leader = GetLeader(); - if (EntityExists(leader)) { + if (EntityIsValid(leader)) { sub_8071DA4(leader); } @@ -746,7 +746,7 @@ void xxx_dungeon_8042F6C(struct UnkStruct_xxx_dungeon_8042F6C *r8) } } - if (EntityExists(GetLeader())) { + if (EntityIsValid(GetLeader())) { sub_80526D0(0x4F); sub_8052740(0x4F); } @@ -978,7 +978,7 @@ void sub_8043D60(void) for (monId = 0; monId < DUNGEON_MAX_WILD_POKEMON; monId++) { Entity *mon = gDungeon->wildPokemon[monId]; - if (EntityExists(mon)) { + if (EntityIsValid(mon)) { EntityInfo *monInfo = GetEntInfo(mon); bool32 unk = TRUE; @@ -997,7 +997,7 @@ void sub_8043D60(void) for (monId = 0; monId < MAX_TEAM_MEMBERS; monId++) { Entity *mon = gDungeon->teamPokemon[monId]; - if (EntityExists(mon)) { + if (EntityIsValid(mon)) { s32 i; EntityInfo *monInfo; @@ -1022,7 +1022,7 @@ void sub_8043D60(void) for (y = 0; y < 32; y++) { for (x = 0; x < 56; x++) { Entity *object = GetTileMut(x, y)->object; - if (EntityExists(object) && GetEntityType(object) == ENTITY_TRAP) { + if (EntityIsValid(object) && GetEntityType(object) == ENTITY_TRAP) { Trap *trapData = GetTrapData(object); if (trapData->id == 27) { trapData->id = TRAP_PITFALL_TRAP; @@ -1043,7 +1043,7 @@ bool8 sub_8043ED0(bool8 a0) if (gDungeon->unk10 == 1) { Entity *leader = GetLeader(); - if (EntityExists(leader)) { + if (EntityIsValid(leader)) { if (!a0) { strcpy(gFormatBuffer_Monsters[0], gDungeon->faintStringBuffer); DisplayDungeonMessage(0, gUnknown_80F89B4, 1); @@ -1055,7 +1055,7 @@ bool8 sub_8043ED0(bool8 a0) } else if (gDungeon->unk10 == 2) { Entity *leader = GetLeader(); - if (EntityExists(leader)) { + if (EntityIsValid(leader)) { if (!a0) { strcpy(gFormatBuffer_Monsters[0], gDungeon->faintStringBuffer); DisplayDungeonMessage(0, gUnknown_80F89D4, 1); @@ -1067,7 +1067,7 @@ bool8 sub_8043ED0(bool8 a0) } else if (gDungeon->unk10 == 3) { Entity *leader = GetLeader(); - if (EntityExists(leader)) { + if (EntityIsValid(leader)) { if (!a0) { strcpy(gFormatBuffer_Monsters[0], gDungeon->faintStringBuffer); DisplayDungeonMessage(0, gUnknown_80F89D8, 1); diff --git a/src/code_8044CC8.c b/src/code_8044CC8.c index ca7285cf3..b9a560d87 100644 --- a/src/code_8044CC8.c +++ b/src/code_8044CC8.c @@ -36,7 +36,7 @@ extern u8 GetFloorType(void); void sub_80460F8(DungeonPos *, Item *, u32); bool8 sub_80461C8(DungeonPos *, u32); -Item * sub_8044CC8(Entity *param_1, unkStruct_8044CC8 *param_2) +Item * sub_8044CC8(Entity *param_1, ActionParameter *param_2) { const Tile *tile; Item *item; @@ -46,7 +46,7 @@ Item * sub_8044CC8(Entity *param_1, unkStruct_8044CC8 *param_2) item = &gTeamInventoryRef->teamItems[param_2->actionUseIndex - 1]; } else if (param_2->actionUseIndex == 0x80) { - tile = GetTile((param_2->lastItemThrowPosition).x,(param_2->lastItemThrowPosition).y); + tile = GetTile((param_2->itemPos).x,(param_2->itemPos).y); item = GetItemData(tile->object); } else { @@ -67,9 +67,9 @@ Item * sub_8044CC8(Entity *param_1, unkStruct_8044CC8 *param_2) bool8 sub_8044D40(ActionContainer *param_1,s32 index) { Item *item; - unkStruct_8044CC8 *puVar1; + ActionParameter *puVar1; - puVar1 = ¶m_1->unk4[index]; + puVar1 = ¶m_1->actionParameters[index]; if ((u8)(puVar1->actionUseIndex - 1) < INVENTORY_SIZE) { item = &gTeamInventoryRef->teamItems[puVar1->actionUseIndex - 1]; item->id = ITEM_NOTHING; @@ -81,21 +81,25 @@ bool8 sub_8044D40(ActionContainer *param_1,s32 index) if (puVar1->actionUseIndex != 0x80) { return FALSE; } - sub_80461C8(&puVar1->lastItemThrowPosition,1); + sub_80461C8(&puVar1->itemPos,1); } return TRUE; } Item *sub_8044D90(Entity *entity, s32 index, s32 unused) { EntityInfo *info = GetEntInfo(entity); - register unkStruct_8044CC8 *puVar1 asm("r3") = &info->action.unk4[index]; +#ifdef NONMATCHING + ActionParameter *puVar1 = &info->action.actionParameters[index]; +#else + register ActionParameter *puVar1 asm("r3") = &info->action.actionParameters[index]; +#endif return sub_8044CC8(entity, puVar1); } Entity *sub_8044DA4(Entity *entity, s32 index) { EntityInfo *info = GetEntInfo(entity); - return gDungeon->teamPokemon[info->action.unk4[index].actionUseIndex]; + return gDungeon->teamPokemon[info->action.actionParameters[index].actionUseIndex]; } u16 sub_8044DC8(Item *param_1) @@ -115,8 +119,8 @@ void sub_8044DF0(Entity *entity, s32 index, u32 unused) info = GetEntInfo(entity); item = sub_8044D90(entity,index,unused); - if ((info->action).unk4[0].actionUseIndex == 0x80) { - sub_80461C8(&(info->action).unk4[0].lastItemThrowPosition,1); + if ((info->action).actionParameters[0].actionUseIndex == 0x80) { + sub_80461C8(&(info->action).actionParameters[0].itemPos,1); } else { item->id = ITEM_NOTHING; @@ -138,9 +142,9 @@ void sub_8044E24(Entity *entity,int index,u32 unused) info = GetEntInfo(entity); if (!IsHMItem(itemPtr->id)) { if (GetItemCategory(itemPtr->id) == CATEGORY_TMS_HMS) { - if (info->action.unk4[index].actionUseIndex == 0x80) { + if (info->action.actionParameters[index].actionUseIndex == 0x80) { item = *itemPtr; - pos = &info->action.unk4[index].lastItemThrowPosition; + pos = &info->action.actionParameters[index].itemPos; sub_80461C8(pos,1); item.quantity = itemPtr->id - 125; item.id = ITEM_TM_USED_TM; diff --git a/src/code_80450F8.c b/src/code_80450F8.c index 7da0fbab5..a1f59b13b 100644 --- a/src/code_80450F8.c +++ b/src/code_80450F8.c @@ -40,7 +40,7 @@ Entity *sub_80453AC(s32 _species) s32 j; Entity *entity = gDungeon->teamPokemon[i]; - if (!EntityExists(entity)) { + if (!EntityIsValid(entity)) { entity->type = ENTITY_MONSTER; entity->unk24 = i; entity->axObj.info.monster = &gDungeon->unk69C[i]; @@ -101,7 +101,7 @@ Entity *sub_804550C(s32 _species) s32 j; Entity *entity = gDungeon->wildPokemon[i]; - if (!EntityExists(entity)) { + if (!EntityIsValid(entity)) { entity->type = ENTITY_MONSTER; entity->unk24 = i; entity->unk22 = 0; @@ -146,7 +146,7 @@ Entity *SpawnTrap(u8 trapID, DungeonPos *pos, u8 c) for (i = 0; i < DUNGEON_MAX_TRAPS; i++) { entity = gDungeon->traps[i]; - if (!EntityExists(entity)) { + if (!EntityIsValid(entity)) { entity->type = ENTITY_TRAP; entity->axObj.info.trap = &gDungeon->unk3908[i]; entity->axObj.info.trap->id = trapID; @@ -175,7 +175,7 @@ Entity *sub_8045708(DungeonPos *pos) for (i = 0; i < DUNGEON_MAX_ITEMS; i++) { ent = gDungeon->items[i]; - if (!EntityExists(ent)) { + if (!EntityIsValid(ent)) { ent->type = ENTITY_ITEM; ent->axObj.info.item = &gDungeon->unk3804[i]; diff --git a/src/code_8045A00.c b/src/code_8045A00.c index 7ad221a53..adeaed8d2 100644 --- a/src/code_8045A00.c +++ b/src/code_8045A00.c @@ -31,7 +31,7 @@ void sub_8045ACC(void) for(index = 0; index < MAX_TEAM_MEMBERS; index++) { entity = gDungeon->teamPokemon[index]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { gDungeon->activePokemon[pokeCount] = entity; pokeCount++; } @@ -40,7 +40,7 @@ void sub_8045ACC(void) for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++) { entity = gDungeon->wildPokemon[index]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { gDungeon->activePokemon[pokeCount] = entity; pokeCount++; } diff --git a/src/code_8048480.c b/src/code_8048480.c index fdef7cb24..954771ce3 100644 --- a/src/code_8048480.c +++ b/src/code_8048480.c @@ -798,7 +798,7 @@ bool8 sub_8048950(Entity *param_1,Item *item) for(index = 0; index < MAX_TEAM_MEMBERS; index++) { entity = gDungeon->teamPokemon[index]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { entityInfo = GetEntInfo(entity); flag = CanMonLearnMove(moveID, entityInfo->id); if (CheckVariousStatuses2(entity, FALSE)) { @@ -814,7 +814,7 @@ bool8 sub_8048950(Entity *param_1,Item *item) } } entity2 = DrawFieldGiveItemMenu(0,1); - if (!EntityExists(entity2)) { + if (!EntityIsValid(entity2)) { return FALSE; } sub_804245C(param_1,item); @@ -851,7 +851,7 @@ bool8 sub_8048A68(Entity *param_1,Item *item) for(index = 0; index < MAX_TEAM_MEMBERS; index++) { entity = gDungeon->teamPokemon[index]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { pEVar6 = GetEntInfo(entity); flag = TRUE; if(((MAX_TEAM_MEMBERS - 1) < pEVar6->teamIndex)) @@ -879,7 +879,7 @@ bool8 sub_8048A68(Entity *param_1,Item *item) } } entity2 = DrawFieldGiveItemMenu(0,1); - if (!EntityExists(entity2)) { + if (!EntityIsValid(entity2)) { return FALSE; } sub_804245C(param_1,item); @@ -908,7 +908,7 @@ bool8 sub_8048B9C(Entity *entity, Item *item) for (i = 0; i < MAX_TEAM_MEMBERS; i++) { Entity *teamMon = gDungeon->teamPokemon[i]; - if (EntityExists(teamMon)) { + if (EntityIsValid(teamMon)) { EntityInfo *teamMonInfo = GetEntInfo(teamMon); bool8 flag = TRUE; if (CheckVariousStatuses2(teamMon, FALSE)){ @@ -925,7 +925,7 @@ bool8 sub_8048B9C(Entity *entity, Item *item) } entity2 = DrawFieldGiveItemMenu(0,1); - if (!EntityExists(entity2)) { + if (!EntityIsValid(entity2)) { return FALSE; } diff --git a/src/code_805D8C8.c b/src/code_805D8C8.c index b8fa96feb..8b5ca511d 100644 --- a/src/code_805D8C8.c +++ b/src/code_805D8C8.c @@ -23,7 +23,7 @@ void sub_8068768(void) for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { entity = gDungeon->activePokemon[i]; - if (entity != NULL && EntityExists(entity)) + if (entity != NULL && EntityIsValid(entity)) LoadPokemonSprite(GetEntInfo(entity)->apparentID, FALSE); } } diff --git a/src/code_805D8C8_1.c b/src/code_805D8C8_1.c index 1fd19e071..e81651380 100644 --- a/src/code_805D8C8_1.c +++ b/src/code_805D8C8_1.c @@ -192,7 +192,7 @@ void DungeonHandlePlayerInput(void) if (gDungeon->unk644.unk28 != 0) { if (sub_805E874() != 0) { leaderInfo->action.action = 2; - leaderInfo->action.unk4[0].actionUseIndex = 0; + leaderInfo->action.actionParameters[0].actionUseIndex = 0; break; } sub_805E804(); @@ -305,8 +305,8 @@ void DungeonHandlePlayerInput(void) } else { SetMonsterActionFields(&leaderInfo->action, ACTION_USE_MOVE_PLAYER); - leaderInfo->action.unk4[0].actionUseIndex = GetTeamMemberEntityIndex(leader); - leaderInfo->action.unk4[1].actionUseIndex = i; + leaderInfo->action.actionParameters[0].actionUseIndex = GetTeamMemberEntityIndex(leader); + leaderInfo->action.actionParameters[1].actionUseIndex = i; } break; } @@ -412,9 +412,9 @@ void DungeonHandlePlayerInput(void) for (i = 0; i < INVENTORY_SIZE; i++) { if (ItemExists(&gTeamInventoryRef->teamItems[i]) && ItemSet(&gTeamInventoryRef->teamItems[i])) { sub_8044C50(ACTION_THROW_ITEM_PLAYER); - leaderInfo->action.unk4[0].actionUseIndex = i +1; - leaderInfo->action.unk4[0].lastItemThrowPosition.x = 0; - leaderInfo->action.unk4[0].lastItemThrowPosition.y = 0; + leaderInfo->action.actionParameters[0].actionUseIndex = i +1; + leaderInfo->action.actionParameters[0].itemPos.x = 0; + leaderInfo->action.actionParameters[0].itemPos.y = 0; break; } } @@ -536,10 +536,10 @@ void DungeonHandlePlayerInput(void) if (GetEntInfo(leader)->cringeClassStatus.status != STATUS_CONFUSED) { gDungeon->unk644.unk28 = 1; } - leaderInfo->action.unk4[0].actionUseIndex = 0; + leaderInfo->action.actionParameters[0].actionUseIndex = 0; } else { - leaderInfo->action.unk4[0].actionUseIndex = 1; + leaderInfo->action.actionParameters[0].actionUseIndex = 1; } } break; @@ -963,15 +963,15 @@ bool8 sub_805EC4C(Entity *a0, u8 a1) SetMonsterActionFields(&entityInfo->action, ACTION_WALK); if (gRealInputs.held & B_BUTTON) { - entityInfo->action.unk4[0].actionUseIndex = 0; + entityInfo->action.actionParameters[0].actionUseIndex = 0; } else { - entityInfo->action.unk4[0].actionUseIndex = 1; + entityInfo->action.actionParameters[0].actionUseIndex = 1; } entityInfo->flags |= 0x8000; SetMonsterActionFields(&tileMonsterInfo->action, ACTION_WALK); - tileMonsterInfo->action.unk4[0].actionUseIndex = 0; + tileMonsterInfo->action.actionParameters[0].actionUseIndex = 0; tileMonsterInfo->action.direction = (entityInfo->action.direction + 4) & 7; tileMonsterInfo->flags |= 0x8000; tileMonsterInfo->targetPos.x = tileMonster->pos.x; @@ -1161,7 +1161,7 @@ u16 GetLeaderActionId(void) // Could this be a start of a new file? static UNUSED EWRAM_DATA u8 sUnused[4] = {0}; -static EWRAM_DATA unkStruct_8044CC8 sUnknownActionUnk4 = {0}; +static EWRAM_DATA ActionParameter sUnknownActionUnk4 = {0}; static EWRAM_DATA s32 sUnknown_202F240 = 0; static UNUSED EWRAM_DATA u8 sUnused2[4] = {0}; static EWRAM_DATA s16 sUnknown_202F248[8] = {0}; @@ -1321,8 +1321,8 @@ void ShowFieldMenu(u8 a0_, bool8 a1) count = 0; for (i = 0; i < MAX_TEAM_MEMBERS; i++) { Entity *teamMon = gDungeon->teamPokemon[i]; - if (EntityExists(teamMon)) { - if (i == GetLeaderActionContainer()->unk4[0].actionUseIndex) { + if (EntityIsValid(teamMon)) { + if (i == GetLeaderActionContainer()->actionParameters[0].actionUseIndex) { sTeamMenuChosenId = count; if (GetLeaderActionId() != 0) { sub_806A2BC(teamMon, 0); @@ -1345,7 +1345,7 @@ void ShowFieldMenu(u8 a0_, bool8 a1) sub_8044C10(1); for (i = 0; i < MAX_TEAM_MEMBERS; i++) { Entity *teamMon = gDungeon->teamPokemon[i]; - if (EntityExists(teamMon)) { + if (EntityIsValid(teamMon)) { if (GetEntInfo(teamMon)->isTeamLeader) { r7 = i; break; @@ -1376,7 +1376,7 @@ void ShowFieldMenu(u8 a0_, bool8 a1) sub_806A2BC(r6, 0); sub_804A728(&r6->pos, 0, 1, 1); - GetLeaderInfo()->action.unk4[0].actionUseIndex = r7; + GetLeaderInfo()->action.actionParameters[0].actionUseIndex = r7; sub_8044C10(0); if (sub_8062F90(r6, 0, 1, r9, r8)) { r10 = -1; @@ -1392,7 +1392,7 @@ void ShowFieldMenu(u8 a0_, bool8 a1) if (sub_8071A8C(r6)) break; } - GetLeaderInfo()->action.unk4[0].actionUseIndex = r7; + GetLeaderInfo()->action.actionParameters[0].actionUseIndex = r7; if (r4 != r7) { sub_8083CE0(0); } @@ -1408,7 +1408,7 @@ void ShowFieldMenu(u8 a0_, bool8 a1) if (sub_8071A8C(r6)) break; } - GetLeaderInfo()->action.unk4[0].actionUseIndex = r7; + GetLeaderInfo()->action.actionParameters[0].actionUseIndex = r7; if (r4 != r7) { sub_8083CE0(0); } @@ -1636,7 +1636,7 @@ void DrawFieldMenu(u8 a0) PrintFormattedStringOnWindow(0x73, 36, gUnknown_80F91C8, 2, 0); for (yLoop = 0, i = 0; i < MAX_TEAM_MEMBERS; i++) { Entity *teamMon = gDungeon->teamPokemon[i]; - if (EntityExists(teamMon)) { + if (EntityIsValid(teamMon)) { EntityInfo *monInfo = GetEntInfo(teamMon); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0], teamMon, 0); gFormatArgs[0] = monInfo->HP; @@ -1803,8 +1803,8 @@ bool8 sub_805FD74(Entity * a0, struct UnkMenuBitsStruct *a1) }; sUnknownActionUnk4.actionUseIndex = 0; - sUnknownActionUnk4.lastItemThrowPosition.x = 0; - sUnknownActionUnk4.lastItemThrowPosition.y = 0; + sUnknownActionUnk4.itemPos.x = 0; + sUnknownActionUnk4.itemPos.y = 0; if (a1 != NULL) { var_2C = (a1->a0_8 != 0); var_34 = (a1->a0_16 != 0); @@ -1836,7 +1836,7 @@ bool8 sub_805FD74(Entity * a0, struct UnkMenuBitsStruct *a1) } for (i_r6 = 0; i_r6 < MAX_TEAM_MEMBERS; i_r6++) { Entity *teamMon = gDungeon->teamPokemon[i_r6]; - if (EntityExists(teamMon)) { + if (EntityIsValid(teamMon)) { EntityInfo *monInfo = GetEntInfo(teamMon); if (monInfo->heldItem.flags & ITEM_FLAG_EXISTS && monInfo->heldItem.flags & ITEM_FLAG_UNPAID) { monInfo->heldItem.flags &= ~(ITEM_FLAG_UNPAID); @@ -1962,7 +1962,7 @@ bool8 sub_805FD74(Entity * a0, struct UnkMenuBitsStruct *a1) } else if (r9 == 3) { SetMonsterActionFields(&a0Info->action, 0xC); - a0Info->action.unk4[0] = sUnknownActionUnk4; + a0Info->action.actionParameters[0] = sUnknownActionUnk4; sub_803EAF0(0, NULL); r9 = 0; break; @@ -1970,7 +1970,7 @@ bool8 sub_805FD74(Entity * a0, struct UnkMenuBitsStruct *a1) else { sUnknown_202F240 = gUnknown_202EE10.menuIndex; if (var_2C != 0) { - a0Info->action.unk4[1] = sUnknownActionUnk4; + a0Info->action.actionParameters[1] = sUnknownActionUnk4; sub_803EAF0(0, NULL); r9 = 0; break; @@ -2012,7 +2012,7 @@ bool8 sub_805FD74(Entity * a0, struct UnkMenuBitsStruct *a1) if (a0Info->action.action == 0x37 || a0Info->action.action == 0x38 || a0Info->action.action == 0x3E) { // Hm... int newAction = sUnknownActionUnk4.actionUseIndex - 0x90; - a0Info->action.unk4[0].actionUseIndex = newAction; + a0Info->action.actionParameters[0].actionUseIndex = newAction; sub_803EAF0(0, 0); r9 = 0; break; @@ -2020,7 +2020,7 @@ bool8 sub_805FD74(Entity * a0, struct UnkMenuBitsStruct *a1) else if (a0Info->action.action == 0x36) { u32 var_38; if (DrawFieldGiveItemMenu((void*)&var_38, 2) != NULL) { - a0Info->action.unk4[1].actionUseIndex = var_38; + a0Info->action.actionParameters[1].actionUseIndex = var_38; sub_803EAF0(0, 0); r9 = 0; break; @@ -2171,7 +2171,7 @@ static void CreateFieldItemMenu(s32 a0, Entity *a1, bool8 a2, bool8 a3, UnkTextS break; default: { Entity *chosenTeamMember = gDungeon->teamPokemon[sUnknown_202F248[a0] - MAX_TEAM_MEMBERS]; - if (EntityExists(chosenTeamMember)) { + if (EntityIsValid(chosenTeamMember)) { EntityInfo *monInfo = GetEntInfo(chosenTeamMember); Item *item = &monInfo->heldItem; SetMessageArgument_2(gFormatBuffer_Monsters[0], monInfo, 0); @@ -2255,11 +2255,11 @@ void sub_8060890(DungeonPos *a0) break; } - sUnknownActionUnk4.lastItemThrowPosition.x = a0->x; - sUnknownActionUnk4.lastItemThrowPosition.y = a0->y; + sUnknownActionUnk4.itemPos.x = a0->x; + sUnknownActionUnk4.itemPos.y = a0->y; } -extern Item * sub_8044CC8(Entity *param_1, unkStruct_8044CC8 *param_2, UNUSED s32 a3); +extern Item * sub_8044CC8(Entity *param_1, ActionParameter *param_2, UNUSED s32 a3); extern void sub_8044F5C(u16 param_1, u8 param_2); extern void sub_8044FF0(u16 param_1); extern u16 sub_8044DC8(Item *param_1); @@ -2338,7 +2338,7 @@ void sub_8060900(Entity *a0) sub_8044F5C(0x36, item->id); for (i = 0; i < MAX_TEAM_MEMBERS; i++) { Entity *teamMon = gDungeon->teamPokemon[i]; - if (EntityExists(teamMon)) { + if (EntityIsValid(teamMon)) { EntityInfo *teamMonInfo = GetEntInfo(teamMon); teamMonInfo->unk157 = FALSE; if (!CheckVariousConditions(teamMon)) { @@ -2395,7 +2395,7 @@ void sub_8060900(Entity *a0) else { s32 index = sUnknownActionUnk4.actionUseIndex - 144; Entity *teamMon = gDungeon->teamPokemon[index]; - if (EntityExists(teamMon)) { + if (EntityIsValid(teamMon)) { bool32 r5, r6, r4; EntityInfo *teamMonInfo = GetEntInfo(teamMon); @@ -2455,10 +2455,10 @@ void sub_8060900(Entity *a0) void sub_8060CE8(ActionContainer *a0) { SetMonsterActionFields(a0, gUnknown_202EE44[gUnknown_202EE10.menuIndex].unk0); - a0->unk4[0] = sUnknownActionUnk4; - a0->unk4[1].actionUseIndex = 0; - a0->unk4[1].lastItemThrowPosition.x = 0; - a0->unk4[1].lastItemThrowPosition.y = 0; + a0->actionParameters[0] = sUnknownActionUnk4; + a0->actionParameters[1].actionUseIndex = 0; + a0->actionParameters[1].itemPos.x = 0; + a0->actionParameters[1].itemPos.y = 0; } void sub_8060D24(UNUSED ActionContainer *a0) @@ -2498,7 +2498,7 @@ s32 sub_8060D64(s16 *a0, bool8 a1, bool8 a2, bool8 a3, Entity *a4) if (!a1 && !a3) { for (i = 0; i < MAX_TEAM_MEMBERS; i++) { Entity *teamMon = gDungeon->teamPokemon[i]; - if (EntityExists(teamMon) && GetEntInfo(teamMon)->heldItem.flags & ITEM_FLAG_EXISTS) { + if (EntityIsValid(teamMon) && GetEntInfo(teamMon)->heldItem.flags & ITEM_FLAG_EXISTS) { a0[count++] = i + MAX_TEAM_MEMBERS; } } @@ -2543,7 +2543,7 @@ bool8 sub_8060E38(Entity *a0) for (i = 0; i < MAX_TEAM_MEMBERS; i++) { Entity *teamMon = gDungeon->teamPokemon[i]; - if (EntityExists(teamMon)) { + if (EntityIsValid(teamMon)) { GetEntInfo(teamMon)->unk157 = TRUE; } } @@ -2621,7 +2621,7 @@ bool8 sub_8060E38(Entity *a0) if (r10) { EntityInfo *info = GetEntInfo(a0); SetMonsterActionFields(&info->action, 0x1B); - info->action.unk4[0].actionUseIndex = sp.unk4[sp.unk0]; + info->action.actionParameters[0].actionUseIndex = sp.unk4[sp.unk0]; ret = FALSE; break; } @@ -2699,7 +2699,7 @@ void DrawFieldTeamMenu(struct UnkFieldTeamMenuStruct *a0, UnkTextStruct3 *a1, bo for (i = 0; i < MAX_TEAM_MEMBERS; i++) { EntityInfo *monInfo; Entity *teamMon = gDungeon->teamPokemon[i]; - if (EntityExists(teamMon)) { + if (EntityIsValid(teamMon)) { a0->unk4[count] = i; monInfo = GetEntInfo(teamMon); a0->unk14[count] = monInfo->unk157; @@ -2761,7 +2761,7 @@ void DrawFieldTeamMenu(struct UnkFieldTeamMenuStruct *a0, UnkTextStruct3 *a1, bo s32 id = a0->unk4[i]; if (id >= 0) { Entity *teamMon = gDungeon->teamPokemon[id]; - if (EntityExists(teamMon)) + if (EntityIsValid(teamMon)) { EntityInfo *monInfo = GetEntInfo(teamMon); s32 color = (a0->unk14[i] != 0) ? 6 : 2; @@ -2871,7 +2871,7 @@ void sub_806145C(struct UnkFieldTeamMenuStruct *a0) void sub_80615B4(ActionContainer *a0, struct UnkFieldTeamMenuStruct *a1) { SetMonsterActionFields(a0, gUnknown_202EE44[gUnknown_202EE10.menuIndex].unk0); - a0->unk4[0].actionUseIndex = a1->unk4[a1->unk0]; + a0->actionParameters[0].actionUseIndex = a1->unk4[a1->unk0]; } void PrintMonTactics(s32 a0, u8 *tacticIds, EntityInfo *mon, s32 windowId); @@ -2906,7 +2906,7 @@ void ShowTacticsMenu(ActionContainer *a0) Entity *teamMon; SetTxtStruct(&sp); - teamMon = gDungeon->teamPokemon[a0->unk4[0].actionUseIndex]; + teamMon = gDungeon->teamPokemon[a0->actionParameters[0].actionUseIndex]; monInfo = GetEntInfo(teamMon); menuIndex = 0; scrollFirstId = 0; diff --git a/src/code_8066D04.c b/src/code_8066D04.c index 1c5eb7a32..9462a3811 100644 --- a/src/code_8066D04.c +++ b/src/code_8066D04.c @@ -37,7 +37,7 @@ extern void sub_8045DB4(DungeonPos *, u32); void HandlePickUpPlayerAction(Entity *entity) { - GetEntInfo(entity)->action.unk4[0].actionUseIndex = 1; + GetEntInfo(entity)->action.actionParameters[0].actionUseIndex = 1; sub_8045DB4(&entity->pos,0); } @@ -125,7 +125,7 @@ void HandleGiveItemAction(Entity *param_1) info2 = GetEntInfo(entity); item = sub_8044D90(param_1,0,2); - if((info1->action).unk4[0].actionUseIndex == 0x80) + if((info1->action).actionParameters[0].actionUseIndex == 0x80) bVar3 = TRUE; else bVar3 = FALSE; @@ -285,13 +285,13 @@ void HandlePlaceItemAction(Entity *entity) Item *item = sub_8044D90(entity,0,4); sub_8045BF8(gFormatBuffer_Items[0],item); - if (info->action.unk4[0].actionUseIndex == 0x80) { + if (info->action.actionParameters[0].actionUseIndex == 0x80) { LogMessageByIdWithPopupCheckUser(entity,*gUnknown_80F8DE0); } - else if (info->action.unk4[0].actionUseIndex < 0x15 && (item->flags & (ITEM_FLAG_STICKY | ITEM_FLAG_SET)) == (ITEM_FLAG_STICKY | ITEM_FLAG_SET)) { + else if (info->action.actionParameters[0].actionUseIndex < 0x15 && (item->flags & (ITEM_FLAG_STICKY | ITEM_FLAG_SET)) == (ITEM_FLAG_STICKY | ITEM_FLAG_SET)) { LogMessageByIdWithPopupCheckUser(entity,*gUnknown_80F8BE0); } - else if (info->action.unk4[0].actionUseIndex == 0x81 && (item->flags & ITEM_FLAG_STICKY)) { + else if (info->action.actionParameters[0].actionUseIndex == 0x81 && (item->flags & ITEM_FLAG_STICKY)) { LogMessageByIdWithPopupCheckUser(entity,*gUnknown_80F8BE0); } else { diff --git a/src/code_8069E0C.c b/src/code_8069E0C.c index 335656fb1..adf69719e 100644 --- a/src/code_8069E0C.c +++ b/src/code_8069E0C.c @@ -121,7 +121,7 @@ void TriggerWeatherAbilities(void) for(index = 0; index < DUNGEON_MAX_POKEMON; index++) { entity = gDungeon->activePokemon[index]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { if (AbilityIsActive(entity, ABILITY_DRIZZLE)) { gDungeon->weather.naturalWeather[WEATHER_RAIN] = 1; } @@ -158,9 +158,9 @@ void sub_8069F9C(Entity *pokemon, Entity *target, Move *move) EntityInfo *pokemonInfo; u8 abilities[4]; - if (!EntityExists(pokemon)) + if (!EntityIsValid(pokemon)) return; - if (!EntityExists(target)) + if (!EntityIsValid(target)) return; if (pokemon == target) return; @@ -237,7 +237,7 @@ void sub_806A120(Entity * pokemon, Entity * target, Move* move) const char *typeString; EntityInfo *entityInfo; - if ((((EntityExists(pokemon)) && (EntityExists(target))) && (pokemon != target)) + if ((((EntityIsValid(pokemon)) && (EntityIsValid(target))) && (pokemon != target)) && (entityInfo = GetEntInfo(target), entityInfo->reflectClassStatus.status == STATUS_CONVERSION2)) { moveType = GetMoveTypeForMonster(pokemon, move); uVar2_u32 = sub_8092364(moveType); @@ -255,7 +255,7 @@ void sub_806A120(Entity * pokemon, Entity * target, Move* move) void sub_806A1B0(Entity *pokemon) { - if ((EntityExists(pokemon)) && (AbilityIsActive(pokemon, ABILITY_TRUANT))) { + if ((EntityIsValid(pokemon)) && (AbilityIsActive(pokemon, ABILITY_TRUANT))) { PausedStatusTarget(pokemon,pokemon,0,1,0); } } @@ -266,7 +266,7 @@ void sub_806A1E8(Entity *pokemon) EntityInfo *entityInfo; bVar3 = FALSE; - if (EntityExists(pokemon)) { + if (EntityIsValid(pokemon)) { if (GetEntityType(pokemon) == ENTITY_MONSTER) { entityInfo = GetEntInfo(pokemon); bVar3 = (!entityInfo->isNotTeamMember); @@ -286,7 +286,7 @@ void sub_806A240(Entity *pokemon, Entity *target) EntityInfo *entityInfo; isNotTeamMember = FALSE; - if (EntityExists(pokemon)){ + if (EntityIsValid(pokemon)){ if (GetEntityType(pokemon) == ENTITY_MONSTER) { entityInfo = GetEntInfo(pokemon); isNotTeamMember = (!entityInfo->isNotTeamMember); @@ -307,7 +307,7 @@ void sub_806A240(Entity *pokemon, Entity *target) void sub_806A2BC(Entity *pokemon, u8 param_2) { - if ((EntityExists(pokemon)) && (GetEntityType(pokemon) == ENTITY_MONSTER) && (gDungeon->unk181e8.cameraTarget != pokemon)) { + if ((EntityIsValid(pokemon)) && (GetEntityType(pokemon) == ENTITY_MONSTER) && (gDungeon->unk181e8.cameraTarget != pokemon)) { if (param_2 != '\0') { sub_804178C(1); while (gDungeon->unk12 < 0x3c) { @@ -330,7 +330,7 @@ void sub_806A338(void) for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { Entity *entity = gDungeon->activePokemon[i]; - if (EntityExists(entity) && (GetEntInfo(entity)->curseClassStatus.status == STATUS_SNATCH)) { + if (EntityIsValid(entity) && (GetEntInfo(entity)->curseClassStatus.status == STATUS_SNATCH)) { gDungeon->snatchPokemon = entity; gDungeon->unk17B3C = GetEntInfo(entity)->unk98; return; @@ -537,7 +537,7 @@ void sub_806A5B8(Entity *entity) { s32 terrainType; - if (!EntityExists(entity)) + if (!EntityIsValid(entity)) return; terrainType = GetTerrainType(GetTileAtEntitySafe(entity)); @@ -628,7 +628,7 @@ UNUSED static void DisplayMsgIfTeamMonsLearnedNewIqSkill(void) for (i = 0; i < MAX_TEAM_MEMBERS; i++) { Entity *entity = gDungeon->teamPokemon[i]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { EntityInfo *info = GetEntInfo(entity); if (info->IQ > 1) { DisplayMsgIfNewIqSkillLearned(info, info->IQ - 1); @@ -699,7 +699,7 @@ void sub_806A914(bool8 a0, bool8 a1, bool8 showRunAwayEffect) for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { Entity *entity = gDungeon->activePokemon[i]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { EntityInfo *info = GetEntInfo(entity); if (!a1 || info->monsterBehavior == 1) { sub_806A898(entity, a0, showRunAwayEffect); @@ -714,7 +714,7 @@ void sub_806A974(void) for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { Entity *entity = gDungeon->activePokemon[i]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { EntityInfo *info = GetEntInfo(entity); sub_806CE68(entity, info->action.direction); } @@ -723,7 +723,7 @@ void sub_806A974(void) void sub_806A9B4(Entity *entity, s32 moveIndex) { - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { EntityInfo *info = GetEntInfo(entity); s32 ret = sub_80935B8(info->moves.moves, moveIndex); @@ -764,7 +764,7 @@ void sub_806AA70(void) for (i = 0; i < MAX_TEAM_MEMBERS; i++) { Entity *entity = gDungeon->teamPokemon[i]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { EntityInfo *info = GetEntInfo(entity); s32 teamIndex = info->teamIndex; @@ -805,11 +805,11 @@ void sub_806AB2C(void) for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { Entity *entity1 = gDungeon->activePokemon[i]; - if (EntityExists(entity1)) { + if (EntityIsValid(entity1)) { EntityInfo *info1 = GetEntInfo(entity1); for (j = 0; j < DUNGEON_MAX_POKEMON; j++) { Entity *entity2 = gDungeon->activePokemon[j]; - if (EntityExists(entity2) && entity1 != entity2 && info1->aiTarget.aiTargetSpawnGenID == entity2->spawnGenID) { + if (EntityIsValid(entity2) && entity1 != entity2 && info1->aiTarget.aiTargetSpawnGenID == entity2->spawnGenID) { info1->aiTarget.aiTarget = entity2; } } @@ -1192,7 +1192,7 @@ void sub_806B404(void) gLeaderPointer = NULL; leader = GetLeader(); - if (EntityExists(leader)) { + if (EntityIsValid(leader)) { pos.x = leader->pos.x; pos.y = leader->pos.y; } @@ -1268,7 +1268,7 @@ void sub_806B678(void) for (i = 0; i < MAX_TEAM_MEMBERS; i++) { Entity *mon = gDungeon->teamPokemon[i]; - if (EntityExists(mon)) { + if (EntityIsValid(mon)) { EntityInfo *monInfo = GetEntInfo(mon); if (monInfo->isTeamLeader) { sub_803F4A0(mon); @@ -1879,7 +1879,7 @@ void sub_806C1D8(void) for (i = 0; i < MAX_TEAM_MEMBERS; i++) { Entity *entity = gDungeon->teamPokemon[i]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { EntityInfo *entInfo = GetEntInfo(entity); s32 teamIndex = entInfo->teamIndex; if (teamIndex >= 0) { diff --git a/src/code_806CD90.c b/src/code_806CD90.c index 16aefe58a..b992b90b4 100644 --- a/src/code_806CD90.c +++ b/src/code_806CD90.c @@ -51,7 +51,7 @@ void sub_806CC10(void) for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { entity = gDungeon->activePokemon[i]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { entityInfo = GetEntInfo(entity); if (entityInfo->unk166 != 0) { @@ -71,7 +71,7 @@ void sub_806CC70(void) for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { entity = gDungeon->activePokemon[i]; - if (EntityExists(entity)) + if (EntityIsValid(entity)) sub_806CCB4(entity, sub_806CEBC(entity)); } } @@ -118,7 +118,7 @@ void sub_806CD90(void) for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { entity = gDungeon->activePokemon[i]; - if (EntityExists(entity)) + if (EntityIsValid(entity)) sub_806CCB4(entity, sub_806CEBC(entity)); } } @@ -204,7 +204,7 @@ void sub_806CF18(Entity *entity) s32 i; EntityInfo *entityInfo; - if (!EntityExists(entity)) + if (!EntityIsValid(entity)) return; entityInfo = GetEntInfo(entity); @@ -229,7 +229,7 @@ void sub_806CF60(void) for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { entity = gDungeon->activePokemon[i]; - if (EntityExists(entity)) + if (EntityIsValid(entity)) sub_806CF98(entity); } } @@ -325,7 +325,7 @@ void HandleDealingDamage(Entity *attacker, Entity *target, struct DamageStruct * return; if (dmgStruct->tookNoDamage) return; - if (!EntityExists(attacker) || !EntityExists(target)) + if (!EntityIsValid(attacker) || !EntityIsValid(target)) return; if (GetEntityType(attacker) != ENTITY_MONSTER || GetEntityType(target) != ENTITY_MONSTER) return; @@ -347,7 +347,7 @@ void HandleDealingDamage(Entity *attacker, Entity *target, struct DamageStruct * RaiseAttackStageTarget(attacker, target, gUnknown_8106A4C, 1); } - if (!EntityExists(attacker) || !EntityExists(target)) + if (!EntityIsValid(attacker) || !EntityIsValid(target)) return; if (r9 @@ -385,7 +385,7 @@ void HandleDealingDamage(Entity *attacker, Entity *target, struct DamageStruct * HandleDealingDamageInternal(target, attacker, &sp, FALSE, giveExp, r10, argC); } } - if (!EntityExists(attacker) || !EntityExists(target)) + if (!EntityIsValid(attacker) || !EntityIsValid(target)) return; // Check trapping / contact abilities @@ -455,7 +455,7 @@ void HandleDealingDamage(Entity *attacker, Entity *target, struct DamageStruct * attackerInfo->abilityEffectFlags |= ABILITY_FLAG_STENCH; } } - if (!EntityExists(attacker) || !EntityExists(target)) + if (!EntityIsValid(attacker) || !EntityIsValid(target)) return; // Destiny Bond @@ -700,7 +700,7 @@ static bool8 HandleDealingDamageInternal(Entity *attacker, Entity *target, struc } r8 = 1; - if (EntityExists(attacker) && GetEntityType(attacker) == ENTITY_MONSTER && attacker != target) + if (EntityIsValid(attacker) && GetEntityType(attacker) == ENTITY_MONSTER && attacker != target) r8 = 0; targetData->unk14C = 0; @@ -797,7 +797,7 @@ static bool8 HandleDealingDamageInternal(Entity *attacker, Entity *target, struc for (i = 0; i < MAX_TEAM_MEMBERS; i++) { teamMember = gDungeon->teamPokemon[i]; - if (EntityExists(teamMember) + if (EntityIsValid(teamMember) && teamMember != target && CanSeeTarget(target, teamMember) && abs(teamMember->pos.x - target->pos.x) <= 1 && abs(teamMember->pos.y - target->pos.y) <= 1) @@ -937,7 +937,7 @@ static bool8 HandleDealingDamageInternal(Entity *attacker, Entity *target, struc sub_8071D4C(attacker, attacker, exp); for (i = 0; i < MAX_TEAM_MEMBERS; i++) { Entity *teamMember = gDungeon->teamPokemon[i]; - if (EntityExists(teamMember) && teamMember != attacker) { + if (EntityIsValid(teamMember) && teamMember != attacker) { sub_8071D4C(attacker, teamMember, exp); } } @@ -953,7 +953,7 @@ static bool8 HandleDealingDamageInternal(Entity *attacker, Entity *target, struc } } - if (EntityExists(attacker) && GetEntityType(attacker) == ENTITY_MONSTER && !GetEntInfo(attacker)->isTeamLeader) + if (EntityIsValid(attacker) && GetEntityType(attacker) == ENTITY_MONSTER && !GetEntInfo(attacker)->isTeamLeader) r10 = FALSE; if (r10) { diff --git a/src/code_806FDF4.c b/src/code_806FDF4.c index 7b11013d4..cfe23f002 100644 --- a/src/code_806FDF4.c +++ b/src/code_806FDF4.c @@ -276,7 +276,7 @@ bool8 sub_806F660(Entity *pokemon, Entity *target) } for (i = 0; i < 4; i++) { - if (!EntityExists(gDungeon->teamPokemon[i])) + if (!EntityIsValid(gDungeon->teamPokemon[i])) break; } if (i == 4) { @@ -305,7 +305,7 @@ void sub_806F910(void) for(index = 0, sVar6 = 0x40; index < MAX_TEAM_MEMBERS; index++) { entity = gDungeon->teamPokemon[index]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { size = GetBodySize(GetEntInfo(entity)->apparentID); entity->axObj.unk40_maybeAnimTimer = sVar6; GetEntInfo(entity)->unk167 = index; @@ -507,7 +507,7 @@ bool8 sub_806FD18(Entity *param_1) return FALSE; for (i = 0; i < MAX_TEAM_MEMBERS; i++) { - if(!EntityExists(gDungeon->teamPokemon[i])) + if(!EntityIsValid(gDungeon->teamPokemon[i])) break; } if (i == MAX_TEAM_MEMBERS) diff --git a/src/code_80718D8.c b/src/code_80718D8.c index 4a6076a0f..3c04e2937 100644 --- a/src/code_80718D8.c +++ b/src/code_80718D8.c @@ -86,7 +86,7 @@ void sub_8071B48(void) if (dungeon->unk644.unk1E > 900) { entity2 = dungeon->unk17B34; - if ((EntityExists(entity2)) && (entity2->spawnGenID == dungeon->unk17B40)) { + if ((EntityIsValid(entity2)) && (entity2->spawnGenID == dungeon->unk17B40)) { SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],entity2,0); entityPtr = entity2; } @@ -99,7 +99,7 @@ void sub_8071B48(void) for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++) { entity = dungeon->wildPokemon[index]; - if ((EntityExists(entity)) && + if ((EntityIsValid(entity)) && (tile = GetTile((entity->pos).x, (entity->pos).y), (tile->terrainType & 0x100) == 0)) { counter++; @@ -187,7 +187,7 @@ void sub_8071DA4(Entity *entity) entityPtr = entity; if ((gDungeon->unkD != 0) && (gDungeon->unkD = 0, gDungeon->unk10 == 0)) { - if (!EntityExists(entityPtr)) { + if (!EntityIsValid(entityPtr)) { sub_80457DC(&EStack_f4); entityPtr = &EStack_f4; } @@ -202,7 +202,7 @@ void sub_8071DA4(Entity *entity) if (target == NULL) continue; - if (!EntityExists(target)) + if (!EntityIsValid(target)) continue; info = GetEntInfo(target); @@ -292,7 +292,7 @@ void sub_8072008(Entity *pokemon, Entity *target, s32 level, u8 param_4, u8 para u32 atk[2]; u32 def[2]; - if (EntityExists(target)) { + if (EntityIsValid(target)) { flag = 0; info = GetEntInfo(target); if (info->isTeamLeader) { @@ -431,7 +431,7 @@ void LevelDownTarget(Entity *pokemon, Entity *target, u32 level) s32 newLevel; LevelData leveldata; - if(EntityExists(target)) + if(EntityIsValid(target)) { flag = FALSE; info = GetEntInfo(target); @@ -468,7 +468,7 @@ bool8 sub_80723D0(Entity *pokemon, Entity *target, u8 param_3, u8 param_4) s32 level; s32 exp; - if(!EntityExists(target)) return FALSE; + if(!EntityIsValid(target)) return FALSE; info = GetEntInfo(target); id = info->id; exp = info->exp; @@ -564,7 +564,7 @@ bool8 sub_80725A4(Entity *pokemon, Entity *target) s32 oldLevel; - if(!EntityExists(target)) return FALSE; + if(!EntityIsValid(target)) return FALSE; info = GetEntInfo(target); id = info->id; exp = info->exp; diff --git a/src/code_8073CF0.c b/src/code_8073CF0.c index 1beeef896..c425bc7a1 100644 --- a/src/code_8073CF0.c +++ b/src/code_8073CF0.c @@ -262,7 +262,7 @@ void sub_8074094(Entity *entity) if (entity == NULL) return; - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; entityInfo = GetEntInfo(entity); @@ -276,7 +276,7 @@ void sub_8074094(Entity *entity) entityInfo->turnsSinceWarpScarfActivation = 0; sub_80444F4(entity); UseAttack(NULL); - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; WarpTarget(entity, entity, 0, NULL); if (entityInfo->isTeamLeader) { @@ -337,7 +337,7 @@ void sub_8074094(Entity *entity) sub_805E804(); sub_80444F4(entity); UseAttack(NULL); - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; if (gDungeon->unk644.unk35 < 10) gDungeon->unk644.unk35++; @@ -366,7 +366,7 @@ void sub_8074094(Entity *entity) } } - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; if (gDungeon->weather.weatherDamageCounter == 0) { if (GetApparentWeather(entity) == WEATHER_HAIL) { @@ -379,7 +379,7 @@ void sub_8074094(Entity *entity) DealDamageToEntity(entity, gHailSandstormDmgValue, 0x12, 0x220); } } - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; } @@ -387,7 +387,7 @@ void sub_8074094(Entity *entity) rand = DungeonRandInt(100); if (AbilityIsActive(entity, ABILITY_SHED_SKIN) && rand < gShedSkinActivateChance && HasNegativeStatus(entity)) { UseAttack(NULL); - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; sub_8079F20(entity, entity, 1, 0); } @@ -402,7 +402,7 @@ void sub_8074094(Entity *entity) // Statuses if (entityInfo->sleepClassStatus.status == STATUS_YAWNING) { UseAttack(NULL); - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; sub_80420B8(entity); } @@ -410,26 +410,26 @@ void sub_8074094(Entity *entity) if (entityInfo->burnClassStatus.status == STATUS_BURN) { if (entityInfo->burnClassStatus.damageCountdown == 0 || --entityInfo->burnClassStatus.damageCountdown == 0) { UseAttack(NULL); - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; entityInfo->burnClassStatus.damageCountdown = gBurnDmgCountdown; TrySendImmobilizeSleepEndMsg(entity, entity); DealDamageToEntity(entity, gBurnDmgValue, 1, 0x208); } - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; } if (entityInfo->burnClassStatus.status == STATUS_POISONED) { if (entityInfo->burnClassStatus.damageCountdown == 0 || --entityInfo->burnClassStatus.damageCountdown == 0) { UseAttack(NULL); - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; entityInfo->burnClassStatus.damageCountdown = gPoisonDmgCountdown; TrySendImmobilizeSleepEndMsg(entity, entity); DealDamageToEntity(entity, gPoisonDmgValue, 3, 0x20A); } - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; } else if (entityInfo->burnClassStatus.status == STATUS_BADLY_POISONED) { @@ -442,45 +442,45 @@ void sub_8074094(Entity *entity) turns = BAD_POISON_DMG_TURN_VALUES_COUNT - 1; UseAttack(NULL); - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; TrySendImmobilizeSleepEndMsg(entity, entity); DealDamageToEntity(entity, gBadPoisonDmgValuesByTurn[turns], 3, 0x20A); } - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; } if (entityInfo->frozenClassStatus.status == STATUS_CONSTRICTION) { if (entityInfo->frozenClassStatus.damageCountdown == 0 || --entityInfo->frozenClassStatus.damageCountdown == 0) { UseAttack(NULL); - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; entityInfo->frozenClassStatus.damageCountdown = gConstrictionDmgCountdown; TrySendImmobilizeSleepEndMsg(entity, entity); sub_8041C4C(entity, entityInfo->frozenClassStatus.unk4); DealDamageToEntity(entity, gConstrictionDmgValue, 2, 0x209); } - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; } else if (entityInfo->frozenClassStatus.status == STATUS_WRAPPED) { if (entityInfo->frozenClassStatus.damageCountdown == 0 || --entityInfo->frozenClassStatus.damageCountdown == 0) { UseAttack(NULL); - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; entityInfo->frozenClassStatus.damageCountdown = gWrapDmgCountdown; TrySendImmobilizeSleepEndMsg(entity, entity); DealDamageToEntity(entity, gWrapDmgValue, 5, 0x20B); } - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; } else if (entityInfo->frozenClassStatus.status == STATUS_INGRAIN) { if (entityInfo->frozenClassStatus.damageCountdown == 0 || --entityInfo->frozenClassStatus.damageCountdown == 0) { UseAttack(NULL); - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; entityInfo->frozenClassStatus.damageCountdown = gIngrainHealCountdown; HealTargetHP(entity, entity, gIngrainHealValue, 0, TRUE); @@ -494,13 +494,13 @@ void sub_8074094(Entity *entity) dmg = 1; entityInfo->curseClassStatus.damageCountdown = gCurseDmgCountdown; UseAttack(NULL); - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; TrySendImmobilizeSleepEndMsg(entity, entity); DealDamageToEntity(entity, dmg, 7, 0x20C); } - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; } @@ -522,7 +522,7 @@ void sub_8074094(Entity *entity) bool8 dmgUser = AbilityIsActive(entity, ABILITY_LIQUID_OOZE); sub_80444F4(entity); UseAttack(NULL); - if (!EntityExists(entity) || !EntityExists(target) || sub_8044B28()) + if (!EntityIsValid(entity) || !EntityIsValid(target) || sub_8044B28()) return; if (entityInfo->frozenClassStatus.status != STATUS_FROZEN) { @@ -539,7 +539,7 @@ void sub_8074094(Entity *entity) } } } - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; } @@ -547,7 +547,7 @@ void sub_8074094(Entity *entity) sub_80838EC(&entityInfo->perishSongTurns); if (entityInfo->perishSongTurns == 0) { UseAttack(NULL); - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[1], entity, 0); LogMessageByIdWithPopupCheckUser(entity, gUnknown_80FEB30); @@ -558,7 +558,7 @@ void sub_8074094(Entity *entity) else { DealDamageToEntity(entity, 0x270F, 0xB, 0x20E); } - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; } } @@ -574,14 +574,14 @@ void sub_8074094(Entity *entity) InitPokemonMove(&bideMove, MOVE_BIDE_2); bideMove.moveFlags |= MOVE_FLAG_LAST_USED; TryUseChosenMove(entity, 0, 0, 0, 0, &bideMove); - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; entityInfo->unkA0 = 0; } } } - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; if (entityInfo->bideClassStatus.status == STATUS_ENRAGED) { @@ -594,7 +594,7 @@ void sub_8074094(Entity *entity) } } - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; } @@ -606,7 +606,7 @@ void TickStatusHeal(Entity *entity) if (entity == NULL) return; - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; sub_805229C(); @@ -649,7 +649,7 @@ void TickStatusHeal(Entity *entity) EndSleepClassStatus(entity, entity, TRUE, TRUE); } } - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; if (entityInfo->burnClassStatus.status != 0) { @@ -658,7 +658,7 @@ void TickStatusHeal(Entity *entity) EndBurnClassStatus(entity, entity); } } - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; if (entityInfo->frozenClassStatus.status != 0) { @@ -667,7 +667,7 @@ void TickStatusHeal(Entity *entity) EndFrozenClassStatus(entity, entity); } } - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; if (entityInfo->cringeClassStatus.status != 0) { @@ -676,7 +676,7 @@ void TickStatusHeal(Entity *entity) EndCringeClassStatus(entity, entity); } } - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; if (entityInfo->reflectClassStatus.status != 0) { @@ -685,7 +685,7 @@ void TickStatusHeal(Entity *entity) EndReflectClassStatus(entity, entity); } } - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; if (entityInfo->curseClassStatus.status != 0) { @@ -694,7 +694,7 @@ void TickStatusHeal(Entity *entity) EndCurseClassStatus(entity, entity, 0); } } - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; if (entityInfo->leechSeedClassStatus.status != 0) { @@ -703,7 +703,7 @@ void TickStatusHeal(Entity *entity) EndLeechSeedClassStatus(entity, entity); } } - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; if (entityInfo->sureShotClassStatus.status != 0) { @@ -712,7 +712,7 @@ void TickStatusHeal(Entity *entity) SendMoveEndMessage(entity, entity); } } - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; if (entityInfo->invisibleClassStatus.status != 0) { @@ -721,7 +721,7 @@ void TickStatusHeal(Entity *entity) SendTransformEndMessage(entity, entity); } } - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; if (entityInfo->blinkerClassStatus.status != 0) { @@ -730,7 +730,7 @@ void TickStatusHeal(Entity *entity) SendEyesightEndMessage(entity, entity); } } - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; if (entityInfo->muzzled.muzzled != 0) { @@ -739,7 +739,7 @@ void TickStatusHeal(Entity *entity) SendMuzzledEndMessage(entity, entity); } } - if (!EntityExists(entity) || sub_8044B28()) + if (!EntityIsValid(entity) || sub_8044B28()) return; if (entityInfo->terrifiedTurns != 0) { @@ -872,7 +872,7 @@ bool8 UseAttack(Entity *a0) for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { Entity *mon = gDungeon->activePokemon[i]; - if (EntityExists(mon)) { + if (EntityIsValid(mon)) { EntityInfo *monInfo = GetEntInfo(mon); if (monInfo->numMoveTiles == 0) { if (monInfo->waiting) { @@ -914,7 +914,7 @@ bool8 UseAttack(Entity *a0) sub_803E46C(7); for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { Entity *mon = gDungeon->activePokemon[i]; - if (EntityExists(mon)) { + if (EntityIsValid(mon)) { EntityInfo *monInfo = GetEntInfo(mon); Unk_Entity_x184 *strPtr = &monInfo->unk184[monInfo->notMoving]; @@ -942,7 +942,7 @@ bool8 UseAttack(Entity *a0) for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { Entity *mon = gDungeon->activePokemon[i]; - if (EntityExists(mon)) { + if (EntityIsValid(mon)) { EntityInfo *monInfo = GetEntInfo(mon); monInfo->numMoveTiles = 0; nullsub_97(mon); @@ -959,7 +959,7 @@ bool8 UseAttack(Entity *a0) EntityInfo *monInfo; Entity *mon = gDungeon->activePokemon[loop]; - if (!EntityExists(mon)) + if (!EntityIsValid(mon)) continue; if (sub_8044B28()) break; @@ -983,14 +983,14 @@ bool8 UseAttack(Entity *a0) else { sub_8075708(mon); } - if (!EntityExists(mon)) + if (!EntityIsValid(mon)) continue; if (sub_8044B28()) break; sub_8043ED0(0); sub_8074094(mon); - if (!EntityExists(mon)) + if (!EntityIsValid(mon)) continue; if (sub_8044B28()) break; @@ -999,7 +999,7 @@ bool8 UseAttack(Entity *a0) sub_8046D20(); sub_8075900(mon, gDungeon->forceMonsterHouse); } - if (!EntityExists(mon)) + if (!EntityIsValid(mon)) continue; if (sub_8044B28()) break; diff --git a/src/code_8075708.c b/src/code_8075708.c index b89fdec07..c3371fb58 100644 --- a/src/code_8075708.c +++ b/src/code_8075708.c @@ -30,7 +30,7 @@ void sub_8075680(void) for(index = 0; index < DUNGEON_MAX_POKEMON; index++) { entity = gDungeon->activePokemon[index]; - if ((EntityExists(entity)) && (info = GetEntInfo(entity), !info->isTeamLeader)) { + if ((EntityIsValid(entity)) && (info = GetEntInfo(entity), !info->isTeamLeader)) { targetPos = &(info->targetPos); if (targetPos->x == 0 && targetPos->y == 0) @@ -62,7 +62,7 @@ void sub_8075708(Entity *entity) EntityInfo *info; info = GetEntInfo(entity); - if (!EntityExists(entity)) { + if (!EntityIsValid(entity)) { return; } tile = GetTileAtEntitySafe(entity); @@ -129,7 +129,7 @@ u32 sub_8075818(Entity *entity) u8 r1; entityInfo = GetEntInfo(entity); - if(EntityExists(entity)) + if(EntityIsValid(entity)) { tile = GetTileAtEntitySafe(entity); if(IQSkillIsEnabled(entity, IQ_SUPER_MOBILE)) diff --git a/src/code_8077274_1.c b/src/code_8077274_1.c index e57804143..24550b07c 100644 --- a/src/code_8077274_1.c +++ b/src/code_8077274_1.c @@ -194,7 +194,7 @@ void MuzzleTarget(Entity *pokemon, Entity *target) { EntityInfo *entityInfo; - if ((EntityExists(target)) && (!HasSafeguardStatus(pokemon, target, TRUE))) { + if ((EntityIsValid(target)) && (!HasSafeguardStatus(pokemon, target, TRUE))) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->muzzled.muzzled != TRUE) { @@ -222,7 +222,7 @@ void TransformStatusTarget(Entity * pokemon, Entity * target) OpenedFile *sprite; UnkDungeonGlobal_unk1CD98 auStack544[64]; - if (!EntityExists(target)) + if (!EntityIsValid(target)) return; entityInfo = GetEntInfo(target); @@ -273,7 +273,7 @@ void MobileStatusTarget(Entity * pokemon, Entity * target) EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); if (entityInfo->invisibleClassStatus.status == STATUS_TRANSFORMED) { @@ -306,7 +306,7 @@ void ExposeStatusTarget(Entity * pokemon, Entity * target, s16 param_3) flag = FALSE; flag2 = FALSE; - if ((EntityExists(target)) && (!HasSafeguardStatus(pokemon,target,TRUE))) { + if ((EntityIsValid(target)) && (!HasSafeguardStatus(pokemon,target,TRUE))) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->hitChanceStages[1] > 10) { @@ -343,7 +343,7 @@ void IdentityItemHolders(Entity *pokemon, Entity *target) { EntityInfo *entityInfo; - if ((EntityExists(target)) && (!HasSafeguardStatus(pokemon, target, TRUE))) { + if ((EntityIsValid(target)) && (!HasSafeguardStatus(pokemon, target, TRUE))) { entityInfo = GetEntInfo(target); if (!gDungeon->unk644.itemHoldersIdentified) { nullsub_89(target); @@ -362,7 +362,7 @@ void BlindTarget(Entity *pokemon, Entity *target) { EntityInfo *entityInfo; - if ((EntityExists(target)) && (!HasSafeguardStatus(pokemon, target, TRUE))) { + if ((EntityIsValid(target)) && (!HasSafeguardStatus(pokemon, target, TRUE))) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->blinkerClassStatus.status != STATUS_BLINKER) { @@ -387,7 +387,7 @@ void CrossEyeVisionTarget(Entity *pokemon, Entity *target) EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { if(!HasSafeguardStatus(pokemon, target, TRUE)) { entityInfo = GetEntInfo(target); @@ -415,7 +415,7 @@ void RestoreVisionTarget(Entity *pokemon, Entity *target) EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->blinkerClassStatus.status != STATUS_EYEDROPS) { @@ -446,7 +446,7 @@ void RestorePPTarget(Entity * pokemon,Entity * target, s32 param_3) EntityInfo *entityInfo; PPChanged = FALSE; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); for(index = 0; index < MAX_MON_MOVES; index++) @@ -484,7 +484,7 @@ void RaiseAtkStatTarget(Entity * pokemon, Entity *target, s32 increment) s32 newStat; EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); entityInfo = GetEntInfo(target); @@ -514,7 +514,7 @@ void RaiseSpAtkStatTarget(Entity * pokemon, Entity *target, s32 increment) s32 newStat; EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); entityInfo = GetEntInfo(target); @@ -544,7 +544,7 @@ void RaiseDefStatTarget(Entity * pokemon, Entity *target, s32 increment) s32 newStat; EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); entityInfo = GetEntInfo(target); @@ -574,7 +574,7 @@ void RaiseSpDefStatTarget(Entity * pokemon, Entity *target, s32 increment) s32 newStat; EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); entityInfo = GetEntInfo(target); @@ -641,7 +641,7 @@ void SetChargeStatusTarget(Entity *pokemon, Entity *target, u8 newStatus, Move * s32 iVar8; EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if ((entityInfo->bideClassStatus.status == newStatus) && (newStatus == STATUS_ENRAGED)) { @@ -701,7 +701,7 @@ void sub_8079764(Entity * pokemon) { EntityInfo *entityInfo; - if (EntityExists(pokemon)) { + if (EntityIsValid(pokemon)) { entityInfo = GetEntInfo(pokemon); if ((entityInfo->bideClassStatus.status != STATUS_BIDE) && (entityInfo->bideClassStatus.status != STATUS_ENRAGED)) { entityInfo->bideClassStatus.status = STATUS_NONE; @@ -716,7 +716,7 @@ void CounterStatusTarget(Entity * pokemon, Entity * target, u8 newStatus) { EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->reflectClassStatus.status == newStatus) { @@ -738,7 +738,7 @@ void SafeguardStatusTarget(Entity * pokemon, Entity * target) { EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->reflectClassStatus.status != STATUS_SAFEGUARD) { @@ -758,7 +758,7 @@ void MistStatusTarget(Entity * pokemon, Entity * target) { EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->reflectClassStatus.status != STATUS_MIST) { @@ -778,7 +778,7 @@ void WishStatusTarget(Entity * pokemon, Entity * target) { EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->reflectClassStatus.status != STATUS_WISH) { @@ -798,7 +798,7 @@ void MagicCoatStatusTarget(Entity * pokemon, Entity * target) { EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->reflectClassStatus.status != STATUS_MAGIC_COAT) { @@ -818,7 +818,7 @@ void LightScreenStatusTarget(Entity * pokemon, Entity * target) { EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->reflectClassStatus.status != STATUS_LIGHT_SCREEN) { @@ -838,7 +838,7 @@ void ReflectStatusTarget(Entity * pokemon, Entity * target) { EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->reflectClassStatus.status != STATUS_REFLECT) { @@ -858,7 +858,7 @@ void ProtectStatusTarget(Entity * pokemon, Entity * target) { EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { nullsub_63(target); entityInfo = GetEntInfo(target); if (entityInfo->reflectClassStatus.status != STATUS_PROTECT) { @@ -879,7 +879,7 @@ void MirrorCoatStatusTarget(Entity * pokemon, Entity * target) { EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->reflectClassStatus.status != STATUS_MIRROR_COAT) { @@ -899,7 +899,7 @@ void EndureStatusTarget(Entity * pokemon, Entity * target) { EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->reflectClassStatus.status != STATUS_ENDURING) { @@ -919,7 +919,7 @@ void MirrorMoveStatusTarget(Entity * pokemon, Entity * target) { EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->reflectClassStatus.status != STATUS_MIRROR_MOVE) { @@ -939,7 +939,7 @@ void Conversion2StatusTarget(Entity * pokemon, Entity * target) { EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); if(AbilityIsActive(target, ABILITY_FORECAST)) @@ -965,7 +965,7 @@ void VitalThrowStatusTarget(Entity * pokemon, Entity * target) { EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->reflectClassStatus.status != STATUS_VITAL_THROW) { @@ -988,7 +988,7 @@ void sub_8079E34(Entity * pokemon, Entity * target, bool8 param_3) s32 index; statChanged = FALSE; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); for(index = 0; index < 2; index++) @@ -1042,12 +1042,12 @@ void sub_8079F20(Entity * pokemon, Entity * target, u8 param_3, u8 param_4) bVar8 = FALSE; moveUnsealed = FALSE; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); if (HasNegativeStatus(target)) { bVar8 = TRUE; EndSleepClassStatus(pokemon,target,0,0); - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } EndBurnClassStatus(pokemon,target); @@ -1110,7 +1110,7 @@ void sub_807A0CC(Entity * pokemon, Entity * target) EntityInfo *entityInfo; s32 index; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); ResetMonEntityData(entityInfo,0); entityInfo->perishSongTurns = 0; @@ -1133,7 +1133,7 @@ void EndSleepClassStatus(Entity * pokemon, Entity * target, bool8 param_3, bool8 bool8 isAsleep; isAsleep = FALSE; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } entityInfo = GetEntInfo(target); @@ -1183,7 +1183,7 @@ void EndBurnClassStatus(Entity * pokemon, Entity * target) { EntityInfo *entityInfo; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } entityInfo = GetEntInfo(target); @@ -1214,7 +1214,7 @@ void EndFrozenClassStatus(Entity * pokemon, Entity *target) EntityInfo *entityInfo; isFrozen = FALSE; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } entityInfo = GetEntInfo(target); @@ -1254,7 +1254,7 @@ void EndCringeClassStatus(Entity * pokemon, Entity *target) { EntityInfo *entityInfo; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } entityInfo = GetEntInfo(target); @@ -1294,7 +1294,7 @@ void EndReflectClassStatus(Entity * pokemon, Entity *target) { EntityInfo *entityInfo; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } entityInfo = GetEntInfo(target); @@ -1353,7 +1353,7 @@ void EndCurseClassStatus(Entity * pokemon, Entity * target, u8 curseClassStatus) u32 uVar3; EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); switch(entityInfo->curseClassStatus.status) { @@ -1392,7 +1392,7 @@ void EndLeechSeedClassStatus(Entity * pokemon, Entity * target) { EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); switch(entityInfo->leechSeedClassStatus.status) @@ -1416,7 +1416,7 @@ void SendMoveEndMessage(Entity * pokemon, Entity * target) { EntityInfo * entityInfo; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } entityInfo = GetEntInfo(target); @@ -1449,7 +1449,7 @@ void SendTransformEndMessage(Entity * pokemon, Entity *target) u32 uVar3; isInvisible = FALSE; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } entityInfo = GetEntInfo(target); @@ -1484,7 +1484,7 @@ void SendEyesightEndMessage(Entity * pokemon,Entity * target) { EntityInfo *entityInfo; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } entityInfo = GetEntInfo(target); @@ -1516,7 +1516,7 @@ void SendMuzzledEndMessage(Entity * pokemon, Entity * target) { EntityInfo *entityInfo; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } entityInfo = GetEntInfo(target); @@ -1564,7 +1564,7 @@ void SendThawedMessage(Entity *pokemon, Entity *target) { EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); if (entityInfo->frozenClassStatus.status == STATUS_FROZEN) { entityInfo->frozenClassStatus.status = STATUS_NONE; @@ -1593,7 +1593,7 @@ void sub_807AA30(void) for(wildIndex = 0; wildIndex < DUNGEON_MAX_WILD_POKEMON; wildIndex++) { wildEntity = gDungeon->wildPokemon[wildIndex]; - if (EntityExists(wildEntity) && + if (EntityIsValid(wildEntity) && (entityInfo = GetEntInfo(wildEntity), entityInfo->sleepClassStatus.status == STATUS_SLEEP) && (entityInfo->sleepClassStatus.turns == 0x7F)) { adjacentCheck = FALSE; @@ -1603,7 +1603,7 @@ void sub_807AA30(void) for(teamIndex = 0; teamIndex < MAX_TEAM_MEMBERS; teamIndex++) { teamEntity = gDungeon->teamPokemon[teamIndex]; - if (EntityExists(teamEntity) && !HasHeldItem(teamEntity, ITEM_SNEAK_SCARF)) { + if (EntityIsValid(teamEntity) && !HasHeldItem(teamEntity, ITEM_SNEAK_SCARF)) { xDiff = teamEntity->pos.x - wildEntity->pos.x; if (xDiff < 0) { xDiff = -xDiff; @@ -1727,7 +1727,7 @@ void sub_807AB38(Entity *entity, bool8 forcedMonsterHouse) spawnStruct.pos.y = positions[rndId].y; if (sub_806AA0C(spawnStruct.species, 1)) { Entity *newMonster = sub_806B7F8(&spawnStruct, FALSE); - if (EntityExists(newMonster)) { + if (EntityIsValid(newMonster)) { newMonster->unk1C = IntToF248_2(200); for (j = 0; j < 100; j++) { newMonster->unk1C = s24_8_mul(newMonster->unk1C, IntToF248_2(0.665)); diff --git a/src/code_807CD9C.c b/src/code_807CD9C.c index 1ff30c326..8f4874380 100644 --- a/src/code_807CD9C.c +++ b/src/code_807CD9C.c @@ -166,14 +166,14 @@ void BlowAwayTarget(Entity *pokemon, Entity *target, u32 direction) if (sub_8044B28()) { return; } - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } sub_806A5B8(target); if (sub_80706A4(target,&target->pos)) { WarpTarget(target,target,0,0); } - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } sub_806CE68(target,8); @@ -432,7 +432,7 @@ void HandleTrawlOrbAction(Entity *user, Entity *target) for (i = 0; i < gDungeon->numItems; i++) { Entity *dungeonItem = gDungeon->items[i]; - if (EntityExists(dungeonItem)) { + if (EntityIsValid(dungeonItem)) { if (itemsCount >= 25) break; @@ -501,7 +501,7 @@ void HandleTrawlOrbAction(Entity *user, Entity *target) } for (i = 0; i < itemsCount; i++) { - if (EntityExists(&itemEntities[i])) { + if (EntityIsValid(&itemEntities[i])) { sub_80461C8(&itemEntities[i].pos, 1); sub_80402AC(itemEntities[i].pos.x, itemEntities[i].pos.y); itemVelocity[i].x = (((targetTilePos[i].x * 24 + 4) * 256) - itemEntities[i].pixelPos.x) / 60; @@ -516,7 +516,7 @@ void HandleTrawlOrbAction(Entity *user, Entity *target) unkAngle = 0; for (animFrame = 0; animFrame < 60; animFrame++) { for (i = 0; i < itemsCount; i++) { - if (EntityExists(&itemEntities[i])) { + if (EntityIsValid(&itemEntities[i])) { IncreaseEntityPixelPos(&itemEntities[i], itemVelocity[i].x, itemVelocity[i].y); itemEntities[i].unk1C.raw = sin_4096(unkAngle) * 0xC; sub_80462AC(&itemEntities[i], hallucinating, 0, var, 0); @@ -593,7 +593,7 @@ void HandlePounceOrbAction(Entity *pokemon, Entity *target, u8 r2) { sub_806A5B8(target); if(sub_80706A4(target, &target->pos)) WarpTarget(target, target, 0, 0); - if(EntityExists(target)) + if(EntityIsValid(target)) { sub_806CE68(target, 8); if(info->isTeamLeader) @@ -749,7 +749,7 @@ void HandleOneRoomOrb(Entity *pokemon, Entity *target) { for(index = 0; index < DUNGEON_MAX_POKEMON; index++) { entity = gDungeon->activePokemon[index]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { entity->room = GetTile(entity->pos.x,entity->pos.y)->room; } } @@ -765,9 +765,9 @@ void HandleOneRoomOrb(Entity *pokemon, Entity *target) { for(index = 0; index < DUNGEON_MAX_POKEMON; index++) { entity = gDungeon->activePokemon[index]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { sub_806A5B8(entity); - if ((EntityExists(entity)) && (sub_80706A4(entity,&entity->pos))) { + if ((EntityIsValid(entity)) && (sub_80706A4(entity,&entity->pos))) { WarpTarget(entity,entity,0,0); } } @@ -795,7 +795,7 @@ void HandleExplosion(Entity *pokemon,Entity *target,DungeonPos *param_3,s32 para uStack_2c = param_6; for (index = 0; index < DUNGEON_MAX_POKEMON; index++) { entity1 = gDungeon->activePokemon[index]; - if ((EntityExists(entity1)) && (AbilityIsActive(entity1, ABILITY_DAMP))) break; + if ((EntityIsValid(entity1)) && (AbilityIsActive(entity1, ABILITY_DAMP))) break; } if (index != DUNGEON_MAX_POKEMON) { sub_804218C(pokemon,target); diff --git a/src/code_807E1A0.c b/src/code_807E1A0.c index 652d55393..73b77fcae 100644 --- a/src/code_807E1A0.c +++ b/src/code_807E1A0.c @@ -42,7 +42,7 @@ void sub_807E1A0(Entity *pokemon,Entity *target,u8 moveType,s16 param_4,s32 para param_4_s32 = param_4; - if (EntityExists(target)) { + if (EntityIsValid(target)) { targetInfo = GetEntInfo(target); InitPokemonMove(&move, MOVE_REGULAR_ATTACK); if (!sub_80571F0(target,&move)) { @@ -95,7 +95,7 @@ void HandleSwitcherOrb(Entity *pokemon,Entity *target) sub_804535C(pokemon,NULL); sub_804535C(target,NULL); - if (EntityExists(pokemon)) { + if (EntityIsValid(pokemon)) { if (GetEntInfo(pokemon)->isTeamLeader) { sub_804AC20(&pokemon->pos); sub_807EC28(FALSE); @@ -104,7 +104,7 @@ void HandleSwitcherOrb(Entity *pokemon,Entity *target) sub_8075900(pokemon,gDungeon->forceMonsterHouse); } - if (EntityExists(target)) { + if (EntityIsValid(target)) { if (GetEntInfo(target)->isTeamLeader) { sub_804AC20(&target->pos); sub_807EC28(FALSE); @@ -121,7 +121,7 @@ void sub_807E378(void) Entity *leader; leader = GetLeader(); - if (EntityExists(leader)) { + if (EntityIsValid(leader)) { uVar2 = gDungeon->unk644.windTurns; if ((gDungeon->unk644.windTurns < 1) || diff --git a/src/code_807E5AC.c b/src/code_807E5AC.c index 05bf64e5a..dca37458b 100644 --- a/src/code_807E5AC.c +++ b/src/code_807E5AC.c @@ -155,7 +155,7 @@ void sub_807E7FC(bool8 r0) for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { Entity *pokemon = gDungeon->activePokemon[i]; - if (EntityExists(pokemon)) { + if (EntityIsValid(pokemon)) { sub_807E8F0(pokemon); } } @@ -181,7 +181,7 @@ void sub_807E8F0(Entity *pokemon) u8 oldTypes[2]; bool8 flag = FALSE; - if (EntityExists(pokemon)) { + if (EntityIsValid(pokemon)) { EntityInfo *info = GetEntInfo(pokemon); s32 previousApparentId = info->apparentID; oldTypes[0] = info->types[0]; @@ -329,7 +329,7 @@ void sub_807EC28(bool8 arg0) for (i = 0; i < DUNGEON_MAX_WILD_POKEMON; i++) { Entity *wildMon = gDungeon->wildPokemon[i]; - if (EntityExists(wildMon)) { + if (EntityIsValid(wildMon)) { EntityInfo *wildMonInfo = GetEntInfo(wildMon); if (wildMonInfo->shopkeeper == SHOPKEEPER_MODE_SHOPKEEPER && sub_8070BC0(wildMon) && GetEntityRoom(leader) == GetEntityRoom(wildMon)) { sameRoom = TRUE; @@ -363,7 +363,7 @@ void sub_807EC28(bool8 arg0) var_28 = TRUE; for (i = 0; i < DUNGEON_MAX_WILD_POKEMON; i++) { Entity *wildMon = gDungeon->wildPokemon[i]; - if (EntityExists(wildMon) + if (EntityIsValid(wildMon) && GetEntInfo(wildMon)->shopkeeper == SHOPKEEPER_MODE_SHOPKEEPER && sub_8070BC0(wildMon) && GetEntityRoom(leader) == GetEntityRoom(wildMon)) @@ -554,7 +554,7 @@ s32 sub_807F19C(bool8 arg0) for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { Entity *mon = gDungeon->activePokemon[i]; - if (EntityExists(mon)) { + if (EntityIsValid(mon)) { EntityInfo *monInfo = GetEntInfo(mon); Item *item = &monInfo->heldItem; if (ItemExists(item) && CanSellItem(item->id)) { @@ -595,7 +595,7 @@ void sub_807F33C(void) for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { Entity *entity = gDungeon->activePokemon[i]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { Item *item; EntityInfo *info = GetEntInfo(entity); @@ -640,7 +640,7 @@ void sub_807F43C(Entity *target, Entity *attacker) s32 positionsCounter = 0; for (monId = 0; monId < DUNGEON_MAX_POKEMON; monId++) { Entity *mon = gDungeon->activePokemon[monId]; - if (EntityExists(mon) && target != mon && attacker != mon && CanSeeTarget(target, mon)) { + if (EntityIsValid(mon) && target != mon && attacker != mon && CanSeeTarget(target, mon)) { if (var_3C == 0) { if (GetTreatmentBetweenMonsters(target, mon, FALSE, TRUE) != 1) continue; @@ -758,7 +758,7 @@ NAKED void sub_807F43C(Entity *target, Entity *attacker) " adds r0, r1\n" " ldr r4, [r0]\n" " adds r0, r4, 0\n" -" bl EntityExists\n" +" bl EntityIsValid\n" " lsls r0, 24\n" " adds r3, r7, 0x1\n" " str r3, [sp, 0x104]\n" @@ -1199,7 +1199,7 @@ NAKED void sub_807F43C(Entity *target, Entity *attacker) " bl GetTile\n" " ldr r6, [r0, 0x10]\n" " adds r0, r6, 0\n" -" bl EntityExists\n" +" bl EntityIsValid\n" " lsls r0, 24\n" " cmp r0, 0\n" " bne _0807F876\n" @@ -1319,7 +1319,7 @@ NAKED void sub_807F43C(Entity *target, Entity *attacker) " bl sub_806F370\n" "_0807F93C:\n" " adds r0, r6, 0\n" -" bl EntityExists\n" +" bl EntityIsValid\n" " lsls r0, 24\n" " cmp r0, 0\n" " beq _0807F954\n" @@ -1345,7 +1345,7 @@ NAKED void sub_807F43C(Entity *target, Entity *attacker) " movs r3, 0\n" " bl sub_806F370\n" " mov r0, r8\n" -" bl EntityExists\n" +" bl EntityIsValid\n" " lsls r0, 24\n" " cmp r0, 0\n" " beq _0807F98E\n" @@ -1379,7 +1379,7 @@ NAKED void sub_807F43C(Entity *target, Entity *attacker) void sub_807F9BC(Entity *entity) { - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { EntityInfo *entInfo = GetEntInfo(entity); if (entInfo->isTeamLeader) { gDungeon->unk1 = 0; diff --git a/src/code_808417C.c b/src/code_808417C.c index 776c0abab..20c78b8cd 100644 --- a/src/code_808417C.c +++ b/src/code_808417C.c @@ -11,7 +11,7 @@ s32 CalculateStatusTurns(Entity *target, s16 *turnRange, bool8 factorCurerSkills s32 numTurns; numTurns = DungeonRandRange(turnRange[0],turnRange[1]); - if (EntityExists(target) && (GetEntityType(target) == ENTITY_MONSTER) && (factorCurerSkills)) { + if (EntityIsValid(target) && (GetEntityType(target) == ENTITY_MONSTER) && (factorCurerSkills)) { if (IQSkillIsEnabled(target, IQ_SELF_CURER) && (numTurns != 0x7f)) { numTurns /= 2; } diff --git a/src/code_8085E98.c b/src/code_8085E98.c index 08d309c63..ee346b39f 100644 --- a/src/code_8085E98.c +++ b/src/code_8085E98.c @@ -116,7 +116,7 @@ bool8 sub_80860A8(u8 id) for(index = 0; index < MAX_TEAM_MEMBERS; index++) { entity = gDungeon->teamPokemon[index]; - if (((EntityExists(entity)) && (info = GetEntInfo(entity), ((info->heldItem).flags & 1))) && ((info->heldItem).id == id)) return TRUE; + if (((EntityIsValid(entity)) && (info = GetEntInfo(entity), ((info->heldItem).flags & 1))) && ((info->heldItem).id == id)) return TRUE; } return FALSE; } diff --git a/src/dungeon_action.c b/src/dungeon_action.c index 866b1506d..840fa7caf 100644 --- a/src/dungeon_action.c +++ b/src/dungeon_action.c @@ -51,7 +51,7 @@ void sub_8044820(void) for (index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++) { entity = gDungeon->wildPokemon[index]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { if (sub_8044B28()) break; entityInfo = GetEntInfo(entity); gDungeon->unkB8 = entity; @@ -69,7 +69,7 @@ void sub_8044820(void) entityInfo->flags &= ~(MOVEMENT_FLAG_UNK_14 | MOVEMENT_FLAG_SWAPPING_PLACES_PETRIFIED_ALLY); entityInfo->recalculateFollow = FALSE; TickStatusHeal(entity); - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { sub_8071DA4(entity); RunMonsterAI(entity, 0); if (sub_8044B28()) break; @@ -88,10 +88,10 @@ void sub_8044820(void) for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++) { entity2 = gDungeon->wildPokemon[index]; - if ((EntityExists(entity2)) && (entityInfo2 = GetEntInfo(entity2), entityInfo2->aiAllySkip)) + if ((EntityIsValid(entity2)) && (entityInfo2 = GetEntInfo(entity2), entityInfo2->aiAllySkip)) { sub_8074094(entity2); - if (EntityExists(entity2)) { + if (EntityIsValid(entity2)) { sub_8071DA4(entity2); entityInfo2->aiAllySkip = FALSE; } @@ -119,7 +119,7 @@ void TrySpawnMonsterAndActivatePlusMinus(void) for(index = 0; index < DUNGEON_MAX_POKEMON; index++) { entity = gDungeon->activePokemon[index]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { entityInfo = GetEntInfo(entity); entityInfo->attacking = FALSE; @@ -153,7 +153,7 @@ void sub_8044AB4(void) if (gSpeedTurns[1][gDungeon->unk644.fractionalTurn + 1] != 0) { for (index = 0; index < DUNGEON_MAX_POKEMON; index++) { - if (EntityExists(gDungeon->activePokemon[index])) { + if (EntityIsValid(gDungeon->activePokemon[index])) { UseAttack(0); break; } @@ -225,8 +225,8 @@ void sub_8044C10(u8 param_1) if(param_1) { - entityInfo->action.unk4[0].actionUseIndex = 0; - entityInfo->action.unk4[1].actionUseIndex = 0; + entityInfo->action.actionParameters[0].actionUseIndex = 0; + entityInfo->action.actionParameters[1].actionUseIndex = 0; entityInfo->action.itemTargetPosition.x = -1; entityInfo->action.itemTargetPosition.y = -1; } @@ -237,8 +237,8 @@ void sub_8044C50(u16 action) EntityInfo * entityInfo = GetLeaderInfo(); entityInfo->action.action = action; - entityInfo->action.unk4[0].actionUseIndex = 0; - entityInfo->action.unk4[1].actionUseIndex = 0; + entityInfo->action.actionParameters[0].actionUseIndex = 0; + entityInfo->action.actionParameters[1].actionUseIndex = 0; entityInfo->action.itemTargetPosition.x = -1; entityInfo->action.itemTargetPosition.y = -1; @@ -247,15 +247,15 @@ void sub_8044C50(u16 action) void ClearMonsterActionFields(ActionContainer *actionPointer) { actionPointer->action = ACTION_NOTHING; - actionPointer->unk4[0].actionUseIndex = 0; - actionPointer->unk4[1].actionUseIndex = 0; + actionPointer->actionParameters[0].actionUseIndex = 0; + actionPointer->actionParameters[1].actionUseIndex = 0; } void SetMonsterActionFields(ActionContainer *actionPointer, u16 action) { actionPointer->action = action; - actionPointer->unk4[0].actionUseIndex = 0; - actionPointer->unk4[1].actionUseIndex = 0; + actionPointer->actionParameters[0].actionUseIndex = 0; + actionPointer->actionParameters[1].actionUseIndex = 0; } void SetActionPassTurnOrWalk(ActionContainer *actionPointer, s16 species) @@ -268,6 +268,6 @@ void SetActionPassTurnOrWalk(ActionContainer *actionPointer, s16 species) { actionPointer->action = ACTION_PASS_TURN; } - actionPointer->unk4[0].actionUseIndex = 0; - actionPointer->unk4[1].actionUseIndex = 0; + actionPointer->actionParameters[0].actionUseIndex = 0; + actionPointer->actionParameters[1].actionUseIndex = 0; } diff --git a/src/dungeon_ai.c b/src/dungeon_ai.c index cd41a2c79..0eff12a29 100644 --- a/src/dungeon_ai.c +++ b/src/dungeon_ai.c @@ -45,7 +45,7 @@ extern void sub_8041888(u32); void sub_8075900(Entity *pokemon, u8 r1) { - if(EntityExists(pokemon)) + if(EntityIsValid(pokemon)) { if(!GetEntInfo(pokemon)->isNotTeamMember) { @@ -108,7 +108,7 @@ void RunMonsterAI(Entity *pokemon, u32 unused) for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { target = gDungeon->activePokemon[i]; - if (EntityExists(target) && + if (EntityIsValid(target) && GetEntInfo(target)->curseClassStatus.status == STATUS_DECOY && CanSeeTarget(pokemon, target)) { diff --git a/src/dungeon_ai_attack.c b/src/dungeon_ai_attack.c index 38b58a35e..481b9f82e 100644 --- a/src/dungeon_ai_attack.c +++ b/src/dungeon_ai_attack.c @@ -107,7 +107,7 @@ void ChooseAIMove(Entity *pokemon) } } } - pokemonInfo->action.unk4[0].actionUseIndex = chosenMoveIndex; + pokemonInfo->action.actionParameters[0].actionUseIndex = chosenMoveIndex; TargetTileInFront(pokemon); return; } @@ -331,7 +331,7 @@ void ChooseAIMove(Entity *pokemon) } } pokemonInfo->action.direction = aiPossibleMove[i].direction & DIRECTION_MASK; - pokemonInfo->action.unk4[0].actionUseIndex = chosenMoveIndex; + pokemonInfo->action.actionParameters[0].actionUseIndex = chosenMoveIndex; TargetTileInFront(pokemon); } else @@ -421,7 +421,7 @@ s32 AIConsiderMove(struct AIPossibleMove *aiPossibleMove, Entity *pokemon, Move for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { Entity *target = gDungeon->activePokemon[i]; - if (EntityExists(target) && CanSeeTarget(pokemon, target)) + if (EntityIsValid(target) && CanSeeTarget(pokemon, target)) { numPotentialTargets = TryAddTargetToAITargetList(numPotentialTargets, targetingFlags, pokemon, target, move, hasStatusChecker); } @@ -466,7 +466,7 @@ s32 AIConsiderMove(struct AIPossibleMove *aiPossibleMove, Entity *pokemon, Move for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { Entity *target = gDungeon->activePokemon[i]; - if (EntityExists(target) && pokemon != target) + if (EntityIsValid(target) && pokemon != target) { s32 direction = GetDirectionTowardsPosition(&pokemon->pos, &target->pos); if (!gCanAttackInDirection[direction] && @@ -490,7 +490,7 @@ s32 AIConsiderMove(struct AIPossibleMove *aiPossibleMove, Entity *pokemon, Move for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { Entity *target = gDungeon->activePokemon[i]; - if (EntityExists(target)) + if (EntityIsValid(target)) { numPotentialTargets = TryAddTargetToAITargetList(numPotentialTargets, targetingFlags, pokemon, target, move, hasStatusChecker); } @@ -952,8 +952,8 @@ void HandleUseMoveAIAction(Entity *target) if (counter >= sub_8070828(target, TRUE)) break; entityInfo = GetEntInfo(target); - sub_8055A00(target, entityInfo->action.unk4[0].actionUseIndex, 1, 0, 0); - if (!EntityExists(target)) + sub_8055A00(target, entityInfo->action.actionParameters[0].actionUseIndex, 1, 0, 0); + if (!EntityIsValid(target)) break; if (sub_8044B28()) break; @@ -963,8 +963,8 @@ void HandleUseMoveAIAction(Entity *target) } sub_8057588(target, 1); - if (EntityExists(target)) - sub_806A9B4(target, GetEntInfo(target)->action.unk4[0].actionUseIndex); + if (EntityIsValid(target)) + sub_806A9B4(target, GetEntInfo(target)->action.actionParameters[0].actionUseIndex); sub_806A1B0(target); } @@ -1050,7 +1050,7 @@ void HandleUseOrbAction(Entity *pokemon) } - if (EntityExists(pokemon)) { + if (EntityIsValid(pokemon)) { if (r4) sub_8044DF0(pokemon, 0, 122); diff --git a/src/dungeon_ai_items.c b/src/dungeon_ai_items.c index f12fb2501..62c7dccde 100644 --- a/src/dungeon_ai_items.c +++ b/src/dungeon_ai_items.c @@ -50,7 +50,7 @@ void sub_807360C(void) for(index = 0; index < DUNGEON_MAX_POKEMON; index++) { entity = gDungeon->activePokemon[index]; - if(EntityExists(entity)) + if(EntityIsValid(entity)) { if(GetEntInfo(entity)->unk152 != 0) { @@ -96,9 +96,9 @@ void AIDecideUseItem(Entity *pokemon) if (DungeonRandOutcome(gAIThrownItemProbabilities[targetIndex])) { SetMonsterActionFields(&pokemonInfo->action, ACTION_THROW_ITEM_AI); - pokemonInfo->action.unk4[0].actionUseIndex = selectedToolboxIndex; - pokemonInfo->action.unk4[0].lastItemThrowPosition.x = pokemon->pos.x; - pokemonInfo->action.unk4[0].lastItemThrowPosition.y = pokemon->pos.y; + pokemonInfo->action.actionParameters[0].actionUseIndex = selectedToolboxIndex; + pokemonInfo->action.actionParameters[0].itemPos.x = pokemon->pos.x; + pokemonInfo->action.actionParameters[0].itemPos.y = pokemon->pos.y; pokemonInfo->action.direction = gAIThrownItemDirections[targetIndex] & DIRECTION_MASK; break; } @@ -120,9 +120,9 @@ void AIDecideUseItem(Entity *pokemon) { u32 chosenTargetIndex = DungeonRandInt(gAIThrowItemActionChoiceCount); SetMonsterActionFields(&pokemonInfo->action, ACTION_THROW_ITEM_AI); - pokemonInfo->action.unk4[0].actionUseIndex = selectedToolboxIndex; - pokemonInfo->action.unk4[0].lastItemThrowPosition.x = pokemon->pos.x; - pokemonInfo->action.unk4[0].lastItemThrowPosition.y = pokemon->pos.y; + pokemonInfo->action.actionParameters[0].actionUseIndex = selectedToolboxIndex; + pokemonInfo->action.actionParameters[0].itemPos.x = pokemon->pos.x; + pokemonInfo->action.actionParameters[0].itemPos.y = pokemon->pos.y; pokemonInfo->action.direction = GetDirectionTowardsPosition(&pokemon->pos, &potentialTargetPositions[chosenTargetIndex]) & DIRECTION_MASK; pokemonInfo->action.itemTargetPosition = potentialTargetPositions[chosenTargetIndex]; } @@ -133,9 +133,9 @@ void AIDecideUseItem(Entity *pokemon) if (itemTypeCompare < CATEGORY_HELD_ITEMS - 2) { SetMonsterActionFields(&pokemonInfo->action, ACTION_EAT_AI); - pokemonInfo->action.unk4[0].actionUseIndex = selectedToolboxIndex; - pokemonInfo->action.unk4[0].lastItemThrowPosition.x = pokemon->pos.x; - pokemonInfo->action.unk4[0].lastItemThrowPosition.y = pokemon->pos.y; + pokemonInfo->action.actionParameters[0].actionUseIndex = selectedToolboxIndex; + pokemonInfo->action.actionParameters[0].itemPos.x = pokemon->pos.x; + pokemonInfo->action.actionParameters[0].itemPos.y = pokemon->pos.y; } else { @@ -189,7 +189,7 @@ void AIDecideUseItem(Entity *pokemon) { if ((item->flags & ITEM_FLAG_STICKY) == 0) { - if (GetItemAIFlag(item->id, ITEM_AI_FLAG_TARGET_SELF)) + if (TestItemAIFlag(item->id, ITEM_AI_FLAG_TARGET_SELF)) { u32 itemWeight = GetAIUseItemProbability(pokemon, item, ITEM_TARGET_ALLY); if (itemWeight != 0) @@ -205,9 +205,9 @@ void AIDecideUseItem(Entity *pokemon) { SetMonsterActionFields(&pokemonInfo->action, ACTION_EAT_AI); } - pokemonInfo->action.unk4[0].actionUseIndex = selectedToolboxIndex; - pokemonInfo->action.unk4[0].lastItemThrowPosition.x = pokemon->pos.x; - pokemonInfo->action.unk4[0].lastItemThrowPosition.y = pokemon->pos.y; + pokemonInfo->action.actionParameters[0].actionUseIndex = selectedToolboxIndex; + pokemonInfo->action.actionParameters[0].itemPos.x = pokemon->pos.x; + pokemonInfo->action.actionParameters[0].itemPos.y = pokemon->pos.y; return; } } @@ -228,7 +228,7 @@ void AIDecideUseItem(Entity *pokemon) for (thrownAIFlag = ITEM_AI_FLAG_TARGET_ALLY; thrownAIFlag <= ITEM_AI_FLAG_TARGET_ENEMY; thrownAIFlag++) { potentialTargetWeights = gAIThrownItemProbabilities; - if (GetItemAIFlag(item->id, thrownAIFlag)) + if (TestItemAIFlag(item->id, thrownAIFlag)) { u8 itemType = GetItemCategory(item->id); if (itemType == CATEGORY_THROWN_ARC) @@ -239,9 +239,9 @@ void AIDecideUseItem(Entity *pokemon) { u32 chosenTargetIndex = DungeonRandInt(gAIThrowItemActionChoiceCount); SetMonsterActionFields(&pokemonInfo->action, ACTION_THROW_ITEM_AI); - pokemonInfo->action.unk4[0].actionUseIndex = selectedToolboxIndex; - pokemonInfo->action.unk4[0].lastItemThrowPosition.x = pokemon->pos.x; - pokemonInfo->action.unk4[0].lastItemThrowPosition.y = pokemon->pos.y; + pokemonInfo->action.actionParameters[0].actionUseIndex = selectedToolboxIndex; + pokemonInfo->action.actionParameters[0].itemPos.x = pokemon->pos.x; + pokemonInfo->action.actionParameters[0].itemPos.y = pokemon->pos.y; pokemonInfo->action.direction = GetDirectionTowardsPosition(&pokemon->pos, &potentialTargetPositions[chosenTargetIndex]) & DIRECTION_MASK; pokemonInfo->action.itemTargetPosition = potentialTargetPositions[chosenTargetIndex]; return; @@ -256,9 +256,9 @@ void AIDecideUseItem(Entity *pokemon) if (DungeonRandOutcome(potentialTargetWeights[targetIndex])) { SetMonsterActionFields(&pokemonInfo->action, ACTION_THROW_ITEM_AI); - pokemonInfo->action.unk4[0].actionUseIndex = selectedToolboxIndex; - pokemonInfo->action.unk4[0].lastItemThrowPosition.x = pokemon->pos.x; - pokemonInfo->action.unk4[0].lastItemThrowPosition.y = pokemon->pos.y; + pokemonInfo->action.actionParameters[0].actionUseIndex = selectedToolboxIndex; + pokemonInfo->action.actionParameters[0].itemPos.x = pokemon->pos.x; + pokemonInfo->action.actionParameters[0].itemPos.y = pokemon->pos.y; pokemonInfo->action.direction = gAIThrownItemDirections[targetIndex] & DIRECTION_MASK; return; } @@ -282,7 +282,7 @@ void GetPossibleAIThrownItemDirections(Entity *pokemon, s32 thrownAIFlag, Item * for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { Entity *targetPokemon = gDungeon->activePokemon[i]; - if (EntityExists(targetPokemon) && pokemon != targetPokemon) + if (EntityIsValid(targetPokemon) && pokemon != targetPokemon) { s32 targetingFlags; if (thrownAIFlag == ITEM_AI_FLAG_TARGET_ALLY) @@ -321,7 +321,7 @@ void GetPossibleAIArcItemTargets(Entity *pokemon, Item *item, for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { Entity *targetPokemon = gDungeon->activePokemon[i]; - if (EntityExists(targetPokemon) && pokemon != targetPokemon && + if (EntityIsValid(targetPokemon) && pokemon != targetPokemon && CanSeeTarget(pokemon, targetPokemon) && GetTreatmentBetweenMonsters(pokemon, targetPokemon, FALSE, TRUE) == TREATMENT_TREAT_AS_ENEMY) { s32 distanceX; diff --git a/src/dungeon_ai_leader.c b/src/dungeon_ai_leader.c index 0800f8b8e..7242351b8 100644 --- a/src/dungeon_ai_leader.c +++ b/src/dungeon_ai_leader.c @@ -146,7 +146,7 @@ bool8 sub_8072CF4(Entity *entity) if (sub_8044B28()) { return FALSE; } - if (!EntityExists(entity)) { + if (!EntityIsValid(entity)) { return FALSE; } if (gUnknown_202F32D != 0) { @@ -262,7 +262,7 @@ bool8 sub_8072CF4(Entity *entity) HandleUnsetItemAction(entity, TRUE); break; case 0x3b: - gDungeon->unkBC = gDungeon->teamPokemon[(info->action).unk4[0].actionUseIndex]; + gDungeon->unkBC = gDungeon->teamPokemon[(info->action).actionParameters[0].actionUseIndex]; break; case ACTION_PLACE_ITEM: HandlePlaceItemAction(entity); @@ -317,13 +317,13 @@ bool8 sub_8072CF4(Entity *entity) break; } sub_807FD84(entity); - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { if (GetEntInfo(entity)->unk14A == 0) { GetEntInfo(entity)->unk14A = 0; sub_8079764(entity); } sub_8041888(0); - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { sub_8085140(); if (info->unk14B != 0) { bVar4 = FALSE; @@ -345,19 +345,19 @@ bool8 sub_8072CF4(Entity *entity) if (!sub_8044B84()) { sub_807348C(); sub_80732F0(); - if (!EntityExists(entity)) { + if (!EntityIsValid(entity)) { return FALSE; } } if (bVar14) { sub_8075818(entity); } - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { if (!sub_8044B84()) { sub_8046D20(); } sub_8041888(0); - if (((EntityExists(entity)) && (!info->aiAllySkip)) && (!bVar14)) { + if (((EntityIsValid(entity)) && (!info->aiAllySkip)) && (!bVar14)) { if (sub_80706A4(entity,&entity->pos) != '\0') { WarpTarget(entity,entity,0,0); } diff --git a/src/dungeon_ai_movement.c b/src/dungeon_ai_movement.c index 4be334eb0..9ca27b3f2 100644 --- a/src/dungeon_ai_movement.c +++ b/src/dungeon_ai_movement.c @@ -106,7 +106,7 @@ bool8 CanTakeItem(Entity *pokemon) EntityInfo *pokemonInfo = GetEntInfo(pokemon); const Tile *mapTile; Entity *object; - if (!EntityExists(pokemon) || CheckVariousConditions(pokemon)) + if (!EntityIsValid(pokemon) || CheckVariousConditions(pokemon)) { return FALSE; } @@ -169,7 +169,7 @@ bool8 ChooseTargetPosition(Entity *pokemon) for (i = 0; i < maxPossibleTargets; i++) { Entity *target = possibleTargets[i]; - if (EntityExists(target) && GetEntInfo(target)->monsterBehavior == BEHAVIOR_FIXED_ENEMY) + if (EntityIsValid(target) && GetEntInfo(target)->monsterBehavior == BEHAVIOR_FIXED_ENEMY) { if (gDungeon->decoyIsActive) { @@ -265,7 +265,7 @@ bool8 ChooseTargetPosition(Entity *pokemon) if (!pokemonInfo->isNotTeamMember) { Entity *leader = GetLeaderIfVisible(pokemon); - if (EntityExists(leader)) + if (EntityIsValid(leader)) { pokemonInfo->aiTarget.aiObjective = AI_CHASE_TARGET; pokemonInfo->aiTarget.aiTargetPos = leader->pos; @@ -531,7 +531,7 @@ bool8 AvoidEnemies(Entity *pokemon) for (i = 0; i < numPossibleTargets; i++) { Entity *target = possibleTargets[i]; - if (EntityExists(target) && CanSeeTarget(pokemon, target)) + if (EntityIsValid(target) && CanSeeTarget(pokemon, target)) { s32 distance; if (gDungeon->decoyIsActive && GetTreatmentBetweenMonsters(pokemon, target, FALSE, TRUE) != TREATMENT_TREAT_AS_ENEMY) diff --git a/src/dungeon_ai_targeting.c b/src/dungeon_ai_targeting.c index 3a14bd9ee..ab8563072 100644 --- a/src/dungeon_ai_targeting.c +++ b/src/dungeon_ai_targeting.c @@ -404,7 +404,7 @@ bool8 ShouldAvoidFirstHit(Entity *pokemon, bool8 forceAvoid) bool8 ShouldMonsterRunAway(Entity *pokemon) { - if (!EntityExists(pokemon)) + if (!EntityIsValid(pokemon)) { return FALSE; } diff --git a/src/dungeon_cutscenes.c b/src/dungeon_cutscenes.c index a8c4a1f35..31d373ea0 100644 --- a/src/dungeon_cutscenes.c +++ b/src/dungeon_cutscenes.c @@ -693,7 +693,7 @@ void sub_8086F54(u8 param_1, u8 param_2) bool8 found = FALSE; for (index = 0; index < 0x10; index++) { struct Entity *entity = gDungeon->wildPokemon[index]; - if ((EntityExists(entity))) { + if ((EntityIsValid(entity))) { struct EntityInfo *entInfo = GetEntInfo(entity); if (entInfo->monsterBehavior != param_1) { found = TRUE; @@ -2554,7 +2554,7 @@ void sub_8089788(Entity *entity, u8 param_2, u8 param_3) for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++) { monEntity = gDungeon->wildPokemon[index]; - if ((EntityExists(monEntity)) && (monEntity != entity) && (GetEntInfo(monEntity)->monsterBehavior == param_2)) { + if ((EntityIsValid(monEntity)) && (monEntity != entity) && (GetEntInfo(monEntity)->monsterBehavior == param_2)) { return; } } @@ -4887,7 +4887,7 @@ void sub_808C948(Entity *entity, u8 param_2) flag = FALSE; for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++){ pokeEntity = gDungeon->wildPokemon[index]; - if ((pokeEntity != entity) && (EntityExists(pokeEntity))) { + if ((pokeEntity != entity) && (EntityIsValid(pokeEntity))) { flag = TRUE; break; } diff --git a/src/dungeon_engine.c b/src/dungeon_engine.c index e06cd4688..22e352926 100644 --- a/src/dungeon_engine.c +++ b/src/dungeon_engine.c @@ -183,10 +183,10 @@ static void sub_8044454(void) for(index = 0; index < DUNGEON_MAX_POKEMON; index++) { entity = gDungeon->activePokemon[index]; - if ((EntityExists(entity)) && (entityInfo = GetEntInfo(entity), (entityInfo->flags & MOVEMENT_FLAG_SWAPPING_PLACES_PETRIFIED_ALLY))) { + if ((EntityIsValid(entity)) && (entityInfo = GetEntInfo(entity), (entityInfo->flags & MOVEMENT_FLAG_SWAPPING_PLACES_PETRIFIED_ALLY))) { if (sub_8044B28()) break; TickStatusHeal(entity); - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { sub_8071DA4(entity); RunMonsterAI(entity, 0); sub_8072CF4(entity); @@ -211,7 +211,7 @@ void sub_80444F4(Entity *pokemon) for(index = 0; index < DUNGEON_MAX_POKEMON; index++) { entity = gDungeon->activePokemon[index]; - if ((EntityExists(entity)) && (pokemon != entity) && (entityInfo = GetEntInfo(entity), (entityInfo->flags & MOVEMENT_FLAG_SWAPPING_PLACES_PETRIFIED_ALLY))) { + if ((EntityIsValid(entity)) && (pokemon != entity) && (entityInfo = GetEntInfo(entity), (entityInfo->flags & MOVEMENT_FLAG_SWAPPING_PLACES_PETRIFIED_ALLY))) { if (sub_8044B28()) break; RunMonsterAI(entity, 0); sub_8072CF4(entity); diff --git a/src/dungeon_items.c b/src/dungeon_items.c index 84d27fab5..0e3c5c05e 100644 --- a/src/dungeon_items.c +++ b/src/dungeon_items.c @@ -175,7 +175,7 @@ bool8 sub_8046F00(Item *item) for(index = 0; index < MAX_TEAM_MEMBERS; index++) { entity = gDungeon->teamPokemon[index]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { canLearnMove = CanMonLearnMove(moveID, GetEntInfo(entity)->id); cannotMove = CheckVariousStatuses2(entity, FALSE); if (cannotMove) { @@ -212,7 +212,7 @@ void sub_8046F84(s32 itemFlag) for(index = 0; index < 4; index++) { entity = gDungeon->teamPokemon[index]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { entityInfo = GetEntInfo(entity); item = &entityInfo->heldItem; if ((item->flags & ITEM_FLAG_EXISTS) && (item->flags & itemFlag)) { @@ -243,7 +243,7 @@ void sub_804700C(void) for(index = 0; index < MAX_TEAM_MEMBERS; index++) { entity = gDungeon->teamPokemon[index]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { entityInfo = GetEntInfo(entity); item = &entityInfo->heldItem; if ((item->flags & ITEM_FLAG_EXISTS)) { @@ -268,7 +268,7 @@ bool8 sub_8047084(s32 itemFlag) for (i = 0; i < MAX_TEAM_MEMBERS; i++) { Entity *entity = gDungeon->teamPokemon[i]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { EntityInfo *entityInfo = GetEntInfo(entity); Item *item = &entityInfo->heldItem; if ((ItemExists(item) & ITEM_FLAG_EXISTS) && (item->flags & itemFlag)) { diff --git a/src/dungeon_leader.c b/src/dungeon_leader.c index 770e6e89a..56e1c737b 100644 --- a/src/dungeon_leader.c +++ b/src/dungeon_leader.c @@ -14,7 +14,7 @@ Entity* GetLeader(void) for (i = 0; i < MAX_TEAM_MEMBERS; i++) { Entity *currentPokemon = gDungeon->teamPokemon[i]; - if (EntityExists(currentPokemon) && GetEntInfo(currentPokemon)->isTeamLeader) + if (EntityIsValid(currentPokemon) && GetEntInfo(currentPokemon)->isTeamLeader) { gLeaderPointer = currentPokemon; return currentPokemon; diff --git a/src/dungeon_message.c b/src/dungeon_message.c index 758ba61d8..dab15b7da 100644 --- a/src/dungeon_message.c +++ b/src/dungeon_message.c @@ -617,7 +617,7 @@ s32 DisplayDungeonMenuMessage(struct MonDialogueSpriteInfo *monSpriteInfo, const void sub_8052D44(s16 *ids, Entity *leader, Entity *partner) { - if (EntityExists(leader)) { + if (EntityIsValid(leader)) { SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0], leader, 0); ids[0] = GetEntInfo(leader)->apparentID; } @@ -626,7 +626,7 @@ void sub_8052D44(s16 *ids, Entity *leader, Entity *partner) ids[0] = 0; } - if (EntityExists(partner)) { + if (EntityIsValid(partner)) { SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[1], partner, 0); ids[1] = GetEntInfo(partner)->apparentID; } diff --git a/src/dungeon_move.c b/src/dungeon_move.c index 6fbe5bd96..e8572f506 100644 --- a/src/dungeon_move.c +++ b/src/dungeon_move.c @@ -399,9 +399,9 @@ static void UseMoveAgainstTargets(Entity **targetsArray, Entity *attacker, Move moveRedirected = FALSE; if (currTarget == NULL) break; - if (!EntityExists(attacker)) + if (!EntityIsValid(attacker)) break; - if (EntityExists(currTarget)) { + if (EntityIsValid(currTarget)) { bool32 r4; bool8 moveHadEffect; @@ -453,7 +453,7 @@ static void UseMoveAgainstTargets(Entity **targetsArray, Entity *attacker, Move direction2++; direction2 &= DIRECTION_MASK; tileEntity = GetTile(currTarget->pos.x + gAdjacentTileOffsets[direction2].x, currTarget->pos.y + gAdjacentTileOffsets[direction2].y)->monster; - if (EntityExists(tileEntity) && GetEntityType(tileEntity) == ENTITY_MONSTER) { + if (EntityIsValid(tileEntity) && GetEntityType(tileEntity) == ENTITY_MONSTER) { if (sub_8045888(currTarget)) { s32 k; for (k = 0; k < 24; k++) { @@ -1603,12 +1603,12 @@ static void UseMoveAgainstTargets(Entity **targetsArray, Entity *attacker, Move break; } - if (EntityExists(currTargetSaved)) { + if (EntityIsValid(currTargetSaved)) { sub_806CE68(currTargetSaved, GetEntInfo(currTargetSaved)->action.direction); } if (!moveHadEffect) { - if (EntityExists(attacker) && EntityExists(currTarget) && targetInfo->isNotTeamMember) { + if (EntityIsValid(attacker) && EntityIsValid(currTarget) && targetInfo->isNotTeamMember) { targetInfo->expMultiplier = expMultiplierBeforeMove; } } @@ -1618,7 +1618,7 @@ static void UseMoveAgainstTargets(Entity **targetsArray, Entity *attacker, Move } } - if (EntityExists(currTarget)) { + if (EntityIsValid(currTarget)) { targetInfo->unk158 = 1; } @@ -1634,11 +1634,11 @@ static void UseMoveAgainstTargets(Entity **targetsArray, Entity *attacker, Move } if (!sub_8044B28()) { - if (EntityExists(attacker) && GetEntInfo(attacker)->unk154 != 0) { + if (EntityIsValid(attacker) && GetEntInfo(attacker)->unk154 != 0) { GetEntInfo(attacker)->unk154 = 0; WarpTarget(attacker, attacker, 0, NULL); } - if (EntityExists(attacker) && GetEntInfo(attacker)->unk155 != 0) { + if (EntityIsValid(attacker) && GetEntInfo(attacker)->unk155 != 0) { GetEntInfo(attacker)->unk155 = 0; LowerAttackStageTarget(attacker, attacker, gUnknown_8106A50, 2, 0, FALSE); } @@ -1706,7 +1706,7 @@ static s32 TryHitTarget(Entity *attacker, Entity *target, Move *move, struct Dam return 0; } - if (EntityExists(target)) { + if (EntityIsValid(target)) { GetEntInfo(target)->unk15A = 1; } @@ -1724,7 +1724,7 @@ s32 sub_8055864(Entity *attacker, Entity *target, Move *move, s32 param_4, s32 i return 0; } - if (EntityExists(target)) { + if (EntityIsValid(target)) { GetEntInfo(target)->unk15A = 1; } return dmgStruct.dmg; @@ -1832,7 +1832,7 @@ bool32 sub_8055A00(Entity *attacker, s32 firstMoveId, s32 var_34, s32 itemId, s3 while (1) { Move *currMove = &attackerInfo->moves.moves[moveId]; - if (!EntityExists(attacker) || sub_8044B28()) + if (!EntityIsValid(attacker) || sub_8044B28()) break; if (currMove->id == MOVE_SNORE || currMove->id == MOVE_SLEEP_TALK) { @@ -1905,7 +1905,7 @@ bool32 sub_8055A00(Entity *attacker, s32 firstMoveId, s32 var_34, s32 itemId, s3 } sub_804178C(1); - if (!EntityExists(attacker) || sub_8044B28()) + if (!EntityIsValid(attacker) || sub_8044B28()) break; if (++moveId >= MAX_MON_MOVES) break; @@ -1913,7 +1913,7 @@ bool32 sub_8055A00(Entity *attacker, s32 firstMoveId, s32 var_34, s32 itemId, s3 break; } - if (EntityExists(attacker)) { + if (EntityIsValid(attacker)) { for (i = 0; i < MAX_MON_MOVES; i++) { if (attackerInfo->mimicMoveIDs[i] != 0) { Move mimicMove, assistMove; @@ -1936,11 +1936,11 @@ bool32 sub_8055A00(Entity *attacker, s32 firstMoveId, s32 var_34, s32 itemId, s3 } } - if (EntityExists(attacker)) { + if (EntityIsValid(attacker)) { sub_8071DA4(attacker); - if (EntityExists(attacker) && gUnknown_202F222 != 0) { + if (EntityIsValid(attacker) && gUnknown_202F222 != 0) { gUnknown_202F222 = 0; - if (EntityExists(attacker)) { + if (EntityIsValid(attacker)) { EntityInfo *attackerInfo = GetEntInfo(attacker); s32 statusTurns = CalculateStatusTurns(attacker, gPauseTurnRange, TRUE); PausedStatusTarget(attacker, attacker, 1, statusTurns, FALSE); @@ -1954,7 +1954,7 @@ bool32 sub_8055A00(Entity *attacker, s32 firstMoveId, s32 var_34, s32 itemId, s3 static void TriggerTargetAbilityEffect(Entity *attacker) { - if (EntityExists(attacker)) { + if (EntityIsValid(attacker)) { EntityInfo *entInfo = GetEntInfo(attacker); if (entInfo->abilityEffectFlags & ABILITY_FLAG_ARENA_TRAP) { @@ -2131,7 +2131,7 @@ bool8 TryUseChosenMove(struct Entity *attacker, u32 r6, s32 itemId, u32 var_30, var_24 = 1; if (gUnknown_202F220 != 0 || gUnknown_202F221 != 0) break; - if (!EntityExists(attacker) || sub_8044B28()) + if (!EntityIsValid(attacker) || sub_8044B28()) return TRUE; entInfo = GetEntInfo(attacker); @@ -2177,7 +2177,7 @@ bool8 TryUseChosenMove(struct Entity *attacker, u32 r6, s32 itemId, u32 var_30, UseMoveAgainstTargets(targetsArray, attacker, move, itemId, isLinkedMove); } - if (!EntityExists(attacker)) + if (!EntityIsValid(attacker)) break; sub_806CF18(attacker); @@ -2193,7 +2193,7 @@ bool8 TryUseChosenMove(struct Entity *attacker, u32 r6, s32 itemId, u32 var_30, EndLeechSeedClassStatus(attacker, attacker); } - if (gUnknown_202F219 != 0 && EntityExists(attacker)) { + if (gUnknown_202F219 != 0 && EntityIsValid(attacker)) { EntityInfo *entInfo = GetEntInfo(attacker); ConfuseStatusTarget(attacker, attacker, FALSE); @@ -2835,7 +2835,7 @@ static void SetTargetsForMove(Entity **targetsArray, Entity *attacker, Move *mov s32 i; for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { Entity *dungeonMon = gDungeon->activePokemon[i]; - if (EntityExists(dungeonMon) && sub_8045A70(attacker, dungeonMon)) { + if (EntityIsValid(dungeonMon) && sub_8045A70(attacker, dungeonMon)) { if (dungeonMon == attacker) { arrId = SetNewTarget(arrId, targetsArray, targetFlags, attacker, attacker, move, canHitSelf); } @@ -2873,7 +2873,7 @@ static void SetTargetsForMove(Entity **targetsArray, Entity *attacker, Move *mov s32 i; for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { Entity *dungeonMon = gDungeon->activePokemon[i]; - if (EntityExists(dungeonMon)) { + if (EntityIsValid(dungeonMon)) { arrId = SetNewTarget(arrId, targetsArray, targetFlags, attacker, dungeonMon, move, canHitPartner); } } @@ -3004,7 +3004,7 @@ bool8 MoveCausesPaused(Move *move) bool8 MoveMatchesBideClassStatus(Entity *pokemon, Move *move) { - if (!EntityExists(pokemon)) + if (!EntityIsValid(pokemon)) { return FALSE; } @@ -3030,7 +3030,7 @@ bool8 MoveMatchesBideClassStatus(Entity *pokemon, Move *move) bool8 IsChargingAnyTwoTurnMove(Entity *pokemon, bool8 checkCharge) { - if (!EntityExists(pokemon)) + if (!EntityIsValid(pokemon)) { return FALSE; } @@ -3074,7 +3074,7 @@ u32 sub_8057144(Entity * pokemon) for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { Entity *dungeonMon = gDungeon->activePokemon[i]; - if (EntityExists(dungeonMon)) { + if (EntityIsValid(dungeonMon)) { Move *moves = GetEntInfo(dungeonMon)->moves.moves; for (j = 0; j < MAX_MON_MOVES; j++) { @@ -3139,7 +3139,7 @@ bool8 sub_805727C(Entity * pokemon, Entity * target, s32 chance) bool8 uVar2; if (sub_8044B28()) return FALSE; - if (!EntityExists(pokemon) || !EntityExists(target)) + if (!EntityIsValid(pokemon) || !EntityIsValid(target)) return FALSE; if (GetEntInfo(target)->unk158 == 0 || GetEntInfo(target)->HP == 0) return FALSE; @@ -3169,7 +3169,7 @@ bool8 sub_805727C(Entity * pokemon, Entity * target, s32 chance) bool8 RollSecondaryEffect(Entity *pokemon, s32 chance) { - if(!EntityExists(pokemon)) + if(!EntityIsValid(pokemon)) return FALSE; if(chance == 0) return TRUE; diff --git a/src/dungeon_music.c b/src/dungeon_music.c index 78da14298..e0c12616f 100644 --- a/src/dungeon_music.c +++ b/src/dungeon_music.c @@ -40,7 +40,7 @@ void sub_8083AB0(s16 param_0, Entity * target, Entity * entity) temp = &gDungeon->unk1CE98; targetEntityInfo = NULL; - if ((EntityExists(target)) && (GetEntityType(target) == ENTITY_MONSTER)) { + if ((EntityIsValid(target)) && (GetEntityType(target) == ENTITY_MONSTER)) { targetEntityInfo = GetEntInfo(target); } entityInfo = GetEntInfo(entity); diff --git a/src/dungeon_pokemon_attributes.c b/src/dungeon_pokemon_attributes.c index d1554dbae..ede950268 100644 --- a/src/dungeon_pokemon_attributes.c +++ b/src/dungeon_pokemon_attributes.c @@ -84,7 +84,7 @@ bool8 sub_80717A4(Entity *pokemon, u16 moveID) bool8 AbilityIsActive(Entity *pokemon, u8 ability) { - if (!EntityExists(pokemon)) + if (!EntityIsValid(pokemon)) { return FALSE; } @@ -197,7 +197,7 @@ bool8 CanSeeTeammate(Entity * pokemon) for(memberIdx = 0; memberIdx < MAX_TEAM_MEMBERS; memberIdx++) { teamMember = gDungeon->teamPokemon[memberIdx]; - if (EntityExists(pokemon) && (pokemon != teamMember) && (CanSeeTarget(pokemon,teamMember))) + if (EntityIsValid(pokemon) && (pokemon != teamMember) && (CanSeeTarget(pokemon,teamMember))) { return TRUE; } @@ -241,7 +241,7 @@ static inline bool8 sub_8071A8C_sub(EntityInfo *pokemonInfo) bool8 sub_8071A8C(Entity *pokemon) { EntityInfo *pokemonInfo; - if(EntityExists(pokemon)) + if(EntityIsValid(pokemon)) { pokemonInfo = GetEntInfo(pokemon); if(pokemonInfo->monsterBehavior != BEHAVIOR_RESCUE_TARGET) diff --git a/src/dungeon_serializer.c b/src/dungeon_serializer.c index a7ec95d5a..588026a2b 100644 --- a/src/dungeon_serializer.c +++ b/src/dungeon_serializer.c @@ -263,7 +263,7 @@ static void WriteMonster(DataSerializer *seri, Entity *src) WriteU8(seri, 0xAA); WriteU8(seri, 0x55); - if (EntityExists(src)) { + if (EntityIsValid(src)) { info = GetEntInfo(src); WriteBytes(seri, &one, 1); WriteBytes(seri, &src->pos.x, 1); @@ -1237,7 +1237,7 @@ void sub_8082B40(void) for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { entity = gDungeon->activePokemon[i]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { info = GetEntInfo(entity); entity->axObj.spriteFile = GetSpriteData(info->apparentID); sub_806CCB4(entity, sub_806CEBC(entity)); diff --git a/src/dungeon_util.c b/src/dungeon_util.c index 6146b994e..e7b32e641 100644 --- a/src/dungeon_util.c +++ b/src/dungeon_util.c @@ -26,7 +26,7 @@ const DungeonPos gAdjacentTileOffsets[] = { {-1, 1} }; -bool8 EntityExists(Entity *entity) +bool8 EntityIsValid(Entity *entity) { if (!entity) { @@ -133,7 +133,7 @@ void sub_804522C(void) { for(index = 0; index < DUNGEON_MAX_POKEMON; index++) { entity = gDungeon->activePokemon[index]; - if(EntityExists(entity)) + if(EntityIsValid(entity)) { if(entity == gDungeon->unk181e8.cameraTarget) { @@ -153,7 +153,7 @@ void sub_804522C(void) { for(index = 0; index < MAX_TEAM_MEMBERS; index++) { entity2 = gDungeon->teamPokemon[index]; - if(EntityExists(entity2)) + if(EntityIsValid(entity2)) { sub_806C51C(entity2); } @@ -161,7 +161,7 @@ void sub_804522C(void) { for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++) { entity2 = gDungeon->wildPokemon[index]; - if(EntityExists(entity2)) + if(EntityIsValid(entity2)) { sub_806C51C(entity2); } diff --git a/src/dungeon_util_1.c b/src/dungeon_util_1.c index 761b17b38..d4873ae97 100644 --- a/src/dungeon_util_1.c +++ b/src/dungeon_util_1.c @@ -38,7 +38,7 @@ Entity *GetPartnerEntity(void) for(counter = 0; counter < MAX_TEAM_MEMBERS; counter++) { entity = gDungeon->teamPokemon[counter]; - if(EntityExists(entity) && GetEntInfo(entity)->joinedAt.id == DUNGEON_JOIN_LOCATION_PARTNER) + if(EntityIsValid(entity) && GetEntInfo(entity)->joinedAt.id == DUNGEON_JOIN_LOCATION_PARTNER) { return entity; } @@ -61,7 +61,7 @@ void sub_80854D4(void) for(index = 0; index < MAX_TEAM_MEMBERS; index++) { entity = gDungeon->teamPokemon[index]; - if(EntityExists(entity)) + if(EntityIsValid(entity)) { stack1[counter] = entity; counter++; @@ -125,7 +125,7 @@ void sub_80855E4(DungeonCallback func) for(index = 0; index < MAX_TEAM_MEMBERS; index++) { entity = gDungeon->teamPokemon[index]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { if (GetEntInfo(entity)->joinedAt.id == DUNGEON_JOIN_LOCATION_PARTNER) { flag = TRUE; } @@ -145,7 +145,7 @@ void sub_808563C(DungeonCallback func) for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++) { entity = gDungeon->wildPokemon[index]; - if ((EntityExists(entity)) && (GetEntInfo(entity)->joinedAt.id != 0x41)) { + if ((EntityIsValid(entity)) && (GetEntInfo(entity)->joinedAt.id != 0x41)) { func(entity); } } @@ -159,7 +159,7 @@ Entity *GetEntityFromMonsterBehavior(u8 entityType) for(index = 0; index < DUNGEON_MAX_POKEMON; index++) { entity = gDungeon->activePokemon[index]; - if ((EntityExists(entity)) && (GetEntInfo(entity)->monsterBehavior == entityType)) return entity; + if ((EntityIsValid(entity)) && (GetEntInfo(entity)->monsterBehavior == entityType)) return entity; } return NULL; } @@ -205,7 +205,7 @@ void sub_8085764(void) for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++) { entity = gDungeon->wildPokemon[index]; - if ((EntityExists(entity)) && (GetEntInfo(entity)->monsterBehavior == BEHAVIOR_ALLY)) { + if ((EntityIsValid(entity)) && (GetEntInfo(entity)->monsterBehavior == BEHAVIOR_ALLY)) { sub_8068FE0(entity,0x207,&stackEntity); } } @@ -221,7 +221,7 @@ void sub_80857B8(void) for(index = 0; index < DUNGEON_MAX_POKEMON; index++) { entity = gDungeon->activePokemon[index]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { entityInfo = GetEntInfo(entity); if ((gDungeon->unk4 == 0) && (gDungeon->unk2 == 0)) { sub_804535C(entity, 0); @@ -286,7 +286,7 @@ void sub_8085930(s32 direction) for(index = 0; index < MAX_TEAM_MEMBERS; index++) { entity = gDungeon->teamPokemon[index]; - if(EntityExists(entity)) + if(EntityIsValid(entity)) { if(direction >= NUM_DIRECTIONS) { @@ -302,7 +302,7 @@ void sub_8085930(s32 direction) for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++) { entity = gDungeon->wildPokemon[index]; - if(EntityExists(entity)) + if(EntityIsValid(entity)) { if(GetEntInfo(entity)->monsterBehavior == BEHAVIOR_ALLY) { @@ -327,7 +327,7 @@ void sub_80859F0(s32 direction) for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++) { entity = gDungeon->wildPokemon[index]; - if(EntityExists(entity)) + if(EntityIsValid(entity)) { if(direction >= NUM_DIRECTIONS) { diff --git a/src/dungeon_visibility.c b/src/dungeon_visibility.c index 9697ba396..4ba991e6d 100644 --- a/src/dungeon_visibility.c +++ b/src/dungeon_visibility.c @@ -8,7 +8,7 @@ bool8 CanSeeTarget(Entity *entity, Entity *targetEntity) { - if (!EntityExists(entity) || !EntityExists(targetEntity) || !targetEntity->isVisible) + if (!EntityIsValid(entity) || !EntityIsValid(targetEntity) || !targetEntity->isVisible) { return FALSE; } @@ -35,7 +35,7 @@ bool8 CanSeeTarget(Entity *entity, Entity *targetEntity) bool8 CanTargetEntity(Entity *entity, Entity *targetEntity) { - if (!EntityExists(entity) || !EntityExists(targetEntity) || !targetEntity->isVisible) + if (!EntityIsValid(entity) || !EntityIsValid(targetEntity) || !targetEntity->isVisible) { return FALSE; } @@ -62,7 +62,7 @@ bool8 CanTargetEntity(Entity *entity, Entity *targetEntity) bool8 sub_8045A70(Entity *entity, Entity *targetEntity) { - if (EntityExists(entity) && EntityExists(targetEntity) && targetEntity->isVisible) + if (EntityIsValid(entity) && EntityIsValid(targetEntity) && targetEntity->isVisible) { return IsPositionActuallyInSight(&entity->pos, &targetEntity->pos); } diff --git a/src/items.c b/src/items.c index 57f4c6972..d5ee5352f 100644 --- a/src/items.c +++ b/src/items.c @@ -285,9 +285,9 @@ u8 *GetItemDescription(u8 id) return gItemParametersData[id].description; } -bool8 GetItemAIFlag(u8 id, u32 r1) +bool8 TestItemAIFlag(u8 id, u32 aiFlag) { - return gItemParametersData[id].aiFlags[r1]; + return gItemParametersData[id].aiFlags[aiFlag]; } // a2 is always NULL diff --git a/src/move_actions.c b/src/move_actions.c index 9e693fb4c..f3eba083c 100644 --- a/src/move_actions.c +++ b/src/move_actions.c @@ -163,7 +163,7 @@ void sub_8057588(Entity * pokemon, u8 param_2) s32 PPCounter; EntityInfo *entityInfo; - if (EntityExists(pokemon)) { + if (EntityIsValid(pokemon)) { entityInfo = GetEntInfo(pokemon); for(index = 0; index < MAX_MON_MOVES; index++) { @@ -1345,7 +1345,7 @@ bool8 sub_8058E5C(Entity *pokemon, Entity *target, Move *move, s32 param_4) bool8 flag; flag = FALSE; - if ((HandleDamagingMove(pokemon, target, move, IntToF248_2(1), param_4) != 0) && (EntityExists(pokemon))) { + if ((HandleDamagingMove(pokemon, target, move, IntToF248_2(1), param_4) != 0) && (EntityIsValid(pokemon))) { iVar2 = GetEntInfo(pokemon)->maxHPStat; if (iVar2 < 0) { iVar2 = iVar2 + 7; @@ -1520,7 +1520,7 @@ bool8 AbsorbMoveAction(Entity *pokemon, Entity *target, Move *move, s32 param_4) if (iVar4 < 1) { iVar4 = 1; } - if (EntityExists(pokemon)) { + if (EntityIsValid(pokemon)) { EntityInfo *entityInfo = GetEntInfo(pokemon); flag = TRUE; SetExpMultplier(entityInfo); @@ -2388,7 +2388,7 @@ bool8 PayDayMoveAction(Entity *pokemon, Entity *target, Move *move, u32 param_4) if (HandleDamagingMove(pokemon, target, move, IntToF248_2(1), param_4) != 0) { flag = TRUE; if (RollSecondaryEffect(pokemon, 0) != 0) { - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { pos.x = 0; pos.y = 0; sub_8045C28(&item,ITEM_POKE,2); @@ -2634,14 +2634,14 @@ bool8 SplashMoveAction(Entity * pokemon, Entity * target, Move *move, u32 param_ if (sub_80571F0(entity,&stackMove) == 0) { sub_806F370(pokemon,entity,gSplashDmgValue,0,0,TYPE_NONE,sub_8057600(move, param_4),0,1,0); } - if ((sub_8044B28() == 0) && (EntityExists(pokemon))) { + if ((sub_8044B28() == 0) && (EntityIsValid(pokemon))) { sub_806F370(pokemon,pokemon,gSplashDmgValue,0,0,0,0x1fe,0,0,0); - if ((sub_8044B28() == 0) && (EntityExists(pokemon))) goto _0805A9FE; + if ((sub_8044B28() == 0) && (EntityIsValid(pokemon))) goto _0805A9FE; } } else { _0805A9FE: - if (EntityExists(target)) { + if (EntityIsValid(target)) { if ((sub_803F428(r9)) || (sub_803F428(&pos1))) { for(counter = 0; counter < 0xC; counter++) { @@ -2657,7 +2657,7 @@ bool8 SplashMoveAction(Entity * pokemon, Entity * target, Move *move, u32 param_ { sub_80694C0(target,pos1.x,pos1.y,0); _0805AA5E: - if (EntityExists(target)) { + if (EntityIsValid(target)) { #ifndef NOMATCHING register DungeonPos *pos asm("r1"); #else @@ -2806,7 +2806,7 @@ bool32 BeatUpMoveAction(Entity * pokemon, Entity * target, Move *move, u32 param for (i = 0; i < numPossibleTargets; i++) { Entity *targetEntity = possibleTargets[i]; - if (EntityExists(targetEntity) + if (EntityIsValid(targetEntity) && pokemon != targetEntity && GetTreatmentBetweenMonsters(pokemon,targetEntity,FALSE,FALSE) == TREATMENT_TREAT_AS_ALLY) { diff --git a/src/move_checks.c b/src/move_checks.c index 90d55658f..496a33cf3 100644 --- a/src/move_checks.c +++ b/src/move_checks.c @@ -415,7 +415,7 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) for (i = 0; i < DUNGEON_MAX_WILD_POKEMON; i++) { Entity *target = gDungeon->wildPokemon[i]; - if (EntityExists(target) && target != pokemon && CanSeeTarget(pokemon, target)) + if (EntityIsValid(target) && target != pokemon && CanSeeTarget(pokemon, target)) { if (GetEntInfo(target)->offensiveStages[STAT_STAGE_ATK] >= MAX_STAT_STAGE) { @@ -439,7 +439,7 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) for (i = 0; i < MAX_TEAM_MEMBERS; i++) { Entity *target = gDungeon->teamPokemon[i]; - if (EntityExists(target) && target != pokemon && CanSeeTarget(pokemon, target)) + if (EntityIsValid(target) && target != pokemon && CanSeeTarget(pokemon, target)) { if (GetEntInfo(target)->offensiveStages[STAT_STAGE_ATK] >= MAX_STAT_STAGE) { diff --git a/src/move_effects_target.c b/src/move_effects_target.c index 284f499a7..c358f5397 100644 --- a/src/move_effects_target.c +++ b/src/move_effects_target.c @@ -155,7 +155,7 @@ u8 sub_8075BF4(Entity * pokemon, s32 sleepClassStatusTurns) u32 uVar4; uVar4 = 0; - if (!EntityExists(pokemon)){ + if (!EntityIsValid(pokemon)){ return uVar4; } else @@ -213,7 +213,7 @@ void SleepStatusTarget(Entity * pokemon, Entity * target, s32 turns, u8 displayM bool8 CannotSleep(Entity * pokemon, Entity * target, u8 param_3, bool8 displayMessage) { - if ((!EntityExists(target)) || + if ((!EntityIsValid(target)) || ((SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0), param_3 != 0 && (HasSafeguardStatus(pokemon,target,displayMessage))))) { return TRUE; @@ -355,7 +355,7 @@ void SleeplessStatusTarget(Entity * pokemon, Entity * target) bool8 isAsleep; isAsleep = FALSE; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } @@ -388,7 +388,7 @@ void PausedStatusTarget(Entity * pokemon, Entity * target, u8 param_3, s32 turns { EntityInfo *entityInfo; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } entityInfo = GetEntInfo(target); @@ -424,7 +424,7 @@ void InfatuateStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessa EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); if (!HasSafeguardStatus(pokemon,target,displayMessage)) { if (AbilityIsActive(target,ABILITY_OBLIVIOUS)) { @@ -461,7 +461,7 @@ void BurnedStatusTarget(Entity * pokemon, Entity * target, u8 param_3, bool8 dis Entity *entity; s32 index; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } @@ -521,7 +521,7 @@ void BurnedStatusTarget(Entity * pokemon, Entity * target, u8 param_3, bool8 dis gAdjacentTileOffsets[index].x, target->pos.y + gAdjacentTileOffsets[index].y); entity = tile_2->monster; - if ((EntityExists(entity)) && (GetEntityType(entity) == ENTITY_MONSTER)) { + if ((EntityIsValid(entity)) && (GetEntityType(entity) == ENTITY_MONSTER)) { if (!hasSynchronized) { hasSynchronized = TRUE; SetMessageArgument_2(gFormatBuffer_Monsters[0],entityInfo,0); @@ -548,7 +548,7 @@ void PoisonedStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessag Entity *entity; s32 index; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } @@ -608,7 +608,7 @@ void PoisonedStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessag gAdjacentTileOffsets[index].x, target->pos.y + gAdjacentTileOffsets[index].y); entity = tile->monster; - if ((EntityExists(entity)) && (GetEntityType(entity) == ENTITY_MONSTER)) { + if ((EntityIsValid(entity)) && (GetEntityType(entity) == ENTITY_MONSTER)) { if (!hasSynchronized) { hasSynchronized = TRUE; SetMessageArgument_2(gFormatBuffer_Monsters[0],entityInfo,0); @@ -637,7 +637,7 @@ void BadlyPoisonedStatusTarget(Entity * pokemon, Entity * target, bool8 displayM Entity *entity; s32 index; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } @@ -690,7 +690,7 @@ void BadlyPoisonedStatusTarget(Entity * pokemon, Entity * target, bool8 displayM gAdjacentTileOffsets[index].x, target->pos.y + gAdjacentTileOffsets[index].y); entity = tile->monster; - if ((EntityExists(entity)) && (GetEntityType(entity) == ENTITY_MONSTER)) { + if ((EntityIsValid(entity)) && (GetEntityType(entity) == ENTITY_MONSTER)) { if (!hasSynchronized) { hasSynchronized = TRUE; SetMessageArgument_2(gFormatBuffer_Monsters[0],entityInfo,0); @@ -715,7 +715,7 @@ void FrozenStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessage) EntityInfo *entityInfo; const Tile *tile; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } @@ -764,7 +764,7 @@ void SqueezedStatusTarget(Entity * pokemon, Entity * target, s16 param_3, bool32 s32 param_3_s32 = param_3; bool8 displayMessage_u8 = displayMessage; - if ((EntityExists(target)) && (!HasSafeguardStatus(pokemon,target,displayMessage_u8))) { + if ((EntityIsValid(target)) && (!HasSafeguardStatus(pokemon,target,displayMessage_u8))) { entityInfo = GetEntInfo(target); if (entityInfo->frozenClassStatus.status == STATUS_WRAP || entityInfo->frozenClassStatus.status == STATUS_WRAPPED) { sub_8076CB4(entityInfo->unk9C); @@ -794,7 +794,7 @@ void ImmobilizedStatusTarget(Entity * pokemon, Entity * target) { EntityInfo *entityInfo; - if ((EntityExists(target)) && (!HasSafeguardStatus(pokemon,target,TRUE))) { + if ((EntityIsValid(target)) && (!HasSafeguardStatus(pokemon,target,TRUE))) { entityInfo = GetEntInfo(target); if (entityInfo->frozenClassStatus.status == STATUS_WRAP || entityInfo->frozenClassStatus.status == STATUS_WRAPPED) { sub_8076CB4(entityInfo->unk9C); @@ -823,7 +823,7 @@ void IngrainedStatusTarget(Entity * pokemon, Entity * target) { EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); if (entityInfo->frozenClassStatus.status == STATUS_WRAP || entityInfo->frozenClassStatus.status == STATUS_WRAPPED) { sub_8076CB4(entityInfo->unk9C); @@ -850,7 +850,7 @@ void WrapTarget(Entity * pokemon, Entity * target) s32 *iVar5; EntityInfo * pokemonEntityData; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } @@ -911,7 +911,7 @@ void sub_8076CB4(s32 param_1) for(index = 0; index < DUNGEON_MAX_POKEMON; index++) { entity = gDungeon->activePokemon[index]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { entityInfo = GetEntInfo(entity); if (entityInfo->unk9C == param_1) { if ((u8)(entityInfo->frozenClassStatus.status - 3U) < 2) { @@ -931,7 +931,7 @@ void PetrifiedStatusTarget(Entity * pokemon, Entity * target) Entity * entity; s32 index; - if ((EntityExists(target)) && (!HasSafeguardStatus(pokemon,target,TRUE))) { + if ((EntityIsValid(target)) && (!HasSafeguardStatus(pokemon,target,TRUE))) { sub_8041C08(target); targetEntityInfo = GetEntInfo(target); if ((u8)(targetEntityInfo->frozenClassStatus.status - 3U) < 2) { @@ -957,7 +957,7 @@ void PetrifiedStatusTarget(Entity * pokemon, Entity * target) for(index = 0; index < MAX_TEAM_MEMBERS; index++) { entity = gDungeon->teamPokemon[index]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { entityInfo = GetEntInfo(entity); if ((entityInfo->aiTarget.aiObjective == AI_CHASE_TARGET) && (entityInfo->aiTarget.aiTarget == target)) { entityInfo->aiTarget.aiObjective = AI_STAND_STILL; @@ -977,7 +977,7 @@ void LowerAttackStageTarget(Entity * pokemon, Entity * target, s32 index, s32 de EntityInfo *entityInfo; s32 attackStage = decrement; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } if (index != STAT_STAGE_ATK) { @@ -1032,7 +1032,7 @@ void LowerDefenseStageTarget(Entity * pokemon, Entity * target, s32 index, s32 d EntityInfo *entityInfo; s32 defenseStage = decrement; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } if (index != STAT_STAGE_DEF) { @@ -1072,7 +1072,7 @@ void RaiseAttackStageTarget(Entity * pokemon, Entity * target, s32 index, s32 in EntityInfo *entityInfo; s32 attackStage = increment; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } entityInfo = GetEntInfo(target); @@ -1112,7 +1112,7 @@ void RaiseDefenseStageTarget(Entity * pokemon, Entity * target, s32 index, s32 i EntityInfo *entityInfo; s32 defenseStage = increment; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } entityInfo = GetEntInfo(target); diff --git a/src/status.c b/src/status.c index f7daa09df..f6ca6db60 100644 --- a/src/status.c +++ b/src/status.c @@ -164,7 +164,7 @@ extern void sub_80420A0(Entity *); u8 GetFlashFireStatus(Entity *pokemon) { - if (!EntityExists(pokemon) || !AbilityIsActive(pokemon, ABILITY_FLASH_FIRE)) + if (!EntityIsValid(pokemon) || !AbilityIsActive(pokemon, ABILITY_FLASH_FIRE)) { return FLASH_FIRE_STATUS_NONE; } @@ -192,7 +192,7 @@ void UpdateFlashFireBoost(Entity * pokemon, Entity *target) EntityInfo * entityInfo; s32 flashFireBoost; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); flashFireBoost = UpdateFlashFireBoost_sub(entityInfo); @@ -209,7 +209,7 @@ void ChangeAttackMultiplierTarget(Entity *pokemon, Entity *target, u32 statStage EntityInfo *entityInfo; s24_8 oldMulti; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } @@ -274,7 +274,7 @@ void ChangeDefenseMultiplierTarget(Entity *pokemon, Entity *target, u32 statStag EntityInfo *entityInfo; s24_8 oldMulti; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } @@ -324,7 +324,7 @@ void RaiseAccuracyStageTarget(Entity * pokemon, Entity * target, s32 statStage) { EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); sub_8042040(target,statStage); @@ -349,7 +349,7 @@ void LowerAccuracyStageTarget(Entity * pokemon, Entity * target, s32 statStage, { EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { if (statStage != STAT_STAGE_ACCURACY) { strcpy(gFormatBuffer_Items[0],*gUnknown_80FC090); } @@ -385,7 +385,7 @@ void CringeStatusTarget(Entity * pokemon,Entity * target, bool8 displayMessage) { EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { if (!HasSafeguardStatus(pokemon, target, displayMessage)) { if (AbilityIsActive(target, ABILITY_INNER_FOCUS)){ SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); @@ -421,7 +421,7 @@ void ParalyzeStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessag bool8 bVar6; bool8 bVar7; - if ((EntityExists(target)) && (!HasSafeguardStatus(pokemon,target,displayMessage))) { + if ((EntityIsValid(target)) && (!HasSafeguardStatus(pokemon,target,displayMessage))) { if (AbilityIsActive(target, ABILITY_LIMBER)) { SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (displayMessage) { @@ -453,7 +453,7 @@ void ParalyzeStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessag { mapTile = GetTile(target->pos.x + gAdjacentTileOffsets[index].x,target->pos.y + gAdjacentTileOffsets[index].y); mapPokemonEntity = mapTile->monster; - if ((EntityExists(mapPokemonEntity)) && (GetEntityType(mapPokemonEntity) == ENTITY_MONSTER)) { + if ((EntityIsValid(mapPokemonEntity)) && (GetEntityType(mapPokemonEntity) == ENTITY_MONSTER)) { if (!bVar7) { bVar7 = TRUE; SetMessageArgument_2(gFormatBuffer_Monsters[0],entityInfo,0); @@ -477,7 +477,7 @@ void RaiseMovementSpeedTarget(Entity * pokemon, Entity * target, s32 turns, bool s32 movSpeed_1; EntityInfo *entityInfo; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } if (turns == 0) { @@ -522,7 +522,7 @@ void LowerMovementSpeedTarget(Entity * pokemon, Entity * target, s32 levels, boo s32 movSpeed_1; EntityInfo *entityInfo; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } if (HasSafeguardStatus(pokemon,target,displayMessage)) { @@ -564,7 +564,7 @@ void ConfuseStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessage { EntityInfo *entityInfo; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } @@ -604,7 +604,7 @@ void CowerStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessage) { EntityInfo *entityInfo; - if ((EntityExists(target)) && (!HasSafeguardStatus(pokemon,target,displayMessage))) { + if ((EntityIsValid(target)) && (!HasSafeguardStatus(pokemon,target,displayMessage))) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->cringeClassStatus.status != STATUS_COWERING) { @@ -630,7 +630,7 @@ void HealTargetHP(Entity *pokemon, Entity *target, s32 param_3, s32 param_4, boo displayMessage_u8 = displayMessage; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } @@ -702,7 +702,7 @@ void HealTargetHP(Entity *pokemon, Entity *target, s32 param_3, s32 param_4, boo void HandleScannerOrb(Entity* pokemon, Entity* target) { - if (EntityExists(target)) { + if (EntityIsValid(target)) { if (GetEntInfo(target)->scanning) { TryDisplayDungeonLoggableMessage3(pokemon,target,*gUnknown_80FAEF0); // Item locations are already known } @@ -721,7 +721,7 @@ void HandleScannerOrb(Entity* pokemon, Entity* target) void HandleStairsOrb(Entity* pokemon, Entity* target) { - if (EntityExists(target)) { + if (EntityIsValid(target)) { if(GetFloorType()) { TryDisplayDungeonLoggableMessage3(pokemon,target,*gUnknown_80FAF3C); @@ -747,7 +747,7 @@ void HandleStairsOrb(Entity* pokemon, Entity* target) void HandleRadarOrb(Entity* pokemon, Entity* target) { - if (EntityExists(target)) { + if (EntityIsValid(target)) { if (GetEntInfo(target)->powerEars != 0) { TryDisplayDungeonLoggableMessage3(pokemon,target,*gUnknown_80FAFD0); } @@ -770,7 +770,7 @@ void HandleLeechSeed(Entity * pokemon, Entity * target, bool8 displayMessage) EntityInfo *entityInfo2; s32 index; - if ((EntityExists(target)) && (GetEntityType(pokemon) == ENTITY_MONSTER)) { + if ((EntityIsValid(target)) && (GetEntityType(pokemon) == ENTITY_MONSTER)) { entityInfo = GetEntInfo(target); if (pokemon == target) { pokemon = target; @@ -829,7 +829,7 @@ void sub_8078084(Entity * pokemon) for(index = 0; index < DUNGEON_MAX_POKEMON; index++) { target = gDungeon->activePokemon[index]; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo2 = GetEntInfo(target); if((u8)(entityInfo2->leechSeedClassStatus.status - 1) <= 1) { @@ -849,7 +849,7 @@ void DestinyBondStatusTarget(Entity * pokemon, Entity * target) EntityInfo *entityInfo2; s32 index; - if (((EntityExists(target)) && (GetEntityType(pokemon) == ENTITY_MONSTER)) && + if (((EntityIsValid(target)) && (GetEntityType(pokemon) == ENTITY_MONSTER)) && (GetEntityType(target) == ENTITY_MONSTER)) { entityInfo = GetEntInfo(pokemon); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],pokemon,0); @@ -886,7 +886,7 @@ void SureShotStatusTarget(Entity *pokemon, Entity * target, s32 turns) { EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->sureShotClassStatus.status != STATUS_SURE_SHOT) { @@ -906,7 +906,7 @@ void WhifferStatusTarget(Entity *pokemon, Entity * target, s32 turns) { EntityInfo *entityInfo; - if (EntityExists(target) && !HasSafeguardStatus(pokemon, target, TRUE)) { + if (EntityIsValid(target) && !HasSafeguardStatus(pokemon, target, TRUE)) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->sureShotClassStatus.status != STATUS_WHIFFER) { @@ -926,7 +926,7 @@ void FixedDamageStatusTarget(Entity *pokemon, Entity * target) { EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->sureShotClassStatus.status != STATUS_SET_DAMAGE) { @@ -946,7 +946,7 @@ void FocusEnergyStatusTarget(Entity *pokemon, Entity * target) { EntityInfo *entityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->sureShotClassStatus.status != STATUS_FOCUS_ENERGY) { @@ -971,7 +971,7 @@ void sub_80783C4(Entity * pokemon, Entity * target, bool8 param_3) ActionContainer action; s32 index; - if ((EntityExists(target)) && (!HasSafeguardStatus(pokemon, target, TRUE))) { + if ((EntityIsValid(target)) && (!HasSafeguardStatus(pokemon, target, TRUE))) { targetEntityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (targetEntityInfo->curseClassStatus.status == STATUS_DECOY) { @@ -981,7 +981,7 @@ void sub_80783C4(Entity * pokemon, Entity * target, bool8 param_3) for(index = 0; index < DUNGEON_MAX_POKEMON; index++) { entity = gDungeon->activePokemon[index]; - if ((((EntityExists(entity)) && (target != entity)) && + if ((((EntityIsValid(entity)) && (target != entity)) && (u8)(GetEntInfo(entity)->curseClassStatus.status - 2U) < 2)) { EndCurseClassStatus(pokemon,entity,STATUS_NONE); sub_803E46C(0x2a); @@ -1004,7 +1004,7 @@ void sub_80783C4(Entity * pokemon, Entity * target, bool8 param_3) for(index = 0; index < DUNGEON_MAX_POKEMON; index++) { entity2 = gDungeon->activePokemon[index]; - if (EntityExists(entity2)) { + if (EntityIsValid(entity2)) { entityInfo = GetEntInfo(entity2); entityInfo->aiTarget.aiObjective = AI_STAND_STILL; entityInfo->aiTarget.aiTarget = NULL; @@ -1029,7 +1029,7 @@ void CurseStatusTarget(Entity *pokemon, Entity * target) EntityInfo * targetEntityInfo; - if ((EntityExists(pokemon) ) && (EntityExists(target))) { + if ((EntityIsValid(pokemon) ) && (EntityIsValid(target))) { pokemonEntityData = GetEntInfo(pokemon); targetEntityInfo = GetEntInfo(target); if (MonsterIsType(pokemon, TYPE_GHOST)) { @@ -1067,13 +1067,13 @@ void SnatchStatusTarget(Entity * pokemon, Entity * target) s32 index; EntityInfo *targetEntityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { EndCurseClassStatus(pokemon,target,STATUS_SNATCH); for(index = 0; index < DUNGEON_MAX_POKEMON; index++) { entity = gDungeon->activePokemon[index]; - if ((EntityExists(entity)) && (GetEntInfo(entity)->curseClassStatus.status == STATUS_SNATCH)) { + if ((EntityIsValid(entity)) && (GetEntInfo(entity)->curseClassStatus.status == STATUS_SNATCH)) { EndCurseClassStatus(pokemon, entity, STATUS_NONE); } } @@ -1098,7 +1098,7 @@ void TauntStatusTarget(Entity * pokemon, Entity * target) { EntityInfo *entityInfo; - if ((EntityExists(target)) && (!HasSafeguardStatus(pokemon,target,TRUE))) { + if ((EntityIsValid(target)) && (!HasSafeguardStatus(pokemon,target,TRUE))) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->cringeClassStatus.status != STATUS_TAUNTED) { @@ -1118,7 +1118,7 @@ void HandleStockpile(Entity * pokemon, Entity * target) { EntityInfo *entityInfo; - if ((EntityExists(target))) { + if ((EntityIsValid(target))) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->stockpileStage < MAX_STOCKPILE_STAGE) { @@ -1139,7 +1139,7 @@ void InvisibleStatusTarget(Entity * pokemon, Entity * target) { EntityInfo * targetEntityInfo; - if (EntityExists(target)) { + if (EntityIsValid(target)) { targetEntityInfo = GetEntInfo(target); if (targetEntityInfo->invisibleClassStatus.status == STATUS_TRANSFORMED) { SendTransformEndMessage(pokemon,target); @@ -1162,7 +1162,7 @@ void PerishSongTarget(Entity * pokemon, Entity * target) { EntityInfo * entityInfo; - if (EntityExists(target) && !HasSafeguardStatus(pokemon, target, TRUE)) { + if (EntityIsValid(target) && !HasSafeguardStatus(pokemon, target, TRUE)) { nullsub_82(target); entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); @@ -1184,7 +1184,7 @@ void EncoreStatusTarget(Entity *pokemon,Entity *target) EntityInfo *EntityInfo; EntityInfo = GetEntInfo(target); - if ((EntityExists(target)) && (!HasSafeguardStatus(pokemon,target,TRUE))) { + if ((EntityIsValid(target)) && (!HasSafeguardStatus(pokemon,target,TRUE))) { for(index = 0; index < MAX_MON_MOVES; index++) { movePtr = &EntityInfo->moves.moves[index]; @@ -1215,7 +1215,7 @@ void sub_8078A58(Entity *pokemon, Entity *target, s32 param_3, s32 param_4) EntityInfo *targetInfo; FixedPoint bellyBefore; - if (!EntityExists(target)) + if (!EntityIsValid(target)) return; targetInfo = GetEntInfo(target); @@ -1268,7 +1268,7 @@ void sub_8078B5C(Entity *pokemon, Entity *target, u32 bellyIncrement, s32 maxBel FixedPoint sp_0x20; bool32 bellySame; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return; } targetInfo = GetEntInfo(target); diff --git a/src/status_actions.c b/src/status_actions.c index 39f43b6e7..c623a8a77 100644 --- a/src/status_actions.c +++ b/src/status_actions.c @@ -738,7 +738,7 @@ bool8 CleanseOrbAction(Entity * pokemon, Entity * target, Move *move, s32 param_ for(i = 0; i < MAX_TEAM_MEMBERS; i++) { Entity *entity = gDungeon->teamPokemon[i]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { Item *item = &GetEntInfo(entity)->heldItem; if (ItemExists(item) && ItemSticky(item)) { item->flags &= ~(ITEM_FLAG_STICKY); @@ -983,7 +983,7 @@ bool8 RollcallOrbAction(Entity * pokemon, Entity *target, Move *move, s32 param_ } for(index = 0; index < numPossibleTargets; index++){ targetEntity = possibleTargets[index]; - if (((EntityExists(targetEntity)) && (pokemon != targetEntity)) && + if (((EntityIsValid(targetEntity)) && (pokemon != targetEntity)) && (GetTreatmentBetweenMonsters(pokemon,targetEntity,TRUE,FALSE) == TREATMENT_TREAT_AS_ALLY)) { WarpTarget(pokemon,targetEntity,2,&pokemon->pos); foundTarget = TRUE; diff --git a/src/status_checks.c b/src/status_checks.c index 8ee12c013..27f51831e 100644 --- a/src/status_checks.c +++ b/src/status_checks.c @@ -171,7 +171,7 @@ bool8 sub_80701A4(Entity *pokemon) (pokemonInfo->bideClassStatus.moveSlot == index)) { SetMonsterActionFields(&pokemonInfo->action, ACTION_USE_MOVE_PLAYER); index_1 = index; - r7 = &pokemonInfo->action.unk4[1].actionUseIndex; + r7 = &pokemonInfo->action.actionParameters[1].actionUseIndex; if((index > 0) && (move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN)) { do { diff --git a/src/status_checks_1.c b/src/status_checks_1.c index 1b361aad2..7628f487a 100644 --- a/src/status_checks_1.c +++ b/src/status_checks_1.c @@ -32,7 +32,7 @@ s32 sub_8070828(Entity *pokemon, bool8 displayMessage) bool8 flag; flag = FALSE; - if (!EntityExists(pokemon)) { + if (!EntityIsValid(pokemon)) { return 0; } else { diff --git a/src/tile_types.c b/src/tile_types.c index c66dff5eb..ac0b9dbd4 100644 --- a/src/tile_types.c +++ b/src/tile_types.c @@ -144,7 +144,7 @@ bool8 sub_804AD34(DungeonPos *pos) for(index = 0; index < DUNGEON_MAX_POKEMON; index++) { entity = gDungeon->activePokemon[index]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { sub_806CF98(entity); } } @@ -205,7 +205,7 @@ void sub_804AE84(DungeonPos *pos) for(index = 0; index < DUNGEON_MAX_POKEMON; index++) { entity = gDungeon->activePokemon[index]; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { sub_806CF98(entity); } } diff --git a/src/trap.c b/src/trap.c index a25e2f5e1..bf54fac0f 100644 --- a/src/trap.c +++ b/src/trap.c @@ -346,7 +346,7 @@ void HandleTrap(Entity *pokemon, DungeonPos *pos, int param_3, char param_4) DealDamageToEntity(target,gSpikeTrapDmgValue,10,0x206); } } - if (EntityExists(target)) { + if (EntityIsValid(target)) { sub_8071DA4(target); } if (flag1) { diff --git a/src/trap_1.c b/src/trap_1.c index 0aa388a41..8e5aa8c2b 100644 --- a/src/trap_1.c +++ b/src/trap_1.c @@ -41,7 +41,7 @@ void SetTrap(Tile *tile, u8 id) Entity *entity; entity = tile->object; - if (EntityExists(entity)) { + if (EntityIsValid(entity)) { if (GetEntityType(entity) == ENTITY_TRAP) { trapData = GetTrapData(entity); trapData->id = id; diff --git a/src/type_effectiveness.c b/src/type_effectiveness.c index 0689a9000..e43b46c60 100644 --- a/src/type_effectiveness.c +++ b/src/type_effectiveness.c @@ -93,7 +93,7 @@ bool8 sub_806E100(s48_16 *param_1, Entity *pokemon, Entity *target, u8 type, str param_5->unkD = 0; param_5->unkE = 0; hasWonderGuard = FALSE; - if (!EntityExists(target)) { + if (!EntityIsValid(target)) { return TRUE; } else { @@ -251,7 +251,7 @@ s32 WeightWeakTypePicker(Entity *user, Entity *target, u8 moveType) u8 *targetTypes; u8 *targetType; u32 moveTypeOffset; - if (!EntityExists(target)) + if (!EntityIsValid(target)) { return 1; }