CommonLibVR
MagicItem.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/A/ActorValues.h"
4 #include "RE/B/BGSKeywordForm.h"
5 #include "RE/B/BSTArray.h"
6 #include "RE/B/BSTSmartPointer.h"
10 #include "RE/M/MagicSystem.h"
11 #include "RE/T/TESBoundObject.h"
12 #include "RE/T/TESFullName.h"
13 
14 namespace RE
15 {
16  class Actor;
17  class ActorValueInfo;
18  class Character;
19  class EffectItem;
20  class EffectSetting;
21  class QueuedFile;
22  class TESModel;
23  class TESObjectWEAP;
24  struct Effect;
25 
26  class MagicItem :
27  public TESBoundObject, // 00
28  public TESFullName, // 30
29  public BGSKeywordForm // 40
30  {
31  public:
32  inline static constexpr auto RTTI = RTTI_MagicItem;
33  inline static constexpr auto VTABLE = VTABLE_MagicItem;
34 
36  {
37  public:
38  // add
39  virtual void VisitModel(TESModel* a_model) = 0; // 00
40  virtual void VisitWeapon(TESObjectWEAP* a_weapon) = 0; // 01
41  };
42  static_assert(sizeof(PreloadableVisitor) == 0x8);
43 
45  {
46  public:
47  // members
48  EffectItem* effect; // 00
50  float magnitude; // 0C
51  bool custom; // 10
52  std::uint8_t pad11; // 11
53  std::uint16_t pad12; // 12
54  std::uint32_t pad14; // 14
55  };
56  static_assert(sizeof(SkillUsageData) == 0x18);
57 
58  class Data
59  {
60  public:
61  // members
62  std::int32_t costOverride; // 0
63  std::uint32_t flags; // 4
64  };
65  static_assert(sizeof(Data) == 0x8);
66 
67  ~MagicItem() override; // 00
68 
69  // override (TESBoundObject)
70  void InitializeData() override; // 04 - { TESForm::InitDefaults(); }
71  bool Load(TESFile* a_mod) override; // 06
72  void InitItemImpl() override; // 13
73  bool IsMagicItem() const override; // 29 - { return true; }
74  void Copy(TESForm* a_srcForm) override; // 2F
75  bool IsAutoCalc() const override; // 3E - { return (GetData().flags & 1) == 0; }
76 
77  // override (BGSKeywordForm)
78  bool HasKeyword(const BGSKeyword* a_keyword) const override; // 04
79 
80  // add
81  [[nodiscard]] virtual MagicSystem::SpellType GetSpellType() const = 0; // 53
82  virtual void SetCastingType(MagicSystem::CastingType a_type); // 54 - { return; }
83  [[nodiscard]] virtual MagicSystem::CastingType GetCastingType() const = 0; // 55
84  virtual void SetDelivery(MagicSystem::Delivery a_delivery); // 56 - { return; }
85  [[nodiscard]] virtual MagicSystem::Delivery GetDelivery() const = 0; // 57
86  virtual bool IsValidDelivery(MagicSystem::Delivery a_delivery); // 58 - { return true; }
87  [[nodiscard]] virtual float GetFixedCastDuration() const; // 59 - { return 0.0; }
88  [[nodiscard]] virtual float GetRange() const; // 5A - { return 0.0; }
89  [[nodiscard]] virtual bool IgnoresResistance() const; // 5B - { return false; }
90  [[nodiscard]] virtual bool IgnoreLOS() const; // 5C - { return false; }
91  [[nodiscard]] virtual bool IsFood() const; // 5D - { return false; }
92  [[nodiscard]] virtual bool GetNoAbsorb() const; // 5E - { return false; }
93  [[nodiscard]] virtual bool GetNoDualCastModifications() const; // 5F - { return false; }
94  virtual bool GetSkillUsageData(SkillUsageData& a_data) const; // 60 - { return false; }
95  [[nodiscard]] virtual bool IsPoison() const; // 61 - { return GetSpellType() == MagicSystem::SpellType::kPoison; }
96  [[nodiscard]] virtual bool IsMedicine() const; // 62 - { return false; }
97  virtual void AdjustCost(float& a_cost, Actor* a_actor) const; // 63 - { return; }
98  [[nodiscard]] virtual float GetChargeTime() const; // 64 - { return 0.0; }
99  [[nodiscard]] virtual std::uint32_t GetMaxEffectCount() const; // 65 - { return 0; }
100  [[nodiscard]] virtual ActorValue GetAssociatedSkill() const; // 66 - { return ActorValue::kNone; }
101  [[nodiscard]] virtual bool IsTwoHanded() const; // 67 - { return false; }
102  virtual std::uint32_t GetChunkID() = 0; // 68
103  virtual void CopyMagicItemData(MagicItem* a_src) = 0; // 69
104  virtual void LoadMagicItemChunk(TESFile* a_mod, std::uint32_t a_chunkID); // 6A - { return; }
105  virtual void LoadChunkDataPostProcess(TESFile* a_mod); // 6B - { return; }
106  [[nodiscard]] virtual const Data* GetData1() const = 0; // 6C
107  virtual Data* GetData2() = 0; // 6D
108  [[nodiscard]] virtual std::uint32_t GetDataSize() const = 0; // 6E
109  virtual void InitFromChunk(TESFile* a_mod) = 0; // 6F
110  virtual void InitChunk() = 0; // 70
111 
112  [[nodiscard]] float CalculateMagickaCost(Actor* a_caster) const;
113  [[nodiscard]] float CalculateTotalGoldValue(Actor* a_caster = nullptr) const;
114  [[nodiscard]] MagicItemDataCollector CollectData() const;
115  [[nodiscard]] EffectSetting* GetAVEffect() const;
116  [[nodiscard]] Effect* GetCostliestEffectItem(MagicSystem::Delivery a_delivery = MagicSystem::Delivery::kTotal, bool a_positiveArea = false) const;
117  [[nodiscard]] Data* GetData();
118  [[nodiscard]] const Data* GetData() const;
119  [[nodiscard]] std::int32_t GetLargestArea() const;
120  [[nodiscard]] std::uint32_t GetLongestDuration() const;
121  [[nodiscard]] bool HasEffect(EffectArchetype a_archetype);
122  [[nodiscard]] bool IsHostile() const;
123  [[nodiscard]] bool IsPermanent() const;
124  [[nodiscard]] Effect* GetEffectIsMatch(EffectSetting* a_base, float a_mag, ::uint32_t a_area, ::uint32_t a_dur, float a_cost);
125  void Traverse(MagicItemTraversalFunctor& a_visitor) const;
126 
127  // members
129  std::int32_t hostileCount; // 70
130  std::uint32_t pad74; // 74
132  std::uint32_t preloadCount; // 80
133  std::uint32_t pad84; // 84
135 
136  protected:
137  float CalculateCost(Actor* a_caster) const;
138 
139  private:
140  KEEP_FOR_RE()
141  };
142  static_assert(sizeof(MagicItem) == 0x90);
143 }
#define KEEP_FOR_RE()
Definition: PCH.h:713
Definition: Actor.h:133
Definition: BGSKeywordForm.h:12
Definition: BGSKeyword.h:10
Definition: BSTArray.h:378
Definition: EffectSetting.h:24
Definition: MagicItemDataCollector.h:11
Definition: MagicItemTraversalFunctor.h:10
Definition: MagicItem.h:59
std::uint32_t flags
Definition: MagicItem.h:63
std::int32_t costOverride
Definition: MagicItem.h:62
Definition: MagicItem.h:36
virtual void VisitModel(TESModel *a_model)=0
virtual void VisitWeapon(TESObjectWEAP *a_weapon)=0
Definition: MagicItem.h:30
virtual void LoadChunkDataPostProcess(TESFile *a_mod)
virtual bool IsMedicine() const
virtual bool GetNoDualCastModifications() const
virtual bool IgnoresResistance() const
float CalculateTotalGoldValue(Actor *a_caster=nullptr) const
bool IsPermanent() const
bool HasEffect(EffectArchetype a_archetype)
virtual void CopyMagicItemData(MagicItem *a_src)=0
void Copy(TESForm *a_srcForm) override
std::uint32_t pad74
Definition: MagicItem.h:130
virtual bool GetNoAbsorb() const
virtual bool IsFood() const
bool IsMagicItem() const override
EffectSetting * avEffectSetting
Definition: MagicItem.h:131
void InitItemImpl() override
Data * GetData()
virtual bool IsValidDelivery(MagicSystem::Delivery a_delivery)
virtual void LoadMagicItemChunk(TESFile *a_mod, std::uint32_t a_chunkID)
std::int32_t GetLargestArea() const
virtual Data * GetData2()=0
virtual float GetChargeTime() const
virtual void AdjustCost(float &a_cost, Actor *a_actor) const
BSTSmartPointer< QueuedFile > preloadedItem
Definition: MagicItem.h:134
virtual float GetRange() const
virtual void InitFromChunk(TESFile *a_mod)=0
std::int32_t hostileCount
Definition: MagicItem.h:129
virtual ActorValue GetAssociatedSkill() const
bool HasKeyword(const BGSKeyword *a_keyword) const override
static constexpr auto VTABLE
Definition: MagicItem.h:33
virtual std::uint32_t GetMaxEffectCount() const
EffectSetting * GetAVEffect() const
static constexpr auto RTTI
Definition: MagicItem.h:32
std::uint32_t preloadCount
Definition: MagicItem.h:132
virtual void SetCastingType(MagicSystem::CastingType a_type)
bool Load(TESFile *a_mod) override
MagicItemDataCollector CollectData() const
virtual void InitChunk()=0
virtual bool GetSkillUsageData(SkillUsageData &a_data) const
virtual float GetFixedCastDuration() const
virtual MagicSystem::Delivery GetDelivery() const =0
void InitializeData() override
virtual MagicSystem::SpellType GetSpellType() const =0
void Traverse(MagicItemTraversalFunctor &a_visitor) const
bool IsAutoCalc() const override
std::uint32_t GetLongestDuration() const
bool IsHostile() const
const Data * GetData() const
virtual void SetDelivery(MagicSystem::Delivery a_delivery)
virtual MagicSystem::CastingType GetCastingType() const =0
std::uint32_t pad84
Definition: MagicItem.h:133
virtual const Data * GetData1() const =0
BSTArray< Effect * > effects
Definition: MagicItem.h:128
virtual bool IgnoreLOS() const
float CalculateCost(Actor *a_caster) const
virtual bool IsPoison() const
Effect * GetCostliestEffectItem(MagicSystem::Delivery a_delivery=MagicSystem::Delivery::kTotal, bool a_positiveArea=false) const
~MagicItem() override
virtual std::uint32_t GetChunkID()=0
Effect * GetEffectIsMatch(EffectSetting *a_base, float a_mag, ::uint32_t a_area, ::uint32_t a_dur, float a_cost)
virtual std::uint32_t GetDataSize() const =0
float CalculateMagickaCost(Actor *a_caster) const
virtual bool IsTwoHanded() const
Definition: TESBoundObject.h:26
Definition: TESFile.h:17
Definition: TESForm.h:40
Definition: TESFullName.h:9
Definition: TESModel.h:16
Definition: TESObjectWEAP.h:79
SpellType
Definition: MagicSystem.h:64
CastingType
Definition: MagicSystem.h:35
Delivery
Definition: MagicSystem.h:43
Definition: AbsorbEffect.h:6
constexpr std::array< REL::ID, 3 > VTABLE_MagicItem
Definition: Offsets_VTABLE.h:11976
constexpr REL::ID RTTI_MagicItem(static_cast< std::uint64_t >(513851))
ActorValue
Definition: ActorValues.h:6
ArchetypeID
Definition: EffectArchetypes.h:8
Definition: Effect.h:11
Definition: MagicItem.h:45
std::uint32_t pad14
Definition: MagicItem.h:54
bool custom
Definition: MagicItem.h:51
std::uint8_t pad11
Definition: MagicItem.h:52
float magnitude
Definition: MagicItem.h:50
std::uint16_t pad12
Definition: MagicItem.h:53
EffectItem * effect
Definition: MagicItem.h:48
ActorValue skill
Definition: MagicItem.h:49