|
|
|
@ -14,6 +14,38 @@ inline void ListRevert(RE::BGSListForm* a_form) |
|
|
|
|
return func(a_form); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline std::int32_t GetItemCount(RE::TESObjectREFR* a_container, RE::FormID a_formID) |
|
|
|
|
{ |
|
|
|
|
std::int32_t iResult = 0; |
|
|
|
|
|
|
|
|
|
auto invChanges = a_container->GetInventoryChanges(); |
|
|
|
|
if (invChanges && invChanges->entryList) { |
|
|
|
|
for (auto& entry : *invChanges->entryList) { |
|
|
|
|
if (entry && entry->object && entry->object->formID == a_formID) { |
|
|
|
|
if (entry->IsLeveled()) { |
|
|
|
|
return entry->countDelta > 0 ? entry->countDelta : 0; |
|
|
|
|
} else { |
|
|
|
|
iResult = entry->countDelta; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
auto container = a_container->GetContainer(); |
|
|
|
|
if (container) { |
|
|
|
|
container->ForEachContainerObject([&](RE::ContainerObject& a_entry) { |
|
|
|
|
if (a_entry.obj->formID == a_formID) { |
|
|
|
|
iResult += a_entry.count; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return iResult > 0 ? iResult : 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline bool RefHasItem(RE::TESForm* a_refOrList, RE::FormID a_formID) |
|
|
|
|
{ |
|
|
|
|
if (!a_refOrList || !a_formID) { |
|
|
|
@ -24,15 +56,7 @@ inline bool RefHasItem(RE::TESForm* a_refOrList, RE::FormID a_formID) |
|
|
|
|
const auto refr = a_refOrList->As<RE::TESObjectREFR>(); |
|
|
|
|
|
|
|
|
|
if (refr) { |
|
|
|
|
const auto invChanges = refr->GetInventoryChanges(); |
|
|
|
|
if (invChanges && invChanges->entryList) { |
|
|
|
|
for (auto& entry : *invChanges->entryList) { |
|
|
|
|
if (entry && entry->object && entry->object->formID == a_formID) { |
|
|
|
|
return entry->countDelta > 0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
return GetItemCount(refr, a_formID) > 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const auto list = a_refOrList->As<RE::BGSListForm>(); |
|
|
|
@ -48,19 +72,19 @@ inline bool RefHasItem(RE::TESForm* a_refOrList, RE::FormID a_formID) |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline bool FollowersHaveItem(RE::TESForm* a_form) |
|
|
|
|
inline std::uint32_t GetFollowerItemCount(RE::FormID a_formID) |
|
|
|
|
{ |
|
|
|
|
std::int32_t iResult = 0; |
|
|
|
|
|
|
|
|
|
if (const auto processLists = RE::ProcessLists::GetSingleton(); processLists) { |
|
|
|
|
for (auto& actorHandle : processLists->highActorHandles) { |
|
|
|
|
if (auto actor = actorHandle.get(); actor && actor->IsPlayerTeammate()) { |
|
|
|
|
|
|
|
|
|
if (RefHasItem(actor->As<RE::TESObjectREFR>(), a_form->formID)) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
iResult += GetItemCount(actor->As<RE::TESObjectREFR>(), a_formID); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return iResult; |
|
|
|
|
} |
|
|
|
|