CommonLibSSE NG
SpellItem.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/B/BGSEquipType.h"
5 #include "RE/F/FormTypes.h"
6 #include "RE/M/MagicItem.h"
7 #include "RE/T/TESDescription.h"
8 
9 namespace RE
10 {
11  class SpellItem :
12  public MagicItem, // 00
13  public BGSEquipType, // 90
14  public BGSMenuDisplayObject, // A0
15  public TESDescription // B0
16  {
17  public:
18  inline static constexpr auto RTTI = RTTI_SpellItem;
19  inline static constexpr auto VTABLE = VTABLE_SpellItem;
20  inline static constexpr auto FORMTYPE = FormType::Spell;
21 
22  enum class SpellFlag
23  {
24  kNone = 0,
25  kCostOverride = 1 << 0,
26  kFoodItem = 1 << 1,
27  kExtendDuration = 1 << 3,
28  kPCStartSpell = 1 << 17,
29  kInstantCast = 1 << 18,
30  kIgnoreLOSCheck = 1 << 19,
31  kIgnoreResistance = 1 << 20,
32  kNoAbsorb = 1 << 21,
33  kNoDualCastMods = 1 << 23
34  };
35 
36  struct RecordFlags
37  {
38  enum RecordFlag : std::uint32_t
39  {
40  kDeleted = 1 << 5,
41  kIgnored = 1 << 12
42  };
43  };
44 
45  class Data // SPIT
46  {
47  public:
48  // members
49  std::int32_t costOverride; // 00
52  float chargeTime; // 0C
55  float castDuration; // 18
56  float range; // 1C
58  };
59  static_assert(sizeof(Data) == 0x28);
60 
61  ~SpellItem() override; // 00
62 
63  // override (MagicItem)
64  void InitializeData() override; // 04
65  void ClearData() override; // 05
66  void InitItemImpl() override; // 13
67  [[nodiscard]] MagicSystem::SpellType GetSpellType() const override; // 53 - { return data.spellType; }
68  void SetCastingType(MagicSystem::CastingType a_type) override; // 54 - { data.castingType = a_type; }
69  [[nodiscard]] MagicSystem::CastingType GetCastingType() const override; // 55 - { return data.castingType; }
70  void SetDelivery(MagicSystem::Delivery a_type) override; // 56 - { if (Unk_58()) { data.delivery = a_type; } }
71  [[nodiscard]] MagicSystem::Delivery GetDelivery() const override; // 57 - { return data.delivery; }
72  [[nodiscard]] float GetFixedCastDuration() const override; // 59 - { return (GetCastingType() == MagicSystem::CastingType::kConcentration) ? data.castDuration : 0.0; }
73  [[nodiscard]] float GetRange() const override; // 5A - { return data.range; }
74  [[nodiscard]] bool IgnoresResistance() const override; // 5B - { return (GetData()->flags >> 20) & 1; }
75  [[nodiscard]] bool IgnoreLOS() const override; // 5C - { return (GetData()->flags >> 19) & 1; }
76  [[nodiscard]] bool GetNoAbsorb() const override; // 5E - { return (GetData()->flags >> 21) & 1; }
77  [[nodiscard]] bool GetNoDualCastModifications() const override; // 5F - { return (GetData()->flags >> 23) & 1; }
78  bool GetSkillUsageData(SkillUsageData& a_data) const override; // 60
79  void AdjustCost(float& a_cost, Actor* a_actor) const override; // 63
80  [[nodiscard]] float GetChargeTime() const override; // 64
81  [[nodiscard]] ActorValue GetAssociatedSkill() const override; // 66
82  [[nodiscard]] bool IsTwoHanded() const override; // 67 - { BGSEquipSlot* equipSlot = BGSEquipType::GetEquipSlot(); return equipSlot && equipSlot->flags & 1; }
83  [[nodiscard]] std::uint32_t GetChunkID() override; // 68 - { return 'SPIT'; }
84  void CopyMagicItemData(MagicItem* a_src) override; // 69
85  void LoadMagicItemChunk(TESFile* a_mod, std::uint32_t a_chunkID) override; // 6A
86  void LoadChunkDataPostProcess(TESFile* a_mod) override; // 6B
87  [[nodiscard]] const MagicItem::Data* GetData1() const override; // 6C - { return &data; }
88  [[nodiscard]] MagicItem::Data* GetData2() override; // 6D - { return &data; }
89  [[nodiscard]] std::uint32_t GetDataSize() const override; // 6E - { return 0x28; }
90  void InitFromChunk(TESFile* a_mod) override; // 6F
91  void InitChunk() override; // 70
92 
93  // override (BGSMenuDisplayObject)
94  [[nodiscard]] TESBoundObject* GetMenuDisplayObject() const override; // 04 - { return menuDispObject; }
95 
96  // members
97  Data data; // C0 - SPIT
98  };
99  static_assert(sizeof(SpellItem) == 0xE8);
100 }
Definition: Actor.h:135
Definition: BGSEquipType.h:9
Definition: BGSMenuDisplayObject.h:10
Definition: BGSPerk.h:31
Definition: MagicItem.h:58
Definition: MagicItem.h:30
Definition: SpellItem.h:46
MagicSystem::CastingType castingType
Definition: SpellItem.h:53
float range
Definition: SpellItem.h:56
MagicSystem::Delivery delivery
Definition: SpellItem.h:54
float chargeTime
Definition: SpellItem.h:52
std::int32_t costOverride
Definition: SpellItem.h:49
BGSPerk * castingPerk
Definition: SpellItem.h:57
float castDuration
Definition: SpellItem.h:55
stl::enumeration< SpellFlag, std::uint32_t > flags
Definition: SpellItem.h:50
MagicSystem::SpellType spellType
Definition: SpellItem.h:51
Definition: SpellItem.h:16
bool GetSkillUsageData(SkillUsageData &a_data) const override
bool IgnoreLOS() const override
bool GetNoAbsorb() const override
MagicSystem::SpellType GetSpellType() const override
void LoadMagicItemChunk(TESFile *a_mod, std::uint32_t a_chunkID) override
static constexpr auto RTTI
Definition: SpellItem.h:18
bool IgnoresResistance() const override
static constexpr auto FORMTYPE
Definition: SpellItem.h:20
void LoadChunkDataPostProcess(TESFile *a_mod) override
void InitItemImpl() override
TESBoundObject * GetMenuDisplayObject() const override
ActorValue GetAssociatedSkill() const override
MagicSystem::Delivery GetDelivery() const override
void InitFromChunk(TESFile *a_mod) override
MagicItem::Data * GetData2() override
const MagicItem::Data * GetData1() const override
MagicSystem::CastingType GetCastingType() const override
float GetRange() const override
~SpellItem() override
static constexpr auto VTABLE
Definition: SpellItem.h:19
float GetChargeTime() const override
void InitializeData() override
Data data
Definition: SpellItem.h:97
bool GetNoDualCastModifications() const override
void ClearData() override
void InitChunk() override
void SetCastingType(MagicSystem::CastingType a_type) override
void SetDelivery(MagicSystem::Delivery a_type) override
std::uint32_t GetChunkID() override
void AdjustCost(float &a_cost, Actor *a_actor) const override
void CopyMagicItemData(MagicItem *a_src) override
bool IsTwoHanded() const override
SpellFlag
Definition: SpellItem.h:23
float GetFixedCastDuration() const override
std::uint32_t GetDataSize() const override
Definition: TESBoundObject.h:24
Definition: TESDescription.h:12
Definition: TESFile.h:17
SpellType
Definition: MagicSystem.h:61
CastingType
Definition: MagicSystem.h:32
Delivery
Definition: MagicSystem.h:40
Definition: AbsorbEffect.h:6
constexpr REL::VariantID RTTI_SpellItem(513849, 392217, 0x1ed6d40)
ActorValue
Definition: ActorValues.h:6
constexpr std::array< REL::VariantID, 6 > VTABLE_SpellItem
Definition: Offsets_VTABLE.h:61
Definition: MagicItem.h:44
Definition: SpellItem.h:37
RecordFlag
Definition: SpellItem.h:39
@ kDeleted
Definition: SpellItem.h:40
@ kIgnored
Definition: SpellItem.h:41