Skip to content

Commit cd6b982

Browse files
authored
Merge pull request #163 from cortex-command-community/inventory-management
Inventory Management
2 parents bbf1894 + 44b8410 commit cd6b982

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
149149

150150
- Fixed an issue where internal Lua functions OriginalDoFile, OriginalLoadFile, and OriginalRequire were polluting the global namespace. They have now been made inaccessible.
151151

152+
- Various fixes and improvements to inventory management when dual-wielding or carrying a shield, to stop situations where the actor unexpectedly puts their items away.
153+
152154
- Fixed issue where MOSR `Gib`s, `AEmitter` or `PEmitter` `Emission`s, and MetaMan `Player`s were not correctly accessible from script.
153155

154156
- Fixed a crash on launch when the `SupportedGameVersion` INI property was not set.

Resources/Credits.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ R"(- C O R T E X C O M M A N D C O M M U N I T Y P R O J E C T -
88
99
Programming
1010
3 4 3 N
11-
A L B E R T O " T H E P A W N " K U R T Y A N
11+
A L B E R T O " T H E P A W N " K U R T Y A N
12+
B I T G H O S T
1213
C O M R A D E S H O O K
1314
E V G E N I Y " W E E G E E " V I G O V S K I Y
1415
F R I S 0 U M A N

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)