Skip to content

Commit

Permalink
Fix SOC weapon zooming and grenade launcher bones usage (#392) (#1747)
Browse files Browse the repository at this point in the history
  • Loading branch information
APAmk2 authored Dec 23, 2024
1 parent a278e3f commit ba599a0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
16 changes: 13 additions & 3 deletions src/xrGame/Weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
constexpr pcstr WPN_SCOPE = "wpn_scope";
constexpr pcstr WPN_SILENCER = "wpn_silencer";
constexpr pcstr WPN_GRENADE_LAUNCHER = "wpn_launcher";
constexpr pcstr WPN_GRENADE_LAUNCHER_SOC = "wpn_grenade_launcher";

BOOL b_toggle_weapon_aim = FALSE;

Expand Down Expand Up @@ -1302,6 +1303,7 @@ void CWeapon::UpdateHUDAddonsVisibility()
static shared_str wpn_scope = WPN_SCOPE;
static shared_str wpn_silencer = WPN_SILENCER;
static shared_str wpn_grenade_launcher = WPN_GRENADE_LAUNCHER;
static shared_str wpn_grenade_launcher_soc = WPN_GRENADE_LAUNCHER_SOC;

// actor only
if (!GetHUDmode())
Expand Down Expand Up @@ -1332,16 +1334,20 @@ void CWeapon::UpdateHUDAddonsVisibility()
else if (m_eSilencerStatus == ALife::eAddonPermanent)
HudItemData()->set_bone_visible(wpn_silencer, TRUE, TRUE);

bool use_soc_name{};
if (HudItemData()->m_model->LL_BoneID(wpn_grenade_launcher) == BI_NONE)
use_soc_name = HudItemData()->m_model->LL_BoneID(wpn_grenade_launcher_soc) != BI_NONE;

if (GrenadeLauncherAttachable())
{
HudItemData()->set_bone_visible(wpn_grenade_launcher, IsGrenadeLauncherAttached());
HudItemData()->set_bone_visible((use_soc_name ? wpn_grenade_launcher_soc : wpn_grenade_launcher), IsGrenadeLauncherAttached());
}
if (m_eGrenadeLauncherStatus == ALife::eAddonDisabled)
{
HudItemData()->set_bone_visible(wpn_grenade_launcher, FALSE, TRUE);
HudItemData()->set_bone_visible((use_soc_name ? wpn_grenade_launcher_soc : wpn_grenade_launcher), FALSE, TRUE);
}
else if (m_eGrenadeLauncherStatus == ALife::eAddonPermanent)
HudItemData()->set_bone_visible(wpn_grenade_launcher, TRUE, TRUE);
HudItemData()->set_bone_visible((use_soc_name ? wpn_grenade_launcher_soc : wpn_grenade_launcher), TRUE, TRUE);
}

void CWeapon::UpdateAddonsVisibility()
Expand All @@ -1352,6 +1358,7 @@ void CWeapon::UpdateAddonsVisibility()
static shared_str wpn_scope = WPN_SCOPE;
static shared_str wpn_silencer = WPN_SILENCER;
static shared_str wpn_grenade_launcher = WPN_GRENADE_LAUNCHER;
static shared_str wpn_grenade_launcher_soc = WPN_GRENADE_LAUNCHER_SOC;

IKinematics* pWeaponVisual = smart_cast<IKinematics*>(Visual());
R_ASSERT(pWeaponVisual);
Expand Down Expand Up @@ -1401,6 +1408,9 @@ void CWeapon::UpdateAddonsVisibility()
}

bone_id = pWeaponVisual->LL_BoneID(wpn_grenade_launcher);
if (bone_id == BI_NONE)
bone_id = pWeaponVisual->LL_BoneID(wpn_grenade_launcher_soc);

if (GrenadeLauncherAttachable())
{
if (IsGrenadeLauncherAttached())
Expand Down
6 changes: 3 additions & 3 deletions src/xrGame/player_hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,12 @@ Fmatrix hud_item_measures::load_monolithic(const shared_str& sect_name, IKinemat
rotation.y = pSettings->r_float(sect_name, strconcat(full_name, prefix, "zoom_rotate_y"));
rotation.z = pSettings->read_if_exists<float>(sect_name, strconcat(full_name, prefix, "zoom_rotate_z"), 0.f);
};
load_zoom_offsets("", m_hands_offset[0][0], m_hands_offset[1][0]);
load_zoom_offsets("", m_hands_offset[0][1], m_hands_offset[1][1]);
if (smart_cast<CWeaponMagazinedWGrenade*>(wpn))
{
load_zoom_offsets("grenade_", m_hands_offset[0][1], m_hands_offset[1][1]);
load_zoom_offsets("grenade_", m_hands_offset[0][2], m_hands_offset[1][2]);
if (wpn->GrenadeLauncherAttachable())
load_zoom_offsets("grenade_normal_", m_hands_offset[0][2], m_hands_offset[1][2]);
load_zoom_offsets("grenade_normal_", m_hands_offset[0][1], m_hands_offset[1][1]);
}
}
}
Expand Down

0 comments on commit ba599a0

Please sign in to comment.