Difference between revisions of "SKSE Plugin Development/Iterating all Actors/NPCs"
Jump to navigation
Jump to search
(Created page with "Also known as Cloak Scanning. <syntaxhighlight lang="css"> const auto processLists = RE::ProcessLists::GetSingleton(); if (!processLists) { return; } const auto *ActorTypeNP...") |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
Similar to "Cloak Scanning" in Papyrus, but way less expensive in terms of performance. | |||
<syntaxhighlight lang="css"> | <syntaxhighlight lang="css"> | ||
Line 20: | Line 20: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
= See Also = | |||
* [[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
}