From 1e62a0687e4964c91398185735abbab5014df36c Mon Sep 17 00:00:00 2001 From: powerof3 <32599957+powerof3@users.noreply.github.com> Date: Tue, 5 Mar 2024 15:44:04 +0530 Subject: [PATCH] outfit fixes --- SPID/src/Distribute.cpp | 9 ++------- SPID/src/DistributeManager.cpp | 16 +++++++++------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/SPID/src/Distribute.cpp b/SPID/src/Distribute.cpp index 1545184..f591ce1 100644 --- a/SPID/src/Distribute.cpp +++ b/SPID/src/Distribute.cpp @@ -147,15 +147,10 @@ namespace Distribute const auto npc = a_npcData.GetNPC(); const auto actor = a_npcData.GetActor(); - - if (!actor->IsDead()) { - actor->ResetInventory(false); - } - + for_each_form(a_npcData, Forms::outfits, a_input, [&](auto* a_outfit) { if (detail::can_equip_outfit(npc, a_outfit)) { - actor->RemoveOutfitItems(npc->defaultOutfit); - npc->defaultOutfit = a_outfit; + npc->defaultOutfit = a_outfit; npc->AddKeyword(processedOutfit); return true; } diff --git a/SPID/src/DistributeManager.cpp b/SPID/src/DistributeManager.cpp index d22084f..e0fc90d 100644 --- a/SPID/src/DistributeManager.cpp +++ b/SPID/src/DistributeManager.cpp @@ -30,7 +30,7 @@ namespace Distribute for (const auto& xList : *entryList->extraLists) { const auto outfitItem = xList ? xList->GetByType() : nullptr; if (outfitItem && outfitItem->id == formID) { - RE::ActorEquipManager::GetSingleton()->EquipObject(actor, entryList->object, xList, 1, nullptr, true); + RE::ActorEquipManager::GetSingleton()->EquipObject(actor, entryList->object, xList, 1, nullptr, true, !actor->IsDead()); } } } @@ -70,6 +70,7 @@ namespace Distribute Distribute(npcData, false, true); } if (processOnLoad) { + a_this->RemoveOutfitItems(nullptr); DistributeItemOutfits(npcData, { a_this, npc, false }); } } @@ -111,13 +112,14 @@ namespace Distribute func(a_this, a_buf); if (const auto npc = a_this->GetActorBase()) { - // some npcs are completely reset upon loading - if (a_this->Is3DLoaded() && detail::should_process_NPC(npc)) { - auto npcData = NPCData(a_this, npc); - Distribute(npcData, false); + // some leveled npcs are completely reset upon loading + if (a_this->Is3DLoaded()) { + if (detail::should_process_NPC(npc)) { + auto npcData = NPCData(a_this, npc); + Distribute(npcData, false); + } + detail::force_equip_outfit(a_this, npc); } - - detail::force_equip_outfit(a_this, npc); } } static inline REL::Relocation func;