Skip to content

Commit

Permalink
inject: fix music trigger setups in Folly (#946)
Browse files Browse the repository at this point in the history
In St. Francis' Folly, the music trigger for track 3 in room 4 has been
moved behind the Neptune door. A new trigger for track 15 has also been
added once the 4 keys are used at the end of the level.
A new injection function to support moving rooms has been added. This
is used in Folly to move room 54 out of earshot so the player does not
hear the boulder that opens the door.

Resolves #865.
  • Loading branch information
lahm86 authored Aug 27, 2023
1 parent bacbddf commit 7278f28
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- fixed original data issues where music triggers are not set as one shot (#939)
- fixed a missing enemy trigger in Tomb of Tihocan (#751)
- fixed incorrect trapdoor triggers in City of Khamoon and a switch trigger in Obelisk of Khamoon (#942)
- fixed the setup of two music triggers in St. Francis' Folly (#865)
- improve spanish localization and added translation for rotated pickups

## [2.15.3](https://github.com/rr-/Tomb1Main/compare/2.15.2...2.15.3) - 2023-08-15
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ Not all options are turned on by default. Refer to `Tomb1Main_ConfigTool.exe` fo
- fixed the bear pat attack so it does not miss Lara
- fixed dead centaurs exploding again after saving and reloading
- fixed the following floor data issues:
- **St. Francis' Folly**: moved the music trigger for track 3 in room 4 behind the Neptune door, and restored track 15 to play after using the 4 keys
- **Tomb of Tihocan**: missing trigger in room 62 for enemy 34
- **City of Khamoon**: incorrect trapdoor trigger types in rooms 31 and 34
- **Obelisk of Khamoon**: missing switch trigger type in room 66
Expand Down
Binary file modified bin/data/folly_fd.bin
Binary file not shown.
60 changes: 60 additions & 0 deletions src/game/inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ typedef enum FLOOR_EDIT_TYPE {
FET_TRIGGER_PARAM = 0,
FET_MUSIC_ONESHOT = 1,
FET_FD_INSERT = 2,
FET_ROOM_SHIFT = 3,
} FLOOR_EDIT_TYPE;

typedef enum ROOM_MESH_EDIT_TYPE {
Expand Down Expand Up @@ -127,6 +128,7 @@ static void Inject_TriggerParameterChange(
static void Inject_SetMusicOneShot(FLOOR_INFO *floor);
static void Inject_InsertFloorData(
INJECTION *injection, FLOOR_INFO *floor, LEVEL_INFO *level_info);
static void Inject_RoomShift(INJECTION *injection, int16_t room_num);

static void Inject_RoomMeshEdits(INJECTION *injection);
static void Inject_TextureRoomFace(INJECTION *injection);
Expand Down Expand Up @@ -1004,6 +1006,9 @@ static void Inject_FloorDataEdits(INJECTION *injection, LEVEL_INFO *level_info)
case FET_FD_INSERT:
Inject_InsertFloorData(injection, floor, level_info);
break;
case FET_ROOM_SHIFT:
Inject_RoomShift(injection, room);
break;
default:
LOG_WARNING("Unknown floor data edit type: %d", edit_type);
break;
Expand Down Expand Up @@ -1167,6 +1172,61 @@ static void Inject_InsertFloorData(
level_info->floor_data_size += data_length;
}

static void Inject_RoomShift(INJECTION *injection, int16_t room_num)
{
MYFILE *fp = injection->fp;

uint32_t x_shift;
uint32_t z_shift;
int32_t y_shift;

File_Read(&x_shift, sizeof(uint32_t), 1, fp);
File_Read(&z_shift, sizeof(uint32_t), 1, fp);
File_Read(&y_shift, sizeof(int32_t), 1, fp);

ROOM_INFO *room = &g_RoomInfo[room_num];
room->x += x_shift;
room->z += z_shift;
room->min_floor += y_shift;
room->max_ceiling += y_shift;

// Move any items in the room to match.
for (int i = 0; i < g_LevelItemCount; i++) {
ITEM_INFO *item = &g_Items[i];
if (item->room_number != room_num) {
continue;
}

item->pos.x += x_shift;
item->pos.y += y_shift;
item->pos.z += z_shift;
}

if (!y_shift) {
return;
}

// Update the sector floor and ceiling clicks to match.
const int8_t click_shift = y_shift / STEP_L;
const int8_t wall_height = NO_HEIGHT / STEP_L;
for (int i = 0; i < room->x_size * room->y_size; i++) {
FLOOR_INFO *floor = &room->floor[i];
if (floor->floor == wall_height || floor->ceiling == wall_height) {
continue;
}

floor->floor += click_shift;
floor->ceiling += click_shift;
}

// Update vertex Y values to match; x and z are room-relative.
int16_t *data_ptr = room->data;
int16_t vertex_count = *data_ptr++;
for (int i = 0; i < vertex_count; i++) {
*(data_ptr + (i * 4) + 1) += y_shift;
}
}

uint32_t Inject_GetExtraRoomMeshSize(int32_t room_index)
{
uint32_t size = 0;
Expand Down

0 comments on commit 7278f28

Please sign in to comment.