Skip to content

Commit

Permalink
Dead actors can't equip stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
powerof3 committed Mar 12, 2024
1 parent e017e6a commit 7c06300
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions SPID/src/Distribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Distribute
{
void add_item(RE::Actor* a_actor, RE::TESBoundObject* a_item, std::uint32_t a_itemCount)
{
using func_t = void (*)(RE::Actor*, RE::TESBoundObject*, std::uint32_t, bool, std::uint32_t, RE::BSScript::Internal::VirtualMachine*);
using func_t = void (*)(RE::Actor*, RE::TESBoundObject*, std::uint32_t, bool, std::uint32_t, RE::BSScript::Internal::VirtualMachine*);
REL::Relocation<func_t> func{ RELOCATION_ID(55945, 56489) };
return func(a_actor, a_item, a_itemCount, true, 0, RE::BSScript::Internal::VirtualMachine::GetSingleton());
}
Expand Down Expand Up @@ -145,14 +145,16 @@ namespace Distribute
});

bool recalcInventory = false;
bool startsDead = actor->IsDead() || (actor->formFlags & RE::Actor::RecordFlags::kStartsDead) != 0;

for_each_form<RE::TESBoundObject>(a_npcData, Forms::items, a_input, [&](std::map<RE::TESBoundObject*, IdxOrCount>& a_objects, const bool a_hasLvlItem) {
if (npc->AddObjectsToContainer(a_objects, npc)) {
if (a_hasLvlItem) {
recalcInventory = true;
if (const auto invChanges = actor->GetInventoryChanges(true)) {
invChanges->InitLeveledItems();
}
} else {
} else if (!startsDead) {
for (auto& [item, count] : a_objects) {
if (item->Is(RE::FormType::Weapon, RE::FormType::Armor)) {
RE::ActorEquipManager::GetSingleton()->EquipObject(actor, item);
Expand All @@ -164,7 +166,7 @@ namespace Distribute
return false;
});

if (recalcInventory) {
if (recalcInventory && !startsDead) {
auto inv_after = actor->GetInventory([](auto& item) {
return item.Is(RE::FormType::Weapon, RE::FormType::Armor);
});
Expand Down

0 comments on commit 7c06300

Please sign in to comment.