Difference between revisions of "SKSE Plugin Development/Iterating all Actors/NPCs"
Jump to navigation
Jump to search
Line 23: | Line 23: | ||
= See Also = | = See Also = | ||
* [[Dynamically Attaching Scripts]] | * [[Dynamically Attaching Scripts]] | ||
[[Category:SKSE Plugin Development]] |
Latest revision as of 17:29, 10 December 2024
Similar to "Cloak Scanning" in Papyrus, but way less expensive in terms of performance.
const auto processLists = RE::ProcessLists::GetSingleton();
if (!processLists) { return; }
const auto *ActorTypeNPC = RE::TESForm::LookupByEditorID<RE::BGSKeyword>("ActorTypeNPC");
for (auto &targetHandle: processLists->highActorHandles) {
const auto actorPtr = targetHandle.get();
if (!actorPtr) { continue; }
// Check if actor is NPC (leave out if you want all actors)
const auto base = actorPtr->GetActorBase();
if (base && !base->GetRace()->HasKeyword(ActorTypeNPC)) {
continue;
}
// Your code here
}