CommonLibVR
Loading...
Searching...
No Matches
MagicTarget.h
Go to the documentation of this file.
1#pragma once
2
3#include "RE/B/BSContainer.h"
5#include "RE/B/BSTEvent.h"
6#include "RE/B/BSTList.h"
9#include "RE/M/MagicSystem.h"
10#include "RE/N/NiPoint3.h"
11#ifdef SKYRIMVR
12# include "RE/B/BSContainer.h"
13#endif
14
15namespace RE
16{
17 class Actor;
18 class ActiveEffect;
19 class BGSKeyword;
20 class EffectItem;
21 class EffectSetting;
22 class MagicItem;
23 class TESBoundObject;
24 class TESObjectREFR;
25
26 struct Effect;
27
29 {
30 public:
31 inline static constexpr auto RTTI = RTTI_MagicTarget;
32 inline static constexpr auto VTABLE = VTABLE_MagicTarget;
33
35
37 {
38 public:
39 inline static constexpr auto RTTI = RTTI_MagicTarget__ForEachActiveEffectVisitor;
41
42 virtual ~ForEachActiveEffectVisitor(){}; // 00
43
44 // add
45 virtual BSContainer::ForEachResult Accept(ActiveEffect* a_effect) = 0; // 01
46 };
47 static_assert(sizeof(ForEachActiveEffectVisitor) == 0x8);
48
57 static_assert(sizeof(SpellDispelData) == 0x20);
58
60 {
63 Effect* effect; // 10
65 std::uint64_t unk20; // 20 - MagicCaster::PostCreationCallback
66 std::uint64_t unk28; // 28 - MagicTarget**
68 float magnitude; // 3C
69 float unk40; // 40
71 std::uint8_t unk48; // 48
72 bool dualCasted; // 49
73 std::uint16_t pad4A; // 4A
74 std::uint32_t pad4C; // 4C
75 };
76 static_assert(sizeof(AddTargetData) == 0x50);
77
78 virtual ~MagicTarget(); // 00
79
80 // add
81 virtual bool AddTarget(AddTargetData& a_targetData); // 01
82 virtual TESObjectREFR* GetTargetStatsObject(); // 02 - { return false; }
83 [[nodiscard]] virtual bool MagicTargetIsActor() const; // 03 - { return false; }
84 virtual bool IsInvulnerable(); // 04 - { return false; }
85 virtual void InvalidateCommandedActorEffect(ActiveEffect* a_effect); // 05 - { return; }
86 virtual bool CanAddActiveEffect() = 0; // 06
88 virtual void EffectAdded(ActiveEffect* a_effect); // 08 - { return; }
89 virtual void EffectRemoved(ActiveEffect* a_effect); // 09 - { return; }
90 virtual float CheckResistance(MagicItem* a_magicItem, Effect* a_effect, TESBoundObject* a_object); // 0A - { return 1.0; }
91 virtual bool CheckAbsorb(Actor* a_actor, MagicItem* a_magicItem, const Effect* a_effect); // 0B - { return false; }
92
93 bool DispelEffect(MagicItem* a_spell, BSPointerHandle<Actor>& a_caster, ActiveEffect* a_effect = nullptr);
94 void DispelEffectsWithArchetype(Archetype a_type, bool a_force);
98 bool HasMagicEffectWithKeyword(BGSKeyword* a_keyword, std::uint64_t a_arg2);
100
101#ifdef SKYRIMVR
102 //VR requires a visitor to access all items
103 class GetEffectCount : public MagicTarget::ForEachActiveEffectVisitor
104 {
105 public:
106 GetEffectCount() :
107 m_count(0) {}
108
109 virtual BSContainer::ForEachResult Accept(ActiveEffect* /*effect*/) override // suppress c4100 error
110 {
111 m_count++;
112 return BSContainer::ForEachResult::kContinue;
113 }
114
115 std::uint32_t GetCount() const { return m_count; }
116
117 private:
118 std::uint32_t m_count;
119 };
120
121 class GetNthEffect : public MagicTarget::ForEachActiveEffectVisitor
122 {
123 public:
124 GetNthEffect(std::uint32_t n) :
125 m_result(nullptr), m_n(n), m_count(0) {}
126
127 virtual BSContainer::ForEachResult Accept(ActiveEffect* effect) override
128 {
129 if (m_count == m_n) {
130 m_result = effect;
131 return BSContainer::ForEachResult::kContinue;
132 }
133 m_count++;
134 return BSContainer::ForEachResult::kStop;
135 }
136
137 ActiveEffect* GetResult() { return m_result; }
138
139 private:
140 ActiveEffect* m_result;
141 std::uint32_t m_n;
142 std::uint32_t m_count;
143 };
144
145 class EffectVisitor : public MagicTarget::ForEachActiveEffectVisitor
146 {
147 public:
148 EffectVisitor(std::function<BSContainer::ForEachResult(ActiveEffect*)> func) :
149 m_functor(func) {}
150
151 virtual BSContainer::ForEachResult Accept(ActiveEffect* effect) override
152 {
153 return m_functor(effect);
154 }
155
156 protected:
157 std::function<BSContainer::ForEachResult(ActiveEffect*)> m_functor;
158 };
159
160 void VisitActiveEffects(std::function<BSContainer::ForEachResult(ActiveEffect*)> func)
161 {
162 EffectVisitor visitor(func);
163 ForEachActiveEffect(visitor);
164 }
165
166 void ForEachActiveEffect(MagicTarget::ForEachActiveEffectVisitor& visitor)
167 {
168 using func_t = decltype(&MagicTarget::ForEachActiveEffect);
169 static REL::Relocation<func_t> func{ REL::ID(33756) };
170 func(this, visitor);
171 }
172#endif
173
174 // members
176 std::uint8_t flags; // 10
177 std::uint8_t pad11; // 11
178 std::uint16_t pad12; // 12
179 std::uint32_t pad14; // 14
180 private:
182 };
183 static_assert(sizeof(MagicTarget) == 0x18);
184}
#define KEEP_FOR_RE()
Definition PCH.h:517
Definition ID.h:427
Definition Relocation.h:210
Definition ActiveEffect.h:27
Definition Actor.h:133
Definition BGSKeyword.h:10
Definition BSPointerHandle.h:91
Definition BSTList.h:10
Definition BSTSmartPointer.h:37
Definition EffectSetting.h:24
Definition MagicItem.h:30
virtual ~ForEachActiveEffectVisitor()
Definition MagicTarget.h:42
virtual BSContainer::ForEachResult Accept(ActiveEffect *a_effect)=0
static constexpr auto VTABLE
Definition MagicTarget.h:40
static constexpr auto RTTI
Definition MagicTarget.h:39
Definition MagicTarget.h:29
SpellDispelData * postUpdateDispelList
Definition MagicTarget.h:175
virtual TESObjectREFR * GetTargetStatsObject()
virtual bool CanAddActiveEffect()=0
virtual float CheckResistance(MagicItem *a_magicItem, Effect *a_effect, TESBoundObject *a_object)
bool HasMagicEffect(EffectSetting *a_effect)
std::uint16_t pad12
Definition MagicTarget.h:178
virtual void InvalidateCommandedActorEffect(ActiveEffect *a_effect)
void VisitEffects(ForEachActiveEffectVisitor &visitor)
virtual ~MagicTarget()
virtual bool CheckAbsorb(Actor *a_actor, MagicItem *a_magicItem, const Effect *a_effect)
std::uint8_t pad11
Definition MagicTarget.h:177
bool DispelEffect(MagicItem *a_spell, BSPointerHandle< Actor > &a_caster, ActiveEffect *a_effect=nullptr)
virtual bool AddTarget(AddTargetData &a_targetData)
bool HasEffectWithArchetype(Archetype a_type)
Actor * GetTargetAsActor()
virtual bool IsInvulnerable()
void DispelEffectsWithArchetype(Archetype a_type, bool a_force)
virtual BSSimpleList< ActiveEffect * > * GetActiveEffectList()=0
bool HasMagicEffectWithKeyword(BGSKeyword *a_keyword, std::uint64_t a_arg2)
virtual bool MagicTargetIsActor() const
std::uint32_t pad14
Definition MagicTarget.h:179
std::uint8_t flags
Definition MagicTarget.h:176
static constexpr auto VTABLE
Definition MagicTarget.h:32
virtual void EffectRemoved(ActiveEffect *a_effect)
virtual void EffectAdded(ActiveEffect *a_effect)
static constexpr auto RTTI
Definition MagicTarget.h:31
Definition NiPoint3.h:6
Definition TESBoundObject.h:26
Definition TESObjectREFR.h:114
ForEachResult
Definition BSContainer.h:6
CastingSource
Definition MagicSystem.h:27
Definition AbsorbEffect.h:6
constexpr std::array< REL::ID, 1 > VTABLE_MagicTarget__ForEachActiveEffectVisitor
Definition Offsets_VTABLE.h:11986
constexpr REL::ID RTTI_MagicTarget__ForEachActiveEffectVisitor(static_cast< std::uint64_t >(685330))
constexpr REL::ID RTTI_MagicTarget(static_cast< std::uint64_t >(513884))
constexpr std::array< REL::ID, 1 > VTABLE_MagicTarget
Definition Offsets_VTABLE.h:11984
ArchetypeID
Definition EffectArchetypes.h:8
Definition Effect.h:11
Definition MagicTarget.h:60
MagicSystem::CastingSource castingSource
Definition MagicTarget.h:70
TESBoundObject * source
Definition MagicTarget.h:64
MagicItem * magicItem
Definition MagicTarget.h:62
std::uint16_t pad4A
Definition MagicTarget.h:73
float magnitude
Definition MagicTarget.h:68
Effect * effect
Definition MagicTarget.h:63
std::uint8_t unk48
Definition MagicTarget.h:71
TESObjectREFR * caster
Definition MagicTarget.h:61
bool dualCasted
Definition MagicTarget.h:72
std::uint64_t unk20
Definition MagicTarget.h:65
NiPoint3 explosionPoint
Definition MagicTarget.h:67
float unk40
Definition MagicTarget.h:69
std::uint64_t unk28
Definition MagicTarget.h:66
std::uint32_t pad4C
Definition MagicTarget.h:74
Definition MagicTarget.h:50
std::uint32_t pad0C
Definition MagicTarget.h:53
SpellDispelData * next
Definition MagicTarget.h:55
MagicItem * spell
Definition MagicTarget.h:51
BSPointerHandle< Actor > caster
Definition MagicTarget.h:52
BSTSmartPointer< ActiveEffect > activeEffect
Definition MagicTarget.h:54