SKSE Plugin Development/Iterating all Actors/NPCs
Jump to navigation
Jump to search
Also known as Cloak Scanning.
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
}