diff --git a/SKSE/Plugins/EnderalSEEasyCrafting.dll b/SKSE/Plugins/EnderalSEEasyCrafting.dll index e014f59..75adc3a 100644 Binary files a/SKSE/Plugins/EnderalSEEasyCrafting.dll and b/SKSE/Plugins/EnderalSEEasyCrafting.dll differ diff --git a/src/src/Main.cpp b/src/src/Main.cpp index 5b87c44..e754f2b 100644 --- a/src/src/Main.cpp +++ b/src/src/Main.cpp @@ -27,8 +27,8 @@ namespace { { GetMessagingInterface()->RegisterListener([](MessagingInterface::Message* message) { if (message->type == MessagingInterface::kPostPostLoad) { - if (!std::filesystem::exists("Data\\Enderal - Forgotten Stories.esm")) { - MessageBoxW(NULL, L"Enderal SE Easy Crafting requires Enderal - Forgotten Stories.esm.", L"Enderal SE Easy Crafting", MB_OK | MB_ICONERROR); + if (!std::filesystem::exists("Data\\Enderal - Forgotten Stories.esm") || !std::filesystem::exists("Data\\SKSE\\Plugins\\EnderalSE.dll")) { + MessageBoxW(NULL, L"Easy Crafting requires Enderal SE 2.0.12 or newer.", L"Enderal SE Easy Crafting", MB_OK | MB_ICONERROR); exit(EXIT_FAILURE); } GetSettings(true); diff --git a/src/src/Util.h b/src/src/Util.h index 2c9f3df..ff16d08 100644 --- a/src/src/Util.h +++ b/src/src/Util.h @@ -148,6 +148,17 @@ inline void ReturnSupplies() playerRef->RemoveItem(item, count, iReason, nullptr, chest, 0, 0); } } + + std::thread([]() { + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + SKSE::GetTaskInterface()->AddTask([]() { + const auto spell = RE::TESForm::LookupByID(0x824AF); + if (spell) { + RE::PlayerCharacter::GetSingleton()->RemoveSpell(spell->As()); + spell->As()->effects[0]->effectItem.magnitude = 1; + } + }); + }).detach(); } inline void FetchSupplies(RE::TESFurniture* a_furn) @@ -166,8 +177,7 @@ inline void FetchSupplies(RE::TESFurniture* a_furn) bAllowFetch = true; } else { RE::TES::GetSingleton()->ForEachReferenceInRange(playerRef, 4000, [&chestAct, &bAllowFetch](RE::TESObjectREFR& b_ref) { - const auto base = b_ref.GetBaseObject(); - if (chestAct == base) { + if (chestAct == b_ref.GetBaseObject()) { bAllowFetch = true; return false; } @@ -181,31 +191,44 @@ inline void FetchSupplies(RE::TESFurniture* a_furn) bSuppliesFetched = true; - switch (a_furn->workBenchData.benchType.underlying()) { - case (int)RE::TESFurniture::WorkBenchData::BenchType::kAlchemy: - case (int)RE::TESFurniture::WorkBenchData::BenchType::kAlchemyExperiment: - RE::DebugNotification("Fetching ingredients..."); - FetchSuppliesByType(RE::FormType::Ingredient); - break; - case (int)RE::TESFurniture::WorkBenchData::BenchType::kEnchanting: - case (int)RE::TESFurniture::WorkBenchData::BenchType::kEnchantingExperiment: - RE::DebugNotification("Fetching soul gems..."); - FetchSuppliesByType(RE::FormType::SoulGem); - break; - default: - if (a_furn->As()->HasKeywordString("CraftingCookpot")) { - RE::DebugNotification("Fetching cooking ingredients..."); - FetchSuppliesByType(RE::FormType::Ingredient); - FetchSuppliesByType(RE::FormType::AlchemyItem); - } else { - RE::DebugNotification("Fetching crafting supplies..."); - FetchSuppliesByType(RE::FormType::Misc); - FetchSuppliesByType(RE::FormType::Ingredient); - FetchSuppliesByType(RE::FormType::SoulGem); - FetchSuppliesByType(RE::FormType::AlchemyItem); - } - break; + const auto spellForm = RE::TESForm::LookupByID(0x824AF); + if (spellForm) { + const auto spell = spellForm->As(); + playerRef->RemoveSpell(spell); + spell->effects[0]->effectItem.magnitude = 30000; + playerRef->AddSpell(spell); } + + std::thread([a_furn]() { + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + SKSE::GetTaskInterface()->AddTask([a_furn]() { + switch (a_furn->workBenchData.benchType.underlying()) { + case (int)RE::TESFurniture::WorkBenchData::BenchType::kAlchemy: + case (int)RE::TESFurniture::WorkBenchData::BenchType::kAlchemyExperiment: + RE::DebugNotification("Fetching ingredients..."); + FetchSuppliesByType(RE::FormType::Ingredient); + break; + case (int)RE::TESFurniture::WorkBenchData::BenchType::kEnchanting: + case (int)RE::TESFurniture::WorkBenchData::BenchType::kEnchantingExperiment: + RE::DebugNotification("Fetching soul gems..."); + FetchSuppliesByType(RE::FormType::SoulGem); + break; + default: + if (a_furn->As()->HasKeywordString("CraftingCookpot")) { + RE::DebugNotification("Fetching cooking ingredients..."); + FetchSuppliesByType(RE::FormType::Ingredient); + FetchSuppliesByType(RE::FormType::AlchemyItem); + } else { + RE::DebugNotification("Fetching crafting supplies..."); + FetchSuppliesByType(RE::FormType::Misc); + FetchSuppliesByType(RE::FormType::Ingredient); + FetchSuppliesByType(RE::FormType::SoulGem); + FetchSuppliesByType(RE::FormType::AlchemyItem); + } + break; + } + }); + }).detach(); } inline bool GetSuppliesFetched()