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

Commit 45e4f5d

Browse files
committed
Move BG item into FG hand when dropping an item.
1 parent 0abe37f commit 45e4f5d

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

Entities/AHuman.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3451,27 +3451,31 @@ void AHuman::Update()
34513451
// Item dropping logic
34523452

34533453
if (m_Controller.IsState(WEAPON_DROP) && m_Status != INACTIVE) {
3454-
bool anyDropped = false;
3454+
Arm *dropperArm = nullptr;
34553455
for (Arm *arm : { m_pFGArm, m_pBGArm }) {
3456-
if (!anyDropped && arm && arm->GetHeldDevice()) {
3456+
if (arm && arm->GetHeldDevice()) {
34573457
HeldDevice *heldDevice = arm->GetHeldDevice();
34583458
arm->RemoveAttachable(heldDevice, true, false);
3459+
if (dropperArm) {
3460+
if (heldDevice) {
3461+
dropperArm->SetHeldDevice(heldDevice);
3462+
arm->SetHandPos(dropperArm->GetPos());
3463+
}
3464+
} else {
3465+
heldDevice->SetPos(arm->GetJointPos() + Vector(arm->GetMaxLength() * GetFlipFactor(), 0).RadRotate(adjustedAimAngle));
3466+
Vector tossVec(1.0F + std::sqrt(std::abs(arm->GetThrowStrength()) / std::sqrt(std::abs(heldDevice->GetMass()) + 1.0F)), RandomNormalNum());
3467+
heldDevice->SetVel(heldDevice->GetVel() * 0.5F + tossVec.RadRotate(m_AimAngle).GetXFlipped(m_HFlipped));
3468+
heldDevice->SetAngularVel(heldDevice->GetAngularVel() + m_AngularVel * 0.5F + 3.0F * RandomNormalNum());
34593469

3460-
heldDevice->SetPos(arm->GetJointPos() + Vector(arm->GetMaxLength() * GetFlipFactor(), 0).RadRotate(adjustedAimAngle));
3461-
Vector tossVec(1.0F + std::sqrt(std::abs(arm->GetThrowStrength()) / std::sqrt(std::abs(heldDevice->GetMass()) + 1.0F)), RandomNormalNum());
3462-
heldDevice->SetVel(heldDevice->GetVel() * 0.5F + tossVec.RadRotate(m_AimAngle).GetXFlipped(m_HFlipped));
3463-
heldDevice->SetAngularVel(heldDevice->GetAngularVel() + m_AngularVel * 0.5F + 3.0F * RandomNormalNum());
3464-
3465-
arm->SetHandPos(heldDevice->GetPos());
3466-
if (!m_Inventory.empty()) {
3467-
arm->SetHeldDevice(dynamic_cast<HeldDevice *>(SwapNextInventory()));
3468-
arm->SetHandPos(m_Pos + RotateOffset(m_HolsterOffset));
3470+
arm->SetHandPos(heldDevice->GetPos());
34693471
}
3470-
anyDropped = true;
3471-
break;
3472+
dropperArm = arm;
3473+
} else if (dropperArm && !m_Inventory.empty()) {
3474+
dropperArm->SetHeldDevice(dynamic_cast<HeldDevice*>(SwapNextInventory()));
3475+
dropperArm->SetHandPos(m_Pos + RotateOffset(m_HolsterOffset));
34723476
}
34733477
}
3474-
if (!anyDropped && !m_Inventory.empty() && !m_pFGArm) {
3478+
if (!dropperArm && !m_Inventory.empty() && !m_pFGArm) {
34753479
DropAllInventory();
34763480
if (m_pBGArm) {
34773481
m_pBGArm->SetHandPos(m_Pos + RotateOffset(m_HolsterOffset));

0 commit comments

Comments
 (0)