66 lines
1.6 KiB
C
66 lines
1.6 KiB
C
#pragma once
|
|
|
|
inline void ListRemoveItem(RE::BGSListForm* a_List, RE::TESForm* a_form)
|
|
{
|
|
using func_t = decltype(&ListRemoveItem);
|
|
REL::Relocation<func_t> func{ REL::RelocationID(20471, 20914) };
|
|
return func(a_List, a_form);
|
|
}
|
|
|
|
inline void ListRevert(RE::BGSListForm* a_form)
|
|
{
|
|
using func_t = decltype(&ListRevert);
|
|
REL::Relocation<func_t> func{ REL::RelocationID(20469, 20912) };
|
|
return func(a_form);
|
|
}
|
|
|
|
inline bool RefHasItem(RE::TESForm* a_refOrList, RE::FormID a_formID)
|
|
{
|
|
if (!a_refOrList || !a_formID) {
|
|
SKSE::log::warn("Invalid arguments in RefHasItem");
|
|
return false;
|
|
}
|
|
|
|
const auto refr = a_refOrList->As<RE::TESObjectREFR>();
|
|
|
|
if (refr) {
|
|
const auto invChanges = refr->GetInventoryChanges();
|
|
if (invChanges && invChanges->entryList) {
|
|
for (auto& entry : *invChanges->entryList) {
|
|
if (entry && entry->object && entry->object->formID == a_formID) {
|
|
return entry->countDelta > 0;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
const auto list = a_refOrList->As<RE::BGSListForm>();
|
|
|
|
if (list) {
|
|
for (const auto& ref : list->forms) {
|
|
if (ref && RefHasItem(ref, a_formID)) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
inline bool FollowersHaveItem(RE::TESForm* a_form)
|
|
{
|
|
if (const auto processLists = RE::ProcessLists::GetSingleton(); processLists) {
|
|
for (auto& actorHandle : processLists->highActorHandles) {
|
|
if (auto actor = actorHandle.get(); actor && actor->IsPlayerTeammate()) {
|
|
|
|
if (RefHasItem(actor->As<RE::TESObjectREFR>(), a_form->formID)) {
|
|
return true;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
return false;
|
|
} |