|
|
|
@ -50,19 +50,19 @@ namespace Papyrus::ArtifactTracker |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline bool is_artifact(RE::TESForm* a_form, RE::TESForm* a_excludeForm = NULL) |
|
|
|
|
inline bool is_artifact(RE::TESForm* a_form) |
|
|
|
|
{ |
|
|
|
|
const auto formType = a_form->GetFormType(); |
|
|
|
|
|
|
|
|
|
if (formType != RE::FormType::Armor && formType != RE::FormType::Weapon && formType != RE::FormType::Book && formType != RE::FormType::Misc) { |
|
|
|
|
if (!a_form->GetPlayable()) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!a_form->GetPlayable() || is_excluded(a_form, a_excludeForm)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
const auto formType = a_form->GetFormType(); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
return ( |
|
|
|
|
formType == RE::FormType::Armor |
|
|
|
|
|| (formType == RE::FormType::Weapon && a_form->formID != 0x000001F4) |
|
|
|
|
|| (formType == RE::FormType::Book && BookCheck::GetBookList().contains(a_form->formID)) |
|
|
|
|
|| (formType == RE::FormType::Misc && MiscCheck::GetMiscList().contains(a_form->formID))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline std::int32_t AddAllFormsToList(RE::StaticFunctionTag*, |
|
|
|
@ -70,22 +70,36 @@ namespace Papyrus::ArtifactTracker |
|
|
|
|
short a_formType, |
|
|
|
|
RE::TESForm* a_excludeForm = NULL) |
|
|
|
|
{ |
|
|
|
|
const auto dataHandler = RE::TESDataHandler::GetSingleton(); |
|
|
|
|
|
|
|
|
|
if (!dataHandler) { |
|
|
|
|
return a_targetList->forms.size(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const auto formType = static_cast<RE::FormType>(a_formType); |
|
|
|
|
|
|
|
|
|
for (const auto& form : dataHandler->GetFormArray(formType)) { |
|
|
|
|
if (!form || !form->GetPlayable()) { |
|
|
|
|
continue; |
|
|
|
|
if (formType == RE::FormType::Book) { |
|
|
|
|
for (auto const& item : BookCheck::GetBookList()) { |
|
|
|
|
if (!a_excludeForm || !is_excluded(item.second, a_excludeForm)) { |
|
|
|
|
a_targetList->AddForm(item.second); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (a_excludeForm && is_excluded(form, a_excludeForm)) { |
|
|
|
|
continue; |
|
|
|
|
} else if (formType == RE::FormType::Misc) { |
|
|
|
|
for (auto const& item : MiscCheck::GetMiscList()) { |
|
|
|
|
if (!a_excludeForm || !is_excluded(item.second, a_excludeForm)) { |
|
|
|
|
a_targetList->AddForm(item.second); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
const auto dataHandler = RE::TESDataHandler::GetSingleton(); |
|
|
|
|
|
|
|
|
|
if (!dataHandler) { |
|
|
|
|
return a_targetList->forms.size(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (const auto& form : dataHandler->GetFormArray(formType)) { |
|
|
|
|
if (!form || !form->GetPlayable()) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (a_excludeForm && is_excluded(form, a_excludeForm)) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
a_targetList->AddForm(form); |
|
|
|
|
} |
|
|
|
|
a_targetList->AddForm(form); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return a_targetList->forms.size(); |
|
|
|
@ -94,8 +108,7 @@ namespace Papyrus::ArtifactTracker |
|
|
|
|
inline std::int32_t AddArtifactsToList(VM* a_vm, StackID a_stackID, RE::StaticFunctionTag*, |
|
|
|
|
RE::TESForm* a_refOrList, |
|
|
|
|
RE::BGSListForm* a_targetList, |
|
|
|
|
RE::TESForm* a_excludeForm = NULL, |
|
|
|
|
bool excludeOnlyMisc = false) |
|
|
|
|
RE::TESForm* a_excludeForm = NULL) |
|
|
|
|
{ |
|
|
|
|
if (!a_refOrList) { |
|
|
|
|
a_vm->TraceStack("a_refOrList in AddItemsOfTypeAndKeywordToList is None", a_stackID); |
|
|
|
@ -110,7 +123,7 @@ namespace Papyrus::ArtifactTracker |
|
|
|
|
a_refOrList->As<RE::BGSListForm>()->ForEachForm([&](RE::TESForm& a_exform) { |
|
|
|
|
const auto refrItem = a_exform.As<RE::TESObjectREFR>(); |
|
|
|
|
if (refrItem) { |
|
|
|
|
AddArtifactsToList(a_vm, a_stackID, {}, refrItem, a_targetList, a_excludeForm, excludeOnlyMisc); |
|
|
|
|
AddArtifactsToList(a_vm, a_stackID, {}, refrItem, a_targetList, a_excludeForm); |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
}); |
|
|
|
@ -124,17 +137,8 @@ namespace Papyrus::ArtifactTracker |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
RE::BGSKeyword* recipeKeyword = RE::TESDataHandler::GetSingleton()->LookupForm<RE::BGSKeyword>(0xF5CB0, "Skyrim.esm"); // VendorItemRecipe
|
|
|
|
|
|
|
|
|
|
auto inv = containerRef->GetInventory([&](RE::TESBoundObject& a_exform) { |
|
|
|
|
return a_exform.GetPlayable() |
|
|
|
|
&& ( |
|
|
|
|
a_exform.formType == RE::FormType::Armor |
|
|
|
|
|| (a_exform.formType == RE::FormType::Weapon && a_exform.formID != 0x000001F4) |
|
|
|
|
|| a_exform.formType == RE::FormType::Misc |
|
|
|
|
|| (a_exform.formType == RE::FormType::Book && BookCheck::GetBookList().contains(a_exform.formID)) |
|
|
|
|
) |
|
|
|
|
&& (excludeOnlyMisc ? (a_exform.formType != RE::FormType::Misc || !is_excluded(&a_exform, a_excludeForm)) : !is_excluded(&a_exform, a_excludeForm)); |
|
|
|
|
return is_artifact(&a_exform) && !is_excluded(&a_exform, a_excludeForm); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
for (const auto& [item, data] : inv) { |
|
|
|
@ -258,7 +262,7 @@ namespace Papyrus::ArtifactTracker |
|
|
|
|
if (count > 0) { |
|
|
|
|
cellItems[item->formID] = true; |
|
|
|
|
if (inv.find(item) == inv.end()) { |
|
|
|
|
if (is_artifact(item, a_excludeForm)) { |
|
|
|
|
if (is_artifact(item) && !is_excluded(item, a_excludeForm)) { |
|
|
|
|
a_cellStorage->AddObjectToContainer(item, nullptr, 1, nullptr); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -278,12 +282,14 @@ namespace Papyrus::ArtifactTracker |
|
|
|
|
|
|
|
|
|
cellItems[baseObj->formID] = true; |
|
|
|
|
|
|
|
|
|
if (!is_artifact(baseObj, a_excludeForm)) { |
|
|
|
|
if (!is_artifact(baseObj)) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (inv.find(baseObj) == inv.end()) { |
|
|
|
|
a_cellStorage->AddObjectToContainer(baseObj, nullptr, 1, nullptr); |
|
|
|
|
if (!a_excludeForm || !is_excluded(baseObj, a_excludeForm)) { |
|
|
|
|
a_cellStorage->AddObjectToContainer(baseObj, nullptr, 1, nullptr); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -297,30 +303,6 @@ namespace Papyrus::ArtifactTracker |
|
|
|
|
cellItems.clear(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline std::int32_t AddAllBooksToList(VM* a_vm, StackID a_stackID, RE::StaticFunctionTag*, |
|
|
|
|
RE::BGSListForm* a_targetList, |
|
|
|
|
RE::TESForm* a_excludeForm = NULL) |
|
|
|
|
{ |
|
|
|
|
if (!a_targetList) { |
|
|
|
|
a_vm->TraceStack("a_targetList in AddItemsOfTypeAndKeywordToList is None", a_stackID); |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (a_excludeForm) { |
|
|
|
|
for (auto const& item : BookCheck::GetBookList()) { |
|
|
|
|
if (!is_excluded(item.second, a_excludeForm)) { |
|
|
|
|
a_targetList->AddForm(item.second); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
for (const auto& item : BookCheck::GetBookList()) { |
|
|
|
|
a_targetList->AddForm(item.second); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return a_targetList->forms.size(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline void Bind(VM& a_vm) |
|
|
|
|
{ |
|
|
|
|
BIND(AddAllFormsToList); |
|
|
|
@ -333,7 +315,5 @@ namespace Papyrus::ArtifactTracker |
|
|
|
|
logger::info("Registered HasRefInCell"sv); |
|
|
|
|
BIND(SyncCellStorage); |
|
|
|
|
logger::info("Registered SyncCellStorage"sv); |
|
|
|
|
BIND(AddAllBooksToList); |
|
|
|
|
logger::info("Registered AddAllBooksToList"sv); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|