Quest potion support

master
Eddoursul 2 years ago
parent d7058764d4
commit 8130a80e05
  1. 40
      src/src/Util.h

@ -158,6 +158,23 @@ inline void FetchSuppliesByForm(RE::TESForm* a_form)
}
}
inline bool IsQuestItem(RE::TESForm* a_form, RE::TESQuest* questElixir, RE::TESQuest* questCuthbert)
{
if (questElixir) {
if (a_form->formID == 0x34D22 || a_form->formID == 0x727E0 || a_form->formID == 0x3AD6F || a_form->formID == 0x59B86) {
return true;
}
}
if (questCuthbert) {
if (a_form->formID == 0x891AF || a_form->formID == 0x34C5D || a_form->formID == 0x34D32) {
return true;
}
}
return false;
}
inline void ReturnSupplies()
{
if (!bSuppliesFetched) {
@ -171,8 +188,21 @@ inline void ReturnSupplies()
const auto chest = GetChest();
const auto playerRef = RE::PlayerCharacter::GetSingleton();
auto questElixir = RE::TESDataHandler::GetSingleton()->LookupForm<RE::TESQuest>(0x1C82F, "Enderal - Forgotten Stories.esm"); // FS_NQ05
auto questCuthbert = RE::TESDataHandler::GetSingleton()->LookupForm<RE::TESQuest>(0x1CA09, "Enderal - Forgotten Stories.esm"); // FS_NQ07
if (questElixir->currentStage != 35) {
questElixir = nullptr;
}
if (questCuthbert->currentStage != 115) {
questCuthbert = nullptr;
}
for (auto& item : supplyCount) {
playerRef->RemoveItem(item.first->As<RE::TESBoundObject>(), item.second, iRemoveReason, nullptr, chest, 0, 0);
if (!IsQuestItem(item.first, questElixir, questCuthbert)) {
playerRef->RemoveItem(item.first->As<RE::TESBoundObject>(), item.second, iRemoveReason, nullptr, chest, 0, 0);
}
}
supplyCount.clear();
@ -199,9 +229,7 @@ inline void ReturnSupplies()
const auto keywords = component->obj->As<RE::BGSKeywordForm>();
if (component->obj->Is(RE::FormType::Ingredient)) {
suppliesToStore.insert(component->obj);
} else if (component->obj->Is(RE::FormType::Misc) && !component->obj->IsGold() && !component->obj->IsLockpick()) {
if (component->obj->Is(RE::FormType::Misc) && !component->obj->IsGold() && !component->obj->IsLockpick()) {
if (keywords->HasKeyword(kOreIngot) || keywords->HasKeyword(kAnimalPart) || keywords->HasKeyword(kAnimalHide) || keywords->HasKeyword(kFirewood) || keywords->HasKeyword(kTool) || keywords->HasKeyword(kClutter) || keywords->HasKeyword(kFoodRaw)) {
suppliesToStore.insert(component->obj);
}
@ -214,12 +242,12 @@ inline void ReturnSupplies()
}
const auto inv = playerRef->GetInventory([&](RE::TESBoundObject& a_form) {
return suppliesToStore.contains(&a_form);
return a_form.Is(RE::FormType::Ingredient) || suppliesToStore.contains(&a_form);
});
for (const auto& [item, data] : inv) {
const auto& [count, entry] = data;
if (count > 0 && !entry->IsFavorited() && !entry->IsQuestObject()) {
if (count > 0 && !entry->IsFavorited() && !entry->IsQuestObject() && !IsQuestItem(item, questElixir, questCuthbert)) {
playerRef->RemoveItem(item, count, iRemoveReason, nullptr, chest, 0, 0);
}
}

Loading…
Cancel
Save