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.
This commit is contained in:
David Markowitz 2022-07-29 17:00:36 -07:00 committed by GitHub
parent 8b386ae6c5
commit 26ddeaa429
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,6 +62,25 @@ InventoryComponent::InventoryComponent(Entity* parent, tinyxml2::XMLDocument* do
const auto& info = Inventory::FindItemComponent(item.itemid); const auto& info = Inventory::FindItemComponent(item.itemid);
UpdateSlot(info.equipLocation, { id, static_cast<LOT>(item.itemid), item.count, slot++ }); UpdateSlot(info.equipLocation, { id, static_cast<LOT>(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<LOT>(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++ } );
}
}
} }
} }