Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 8cf5f09

Browse files
committed
Fixed fg-arm flailing when reloading 1-handed weapon, so shields are no longer so useless
Made AHuman show both weapon ammo states when 2 one-handed weapons are equipped Changed HDFirearm IsReloading to const method since it doesn't change the object and it's needed for some checking
1 parent d0f0b1d commit 8cf5f09

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

Entities/AHuman.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3410,8 +3410,9 @@ void AHuman::Update()
34103410
if (!pDevice->IsFull() && m_Controller.IsState(WEAPON_RELOAD) && !m_pItemInReach)
34113411
{
34123412
pDevice->Reload();
3413-
if (m_pBGArm && m_pBGArm->IsAttached())
3413+
if (m_pBGArm && m_pBGArm->IsAttached() && GetEquippedBGItem() == NULL) {
34143414
m_pBGArm->SetHandPos(m_Pos + m_HolsterOffset.GetXFlipped(m_HFlipped));
3415+
}
34153416
m_DeviceSwitchSound.Play(m_Pos);
34163417

34173418
// Interrupt sharp aiming
@@ -3422,15 +3423,17 @@ void AHuman::Update()
34223423
// Detect reloading and move hand accordingly
34233424
if (pDevice->IsReloading())
34243425
{
3425-
if (m_pBGArm && m_pBGArm->IsAttached())
3426+
if (m_pBGArm && m_pBGArm->IsAttached() && GetEquippedBGItem() == NULL) {
34263427
m_pBGArm->SetHandPos(m_Pos + m_HolsterOffset.GetXFlipped(m_HFlipped));
3428+
}
34273429
}
34283430

34293431
// Detect reloading being completed and move hand accordingly
34303432
if (pDevice->DoneReloading())
34313433
{
3432-
if (m_pBGArm && m_pBGArm->IsAttached())
3434+
if (m_pBGArm && m_pBGArm->IsAttached() && GetEquippedBGItem() == NULL) {
34333435
m_pBGArm->SetHandPos(pDevice->GetMagazinePos());
3436+
}
34343437
}
34353438
}
34363439
}
@@ -4905,16 +4908,20 @@ void AHuman::DrawHUD(BITMAP *pTargetBitmap, const Vector &targetPos, int whichSc
49054908
// Ammo
49064909
if (pHeldFirearm)
49074910
{
4911+
MovableObject *bgHeldItem = GetEquippedBGItem();
4912+
HDFirearm const *bgHeldFirearm = bgHeldItem == NULL ? NULL : dynamic_cast<HDFirearm *>(bgHeldItem);
4913+
49084914
str[0] = -56; str[1] = 0;
49094915
pSymbolFont->DrawAligned(&allegroBitmap, drawPos.m_X - 10, drawPos.m_Y + m_HUDStack, str, GUIFont::Left);
4910-
if (pHeldFirearm->IsReloading())
4911-
sprintf_s(str, sizeof(str), "%s", "Reloading...");
4912-
else
4913-
{
4914-
if (pHeldFirearm->GetRoundInMagCount() < 0)
4915-
sprintf_s(str, sizeof(str), "%s", "Infinite");
4916-
else
4917-
sprintf_s(str, sizeof(str), "%i", pHeldFirearm->GetRoundInMagCount());
4916+
std::string fgWeaponString = pHeldFirearm->GetRoundInMagCount() < 0 ? "Infinite" : std::to_string(pHeldFirearm->GetRoundInMagCount());
4917+
fgWeaponString = pHeldFirearm->IsReloading() ? "Reloading" : fgWeaponString;
4918+
4919+
if (bgHeldItem && bgHeldFirearm) {
4920+
std::string bgWeaponString = bgHeldFirearm->GetRoundInMagCount() < 0 ? "Infinite" : std::to_string(bgHeldFirearm->GetRoundInMagCount());
4921+
bgWeaponString = bgHeldFirearm->IsReloading() ? "Reloading" : bgWeaponString;
4922+
sprintf_s(str, sizeof(str), "%s | %s", fgWeaponString.c_str(), bgWeaponString.c_str());
4923+
} else {
4924+
sprintf_s(str, sizeof(str), "%s", fgWeaponString.c_str());
49184925
}
49194926
pSmallFont->DrawAligned(&allegroBitmap, drawPos.m_X - 0, drawPos.m_Y + m_HUDStack + 3, str, GUIFont::Left);
49204927

Entities/HDFirearm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ ENTITYALLOCATION(HDFirearm)
587587
// Arguments: None.
588588
// Return value: Whetehr being reloaded.
589589

590-
virtual bool IsReloading() { return m_Reloading; }
590+
virtual bool IsReloading() const { return m_Reloading; }
591591

592592

593593
//////////////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)