|
|
|
@ -265,15 +265,74 @@ namespace Papyrus::ArtifactTracker |
|
|
|
|
cellItems.clear(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// From po3's Papyrus Extender
|
|
|
|
|
inline std::vector<RE::Actor*> GetPlayerFollowers(RE::StaticFunctionTag*) |
|
|
|
|
{ |
|
|
|
|
std::vector<RE::Actor*> result; |
|
|
|
|
|
|
|
|
|
if (const auto processLists = RE::ProcessLists::GetSingleton(); processLists) { |
|
|
|
|
for (auto& actorHandle : processLists->highActorHandles) { |
|
|
|
|
if (auto actor = actorHandle.get(); actor && actor->IsPlayerTeammate()) { |
|
|
|
|
result.push_back(actor.get()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline std::int32_t AddArtifactsFromFollowersToList(RE::StaticFunctionTag*, |
|
|
|
|
RE::BGSListForm* a_targetList, |
|
|
|
|
RE::TESForm* a_excludeForm = NULL) |
|
|
|
|
{ |
|
|
|
|
for (const auto& actor : GetPlayerFollowers(nullptr)) { |
|
|
|
|
auto inv = actor->GetInventory([&](RE::TESBoundObject& a_exform) { |
|
|
|
|
return is_artifact(&a_exform) && !is_excluded(&a_exform, a_excludeForm); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
for (const auto& item : inv) { |
|
|
|
|
if (item.second.first > 0) { |
|
|
|
|
a_targetList->AddForm(item.first); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return a_targetList->forms.size(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline bool FollowersHaveItem(RE::StaticFunctionTag*, |
|
|
|
|
RE::TESBoundObject* a_form) |
|
|
|
|
{ |
|
|
|
|
for (const auto& actor : GetPlayerFollowers(nullptr)) { |
|
|
|
|
const auto inv = actor->GetInventory([&](RE::TESBoundObject& a_object) -> bool { |
|
|
|
|
return a_form->formID == a_object.formID; |
|
|
|
|
}); |
|
|
|
|
const auto it = inv.find(a_form); |
|
|
|
|
const auto iCount = it != inv.end() ? it->second.first : 0; |
|
|
|
|
|
|
|
|
|
if (iCount > 0) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline void Bind(VM& a_vm) |
|
|
|
|
{ |
|
|
|
|
BIND(AddAllFormsToList); |
|
|
|
|
logger::info("Registered AddAllFormsToList"sv); |
|
|
|
|
BIND(AddArtifactsToList); |
|
|
|
|
logger::info("Registered AddArtifactsToList"sv); |
|
|
|
|
BIND(AddArtifactsFromFollowersToList); |
|
|
|
|
logger::info("Registered AddArtifactsFromFollowersToList"sv); |
|
|
|
|
BIND(GetCellStorage); |
|
|
|
|
logger::info("Registered GetCellStorage"sv); |
|
|
|
|
BIND(SyncCellStorage); |
|
|
|
|
logger::info("Registered SyncCellStorage"sv); |
|
|
|
|
BIND(FollowersHaveItem); |
|
|
|
|
logger::info("Registered FollowersHaveItem"sv); |
|
|
|
|
BIND(GetPlayerFollowers); |
|
|
|
|
logger::info("Registered GetPlayerFollowers"sv); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|