From 26ddeaa4292b9c01c6a9dbf9f9503f61258c667f Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Fri, 29 Jul 2022 17:00:36 -0700 Subject: [PATCH] Fix NPC Proxy items (#684) * Fix racing lap times * Address NPC proxies NPCs are supposed to equip the sub items of items they equip and were not doing so. This PR adds this functionality and fixes and issue where Neido on Crux Prime was not wearing their sword. Tested that Neido has their sword and that other NPCs that wear proxies also get their proxies equipped. Had no issues with any other world crashing. --- dGame/dComponents/InventoryComponent.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index a48173bb..6dbb3bd8 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -62,6 +62,25 @@ InventoryComponent::InventoryComponent(Entity* parent, tinyxml2::XMLDocument* do const auto& info = Inventory::FindItemComponent(item.itemid); UpdateSlot(info.equipLocation, { id, static_cast(item.itemid), item.count, slot++ }); + + // Equip this items proxies. + auto subItems = info.subItems; + + subItems.erase(std::remove_if(subItems.begin(), subItems.end(), ::isspace), subItems.end()); + + if (!subItems.empty()) { + const auto subItemsSplit = GeneralUtils::SplitString(subItems, ','); + + for (auto proxyLotAsString : subItemsSplit) { + const auto proxyLOT = static_cast(std::stoi(proxyLotAsString)); + + const auto& proxyInfo = Inventory::FindItemComponent(proxyLOT); + const LWOOBJID proxyId = ObjectIDManager::Instance()->GenerateObjectID(); + + // Use item.count since we equip item.count number of the item this is a requested proxy of + UpdateSlot(proxyInfo.equipLocation, { proxyId, proxyLOT, item.count, slot++ } ); + } + } } }