1
Fork 0

Precache misc items

ae-1.6.629
Eddoursul 2 years ago
parent 1e71ef6032
commit 4341644277
  1. BIN
      Artifact Tracker.esp
  2. BIN
      SKSE/Plugins/ArtifactTrackerFunctions.dll
  3. BIN
      Scripts/ETR_Functions.pex
  4. BIN
      Scripts/ETR_TrackFoundItems.pex
  5. BIN
      Scripts/ETR_TrackNewItems.pex
  6. BIN
      Scripts/ETR_TrackStoredItems.pex
  7. 1
      Source/ArtifactTrackerDLL/CMakeLists.txt
  8. 4
      Source/ArtifactTrackerDLL/src/BookCheck.cpp
  9. 104
      Source/ArtifactTrackerDLL/src/Functions/ArtifactTracker.h
  10. 2
      Source/ArtifactTrackerDLL/src/Main.cpp
  11. 29
      Source/ArtifactTrackerDLL/src/MiscCheck.cpp
  12. 8
      Source/ArtifactTrackerDLL/src/MiscCheck.h
  13. 1
      Source/ArtifactTrackerDLL/src/Papyrus.cpp
  14. 4
      Source/Scripts/ETR_Functions.psc
  15. 9
      Source/Scripts/ETR_TrackFoundItems.psc
  16. 10
      Source/Scripts/ETR_TrackNewItems.psc
  17. 10
      Source/Scripts/ETR_TrackStoredItems.psc

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -24,6 +24,7 @@ set(sources
src/Main.cpp
src/Papyrus.cpp
src/BookCheck.cpp
src/MiscCheck.cpp
${CMAKE_CURRENT_BINARY_DIR}/version.rc)

@ -13,10 +13,10 @@ namespace BookCheck
return;
}
RE::BGSKeyword* recipeKeyword = dataHandler->LookupForm<RE::BGSKeyword>(0xF5CB0, "Skyrim.esm"); // VendorItemRecipe
const RE::BGSKeyword* recipeKeyword = dataHandler->LookupForm<RE::BGSKeyword>(0xF5CB0, "Skyrim.esm"); // VendorItemRecipe
for (const auto& form : dataHandler->GetFormArray<RE::TESObjectBOOK>()) {
if (!form || form->TeachesSpell()) {
if (!form || !form->GetPlayable() || form->TeachesSpell()) {
continue;
}
if (form->HasKeyword(recipeKeyword) || IsBook(form)) {

@ -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);
}
}

@ -1,5 +1,6 @@
#include "Papyrus.h"
#include "BookCheck.h"
#include "MiscCheck.h"
using namespace RE::BSScript;
using namespace SKSE;
@ -30,6 +31,7 @@ namespace {
GetMessagingInterface()->RegisterListener([](MessagingInterface::Message* message) {
if (message->type == MessagingInterface::kDataLoaded) {
BookCheck::PreloadBookList();
MiscCheck::PreloadMiscList();
}
});
}

@ -0,0 +1,29 @@
#include "MiscCheck.h"
namespace MiscCheck
{
std::unordered_map<RE::FormID, RE::TESObjectMISC*> validMisc;
void PreloadMiscList()
{
const auto dataHandler = RE::TESDataHandler::GetSingleton();
if (!dataHandler) {
return;
}
RE::BGSListForm* excludeForms = dataHandler->LookupForm<RE::BGSListForm>(0x809, "Artifact Tracker.esp"); // ETR_ExcludeMiscForms
RE::BGSListForm* excludeKeywords = dataHandler->LookupForm<RE::BGSListForm>(0x808, "Artifact Tracker.esp"); // ETR_ExcludeMiscKeywords
for (const auto& form : dataHandler->GetFormArray<RE::TESObjectMISC>()) {
if (form->GetPlayable() && !excludeForms->HasForm(form) && !form->HasKeywordInList(excludeKeywords, false)) {
validMisc[form->formID] = form;
}
}
}
std::unordered_map<RE::FormID, RE::TESObjectMISC*> GetMiscList()
{
return validMisc;
}
}

@ -0,0 +1,8 @@
#pragma once
namespace MiscCheck
{
void PreloadMiscList();
std::unordered_map<RE::FormID, RE::TESObjectMISC*> GetMiscList();
}

@ -1,5 +1,6 @@
#include "Papyrus.h"
#include "BookCheck.h"
#include "MiscCheck.h"
#include "Functions/ObjectReference.h"
#include "Functions/ArtifactTracker.h"

@ -2,9 +2,7 @@ Scriptname ETR_Functions Hidden
int function AddAllFormsToList(FormList targetList, int formType, Form excludeForm = None) native global
int function AddAllBooksToList(FormList targetList, Form excludeForm = None) native global
int function AddArtifactsToList(Form refOrList, FormList targetList, Form excludeForm = None, bool excludeOnlyMisc = false) native global
int function AddArtifactsToList(Form refOrList, FormList targetList, Form excludeForm = None) native global
int function GetItemCountInList(FormList refList, Form baseForm) native global

@ -6,7 +6,6 @@ FormList Property ETR_ItemsNew Auto
FormList Property ETR_ItemsFound Auto
FormList Property ETR_ItemsStored Auto
FormList Property ETR_PersistentStorageList Auto
FormList Property ETR_ExcludeFromNew Auto
FormList Property ETR_ExcludeMisc Auto
Container Property ETR_CellStorageContainer Auto
@ -89,7 +88,7 @@ Event OnUpdate()
endif
bRescanHome = false
ObjectReference cellStorage = ETR_Functions.GetCellStorage(PlayerRef, ETR_PersistentStorageList, ETR_CellStorageContainer)
ETR_Functions.SyncCellStorage(cellStorage, ETR_ExcludeMisc)
ETR_Functions.SyncCellStorage(cellStorage)
if ! bRescanPersistent
ETR_Functions.AddArtifactsToList(cellStorage, ETR_ItemsStored)
endif
@ -101,18 +100,18 @@ Event OnUpdate()
int n = aContainers.length
while n > 0
n -= 1
ETR_Functions.AddArtifactsToList(aContainers[n], ETR_ItemsStored, ETR_ExcludeMisc, true)
ETR_Functions.AddArtifactsToList(aContainers[n], ETR_ItemsStored)
endwhile
endif
ETR_ItemsFound.Revert()
ETR_Functions.AddArtifactsToList(PlayerRef, ETR_ItemsFound, ETR_ExcludeFromNew)
ETR_Functions.AddArtifactsToList(PlayerRef, ETR_ItemsFound, ETR_ItemsStored)
Actor[] aFollowers = ETR_Functions.GetPlayerFollowers()
int i = aFollowers.length
while i > 0
i -= 1
ETR_Functions.AddArtifactsToList(aFollowers[i], ETR_ItemsFound, ETR_ExcludeFromNew)
ETR_Functions.AddArtifactsToList(aFollowers[i], ETR_ItemsFound, ETR_ItemsStored)
endwhile
bBusy = false

@ -47,23 +47,23 @@ event OnPlayerLoadGame()
; Rebuild all lists to avoid discrepancies, stale data, and broken records
ETR_ItemsStored.Revert()
ETR_Functions.AddArtifactsToList(ETR_PersistentStorageList, ETR_ItemsStored, ETR_ExcludeMisc, true)
ETR_Functions.AddArtifactsToList(ETR_PersistentStorageList, ETR_ItemsStored)
ETR_ItemsFound.Revert()
ETR_Functions.AddArtifactsToList(PlayerRef, ETR_ItemsFound, ETR_ExcludeFromNew)
ETR_Functions.AddArtifactsToList(PlayerRef, ETR_ItemsFound, ETR_ItemsStored)
Actor[] aFollowers = ETR_Functions.GetPlayerFollowers()
int i = aFollowers.length
while i > 0
i -= 1
ETR_Functions.AddArtifactsToList(aFollowers[i], ETR_ItemsFound, ETR_ExcludeFromNew)
ETR_Functions.AddArtifactsToList(aFollowers[i], ETR_ItemsFound, ETR_ItemsStored)
endwhile
ETR_ItemsNew.Revert()
ETR_Functions.AddAllFormsToList(ETR_ItemsNew, 26, ETR_FoundAndStored)
ETR_Functions.AddAllFormsToList(ETR_ItemsNew, 41, ETR_FoundAndStored)
ETR_Functions.AddAllFormsToList(ETR_ItemsNew, 32, ETR_ExcludeFromNew)
ETR_Functions.AddAllBooksToList(ETR_ItemsNew, ETR_FoundAndStored)
ETR_Functions.AddAllFormsToList(ETR_ItemsNew, 32, ETR_FoundAndStored)
ETR_Functions.AddAllFormsToList(ETR_ItemsNew, 27, ETR_FoundAndStored)
endevent

@ -80,7 +80,7 @@ Event OnUpdate()
return
endif
ObjectReference cellStorage = ETR_Functions.GetCellStorage(PlayerRef, ETR_PersistentStorageList, ETR_CellStorageContainer)
ETR_Functions.SyncCellStorage(cellStorage, ETR_ExcludeMisc)
ETR_Functions.SyncCellStorage(cellStorage)
endif
if bRescanPersistent
@ -90,17 +90,17 @@ Event OnUpdate()
int n = aContainers.length
while n > 0
n -= 1
ETR_Functions.AddArtifactsToList(aContainers[n], ETR_ItemsStored, ETR_ExcludeMisc, true)
ETR_Functions.AddArtifactsToList(aContainers[n], ETR_ItemsStored)
endwhile
ETR_ItemsFound.Revert()
ETR_Functions.AddArtifactsToList(PlayerRef, ETR_ItemsFound, ETR_ExcludeFromNew)
ETR_Functions.AddArtifactsToList(PlayerRef, ETR_ItemsFound, ETR_ItemsStored)
Actor[] aFollowers = ETR_Functions.GetPlayerFollowers()
int i = aFollowers.length
while i > 0
i -= 1
ETR_Functions.AddArtifactsToList(aFollowers[i], ETR_ItemsFound, ETR_ExcludeFromNew)
ETR_Functions.AddArtifactsToList(aFollowers[i], ETR_ItemsFound, ETR_ItemsStored)
endwhile
endif
@ -126,7 +126,7 @@ event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemRefere
elseif bAtHome
ObjectReference cellStorage = ETR_Functions.GetCellStorage(PlayerRef, ETR_PersistentStorageList, ETR_CellStorageContainer)
if cellStorage.GetItemCount(akBaseItem)
ETR_Functions.SyncCellStorage(cellStorage, ETR_ExcludeMisc)
ETR_Functions.SyncCellStorage(cellStorage)
if ETR_Functions.GetItemCountInList(ETR_PersistentStorageList, akBaseItem) == 0
ETR_ItemsStored.RemoveAddedForm(akBaseItem)
ETR_ItemsFound.AddForm(akBaseItem)

Loading…
Cancel
Save