diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a9fd3eb9..02a029376 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - added controller detection during runtime (#850) - added an option to allow cancelling Lara's ledge-swinging animation (#856) - added an option to allow Lara to jump at any point while running, similar to TR2+ (#157) +- added the ability to define the anchor room for Bacon Lara in the gameflow (#868) - changed screen resolution option to apply immediately (#114) - changed shaders to use GLSL 1.20 which should fix most issues with OpenGL 2.1 (#327, #685) - fixed sounds stopping instead of pausing if game sounds in inventory are disabled (#717) diff --git a/README.md b/README.md index 59022f412..2e4348704 100644 --- a/README.md +++ b/README.md @@ -383,6 +383,7 @@ Not all options are turned on by default. Refer to `Tomb1Main_ConfigTool.exe` fo - you no longer are constrained to 4 or 21 levels only - you can offer a custom Gym level - you can change the main menu backdrop + - you can specify the anchor room for Bacon Lara - added automatic calculation of secret counts (no longer having to fiddle with the .exe to get correct secret stats) - added save game crystals game mode (enabled via gameflow) - added per-level customizable water color (with customizable blue component) diff --git a/bin/cfg/Tomb1Main_gameflow.json5 b/bin/cfg/Tomb1Main_gameflow.json5 index 19daa048d..aaa6a40da 100644 --- a/bin/cfg/Tomb1Main_gameflow.json5 +++ b/bin/cfg/Tomb1Main_gameflow.json5 @@ -406,6 +406,7 @@ {"type": "play_fmv", "fmv_path": "fmv/pyramid.avi"}, {"type": "start_game"}, {"type": "give_item", "object_id": 84, "quantity": 1}, + {"type": "setup_bacon_lara", "anchor_room": 10}, {"type": "loop_game"}, {"type": "stop_game"}, {"type": "play_fmv", "fmv_path": "fmv/prison.avi"}, diff --git a/src/game/gameflow.c b/src/game/gameflow.c index 18cbf466e..fccc1253f 100644 --- a/src/game/gameflow.c +++ b/src/game/gameflow.c @@ -10,6 +10,7 @@ #include "game/inventory/inventory_vars.h" #include "game/lara.h" #include "game/music.h" +#include "game/objects/creatures/bacon_lara.h" #include "game/output.h" #include "game/room.h" #include "game/shell.h" @@ -614,6 +615,24 @@ static bool GameFlow_LoadLevelSequence( seq->data = swap_data; + } else if (!strcmp(type_str, "setup_bacon_lara")) { + seq->type = GFS_SETUP_BACON_LARA; + int tmp = json_object_get_int( + jseq_obj, "anchor_room", JSON_INVALID_NUMBER); + if (tmp == JSON_INVALID_NUMBER) { + LOG_ERROR( + "level %d, sequence %s: 'anchor_room' must be a number", + level_num, type_str); + return false; + } + if (tmp < 0) { + LOG_ERROR( + "level %d, sequence %s: 'anchor_room' must be >= 0", + level_num, type_str); + return false; + } + seq->data = (void *)tmp; + } else { LOG_ERROR("unknown sequence type %s", type_str); return false; @@ -1037,6 +1056,7 @@ void GameFlow_Shutdown(void) case GFS_PLAY_SYNCED_AUDIO: case GFS_REMOVE_AMMO: case GFS_REMOVE_MEDIPACKS: + case GFS_SETUP_BACON_LARA: break; } seq++; @@ -1325,6 +1345,16 @@ GameFlow_InterpretSequence(int32_t level_num, GAMEFLOW_LEVEL_TYPE level_type) break; } + case GFS_SETUP_BACON_LARA: { + int32_t anchor_room = (int32_t)seq->data; + if (!BaconLara_InitialiseAnchor(anchor_room)) { + LOG_ERROR( + "Could not anchor Bacon Lara to room %d", anchor_room); + return GF_EXIT_TO_TITLE; + } + break; + } + case GFS_END: return ret; } @@ -1356,6 +1386,7 @@ GameFlow_StorySoFar(int32_t level_num, int32_t savegame_level) case GFS_REMOVE_SCIONS: case GFS_REMOVE_AMMO: case GFS_REMOVE_MEDIPACKS: + case GFS_SETUP_BACON_LARA: break; case GFS_START_GAME: diff --git a/src/game/objects/creatures/bacon_lara.c b/src/game/objects/creatures/bacon_lara.c index a7c5ffeb9..b37c365e4 100644 --- a/src/game/objects/creatures/bacon_lara.c +++ b/src/game/objects/creatures/bacon_lara.c @@ -10,6 +10,9 @@ #include #include +static int32_t m_AnchorX = -1; +static int32_t m_AnchorZ = -1; + void BaconLara_Setup(OBJECT_INFO *obj) { obj->initialise = BaconLara_Initialise; @@ -30,8 +33,25 @@ void BaconLara_Initialise(int16_t item_num) g_Items[item_num].data = NULL; } +bool BaconLara_InitialiseAnchor(int32_t room_index) +{ + if (room_index >= g_RoomCount) { + return false; + } + + ROOM_INFO *r = &g_RoomInfo[room_index]; + m_AnchorX = r->x + r->y_size * (WALL_L >> 1); + m_AnchorZ = r->z + r->x_size * (WALL_L >> 1); + + return true; +} + void BaconLara_Control(int16_t item_num) { + if (m_AnchorX == -1) { + return; + } + ITEM_INFO *item = &g_Items[item_num]; if (item->hit_points < LARA_HITPOINTS) { @@ -40,9 +60,9 @@ void BaconLara_Control(int16_t item_num) } if (!item->data) { - int32_t x = 2 * 36 * WALL_L - g_LaraItem->pos.x; + int32_t x = 2 * m_AnchorX - g_LaraItem->pos.x; int32_t y = g_LaraItem->pos.y; - int32_t z = 2 * 60 * WALL_L - g_LaraItem->pos.z; + int32_t z = 2 * m_AnchorZ - g_LaraItem->pos.z; int16_t room_num = item->room_number; FLOOR_INFO *floor = Room_GetFloor(x, y, z, &room_num); diff --git a/src/game/objects/creatures/bacon_lara.h b/src/game/objects/creatures/bacon_lara.h index 2c994813e..d0c90814a 100644 --- a/src/game/objects/creatures/bacon_lara.h +++ b/src/game/objects/creatures/bacon_lara.h @@ -2,9 +2,11 @@ #include "global/types.h" +#include #include void BaconLara_Setup(OBJECT_INFO *obj); void BaconLara_Initialise(int16_t item_num); +bool BaconLara_InitialiseAnchor(int32_t room_index); void BaconLara_Control(int16_t item_num); void BaconLara_Draw(ITEM_INFO *item); diff --git a/src/global/types.h b/src/global/types.h index 91d51bd24..01fb19cd3 100644 --- a/src/global/types.h +++ b/src/global/types.h @@ -997,6 +997,7 @@ typedef enum GAMEFLOW_SEQUENCE_TYPE { GFS_MESH_SWAP, GFS_REMOVE_AMMO, GFS_REMOVE_MEDIPACKS, + GFS_SETUP_BACON_LARA, } GAMEFLOW_SEQUENCE_TYPE; typedef enum GAME_STRING_ID {