Skip to content

Commit

Permalink
tr1/objects/scion3: save scion hitpoints
Browse files Browse the repository at this point in the history
This ensures the shootable scion's hitpoints value is saved so if it's
still active on reload, Lara can't continue to target it.

Resolves LostArtefacts#1819.
  • Loading branch information
lahm86 committed Nov 3, 2024
1 parent fec71a2 commit efc150d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/tr1/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
- fixed being unable to rename the lead bar (#1774, regression from 4.5)
- fixed the controls menu extending to the bottom of the screen with certain text scaling values (#1783, regression from 2.12)
- fixed game stuck at remapping controller key if no controllers connected (#1788)
- fixed being able to shoot the scion multiple times if save/load is used while it blows up (#1819)
- improved enemy item drops by supporting the TR2+ approach of having drops defined in level data (#1713)
- improved Italian localization for the Config Tool
- removed health cheat (we now have the `/hp` command)
Expand Down
1 change: 1 addition & 0 deletions docs/tr1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ Not all options are turned on by default. Refer to `TR1X_ConfigTool.exe` for det
- fixed the Scion being extremely difficult to shoot with the shotgun
- fixed collision issues with drawbridges, trapdoors, and bridges when stacked over each other, over slopes, and near the ground
- fixed a potential softlock when killing the Torso boss in Great Pyramid
- fixed being able to shoot the scion multiple times if save/load is used while it blows up

#### Cheats
- added a fly cheat
Expand Down
1 change: 1 addition & 0 deletions src/tr1/game/objects/general/scion3.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ void Scion3_Setup(OBJECT *obj)
obj->control = Scion3_Control;
obj->hit_points = 5;
obj->save_flags = 1;
obj->save_hitpoints = 1;
}

void Scion3_Control(int16_t item_num)
Expand Down
13 changes: 10 additions & 3 deletions src/tr1/game/savegame/savegame_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ static char *m_SGBufPtr = NULL;

static bool M_ItemHasSaveFlags(OBJECT *obj, ITEM *item);
static bool M_ItemHasSaveAnim(const ITEM *item);
static bool M_ItemHasHitPoints(const ITEM *item);
static bool M_NeedsBaconLaraFix(char *buffer);

static void M_Reset(char *buffer);
Expand Down Expand Up @@ -87,6 +88,12 @@ static bool M_ItemHasSaveAnim(const ITEM *const item)
return obj->save_anim && item->object_id != O_BACON_LARA;
}

static bool M_ItemHasHitPoints(const ITEM *const item)
{
const OBJECT *const obj = &g_Objects[item->object_id];
return obj->save_hitpoints && item->object_id != O_SCION_ITEM_3;
}

static bool M_NeedsBaconLaraFix(char *buffer)
{
// Heuristic for issue #261.
Expand Down Expand Up @@ -158,7 +165,7 @@ static bool M_NeedsBaconLaraFix(char *buffer)
M_Read(&tmp_item.anim_num, sizeof(int16_t));
M_Read(&tmp_item.frame_num, sizeof(int16_t));
}
if (obj->save_hitpoints) {
if (M_ItemHasHitPoints(item)) {
M_Read(&tmp_item.hit_points, sizeof(int16_t));
}
if (M_ItemHasSaveFlags(obj, item)) {
Expand Down Expand Up @@ -596,7 +603,7 @@ bool Savegame_Legacy_LoadFromFile(MYFILE *fp, GAME_INFO *game_info)
M_Read(&item->frame_num, sizeof(int16_t));
}

if (obj->save_hitpoints) {
if (M_ItemHasHitPoints(item)) {
M_Read(&item->hit_points, sizeof(int16_t));
}

Expand Down Expand Up @@ -767,7 +774,7 @@ void Savegame_Legacy_SaveToFile(MYFILE *fp, GAME_INFO *game_info)
M_Write(&item->frame_num, sizeof(int16_t));
}

if (obj->save_hitpoints) {
if (M_ItemHasHitPoints(item)) {
M_Write(&item->hit_points, sizeof(int16_t));
}

Expand Down

0 comments on commit efc150d

Please sign in to comment.