Skip to content

Commit

Permalink
gameflow: add bacon lara anchor sequence
Browse files Browse the repository at this point in the history
Resolves #868.
  • Loading branch information
lahm86 authored Jun 6, 2023
1 parent 22b793f commit 37b8a1b
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions bin/cfg/Tomb1Main_gameflow.json5
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
31 changes: 31 additions & 0 deletions src/game/gameflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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++;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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:
Expand Down
24 changes: 22 additions & 2 deletions src/game/objects/creatures/bacon_lara.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#include <stdbool.h>
#include <stddef.h>

static int32_t m_AnchorX = -1;
static int32_t m_AnchorZ = -1;

void BaconLara_Setup(OBJECT_INFO *obj)
{
obj->initialise = BaconLara_Initialise;
Expand All @@ -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) {
Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/game/objects/creatures/bacon_lara.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

#include "global/types.h"

#include <stdbool.h>
#include <stdint.h>

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);
1 change: 1 addition & 0 deletions src/global/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 37b8a1b

Please sign in to comment.