20 a_actor->NotifyAnimationGraph(
"attackStop");
21 a_actor->NotifyAnimationGraph(
"blockStop");
34 return (
static_cast<bool>(a_actor->actorState1.movingForward) ||
35 static_cast<bool>(a_actor->actorState1.movingBack) ||
36 static_cast<bool>(a_actor->actorState1.movingLeft) ||
37 static_cast<bool>(a_actor->actorState1.movingRight));
44 [[nodiscard]]
static bool IsGod(RE::Actor* a_actor)
48 return a_actor->IsPlayerRef() && RE::PlayerCharacter::IsGodMode();
59 using ct = RE::MagicSystem::CastingType;
60 switch (
const auto type = a_caster->currentSpell->GetCastingType())
78 const auto base = a_actor->GetActorBase();
82 const uint32_t perk_count = base->perkCount;
83 for (uint32_t i = 0; i < perk_count; i++)
85 RE::BGSPerk* perk = base->perks[i].perk;
88 perks.push_back(perk);
100 const auto proc = actor->currentProcess;
104 for (
auto& [
object, slot] : proc->equippedForms)
108 if (
const auto armor = object->As<RE::TESObjectARMO>())
110 if (armor->IsHeavyArmor())
127 const auto proc = actor->currentProcess;
131 for (
auto& [
object, slot] : proc->equippedForms)
135 if (
const auto armor = object->As<RE::TESObjectARMO>())
137 if (!armor->IsHeavyArmor())
156 if (!victim || !attacker)
162 victim->actorState1.sitSleepState == RE::SIT_SLEEP_STATE::kIsSitting ||
163 victim->actorState1.sitSleepState == RE::SIT_SLEEP_STATE::kIsSleeping ||
164 (victim->GetHeadingAngle(attacker->GetPosition(),
false) <= -135 ||
165 victim->GetHeadingAngle(attacker->GetPosition(),
false) >= 135) ||
177 if (
const auto* rightHandItem = actor->GetEquippedEntryData(
false))
179 if (rightHandItem->IsQuestObject())
185 if (
const auto* leftHandItem = actor->GetEquippedEntryData(
true))
187 if (leftHandItem->IsQuestObject())
207 if (a_ref->HasKeywordWithType(RE::DEFAULT_OBJECT::kKeywordVampire))
225 if (a_ref->HasKeywordWithType(RE::DEFAULT_OBJECT::kKeywordUndead))
245 if (a_actor->HasKeywordWithType(RE::DEFAULT_OBJECT::kKeywordDragon))
249 const auto key = RE::TESForm::LookupByEditorID<RE::BGSKeyword>(
"ActorTypeDragon");
252 return a_actor->HasKeyword(key);
259 const auto player = RE::PlayerCharacter::GetSingleton();
261 auto cell = player->GetParentCell();
264 cell = player->GetSaveParentCell();
277 const auto process = a_actor->GetHighProcess();
278 return process ? process->lightLevel : 0.0f;
285 const auto player = RE::PlayerCharacter::GetSingleton();
296 static void TryStagger(RE::Actor* a_target,
float a_staggerMult, RE::Actor* a_aggressor)
299 static REL::Relocation<func_t> func{RELOCATION_ID(36700, 37710)};
300 func(a_target, a_staggerMult, a_aggressor);
311 return actor && (actor->formFlags & RE::Actor::RecordFlags::kStartsDead);
329 return a_actor->GetActorValueModifier(RE::ACTOR_VALUE_MODIFIER::kTemporary, RE::ActorValue::kHealth) +
330 a_actor->GetPermanentActorValue(RE::ActorValue::kHealth);
344 return actor->GetActorValueModifier(RE::ACTOR_VALUE_MODIFIER::kTemporary, RE::ActorValue::kStamina) +
345 actor->GetPermanentActorValue(RE::ActorValue::kStamina);
359 return actor->GetActorValueModifier(RE::ACTOR_VALUE_MODIFIER::kTemporary, RE::ActorValue::kMagicka) +
360 actor->GetPermanentActorValue(RE::ActorValue::kMagicka);
373 a_actor->RestoreActorValue(RE::ActorValue::kHealth,
GetMaxHealth(a_actor));
374 a_actor->RestoreActorValue(RE::ActorValue::kStamina,
GetMaxStamina(a_actor));
375 a_actor->RestoreActorValue(RE::ActorValue::kMagicka,
GetMaxMagicka(a_actor));
387 const auto& activeEffects = a_actor->GetActiveEffectList();
391 return std::ranges::any_of(*activeEffects,
392 [a_type](
const RE::ActiveEffect* effect) ->
bool
394 if (!effect || effect->flags.any(RE::ActiveEffect::Flag::kInactive))
396 const auto base = effect->GetBaseObject();
397 return base && base->HasArchetype(a_type);
407 if (!a_actor || a_keyword.empty() || !a_actor->Is3DLoaded())
411 const auto& activeEffects = a_actor->GetActiveEffectList();
415 if (
const auto key = RE::TESForm::LookupByEditorID<RE::BGSKeyword>(a_keyword))
417 return std::ranges::any_of(*activeEffects,
418 [key](
const RE::ActiveEffect* effect) ->
bool
420 if (!effect || effect->flags.any(RE::ActiveEffect::Flag::kInactive))
422 const auto base = effect->GetBaseObject();
423 return base && base->HasKeyword(key);
426 return std::ranges::any_of(*activeEffects,
427 [a_keyword](
const RE::ActiveEffect* effect) ->
bool
429 if (!effect || effect->flags.any(RE::ActiveEffect::Flag::kInactive))
431 const auto base = effect->GetBaseObject();
432 return base && base->HasKeywordString(a_keyword);
440 static bool IsEffectActive(RE::Actor* a_actor,
const RE::EffectSetting* a_effect)
442 if (!a_actor || !a_effect)
446 const auto& activeEffects = a_actor->GetActiveEffectList();
450 return std::ranges::any_of(*activeEffects,
451 [a_effect](
const RE::ActiveEffect* effect) ->
bool
453 if (!effect || effect->flags.any(RE::ActiveEffect::Flag::kInactive))
455 const auto base = effect->GetBaseObject();
456 return base == a_effect;
466 static void AddItem(RE::Actor* a_actor, RE::TESBoundObject* a_item, RE::ExtraDataList* a_extraList,
int a_count,
467 RE::TESObjectREFR* a_fromRefr)
469 using func_t =
decltype(
AddItem);
470 static REL::Relocation<func_t> func{RELOCATION_ID(36525, 37525)};
471 return func(a_actor, a_item, a_extraList, a_count, a_fromRefr);
479 return AddItem(RE::PlayerCharacter::GetSingleton(), a_item,
nullptr, a_count,
nullptr);
489 static REL::Relocation<func_t> func{RELOCATION_ID(16564, 16919)};
490 return func(item, count);
502 const auto& inv = actor->GetInventory();
503 const auto it = inv.find(item);
504 return it != inv.end() && it->second.first > 0;
521 if (
const auto weapon = a_actor->GetAttackingWeapon())
523 const auto obj = weapon->object;
524 return obj ? obj->As<RE::TESObjectWEAP>() :
nullptr;
526 if (
const auto rhs = a_actor->GetEquippedObject(
false); rhs && rhs->IsWeapon())
528 return rhs->As<RE::TESObjectWEAP>();
530 if (
const auto lhs = a_actor->GetEquippedObject(
true); lhs && lhs->IsWeapon())
532 return lhs->As<RE::TESObjectWEAP>();
542 RE::NiPointer<RE::Actor> currentMount;
543 if (RE::PlayerCharacter::GetSingleton()->GetMount(currentMount))
545 return currentMount.get();
559 const auto high = actor->GetHighProcess();
563 const auto& attackData = high->attackData;
567 return attackData->data.flags.any(RE::AttackData::AttackFlag::kPowerAttack);
579 const auto high = actor->GetHighProcess();
584 if (actor->GetAttackState() == RE::ATTACK_STATE_ENUM::kNone)
587 const auto& attackData = high->attackData;
591 return attackData->data.flags.any(RE::AttackData::AttackFlag::kBashAttack);
601 static std::vector<RE::Actor*>
GetNearbyActors(
const RE::TESObjectREFR* a_ref,
const float a_radius,
602 const bool a_ignorePlayer)
604 std::vector<RE::Actor*> result;
605 const auto processLists = RE::ProcessLists::GetSingleton();
609 if (a_ignorePlayer && processLists->numberHighActors == 0)
612 const auto squaredRadius = a_radius * a_radius;
613 const auto originPos = a_ref->GetPosition();
615 result.reserve(processLists->numberHighActors);
617 const auto get_actor_within_radius = [&](RE::Actor* a_actor)
619 if (a_actor && a_actor != a_ref && originPos.GetSquaredDistance(a_actor->GetPosition()) <= squaredRadius)
621 result.emplace_back(a_actor);
624 for (
auto& actorHandle : processLists->highActorHandles)
626 const auto actor = actorHandle.get();
627 get_actor_within_radius(actor.get());
632 get_actor_within_radius(RE::PlayerCharacter::GetSingleton());
646 std::erase_if(actors, [](
const RE::Actor* a) {
return a->IsPlayerTeammate(); });
654 static bool IsGuardNearby(
const RE::TESObjectREFR* a_ref,
const float a_radius)
657 [](
const RE::Actor* a) {
return a && a->IsGuard(); });
664 static RE::Actor*
GetClosestActor(
const RE::TESObjectREFR* a_ref,
const float a_radius)
699 static REL::Relocation<func_t> func{RELOCATION_ID(36347, 37337)};
700 return func(a_actor, a_av);
712 const auto originPos = a_ref->GetPosition();
713 const auto it = std::ranges::min_element(actors,
714 [&](RE::Actor* a, RE::Actor* b)
716 return originPos.GetSquaredDistance(a->GetPosition()) <
717 originPos.GetSquaredDistance(b->GetPosition());
719 return it != actors.end() ? *it :
nullptr;
static void AddItemPlayer(RE::TESBoundObject *a_item, const int a_count)
Helper function to add an item to the player.
Definition st-actor.h:477
static float GetMaxHealth(RE::Actor *a_actor)
Get maximum Health of an actor.
Definition st-actor.h:321
static bool HasEffectWithKeywordActive(RE::Actor *a_actor, const std::string_view a_keyword)
Check if an actor has an effect active with a specific keyword.
Definition st-actor.h:405
static bool StartsDead(const RE::Actor *actor)
Check if actor is supposed to spawn dead.
Definition st-actor.h:309
static bool ActorHasEquippedHeavyArmor(RE::Actor *actor)
Check if an actor has any heavy armor equipped. It returning false does not mean the actor has light ...
Definition st-actor.h:96
static RE::Actor * GetClosestActor(const RE::TESObjectREFR *a_ref, const float a_radius)
Get the closest actor within a radius.
Definition st-actor.h:664
static RE::Actor * GetClosestFromVector(const RE::TESObjectREFR *a_ref, const std::vector< RE::Actor * > &actors)
Helper function to get the closest actor from a vector.
Definition st-actor.h:708
static std::vector< RE::Actor * > GetNearbyNonPlayerTeammates(const RE::TESObjectREFR *a_ref, const float a_radius)
Search all non-teammates within a certain radius.
Definition st-actor.h:643
static bool IsGuardNearby(const RE::TESObjectREFR *a_ref, const float a_radius)
Check if any actor within a certain radius is a guard.
Definition st-actor.h:654
static bool CasterIsCastingObject(RE::ActorMagicCaster *a_caster)
check if current spell is an object
Definition st-actor.h:55
static bool IsVampire(RE::Actor *a_ref)
Check if actor is vampire.
Definition st-actor.h:199
static bool IsBashing(const RE::Actor *actor)
Check if an actor is shield bashing.
Definition st-actor.h:573
static RE::Actor * GetClosestNonPlayerTeammate(const RE::TESObjectREFR *a_ref, const float a_radius)
Get the closest non-player teammate within a radius of a reference.
Definition st-actor.h:674
static bool IsInOpportunityState(RE::Actor *victim, const RE::Actor *attacker)
Very specific function used to see if an Actor is in a state an attack of opportunity should be possi...
Definition st-actor.h:153
static bool ActorHasItem(RE::Actor *actor, RE::TESBoundObject *item)
Check if actor has the specified item in the inventory.
Definition st-actor.h:497
static RE::TESObjectWEAP * GetWieldingWeapon(RE::Actor *a_actor)
Get the weapon a character is currently wielding.
Definition st-actor.h:513
static float GetCurrentLightLevelPlayer()
Get the light level the player is standing in.
Definition st-actor.h:283
static bool IsMoving(const RE::Actor *a_actor)
Convenience function to check if actor is moving.
Definition st-actor.h:27
static float GetMaxMagicka(RE::Actor *actor)
Get maximum Magicka of an actor.
Definition st-actor.h:351
static int RemoveItemPlayer(RE::TESBoundObject *item, int count)
Remove item from the player.
Definition st-actor.h:486
static void SetNPCLevel(RE::Actor *actor, uint16_t level)
Runs the console command SetLevel to set an actor's level to the amount.
Definition st-actor.h:686
static std::vector< RE::Actor * > GetNearbyActors(const RE::TESObjectREFR *a_ref, const float a_radius, const bool a_ignorePlayer)
Get all nearby actors.
Definition st-actor.h:601
static void AddItem(RE::Actor *a_actor, RE::TESBoundObject *a_item, RE::ExtraDataList *a_extraList, int a_count, RE::TESObjectREFR *a_fromRefr)
Add item to actor.
Definition st-actor.h:466
static void InterruptAttack(RE::Actor *a_actor)
Interrupt attack.
Definition st-actor.h:14
static bool ActorHasEquippedLightArmor(const RE::Actor *actor)
Check if an actor has any light armor equipped. It returning false does not mean the actor has heavy ...
Definition st-actor.h:123
static bool IsDragon(const RE::Actor *a_actor)
Check if actor is a dragon.
Definition st-actor.h:237
static void FullyHealActor(RE::Actor *a_actor)
Fully heals all 3 attributes of an actor.
Definition st-actor.h:365
static RE::Actor * GetPlayerMount()
Get the player mount.
Definition st-actor.h:540
static float GetMaxStamina(RE::Actor *actor)
Get maximum Stamina of an actor.
Definition st-actor.h:336
static void TryStagger(RE::Actor *a_target, float a_staggerMult, RE::Actor *a_aggressor)
Try to stagger a target.
Definition st-actor.h:296
static bool ActorHasQuestObjectInHand(RE::Actor *actor)
Check if actor has Quest item as weapon.
Definition st-actor.h:173
static float GetActorValuePercentage(RE::Actor *a_actor, RE::ActorValue a_av)
Get the actor value percentage of an actor.
Definition st-actor.h:696
static bool IsUndead(RE::Actor *a_ref)
Check if actor is undead.
Definition st-actor.h:217
static bool ActorHasEffectOfTypeActive(RE::Actor *a_actor, RE::EffectArchetypes::ArchetypeID a_type)
Check if actor has an effect of a specific type active.
Definition st-actor.h:382
static float GetCurrentLightLevel(const RE::Actor *a_actor)
Get the current light level the actor is standing in.
Definition st-actor.h:272
static RE::TESObjectCELL * GetPlayerCell()
Get the current cell the player is in.
Definition st-actor.h:257
static void GetPerksFromBaseActor(RE::Actor *a_actor, std::vector< RE::BGSPerk * > &perks)
Fills a vector<RE::BGSPerk*> reference with all the perks an actor inherits from the actor base.
Definition st-actor.h:73
static bool IsEffectActive(RE::Actor *a_actor, const RE::EffectSetting *a_effect)
Check if an actor has a specific effect active.
Definition st-actor.h:440
static bool IsGod(RE::Actor *a_actor)
convenience function to check if an actor is the player and whether god mode is enabled
Definition st-actor.h:44
static bool IsPowerAttacking(const RE::Actor *actor)
Check if an actor is power attacking.
Definition st-actor.h:553
static void RunConsoleCommandOnRef(RE::TESObjectREFR *a_target, const std::string_view a_command)
Run console command on reference.
Definition st-misc.h:117