1

Fixed book filtering, added a few comments

This commit is contained in:
Eddoursul 2022-07-01 16:40:15 +02:00
parent 7c1a934d4e
commit 238d00a816
4 changed files with 24 additions and 14 deletions

Binary file not shown.

View File

@ -24,21 +24,21 @@ namespace ArtifactTracker
const auto dataHandler = RE::TESDataHandler::GetSingleton();
if (!dataHandler) {
SKSE::log::warn("Failed to call RE::TESDataHandler::GetSingleton()");
SKSE::log::error("Failed to call RE::TESDataHandler::GetSingleton()");
return;
}
g_cellContainer = dataHandler->LookupForm(0x800, "Artifact Tracker.esp")->As<RE::TESBoundObject>();
g_cellContainer = dataHandler->LookupForm(0x800, "Artifact Tracker.esp")->As<RE::TESBoundObject>(); // ETR_CellStorageContainer
g_listNew = dataHandler->LookupForm<RE::BGSListForm>(0x803, "Artifact Tracker.esp");
g_listStored = dataHandler->LookupForm<RE::BGSListForm>(0x805, "Artifact Tracker.esp");
g_listFound = dataHandler->LookupForm<RE::BGSListForm>(0x806, "Artifact Tracker.esp");
g_persistentStorage = dataHandler->LookupForm<RE::BGSListForm>(0x807, "Artifact Tracker.esp");
g_listNew = dataHandler->LookupForm<RE::BGSListForm>(0x803, "Artifact Tracker.esp"); // ETR_ItemsNew
g_listStored = dataHandler->LookupForm<RE::BGSListForm>(0x805, "Artifact Tracker.esp"); // ETR_ItemsStored
g_listFound = dataHandler->LookupForm<RE::BGSListForm>(0x806, "Artifact Tracker.esp"); // ETR_ItemsFound
g_persistentStorage = dataHandler->LookupForm<RE::BGSListForm>(0x807, "Artifact Tracker.esp"); // ETR_PersistentStorageList
g_homeKeyword = dataHandler->LookupForm<RE::BGSKeyword>(0xFC1A3, "Skyrim.esm");
g_homeKeyword = dataHandler->LookupForm<RE::BGSKeyword>(0xFC1A3, "Skyrim.esm"); // LocTypePlayerHouse
const RE::BGSKeyword* recipeKeyword = dataHandler->LookupForm<RE::BGSKeyword>(0xF5CB0, "Skyrim.esm"); // VendorItemRecipe
RE::BGSListForm* excludeKeywords = dataHandler->LookupForm<RE::BGSListForm>(0x801, "Artifact Tracker.esp"); // ETR_ExcludeMiscKeywords
const auto recipeKeyword = dataHandler->LookupForm<RE::BGSKeyword>(0xF5CB0, "Skyrim.esm"); // VendorItemRecipe
const auto excludeKeywords = dataHandler->LookupForm<RE::BGSListForm>(0x801, "Artifact Tracker.esp"); // ETR_ExcludeMiscKeywords
if (!g_cellContainer || !g_listNew || !g_listStored || !g_listFound || !g_persistentStorage || !g_homeKeyword || !recipeKeyword || !excludeKeywords) {
SKSE::log::warn("Failed to load data from Artifact Tracker.esp");
@ -49,7 +49,7 @@ namespace ArtifactTracker
// Preloading item lists
for (const auto& form : dataHandler->GetFormArray<RE::TESObjectBOOK>()) {
if (form && !form->TeachesSpell() && (!form->HasKeyword(recipeKeyword) || BookCheck::IsBook(form))) {
if (form && !form->TeachesSpell() && (form->HasKeyword(recipeKeyword) || BookCheck::IsBook(form))) {
g_artifactMap[form->formID] = form;
}
}
@ -130,7 +130,7 @@ namespace ArtifactTracker
g_bHomeContainer = IsHome()
&& refr
&& refr.get()->GetParentCell() == RE::PlayerCharacter::GetSingleton()->GetParentCell()
&& !g_persistentStorage->HasForm(refr.get());
&& !g_persistentMap.contains(refr.get()->formID);
#ifdef _DEBUG
if (g_bHomeContainer) {
@ -248,7 +248,7 @@ namespace ArtifactTracker
g_persistentMap[cellStorage->formID] = cellStorage;
ToggleHomeMode(cellStorage);
} else {
SKSE::log::warn("Failed to create cell storage in OnCellEnter");
SKSE::log::error("Failed to create cell storage in OnCellEnter");
ToggleHomeMode(nullptr);
}
}
@ -410,8 +410,8 @@ namespace ArtifactTracker
if (!RefHasItem(g_cellStorage, form->formID)) {
#ifdef _DEBUG
SKSE::log::info("Added dropped {} to cell storage", form->GetName());
RE::DebugNotification("Adding to cell storage");
#endif
RE::DebugNotification("adding to cell storage");
g_cellStorage->AddObjectToContainer(form->As<RE::TESBoundObject>(), nullptr, 1, nullptr);
}
ListRemoveItem(g_listFound, form);

View File

@ -33,7 +33,14 @@ auto EventListener::ProcessEvent(
RE::BSTEventSource<RE::BGSActorCellEvent>* a_eventSource)
-> RE::BSEventNotifyControl
{
// Fires on every cell change, loaded or not.
// If it's new and not loaded, we can't add a new cell storage.
// In this case, it registers TESCellFullyLoadedEvent, which ensures a new ref can be added.
if (a_event->flags == RE::BGSActorCellEvent::CellFlag::kEnter) {
#ifdef _DEBUG
SKSE::log::info("BGSActorCellEvent");
#endif
ArtifactTracker::OnCellEnter(a_event->cellID);
}
@ -59,7 +66,11 @@ auto EventListener::ProcessEvent(
RE::BSTEventSource<RE::MenuOpenCloseEvent>* a_eventSource)
-> RE::BSEventNotifyControl
{
// This listener is expected to be unregistered outside of home.
if (ArtifactTracker::IsHome() && a_event->menuName == "ContainerMenu") {
#ifdef _DEBUG
SKSE::log::info("MenuOpenCloseEvent");
#endif
ArtifactTracker::SetContainerMode(a_event->opening);
}

View File

@ -1,7 +1,6 @@
#include "Papyrus.h"
#include "ArtifactTracker.h"
using namespace ArtifactTracker;
using namespace RE::BSScript;
using namespace SKSE;
using namespace SKSE::log;