Skip to content

Commit

Permalink
Add TESObjectREFR::GetEnchantment
Browse files Browse the repository at this point in the history
  • Loading branch information
powerof3 committed Nov 25, 2024
1 parent eb78881 commit d160a87
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
2 changes: 0 additions & 2 deletions include/RE/A/ArrowProjectile.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#pragma once

#include "RE/F/FormTypes.h"
#include "RE/M/MissileProjectile.h"

namespace RE
{
class AlchemyItem;
class EnchantmentItem;

class ArrowProjectile : public MissileProjectile
{
Expand Down
1 change: 1 addition & 0 deletions include/RE/Skyrim.h
Original file line number Diff line number Diff line change
Expand Up @@ -1653,6 +1653,7 @@
#include "RE/V/VirtualMachine.h"
#include "RE/V/VoiceSpellFireHandler.h"
#include "RE/W/WeaponAnimationGraphManagerHolder.h"
#include "RE/W/WeaponEnchantmentController.h"
#include "RE/W/WeatherType.h"
#include "RE/W/WerewolfEffect.h"
#include "RE/W/WerewolfFeedEffect.h"
Expand Down
2 changes: 2 additions & 0 deletions include/RE/T/TESObjectREFR.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace RE
class BSFaceGenNiNode;
class BSFlattenedBoneTree;
class DialogueResponse;
class EnchantmentItem;
class Explosion;
class InventoryChanges;
class InventoryEntryData;
Expand Down Expand Up @@ -380,6 +381,7 @@ namespace RE
BGSEncounterZone* GetEncounterZone() const;
BGSLocation* GetEditorLocation() const;
bool GetEditorLocation(NiPoint3& a_outPos, NiPoint3& a_outRot, TESForm*& a_outWorldOrCell, TESObjectCELL* a_fallback);
EnchantmentItem* GetEnchantment() const;
std::optional<double> GetEnchantmentCharge() const;
TESFaction* GetFactionOwner();
ObjectRefHandle GetHandle();
Expand Down
18 changes: 18 additions & 0 deletions src/RE/T/TESObjectREFR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,24 @@ namespace RE
return GetEditorLocation2(a_outPos, a_outRot, a_outWorldOrCell, a_fallback);
}

EnchantmentItem* TESObjectREFR::GetEnchantment() const
{
auto xEnch = extraList.GetByType<ExtraEnchantment>();
if (xEnch && xEnch->enchantment) {
return xEnch->enchantment;
}

auto obj = GetObjectReference();
if (obj) {
auto ench = obj->As<TESEnchantableForm>();
if (ench) {
return ench->formEnchanting;
}
}

return nullptr;
}

std::optional<double> TESObjectREFR::GetEnchantmentCharge() const
{
std::optional<double> result;
Expand Down

0 comments on commit d160a87

Please sign in to comment.