Skip to content

Commit e1e5627

Browse files
committed
Add argument depositToFront to AHuman::EquipShieldInBGArm, argument not exposed to lua yet. Remove code for putting away and retrieving offhand when proning/crouching/climbing. This would probably have been better done before midnight, will review.
1 parent 34552e8 commit e1e5627

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

Source/Entities/AHuman.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ bool AHuman::EquipShield() {
998998
return false;
999999
}
10001000

1001-
bool AHuman::EquipShieldInBGArm() {
1001+
bool AHuman::EquipShieldInBGArm(bool depositToFront) {
10021002
if (!(m_pBGArm && m_pBGArm->IsAttached())) {
10031003
return false;
10041004
}
@@ -1007,7 +1007,11 @@ bool AHuman::EquipShieldInBGArm() {
10071007
// If we're holding a shield, but aren't supposed to, because we need to support the FG hand's two-handed device, then let go of the shield and put it back in inventory.
10081008
if (m_pFGArm && m_pFGArm->IsAttached() && m_pFGArm->GetHeldDevice() && !m_pFGArm->GetHeldDevice()->IsOneHanded()) {
10091009
m_pBGArm->GetHeldDevice()->Deactivate();
1010-
AddToInventoryBack(m_pBGArm->RemoveAttachable(heldDevice));
1010+
if (depositToFront) {
1011+
AddToInventoryFront(m_pBGArm->RemoveAttachable(heldDevice));
1012+
} else {
1013+
AddToInventoryBack(m_pBGArm->RemoveAttachable(heldDevice));
1014+
}
10111015
return false;
10121016
}
10131017
return true;
@@ -1030,7 +1034,11 @@ bool AHuman::EquipShieldInBGArm() {
10301034
// Put back into the inventory what we had in our hands, if anything
10311035
if (HeldDevice* heldDevice = m_pBGArm->GetHeldDevice()) {
10321036
heldDevice->Deactivate();
1033-
AddToInventoryBack(m_pBGArm->RemoveAttachable(heldDevice));
1037+
if (depositToFront) {
1038+
AddToInventoryFront(m_pBGArm->RemoveAttachable(heldDevice));
1039+
} else {
1040+
AddToInventoryBack(m_pBGArm->RemoveAttachable(heldDevice));
1041+
}
10341042
}
10351043

10361044
// Now put the device we were looking for and found into the hand
@@ -1565,7 +1573,6 @@ void AHuman::PreControllerUpdate() {
15651573
}
15661574
// Disengage the prone state as soon as prone is released.
15671575
if (!prone && m_ProneState != NOTPRONE) {
1568-
EquipShieldInBGArm();
15691576
m_ProneState = NOTPRONE;
15701577
}
15711578
}
@@ -1613,7 +1620,7 @@ void AHuman::PreControllerUpdate() {
16131620
} else {
16141621
m_pFGArm->SetHeldDevice(dynamic_cast<HeldDevice*>(SwapPrevInventory(m_pFGArm->RemoveAttachable(m_pFGArm->GetHeldDevice()))));
16151622
}
1616-
EquipShieldInBGArm();
1623+
EquipShieldInBGArm(!changeNext);
16171624
m_pFGArm->SetHandPos(m_Pos + RotateOffset(m_HolsterOffset));
16181625
}
16191626
m_EquipHUDTimer.Reset();
@@ -2306,9 +2313,9 @@ void AHuman::PreControllerUpdate() {
23062313
if (m_Status == STABLE) {
23072314
if (m_ArmClimbing[BGROUND]) {
23082315
// Can't climb or crawl with the shield
2309-
if (m_MovementState != CRAWL || m_ProneState == LAYINGPRONE) {
2310-
UnequipBGArm();
2311-
}
2316+
// if (m_MovementState != CRAWL || m_ProneState == LAYINGPRONE) {
2317+
// UnequipBGArm();
2318+
//}
23122319
m_pBGArm->AddHandTarget("Hand AtomGroup Limb Pos", m_pBGHandGroup->GetLimbPos(m_HFlipped));
23132320
} else {
23142321
HeldDevice* heldDevice = GetEquippedItem();

Source/Entities/AHuman.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ namespace RTE {
301301
/// this only works if nothing is held at all, or the FG arm holds a
302302
/// one-handed device, or we're in inventory mode.
303303
/// @return Whether a shield was successfully equipped in the background arm.
304-
bool EquipShieldInBGArm();
304+
bool EquipShieldInBGArm(bool depositToFront = false);
305305

306306
/// Tries to equip the first dual-wieldable in inventory to the background arm;
307307
/// this only works if nothing is held at all, or the FG arm holds a

Source/Lua/LuaBindingsEntities.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, AHuman) {
442442
.def("EquipThrowable", &AHuman::EquipThrowable)
443443
.def("EquipDiggingTool", &AHuman::EquipDiggingTool)
444444
.def("EquipShield", &AHuman::EquipShield)
445-
.def("EquipShieldInBGArm", &AHuman::EquipShieldInBGArm)
445+
.def("EquipShieldInBGArm", (bool(AHuman::*)()) & AHuman::EquipShieldInBGArm)
446446
.def("EquipDeviceInGroup", &AHuman::EquipDeviceInGroup)
447447
.def("EquipNamedDevice", (bool(AHuman::*)(const std::string&, bool)) & AHuman::EquipNamedDevice)
448448
.def("EquipNamedDevice", (bool(AHuman::*)(const std::string&, const std::string&, bool)) & AHuman::EquipNamedDevice)

0 commit comments

Comments
 (0)