Added support for equipment spectralization

master
Eddoursul 2 years ago
parent ddb85480d2
commit 52b2ab878d
  1. BIN
      SKSE/Plugins/EnderalSEEasyCrafting.dll
  2. 10
      src/src/EventListener.cpp
  3. 41
      src/src/Util.h

@ -29,7 +29,15 @@ auto EventListener::ProcessEvent(
});
}
}
}
} else if (a_event->eventName == "Enderal_StartSpectralizing") {
SKSE::GetTaskInterface()->AddTask([]() {
FetchSpectralizingSupplies();
});
} else if (a_event->eventName == "Enderal_FinishSpectralizing") {
SKSE::GetTaskInterface()->AddTask([]() {
ReturnSupplies();
});
}
return RE::BSEventNotifyControl::kContinue;
}

@ -93,6 +93,31 @@ inline void FetchSuppliesByType(RE::FormType formType)
}
}
inline void FetchSuppliesByForm(RE::TESForm* a_form)
{
if (!a_form) {
return;
}
const auto chest = RE::TESForm::LookupByID(0x5C132)->As<RE::TESObjectREFR>();
const auto targetRef = RE::PlayerCharacter::GetSingleton();
const auto inv = chest->GetInventory([&](RE::TESBoundObject& a_xform) {
return a_form == &a_xform;
});
RE::ITEM_REMOVE_REASON iReason = RE::ITEM_REMOVE_REASON::kStoreInContainer;
for (const auto& [item, data] : inv) {
const auto& [count, entry] = data;
if (count > 0) {
supplyCount.insert({ item, count });
chest->RemoveItem(item, count, iReason, nullptr, targetRef, 0, 0);
}
}
}
inline void ReturnSupplies()
{
if (!bSuppliesFetched) {
@ -248,4 +273,18 @@ inline void FetchSupplies(RE::TESFurniture* a_furn)
inline bool GetSuppliesFetched()
{
return bSuppliesFetched;
}
}
inline void FetchSpectralizingSupplies()
{
if (GetSettings().at("ShowFetchingNotification")) {
RE::DebugNotification("Fetching spectralizing supplies...");
}
bSuppliesFetched = true;
supplyCount.clear();
FetchSuppliesByType(RE::FormType::SoulGem);
FetchSuppliesByForm(RE::TESForm::LookupByID(0x34CDD)); // Bone Meal
FetchSuppliesByForm(RE::TESForm::LookupByID(0x3AD63)); // Ectoplasm
}

Loading…
Cancel
Save