From cc1fe55866bcab9ffbb3b8a6895b7580ccbd0846 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Wed, 15 Oct 2025 21:02:29 +0200 Subject: [PATCH] dungeon entity movement --- include/dungeon_action_execution.h | 3 + include/dungeon_ai.h | 1 - include/dungeon_entity_movement.h | 13 + ld_script.ld | 4 +- src/blow_away.c | 4 +- src/dungeon_action_execution.c | 7 +- src/dungeon_ai_attack.c | 3 +- ...de_8075708.c => dungeon_entity_movement.c} | 367 ++++++++---------- src/dungeon_main.c | 4 +- src/hurl_orb.c | 4 +- src/move_orb_actions_3.c | 4 +- src/one_room_orb.c | 4 +- src/pounce_orb.c | 4 +- src/run_dungeon.c | 6 +- src/switcher_orb.c | 6 +- src/warp_target.c | 4 +- sym_ewram.txt | 2 +- 17 files changed, 203 insertions(+), 237 deletions(-) create mode 100644 include/dungeon_entity_movement.h rename src/{code_8075708.c => dungeon_entity_movement.c} (56%) diff --git a/include/dungeon_action_execution.h b/include/dungeon_action_execution.h index 530b579b4..7963bd522 100644 --- a/include/dungeon_action_execution.h +++ b/include/dungeon_action_execution.h @@ -3,6 +3,9 @@ #include "structs/dungeon_entity.h" +extern u8 gUnknown_202F32C; +extern u8 gUnknown_202F32D; + bool8 ExecuteEntityDungeonAction(Entity *entity); #endif diff --git a/include/dungeon_ai.h b/include/dungeon_ai.h index 3334419b1..bed4431c0 100644 --- a/include/dungeon_ai.h +++ b/include/dungeon_ai.h @@ -3,7 +3,6 @@ #include "structs/dungeon_entity.h" -void sub_8075900(Entity *pokemon, u8 r1); void RunMonsterAI(Entity *pokemon, u32 unused); #endif diff --git a/include/dungeon_entity_movement.h b/include/dungeon_entity_movement.h new file mode 100644 index 000000000..2efe13bc8 --- /dev/null +++ b/include/dungeon_entity_movement.h @@ -0,0 +1,13 @@ +#ifndef GUARD_DUNGEON_ENTITY_MOVEMENT_H +#define GUARD_DUNGEON_ENTITY_MOVEMENT_H + +#include "structs/dungeon_entity.h" +#include "structs/str_position.h" + +void sub_8074FB0(Entity *entity, s32 a1, DungeonPos *pos); +bool8 DisplayActions(Entity *a0); +void sub_8075680(bool8 unused); +bool8 CheckEntityTileForInteraction(Entity *entity); +void TryTriggerMonsterHouseWithMsg(Entity *pokemon, bool8 forcedMonsterHouse); + +#endif diff --git a/ld_script.ld b/ld_script.ld index 6d96517c8..121391bcf 100755 --- a/ld_script.ld +++ b/ld_script.ld @@ -247,7 +247,7 @@ SECTIONS { src/dungeon_action_execution.o(.text); src/dungeon_ai_items.o(.text); src/dungeon_turn_effects.o(.text); - src/code_8075708.o(.text); + src/dungeon_entity_movement.o(.text); src/dungeon_ai.o(.text); src/move_orb_effects_1.o(.text); src/move_orb_effects_2.o(.text); @@ -632,7 +632,7 @@ SECTIONS { src/dungeon_action_execution.o(.rodata); src/dungeon_ai_items.o(.rodata); src/dungeon_turn_effects.o(.rodata); - src/code_8075708.o(.rodata); + src/dungeon_entity_movement.o(.rodata); src/dungeon_ai.o(.rodata); src/move_orb_effects_1.o(.rodata); src/move_orb_effects_2.o(.rodata); diff --git a/src/blow_away.c b/src/blow_away.c index da8d9b948..24c0356f1 100644 --- a/src/blow_away.c +++ b/src/blow_away.c @@ -9,7 +9,7 @@ #include "dungeon_message.h" #include "code_806CD90.h" #include "structs/str_dungeon.h" -#include "dungeon_ai.h" +#include "dungeon_entity_movement.h" #include "run_dungeon.h" #include "dungeon_generation.h" #include "dungeon_logic.h" @@ -144,7 +144,7 @@ void BlowAwayTarget(Entity *pokemon, Entity *target, u32 direction) sub_807EC28(FALSE); } sub_806A5B8(target); - sub_8075900(target,gDungeon->forceMonsterHouse); + TryTriggerMonsterHouseWithMsg(target,gDungeon->forceMonsterHouse); } } } diff --git a/src/dungeon_action_execution.c b/src/dungeon_action_execution.c index 64853ee2a..4af3c08ac 100644 --- a/src/dungeon_action_execution.c +++ b/src/dungeon_action_execution.c @@ -39,6 +39,7 @@ #include "warp_target.h" #include "move_orb_effects_1.h" #include "move_orb_effects_3.h" +#include "dungeon_entity_movement.h" void sub_8075BA4(Entity *param_1, u8 param_2); void sub_804178C(u8 param_1); @@ -48,7 +49,6 @@ extern void sub_8067110(Entity *); void HandleUseMoveAIAction(Entity *target); void sub_8041888(u8 param_1); void sub_805EFB4(Entity *, u8); -void sub_8074FB0(Entity *, u8, DungeonPos *); void HandlePlaceItemAction(Entity *); void HandlePickUpPlayerAction(Entity *); void sub_8066E14(Entity * ); @@ -67,7 +67,6 @@ void sub_806A1E8(Entity *pokemon); void HandlePickUpAIAction(Entity *pokemon); void HandleThrowItemAIAction(Entity *pokemon); void HandleEatAIAction(Entity *pokemon); -u32 sub_8075818(Entity *entity);; EWRAM_DATA u8 gUnknown_202F32C = 0; EWRAM_DATA u8 gUnknown_202F32D = 0; @@ -321,7 +320,9 @@ bool8 ExecuteEntityDungeonAction(Entity *entity) } } if (bVar14) { - sub_8075818(entity); + if (CheckEntityTileForInteraction(entity)) { + // Some missing DS/Debug checks there? + } } if (EntityIsValid(entity)) { if (!sub_8044B84()) { diff --git a/src/dungeon_ai_attack.c b/src/dungeon_ai_attack.c index e3758411f..d63e340fd 100644 --- a/src/dungeon_ai_attack.c +++ b/src/dungeon_ai_attack.c @@ -36,6 +36,7 @@ #include "dungeon_items.h" #include "dungeon_kecleon_shop.h" #include "dungeon_strings.h" +#include "dungeon_entity_movement.h" #define REGULAR_ATTACK_INDEX 4 @@ -1034,7 +1035,7 @@ void HandleUseOrbAction(Entity *pokemon) } sub_806A5B8(pokemon); - sub_8075900(pokemon, gDungeon->forceMonsterHouse); + TryTriggerMonsterHouseWithMsg(pokemon, gDungeon->forceMonsterHouse); } else if (r4) sub_8044D40(&act, 0); diff --git a/src/code_8075708.c b/src/dungeon_entity_movement.c similarity index 56% rename from src/code_8075708.c rename to src/dungeon_entity_movement.c index 2c17355d9..13acae00c 100644 --- a/src/code_8075708.c +++ b/src/dungeon_entity_movement.c @@ -1,6 +1,6 @@ #include "global.h" #include "globaldata.h" -#include "dungeon_ai.h" +#include "dungeon_entity_movement.h" #include "constants/iq_skill.h" #include "constants/item.h" #include "constants/status.h" @@ -47,26 +47,28 @@ #include "dungeon_cutscene.h" #include "dungeon_monster_house.h" #include "dungeon_strings.h" +#include "dungeon_main.h" #include "warp_target.h" +#include "dungeon_action_execution.h" +#include "dungeon_tilemap.h" +#include "run_dungeon.h" -extern void sub_8073D14(Entity *); -extern void sub_8075708(Entity *entity); -extern void sub_805229C(void); -extern void sub_80420B8(Entity *pokemon); -extern void sub_8041C4C(Entity *pokemon, u32 r1); -extern void sub_805E804(void); -extern bool8 TryUseChosenMove(struct Entity *, u32, u32, u32, u32, struct Move *); -extern void nullsub_97(Entity *entity); -extern void CheckLeaderTile(void); -extern void sub_8075708(Entity *entity); -extern void TryForcedLoss(u32); -extern void sub_8075900(Entity *pokemon, u8 r1); -extern void sub_8075050(EntityInfo *info, Unk_Entity_x184 *strPtr); -extern bool8 sub_803F428(DungeonPos *pos); +static EWRAM_DATA s32 sSpeedMultiplier = 0; -extern u8 gUnknown_202F32D; +static void sub_8075050(EntityInfo *info, Unk_Entity_x184 *strPtr); +static void nullsub_97(Entity *entity); +static void TryInteractWithTile(Entity *entity); -static EWRAM_DATA s32 gUnknown_202F378 = 0; +extern void sub_8041888(u32); +extern void sub_8073D14(Entity *entity); + +static inline void SetSpeedMultiplier(void) +{ + if (gGameOptionsRef->dungeonSpeed != 0) + sSpeedMultiplier = 2; + else + sSpeedMultiplier = 1; +} void sub_8074FB0(Entity *entity, s32 a1, DungeonPos *pos) { @@ -77,11 +79,7 @@ void sub_8074FB0(Entity *entity, s32 a1, DungeonPos *pos) entityInfo->action.action = 0; return; } - - if (gGameOptionsRef->dungeonSpeed != 0) - gUnknown_202F378 = 2; - else - gUnknown_202F378 = 1; + SetSpeedMultiplier(); strPtr = &entityInfo->unk184[entityInfo->numMoveTiles]; strPtr->unk1A = 0; @@ -90,26 +88,22 @@ void sub_8074FB0(Entity *entity, s32 a1, DungeonPos *pos) strPtr->previousTargetMovePosition1.y = entity->pos.y; strPtr->previousTargetMovePosition2.x = pos->x; strPtr->previousTargetMovePosition2.y = pos->y; - strPtr->lastMoveIncrement.x = gUnknown_80F4D44[a1].x * gUnknown_202F378; - strPtr->lastMoveIncrement.y = gUnknown_80F4D44[a1].y * gUnknown_202F378; + strPtr->lastMoveIncrement.x = gUnknown_80F4D44[a1].x * sSpeedMultiplier; + strPtr->lastMoveIncrement.y = gUnknown_80F4D44[a1].y * sSpeedMultiplier; sub_8075050(entityInfo, strPtr); } -void sub_8075050(EntityInfo *info, Unk_Entity_x184 *strPtr) +static void sub_8075050(EntityInfo *info, Unk_Entity_x184 *strPtr) { s32 savedX, savedY; - if (gGameOptionsRef->dungeonSpeed != 0) - gUnknown_202F378 = 2; - else - gUnknown_202F378 = 1; - + SetSpeedMultiplier(); info->numMoveTiles++; if (info->numMoveTiles == 2) { - info->unk184[0].walkAnimFramesLeft = 24 / (gUnknown_202F378 * 2); + info->unk184[0].walkAnimFramesLeft = 24 / (sSpeedMultiplier * 2); info->unk184[0].lastMoveIncrement.x *= 2; info->unk184[0].lastMoveIncrement.y *= 2; - strPtr->walkAnimFramesLeft = 24 / (gUnknown_202F378 * 2); + strPtr->walkAnimFramesLeft = 24 / (sSpeedMultiplier * 2); strPtr->lastMoveIncrement.x *= 2; strPtr->lastMoveIncrement.y *= 2; } @@ -119,13 +113,13 @@ void sub_8075050(EntityInfo *info, Unk_Entity_x184 *strPtr) savedX = strPtr->lastMoveIncrement.x; savedY = strPtr->lastMoveIncrement.y; for (i = 0; i < 2; i++) { - info->unk184[i].walkAnimFramesLeft = 24 / (gUnknown_202F378 * 3); + info->unk184[i].walkAnimFramesLeft = 24 / (sSpeedMultiplier * 3); info->unk184[i].lastMoveIncrement.x *= 3; info->unk184[i].lastMoveIncrement.y *= 3; info->unk184[i].lastMoveIncrement.x /= 2; info->unk184[i].lastMoveIncrement.y /= 2; } - strPtr->walkAnimFramesLeft = 24 / (gUnknown_202F378 * 3); + strPtr->walkAnimFramesLeft = 24 / (sSpeedMultiplier * 3); strPtr->lastMoveIncrement.x = savedX * 3; strPtr->lastMoveIncrement.y = savedY * 3; } @@ -135,18 +129,18 @@ void sub_8075050(EntityInfo *info, Unk_Entity_x184 *strPtr) savedX = strPtr->lastMoveIncrement.x; savedY = strPtr->lastMoveIncrement.y; for (i = 0; i < 3; i++) { - info->unk184[i].walkAnimFramesLeft = 24 / (gUnknown_202F378 * 4); + info->unk184[i].walkAnimFramesLeft = 24 / (sSpeedMultiplier * 4); info->unk184[i].lastMoveIncrement.x *= 4; info->unk184[i].lastMoveIncrement.y *= 4; info->unk184[i].lastMoveIncrement.x /= 3; info->unk184[i].lastMoveIncrement.y /= 3; } - strPtr->walkAnimFramesLeft = 24 / (gUnknown_202F378 * 4); + strPtr->walkAnimFramesLeft = 24 / (sSpeedMultiplier * 4); strPtr->lastMoveIncrement.x = savedX * 4; strPtr->lastMoveIncrement.y = savedY * 4; } else { - strPtr->walkAnimFramesLeft = 24 / gUnknown_202F378; + strPtr->walkAnimFramesLeft = 24 / sSpeedMultiplier; } } @@ -159,9 +153,9 @@ bool8 DisplayActions(Entity *a0) gUnknown_202F32D = 0; if (gGameOptionsRef->dungeonSpeed != 0) - gUnknown_202F378 = 2; + sSpeedMultiplier = 2; else - gUnknown_202F378 = 1; + sSpeedMultiplier = 1; for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { Entity *mon = gDungeon->activePokemon[i]; @@ -203,7 +197,7 @@ bool8 DisplayActions(Entity *a0) gDungeon->unkB8 = a0; if (gDungeon->unk644.unk28 == 0 && r9) { sub_80526D0(0x35); - for (loop = 0; loop < 24 / gUnknown_202F378; loop++) { + for (loop = 0; loop < 24 / sSpeedMultiplier; loop++) { DungeonRunFrameActions(7); for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { Entity *mon = gDungeon->activePokemon[i]; @@ -274,7 +268,7 @@ bool8 DisplayActions(Entity *a0) CheckLeaderTile(); } else { - sub_8075708(mon); + TryInteractWithTile(mon); } if (!EntityIsValid(mon)) continue; @@ -290,7 +284,7 @@ bool8 DisplayActions(Entity *a0) EnemyEvolution(mon); sub_8046D20(); - sub_8075900(mon, gDungeon->forceMonsterHouse); + TryTriggerMonsterHouseWithMsg(mon, gDungeon->forceMonsterHouse); } if (!EntityIsValid(mon)) continue; @@ -319,95 +313,84 @@ bool8 DisplayActions(Entity *a0) return TRUE; } -void sub_8075680(void) +void sub_8075680(bool8 unused) { u32 direction; - DungeonPos *targetPos; - Entity *entity; - EntityInfo *info; - int index; + int i; - for(index = 0; index < DUNGEON_MAX_POKEMON; index++) - { - entity = gDungeon->activePokemon[index]; - if ((EntityIsValid(entity)) && (info = GetEntInfo(entity), !info->isTeamLeader)) { - targetPos = &(info->targetPos); + for (i = 0; i < DUNGEON_MAX_POKEMON; i++) { + Entity *entity = gDungeon->activePokemon[i]; + if (EntityIsValid(entity)) { + EntityInfo *info = GetEntInfo(entity); + if (!info->isTeamLeader) { + DungeonPos *targetPos = &info->targetPos; - if (targetPos->x == 0 && targetPos->y == 0) - continue; + if (targetPos->x == 0 && targetPos->y == 0) + continue; + if (targetPos->x == entity->pos.x && targetPos->y == entity->pos.y) + continue; + if (CheckVariousStatuses2(entity, TRUE)) + continue; - if (targetPos->x == entity->pos.x && targetPos->y == entity->pos.y) - continue; - - if (CheckVariousStatuses2(entity, TRUE)) - continue; - - direction = GetDirectionTowardsPosition(&entity->pos, targetPos); - info->action.direction = direction & DIRECTION_MASK; - sub_806CDD4(entity, sub_806CEBC(entity), direction); + direction = GetDirectionTowardsPosition(&entity->pos, targetPos); + info->action.direction = direction & DIRECTION_MASK; + sub_806CDD4(entity, sub_806CEBC(entity), direction); + } } } } -void nullsub_97(Entity *entity) +static void nullsub_97(Entity *entity) {} -void sub_8075708(Entity *entity) +static void TryInteractWithTile(Entity *entity) { - bool8 bVar1; - bool8 bVar2; const Tile *tile; - Trap *trapData; - Entity *trap; - EntityInfo *info; - - info = GetEntInfo(entity); - if (!EntityIsValid(entity)) { + Entity *tileEntity; + EntityInfo *info = GetEntInfo(entity); + if (!EntityIsValid(entity)) return; - } + tile = GetTileAtEntitySafe(entity); - if (((IQSkillIsEnabled(entity, IQ_SUPER_MOBILE)) && (info->invisibleClassStatus.status != STATUS_MOBILE)) && - (!HasHeldItem(entity, ITEM_MOBILE_SCARF))) { + if (IQSkillIsEnabled(entity, IQ_SUPER_MOBILE) + && info->invisibleClassStatus.status != STATUS_MOBILE + && !(HasHeldItem(entity, ITEM_MOBILE_SCARF))) + { sub_804AE84(&entity->pos); } - trap = tile->object; - if (trap == NULL) { + tileEntity = tile->object; + if (tileEntity == NULL) return; - } - switch(GetEntityType(trap)) { - case ENTITY_TRAP: - trapData = GetTrapInfo(trap); - bVar1 = FALSE; - bVar2 = FALSE; - if ((IQSkillIsEnabled(entity, IQ_TRAP_SEER)) && (!trap->isVisible)) { - trap->isVisible = TRUE; + switch (GetEntityType(tileEntity)) { + case ENTITY_TRAP: { + Trap *trapData = GetTrapInfo(tileEntity); + bool8 trigger = FALSE; + bool8 onlyMakeVisible = FALSE; + if (IQSkillIsEnabled(entity, IQ_TRAP_SEER) && !tileEntity->isVisible) { + tileEntity->isVisible = TRUE; UpdateTrapsVisibility(); - bVar2 = TRUE; + onlyMakeVisible = TRUE; } if (trapData->unk1 == 0) { - if (!trap->isVisible) goto _080757EC; - if (info->isNotTeamMember) goto _080757EC; + if (tileEntity->isVisible && !info->isNotTeamMember) + trigger = TRUE; } - else { - if (trapData->unk1 == 1) { - if (!info->isNotTeamMember) goto _080757EC; - goto _ret; - } - if ((trapData->unk1 == 2) && (!info->isNotTeamMember)) { - bVar1 = TRUE; - } - _080757EC: - if (!bVar1) { - return; - } + else if (trapData->unk1 == 1) { + if (info->isNotTeamMember) + trigger = TRUE; } - _ret: - if (!bVar2) { + else if (trapData->unk1 == 2) { + if (!info->isNotTeamMember) + trigger = TRUE; + } + + if (trigger && !onlyMakeVisible) { TryTriggerTrap(entity, &entity->pos, 0, 1); } break; + } case ENTITY_ITEM: sub_8073D14(entity); break; @@ -419,119 +402,85 @@ void sub_8075708(Entity *entity) } } -u32 sub_8075818(Entity *entity) +bool8 CheckEntityTileForInteraction(Entity *entity) { - const Tile *tile; - EntityInfo *entityInfo; Entity *subEntity; - Item *item; - Trap *trapData; - u8 r1; + const Tile *tile; + EntityInfo *entityInfo = GetEntInfo(entity); + if (!EntityIsValid(entity)) + return FALSE; - entityInfo = GetEntInfo(entity); - if(EntityIsValid(entity)) - { - tile = GetTileAtEntitySafe(entity); - if(IQSkillIsEnabled(entity, IQ_SUPER_MOBILE)) - if(!(tile->terrainFlags & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY))) - return 1; - subEntity = tile->object; - if(subEntity != NULL) - { - switch(GetEntityType(subEntity)) - { - case ENTITY_NOTHING: - case ENTITY_MONSTER: - case ENTITY_UNK_4: - case ENTITY_UNK_5: - break; - case ENTITY_TRAP: - trapData = GetTrapInfo(subEntity); - r1 = 0; - if(trapData->unk1 == 0) - { - if(!subEntity->isVisible || entityInfo->isNotTeamMember) - goto flag_check; - else - goto error; - } - else if(trapData->unk1 == 1) - { - if(!entityInfo->isNotTeamMember) - goto flag_check; - else - goto error; - } - else if(trapData->unk1 == 2) - { - if(!entityInfo->isNotTeamMember) - r1 = 1; - } -flag_check: - if(r1 == 0) - break; - else - goto error; - case ENTITY_ITEM: - if(!entityInfo->isTeamLeader) - { - if(!(entityInfo->heldItem.flags & ITEM_FLAG_EXISTS)) - { - if(!(tile->terrainFlags & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY))) - { - if(entityInfo->isNotTeamMember) - break; - else - { - item = GetItemInfo(subEntity); - if(!(item->flags & ITEM_FLAG_IN_SHOP)) - { - return 1; - } - } - } - else - { - item = GetItemInfo(subEntity); - if(!(item->flags & ITEM_FLAG_IN_SHOP)) - { -error: - return 1; - } - } - } - } - break; + tile = GetTileAtEntitySafe(entity); + if (IQSkillIsEnabled(entity, IQ_SUPER_MOBILE) && GetTerrainType(tile) == TERRAIN_TYPE_WALL) + return TRUE; + subEntity = tile->object; + if (subEntity == NULL) + return FALSE; + + switch (GetEntityType(subEntity)) { + case ENTITY_TRAP: { + Trap *trapData = GetTrapInfo(subEntity); + bool8 flag = FALSE; + + if (trapData->unk1 == 0) { + if (subEntity->isVisible && !entityInfo->isNotTeamMember) + flag = TRUE; } + else if (trapData->unk1 == 1) { + if (entityInfo->isNotTeamMember) + flag = TRUE; + } + else if (trapData->unk1 == 2) { + if (!entityInfo->isNotTeamMember) + flag = TRUE; + } + + if (flag) + return TRUE; + + break; } - } - return 0; -} - -extern void sub_8041888(u32); - -void sub_8075900(Entity *pokemon, u8 r1) -{ - if(EntityIsValid(pokemon)) - { - if(!GetEntInfo(pokemon)->isNotTeamMember) - { - if(!IsFloorOver()) - { - if(!gDungeon->unk644.monsterHouseTriggered) - { - if((GetTileAtEntitySafe(pokemon)->terrainFlags & TERRAIN_TYPE_IN_MONSTER_HOUSE)) - { - // It's a monster house! - LogMessageByIdWithPopupCheckUser(GetLeader(), gPtrItsaMonsterHouseMessage); - gDungeon->unk644.monsterHouseTriggeredEvent = TRUE; - TriggerMonsterHouse(pokemon, r1); - sub_8041888(0); - if(sub_803F428(&pokemon->pos)) - sub_803E708(0x78, 0x39); + case ENTITY_ITEM: + if (!entityInfo->isTeamLeader && !ItemExists(&entityInfo->heldItem)) { + if (GetTerrainType(tile) == TERRAIN_TYPE_WALL) { + if (!entityInfo->isNotTeamMember) { + Item *item = GetItemInfo(subEntity); + if (!(item->flags & ITEM_FLAG_IN_SHOP)) + return TRUE; } } + else { + Item *item = GetItemInfo(subEntity); + if (!(item->flags & ITEM_FLAG_IN_SHOP)) + return TRUE; + } + } - } + break; + case ENTITY_NOTHING: + case ENTITY_MONSTER: + case ENTITY_UNK_4: + case ENTITY_UNK_5: + break; + } + + return FALSE; +} + +void TryTriggerMonsterHouseWithMsg(Entity *pokemon, bool8 forcedMonsterHouse) +{ + if (EntityIsValid(pokemon) + && !GetEntInfo(pokemon)->isNotTeamMember + && !IsFloorOver() + && !gDungeon->unk644.monsterHouseTriggered + && (GetTileAtEntitySafe(pokemon)->terrainFlags & TERRAIN_TYPE_IN_MONSTER_HOUSE)) + { + // It's a monster house! + LogMessageByIdWithPopupCheckUser(GetLeader(), gPtrItsaMonsterHouseMessage); + gDungeon->unk644.monsterHouseTriggeredEvent = TRUE; + TriggerMonsterHouse(pokemon, forcedMonsterHouse); + sub_8041888(0); + if (sub_803F428(&pokemon->pos)) + sub_803E708(0x78, 0x39); } } diff --git a/src/dungeon_main.c b/src/dungeon_main.c index 71a40a2e6..9e71efbba 100644 --- a/src/dungeon_main.c +++ b/src/dungeon_main.c @@ -59,12 +59,12 @@ #include "dungeon_engine.h" #include "dungeon_item_action.h" #include "dungeon_strings.h" +#include "dungeon_entity_movement.h" extern void HandleUnsetItemAction(Entity *,bool8); extern void TryTriggerTrap(Entity *pokemon, DungeonPos *pos, int param_3, char param_4); void TryPointCameraToMonster(Entity *a0, u8 a1); bool8 sub_80701A4(Entity *a0); -void sub_8075680(u32); void ClearUnpaidFlagFromAllItems(void); void sub_806A914(u8 a0, u8 a1, u8 a2); u16 GetLeaderActionId(void); @@ -175,7 +175,7 @@ void DungeonHandlePlayerInput(void) } if (var_38 != 0 && --var_38 == 0) { - sub_8075680(0); + sub_8075680(FALSE); } TryCreateModeArrows(leader); diff --git a/src/hurl_orb.c b/src/hurl_orb.c index 323de2c3e..07cc32e51 100644 --- a/src/hurl_orb.c +++ b/src/hurl_orb.c @@ -13,7 +13,7 @@ #include "constants/type.h" #include "constants/weather.h" #include "dungeon_info.h" -#include "dungeon_ai.h" +#include "dungeon_entity_movement.h" #include "dungeon_config.h" #include "dungeon_generation.h" #include "dungeon_items.h" @@ -243,6 +243,6 @@ static void sub_807F9BC(Entity *entity) sub_807EC28(FALSE); } sub_806A5B8(entity); - sub_8075900(entity, gDungeon->forceMonsterHouse); + TryTriggerMonsterHouseWithMsg(entity, gDungeon->forceMonsterHouse); } } diff --git a/src/move_orb_actions_3.c b/src/move_orb_actions_3.c index 11c664134..85ae35a1e 100644 --- a/src/move_orb_actions_3.c +++ b/src/move_orb_actions_3.c @@ -13,7 +13,7 @@ #include "constants/targeting.h" #include "constants/type.h" #include "constants/weather.h" -#include "dungeon_ai.h" +#include "dungeon_entity_movement.h" #include "dungeon_logic.h" #include "dungeon_config.h" #include "run_dungeon.h" @@ -655,7 +655,7 @@ _0805AA5E: sub_807EC28(FALSE); } sub_806A5B8(target); - sub_8075900(target,gDungeon->forceMonsterHouse); + TryTriggerMonsterHouseWithMsg(target,gDungeon->forceMonsterHouse); } } return TRUE; diff --git a/src/one_room_orb.c b/src/one_room_orb.c index 6bb5fd6cb..1724aee56 100644 --- a/src/one_room_orb.c +++ b/src/one_room_orb.c @@ -7,7 +7,7 @@ #include "dungeon_message.h" #include "code_806CD90.h" #include "structs/str_dungeon.h" -#include "dungeon_ai.h" +#include "dungeon_entity_movement.h" #include "run_dungeon.h" #include "dungeon_generation.h" #include "dungeon_logic.h" @@ -132,7 +132,7 @@ void HandleOneRoomOrb(Entity *pokemon, Entity *target) UpdateTrapsVisibility(); LogMessageByIdWithPopupCheckUser(pokemon,gUnknown_80FD3A0); sub_803E708(0x28,0x2b); - sub_8075900(pokemon,1); + TryTriggerMonsterHouseWithMsg(pokemon,1); for(index = 0; index < DUNGEON_MAX_POKEMON; index++) { entity = gDungeon->activePokemon[index]; diff --git a/src/pounce_orb.c b/src/pounce_orb.c index 62ba8bd50..74e180569 100644 --- a/src/pounce_orb.c +++ b/src/pounce_orb.c @@ -7,7 +7,7 @@ #include "dungeon_message.h" #include "code_806CD90.h" #include "structs/str_dungeon.h" -#include "dungeon_ai.h" +#include "dungeon_entity_movement.h" #include "run_dungeon.h" #include "dungeon_generation.h" #include "dungeon_logic.h" @@ -83,6 +83,6 @@ void HandlePounceOrb(Entity *pokemon, Entity *target, u8 r2) } sub_806A5B8(target); - sub_8075900(target, gDungeon->forceMonsterHouse); + TryTriggerMonsterHouseWithMsg(target, gDungeon->forceMonsterHouse); } } diff --git a/src/run_dungeon.c b/src/run_dungeon.c index 4ebb24a4c..9c9e09348 100644 --- a/src/run_dungeon.c +++ b/src/run_dungeon.c @@ -23,7 +23,7 @@ #include "cpu.h" #include "dungeon_8083AB0.h" #include "dungeon_info.h" -#include "dungeon_ai.h" +#include "dungeon_entity_movement.h" #include "dungeon_config.h" #include "dungeon_engine.h" #include "dungeon_generation.h" @@ -58,6 +58,7 @@ #include "dungeon_cleared_window.h" #include "dungeon_cutscene.h" #include "dungeon_mon_spawn.h" +#include "dungeon_action_execution.h" EWRAM_INIT struct UnkStruct_203B414 *gUnknown_203B414 = NULL; EWRAM_INIT Dungeon *gDungeon = NULL; @@ -90,7 +91,6 @@ extern bool8 TryForcedLoss(bool8); extern void sub_806A914(bool8 a0, bool8 a1, bool8 showRunAwayEffect); extern void sub_8042B0C(Entity *); -extern u8 gUnknown_202F32C; extern u8 gUnknown_202F1A8; void EnforceMaxItemsAndMoney(void); @@ -453,7 +453,7 @@ void RunDungeon_Async(DungeonSetupStruct *setupPtr) } else { sub_80427AC(); - sub_8075900(GetLeader(), gDungeon->forceMonsterHouse); + TryTriggerMonsterHouseWithMsg(GetLeader(), gDungeon->forceMonsterHouse); sub_807EAA0(1, 0); } diff --git a/src/switcher_orb.c b/src/switcher_orb.c index e8977836a..87fc10f49 100644 --- a/src/switcher_orb.c +++ b/src/switcher_orb.c @@ -7,7 +7,7 @@ #include "dungeon_message.h" #include "code_806CD90.h" #include "structs/str_dungeon.h" -#include "dungeon_ai.h" +#include "dungeon_entity_movement.h" #include "run_dungeon.h" #include "dungeon_generation.h" #include "dungeon_logic.h" @@ -62,7 +62,7 @@ void HandleSwitcherOrb(Entity *pokemon, Entity *target, bool8 unused) sub_807EC28(FALSE); } sub_806A5B8(pokemon); - sub_8075900(pokemon,gDungeon->forceMonsterHouse); + TryTriggerMonsterHouseWithMsg(pokemon,gDungeon->forceMonsterHouse); } if (EntityIsValid(target)) { @@ -71,7 +71,7 @@ void HandleSwitcherOrb(Entity *pokemon, Entity *target, bool8 unused) sub_807EC28(FALSE); } sub_806A5B8(target); - sub_8075900(target,gDungeon->forceMonsterHouse); + TryTriggerMonsterHouseWithMsg(target,gDungeon->forceMonsterHouse); } } } diff --git a/src/warp_target.c b/src/warp_target.c index 1b0f4cf1e..29b4c6068 100644 --- a/src/warp_target.c +++ b/src/warp_target.c @@ -7,7 +7,7 @@ #include "dungeon_message.h" #include "code_806CD90.h" #include "structs/str_dungeon.h" -#include "dungeon_ai.h" +#include "dungeon_entity_movement.h" #include "run_dungeon.h" #include "dungeon_generation.h" #include "dungeon_logic.h" @@ -138,5 +138,5 @@ void WarpTarget(Entity *pokemon, Entity *target, u32 param_3, DungeonPos *pos) sub_807EC28(0); } sub_806A5B8(target); - sub_8075900(target,gDungeon->forceMonsterHouse); + TryTriggerMonsterHouseWithMsg(target,gDungeon->forceMonsterHouse); } diff --git a/sym_ewram.txt b/sym_ewram.txt index 97a795918..aa8801909 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -55,7 +55,7 @@ .include "src/dungeon_leveling.o" .include "src/dungeon_action_execution.o" .include "src/dungeon_ai_items.o" - .include "src/code_8075708.o" + .include "src/dungeon_entity_movement.o" .space 4 .include "src/dungeon_ai_attack.o" .include "src/dungeon_cutscene.o"