Skip to content

Commit

Permalink
pickup: add guns to emtpy holsters on pickup
Browse files Browse the repository at this point in the history
  • Loading branch information
walkawayy committed Aug 10, 2024
1 parent 52bcb5b commit b5554c8
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- added deadly water feature from TR2+ for custom levels (#1404)
- added skybox support, with a default option provided for Lost Valley, Colosseum and Obelisk of Khamoon (#94)
- added an option for Lara to use her underwater swimming physics from TR2+ (#1003)
- added weapons to Lara's empty holsters on pickup (#1291)
- changed the turbo cheat to no longer affect the gameplay time (#1420)
- fixed adjacent Midas Touch objects potentially allowing gold bar duplication in custom levels (#1415)
- fixed the excessive pitch and playback speed correction for music files with sampling rate other than 44100 Hz (#1417, regression from 2.0)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ Not all options are turned on by default. Refer to `TR1X_ConfigTool.exe` for det
- added graphics effects, lava emitters, flame emitters, and waterfalls to the savegame so they now persist on load
- added an option to restore the mummy in City of Khamoon room 25, similar to the PS version
- added a flag indicating if new game plus is unlocked to the player config which allows the player to select new game plus or not when making a new game
- added weapons to Lara's empty holsters on pickup
- fixed keys and items not working when drawing guns immediately after using them
- fixed counting the secret in The Great Pyramid
- fixed running out of ammo forcing Lara to equip pistols even if she doesn't carry them
Expand Down
2 changes: 1 addition & 1 deletion src/game/carrier.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void Carrier_TestItemDrops(int16_t item_num)
GAME_OBJECT_ID object_id = item->object_id;
if (g_GameFlow.convert_dropped_guns
&& Object_IsObjectType(object_id, g_GunObjects)
&& Inv_RequestItem(object_id)) {
&& Inv_RequestItem(object_id) && object_id != O_PISTOL_ITEM) {
object_id = Object_GetCognate(object_id, g_GunAmmoObjectMap);
}

Expand Down
2 changes: 2 additions & 0 deletions src/game/objects/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ const GAME_OBJECT_ID g_PickupObjects[] = {

const GAME_OBJECT_ID g_GunObjects[] = {
// clang-format off
O_PISTOL_ITEM,
O_SHOTGUN_ITEM,
O_MAGNUM_ITEM,
O_UZI_ITEM,
Expand Down Expand Up @@ -168,6 +169,7 @@ const GAME_OBJECT_ID g_InvObjects[] = {

const GAME_OBJECT_PAIR g_GunAmmoObjectMap[] = {
// clang-format off
{ O_PISTOL_ITEM, O_PISTOL_AMMO_ITEM },
{ O_SHOTGUN_ITEM, O_SG_AMMO_ITEM },
{ O_MAGNUM_ITEM, O_MAG_AMMO_ITEM },
{ O_UZI_ITEM, O_UZI_AMMO_ITEM },
Expand Down
34 changes: 31 additions & 3 deletions src/game/objects/general/pickup.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,44 @@ static const OBJECT_BOUNDS m_PickUpBoundsUW = {
},
};

static void PickUp_AddGunToMesh(
const GAME_OBJECT_ID obj_num, const ITEM_INFO *lara_item);
static void PickUp_GetItem(
int16_t item_num, ITEM_INFO *item, ITEM_INFO *lara_item);
static void PickUp_GetAllAtLaraPos(ITEM_INFO *item, ITEM_INFO *lara_item);

static void PickUp_GetItem(
int16_t item_num, ITEM_INFO *item, ITEM_INFO *lara_item)
static void PickUp_AddGunToMesh(
const GAME_OBJECT_ID obj_num, const ITEM_INFO *const lara_item)
{
if (item->object_number == O_SHOTGUN_ITEM) {
const bool lara_has_pistols = Inv_RequestItem(O_PISTOL_ITEM)
|| Inv_RequestItem(O_MAGNUM_ITEM) || Inv_RequestItem(O_UZI_ITEM);

if (!Inv_RequestItem(O_SHOTGUN_ITEM) && obj_num == O_SHOTGUN_ITEM) {
g_Lara.mesh_ptrs[LM_TORSO] =
g_Meshes[g_Objects[O_SHOTGUN_ANIM].mesh_index + LM_TORSO];
} else if (!lara_has_pistols && obj_num == O_PISTOL_ITEM) {
g_Lara.mesh_ptrs[LM_THIGH_L] =
g_Meshes[g_Objects[O_PISTOL_ANIM].mesh_index + LM_THIGH_L];
g_Lara.mesh_ptrs[LM_THIGH_R] =
g_Meshes[g_Objects[O_PISTOL_ANIM].mesh_index + LM_THIGH_R];
} else if (!lara_has_pistols && obj_num == O_MAGNUM_ITEM) {
g_Lara.mesh_ptrs[LM_THIGH_L] =
g_Meshes[g_Objects[O_MAGNUM_ANIM].mesh_index + LM_THIGH_L];
g_Lara.mesh_ptrs[LM_THIGH_R] =
g_Meshes[g_Objects[O_MAGNUM_ANIM].mesh_index + LM_THIGH_R];
} else if (!lara_has_pistols && obj_num == O_UZI_ITEM) {
g_Lara.mesh_ptrs[LM_THIGH_L] =
g_Meshes[g_Objects[O_UZI_ANIM].mesh_index + LM_THIGH_L];
g_Lara.mesh_ptrs[LM_THIGH_R] =
g_Meshes[g_Objects[O_UZI_ANIM].mesh_index + LM_THIGH_R];
}
}

static void PickUp_GetItem(
int16_t item_num, ITEM_INFO *item, ITEM_INFO *lara_item)
{
if (Object_IsObjectType(item->object_number, g_GunObjects)) {
PickUp_AddGunToMesh(item->object_number, lara_item);
}
Overlay_AddPickup(item->object_number);
Inv_AddItem(item->object_number);
Expand Down

0 comments on commit b5554c8

Please sign in to comment.