1

Non-nested exclusion in AddArtifactsToList by default

This commit is contained in:
Eddoursul 2022-06-22 10:59:20 +02:00
parent 0b6983df8c
commit 9ddc6a8c3a
11 changed files with 21 additions and 21 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -2,7 +2,7 @@
namespace Papyrus::ArtifactTracker namespace Papyrus::ArtifactTracker
{ {
inline bool is_excluded(RE::TESForm* a_form, RE::TESForm* a_excludeForm = NULL) inline bool is_excluded(RE::TESForm* a_form, RE::TESForm* a_excludeForm = NULL, bool nested = true)
{ {
if (!a_excludeForm) { if (!a_excludeForm) {
return false; return false;
@ -13,7 +13,7 @@ namespace Papyrus::ArtifactTracker
if (list) { if (list) {
if (list->HasForm(a_form)) { if (list->HasForm(a_form)) {
return true; return true;
} else { } else if (nested) {
bool isExcluded = false; bool isExcluded = false;
list->ForEachForm([&](RE::TESForm& a_exform) { list->ForEachForm([&](RE::TESForm& a_exform) {
@ -69,7 +69,8 @@ namespace Papyrus::ArtifactTracker
inline std::int32_t AddAllFormsToList(RE::StaticFunctionTag*, inline std::int32_t AddAllFormsToList(RE::StaticFunctionTag*,
RE::BGSListForm* a_targetList, RE::BGSListForm* a_targetList,
short a_formType, short a_formType,
RE::TESForm* a_excludeForm = NULL) RE::TESForm* a_excludeForm = NULL,
bool excludeNested = true)
{ {
const auto formType = static_cast<RE::FormType>(a_formType); const auto formType = static_cast<RE::FormType>(a_formType);
@ -77,7 +78,7 @@ namespace Papyrus::ArtifactTracker
case RE::FormType::Book: case RE::FormType::Book:
for (auto const& item : BookCheck::GetBookList()) { for (auto const& item : BookCheck::GetBookList()) {
if (!a_excludeForm || !is_excluded(item.second, a_excludeForm)) { if (!a_excludeForm || !is_excluded(item.second, a_excludeForm, excludeNested)) {
a_targetList->AddForm(item.second); a_targetList->AddForm(item.second);
} }
} }
@ -85,7 +86,7 @@ namespace Papyrus::ArtifactTracker
case RE::FormType::Misc: case RE::FormType::Misc:
for (auto const& item : MiscCheck::GetMiscList()) { for (auto const& item : MiscCheck::GetMiscList()) {
if (!a_excludeForm || !is_excluded(item.second, a_excludeForm)) { if (!a_excludeForm || !is_excluded(item.second, a_excludeForm, excludeNested)) {
a_targetList->AddForm(item.second); a_targetList->AddForm(item.second);
} }
} }
@ -105,7 +106,7 @@ namespace Papyrus::ArtifactTracker
if (!form || !form->GetPlayable()) { if (!form || !form->GetPlayable()) {
continue; continue;
} }
if (a_excludeForm && is_excluded(form, a_excludeForm)) { if (a_excludeForm && is_excluded(form, a_excludeForm, excludeNested)) {
continue; continue;
} }
a_targetList->AddForm(form); a_targetList->AddForm(form);
@ -118,7 +119,8 @@ namespace Papyrus::ArtifactTracker
inline std::int32_t AddArtifactsToList(VM* a_vm, StackID a_stackID, RE::StaticFunctionTag*, inline std::int32_t AddArtifactsToList(VM* a_vm, StackID a_stackID, RE::StaticFunctionTag*,
RE::TESForm* a_refOrList, RE::TESForm* a_refOrList,
RE::BGSListForm* a_targetList, RE::BGSListForm* a_targetList,
RE::TESForm* a_excludeForm = NULL) RE::TESForm* a_excludeForm = NULL,
bool excludeNested = false)
{ {
if (!a_refOrList) { if (!a_refOrList) {
a_vm->TraceStack("a_refOrList in AddArtifactsToList is None", a_stackID); a_vm->TraceStack("a_refOrList in AddArtifactsToList is None", a_stackID);
@ -133,7 +135,7 @@ namespace Papyrus::ArtifactTracker
a_refOrList->As<RE::BGSListForm>()->ForEachForm([&](RE::TESForm& a_exform) { a_refOrList->As<RE::BGSListForm>()->ForEachForm([&](RE::TESForm& a_exform) {
const auto refrItem = a_exform.As<RE::TESObjectREFR>(); const auto refrItem = a_exform.As<RE::TESObjectREFR>();
if (refrItem) { if (refrItem) {
AddArtifactsToList(a_vm, a_stackID, {}, refrItem, a_targetList, a_excludeForm); AddArtifactsToList(a_vm, a_stackID, nullptr, refrItem, a_targetList, a_excludeForm);
} }
return true; return true;
}); });
@ -148,7 +150,7 @@ namespace Papyrus::ArtifactTracker
} }
auto inv = containerRef->GetInventory([&](RE::TESBoundObject& a_exform) { auto inv = containerRef->GetInventory([&](RE::TESBoundObject& a_exform) {
return is_artifact(&a_exform) && !is_excluded(&a_exform, a_excludeForm); return is_artifact(&a_exform) && !is_excluded(&a_exform, a_excludeForm, excludeNested);
}); });
for (const auto& item : inv) { for (const auto& item : inv) {
@ -283,11 +285,12 @@ namespace Papyrus::ArtifactTracker
inline std::int32_t AddArtifactsFromFollowersToList(RE::StaticFunctionTag*, inline std::int32_t AddArtifactsFromFollowersToList(RE::StaticFunctionTag*,
RE::BGSListForm* a_targetList, RE::BGSListForm* a_targetList,
RE::TESForm* a_excludeForm = NULL) RE::TESForm* a_excludeForm = NULL,
bool excludeNested = false)
{ {
for (const auto& actor : GetPlayerFollowers(nullptr)) { for (const auto& actor : GetPlayerFollowers(nullptr)) {
auto inv = actor->GetInventory([&](RE::TESBoundObject& a_exform) { auto inv = actor->GetInventory([&](RE::TESBoundObject& a_exform) {
return is_artifact(&a_exform) && !is_excluded(&a_exform, a_excludeForm); return is_artifact(&a_exform) && !is_excluded(&a_exform, a_excludeForm, excludeNested);
}); });
for (const auto& item : inv) { for (const auto& item : inv) {

View File

@ -1,8 +1,8 @@
Scriptname ETR_Functions Hidden Scriptname ETR_Functions Hidden
int function AddAllFormsToList(FormList targetList, int formType, Form excludeForm = None) native global int function AddAllFormsToList(FormList targetList, int formType, Form excludeForm = None, bool excludeNested = true) native global
int function AddArtifactsToList(Form refOrList, FormList targetList, Form excludeForm = None) native global int function AddArtifactsToList(Form refOrList, FormList targetList, Form excludeForm = None, bool excludeNested = false) native global
int function GetItemCountInList(FormList refList, Form baseForm) native global int function GetItemCountInList(FormList refList, Form baseForm) native global
@ -14,4 +14,4 @@ Actor[] function GetPlayerFollowers() native global
bool function FollowersHaveItem(Form baseForm) native global bool function FollowersHaveItem(Form baseForm) native global
int function AddArtifactsFromFollowersToList(FormList targetList, Form excludeForm = None) native global int function AddArtifactsFromFollowersToList(FormList targetList, Form excludeForm = None, bool excludeNested = false) native global

View File

@ -6,7 +6,6 @@ FormList Property ETR_ItemsNew Auto
FormList Property ETR_ItemsFound Auto FormList Property ETR_ItemsFound Auto
FormList Property ETR_ItemsStored Auto FormList Property ETR_ItemsStored Auto
FormList Property ETR_PersistentStorageList Auto FormList Property ETR_PersistentStorageList Auto
FormList Property ETR_ExcludeMisc Auto
Container Property ETR_CellStorageContainer Auto Container Property ETR_CellStorageContainer Auto
@ -52,7 +51,7 @@ Event OnLocationChange(Location akOldLoc, Location akNewLoc)
iFollowerIndex = iCurrentFollowers iFollowerIndex = iCurrentFollowers
bRescanHome = false bRescanHome = false
bRescanPersistent = false bRescanPersistent = false
RegisterForSingleUpdate(3.0) ; wait until followers load into the location RegisterForSingleUpdate(5.0) ; wait until followers load into the location
endif endif
endEvent endEvent
@ -133,10 +132,12 @@ event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemRefe
ETR_ItemsFound.RemoveAddedForm(akBaseItem) ETR_ItemsFound.RemoveAddedForm(akBaseItem)
ETR_ItemsNew.AddForm(akBaseItem) ETR_ItemsNew.AddForm(akBaseItem)
endif endif
elseif bAtHome && akItemReference elseif bAtHome && akItemReference
ETR_ItemsFound.RemoveAddedForm(akBaseItem) ETR_ItemsFound.RemoveAddedForm(akBaseItem)
ETR_ItemsStored.AddForm(akBaseItem) ETR_ItemsStored.AddForm(akBaseItem)
ETR_Functions.GetCellStorage(PlayerRef, ETR_PersistentStorageList, ETR_CellStorageContainer).AddItem(akBaseItem, 1, true) ETR_Functions.GetCellStorage(PlayerRef, ETR_PersistentStorageList, ETR_CellStorageContainer).AddItem(akBaseItem, 1, true)
elseif PlayerRef.GetItemCount(akBaseItem) == 0 && ! ETR_Functions.FollowersHaveItem(akBaseItem) elseif PlayerRef.GetItemCount(akBaseItem) == 0 && ! ETR_Functions.FollowersHaveItem(akBaseItem)
ETR_ItemsFound.RemoveAddedForm(akBaseItem) ETR_ItemsFound.RemoveAddedForm(akBaseItem)
ETR_ItemsNew.AddForm(akBaseItem) ETR_ItemsNew.AddForm(akBaseItem)

View File

@ -5,9 +5,7 @@ Actor Property PlayerRef Auto
FormList Property ETR_ItemsNew Auto FormList Property ETR_ItemsNew Auto
FormList Property ETR_ItemsFound Auto FormList Property ETR_ItemsFound Auto
FormList Property ETR_ItemsStored Auto FormList Property ETR_ItemsStored Auto
FormList Property ETR_ExcludeFromNew Auto
FormList Property ETR_PersistentStorageList Auto FormList Property ETR_PersistentStorageList Auto
FormList Property ETR_ExcludeMisc Auto
FormList Property ETR_FoundAndStored Auto FormList Property ETR_FoundAndStored Auto
@ -48,10 +46,10 @@ event OnPlayerLoadGame()
ETR_Functions.AddArtifactsFromFollowersToList(ETR_ItemsFound, ETR_ItemsStored) ETR_Functions.AddArtifactsFromFollowersToList(ETR_ItemsFound, ETR_ItemsStored)
ETR_ItemsNew.Revert() ETR_ItemsNew.Revert()
ETR_Functions.AddAllFormsToList(ETR_ItemsNew, 26, ETR_FoundAndStored)
ETR_Functions.AddAllFormsToList(ETR_ItemsNew, 41, ETR_FoundAndStored) ETR_Functions.AddAllFormsToList(ETR_ItemsNew, 41, ETR_FoundAndStored)
ETR_Functions.AddAllFormsToList(ETR_ItemsNew, 32, ETR_FoundAndStored) ETR_Functions.AddAllFormsToList(ETR_ItemsNew, 32, ETR_FoundAndStored)
ETR_Functions.AddAllFormsToList(ETR_ItemsNew, 27, ETR_FoundAndStored) ETR_Functions.AddAllFormsToList(ETR_ItemsNew, 27, ETR_FoundAndStored)
ETR_Functions.AddAllFormsToList(ETR_ItemsNew, 26, ETR_FoundAndStored)
endevent endevent

View File

@ -6,8 +6,6 @@ FormList Property ETR_ItemsNew Auto
FormList Property ETR_ItemsFound Auto FormList Property ETR_ItemsFound Auto
FormList Property ETR_ItemsStored Auto FormList Property ETR_ItemsStored Auto
FormList Property ETR_PersistentStorageList Auto FormList Property ETR_PersistentStorageList Auto
FormList Property ETR_ExcludeFromNew Auto
FormList Property ETR_ExcludeMisc Auto
Container Property ETR_CellStorageContainer Auto Container Property ETR_CellStorageContainer Auto