From 5929e49b7237271a1f4b2b62f29f5082cc3c30a8 Mon Sep 17 00:00:00 2001 From: z64a <53960937+z64a@users.noreply.github.com> Date: Mon, 30 Sep 2024 22:50:46 -0400 Subject: [PATCH] isBattle refactor (#1211) --- include/common_structs.h | 2 +- include/dead.h | 2 +- include/enums.h | 24 ++++--- include/functions.h | 2 +- include/npc.h | 2 +- src/111f0_len_860.c | 6 +- src/23680.c | 65 ++++++++++--------- src/25AF0.c | 2 +- src/77480.c | 4 +- src/8a860_len_3f30.c | 2 +- src/animator.c | 22 +++---- src/audio/sfx.c | 6 +- src/battle/battle.c | 2 +- src/effects.c | 10 +-- src/effects/fire_breath.c | 2 +- src/effects/lightning.c | 2 +- src/effects/lightning_bolt.c | 2 +- src/effects/star.c | 2 +- src/encounter_api.c | 6 +- src/entity.c | 30 ++++----- src/entity_model.c | 18 ++--- src/evt/cam_api.c | 2 +- src/evt/model_api.c | 6 +- src/evt/script_list.c | 4 +- src/evt/virtual_entity.c | 6 +- src/heap.c | 8 +-- src/hud_element.c | 22 +++---- src/imgfx.c | 6 +- src/inventory.c | 18 ++--- src/item_entity.c | 16 ++--- src/model.c | 6 +- src/npc.c | 6 +- src/screen_overlays.c | 4 +- src/sprite.c | 6 +- src/sprite_shading.c | 2 +- src/state_battle.c | 4 +- src/state_demo.c | 2 +- src/state_file_select.c | 4 +- src/state_intro.c | 2 +- src/state_pause.c | 4 +- src/state_startup.c | 2 +- src/state_title_screen.c | 2 +- src/status_icons.c | 41 +++++++----- src/trigger.c | 4 +- src/worker.c | 12 ++-- src/world/action/misc.c | 2 +- src/world/area_dgb/dgb_08/npc.c | 2 +- src/world/area_dro/dro_02/npc.c | 2 +- src/world/area_gv/gv_01/main.c | 2 +- src/world/area_omo/omo_09/npc.c | 2 +- src/world/common/enemy/ai/AvoidPlayerAI.inc.c | 6 +- src/world/common/enemy/ai/BulletBillAI.inc.c | 10 +-- src/world/common/enemy/ai/CleftAI.inc.c | 6 +- .../common/enemy/ai/ClubbaNappingAI.inc.c | 6 +- .../common/enemy/ai/ClubbaPatrolAI.inc.c | 6 +- src/world/common/enemy/ai/FlyingAI.inc.c | 10 +-- .../common/enemy/ai/FlyingMagikoopaAI.inc.c | 6 +- .../common/enemy/ai/FlyingNoAttackAI.inc.c | 4 +- src/world/common/enemy/ai/GrooveGuyAI.inc.c | 6 +- src/world/common/enemy/ai/GuardAI.inc.c | 6 +- src/world/common/enemy/ai/HoppingAI.inc.c | 8 +-- src/world/common/enemy/ai/KoopaPatrolAI.inc.c | 8 +-- src/world/common/enemy/ai/LakituAI.inc.c | 8 +-- src/world/common/enemy/ai/MagikoopaAI.inc.c | 6 +- .../common/enemy/ai/MagikoopaSpellAI.inc.c | 6 +- src/world/common/enemy/ai/MeleeHitbox.inc.c | 6 +- src/world/common/enemy/ai/MontyMoleAI.inc.c | 22 ++++--- src/world/common/enemy/ai/ParatroopaAI.inc.c | 4 +- .../common/enemy/ai/PatrolNoAttackAI.inc.c | 6 +- .../common/enemy/ai/PiranhaPlantAI.inc.c | 8 +-- .../common/enemy/ai/ProjectileHitbox.inc.c | 6 +- .../common/enemy/ai/RangedAttackAI.inc.c | 8 +-- .../common/enemy/ai/ShyGuyPatrolAI.inc.c | 6 +- .../common/enemy/ai/ShyGuyWanderAI.inc.c | 6 +- src/world/common/enemy/ai/SpearGuyAI.inc.c | 6 +- src/world/common/enemy/ai/SpinyAI.inc.c | 6 +- .../common/enemy/ai/States_PatrolAI.inc.c | 2 +- src/world/common/enemy/ai/SwooperAI.inc.c | 6 +- src/world/common/enemy/ai/TackleAI.inc.c | 8 +-- src/world/common/enemy/ai/WanderMeleeAI.inc.c | 6 +- tools/ignored_funcs.txt | 2 +- ver/pal/undefined_syms.txt | 2 +- ver/us/symbol_addrs.txt | 2 +- ver/us/undefined_syms.txt | 2 +- 84 files changed, 326 insertions(+), 302 deletions(-) diff --git a/include/common_structs.h b/include/common_structs.h index c9f0951e51..170f0e1f1e 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -1427,7 +1427,7 @@ typedef struct GameStatus { /* 0x06A */ s8 demoStickX; /* 0x06B */ s8 demoStickY; /* 0x06C */ s32 mainScriptID; - /* 0x070 */ s8 isBattle; + /* 0x070 */ s8 context; /* 0x071 */ s8 demoState; // see DemoState enum /* 0x072 */ s8 nextDemoScene; /* which part of the demo to play next */ /* 0x073 */ u8 contBitPattern; diff --git a/include/dead.h b/include/dead.h index d416b0df96..49a4dee21f 100644 --- a/include/dead.h +++ b/include/dead.h @@ -26,7 +26,7 @@ #define cos_deg dead_cos_deg #define sin_cos_deg dead_sin_cos_deg #define gPlayerStatus dead_gPlayerStatus -#define is_point_within_region dead_is_point_within_region +#define is_point_outside_territory dead_is_point_outside_territory #define npc_raycast_down_sides dead_npc_raycast_down_sides #define basic_ai_check_player_dist dead_basic_ai_check_player_dist #define fx_emote dead_fx_emote diff --git a/include/enums.h b/include/enums.h index a6b91d199d..9d83dfeb1e 100644 --- a/include/enums.h +++ b/include/enums.h @@ -3526,6 +3526,12 @@ enum EffectGfxDataFlags { #include "move_enum.h" +enum GameContext { + CONTEXT_WORLD = 0, + CONTEXT_BATTLE = 1, + CONTEXT_PAUSE = 2, +}; + enum DemoState { DEMO_STATE_NONE = 0, DEMO_STATE_ACTIVE = 1, @@ -4556,14 +4562,14 @@ enum EnemyFlags { // used with enemy->aiFlags enum EnemyAIFlags { - ENEMY_AI_FLAG_1 = 0x00000001, - ENEMY_AI_FLAG_2 = 0x00000002, // do not move; do not sense player - ENEMY_AI_FLAG_SUSPEND = 0x00000004, - ENEMY_AI_FLAG_8 = 0x00000008, - ENEMY_AI_FLAG_10 = 0x00000010, - ENEMY_AI_FLAG_20 = 0x00000020, - ENEMY_AI_FLAG_40 = 0x00000040, - ENEMY_AI_FLAG_80 = 0x00000080, + AI_FLAG_1 = 0x00000001, + AI_FLAG_CANT_DETECT_PLAYER = 0x00000002, + AI_FLAG_SUSPEND = 0x00000004, + AI_FLAG_SKIP_EMOTE_AFTER_FLEE = 0x00000008, + AI_FLAG_SKIP_IDLE_ANIM_AFTER_FLEE = 0x00000010, + AI_FLAG_OUTSIDE_TERRITORY = 0x00000020, + AI_FLAG_NEEDS_HEADING = 0x00000040, + AI_FLAG_80 = 0x00000080, }; enum EnemyAIStates { @@ -4613,7 +4619,7 @@ enum EnemyDetectFlags { AI_DETECT_FLAG_8 = 0x08, }; -enum EnemyTerritoryFlags { +enum TerritoryFlags { AI_TERRITORY_IGNORE_HIDING = 0x01, // bow and sushi dont prevent enemy detection AI_TERRITORY_IGNORE_ELEVATION = 0x02, // vertical size of detection volume is ignored }; diff --git a/include/functions.h b/include/functions.h index ef68443c93..95c2067405 100644 --- a/include/functions.h +++ b/include/functions.h @@ -414,7 +414,7 @@ s32 suspend_all_script(s32 id); s32 resume_all_script(s32 id); s32 create_shadow_type(s32 type, f32 x, f32 y, f32 z); -s32 is_point_within_region(s32 shape, f32 pointX, f32 pointY, f32 centerX, f32 centerY, f32 sizeX, f32 sizeZ); +b32 is_point_outside_territory(s32 shape, f32 pointX, f32 pointY, f32 centerX, f32 centerY, f32 sizeX, f32 sizeZ); PlayerData* get_player_data(void); b32 npc_raycast_down_around(s32, f32*, f32*, f32*, f32*, f32, f32); diff --git a/include/npc.h b/include/npc.h index 3c3e58dcf4..c97a87f55a 100644 --- a/include/npc.h +++ b/include/npc.h @@ -424,7 +424,7 @@ extern EncounterStatus gCurrentEncounter; #endif -s32 basic_ai_check_player_dist(EnemyDetectVolume* arg0, Enemy* arg1, f32 arg2, f32 arg3, s8 arg4); +b32 basic_ai_check_player_dist(EnemyDetectVolume* arg0, Enemy* arg1, f32 arg2, f32 arg3, b8 arg4); /// The default Npc::onUpdate and Npc::onRender callback. void STUB_npc_callback(Npc*); diff --git a/src/111f0_len_860.c b/src/111f0_len_860.c index 398134d272..e40213da4e 100644 --- a/src/111f0_len_860.c +++ b/src/111f0_len_860.c @@ -51,7 +51,7 @@ void state_step_enter_world(void) { break; } - gGameStatusPtr->isBattle = FALSE; + gGameStatusPtr->context = CONTEXT_WORLD; gGameStatusPtr->debugScripts = DEBUG_SCRIPTS_NONE; if (!gLoadedFromFileSelect) { @@ -155,7 +155,7 @@ void state_step_change_map(void) { if (gMapTransitionStateTime != 0) { gMapTransitionStateTime--; } else { - gGameStatusPtr->isBattle = FALSE; + gGameStatusPtr->context = CONTEXT_WORLD; gGameStatusPtr->debugScripts = DEBUG_SCRIPTS_NONE; load_map_by_IDs(gGameStatusPtr->areaID, gGameStatusPtr->mapID, LOAD_FROM_MAP); set_time_freeze_mode(TIME_FREEZE_NORMAL); @@ -230,7 +230,7 @@ void state_step_game_over(void) { if (gMapTransitionStateTime != 0) { gMapTransitionStateTime--; } else { - gGameStatusPtr->isBattle = FALSE; + gGameStatusPtr->context = CONTEXT_WORLD; gGameStatusPtr->debugScripts = DEBUG_SCRIPTS_NONE; load_map_by_IDs(gGameStatusPtr->areaID, gGameStatusPtr->mapID, LOAD_FROM_MAP); nuContRmbForceStopEnd(); diff --git a/src/23680.c b/src/23680.c index dd88ff65a6..85f94c3287 100644 --- a/src/23680.c +++ b/src/23680.c @@ -295,16 +295,16 @@ void spawn_drops(Enemy* enemy) { s32 get_coin_drop_amount(Enemy* enemy) { EncounterStatus* currentEncounter = &gCurrentEncounter; EnemyDrops* enemyDrops = enemy->drops; - s32 maxCoinBonus = enemyDrops->maxCoinBonus; + s32 max = enemyDrops->maxCoinBonus; s32 amt = enemyDrops->minCoinBonus; s32 minTemp = enemyDrops->minCoinBonus; - if (maxCoinBonus < amt) { + if (max < amt) { amt = enemyDrops->maxCoinBonus; - maxCoinBonus = enemyDrops->minCoinBonus; + max = enemyDrops->minCoinBonus; } - minTemp = maxCoinBonus - amt; + minTemp = max - amt; if ((amt < 0) || (minTemp != 0)) { amt = rand_int(minTemp) - -amt; } @@ -392,24 +392,24 @@ s32 func_80048F0C(void) { return 0; } -s32 is_point_within_region(s32 shape, f32 pointX, f32 pointY, f32 centerX, f32 centerY, f32 sizeX, f32 sizeZ) { +b32 is_point_outside_territory(s32 shape, f32 centerX, f32 centerZ, f32 pointX, f32 pointZ, f32 sizeX, f32 sizeZ) { f32 dist1; f32 dist2; switch (shape) { - case 0: - dist1 = dist2D(pointX, pointY, centerX, centerY); + case SHAPE_CYLINDER: + dist1 = dist2D(centerX, centerZ, pointX, pointZ); return (sizeX < dist1); - case 1: - dist1 = dist2D(pointX, 0, centerX, 0); - dist2 = dist2D(0, pointY, 0, centerY); + case SHAPE_RECT: + dist1 = dist2D(centerX, 0, pointX, 0); + dist2 = dist2D(0, centerZ, 0, pointZ); return ((sizeX < dist1) || (sizeZ < dist2)); default: return FALSE; } } -s32 basic_ai_check_player_dist(EnemyDetectVolume* territory, Enemy* enemy, f32 radius, f32 fwdPosOffset, s8 useWorldYaw) { +b32 basic_ai_check_player_dist(EnemyDetectVolume* territory, Enemy* enemy, f32 radius, f32 fwdPosOffset, b8 useWorldYaw) { Npc* npc = get_npc_unsafe(enemy->npcID); PlayerStatus* playerStatus = &gPlayerStatus; PartnerStatus* partnerStatus; @@ -417,7 +417,7 @@ s32 basic_ai_check_player_dist(EnemyDetectVolume* territory, Enemy* enemy, f32 r f32 dist; s32 skipCheckForPlayer; - if (enemy->aiFlags & ENEMY_AI_FLAG_2) { + if (enemy->aiFlags & AI_FLAG_CANT_DETECT_PLAYER) { return FALSE; } @@ -441,7 +441,7 @@ s32 basic_ai_check_player_dist(EnemyDetectVolume* territory, Enemy* enemy, f32 r return FALSE; } - if (territory->sizeX | territory->sizeZ && is_point_within_region(territory->shape, + if (territory->sizeX | territory->sizeZ && is_point_outside_territory(territory->shape, territory->pointX, territory->pointZ, playerStatus->pos.x, playerStatus->pos.z, territory->sizeX, territory->sizeZ)) { @@ -563,8 +563,8 @@ void basic_ai_wander_init(Evt* script, MobileAISettings* npcAISettings, EnemyDet npc->moveSpeed = enemy->territory->wander.moveSpeedOverride / 32767.0; } - enemy->aiFlags &= ~ENEMY_AI_FLAG_40; - enemy->aiFlags &= ~ENEMY_AI_FLAG_20; + enemy->aiFlags &= ~AI_FLAG_NEEDS_HEADING; + enemy->aiFlags &= ~AI_FLAG_OUTSIDE_TERRITORY; script->AI_TEMP_STATE = AI_STATE_WANDER; } @@ -576,6 +576,7 @@ void basic_ai_wander(Evt* script, MobileAISettings* aiSettings, EnemyDetectVolum EffectInstance* sp34; f32 yaw; + // search for the player if (aiSettings->playerSearchInterval >= 0) { if (script->functionTemp[1] <= 0) { script->functionTemp[1] = aiSettings->playerSearchInterval; @@ -588,8 +589,8 @@ void basic_ai_wander(Evt* script, MobileAISettings* aiSettings, EnemyDetectVolum npc->yaw = yaw; ai_enemy_play_sound(npc, SOUND_AI_ALERT_A, SOUND_PARAM_MORE_QUIET); fx_emote(EMOTE_EXCLAMATION, npc, 0, npc->collisionHeight, 1.0f, 2.0f, -20.0f, 15, &sp34); - enemy->aiFlags &= ~ENEMY_AI_FLAG_40; - enemy->aiFlags &= ~ENEMY_AI_FLAG_20; + enemy->aiFlags &= ~AI_FLAG_NEEDS_HEADING; + enemy->aiFlags &= ~AI_FLAG_OUTSIDE_TERRITORY; if (enemy->npcSettings->actionFlags & AI_ACTION_JUMP_WHEN_SEE_PLAYER) { script->AI_TEMP_STATE = AI_STATE_ALERT_INIT; @@ -603,37 +604,39 @@ void basic_ai_wander(Evt* script, MobileAISettings* aiSettings, EnemyDetectVolum script->functionTemp[1]--; } - // check if the wander we've reached the boundary of the territory - if (is_point_within_region(enemy->territory->wander.wanderShape, + // check if we've wandered beyond the boundary of the territory + if (is_point_outside_territory(enemy->territory->wander.wanderShape, enemy->territory->wander.centerPos.x, enemy->territory->wander.centerPos.z, npc->pos.x, npc->pos.z, enemy->territory->wander.wanderSize.x, enemy->territory->wander.wanderSize.z) - && npc->moveSpeed < dist2D(enemy->territory->wander.centerPos.x, enemy->territory->wander.centerPos.z, npc->pos.x, npc->pos.z)) { - if (!(enemy->aiFlags & ENEMY_AI_FLAG_20)) { - enemy->aiFlags |= (ENEMY_AI_FLAG_20 | ENEMY_AI_FLAG_40); + && npc->moveSpeed < dist2D(enemy->territory->wander.centerPos.x, enemy->territory->wander.centerPos.z, npc->pos.x, npc->pos.z) + ) { + if (!(enemy->aiFlags & AI_FLAG_OUTSIDE_TERRITORY)) { + enemy->aiFlags |= (AI_FLAG_OUTSIDE_TERRITORY | AI_FLAG_NEEDS_HEADING); } - if (enemy->aiFlags & ENEMY_AI_FLAG_40) { + if (enemy->aiFlags & AI_FLAG_NEEDS_HEADING) { npc->yaw = clamp_angle(atan2(npc->pos.x, npc->pos.z, enemy->territory->wander.centerPos.x, enemy->territory->wander.centerPos.z)); - enemy->aiFlags &= ~ENEMY_AI_FLAG_40; + enemy->aiFlags &= ~AI_FLAG_NEEDS_HEADING; } + // if current heading is deflected by a wall, recalculate yaw to continue pursuing centerPos x = npc->pos.x; y = npc->pos.y; z = npc->pos.z; if (npc_test_move_simple_with_slipping(npc->collisionChannel, &x, &y, &z, 2.0 * npc->moveSpeed, npc->yaw, npc->collisionHeight, npc->collisionDiameter)) { yaw = clamp_angle(atan2(npc->pos.x, npc->pos.z, enemy->territory->wander.centerPos.x, enemy->territory->wander.centerPos.z)); - enemy->aiFlags &= ~ENEMY_AI_FLAG_40; + enemy->aiFlags &= ~AI_FLAG_NEEDS_HEADING; ai_check_fwd_collisions(npc, 5.0f, &yaw, NULL, NULL, NULL); npc->yaw = yaw; } stillWithinTerritory = TRUE; - } else if (enemy->aiFlags & ENEMY_AI_FLAG_20) { - enemy->aiFlags &= ~ENEMY_AI_FLAG_20; - enemy->aiFlags &= ~ENEMY_AI_FLAG_40; + } else if (enemy->aiFlags & AI_FLAG_OUTSIDE_TERRITORY) { + enemy->aiFlags &= ~AI_FLAG_OUTSIDE_TERRITORY; + enemy->aiFlags &= ~AI_FLAG_NEEDS_HEADING; } // perform the motion @@ -853,7 +856,7 @@ API_CALLABLE(BasicAI_Main) { territory.halfHeight = 65.0f; territory.detectFlags = 0; - if (isInitialCall || enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (isInitialCall || enemy->aiFlags & AI_FLAG_SUSPEND) { script->AI_TEMP_STATE = AI_STATE_WANDER_INIT; npc->duration = 0; @@ -868,14 +871,14 @@ API_CALLABLE(BasicAI_Main) { npc->flags |= NPC_FLAG_FLYING; } - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { script->AI_TEMP_STATE = AI_STATE_SUSPEND; script->functionTemp[1] = AI_STATE_WANDER_INIT; } else if (enemy->flags & ENEMY_FLAG_BEGIN_WITH_CHASING) { script->AI_TEMP_STATE = AI_STATE_CHASE_INIT; } - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; enemy->flags &= ~ENEMY_FLAG_BEGIN_WITH_CHASING; } diff --git a/src/25AF0.c b/src/25AF0.c index d057e9d8ed..a0bdb7ee2a 100644 --- a/src/25AF0.c +++ b/src/25AF0.c @@ -27,7 +27,7 @@ s32 ai_check_fwd_collisions(Npc* npc, f32 time, f32* outYaw, f32* outDistFwd, f3 f32 cwHitDist = -1.0f; f32 ccwHitDist = -1.0f; f32 yaw; - s32 fwdHit; + b32 fwdHit; x1 = npc->pos.x; y1 = npc->pos.y; diff --git a/src/77480.c b/src/77480.c index b1ab1ead96..f74676062f 100644 --- a/src/77480.c +++ b/src/77480.c @@ -1052,7 +1052,7 @@ void check_for_pulse_stone(void) { return; } - if (gGameStatusPtr->areaID != AREA_SBK || gGameStatusPtr->isBattle) { + if (gGameStatusPtr->areaID != AREA_SBK || gGameStatusPtr->context != CONTEXT_WORLD) { return; } @@ -1318,7 +1318,7 @@ void clear_interact_prompt(void) { void update_partner_timers(void) { PlayerData* playerData = &gPlayerData; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { s32 i; for (i = 1; i < ARRAY_COUNT(playerData->partnerUnlockedTime); i++) { diff --git a/src/8a860_len_3f30.c b/src/8a860_len_3f30.c index 659a8feffa..c782301085 100644 --- a/src/8a860_len_3f30.c +++ b/src/8a860_len_3f30.c @@ -241,7 +241,7 @@ void destroy_popup_menu(void) { gPopupMenu->popupType == POPUP_TYPE_TRADE_FOR_BADGE || gPopupMenu->popupType == POPUP_TYPE_UPGRADE_PARTNER || gPopupMenu->popupType == POPUP_TYPE_USE_KEY - ) && !gGameStatusPtr->isBattle) { + ) && gGameStatusPtr->context == CONTEXT_WORLD) { if (!PopupMenu_WasStatusBarIgnoringChanges) { status_bar_respond_to_changes(); } diff --git a/src/animator.c b/src/animator.c index 5f58c25ea7..3b22ce6f0a 100644 --- a/src/animator.c +++ b/src/animator.c @@ -184,7 +184,7 @@ void free_animator_nodes(AnimatorNode* root) { void clear_animator_list(void) { s32 i; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gCurrentAnimMeshListPtr = &D_801539C0; for (i = 0; i < ARRAY_COUNT(D_801533C0); i++) { D_801533C0[i].ttl = -1; @@ -212,7 +212,7 @@ void clear_animator_list(void) { } void reset_animator_list(void) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gCurrentAnimMeshListPtr = &D_801539C0; } else { gCurrentAnimMeshListPtr = &D_80153A00; @@ -311,7 +311,7 @@ s32 create_model_animator(s16* animPos) { animator->staticNodeIDs[j] = j + 1; } - if (gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context != CONTEXT_WORLD) { i |= BATTLE_ID_BIT; } return i; @@ -351,7 +351,7 @@ s32 create_mesh_animator(s16* animPos, s16* animBuffer) { animator->staticNodeIDs[j] = j + 1; } - if (gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context != CONTEXT_WORLD) { i |= BATTLE_ID_BIT; } return i; @@ -434,7 +434,7 @@ void update_model_animator(s32 animatorID) { s32 temp; s32 i; - if (gGameStatusPtr->isBattle && !(animatorID & BATTLE_ID_BIT)) { + if (gGameStatusPtr->context != CONTEXT_WORLD && !(animatorID & BATTLE_ID_BIT)) { return; } @@ -448,7 +448,7 @@ void update_model_animator(s32 animatorID) { if (animator->flags & MODEL_ANIMATOR_FLAG_FREEZE_ANIMATION) { return; } - + animator->flags &= ~MODEL_ANIMATOR_FLAG_UPDATE_PENDING; animator->nextUpdateTime -= animator->timeScale; @@ -498,7 +498,7 @@ void update_model_animator_with_transform(s32 animatorID, Mtx* mtx) { s32 temp; s32 i; - if (gGameStatusPtr->isBattle && !(animatorID & BATTLE_ID_BIT)) { + if (gGameStatusPtr->context != CONTEXT_WORLD && !(animatorID & BATTLE_ID_BIT)) { return; } @@ -717,10 +717,10 @@ void render_animated_model(s32 animatorID, Mtx* rootTransform) { RenderTask rt; RenderTask* rtPtr = &rt; - if (gGameStatusPtr->isBattle && !(animatorID & BATTLE_ID_BIT)) { + if (gGameStatusPtr->context != CONTEXT_WORLD && !(animatorID & BATTLE_ID_BIT)) { return; } - + animatorID &= ~BATTLE_ID_BIT; animator = (*gCurrentAnimMeshListPtr)[animatorID]; @@ -747,7 +747,7 @@ void render_animated_model_with_vertices(s32 animatorID, Mtx* rootTransform, s32 RenderTask rt; RenderTask* rtPtr = &rt; - if (gGameStatusPtr->isBattle && !(animatorID & BATTLE_ID_BIT)) { + if (gGameStatusPtr->context != CONTEXT_WORLD && !(animatorID & BATTLE_ID_BIT)) { return; } @@ -1125,7 +1125,7 @@ void load_model_animator_tree(s32 index, StaticAnimatorNode** tree) { if (animator == NULL || animator->flags == 0) { return; } - + gAnimTreeRoot = tree; load_model_animator_node(*tree, animator, 0, nodeIDs); set_animator_tree_to_node_map(animator, nodeIDs, ARRAY_COUNT(animator->staticNodeIDs)); diff --git a/src/audio/sfx.c b/src/audio/sfx.c index b69af7da1d..29c50e3658 100644 --- a/src/audio/sfx.c +++ b/src/audio/sfx.c @@ -311,7 +311,7 @@ void sfx_clear_sounds(void) { // name might be incorrect? void sfx_clear_env_sounds(s16 playSounds) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gCurrentEnvSounds = wEnvSounds; } else { gCurrentEnvSounds = bEnvSounds; @@ -362,7 +362,7 @@ void sfx_stop_env_sounds(void) { SoundInstance* sound; s32 i; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gCurrentEnvSounds = wEnvSounds; } else { gCurrentEnvSounds = bEnvSounds; @@ -619,7 +619,7 @@ void sfx_compute_spatialized_sound_params_ignore_depth(f32 x, f32 y, f32 z, s16* *volume = 1; } - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { // 25/75 at screen edge *pan = (screenX * 0.2f) + 32.0f; } else { diff --git a/src/battle/battle.c b/src/battle/battle.c index 52b6e22288..d89534610a 100644 --- a/src/battle/battle.c +++ b/src/battle/battle.c @@ -220,7 +220,7 @@ void load_demo_battle(u32 index) { gGameStatusPtr->demoBattleFlags = 0; gGameStatusPtr->areaID = 0; gGameStatusPtr->mapID = 0; - gGameStatusPtr->isBattle = FALSE; + gGameStatusPtr->context = CONTEXT_WORLD; general_heap_create(); clear_worker_list(); diff --git a/src/effects.c b/src/effects.c index aba4f26854..7dc47c9503 100644 --- a/src/effects.c +++ b/src/effects.c @@ -75,7 +75,7 @@ void update_effects(void) { if (effectInstance != NULL && (effectInstance->flags & FX_INSTANCE_FLAG_ENABLED)) { effectInstance->graphics->flags &= ~FX_GRAPHICS_CAN_FREE; - if (gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context != CONTEXT_WORLD) { if (effectInstance->flags & FX_INSTANCE_FLAG_BATTLE) { effectInstance->graphics->update(effectInstance); effectInstance->flags |= FX_INSTANCE_FLAG_HAS_UPDATED; @@ -118,7 +118,7 @@ void render_effects_world(void) { if (effectInstance != NULL) { if (effectInstance->flags & FX_INSTANCE_FLAG_ENABLED) { if (effectInstance->flags & FX_INSTANCE_FLAG_HAS_UPDATED) { - if (gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context != CONTEXT_WORLD) { if (effectInstance->flags & FX_INSTANCE_FLAG_BATTLE) { effectInstance->graphics->renderWorld(effectInstance); } @@ -145,11 +145,11 @@ void render_effects_UI(void) { if (effectInstance->flags & FX_INSTANCE_FLAG_HAS_UPDATED) { void (*renderUI)(EffectInstance* effect); - if (gGameStatusPtr->isBattle && !(effectInstance->flags & FX_INSTANCE_FLAG_BATTLE)) { + if (gGameStatusPtr->context != CONTEXT_WORLD && !(effectInstance->flags & FX_INSTANCE_FLAG_BATTLE)) { continue; } - if (!gGameStatusPtr->isBattle && effectInstance->flags & FX_INSTANCE_FLAG_BATTLE) { + if (gGameStatusPtr->context == CONTEXT_WORLD && effectInstance->flags & FX_INSTANCE_FLAG_BATTLE) { continue; } @@ -245,7 +245,7 @@ EffectInstance* create_effect_instance(EffectBlueprint* effectBp) { effectBp->init(newEffectInst); } - if (gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context != CONTEXT_WORLD) { newEffectInst->flags |= FX_INSTANCE_FLAG_BATTLE; } return newEffectInst; diff --git a/src/effects/fire_breath.c b/src/effects/fire_breath.c index 34c04218c2..13c65983b2 100644 --- a/src/effects/fire_breath.c +++ b/src/effects/fire_breath.c @@ -167,7 +167,7 @@ void fire_breath_render(EffectInstance* effect) { renderTask.appendGfx = fire_breath_appendGfx; renderTask.appendGfxArg = effect; - if (gGameStatusPtr->isBattle == TRUE) { + if (gGameStatusPtr->context == CONTEXT_BATTLE) { renderTask.dist = data->pos.z + 1000.0f; } else { renderTask.dist = 0; diff --git a/src/effects/lightning.c b/src/effects/lightning.c index 7911520460..9590a71f34 100644 --- a/src/effects/lightning.c +++ b/src/effects/lightning.c @@ -101,7 +101,7 @@ EffectInstance* lightning_main( s32 effectArg0; load_effect(EFFECT_FLASHING_BOX_SHOCKWAVE); - if (gGameStatusPtr->isBattle == TRUE) { + if (gGameStatusPtr->context == CONTEXT_BATTLE) { effectArg0 = FX_SHOCK_OVERLAY_LIGHTNING_BATTLE; } else { effectArg0 = FX_SHOCK_OVERLAY_LIGHTNING_WORLD; diff --git a/src/effects/lightning_bolt.c b/src/effects/lightning_bolt.c index 6a9c24742c..b3a9ddb240 100644 --- a/src/effects/lightning_bolt.c +++ b/src/effects/lightning_bolt.c @@ -155,7 +155,7 @@ void lightning_bolt_render(EffectInstance *effect) { renderTask.appendGfx = lightning_bolt_appendGfx; renderTask.appendGfxArg = effect; - if (gGameStatusPtr->isBattle == TRUE) { + if (gGameStatusPtr->context == CONTEXT_BATTLE) { renderTask.dist = data->tipPos.z + 1000.0f; } else { renderTask.dist = 10; diff --git a/src/effects/star.c b/src/effects/star.c index 6d8112614f..e56394838d 100644 --- a/src/effects/star.c +++ b/src/effects/star.c @@ -151,7 +151,7 @@ void star_update(EffectInstance* effect) { load_effect(EFFECT_LANDING_DUST); landing_dust_main(0, data->pos.x, data->pos.y - 5.0f, data->pos.z, 0.0f); - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { sfx_play_sound_at_position(SOUND_SEQ_SHOOTING_STAR_BOUNCE, SOUND_SPACE_DEFAULT, data->pos.x, data->pos.y, data->pos.z); } diff --git a/src/encounter_api.c b/src/encounter_api.c index e2f67f6a14..4970ae73ed 100644 --- a/src/encounter_api.c +++ b/src/encounter_api.c @@ -848,16 +848,16 @@ API_CALLABLE(OnPlayerFled) { Bytecode* args = script->ptrReadPos; s32 skipReaction = evt_get_variable(script, *args++); - enemy->aiFlags |= ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags |= AI_FLAG_SUSPEND; if (!skipReaction) { EffectInstance* emoteEffect; - if (!(enemy->aiFlags & ENEMY_AI_FLAG_10)) { + if (!(enemy->aiFlags & AI_FLAG_SKIP_IDLE_ANIM_AFTER_FLEE)) { npc->curAnim = enemy->animList[ENEMY_ANIM_INDEX_IDLE]; } - if (!(enemy->aiFlags & ENEMY_AI_FLAG_8)) { + if (!(enemy->aiFlags & AI_FLAG_SKIP_EMOTE_AFTER_FLEE)) { fx_emote(EMOTE_QUESTION, npc, 0.0f, npc->collisionHeight, 1.0f, 0.0f, -20.0f, 40, &emoteEffect); } diff --git a/src/entity.c b/src/entity.c index 5ba20bda6a..8da9ff9557 100644 --- a/src/entity.c +++ b/src/entity.c @@ -345,7 +345,7 @@ void render_entities(void) { Entity* entity = get_entity_by_index(i); if (entity != NULL) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { if (gEntityHideMode != ENTITY_HIDE_MODE_0 && !(entity->flags & ENTITY_FLAG_IGNORE_DISTANCE_CULLING) && dist2D(gPlayerStatusPtr->pos.x, @@ -541,7 +541,7 @@ Shadow* get_shadow_by_index(s32 index) { EntityList* get_entity_list(void) { EntityList* ret; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { ret = &gWorldEntityList; } else { ret = &gBattleEntityList; @@ -552,7 +552,7 @@ EntityList* get_entity_list(void) { ShadowList* get_shadow_list(void) { ShadowList* ret; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { ret = &gWorldShadowList; } else { ret = &gBattleShadowList; @@ -795,7 +795,7 @@ void clear_entity_data(b32 arg0) { entity_updateCounter = 0; D_80151304 = 0; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gEntityHideMode = ENTITY_HIDE_MODE_0; } @@ -807,7 +807,7 @@ void clear_entity_data(b32 arg0) { } D_8014AFB0 = 255; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { wEntityDataLoadedSize = 0; for (i = 0; i < MAX_ENTITIES; i++) { wEntityBlueprint[i] = NULL; @@ -819,7 +819,7 @@ void clear_entity_data(b32 arg0) { } } - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gEntityHeapBottom = WORLD_ENTITY_HEAP_BOTTOM; gEntityHeapBase = WORLD_ENTITY_HEAP_BASE; } else { @@ -840,7 +840,7 @@ void clear_entity_data(b32 arg0) { } void init_entity_data(void) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gEntityHeapBottom = WORLD_ENTITY_HEAP_BOTTOM; gEntityHeapBase = WORLD_ENTITY_HEAP_BASE; reload_world_entity_data(); @@ -957,7 +957,7 @@ s32 is_entity_data_loaded(Entity* entity, EntityBlueprint* blueprint, s32* loade *loadedEnd = 0; ret = FALSE; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { blueprints = wEntityBlueprint; } else { blueprints = bEntityBlueprint; @@ -1016,7 +1016,7 @@ void load_simple_entity_data(Entity* entity, EntityBlueprint* bp, s32 listIndex) s32 totalSize; entity->vertexSegment = 0xA; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { totalSize = wEntityDataLoadedSize; } else { totalSize = bEntityDataLoadedSize; @@ -1038,7 +1038,7 @@ void load_simple_entity_data(Entity* entity, EntityBlueprint* bp, s32 listIndex) get_entity_type(entity->listIndex); } - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { wEntityDataLoadedSize = totalSize; } else { bEntityDataLoadedSize = totalSize; @@ -1091,7 +1091,7 @@ void load_split_entity_data(Entity* entity, EntityBlueprint* entityData, s32 lis animBaseAddr = (void*)(gEntityHeapBottom + specialSize * 4 + dma1size * 4); swizzlePointers = TRUE; } else if (is_entity_data_loaded(entity, entityData, &loadedStart, &loadedEnd)) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { totalLoaded = wEntityDataLoadedSize; } else { totalLoaded = bEntityDataLoadedSize; @@ -1116,7 +1116,7 @@ void load_split_entity_data(Entity* entity, EntityBlueprint* entityData, s32 lis totalLoaded += dma2size_2; get_entity_type(entity->listIndex); - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { wEntityDataLoadedSize = totalLoaded; } else { bEntityDataLoadedSize = totalLoaded; @@ -1688,7 +1688,7 @@ s32 entity_raycast_down(f32* x, f32* y, f32* z, f32* hitYaw, f32* hitPitch, f32* } void set_standard_shadow_scale(Shadow* shadow, f32 height) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { shadow->scale.x = 0.13 - (height / 2600.0f); } else { shadow->scale.x = 0.12 - (height / 3600.0f); @@ -1701,7 +1701,7 @@ void set_standard_shadow_scale(Shadow* shadow, f32 height) { } void set_npc_shadow_scale(Shadow* shadow, f32 height, f32 npcRadius) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { shadow->scale.x = 0.13 - (height / 2600.0f); } else { shadow->scale.x = 0.12 - (height / 3600.0f); @@ -1722,7 +1722,7 @@ void set_peach_shadow_scale(Shadow* shadow, f32 scale) { PlayerStatus* playerStatus = &gPlayerStatus; f32 phi_f2 = 0.12f; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { switch (playerStatus->anim) { case ANIM_Peach2_Carried: case ANIM_Peach2_Thrown: diff --git a/src/entity_model.c b/src/entity_model.c index d379bf005e..108c890125 100644 --- a/src/entity_model.c +++ b/src/entity_model.c @@ -51,7 +51,7 @@ void free_entity_model_by_ref(EntityModel* entityModel); void clear_entity_models(void) { s32 i; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gCurrentEntityModelList = &gWorldEntityModelList; } else { gCurrentEntityModelList = &gBattleEntityModelList; @@ -74,7 +74,7 @@ void clear_entity_models(void) { void init_entity_models(void) { s32 i; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gCurrentEntityModelList = &gWorldEntityModelList; } else { gCurrentEntityModelList = &gBattleEntityModelList; @@ -121,7 +121,7 @@ s32 load_entity_model(EntityModelScript* cmdList) { newEntityModel->fpSetupGfxCallback = NULL; newEntityModel->cmdListSavedPos = newEntityModel->cmdListReadPos; - if (gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context != CONTEXT_WORLD) { i |= BATTLE_ENTITY_ID_BIT; } return i; @@ -163,7 +163,7 @@ s32 ALT_load_entity_model(EntityModelScript* cmdList) { newEntityModel->fpSetupGfxCallback = NULL; newEntityModel->cmdListSavedPos = newEntityModel->cmdListReadPos; - if (gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context != CONTEXT_WORLD) { i |= BATTLE_ENTITY_ID_BIT; } return i; @@ -172,7 +172,7 @@ s32 ALT_load_entity_model(EntityModelScript* cmdList) { void exec_entity_model_commandlist(s32 idx) { EntityModel* entityModel; - if (!gGameStatusPtr->isBattle || (idx & BATTLE_ENTITY_ID_BIT)) { + if (gGameStatusPtr->context == CONTEXT_WORLD || (idx & BATTLE_ENTITY_ID_BIT)) { idx &= ~BATTLE_ENTITY_ID_BIT; entityModel = (*gCurrentEntityModelList)[idx]; if (entityModel != NULL && (entityModel->flags)) { @@ -412,7 +412,7 @@ void draw_entity_model_A(s32 modelIdx, Mtx* transformMtx) { f32 x, y, z, w; f32 inX, inY, inZ; - if ((!gGameStatusPtr->isBattle) || (modelIdx & BATTLE_ENTITY_ID_BIT)) { + if ((gGameStatusPtr->context == CONTEXT_WORLD) || (modelIdx & BATTLE_ENTITY_ID_BIT)) { modelIdx &= ~BATTLE_ENTITY_ID_BIT; model = (*gCurrentEntityModelList)[modelIdx]; @@ -450,7 +450,7 @@ void draw_entity_model_B(s32 modelIdx, Mtx* transformMtx, s32 vertexSegment, Vec f32 x, y, z, w; f32 inX, inY, inZ; - if ((!gGameStatusPtr->isBattle) || (modelIdx & BATTLE_ENTITY_ID_BIT)) { + if ((gGameStatusPtr->context == CONTEXT_WORLD) || (modelIdx & BATTLE_ENTITY_ID_BIT)) { modelIdx &= ~BATTLE_ENTITY_ID_BIT; model = (*gCurrentEntityModelList)[modelIdx]; @@ -485,7 +485,7 @@ void draw_entity_model_C(s32 modelIdx, Mtx* transformMtx) { RenderTask rt; RenderTask* rtPtr = &rt; - if ((!gGameStatusPtr->isBattle) || (modelIdx & BATTLE_ENTITY_ID_BIT)) { + if ((gGameStatusPtr->context == CONTEXT_WORLD) || (modelIdx & BATTLE_ENTITY_ID_BIT)) { modelIdx &= ~BATTLE_ENTITY_ID_BIT; model = (*gCurrentEntityModelList)[modelIdx]; @@ -515,7 +515,7 @@ void draw_entity_model_D(s32 modelIdx, Mtx* transformMtx, s32 arg2, Vec3s* verte RenderTask rt; RenderTask* rtPtr = &rt; - if ((!gGameStatusPtr->isBattle) || (modelIdx & BATTLE_ENTITY_ID_BIT)) { + if ((gGameStatusPtr->context == CONTEXT_WORLD) || (modelIdx & BATTLE_ENTITY_ID_BIT)) { modelIdx &= ~BATTLE_ENTITY_ID_BIT; model = (*gCurrentEntityModelList)[modelIdx]; diff --git a/src/evt/cam_api.c b/src/evt/cam_api.c index df1a28e254..219338082c 100644 --- a/src/evt/cam_api.c +++ b/src/evt/cam_api.c @@ -278,7 +278,7 @@ API_CALLABLE(ShakeCam) { *(f32*)&script->functionTemp[3] = 1.0f; //TODO functionTempF ? script->functionTemp[1] = duration; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { if (magnitude > 10.0f) { magnitude = 10.0f; } diff --git a/src/evt/model_api.c b/src/evt/model_api.c index 22ec06e48b..ea6b75379d 100644 --- a/src/evt/model_api.c +++ b/src/evt/model_api.c @@ -50,7 +50,7 @@ void render_animated_models(void) { // split here? API_CALLABLE(InitAnimatedModels) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gCurrentMeshAnimationListPtr = &gWorldMeshAnimationList; } else { gCurrentMeshAnimationListPtr = &gBattleMeshAnimationList; @@ -258,7 +258,7 @@ API_CALLABLE(SetAnimatorFlags) { void reset_model_animators(void) { s32 i; - if (!gGameStatusPtr->isBattle ) { + if (gGameStatusPtr->context == CONTEXT_WORLD ) { gCurrentMeshAnimationListPtr = &gWorldMeshAnimationList; } else { gCurrentMeshAnimationListPtr = &gBattleMeshAnimationList; @@ -276,7 +276,7 @@ void reset_model_animators(void) { } void init_model_animators(void) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gCurrentMeshAnimationListPtr = &gWorldMeshAnimationList; } else { gCurrentMeshAnimationListPtr = &gBattleMeshAnimationList; diff --git a/src/evt/script_list.c b/src/evt/script_list.c index 6b2a74b1e6..1130be3c1a 100644 --- a/src/evt/script_list.c +++ b/src/evt/script_list.c @@ -170,7 +170,7 @@ void find_script_labels(Evt* script) { void clear_script_list(void) { s32 i; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gCurrentScriptListPtr = &gWorldScriptList; gMapVars = gWorldMapVars; gMapFlags = gWorldMapFlags; @@ -201,7 +201,7 @@ void clear_script_list(void) { } void init_script_list(void) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gCurrentScriptListPtr = &gWorldScriptList; gMapVars = gWorldMapVars; gMapFlags = gWorldMapFlags; diff --git a/src/evt/virtual_entity.c b/src/evt/virtual_entity.c index 780aa62bf6..0012a011ec 100644 --- a/src/evt/virtual_entity.c +++ b/src/evt/virtual_entity.c @@ -119,7 +119,7 @@ void virtual_entity_list_render_UI(void) { } API_CALLABLE(InitVirtualEntityList) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gCurrentVirtualEntityListPtr = &wWorldVirtualEntityList; } else { gCurrentVirtualEntityListPtr = &bBattleVirtualEntityList; @@ -654,7 +654,7 @@ void virtual_entity_delete_by_ref(VirtualEntity* obj) { void clear_virtual_entity_list(void) { s32 i; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gCurrentVirtualEntityListPtr = &wWorldVirtualEntityList; } else { gCurrentVirtualEntityListPtr = &bBattleVirtualEntityList; @@ -671,7 +671,7 @@ void clear_virtual_entity_list(void) { } void init_virtual_entity_list(void) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gCurrentVirtualEntityListPtr = &wWorldVirtualEntityList; } else { gCurrentVirtualEntityListPtr = &bBattleVirtualEntityList; diff --git a/src/heap.c b/src/heap.c index 7aa150a715..8cb5a9a213 100644 --- a/src/heap.c +++ b/src/heap.c @@ -32,7 +32,7 @@ s32 func_8002ACDC(void) { } void* heap_malloc(s32 size) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { return general_heap_malloc(size); } else { return _heap_malloc(&heap_battleHead, size); @@ -40,7 +40,7 @@ void* heap_malloc(s32 size) { } s32 heap_free(void* data) { - if (gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context != CONTEXT_WORLD) { return _heap_free(&heap_battleHead, data); } else { return general_heap_free(data); @@ -55,7 +55,7 @@ s32 collision_heap_create(void) { } void* collision_heap_malloc(s32 size) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { return _heap_malloc(&heap_collisionHead, size); } else { return _heap_malloc(&heap_battleHead, size); @@ -63,7 +63,7 @@ void* collision_heap_malloc(s32 size) { } s32 collision_heap_free(void* data) { - if (gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context != CONTEXT_WORLD) { return _heap_free(&heap_battleHead, data); } else { return _heap_free(&heap_collisionHead, data); diff --git a/src/hud_element.c b/src/hud_element.c index 435480a14c..a1d6f4eb52 100644 --- a/src/hud_element.c +++ b/src/hud_element.c @@ -190,7 +190,7 @@ void hud_element_load_script(HudElement* hudElement, HudScript* anim) { if (entry->id == -1) { entry->id = raster; entry->data = &gHudElementCacheBuffer[*gHudElementCacheSize]; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { capacity = gHudElementCacheCapacity; } else { capacity = gHudElementCacheCapacity / 2; @@ -198,7 +198,7 @@ void hud_element_load_script(HudElement* hudElement, HudScript* anim) { ASSERT(capacity > *gHudElementCacheSize + gHudElementSizes[preset].size); nuPiReadRom((s32)icon_ROM_START + raster, entry->data, gHudElementSizes[preset].size); *gHudElementCacheSize += gHudElementSizes[preset].size; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { *pos = i; } else { *pos = (u16)(*pos) | (i << 16); @@ -206,7 +206,7 @@ void hud_element_load_script(HudElement* hudElement, HudScript* anim) { i++; break; } else if (entry->id == raster) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { *pos = i; } else { *pos = (u16)(*pos) | (i << 16); @@ -226,7 +226,7 @@ void hud_element_load_script(HudElement* hudElement, HudScript* anim) { if (entry->id == -1) { entry->id = palette; entry->data = &gHudElementCacheBuffer[*gHudElementCacheSize]; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { capacity = gHudElementCacheCapacity; } else { capacity = gHudElementCacheCapacity / 2; @@ -234,7 +234,7 @@ void hud_element_load_script(HudElement* hudElement, HudScript* anim) { ASSERT(capacity > *gHudElementCacheSize + 32); nuPiReadRom((s32)icon_ROM_START + palette, entry->data, 32); *gHudElementCacheSize += 32; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { *pos = i; } else { *pos = (u16)(*pos) | (i << 16); @@ -242,7 +242,7 @@ void hud_element_load_script(HudElement* hudElement, HudScript* anim) { i++; break; } else if (entry->id == palette) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { *pos = i; } else { *pos = (u16)(*pos) | (i << 16); @@ -610,7 +610,7 @@ void hud_element_clear_cache(void) { HudCacheEntry* entryRaster; HudCacheEntry* entryPalette; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gHudElements = &gHudElementsWorld; gHudElementCacheSize = &gHudElementCacheSizeWorld; gHudElementCacheTableRaster = gHudElementCacheTableRasterWorld; @@ -622,7 +622,7 @@ void hud_element_clear_cache(void) { gHudElementCacheTablePalette = gHudElementCacheTablePaletteBattle; } - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gHudElementCacheBuffer = general_heap_malloc(gHudElementCacheCapacity); ASSERT(gHudElementCacheBuffer); gHudElementCacheBufferWorld = gHudElementCacheBuffer; @@ -664,7 +664,7 @@ extern Addr D_80200000; #endif void init_hud_element_list(void) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { if (gHudElementCacheBufferBattle != NULL) { #if VERSION_PAL if (gHudElementCacheBufferBattle != D_80200000) { @@ -755,7 +755,7 @@ s32 hud_element_create(HudScript* anim) { hudElement->tint.g = 255; hudElement->tint.b = 255; - if (gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context != CONTEXT_WORLD) { hudElement->flags |= HUD_ELEMENT_FLAG_BATTLE; id |= HUD_ELEMENT_BATTLE_ID_MASK; } @@ -2042,7 +2042,7 @@ void hud_element_clear_flags(s32 id, s32 flags) { void ALT_clear_hud_element_cache(void) { s32 i; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { heap_free(gHudElementCacheBuffer); gHudElementCacheBuffer = heap_malloc(gHudElementCacheCapacity); ASSERT(gHudElementCacheBuffer); diff --git a/src/imgfx.c b/src/imgfx.c index 64bab44e8f..7ba39647f7 100644 --- a/src/imgfx.c +++ b/src/imgfx.c @@ -1526,7 +1526,7 @@ void imgfx_appendGfx_mesh_basic(ImgFXState* state, Matrix4f mtx) { ) { cam = &gCameras[gCurrentCamID]; - if (gGameStatusPtr->isBattle == 2) { + if (gGameStatusPtr->context == CONTEXT_PAUSE) { gSPViewport(gMainGfxPos++, &D_8014EE50); } else { gSPViewport(gMainGfxPos++, &cam->vpAlt); @@ -1565,7 +1565,7 @@ void imgfx_appendGfx_mesh_basic(ImgFXState* state, Matrix4f mtx) { alpha2 = 255; cam = &gCameras[gCurrentCamID]; - if (gGameStatusPtr->isBattle == 2) { + if (gGameStatusPtr->context == CONTEXT_PAUSE) { gSPViewport(gMainGfxPos++, &D_8014EE50); } else { gSPViewport(gMainGfxPos++, &cam->vpAlt); @@ -1620,7 +1620,7 @@ void imgfx_appendGfx_mesh_basic(ImgFXState* state, Matrix4f mtx) { && (state->flags & someFlags) ) { cam = &gCameras[gCurrentCamID]; - if (gGameStatusPtr->isBattle == 2) { + if (gGameStatusPtr->context == CONTEXT_PAUSE) { gSPViewport(gMainGfxPos++, &D_8014EE40); D_8014EE50.vp.vtrans[0] = D_8014EE40.vp.vtrans[0] + gGameStatusPtr->altViewportOffset.x; D_8014EE50.vp.vtrans[1] = D_8014EE40.vp.vtrans[1] + gGameStatusPtr->altViewportOffset.y; diff --git a/src/inventory.c b/src/inventory.c index 49819b56f2..78b623ad7f 100644 --- a/src/inventory.c +++ b/src/inventory.c @@ -465,7 +465,7 @@ void status_bar_draw_number(s32 iconID, s32 startX, s32 startY, s32 value, s32 n b32 keepDrawing; s32 digit; s32 i; - + hud_element_set_script(iconID, TimesHudScript); drawX = startX + 8; drawY = startY + 8; @@ -578,7 +578,7 @@ void update_status_bar(void) { return; } - if (!gGameStatusPtr->isBattle && playerData->coins != statusBar->displayCoins) { + if (gGameStatusPtr->context == CONTEXT_WORLD && playerData->coins != statusBar->displayCoins) { status_bar_start_blinking_coins(); } @@ -626,7 +626,7 @@ void update_status_bar(void) { // sync displayed HP toward true HP if (statusBar->displayHP != playerData->curHP) { - if (!gGameStatusPtr->isBattle && playerData->curHP < statusBar->displayHP) { + if (gGameStatusPtr->context == CONTEXT_WORLD && playerData->curHP < statusBar->displayHP) { status_bar_start_blinking_hp(); } if (statusBar->displayHP < playerData->curHP) { @@ -645,7 +645,7 @@ void update_status_bar(void) { // sync displayed FP toward true FP if (statusBar->displayFP != playerData->curFP) { - if (!gGameStatusPtr->isBattle && playerData->curFP < statusBar->displayFP) { + if (gGameStatusPtr->context == CONTEXT_WORLD && playerData->curFP < statusBar->displayFP) { status_bar_start_blinking_fp(); } if (statusBar->displayFP < playerData->curFP) { @@ -700,7 +700,7 @@ void update_status_bar(void) { } else { if (!statusBar->ignoreChanges) { if (!statusBar->unk_3B || playerStatus->actionState != ACTION_STATE_IDLE) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { statusBar->hidden = TRUE; statusBar->showTimer = 0; statusBar->unk_3C = FALSE; @@ -723,7 +723,7 @@ void update_status_bar(void) { statusBar->showTimer++; } - if (statusBar->showTimer >= 240 && !gGameStatusPtr->isBattle) { + if (statusBar->showTimer >= 240 && gGameStatusPtr->context == CONTEXT_WORLD) { statusBar->showTimer = 210; statusBar->hidden = FALSE; statusBar->unk_3B = TRUE; @@ -1372,7 +1372,7 @@ s32 is_status_bar_visible(void) { void status_bar_start_blinking_hp(void) { StatusBar* statusBar = &gStatusBar; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { statusBar->hpBlinkTimer = 120; } @@ -1395,7 +1395,7 @@ void status_bar_stop_blinking_hp(void) { void status_bar_start_blinking_fp(void) { StatusBar* statusBar = &gStatusBar; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { statusBar->fpBlinkTimer = 120; } @@ -1417,7 +1417,7 @@ void status_bar_stop_blinking_fp(void) { void status_bar_start_blinking_coins(void) { StatusBar* statusBar = &gStatusBar; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { statusBar->coinsBlinkTimer = 120; } diff --git a/src/item_entity.c b/src/item_entity.c index 6f2ce3c859..6027f0a383 100644 --- a/src/item_entity.c +++ b/src/item_entity.c @@ -242,7 +242,7 @@ void reveal_item_entity(ItemEntity* item) { void clear_item_entity_data(void) { s32 i; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gCurrentItemEntities = WorldItemEntities; } else { gCurrentItemEntities = BattleItemEntities; @@ -258,7 +258,7 @@ void clear_item_entity_data(void) { CoinSparkleCenterZ = 0; ItemEntityAlternatingSpawn = 0; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { ItemEntityRenderGroup = 0; } @@ -271,7 +271,7 @@ void clear_item_entity_data(void) { } void init_item_entity_list(void) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gCurrentItemEntities = WorldItemEntities; } else { gCurrentItemEntities = BattleItemEntities; @@ -327,7 +327,7 @@ void item_entity_load(ItemEntity* item) { ASSERT(*gHudElementCacheSize + size < 0x11000); nuPiReadRom((s32)icon_ROM_START + raster, entry->data, size); *gHudElementCacheSize += size; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { *pos = i; } else { *pos = (u16)(*pos) | (i << 16); @@ -337,7 +337,7 @@ void item_entity_load(ItemEntity* item) { } else { cond = entry->id == raster; // TODO required to match if (cond) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { *pos = i; } else { *pos = (u16)(*pos) | (i << 16); @@ -360,7 +360,7 @@ void item_entity_load(ItemEntity* item) { ASSERT(*gHudElementCacheSize + 0x20 < 0x11000); nuPiReadRom((s32)icon_ROM_START + palette, entry->data, 0x20); *gHudElementCacheSize += 0x20; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { *pos = i; } else { *pos = (u16)(*pos) | (i << 16); @@ -368,7 +368,7 @@ void item_entity_load(ItemEntity* item) { pos++; break; } else if (entry->id == palette) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { *pos = i; } else { *pos = (u16)(*pos) | (i << 16); @@ -791,7 +791,7 @@ void item_entity_update(ItemEntity* entity) { entity->nextUpdate = *args++; *args++; *args++; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { entity->lookupRasterIndex = *args++; entity->lookupPaletteIndex = *args++; } else { diff --git a/src/model.c b/src/model.c index 00a1ad4ead..f739a540e6 100644 --- a/src/model.c +++ b/src/model.c @@ -2318,7 +2318,7 @@ void mdl_load_all_textures(ModelNode* rootModel, s32 romOffset, s32 size) { s32 baseOffset = 0; // textures are loaded to the upper half of the texture heap when not in the world - if (gGameStatusPtr->isBattle != 0) { + if (gGameStatusPtr->context != CONTEXT_WORLD) { baseOffset = WORLD_TEXTURE_MEMORY_SIZE; } @@ -2359,7 +2359,7 @@ s32 mdl_get_child_count(ModelNode* model) { void clear_model_data(void) { s32 i; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gCurrentModels = &wModelList; gCurrentTransformGroups = &wTransformGroups; gCurrentCustomModelGfxPtr = &wCustomModelGfx; @@ -2424,7 +2424,7 @@ void clear_model_data(void) { } void init_model_data(void) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gCurrentModels = &wModelList; gCurrentTransformGroups = &wTransformGroups; gCurrentCustomModelGfxPtr = &wCustomModelGfx; diff --git a/src/npc.c b/src/npc.c index 29a6988fbc..73bec256d8 100644 --- a/src/npc.c +++ b/src/npc.c @@ -77,7 +77,7 @@ void mtx_ident_mirror_y(Matrix4f mtx) { void clear_npcs(void) { s32 i; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gCurrentNpcListPtr = &gWorldNpcList; } else { gCurrentNpcListPtr = &gBattleNpcList; @@ -92,7 +92,7 @@ void clear_npcs(void) { } void init_npc_list(void) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gCurrentNpcListPtr = &gWorldNpcList; } else { gCurrentNpcListPtr = &gBattleNpcList; @@ -207,7 +207,7 @@ s32 create_npc_impl(NpcBlueprint* blueprint, AnimID* animList, s32 isPeachNpc) { npc->shadowIndex = create_shadow_type(SHADOW_VARYING_CIRCLE, npc->pos.x, npc->pos.y, npc->pos.z); npc->shadowScale = 1.0f; - if (gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context != CONTEXT_WORLD) { i |= BATTLE_NPC_ID_BIT; } return i; diff --git a/src/screen_overlays.c b/src/screen_overlays.c index 1d16a24d66..912e856f57 100644 --- a/src/screen_overlays.c +++ b/src/screen_overlays.c @@ -479,7 +479,7 @@ void func_80138198(void) { void render_screen_overlay_frontUI(void) { if (screen_overlay_frontType != OVERLAY_NONE && screen_overlay_frontZoom != -1.0f - && gGameStatusPtr->isBattle != 2 + && gGameStatusPtr->context != CONTEXT_PAUSE ) { _render_transition_stencil(screen_overlay_frontType, screen_overlay_frontZoom, &ScreenOverlays[0]); } @@ -488,7 +488,7 @@ void render_screen_overlay_frontUI(void) { void render_screen_overlay_backUI(void) { if (screen_overlay_backType != OVERLAY_NONE && screen_overlay_backZoom != -1.0f - && gGameStatusPtr->isBattle != 2 + && gGameStatusPtr->context != CONTEXT_PAUSE ) { _render_transition_stencil(screen_overlay_backType, screen_overlay_backZoom, &ScreenOverlays[1]); } diff --git a/src/sprite.c b/src/sprite.c index a0feb7fec3..9786be6672 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -241,7 +241,7 @@ void spr_appendGfx_component_flat( gDPSetTileSize(gMainGfxPos++, 2, 0, 0, 63 << 2, 0); if (gSpriteShadingProfile->flags & SPR_SHADING_FLAG_SET_VIEWPORT) { Camera* camera = &gCameras[gCurrentCamID]; - if (gGameStatusPtr->isBattle == 2) { + if (gGameStatusPtr->context == CONTEXT_PAUSE) { gSPViewport(gMainGfxPos++, &SprPauseVpAlt); } else { gSPViewport(gMainGfxPos++, &camera->vpAlt); @@ -268,7 +268,7 @@ void spr_appendGfx_component_flat( 256, 256); if (gSpriteShadingProfile->flags & SPR_SHADING_FLAG_SET_VIEWPORT) { Camera* camera = &gCameras[gCurrentCamID]; - if (gGameStatusPtr->isBattle == 2) { + if (gGameStatusPtr->context == CONTEXT_PAUSE) { gSPViewport(gMainGfxPos++, &SprPauseVpAlt); } else { gSPViewport(gMainGfxPos++, &camera->vpAlt); @@ -304,7 +304,7 @@ void spr_appendGfx_component_flat( if (gSpriteShadingProfile->flags & SPR_SHADING_FLAG_SET_VIEWPORT) { Camera* camera = &gCameras[gCurrentCamID]; - if (gGameStatusPtr->isBattle == 2) { + if (gGameStatusPtr->context == CONTEXT_PAUSE) { gSPViewport(gMainGfxPos++, &SprPauseVp); SprPauseVpAlt.vp.vtrans[0] = SprPauseVp.vp.vtrans[0] + gGameStatusPtr->altViewportOffset.x; SprPauseVpAlt.vp.vtrans[1] = SprPauseVp.vp.vtrans[1] + gGameStatusPtr->altViewportOffset.y; diff --git a/src/sprite_shading.c b/src/sprite_shading.c index 4d3837585e..d0d1e07f0e 100644 --- a/src/sprite_shading.c +++ b/src/sprite_shading.c @@ -37,7 +37,7 @@ void clear_sprite_shading_data(void) { } void init_sprite_shading_data(void) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gSpriteShadingProfile = &wSpriteShadingProfile; gAuxSpriteShadingProfile = &wSpriteShadingProfileAux; } else { diff --git a/src/state_battle.c b/src/state_battle.c index d0c4d91402..63ee4687b6 100644 --- a/src/state_battle.c +++ b/src/state_battle.c @@ -57,7 +57,7 @@ void state_step_battle(void) { nuContRmbForceStopEnd(); sfx_stop_env_sounds(); func_8003B1A8(); - gGameStatusPtr->isBattle = TRUE; + gGameStatusPtr->context = CONTEXT_BATTLE; backup_map_collision_data(); #if !VERSION_IQUE @@ -146,7 +146,7 @@ void state_step_end_battle(void) { mapSettings = get_current_map_settings(); mapConfig = &gAreas[gGameStatusPtr->areaID].maps[gGameStatusPtr->mapID]; btl_restore_world_cameras(); - gGameStatusPtr->isBattle = FALSE; + gGameStatusPtr->context = CONTEXT_WORLD; func_8005AF84(); func_8002ACDC(); sfx_clear_env_sounds(1); diff --git a/src/state_demo.c b/src/state_demo.c index 9ae697ce1e..d0db4c3d4d 100644 --- a/src/state_demo.c +++ b/src/state_demo.c @@ -191,7 +191,7 @@ void state_step_demo(void) { gGameStatusPtr->demoState = DEMO_STATE_NONE; gGameStatusPtr->peachFlags = 0; enable_sounds(); - gGameStatusPtr->isBattle = FALSE; + gGameStatusPtr->context = CONTEXT_WORLD; gGameStatusPtr->debugUnused1 = FALSE; gGameStatusPtr->debugScripts = DEBUG_SCRIPTS_NONE; gGameStatusPtr->keepUsingPartnerOnMapChange = FALSE; diff --git a/src/state_file_select.c b/src/state_file_select.c index e9e6eabfd1..cef428fde2 100644 --- a/src/state_file_select.c +++ b/src/state_file_select.c @@ -139,7 +139,7 @@ void state_step_language_select(void) { D_800A0930 = -1; sfx_stop_env_sounds(); func_8003B1A8(); - gGameStatusPtr->isBattle = 2; + gGameStatusPtr->context = CONTEXT_PAUSE; backup_map_collision_data(); battle_heap_create(); sfx_clear_env_sounds(0); @@ -292,7 +292,7 @@ void state_step_exit_language_select(void) { gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME; mapSettings = get_current_map_settings(); mapConfig = &gAreas[gGameStatusPtr->areaID].maps[gGameStatusPtr->mapID]; - gGameStatusPtr->isBattle = FALSE; + gGameStatusPtr->context = CONTEXT_WORLD; func_8005AF84(); func_8002ACDC(); sfx_clear_env_sounds(1); diff --git a/src/state_intro.c b/src/state_intro.c index 58d57fb41f..b502593931 100644 --- a/src/state_intro.c +++ b/src/state_intro.c @@ -156,7 +156,7 @@ void state_step_intro(void) { break; case INTRO_LOAD_MAP: set_curtain_draw_callback(NULL); - gGameStatusPtr->isBattle = FALSE; + gGameStatusPtr->context = CONTEXT_WORLD; gGameStatusPtr->debugUnused1 = FALSE; gGameStatusPtr->debugScripts = DEBUG_SCRIPTS_NONE; gGameStatusPtr->keepUsingPartnerOnMapChange = FALSE; diff --git a/src/state_pause.c b/src/state_pause.c index db55030dff..917dec7bf9 100644 --- a/src/state_pause.c +++ b/src/state_pause.c @@ -82,7 +82,7 @@ void state_step_pause(void) { gGameStatusPtr->savedBackgroundDarkness = gGameStatusPtr->backgroundDarkness; sfx_stop_env_sounds(); func_8003B1A8(); - gGameStatusPtr->isBattle = 2; + gGameStatusPtr->context = CONTEXT_PAUSE; backup_map_collision_data(); battle_heap_create(); nuContRmbForceStop(); @@ -163,7 +163,7 @@ void state_step_unpause(void) { gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME; mapSettings = get_current_map_settings(); mapConfig = &gAreas[gGameStatusPtr->areaID].maps[gGameStatusPtr->mapID]; - gGameStatusPtr->isBattle = FALSE; + gGameStatusPtr->context = CONTEXT_WORLD; gGameStatusPtr->backgroundFlags &= ~BACKGROUND_RENDER_STATE_MASK; func_8005AF84(); func_8002ACDC(); diff --git a/src/state_startup.c b/src/state_startup.c index 085607be42..b9d4e7aa5e 100644 --- a/src/state_startup.c +++ b/src/state_startup.c @@ -20,7 +20,7 @@ void state_step_startup(void) { gOverrideFlags = 0; gGameStatusPtr->areaID = 0; - gGameStatusPtr->isBattle = 0; + gGameStatusPtr->context = CONTEXT_WORLD; gameStatus->prevArea = -1; gameStatus->mapID = 0; gameStatus->entryID = 0; diff --git a/src/state_title_screen.c b/src/state_title_screen.c index 7da37a898f..751ea3da6b 100644 --- a/src/state_title_screen.c +++ b/src/state_title_screen.c @@ -126,7 +126,7 @@ void state_init_title_screen(void) { sfx_set_reverb_mode(0); gGameStatusPtr->startupState = TITLE_STATE_INIT; gGameStatusPtr->logoTime = 0; - gGameStatusPtr->isBattle = FALSE; + gGameStatusPtr->context = CONTEXT_WORLD; gGameStatusPtr->introPart = INTRO_PART_NONE; startup_fade_screen_update(); titleData = load_asset_by_name("title_data", &titleDataSize); diff --git a/src/status_icons.c b/src/status_icons.c index 78b241af3b..c02c442e65 100644 --- a/src/status_icons.c +++ b/src/status_icons.c @@ -615,7 +615,7 @@ void draw_all_status_icons(void* data) { if (icon->status1.activeTask == STATUS_ICON_TASK_DRAW) { if (icon->flags & STATUS_ICON_FLAG_DEBUFF) { hud_element_set_flags(icon->status1.activeElementID, HUD_ELEMENT_FLAG_DISABLED); - } else if (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->isBattle != 1) { + } else if (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->context != CONTEXT_BATTLE) { hud_element_clear_flags(icon->status1.activeElementID, HUD_ELEMENT_FLAG_DISABLED); x = icon->worldPos.x; @@ -632,7 +632,9 @@ void draw_all_status_icons(void* data) { } } - if (icon->status1.removingTask == STATUS_ICON_TASK_DRAW && (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->isBattle != 1)) { + if (icon->status1.removingTask == STATUS_ICON_TASK_DRAW + && (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->context != CONTEXT_BATTLE) + ) { hud_element_clear_flags(icon->status1.removingElementID, HUD_ELEMENT_FLAG_DISABLED); if (isActiveDrawn == 0) { @@ -654,7 +656,7 @@ void draw_all_status_icons(void* data) { if (icon->status2.activeTask == STATUS_ICON_TASK_DRAW) { if (icon->flags & STATUS_ICON_FLAG_STATIC) { hud_element_set_flags(icon->status2.activeElementID, HUD_ELEMENT_FLAG_DISABLED); - } else if (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->isBattle != 1) { + } else if (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->context != CONTEXT_BATTLE) { hud_element_clear_flags(icon->status2.activeElementID, HUD_ELEMENT_FLAG_DISABLED); offsetY = 0; @@ -677,7 +679,9 @@ void draw_all_status_icons(void* data) { } } - if (icon->status2.removingTask == STATUS_ICON_TASK_DRAW && (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->isBattle != 1)) { + if (icon->status2.removingTask == STATUS_ICON_TASK_DRAW + && (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->context != CONTEXT_BATTLE) + ) { hud_element_clear_flags(icon->status2.removingElementID, HUD_ELEMENT_FLAG_DISABLED); offsetY = 0; @@ -703,7 +707,7 @@ void draw_all_status_icons(void* data) { if (icon->status3.activeTask == STATUS_ICON_TASK_DRAW) { if (icon->flags & STATUS_ICON_FLAG_TRANSPARENT) { hud_element_set_flags(icon->status3.activeElementID, HUD_ELEMENT_FLAG_DISABLED); - } else if (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->isBattle != 1) { + } else if (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->context != CONTEXT_BATTLE) { hud_element_clear_flags(icon->status3.activeElementID, HUD_ELEMENT_FLAG_DISABLED); offsetY = 0; @@ -727,7 +731,9 @@ void draw_all_status_icons(void* data) { } } - if (icon->status3.removingTask == STATUS_ICON_TASK_DRAW && (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->isBattle != 1)) { + if (icon->status3.removingTask == STATUS_ICON_TASK_DRAW + && (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->context != CONTEXT_BATTLE) + ) { hud_element_clear_flags(icon->status3.removingElementID, HUD_ELEMENT_FLAG_DISABLED); offsetY = 0; @@ -756,7 +762,7 @@ void draw_all_status_icons(void* data) { if (icon->status4.activeTask == STATUS_ICON_TASK_DRAW) { if (icon->flags & STATUS_ICON_FLAG_STATUS_CHILL_OUT) { hud_element_set_flags(icon->status4.activeElementID, HUD_ELEMENT_FLAG_DISABLED); - } else if (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->isBattle != 1) { + } else if (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->context != CONTEXT_BATTLE) { hud_element_clear_flags(icon->status4.activeElementID, HUD_ELEMENT_FLAG_DISABLED); offsetY = 0; @@ -784,7 +790,9 @@ void draw_all_status_icons(void* data) { } } - if (icon->status4.removingTask == STATUS_ICON_TASK_DRAW && (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->isBattle != 1)) { + if (icon->status4.removingTask == STATUS_ICON_TASK_DRAW + && (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->context != CONTEXT_BATTLE) + ) { hud_element_clear_flags(icon->status4.removingElementID, HUD_ELEMENT_FLAG_DISABLED); offsetY = 0; @@ -816,7 +824,7 @@ void draw_all_status_icons(void* data) { if (icon->boostJump.active) { if (icon->flags & STATUS_ICON_FLAG_BOOST_JUMP) { hud_element_set_flags(icon->boostJump.activeElementID, HUD_ELEMENT_FLAG_DISABLED); - } else if (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->isBattle != 1) { + } else if (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->context != CONTEXT_BATTLE) { hud_element_clear_flags(icon->boostJump.activeElementID, HUD_ELEMENT_FLAG_DISABLED); x = icon->worldPos.x; @@ -846,7 +854,7 @@ void draw_all_status_icons(void* data) { if (icon->boostHammer.active) { if (icon->flags & STATUS_ICON_FLAG_BOOST_HAMMER) { hud_element_set_flags(icon->boostHammer.activeElementID, HUD_ELEMENT_FLAG_DISABLED); - } else if (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->isBattle != 1) { + } else if (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->context != CONTEXT_BATTLE) { hud_element_clear_flags(icon->boostHammer.activeElementID, HUD_ELEMENT_FLAG_DISABLED); x = icon->worldPos.x; @@ -876,7 +884,7 @@ void draw_all_status_icons(void* data) { if (icon->boostPartner.active) { if (icon->flags & STATUS_ICON_FLAG_BOOST_PARTNER) { hud_element_set_flags(icon->boostPartner.activeElementID, HUD_ELEMENT_FLAG_DISABLED); - } else if (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->isBattle != 1) { + } else if (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->context != CONTEXT_BATTLE) { hud_element_clear_flags(icon->boostPartner.activeElementID, HUD_ELEMENT_FLAG_DISABLED); x = icon->worldPos.x; @@ -894,7 +902,7 @@ void draw_all_status_icons(void* data) { if (icon->surprise.active) { if (icon->flags & STATUS_ICON_FLAG_SURPRISE) { hud_element_set_flags(icon->surprise.activeElementID, HUD_ELEMENT_FLAG_DISABLED); - } else if (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->isBattle != 1) { + } else if (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->context != CONTEXT_BATTLE) { hud_element_clear_flags(icon->surprise.activeElementID, HUD_ELEMENT_FLAG_DISABLED); x = icon->worldPos.x; @@ -912,7 +920,7 @@ void draw_all_status_icons(void* data) { if (icon->peril.active) { if (icon->flags & STATUS_ICON_FLAG_PERIL) { hud_element_set_flags(icon->peril.activeElementID, HUD_ELEMENT_FLAG_DISABLED); - } else if (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->isBattle != 1) { + } else if (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->context != CONTEXT_BATTLE) { hud_element_clear_flags(icon->peril.activeElementID, HUD_ELEMENT_FLAG_DISABLED); x = icon->worldPos.x; @@ -930,7 +938,7 @@ void draw_all_status_icons(void* data) { if (icon->danger.active) { if (icon->flags & STATUS_ICON_FLAG_DANGER) { hud_element_set_flags(icon->danger.activeElementID, HUD_ELEMENT_FLAG_DISABLED); - } else if (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->isBattle != 1) { + } else if (icon->flags & STATUS_ICON_FLAG_BATTLE || gGameStatusPtr->context != CONTEXT_BATTLE) { hud_element_clear_flags(icon->danger.activeElementID, HUD_ELEMENT_FLAG_DISABLED); x = icon->worldPos.x; @@ -959,8 +967,9 @@ s32 create_status_icon_set(void) { ASSERT(i < MAX_ICONS); icon->flags = STATUS_ICON_FLAG_USED; - if (gGameStatusPtr->isBattle) { - icon->flags = STATUS_ICON_FLAG_BATTLE | STATUS_ICON_FLAG_USED; + + if (gGameStatusPtr->context != CONTEXT_WORLD) { + icon->flags |= STATUS_ICON_FLAG_BATTLE; } icon->worldPos.x = 0; diff --git a/src/trigger.c b/src/trigger.c index b89a31016c..7f6c663b81 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -13,7 +13,7 @@ void clear_trigger_data(void) { CollisionStatus* collisionStatus = &gCollisionStatus; s32 i; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gCurrentTriggerListPtr = &wTriggerList; } else { gCurrentTriggerListPtr = &bTriggerList; @@ -42,7 +42,7 @@ void clear_trigger_data(void) { } void init_trigger_list(void) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gCurrentTriggerListPtr = &wTriggerList; } else { gCurrentTriggerListPtr = &bTriggerList; diff --git a/src/worker.c b/src/worker.c index 357fae23ce..ca8fa7c521 100644 --- a/src/worker.c +++ b/src/worker.c @@ -10,7 +10,7 @@ void worker_delegate_do_nothing(void) { void clear_worker_list(void) { s32 i; - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gCurrentWorkerListPtr = &gWorldWorkerList; } else { gCurrentWorkerListPtr = &gBattleWorkerList; @@ -22,7 +22,7 @@ void clear_worker_list(void) { } void init_worker_list(void) { - if (!gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context == CONTEXT_WORLD) { gCurrentWorkerListPtr = &gWorldWorkerList; } else { gCurrentWorkerListPtr = &gBattleWorkerList; @@ -54,7 +54,7 @@ s32 create_worker_world(void (*updateFunc)(void), void (*drawFunc)(void)) { worker->draw = worker_delegate_do_nothing; } - if (gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context != CONTEXT_WORLD) { i |= BATTLE_ENTITY_ID_BIT; } return i; @@ -85,7 +85,7 @@ s32 create_worker_frontUI(void (*updateFunc)(void), void (*drawFunc)(void)) { worker->draw = worker_delegate_do_nothing; } - if (gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context != CONTEXT_WORLD) { i |= BATTLE_ENTITY_ID_BIT; } return i; @@ -116,7 +116,7 @@ s32 create_worker_backUI(void (*updateFunc)(void), void (*drawFunc)(void)) { worker->draw = &worker_delegate_do_nothing; } - if (gGameStatusPtr->isBattle) { + if (gGameStatusPtr->context != CONTEXT_WORLD) { i |= BATTLE_ENTITY_ID_BIT; } return i; @@ -174,7 +174,7 @@ void render_workers_backUI(void) { } void free_worker(s32 idx) { - if (!gGameStatusPtr->isBattle || (idx & BATTLE_ENTITY_ID_BIT)) { + if (gGameStatusPtr->context == CONTEXT_WORLD || (idx & BATTLE_ENTITY_ID_BIT)) { idx &= ~BATTLE_ENTITY_ID_BIT; if ((*gCurrentWorkerListPtr)[idx] != NULL) { heap_free((*gCurrentWorkerListPtr)[idx]); diff --git a/src/world/action/misc.c b/src/world/action/misc.c index a9a4892f3c..4cfd6a7212 100644 --- a/src/world/action/misc.c +++ b/src/world/action/misc.c @@ -155,7 +155,7 @@ void action_update_first_strike(void) { if (playerStatus->curStateTime != 0) { playerStatus->curStateTime--; - } else if (!gGameStatusPtr->isBattle) { + } else if (gGameStatusPtr->context == CONTEXT_WORLD) { set_action_state(ACTION_STATE_IDLE); } } diff --git a/src/world/area_dgb/dgb_08/npc.c b/src/world/area_dgb/dgb_08/npc.c index f27fb92769..004544ff73 100644 --- a/src/world/area_dgb/dgb_08/npc.c +++ b/src/world/area_dgb/dgb_08/npc.c @@ -90,7 +90,7 @@ API_CALLABLE(N(SetTubbaPatrolTerritory)) { API_CALLABLE(N(SetTubbaPatrolMode)) { if (get_enemy_safe(NPC_Tubba)) { Enemy* enemy = get_enemy(NPC_Tubba); - enemy->aiFlags |= ENEMY_AI_FLAG_80; + enemy->aiFlags |= AI_FLAG_80; return ApiStatus_DONE2; } diff --git a/src/world/area_dro/dro_02/npc.c b/src/world/area_dro/dro_02/npc.c index 1e52ee03b7..ac0a2f2e91 100644 --- a/src/world/area_dro/dro_02/npc.c +++ b/src/world/area_dro/dro_02/npc.c @@ -34,7 +34,7 @@ NpcSettings N(NpcSettings_Archeologist_Wander) = { .radius = 24, .ai = &N(EVS_NpcAI_Archeologist), .level = ACTOR_LEVEL_NONE, - .actionFlags = ENEMY_AI_FLAG_10, + .actionFlags = AI_FLAG_SKIP_IDLE_ANIM_AFTER_FLEE, }; NpcSettings N(NpcSettings_Archeologist) = { diff --git a/src/world/area_gv/gv_01/main.c b/src/world/area_gv/gv_01/main.c index 728b4ea84a..657611f05d 100644 --- a/src/world/area_gv/gv_01/main.c +++ b/src/world/area_gv/gv_01/main.c @@ -282,7 +282,7 @@ API_CALLABLE(N(FadeToTitleScreen)) { } API_CALLABLE(N(ChangeStateToTitleScreen)) { - gGameStatusPtr->isBattle = FALSE; + gGameStatusPtr->context = CONTEXT_WORLD; gGameStatusPtr->debugUnused1 = FALSE; gGameStatusPtr->debugScripts = DEBUG_SCRIPTS_NONE; gGameStatusPtr->keepUsingPartnerOnMapChange = FALSE; diff --git a/src/world/area_omo/omo_09/npc.c b/src/world/area_omo/omo_09/npc.c index 6268f49490..cecd192de9 100644 --- a/src/world/area_omo/omo_09/npc.c +++ b/src/world/area_omo/omo_09/npc.c @@ -406,7 +406,7 @@ NpcData N(NpcData_ShyGuy_Thief) = { .flags = ENEMY_FLAG_IGNORE_ENTITY_COLLISION | ENEMY_FLAG_FLYING, .drops = SHY_GUY_DROPS, .animations = YELLOW_SHY_GUY_ANIMS, - .aiFlags = ENEMY_AI_FLAG_1, + .aiFlags = AI_FLAG_1, .aiDetectFlags = AI_DETECT_SIGHT, }; diff --git a/src/world/common/enemy/ai/AvoidPlayerAI.inc.c b/src/world/common/enemy/ai/AvoidPlayerAI.inc.c index 4a52747cd6..3b58c3d242 100644 --- a/src/world/common/enemy/ai/AvoidPlayerAI.inc.c +++ b/src/world/common/enemy/ai/AvoidPlayerAI.inc.c @@ -181,7 +181,7 @@ API_CALLABLE(N(AvoidPlayerAI_Main)) { enemy->unk_118 = 0.01f; #endif - if (isInitialCall || (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND)) { + if (isInitialCall || (enemy->aiFlags & AI_FLAG_SUSPEND)) { script->functionTemp[0] = AI_STATE_WANDER_INIT; npc->duration = 0; npc->curAnim = enemy->animList[ENEMY_ANIM_INDEX_IDLE]; @@ -193,10 +193,10 @@ API_CALLABLE(N(AvoidPlayerAI_Main)) { npc->flags &= ~NPC_FLAG_GRAVITY; npc->flags |= NPC_FLAG_FLYING; } - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { script->functionTemp[0] = AI_STATE_SUSPEND; script->functionTemp[1] = AI_STATE_WANDER_INIT; - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; } } diff --git a/src/world/common/enemy/ai/BulletBillAI.inc.c b/src/world/common/enemy/ai/BulletBillAI.inc.c index d3afb56cd3..0f854e0145 100644 --- a/src/world/common/enemy/ai/BulletBillAI.inc.c +++ b/src/world/common/enemy/ai/BulletBillAI.inc.c @@ -49,18 +49,18 @@ API_CALLABLE(N(BulletBillAI_Main)) { if (isInitialCall || enemy->VAR_PROJECTILE_HITBOX_STATE == PROJECTILE_HITBOX_STATE_DONE) { script->AI_TEMP_STATE = AI_STATE_BULLET_INIT; npc->duration = 0; - enemy->aiFlags |= ENEMY_AI_FLAG_8; + enemy->aiFlags |= AI_FLAG_SKIP_EMOTE_AFTER_FLEE; enemy->flags |= ENEMY_FLAG_ACTIVE_WHILE_OFFSCREEN; npc->flags |= NPC_FLAG_IGNORE_CAMERA_FOR_YAW; enemy->VAR_PROJECTILE_HITBOX_STATE = PROJECTILE_HITBOX_STATE_NONE; enemy->AI_VAR_BULLET_BLASTER = -1; } - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { if (enemy->aiSuspendTime != 0) { return 0; } - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; } switch (script->AI_TEMP_STATE) { @@ -172,12 +172,12 @@ API_CALLABLE(N(BillBlasterAI_Main)) { return ApiStatus_BLOCK; } - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { npc->curAnim = enemy->animList[ENEMY_ANIM_INDEX_IDLE]; if (enemy->aiSuspendTime != 0) { return ApiStatus_BLOCK; } - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; } switch (script->AI_TEMP_STATE) { diff --git a/src/world/common/enemy/ai/CleftAI.inc.c b/src/world/common/enemy/ai/CleftAI.inc.c index 9751a1dfca..2520ad09e7 100644 --- a/src/world/common/enemy/ai/CleftAI.inc.c +++ b/src/world/common/enemy/ai/CleftAI.inc.c @@ -188,7 +188,7 @@ void N(CleftAI_Tackle)(Evt* script, MobileAISettings* aiSettings, EnemyDetectVol spawn_surface_effects(npc, SURFACE_INTERACT_RUN); npc_move_heading(npc, npc->moveSpeed, npc->yaw); - if (is_point_within_region(enemy->territory->wander.detectShape, + if (is_point_outside_territory(enemy->territory->wander.detectShape, enemy->territory->wander.detectPos.x, enemy->territory->wander.detectPos.z, npc->pos.x, npc->pos.z, enemy->territory->wander.detectSize.x, enemy->territory->wander.detectSize.z)) { @@ -316,11 +316,11 @@ API_CALLABLE(N(CleftAI_Main)) { } } - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { if (enemy->aiSuspendTime) { return ApiStatus_BLOCK; } - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; } if (((script->AI_TEMP_STATE == AI_STATE_CLEFT_CHASE_INIT) diff --git a/src/world/common/enemy/ai/ClubbaNappingAI.inc.c b/src/world/common/enemy/ai/ClubbaNappingAI.inc.c index e45b53aa23..d64af7ab72 100644 --- a/src/world/common/enemy/ai/ClubbaNappingAI.inc.c +++ b/src/world/common/enemy/ai/ClubbaNappingAI.inc.c @@ -216,7 +216,7 @@ API_CALLABLE(N(ClubbaNappingAI_Main)) { territory.halfHeight = 40.0f; territory.detectFlags = 0; - if (isInitialCall || (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND)) { + if (isInitialCall || (enemy->aiFlags & AI_FLAG_SUSPEND)) { script->AI_TEMP_STATE = AI_STATE_NAPPING_CLUBBA_INIT; npc->duration = 30; npc->curAnim = enemy->animList[10]; @@ -227,12 +227,12 @@ API_CALLABLE(N(ClubbaNappingAI_Main)) { } else { npc->flags = (npc->flags & ~NPC_FLAG_GRAVITY) | NPC_FLAG_FLYING; } - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { script->AI_TEMP_STATE = AI_STATE_SUSPEND; script->AI_TEMP_STATE_AFTER_SUSPEND = AI_RETURN_HOME_INIT; npc->curAnim = enemy->animList[ENEMY_ANIM_INDEX_IDLE]; } - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; } if (script->AI_TEMP_STATE >= AI_STATE_ALERT_INIT diff --git a/src/world/common/enemy/ai/ClubbaPatrolAI.inc.c b/src/world/common/enemy/ai/ClubbaPatrolAI.inc.c index 104a3da7a6..16abb845f9 100644 --- a/src/world/common/enemy/ai/ClubbaPatrolAI.inc.c +++ b/src/world/common/enemy/ai/ClubbaPatrolAI.inc.c @@ -22,7 +22,7 @@ API_CALLABLE(N(ClubbaPatrolAI_Main)) { territory.halfHeight = 65.0f; territory.detectFlags = 0; - if (isInitialCall || (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND)) { + if (isInitialCall || (enemy->aiFlags & AI_FLAG_SUSPEND)) { script->AI_TEMP_STATE = AI_STATE_PATROL_INIT; npc->duration = 0; npc->curAnim = enemy->animList[ENEMY_ANIM_INDEX_IDLE]; @@ -34,10 +34,10 @@ API_CALLABLE(N(ClubbaPatrolAI_Main)) { npc->flags &= ~NPC_FLAG_GRAVITY; npc->flags |= NPC_FLAG_FLYING; } - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { script->AI_TEMP_STATE = AI_STATE_SUSPEND; script->functionTemp[1] = AI_STATE_PATROL_INIT; - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; } enemy->varTable[0] = 0; } diff --git a/src/world/common/enemy/ai/FlyingAI.inc.c b/src/world/common/enemy/ai/FlyingAI.inc.c index 2d427a3c20..77cd61207f 100644 --- a/src/world/common/enemy/ai/FlyingAI.inc.c +++ b/src/world/common/enemy/ai/FlyingAI.inc.c @@ -20,7 +20,7 @@ void N(FlyingAI_WanderInit)(Evt* script, MobileAISettings* aiSettings, EnemyDete Npc* npc = get_npc_unsafe(enemy->npcID); npc->duration = aiSettings->moveTime / 2 + rand_int(aiSettings->moveTime / 2 + 1); - if (is_point_within_region(enemy->territory->wander.wanderShape, + if (is_point_outside_territory(enemy->territory->wander.wanderShape, enemy->territory->wander.centerPos.x, enemy->territory->wander.centerPos.z, npc->pos.x, npc->pos.z, enemy->territory->wander.wanderSize.x, enemy->territory->wander.wanderSize.z)) { @@ -151,7 +151,7 @@ void N(FlyingAI_Wander)(Evt* script, MobileAISettings* aiSettings, EnemyDetectVo enemy->varTable[9]--; } - if (is_point_within_region(enemy->territory->wander.wanderShape, + if (is_point_outside_territory(enemy->territory->wander.wanderShape, enemy->territory->wander.centerPos.x, enemy->territory->wander.centerPos.z, npc->pos.x, npc->pos.z, @@ -428,7 +428,7 @@ void N(FlyingAI_Init)(Npc* npc, Enemy* enemy, Evt* script, MobileAISettings* aiS enemy->varTable[3] = (depth * 100.0) + 0.5; enemy->varTable[7] = (posY * 100.0) + 0.5; script->functionTemp[1] = aiSettings->playerSearchInterval; - enemy->aiFlags |= ENEMY_AI_FLAG_10; + enemy->aiFlags |= AI_FLAG_SKIP_IDLE_ANIM_AFTER_FLEE; } API_CALLABLE(N(FlyingAI_Main)) { @@ -466,11 +466,11 @@ API_CALLABLE(N(FlyingAI_Main)) { npc->verticalRenderOffset = -2; - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { if (enemy->aiSuspendTime != 0) { return ApiStatus_BLOCK; } - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; } switch (script->AI_TEMP_STATE) { diff --git a/src/world/common/enemy/ai/FlyingMagikoopaAI.inc.c b/src/world/common/enemy/ai/FlyingMagikoopaAI.inc.c index d15f12ab70..232a423bac 100644 --- a/src/world/common/enemy/ai/FlyingMagikoopaAI.inc.c +++ b/src/world/common/enemy/ai/FlyingMagikoopaAI.inc.c @@ -60,7 +60,7 @@ void N(FlyingMagikoopaAI_15)(Evt* arg0, MobileAISettings* arg1, EnemyDetectVolum if (npc->duration <= 0) { randomDist = rand_int(30) + 180.0; isCCW = FALSE; - if (is_point_within_region(enemy->territory->wander.wanderShape, enemy->territory->wander.centerPos.x, enemy->territory->wander.centerPos.z, npc->pos.x, npc->pos.z, enemy->territory->wander.wanderSize.x, enemy->territory->wander.wanderSize.z)) { + if (is_point_outside_territory(enemy->territory->wander.wanderShape, enemy->territory->wander.centerPos.x, enemy->territory->wander.centerPos.z, npc->pos.x, npc->pos.z, enemy->territory->wander.wanderSize.x, enemy->territory->wander.wanderSize.z)) { npc->yaw = atan2(npc->pos.x, npc->pos.z, enemy->territory->wander.centerPos.x, enemy->territory->wander.centerPos.z) - iterations; moveDist = dist2D(npc->pos.x, npc->pos.z, enemy->territory->wander.centerPos.x, enemy->territory->wander.centerPos.z); if (randomDist > moveDist) { @@ -307,11 +307,11 @@ API_CALLABLE(N(FlyingMagikoopaAI_Main)) { npc->verticalRenderOffset = -5; - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { if (enemy->aiSuspendTime != 0) { return ApiStatus_BLOCK; } - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; } switch (script->AI_TEMP_STATE) { diff --git a/src/world/common/enemy/ai/FlyingNoAttackAI.inc.c b/src/world/common/enemy/ai/FlyingNoAttackAI.inc.c index 22668fdda6..e1ddd9d59c 100644 --- a/src/world/common/enemy/ai/FlyingNoAttackAI.inc.c +++ b/src/world/common/enemy/ai/FlyingNoAttackAI.inc.c @@ -127,11 +127,11 @@ API_CALLABLE(N(FlyingNoAttackAI_Main)) { } npc->verticalRenderOffset = -2; - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { if (enemy->aiSuspendTime) { return ApiStatus_BLOCK; } - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; } switch (script->functionTemp[0]) { diff --git a/src/world/common/enemy/ai/GrooveGuyAI.inc.c b/src/world/common/enemy/ai/GrooveGuyAI.inc.c index f8307a828c..472a229960 100644 --- a/src/world/common/enemy/ai/GrooveGuyAI.inc.c +++ b/src/world/common/enemy/ai/GrooveGuyAI.inc.c @@ -86,7 +86,7 @@ API_CALLABLE(N(GrooveGuyAI_Main)) { territory.halfHeight = 65.0f; territory.detectFlags = 0; - if (isInitialCall || enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (isInitialCall || enemy->aiFlags & AI_FLAG_SUSPEND) { script->functionTemp[0] = 0; npc->duration = 0; npc->curAnim = enemy->animList[ENEMY_ANIM_INDEX_IDLE]; @@ -100,13 +100,13 @@ API_CALLABLE(N(GrooveGuyAI_Main)) { npc->flags |= NPC_FLAG_FLYING; } - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { script->functionTemp[0] = 99; script->functionTemp[1] = 0; } else if (enemy->flags & ENEMY_FLAG_BEGIN_WITH_CHASING) { script->functionTemp[0] = 12; } - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; enemy->flags &= ~ENEMY_FLAG_BEGIN_WITH_CHASING; hitDepth = 100.0f; diff --git a/src/world/common/enemy/ai/GuardAI.inc.c b/src/world/common/enemy/ai/GuardAI.inc.c index 643ec8f42f..e346135506 100644 --- a/src/world/common/enemy/ai/GuardAI.inc.c +++ b/src/world/common/enemy/ai/GuardAI.inc.c @@ -205,7 +205,7 @@ API_CALLABLE(N(GuardAI_Main)) { territory.halfHeight = 65.0f; territory.detectFlags = 0; - if (isInitialCall || (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND)) { + if (isInitialCall || (enemy->aiFlags & AI_FLAG_SUSPEND)) { script->AI_TEMP_STATE = AI_STATE_GUARD_IDLE_INIT; npc->duration = 0; enemy->varTable[0] = npc->yaw; @@ -220,10 +220,10 @@ API_CALLABLE(N(GuardAI_Main)) { npc->flags |= NPC_FLAG_FLYING; } - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { script->AI_TEMP_STATE = AI_STATE_SUSPEND; script->functionTemp[1] = 15; - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; } else if (enemy->flags & ENEMY_FLAG_BEGIN_WITH_CHASING) { script->AI_TEMP_STATE = AI_STATE_CHASE_INIT; enemy->flags &= ~ENEMY_FLAG_BEGIN_WITH_CHASING; diff --git a/src/world/common/enemy/ai/HoppingAI.inc.c b/src/world/common/enemy/ai/HoppingAI.inc.c index b28b00b7f3..540ab286bb 100644 --- a/src/world/common/enemy/ai/HoppingAI.inc.c +++ b/src/world/common/enemy/ai/HoppingAI.inc.c @@ -14,7 +14,7 @@ void N(HoppingAI_HopInit)(Evt* script, MobileAISettings* aiSettings, EnemyDetect npc->jumpScale = 1.5f; ai_enemy_play_sound(npc, SOUND_SEQ_FUZZY_HOP, 0); - if (is_point_within_region(enemy->territory->wander.wanderShape, + if (is_point_outside_territory(enemy->territory->wander.wanderShape, enemy->territory->wander.centerPos.x, enemy->territory->wander.centerPos.z, npc->pos.x, npc->pos.z, @@ -245,18 +245,18 @@ API_CALLABLE(N(HoppingAI_Main)) { npc->flags &= ~NPC_FLAG_GRAVITY; npc->flags |= NPC_FLAG_FLYING; - enemy->aiFlags |= (ENEMY_AI_FLAG_8 | ENEMY_AI_FLAG_10); + enemy->aiFlags |= (AI_FLAG_SKIP_EMOTE_AFTER_FLEE | AI_FLAG_SKIP_IDLE_ANIM_AFTER_FLEE); if (enemy->flags & ENEMY_FLAG_BEGIN_WITH_CHASING) { script->AI_TEMP_STATE = AI_STATE_CHASE_INIT; enemy->flags &= ~ENEMY_FLAG_BEGIN_WITH_CHASING; } } - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { if (enemy->aiSuspendTime != 0) { return ApiStatus_BLOCK; } - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; } switch (script->AI_TEMP_STATE) { diff --git a/src/world/common/enemy/ai/KoopaPatrolAI.inc.c b/src/world/common/enemy/ai/KoopaPatrolAI.inc.c index 5cda665ed8..6c29734cdc 100644 --- a/src/world/common/enemy/ai/KoopaPatrolAI.inc.c +++ b/src/world/common/enemy/ai/KoopaPatrolAI.inc.c @@ -25,10 +25,10 @@ API_CALLABLE(N(KoopaPatrolAI_Main)) { if (isInitialCall) { enemy->varTable[6] = npc->collisionHeight; - enemy->aiFlags |= ENEMY_AI_FLAG_8; + enemy->aiFlags |= AI_FLAG_SKIP_EMOTE_AFTER_FLEE; } - if (isInitialCall || (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND)) { + if (isInitialCall || (enemy->aiFlags & AI_FLAG_SUSPEND)) { npc->duration = 0; script->functionTemp[0] = 0; enemy->hitboxIsActive = FALSE; @@ -46,13 +46,13 @@ API_CALLABLE(N(KoopaPatrolAI_Main)) { npc->flags |= NPC_FLAG_FLYING; } - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { EffectInstance* emoteTemp; script->functionTemp[0] = 99; script->functionTemp[1] = 0; fx_emote(EMOTE_QUESTION, npc, 0.0f, npc->collisionHeight, 1.0f, 2.0f, -20.0f, 40, &emoteTemp); - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; } else if (enemy->flags & ENEMY_FLAG_BEGIN_WITH_CHASING) { script->functionTemp[0] = AI_STATE_CHASE_INIT; enemy->flags &= ~ENEMY_FLAG_BEGIN_WITH_CHASING; diff --git a/src/world/common/enemy/ai/LakituAI.inc.c b/src/world/common/enemy/ai/LakituAI.inc.c index 8f60b92a1e..03581ea0e1 100644 --- a/src/world/common/enemy/ai/LakituAI.inc.c +++ b/src/world/common/enemy/ai/LakituAI.inc.c @@ -75,7 +75,7 @@ void N(LakituAI_Wander)(Evt* script, MobileAISettings* aiSettings, EnemyDetectVo script->functionTemp[1]--; } - if (is_point_within_region(enemy->territory->wander.wanderShape, enemy->territory->wander.centerPos.x, + if (is_point_outside_territory(enemy->territory->wander.wanderShape, enemy->territory->wander.centerPos.x, enemy->territory->wander.centerPos.z, npc->pos.x, npc->pos.z, enemy->territory->wander.wanderSize.x, enemy->territory->wander.wanderSize.z) != 0) { npc->yaw = atan2(npc->pos.x, npc->pos.z, enemy->territory->wander.centerPos.x, enemy->territory->wander.centerPos.z); @@ -192,11 +192,11 @@ API_CALLABLE(N(LakituAI_Main)) { } npc->verticalRenderOffset = -3; - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { if (enemy->aiSuspendTime != 0) { return ApiStatus_BLOCK; } - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; } switch (script->AI_TEMP_STATE) { @@ -283,7 +283,7 @@ API_CALLABLE(N(LakituAI_Main)) { npc->yaw = atan2(npc->pos.x, npc->pos.z, gPlayerStatusPtr->pos.x, gPlayerStatusPtr->pos.z); playerDist = dist2D(gPlayerStatusPtr->pos.x, gPlayerStatusPtr->pos.z, npc->pos.x, npc->pos.z); - if (!is_point_within_region(territoryPtr->shape, + if (!is_point_outside_territory(territoryPtr->shape, territoryPtr->pointX, territoryPtr->pointZ, npc->pos.x, npc->pos.z, territoryPtr->sizeX, territoryPtr->sizeZ)) { diff --git a/src/world/common/enemy/ai/MagikoopaAI.inc.c b/src/world/common/enemy/ai/MagikoopaAI.inc.c index fc14f49297..28da0d602b 100644 --- a/src/world/common/enemy/ai/MagikoopaAI.inc.c +++ b/src/world/common/enemy/ai/MagikoopaAI.inc.c @@ -248,14 +248,14 @@ API_CALLABLE(N(MagikoopaAI_Main)) { territory.halfHeight = 100.0f; territory.detectFlags = 0; - if (isInitialCall || (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND)) { + if (isInitialCall || (enemy->aiFlags & AI_FLAG_SUSPEND)) { npc->curAnim = enemy->animList[0]; npc->flags &= ~NPC_FLAG_JUMPING; npc->flags |= NPC_FLAG_200000; enemy->flags |= ENEMY_FLAG_ACTIVE_WHILE_OFFSCREEN; npc->duration = 0; - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + if (enemy->aiFlags & AI_FLAG_SUSPEND) { + enemy->aiFlags &= ~AI_FLAG_SUSPEND; npc->alpha = 0xFF; npc->duration = 20; npc->scale.x = 1.0f; diff --git a/src/world/common/enemy/ai/MagikoopaSpellAI.inc.c b/src/world/common/enemy/ai/MagikoopaSpellAI.inc.c index 18626fd89a..f33298362e 100644 --- a/src/world/common/enemy/ai/MagikoopaSpellAI.inc.c +++ b/src/world/common/enemy/ai/MagikoopaSpellAI.inc.c @@ -48,7 +48,7 @@ API_CALLABLE(N(MagikoopaAI_SpellMain)) { f32 t1; f32 t2; - if (isInitialCall || (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND)) { + if (isInitialCall || (enemy->aiFlags & AI_FLAG_SUSPEND)) { script->functionTemp[0] = 0; npc1->duration = 0; npc1->flags |= NPC_FLAG_200000 | NPC_FLAG_IGNORE_CAMERA_FOR_YAW | NPC_FLAG_IGNORE_PLAYER_COLLISION | NPC_FLAG_INVISIBLE; @@ -56,8 +56,8 @@ API_CALLABLE(N(MagikoopaAI_SpellMain)) { ENEMY_FLAG_ACTIVE_WHILE_OFFSCREEN | ENEMY_FLAG_PROJECTILE; npc1->scale.x = 0.4f; npc1->scale.y = 0.4f; - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + if (enemy->aiFlags & AI_FLAG_SUSPEND) { + enemy->aiFlags &= ~AI_FLAG_SUSPEND; } } diff --git a/src/world/common/enemy/ai/MeleeHitbox.inc.c b/src/world/common/enemy/ai/MeleeHitbox.inc.c index 24baea7dbe..f7a7c5c0da 100644 --- a/src/world/common/enemy/ai/MeleeHitbox.inc.c +++ b/src/world/common/enemy/ai/MeleeHitbox.inc.c @@ -112,7 +112,7 @@ API_CALLABLE(N(MeleeHitbox_Main)) { hitboxEnemy->unk_118 = 0.0001f; #endif - if (isInitialCall || (hitboxEnemy->aiFlags & ENEMY_AI_FLAG_SUSPEND)) { + if (isInitialCall || (hitboxEnemy->aiFlags & AI_FLAG_SUSPEND)) { script->functionTemp[0] = 0; hitboxNpc->duration = 0; hitboxNpc->flags |= (NPC_FLAG_INVISIBLE | NPC_FLAG_IGNORE_PLAYER_COLLISION); @@ -120,8 +120,8 @@ API_CALLABLE(N(MeleeHitbox_Main)) { hitboxNpc->pos.x = NPC_DISPOSE_POS_X; hitboxNpc->pos.y = NPC_DISPOSE_POS_Y; hitboxNpc->pos.z = NPC_DISPOSE_POS_Z; - if (hitboxEnemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { - hitboxEnemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + if (hitboxEnemy->aiFlags & AI_FLAG_SUSPEND) { + hitboxEnemy->aiFlags &= ~AI_FLAG_SUSPEND; } } diff --git a/src/world/common/enemy/ai/MontyMoleAI.inc.c b/src/world/common/enemy/ai/MontyMoleAI.inc.c index 423dfac0b3..8c3f416827 100644 --- a/src/world/common/enemy/ai/MontyMoleAI.inc.c +++ b/src/world/common/enemy/ai/MontyMoleAI.inc.c @@ -27,7 +27,13 @@ enum AiStateMontyMole { AI_STATE_MOLE_BURROW = 21, // burrow underground }; -#define MONTY_MOLE_UNK_NPC_FLAGS 0x1F100000 +#define INTANGIBLE_MONTY_MOLE_NPC_FLAGS \ + ENEMY_FLAG_100000 \ + | ENEMY_FLAG_IGNORE_TOUCH \ + | ENEMY_FLAG_IGNORE_JUMP \ + | ENEMY_FLAG_IGNORE_HAMMER \ + | ENEMY_FLAG_IGNORE_PARTNER \ + | ENEMY_FLAG_CANT_INTERACT static s32 N(MontyMoleAI_CanAttack)(Evt* script, EnemyDetectVolume* territory, f32 radius, f32 arg3) { Camera* cam; @@ -74,7 +80,7 @@ static void N(MontyMoleAI_Init)(Evt* script, MobileAISettings* aiSettings, Enemy } else { npc->moveSpeed = enemy->territory->wander.moveSpeedOverride / 32767.0; } - enemy->flags |= MONTY_MOLE_UNK_NPC_FLAGS; + enemy->flags |= INTANGIBLE_MONTY_MOLE_NPC_FLAGS; npc->flags |= NPC_FLAG_INVISIBLE; script->functionTemp[1] = 0; script->AI_TEMP_STATE = AI_STATE_MOLE_WANDER; @@ -86,7 +92,7 @@ static void N(MontyMoleAI_Wander)(Evt* script, MobileAISettings* aiSettings, Ene Npc dummyNpc; f32 hitDepth; - if (is_point_within_region(enemy->territory->wander.wanderShape, + if (is_point_outside_territory(enemy->territory->wander.wanderShape, enemy->territory->wander.centerPos.x, enemy->territory->wander.centerPos.z, npc->pos.x, npc->pos.z, enemy->territory->wander.wanderSize.x, enemy->territory->wander.wanderSize.z)) { @@ -142,7 +148,7 @@ static void N(MontyMoleAI_Surface)(Evt* script, MobileAISettings* aiSettings, En npc->duration--; if (npc->duration == 2) { - enemy->flags &= ~MONTY_MOLE_UNK_NPC_FLAGS; + enemy->flags &= ~(INTANGIBLE_MONTY_MOLE_NPC_FLAGS); } if (npc->duration <= 0) { npc->curAnim = ANIM_MontyMole_Anim18; // get and throw rock @@ -217,7 +223,7 @@ static void N(MontyMoleAI_Burrow)(Evt* script, MobileAISettings* aiSettings, Ene npc->duration--; if (npc->duration == 3) { - enemy->flags |= MONTY_MOLE_UNK_NPC_FLAGS; + enemy->flags |= INTANGIBLE_MONTY_MOLE_NPC_FLAGS; } if (npc->duration <= 0) { npc->flags |= NPC_FLAG_INVISIBLE; @@ -246,12 +252,12 @@ API_CALLABLE(N(MontyMoleAI_Main)) { script->AI_TEMP_STATE = AI_STATE_MOLE_INIT; npc->duration = 0; npc->flags &= ~NPC_FLAG_JUMPING; - enemy->aiFlags |= (ENEMY_AI_FLAG_8 | ENEMY_AI_FLAG_10); + enemy->aiFlags |= (AI_FLAG_SKIP_EMOTE_AFTER_FLEE | AI_FLAG_SKIP_IDLE_ANIM_AFTER_FLEE); } - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { if (enemy->aiSuspendTime == 0) { - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; } else { return ApiStatus_BLOCK; } diff --git a/src/world/common/enemy/ai/ParatroopaAI.inc.c b/src/world/common/enemy/ai/ParatroopaAI.inc.c index 8a6880106b..05b48a40c7 100644 --- a/src/world/common/enemy/ai/ParatroopaAI.inc.c +++ b/src/world/common/enemy/ai/ParatroopaAI.inc.c @@ -121,11 +121,11 @@ API_CALLABLE(N(ParatroopaAI_Main)) { npc->verticalRenderOffset = -3; - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { if (enemy->aiSuspendTime != 0) { return ApiStatus_BLOCK; } - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; } switch (script->AI_TEMP_STATE) { diff --git a/src/world/common/enemy/ai/PatrolNoAttackAI.inc.c b/src/world/common/enemy/ai/PatrolNoAttackAI.inc.c index a765e07c8b..d531491605 100644 --- a/src/world/common/enemy/ai/PatrolNoAttackAI.inc.c +++ b/src/world/common/enemy/ai/PatrolNoAttackAI.inc.c @@ -33,7 +33,7 @@ API_CALLABLE(N(PatrolNoAttackAI_Main)) { enemy->unk_118 = 0.0001f; #endif - if (isInitialCall || enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (isInitialCall || enemy->aiFlags & AI_FLAG_SUSPEND) { script->AI_TEMP_STATE = AI_STATE_PATROL_INIT; npc->duration = 0; npc->curAnim = enemy->animList[ENEMY_ANIM_INDEX_IDLE]; @@ -47,10 +47,10 @@ API_CALLABLE(N(PatrolNoAttackAI_Main)) { npc->flags |= NPC_FLAG_FLYING; } - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { script->AI_TEMP_STATE = AI_STATE_SUSPEND; script->functionTemp[1] = 0; - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; } else if (enemy->flags & ENEMY_FLAG_BEGIN_WITH_CHASING) { script->AI_TEMP_STATE = AI_STATE_CHASE_INIT; enemy->flags &= ~ENEMY_FLAG_BEGIN_WITH_CHASING; diff --git a/src/world/common/enemy/ai/PiranhaPlantAI.inc.c b/src/world/common/enemy/ai/PiranhaPlantAI.inc.c index 45049e06af..410460b79b 100644 --- a/src/world/common/enemy/ai/PiranhaPlantAI.inc.c +++ b/src/world/common/enemy/ai/PiranhaPlantAI.inc.c @@ -164,7 +164,7 @@ void N(PiranhaPlantAI_10)(Evt* script, MobileAISettings* aiSettings, EnemyDetect } } - if (is_point_within_region(territory->shape, territory->pointX, territory->pointZ, npc->pos.x, npc->pos.z, territory->sizeX, territory->sizeZ)) { + if (is_point_outside_territory(territory->shape, territory->pointX, territory->pointZ, npc->pos.x, npc->pos.z, territory->sizeX, territory->sizeZ)) { switch (territory->shape) { case SHAPE_CYLINDER: sp38 = dist2D(npc->pos.x, npc->pos.z, territory->pointX, territory->pointZ); @@ -319,16 +319,16 @@ API_CALLABLE(N(PiranhaPlantAI_Main)) { } #endif - if (isInitialCall || (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND)) { + if (isInitialCall || (enemy->aiFlags & AI_FLAG_SUSPEND)) { script->AI_TEMP_STATE = AI_STATE_PIRANHA_PLANT_00; npc->duration = 0; npc->curAnim = enemy->animList[ENEMY_ANIM_INDEX_IDLE]; enemy->AI_VAR_ATTACK_STATE = MELEE_HITBOX_STATE_NONE; - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { script->AI_TEMP_STATE = AI_STATE_SUSPEND; script->functionTemp[1] = AI_STATE_PIRANHA_PLANT_00; - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; } } diff --git a/src/world/common/enemy/ai/ProjectileHitbox.inc.c b/src/world/common/enemy/ai/ProjectileHitbox.inc.c index ececea58cb..d0904e508c 100644 --- a/src/world/common/enemy/ai/ProjectileHitbox.inc.c +++ b/src/world/common/enemy/ai/ProjectileHitbox.inc.c @@ -149,7 +149,7 @@ API_CALLABLE(N(ProjectileAI_Main)) { npc->verticalRenderOffset = npc->collisionHeight / 2; } - if (isInitialCall || (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND)) { + if (isInitialCall || (enemy->aiFlags & AI_FLAG_SUSPEND)) { script->functionTemp[0] = 0; npc->duration = 0; npc->flags |= NPC_FLAG_IGNORE_CAMERA_FOR_YAW | NPC_FLAG_IGNORE_PLAYER_COLLISION | NPC_FLAG_INVISIBLE; @@ -159,8 +159,8 @@ API_CALLABLE(N(ProjectileAI_Main)) { enemy->flags |= ENEMY_FLAG_IGNORE_PARTNER | ENEMY_FLAG_CANT_INTERACT | ENEMY_FLAG_IGNORE_HAMMER | ENEMY_FLAG_IGNORE_JUMP | ENEMY_FLAG_IGNORE_TOUCH | ENEMY_FLAG_ACTIVE_WHILE_OFFSCREEN | ENEMY_FLAG_100000 | ENEMY_FLAG_PROJECTILE; - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + if (enemy->aiFlags & AI_FLAG_SUSPEND) { + enemy->aiFlags &= ~AI_FLAG_SUSPEND; } } diff --git a/src/world/common/enemy/ai/RangedAttackAI.inc.c b/src/world/common/enemy/ai/RangedAttackAI.inc.c index 3831cd00c4..b267203780 100644 --- a/src/world/common/enemy/ai/RangedAttackAI.inc.c +++ b/src/world/common/enemy/ai/RangedAttackAI.inc.c @@ -29,7 +29,7 @@ API_CALLABLE(N(RangedAttackAI_Main)) { territory.halfHeight = 40.0f; territory.detectFlags = 0; - if (isInitialCall || (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND)) { + if (isInitialCall || (enemy->aiFlags & AI_FLAG_SUSPEND)) { script->AI_TEMP_STATE = 0; npc->duration = 0; npc->curAnim = enemy->animList[ENEMY_ANIM_INDEX_IDLE]; @@ -43,14 +43,14 @@ API_CALLABLE(N(RangedAttackAI_Main)) { npc->flags |= NPC_FLAG_FLYING; } - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { script->AI_TEMP_STATE = AI_STATE_SUSPEND; script->functionTemp[1] = 0; - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; } else if (enemy->flags & ENEMY_FLAG_BEGIN_WITH_CHASING) { script->AI_TEMP_STATE = AI_STATE_CHASE_INIT; } - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; enemy->flags &= ~ENEMY_FLAG_BEGIN_WITH_CHASING; } diff --git a/src/world/common/enemy/ai/ShyGuyPatrolAI.inc.c b/src/world/common/enemy/ai/ShyGuyPatrolAI.inc.c index 843c66c29f..532db1d75a 100644 --- a/src/world/common/enemy/ai/ShyGuyPatrolAI.inc.c +++ b/src/world/common/enemy/ai/ShyGuyPatrolAI.inc.c @@ -80,7 +80,7 @@ API_CALLABLE(N(ShyGuyPatrolAI_Main)) { territory.halfHeight = 65.0f; territory.detectFlags = 0; - if (isInitialCall || enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (isInitialCall || enemy->aiFlags & AI_FLAG_SUSPEND) { script->functionTemp[0] = 0; npc->duration = 0; npc->curAnim = enemy->animList[ENEMY_ANIM_INDEX_IDLE]; @@ -94,10 +94,10 @@ API_CALLABLE(N(ShyGuyPatrolAI_Main)) { npc->flags |= NPC_FLAG_FLYING; } - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { script->functionTemp[0] = 99; script->functionTemp[1] = 0; - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; } else if (enemy->flags & ENEMY_FLAG_BEGIN_WITH_CHASING) { script->functionTemp[0] = 12; enemy->flags &= ~ENEMY_FLAG_BEGIN_WITH_CHASING; diff --git a/src/world/common/enemy/ai/ShyGuyWanderAI.inc.c b/src/world/common/enemy/ai/ShyGuyWanderAI.inc.c index f1ebcb4b5e..2e2cd958be 100644 --- a/src/world/common/enemy/ai/ShyGuyWanderAI.inc.c +++ b/src/world/common/enemy/ai/ShyGuyWanderAI.inc.c @@ -78,7 +78,7 @@ API_CALLABLE(N(ShyGuyWanderAI_Main)) { territory.halfHeight = 65.0f; territory.detectFlags = 0; - if (isInitialCall || enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (isInitialCall || enemy->aiFlags & AI_FLAG_SUSPEND) { script->functionTemp[0] = 0; npc->duration = 0; npc->curAnim = enemy->animList[ENEMY_ANIM_INDEX_IDLE]; @@ -92,13 +92,13 @@ API_CALLABLE(N(ShyGuyWanderAI_Main)) { npc->flags |= NPC_FLAG_FLYING; } - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { script->functionTemp[0] = 99; script->functionTemp[1] = 0; } else if (enemy->flags & ENEMY_FLAG_BEGIN_WITH_CHASING) { script->functionTemp[0] = 12; } - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; enemy->flags &= ~ENEMY_FLAG_BEGIN_WITH_CHASING; hitDepth = 100.0f; diff --git a/src/world/common/enemy/ai/SpearGuyAI.inc.c b/src/world/common/enemy/ai/SpearGuyAI.inc.c index c6e43cad0b..9e6874f961 100644 --- a/src/world/common/enemy/ai/SpearGuyAI.inc.c +++ b/src/world/common/enemy/ai/SpearGuyAI.inc.c @@ -97,7 +97,7 @@ API_CALLABLE(N(SpearGuyAI_Main)) { territory.halfHeight = 65.0f; territory.detectFlags = 0; - if (isInitialCall || (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND)) { + if (isInitialCall || (enemy->aiFlags & AI_FLAG_SUSPEND)) { script->AI_TEMP_STATE = AI_STATE_WANDER_INIT; npc->duration = 0; npc->curAnim = enemy->animList[ENEMY_ANIM_INDEX_IDLE]; @@ -111,10 +111,10 @@ API_CALLABLE(N(SpearGuyAI_Main)) { npc->flags |= NPC_FLAG_FLYING; } - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { script->AI_TEMP_STATE = AI_STATE_SUSPEND; script->AI_TEMP_STATE_AFTER_SUSPEND = AI_STATE_WANDER_INIT; - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; } enemy->varTable[0] = 0; } diff --git a/src/world/common/enemy/ai/SpinyAI.inc.c b/src/world/common/enemy/ai/SpinyAI.inc.c index 32736d55aa..8dc567098f 100644 --- a/src/world/common/enemy/ai/SpinyAI.inc.c +++ b/src/world/common/enemy/ai/SpinyAI.inc.c @@ -38,7 +38,7 @@ API_CALLABLE(N(SpinyAI_Main)) { if (isInitialCall) { enemy->varTable[6] = npc->collisionHeight; - enemy->aiFlags |= ENEMY_AI_FLAG_8; + enemy->aiFlags |= AI_FLAG_SKIP_EMOTE_AFTER_FLEE; } if (isInitialCall || (enemy->varTable[10] == 100)) { @@ -56,10 +56,10 @@ API_CALLABLE(N(SpinyAI_Main)) { npc->pos.z = NPC_DISPOSE_POS_Z; } - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { npc->duration = 0; npc->collisionHeight = enemy->varTable[6]; - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; if (npc->flags & NPC_FLAG_JUMPING) { npc->curAnim = ANIM_Spiny_Anim18; npc->moveSpeed = 0.0f; diff --git a/src/world/common/enemy/ai/States_PatrolAI.inc.c b/src/world/common/enemy/ai/States_PatrolAI.inc.c index 30c50515b7..6062f5ca92 100644 --- a/src/world/common/enemy/ai/States_PatrolAI.inc.c +++ b/src/world/common/enemy/ai/States_PatrolAI.inc.c @@ -235,7 +235,7 @@ void N(PatrolAI_LosePlayer)(Evt* script, MobileAISettings* aiSettings, EnemyDete npc->duration--; if (npc->duration == 0) { - if (enemy->aiFlags & ENEMY_AI_FLAG_80) { + if (enemy->aiFlags & AI_FLAG_80) { script->AI_TEMP_STATE = AI_STATE_PATROL_15; } else { script->AI_TEMP_STATE = AI_STATE_WANDER_INIT; diff --git a/src/world/common/enemy/ai/SwooperAI.inc.c b/src/world/common/enemy/ai/SwooperAI.inc.c index e566263a91..b2299c93c2 100644 --- a/src/world/common/enemy/ai/SwooperAI.inc.c +++ b/src/world/common/enemy/ai/SwooperAI.inc.c @@ -24,7 +24,7 @@ API_CALLABLE(N(SwooperAI_Main)) { if (isInitialCall) { script->functionTemp[0] = 0; npc->duration = 0; - enemy->aiFlags |= ENEMY_AI_FLAG_10; + enemy->aiFlags |= AI_FLAG_SKIP_IDLE_ANIM_AFTER_FLEE; hitDepth = 1000.0f; x = npc->pos.x; y = npc->pos.y; @@ -33,9 +33,9 @@ API_CALLABLE(N(SwooperAI_Main)) { enemy->varTable[1] = y; } - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { if (enemy->aiSuspendTime == 0) { - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; } else { return ApiStatus_BLOCK; } diff --git a/src/world/common/enemy/ai/TackleAI.inc.c b/src/world/common/enemy/ai/TackleAI.inc.c index 9909c5827a..d289457796 100644 --- a/src/world/common/enemy/ai/TackleAI.inc.c +++ b/src/world/common/enemy/ai/TackleAI.inc.c @@ -40,10 +40,10 @@ API_CALLABLE(N(TackleAI_Main)) { enemy->varTable[6] = npc->collisionHeight; enemy->varTable[8] = 0; enemy->instigatorValue = 0; - enemy->aiFlags |= ENEMY_AI_FLAG_8; + enemy->aiFlags |= AI_FLAG_SKIP_EMOTE_AFTER_FLEE; } - if (isInitialCall || (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND)) { + if (isInitialCall || (enemy->aiFlags & AI_FLAG_SUSPEND)) { script->AI_TEMP_STATE = 0; npc->duration = 0; enemy->hitboxIsActive = FALSE; @@ -60,13 +60,13 @@ API_CALLABLE(N(TackleAI_Main)) { npc->flags |= NPC_FLAG_FLYING; } - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { EffectInstance* emoteTemp; script->AI_TEMP_STATE = 99; script->functionTemp[1] = 0; fx_emote(EMOTE_QUESTION, npc, 0.0f, npc->collisionHeight, 1.0f, 2.0f, -20.0f, 40, &emoteTemp); - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; } else if (enemy->flags & ENEMY_FLAG_BEGIN_WITH_CHASING) { script->AI_TEMP_STATE = 12; enemy->flags &= ~ENEMY_FLAG_BEGIN_WITH_CHASING; diff --git a/src/world/common/enemy/ai/WanderMeleeAI.inc.c b/src/world/common/enemy/ai/WanderMeleeAI.inc.c index f4dac78d9a..b8264a5b44 100644 --- a/src/world/common/enemy/ai/WanderMeleeAI.inc.c +++ b/src/world/common/enemy/ai/WanderMeleeAI.inc.c @@ -38,7 +38,7 @@ API_CALLABLE(N(WanderMeleeAI_Main)) { enemy->unk_118 = 0.0001f; #endif - if (isInitialCall || (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND)) { + if (isInitialCall || (enemy->aiFlags & AI_FLAG_SUSPEND)) { script->AI_TEMP_STATE = AI_STATE_WANDER_INIT; npc->duration = 0; npc->curAnim = enemy->animList[ENEMY_ANIM_INDEX_IDLE]; @@ -52,10 +52,10 @@ API_CALLABLE(N(WanderMeleeAI_Main)) { npc->flags |= NPC_FLAG_FLYING; } - if (enemy->aiFlags & ENEMY_AI_FLAG_SUSPEND) { + if (enemy->aiFlags & AI_FLAG_SUSPEND) { script->AI_TEMP_STATE = AI_STATE_SUSPEND; script->functionTemp[1] = AI_STATE_WANDER_INIT; - enemy->aiFlags &= ~ENEMY_AI_FLAG_SUSPEND; + enemy->aiFlags &= ~AI_FLAG_SUSPEND; } enemy->AI_VAR_ATTACK_STATE = MELEE_HITBOX_STATE_NONE; } diff --git a/tools/ignored_funcs.txt b/tools/ignored_funcs.txt index f04a8fb242..7cb6a7e052 100644 --- a/tools/ignored_funcs.txt +++ b/tools/ignored_funcs.txt @@ -26,7 +26,7 @@ dead_npc_move_heading = 0x8003E424; dead_sqrtf = 0x80067040; dead_npc_test_move_simple_with_slipping = 0x800E5304; dead_npc_raycast_down_sides = 0x800E423C; -dead_is_point_within_region = 0x8004D0C4; +dead_is_point_outside_territory = 0x8004D0C4; dead_rand_int = 0x8002ACEC; dead_get_npc_safe = 0x8003E534; // get_npc_safe dead_heap_malloc = 0x8002BFD4; diff --git a/ver/pal/undefined_syms.txt b/ver/pal/undefined_syms.txt index 7cf5637248..fe8d3aff16 100644 --- a/ver/pal/undefined_syms.txt +++ b/ver/pal/undefined_syms.txt @@ -140,7 +140,7 @@ remove_status_debuff = 0x80047D88; remove_status_static = 0x80047E90; remove_status_chill_out = 0x80048074; spawn_drops = 0x80048860; -is_point_within_region = 0x800495B4; +is_point_outside_territory = 0x800495B4; basic_ai_check_player_dist = 0x80049694; ai_check_player_dist = 0x800499CC; ai_enemy_play_sound = 0x80049AA0; diff --git a/ver/us/symbol_addrs.txt b/ver/us/symbol_addrs.txt index 2c0a0b5cbd..d8d83c6f74 100644 --- a/ver/us/symbol_addrs.txt +++ b/ver/us/symbol_addrs.txt @@ -470,7 +470,7 @@ spawn_drops = 0x80048280; // type:func rom:0x23680 get_coin_drop_amount = 0x80048D50; // type:func rom:0x24150 func_80048E34 = 0x80048E34; // type:func rom:0x24234 func_80048F0C = 0x80048F0C; // type:func rom:0x2430C -is_point_within_region = 0x80048FD4; // type:func rom:0x243D4 +is_point_outside_territory = 0x80048FD4; // type:func rom:0x243D4 basic_ai_check_player_dist = 0x800490B4; // type:func rom:0x244B4 ai_check_player_dist = 0x800493EC; // type:func rom:0x247EC ai_enemy_play_sound = 0x800494C0; // type:func rom:0x248C0 diff --git a/ver/us/undefined_syms.txt b/ver/us/undefined_syms.txt index 927b249ac3..5f175ad240 100644 --- a/ver/us/undefined_syms.txt +++ b/ver/us/undefined_syms.txt @@ -96,7 +96,7 @@ dead_GetSelfNpcID = GetSelfNpcID + 0x40B0; dead_SetEnemyFlagBits = SetEnemyFlagBits + 0x40B0; dead_GetSelfAnimationFromTable = GetSelfAnimationFromTable + 0x40B0; dead_OnPlayerFled = OnPlayerFled + 0x40B0; -dead_is_point_within_region = is_point_within_region + 0x40F0; +dead_is_point_outside_territory = is_point_outside_territory + 0x40F0; dead_basic_ai_check_player_dist = basic_ai_check_player_dist + 0x40F0; dead_ai_enemy_play_sound = ai_enemy_play_sound + 0x4340; dead_basic_ai_wander_init = basic_ai_wander_init + 0x4420;