Skip to content

Commit

Permalink
Add some Actor functions
Browse files Browse the repository at this point in the history
  • Loading branch information
zax-ftw authored and powerof3 committed Aug 16, 2024
1 parent 475c0a5 commit 05ece3e
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/RE/A/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ namespace RE
TESForm* GetEquippedObjectInSlot(const BGSEquipSlot* slot) const;
float GetEquippedWeight();
std::int32_t GetFactionRank(TESFaction* a_faction, bool a_isPlayer);
FIGHT_REACTION GetFactionReaction(Actor* a_other) const;
std::int32_t GetGoldAmount(bool a_noInit = false);
ActorHandle GetHandle();
[[nodiscard]] NiAVObject* GetHeadPartObject(BGSHeadPart::HeadPartType a_type);
Expand All @@ -548,13 +549,16 @@ namespace RE
bool GetMountedBy(NiPointer<Actor>& a_outRider);
double GetMoveDirectionRelativeToFacing();
ObjectRefHandle GetOccupiedFurniture() const;
bool GetPlayerControls() const;
TESRace* GetRace() const;
float GetRegenDelay(ActorValue a_actorValue) const;
bool GetRider(NiPointer<Actor>& a_outRider);
[[nodiscard]] TESObjectARMO* GetSkin() const;
[[nodiscard]] TESObjectARMO* GetSkin(BGSBipedObjectForm::BipedObjectSlot a_slot, bool a_noInit = false);
[[nodiscard]] SOUL_LEVEL GetSoulSize() const;
TESNPC* GetTemplateBase();
float GetTotalCarryWeight();
float GetTrackedDamage() const;
TESFaction* GetVendorFaction();
const TESFaction* GetVendorFaction() const;
float GetVoiceRecoveryTime();
Expand All @@ -573,12 +577,15 @@ namespace RE
bool IsAIEnabled() const;
bool IsAlarmed() const;
bool IsAMount() const;
bool IsAngryWithPlayer() const { return boolFlags.all(BOOL_FLAGS::kAngryWithPlayer); };
bool IsAnimationDriven() const;
bool IsBeingRidden() const;
bool IsBlocking() const;
bool IsCasting(MagicItem* a_spell) const;
bool IsCombatTarget(Actor* a_other) const;
bool IsCommandedActor() const;
bool IsCurrentShout(SpellItem* a_power);
bool IsDoingFavor() const;
bool IsDualCasting() const;
bool IsEssential() const;
bool IsFactionInCrimeGroup(const TESFaction* a_faction) const;
Expand Down Expand Up @@ -614,6 +621,7 @@ namespace RE
void SetHeading(float a_angle); // SetRotationZ
void SetLifeState(ACTOR_LIFE_STATE a_lifeState);
void SetLooking(float a_angle); // SetRotationX
void SetPlayerControls(bool a_enable);
bool SetSleepOutfit(BGSOutfit* a_outfit, bool a_update3D);
void StealAlarm(TESObjectREFR* a_ref, TESForm* a_object, std::int32_t a_num, std::int32_t a_total, TESForm* a_owner, bool a_allowWarning);
void StopAlarmOnActor();
Expand Down
58 changes: 58 additions & 0 deletions src/RE/A/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
#include "RE/B/bhkCharacterController.h"
#include "RE/E/ExtraCanTalkToPlayer.h"
#include "RE/E/ExtraFactionChanges.h"
#include "RE/E/ExtraLeveledCreature.h"
#include "RE/F/FixedStrings.h"
#include "RE/F/FormTraits.h"
#include "RE/H/HighProcessData.h"
#include "RE/I/InventoryEntryData.h"
#include "RE/M/MiddleHighProcessData.h"
#include "RE/M/MovementControllerNPC.h"
#include "RE/M/Misc.h"
#include "RE/N/NiColor.h"
#include "RE/N/NiMath.h"
Expand Down Expand Up @@ -433,6 +435,13 @@ namespace RE
return func(this, a_faction, a_isPlayer);
}

FIGHT_REACTION Actor::GetFactionReaction(Actor* a_other) const
{
using func_t = decltype(&GetFactionReaction);
REL::Relocation<func_t> func{ RELOCATION_ID(36658, 37666) };
return func(this, a_other);
}

std::int32_t Actor::GetGoldAmount(bool a_noInit)
{
const auto inv = GetInventory([](TESBoundObject& a_object) -> bool {
Expand Down Expand Up @@ -539,6 +548,14 @@ namespace RE
}
}

bool Actor::GetPlayerControls() const
{
if (movementController) {
return movementController->IsPlayerControlsEnabled();
}
return false;
}

TESRace* Actor::GetRace() const
{
if (race) {
Expand Down Expand Up @@ -589,13 +606,27 @@ namespace RE
return func(this);
}

TESNPC* Actor::GetTemplateBase()
{
auto leveledCreature = extraList.GetByType<ExtraLeveledCreature>();
if (leveledCreature) {
return static_cast<TESNPC*>(leveledCreature->templateBase);
}
return GetActorBase();
}

float Actor::GetTotalCarryWeight()
{
using func_t = decltype(&Actor::GetTotalCarryWeight);
static REL::Relocation<func_t> func{ RELOCATION_ID(36456, 37452) };
return func(this);
}

float Actor::GetTrackedDamage() const
{
return currentProcess ? currentProcess->trackedDamage : 0.0f;
}

TESFaction* Actor::GetVendorFaction()
{
if (!vendorFaction) {
Expand Down Expand Up @@ -766,6 +797,13 @@ namespace RE
return func(this, a_spell);
}

bool Actor::IsCombatTarget(Actor* a_other) const
{
using func_t = decltype(&IsCombatTarget);
REL::Relocation<func_t> func{ RELOCATION_ID(37618, 38571) };
return func(this, a_other);
}

bool Actor::IsCommandedActor() const
{
return boolFlags.all(BOOL_FLAGS::kIsCommandedActor);
Expand All @@ -778,6 +816,14 @@ namespace RE
return func(this, a_power);
}

bool Actor::IsDoingFavor() const
{
if (currentProcess) {
return currentProcess->IsInCommandState();
}
return false;
}

bool Actor::IsDualCasting() const
{
if (!currentProcess) {
Expand Down Expand Up @@ -1036,6 +1082,18 @@ namespace RE
return func(this, a_angle);
}

void Actor::SetPlayerControls(bool a_enable)
{
if (movementController) {
EnableAI(!a_enable);
if (a_enable) {
movementController->EnablePlayerControls();
} else {
movementController->DisablePlayerControls();
}
}
}

bool Actor::SetSleepOutfit(BGSOutfit* a_outfit, bool a_update3D)
{
const auto npc = GetActorBase();
Expand Down

0 comments on commit 05ece3e

Please sign in to comment.