|
|
|
@ -23,6 +23,7 @@ namespace ArtifactTracker |
|
|
|
|
RE::BGSKeyword* g_homeKeyword; |
|
|
|
|
std::unordered_map<RE::FormID, RE::TESForm*> g_artifactMap; |
|
|
|
|
std::unordered_set<RE::FormType> g_artifactFormTypes; |
|
|
|
|
std::unordered_set<RE::FormType> g_artifactAllFormTypes; |
|
|
|
|
std::unordered_map<RE::FormID, RE::TESObjectREFR*> g_persistentMap; |
|
|
|
|
RE::TESObjectREFR* g_cellStorage; |
|
|
|
|
const SKSE::LoadInterface* g_loadInterface; |
|
|
|
@ -72,6 +73,14 @@ namespace ArtifactTracker |
|
|
|
|
|
|
|
|
|
// Preloading item lists
|
|
|
|
|
|
|
|
|
|
g_artifactAllFormTypes.insert(RE::FormType::Weapon); |
|
|
|
|
g_artifactAllFormTypes.insert(RE::FormType::Armor); |
|
|
|
|
g_artifactAllFormTypes.insert(RE::FormType::Book); |
|
|
|
|
g_artifactAllFormTypes.insert(RE::FormType::Misc); |
|
|
|
|
g_artifactAllFormTypes.insert(RE::FormType::AlchemyItem); |
|
|
|
|
g_artifactAllFormTypes.insert(RE::FormType::Ingredient); |
|
|
|
|
g_artifactAllFormTypes.insert(RE::FormType::SoulGem); |
|
|
|
|
|
|
|
|
|
g_artifactFormTypes.insert(RE::FormType::Weapon); |
|
|
|
|
for (const auto& form : dataHandler->GetFormArray<RE::TESObjectWEAP>()) { |
|
|
|
|
if (form->GetPlayable() && !form->IsBound() && !form->weaponData.flags.all(RE::TESObjectWEAP::Data::Flag::kCantDrop)) { |
|
|
|
@ -425,7 +434,7 @@ namespace ArtifactTracker |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const auto contInv = a_ref.GetInventory([&](RE::TESBoundObject& a_object) -> bool { |
|
|
|
|
return !cellItems.contains(a_object.formID) && IsArtifact(&a_object); |
|
|
|
|
return !cellItems.contains(a_object.formID) && g_artifactAllFormTypes.contains(a_object.GetFormType()); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
for (const auto& [item, data] : contInv) { |
|
|
|
@ -434,7 +443,7 @@ namespace ArtifactTracker |
|
|
|
|
if (inv.find(item) == inv.end()) { |
|
|
|
|
g_cellStorage->AddObjectToContainer(item, nullptr, 1, nullptr); |
|
|
|
|
} |
|
|
|
|
if (!g_listStored->HasForm(item)) { |
|
|
|
|
if (IsArtifact(item) && !g_listStored->HasForm(item)) { |
|
|
|
|
ListRemoveItem(g_listNew, item); |
|
|
|
|
ListRemoveItem(g_listFound, item); |
|
|
|
|
g_listStored->AddForm(item); |
|
|
|
@ -445,7 +454,7 @@ namespace ArtifactTracker |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (a_ref.IsDisabled() || a_ref.IsMarkedForDeletion() || cellItems.contains(baseObj->formID) || !IsArtifact(baseObj)) { |
|
|
|
|
if (!g_artifactAllFormTypes.contains(baseObj->GetFormType()) || a_ref.IsDisabled() || a_ref.IsMarkedForDeletion() || cellItems.contains(baseObj->formID)) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -455,7 +464,7 @@ namespace ArtifactTracker |
|
|
|
|
g_cellStorage->AddObjectToContainer(baseObj, nullptr, 1, nullptr); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!g_listStored->HasForm(baseObj)) { |
|
|
|
|
if (IsArtifact(baseObj) && !g_listStored->HasForm(baseObj)) { |
|
|
|
|
ListRemoveItem(g_listNew, baseObj); |
|
|
|
|
ListRemoveItem(g_listFound, baseObj); |
|
|
|
|
g_listStored->AddForm(baseObj); |
|
|
|
@ -469,7 +478,7 @@ namespace ArtifactTracker |
|
|
|
|
if (count > 0 && !cellItems.contains(item->formID)) { |
|
|
|
|
g_cellStorage->RemoveItem(item, count, RE::ITEM_REMOVE_REASON::kRemove, nullptr, nullptr); |
|
|
|
|
|
|
|
|
|
if (!RefListHasItem(g_persistentStorage, item->formID)) { |
|
|
|
|
if (IsArtifact(item) && !RefListHasItem(g_persistentStorage, item->formID)) { |
|
|
|
|
ListRemoveItem(g_listStored, item); |
|
|
|
|
if (GetItemCount(RE::PlayerCharacter::GetSingleton(), item) || FollowersHaveItem(item)) { |
|
|
|
|
ListRemoveItem(g_listNew, item); |
|
|
|
|