1
Fork 0

Moved delayed follower updates to the DLL

ae-1.6.629
Eddoursul 2 years ago
parent 39b9e5cc04
commit 77ef7c15da
  1. BIN
      SKSE/Plugins/ArtifactTracker.dll
  2. BIN
      Scripts/ArtifactTrackerPlayer.pex
  3. 45
      Source/ArtifactTrackerDLL/src/ArtifactTracker.cpp
  4. 2
      Source/ArtifactTrackerDLL/src/ArtifactTracker.h
  5. 13
      Source/ArtifactTrackerDLL/src/EventListener.cpp
  6. 8
      Source/ArtifactTrackerDLL/src/EventListener.h
  7. 27
      Source/Scripts/ArtifactTrackerPlayer.psc

Binary file not shown.

Binary file not shown.

@ -18,6 +18,7 @@ namespace ArtifactTracker
std::unordered_set<RE::FormType> g_artifactFormTypes;
std::unordered_map<RE::FormID, RE::TESObjectREFR*> g_persistentMap;
RE::TESObjectREFR* g_cellStorage;
std::uint32_t g_iFollowerIndex;
bool Init(bool bKID)
{
@ -628,4 +629,48 @@ namespace ArtifactTracker
}
}
}
// From po3's Papyrus Extender
std::vector<RE::Actor*> GetPlayerFollowers()
{
std::vector<RE::Actor*> result;
if (const auto processLists = RE::ProcessLists::GetSingleton(); processLists) {
for (auto& actorHandle : processLists->highActorHandles) {
if (auto actor = actorHandle.get(); actor && actor->IsPlayerTeammate()) {
result.push_back(actor.get());
}
}
}
return result;
}
void RescanFoundArtifacts()
{
ListRevert(g_listFound);
AddRefArtifactsToList(RE::PlayerCharacter::GetSingleton(), g_listFound, g_listStored);
for (const auto& ref : GetPlayerFollowers()) {
AddRefArtifactsToList(ref, g_listFound, g_listStored);
}
}
void OnLocationChange()
{
std::uint32_t iCurrentFollowers;
for (const auto& actor : GetPlayerFollowers()) {
iCurrentFollowers += actor->formID;
}
if (iCurrentFollowers != g_iFollowerIndex) {
g_iFollowerIndex = iCurrentFollowers;
std::thread([]() {
std::this_thread::sleep_for(std::chrono::milliseconds(3000)); // wait for followers to load into the new cell
RE::DebugNotification("Team changed, rescanning the found list");
RescanFoundArtifacts();
}).detach();
}
}
}

@ -37,4 +37,6 @@ namespace ArtifactTracker
void OnContainerChanged(const RE::TESContainerChangedEvent* a_event, RE::TESForm* form);
void AddRefArtifactsToList(RE::TESForm* a_refOrList, RE::BGSListForm* a_targetList, RE::BGSListForm* a_excludeList = NULL);
void OnLocationChange();
}

@ -12,6 +12,7 @@ void EventListener::Install()
{
RE::PlayerCharacter::GetSingleton()->AddEventSink<RE::BGSActorCellEvent>(EventListener::GetSingleton());
RE::ScriptEventSourceHolder::GetSingleton()->AddEventSink<RE::TESContainerChangedEvent>(EventListener::GetSingleton());
RE::ScriptEventSourceHolder::GetSingleton()->AddEventSink<RE::TESActorLocationChangeEvent>(EventListener::GetSingleton());
}
auto EventListener::ProcessEvent(
@ -106,3 +107,15 @@ auto EventListener::ProcessEvent(
return RE::BSEventNotifyControl::kContinue;
}
auto EventListener::ProcessEvent(
const RE::TESActorLocationChangeEvent* a_event,
RE::BSTEventSource<RE::TESActorLocationChangeEvent>* a_eventSource)
-> RE::BSEventNotifyControl
{
if (a_event->actor->IsPlayerRef()) {
ArtifactTracker::OnLocationChange();
}
return RE::BSEventNotifyControl::kContinue;
}

@ -6,7 +6,8 @@ class EventListener :
public RE::BSTEventSink<RE::TESCellFullyLoadedEvent>,
public RE::BSTEventSink<RE::BGSActorCellEvent>,
public RE::BSTEventSink<RE::MenuOpenCloseEvent>,
public RE::BSTEventSink<RE::TESActivateEvent>
public RE::BSTEventSink<RE::TESActivateEvent>,
public RE::BSTEventSink<RE::TESActorLocationChangeEvent>
{
public:
~EventListener() = default;
@ -48,6 +49,11 @@ public:
RE::BSTEventSource<RE::TESActivateEvent>* a_eventSource)
-> RE::BSEventNotifyControl override;
auto ProcessEvent(
const RE::TESActorLocationChangeEvent* a_event,
RE::BSTEventSource<RE::TESActorLocationChangeEvent>* a_eventSource)
-> RE::BSEventNotifyControl override;
private:
EventListener() = default;
};

@ -4,7 +4,6 @@ FormList Property ETR_ItemsNew Auto
FormList Property ETR_ItemsFound Auto
FormList Property ETR_ItemsStored Auto
int iFollowerIndex = 0
int iArtifactCount = 0
@ -58,32 +57,6 @@ Event OnPlayerLoadGame()
EndEvent
Event OnLocationChange(Location akOldLoc, Location akNewLoc)
int iCurrentFollowers = 0;
Actor[] aFollowers = GetPlayerFollowers()
int i = aFollowers.length
while i > 0
i -= 1
iCurrentFollowers += aFollowers[i].GetFormID()
endwhile
if iCurrentFollowers != iFollowerIndex
iFollowerIndex = iCurrentFollowers
RegisterForSingleUpdate(5.0) ; wait until followers load into the location
endif
endEvent
Event OnUpdate()
Debug.Notification("Team changed, updating ETR_ItemsFound")
RescanFoundArtifacts()
EndEvent
; NATIVE FUNCTIONS
bool function Load() native global

Loading…
Cancel
Save