CommonLibVR
Projectile.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/B/BGSProjectile.h"
4 #include "RE/B/BSAtomic.h"
5 #include "RE/B/BSPointerHandle.h"
7 #include "RE/B/BSSoundHandle.h"
8 #include "RE/B/BSTList.h"
9 #include "RE/B/BSTSingleton.h"
10 #include "RE/C/CollisionLayers.h"
11 #include "RE/F/FormTypes.h"
12 #include "RE/I/ImpactResults.h"
13 #include "RE/N/NiSmartPointer.h"
14 #include "RE/N/NiTransform.h"
15 #include "RE/T/TESObjectREFR.h"
16 
17 namespace RE
18 {
19  class Actor;
20  class bhkCollisionObject;
21  class bhkShape;
22  class bhkSimpleShapePhantom;
23  class BGSMaterialType;
24  class BSLight;
25  class CombatController;
26  class MagicItem;
27  class QueuedFile;
28 
29  class Projectile : public TESObjectREFR
30  {
31  public:
32  inline static constexpr auto RTTI = RTTI_Projectile;
33  inline static constexpr auto VTABLE = VTABLE_Projectile;
34 
36  {
37  public:
38  // members
41  float wobble; // 28
42  };
43  static_assert(sizeof(WobbleControl) == 0x2C);
44 
45  class Manager : public BSTSingletonSDM<Manager>
46  {
47  public:
48  static Manager* GetSingleton();
49 
50  // members
54  mutable BSSpinLock projectileLock; // 50
56  };
57 
59  {
60  public:
61  // members
62  float x;
63  float z;
64  };
65  static_assert(sizeof(ProjectileRot) == 0x08);
66 
67  struct LaunchData
68  {
69  public:
70  inline static constexpr auto RTTI = RTTI_Projectile__LaunchData;
71  inline static constexpr auto VTABLE = VTABLE_Projectile__LaunchData;
72 
73  virtual ~LaunchData() = default;
74 
75  LaunchData() = default;
76  LaunchData(BGSProjectile* a_bproj, Actor* a_shooter, const NiPoint3& a_origin, const ProjectileRot& a_angles);
77  LaunchData(Actor* a_shooter, const NiPoint3& a_origin, const ProjectileRot& a_angles, MagicItem* a_spell);
78  LaunchData(Actor* a_shooter, const NiPoint3& a_origin, const ProjectileRot& a_angles, TESAmmo* a_ammo, TESObjectWEAP* a_weap);
79 
80  // members
88  float angleZ; // 48
89  float angleX; // 4C
90  void* unk50; // 50 - maps to Projectile unk110
92  float unk60; // 60 - maps to Projectile unk1A8
93  float unk64; // 64 - maps to Projectile unk1AC
95  MagicItem* spell; // 70
97  std::uint32_t pad7C; // 7C
100  std::int32_t area; // 90
101  float power; // 94
102  float scale; // 98
103  bool alwaysHit; // 9C
105  bool autoAim; // 9E
106  bool chainShatter; // 9F
107  bool useOrigin; // A0
109  bool forceConeOfFire; // A2
110  };
111  static_assert(sizeof(LaunchData) == 0xA8);
112 
113  struct ImpactData
114  {
115  public:
116  // members
122  std::int32_t damageRootNodeType; // 30
126  std::uint16_t unk44; // 44
127  std::uint16_t unk46; // 46
128  std::uint8_t unk48; // 48
129  std::uint8_t unk49; // 49
130  };
131  static_assert(sizeof(ImpactData) == 0x50);
132 
133  enum class Flags
134  {
135  kNone = 0,
136  kUnk0 = 1 << 0,
137  kNotAddThreat = 1 << 1,
138  kUnk2 = 1 << 2,
139  kUnk3 = 1 << 3,
140  kIsTracer = 1 << 4,
141  kFading = 1 << 5,
142  kGravityUpdateModel = 1 << 6,
143  kUnk7 = 1 << 7,
144  kInited = 1 << 8,
145  kChainShatter = 1 << 9,
146  kUnk10 = 1 << 10,
147  kUnk11 = 1 << 11,
148  kAlwaysHit = 1 << 12,
149  kHitScan = 1 << 13,
150  kUnk14 = 1 << 14,
151  kDestroyAfterHit = 1 << 15,
152  kAddedToManager = 1 << 16,
153  kNoDamageOutsideCombat = 1 << 17,
154  kCanStartTrails = 1 << 18,
155  kAggressiveActor = 1 << 19,
156  kAddedVisualEffectOnGround = 1 << 20,
157  kAutoAim = 1 << 21,
158  kProcessedImpacts = 1 << 22,
159  kUnk23 = 1 << 23,
160  kUnk24 = 1 << 24,
161  kDestroyed = 1 << 25,
162  kUnk26 = 1 << 26,
163  kUnk27 = 1 << 27,
164  kIsDual = 1 << 28,
165  kUseOrigin = 1 << 29,
166  kUnk30 = 1 << 30,
167  kMoved = 1 << 31
168  };
169 
170  ~Projectile() override; // 00
171 
172  // override (TESObjectREFR)
173  bool Load(TESFile* a_mod) override; // 06 - { return TESObjectREFR::Load(a_mod); }
174  void SaveGame(BGSSaveFormBuffer* a_buf) override; // 0E
175  void LoadGame(BGSLoadFormBuffer* a_buf) override; // 0F
176  void InitLoadGame(BGSLoadFormBuffer* a_buf) override; // 10
177  void FinishLoadGame(BGSLoadFormBuffer* a_buf) override; // 11
178  void Revert(BGSLoadFormBuffer* a_buf) override; // 12
179  bool GetAllowPromoteToPersistent() const override; // 47 - { return false; }
180  bool HasKeywordHelper(const BGSKeyword* a_keyword) const override; // 48
181  void SetActorCause(ActorCause* a_cause) override; // 50 - { actorCause = a_cause; }
182  ActorCause* GetActorCause() const override; // 51 - { return actorCause; }
184  bool DetachHavok(NiAVObject* a_obj3D) override; // 65
185  void InitHavok() override; // 66
186  NiAVObject* Load3D(bool a_backgroundLoading) override; // 6A
187  void Set3D(NiAVObject* a_object, bool a_queue3DTasks = true) override; // 6C
188  void MoveHavok(bool a_forceRec) override; // 85 - { return; }
189  void GetLinearVelocity(NiPoint3& a_velocity) const override; // 86
190 #ifndef SKYRIMVR
191  NiNode* GetFireNode() override; // 8B
192  Projectile* AsProjectile() override; // 8F - { return this; }
193  bool OnAddCellPerformQueueReference(TESObjectCELL& a_cell) const override; // 90 - { return false; }
194 #else
195  NiNode* GetFireNode() override; // 8C
196  Projectile* AsProjectile() override; // 90 - { return this; }
197  bool OnAddCellPerformQueueReference(TESObjectCELL& a_cell) const override; // 91 - { return false; }
198 #endif
199  // add
200  virtual bool IsMissileProjectile(); // A2 - { return 0; }
201  virtual bool IsGrenadeProjectile(); // A3 - { return 0; }
202  virtual bool IsFlameProjectile(); // A4 - { return 0; }
203  virtual bool IsBeamProjectile(); // A5 - { return 0; }
204  virtual void Unk_A6(void); // A6 - { return 0; }
205  virtual bool IsBarrierProjectile(); // A7 - { return 0; }
206  virtual void OnKill(); // A8 - { return; }
207  virtual void Process3D(); // A9 - { return; }
208  virtual void PostLoad3D(NiAVObject* a_root); // AA
209  virtual void UpdateImpl(float a_delta) = 0; // AB
210  virtual bool ProcessImpacts(); // AC
211  virtual void Update3D(); // AD
212  virtual void Unk_AE(void); // AE - { return 0; }
213  virtual float GetPowerSpeedMult() const; // AF - { if (unk158) return 1.0; else return unk188; } - "float GetSpeed()"?
214  virtual float GetWeaponSpeedMult() const; // B0 - { return 1.0; }
215  virtual bool GetStopMainSoundAfterImpact(); // B1 - { return 0; }
216  virtual void ReportHavokDeactivation(); // B2 - { return; }
217  virtual bool TurnOff(Actor* a_owner, bool a_noDeactivateSound); // B3
218  virtual bool IsPermanent() const; // B4 - { return TESDataHandler::GetSingleton()->IsGeneratedFormID(formID) == 0; }
219  virtual float GetGravity(); // B5 - { void* var = unk40; if ((var->unk80 >> 17) & 1) return 1.0; else return var->unk84; }
220  virtual void CleanUpPointersOnDisable(); // B6
221  virtual bool RunTargetPick(); // B7
222  virtual bool GetKillOnCollision(); // B8 - { return 1; }
223  virtual bool ShouldBeLimited(); // B9 - { return 0; }
224  virtual bool TargetsWholeBody(); // BA - { return 0; }
225  virtual std::uint32_t GetCollisionGroup(); // BB
226  virtual bhkShape* GetCollisionShape(); // BC
227  virtual void AddImpact(TESObjectREFR* a_ref, const NiPoint3& a_targetLoc, const NiPoint3& a_velocity, hkpCollidable* a_collidable, std::int32_t a_arg6, std::uint32_t a_arg7); // BD
228  virtual bool HandleHits(hkpCollidable* a_collidable); // BE
229  virtual void OnTriggerEnter(); // BF - { return; }
230  virtual void Handle3DLoaded(); // C0 - { return; }
231  virtual bool ShouldUseDesiredTarget(); // C1 - { return 0; }
232 
234  float GetHeight() const;
235  float GetSpeed() const;
236 
237  static ProjectileHandle* Launch(ProjectileHandle* a_result, LaunchData& a_data) noexcept;
238  static ProjectileHandle* LaunchSpell(ProjectileHandle* a_result, Actor* a_shooter, SpellItem* a_spell, const NiPoint3& a_origin, const ProjectileRot& a_angles) noexcept;
239  static ProjectileHandle* LaunchSpell(ProjectileHandle* a_result, Actor* a_shooter, SpellItem* a_spell, MagicSystem::CastingSource a_source) noexcept;
240  static ProjectileHandle* LaunchArrow(ProjectileHandle* a_result, Actor* a_shooter, TESAmmo* a_ammo, TESObjectWEAP* a_weap, const NiPoint3& a_origin, const ProjectileRot& a_angles) noexcept;
241  static ProjectileHandle* LaunchArrow(ProjectileHandle* a_result, Actor* a_shooter, TESAmmo* a_ammo, TESObjectWEAP* a_weap) noexcept;
242 
243  // members
246  float unk0DC; // 0DC
247  bhkSimpleShapePhantom* unk0E0; // 0E0 - smart ptr
248  mutable BSSpinLock unk0E8; // 0E8
251  NiPointer<BSLight> light; // 108 - smart ptr
252  void* unk110; // 110 - smart ptr
258  std::uint32_t* unk140; // 140
261  MagicItem* spell; // 158
263  std::uint32_t pad164; // 164
267  std::uint64_t unk180; // 180
268  float power; // 188
269  float speedMult; // 18C
270  float range; // 190
271  float livingTime; // 194
272  float weaponDamage; // 198
273  float transparency; // 19C - for beam disappearing
274  float explosionTimer; // 1A0
275  std::uint32_t unk1A4; // 1A4
276  float unk1A8; // 1A8 - 0.0f
277  float unk1AC; // 1AC - 0.0f
280  float distanceMoved; // 1C0
281  std::uint32_t pad_1C4; // 1C4
282  float scale; // 1C8 - for double cast model scale
284  bool unk1D0; // 1D0
285  bool unk1D1; // 1D0
286  char unk1D2[6]; // 1D2
287  private:
288  KEEP_FOR_RE()
289  };
290 #ifndef SKYRIM_SUPPORT_AE
291  static_assert(sizeof(Projectile) == 0x1D8);
292 #else
293  static_assert(sizeof(Projectile) == 0x1E0);
294 #endif
295 }
#define KEEP_FOR_RE()
Definition: PCH.h:713
Definition: ActorCause.h:9
Definition: Actor.h:133
Definition: AlchemyItem.h:24
Definition: BGSExplosion.h:53
Definition: BGSKeyword.h:10
Definition: BGSLoadFormBuffer.h:11
Definition: BGSMaterialType.h:12
Definition: BGSProjectile.h:79
Definition: BGSSaveFormBuffer.h:8
Definition: BSTList.h:10
Definition: BSAtomic.h:92
Definition: BSTArray.h:378
Definition: CombatController.h:23
Definition: EffectSetting.h:24
Definition: EnchantmentItem.h:10
Definition: InventoryEntryData.h:15
Definition: MagicCaster.h:25
Definition: MagicItem.h:30
Definition: NiAVObject.h:57
Definition: NiMatrix3.h:8
Definition: NiNode.h:12
Definition: NiPoint3.h:6
Definition: NiSmartPointer.h:9
Definition: NiTransform.h:9
Definition: Projectile.h:46
static Manager * GetSingleton()
BSTArray< WobbleControl > wobble
Definition: Projectile.h:55
BSTArray< ProjectileHandle > pending
Definition: Projectile.h:53
BSTArray< ProjectileHandle > limited
Definition: Projectile.h:52
BSTArray< ProjectileHandle > unlimited
Definition: Projectile.h:51
BSSpinLock projectileLock
Definition: Projectile.h:54
Definition: Projectile.h:30
NiPointer< ActorCause > actorCause
Definition: Projectile.h:253
BGSExplosion * explosion
Definition: Projectile.h:260
~Projectile() override
ModelDBHandle muzzleFlashDBHandle
Definition: Projectile.h:266
NiNode * GetFireNode() override
virtual void Handle3DLoaded()
Flags
Definition: Projectile.h:134
virtual float GetPowerSpeedMult() const
NiAVObject * Load3D(bool a_backgroundLoading) override
float GetSpeed() const
ObjectRefHandle shooter
Definition: Projectile.h:254
void InitLoadGame(BGSLoadFormBuffer *a_buf) override
Projectile * AsProjectile() override
float livingTime
Definition: Projectile.h:271
bool GetAllowPromoteToPersistent() const override
NiPointer< QueuedFile > projectileDBFiles
Definition: Projectile.h:265
void * unk110
Definition: Projectile.h:252
ObjectRefHandle desiredTarget
Definition: Projectile.h:255
virtual bool IsBarrierProjectile()
static ProjectileHandle * LaunchSpell(ProjectileHandle *a_result, Actor *a_shooter, SpellItem *a_spell, const NiPoint3 &a_origin, const ProjectileRot &a_angles) noexcept
virtual bool ShouldUseDesiredTarget()
float speedMult
Definition: Projectile.h:269
EffectSetting * avEffect
Definition: Projectile.h:264
void MoveHavok(bool a_forceRec) override
stl::enumeration< Flags, std::uint32_t > flags
Definition: Projectile.h:283
float explosionTimer
Definition: Projectile.h:274
std::uint32_t * unk140
Definition: Projectile.h:258
virtual void ReportHavokDeactivation()
float range
Definition: Projectile.h:270
virtual void PostLoad3D(NiAVObject *a_root)
void LoadGame(BGSLoadFormBuffer *a_buf) override
virtual bool TargetsWholeBody()
virtual float GetWeaponSpeedMult() const
virtual void OnTriggerEnter()
NiPoint3 linearVelocity
Definition: Projectile.h:250
float distanceMoved
Definition: Projectile.h:280
std::uint64_t unk180
Definition: Projectile.h:267
void FinishLoadGame(BGSLoadFormBuffer *a_buf) override
virtual bool GetKillOnCollision()
virtual std::uint32_t GetCollisionGroup()
ActorCause * GetActorCause() const override
float weaponDamage
Definition: Projectile.h:272
static ProjectileHandle * Launch(ProjectileHandle *a_result, LaunchData &a_data) noexcept
virtual float GetGravity()
bool Load(TESFile *a_mod) override
virtual bool TurnOff(Actor *a_owner, bool a_noDeactivateSound)
virtual bool GetStopMainSoundAfterImpact()
void Set3D(NiAVObject *a_object, bool a_queue3DTasks=true) override
virtual void CleanUpPointersOnDisable()
float unk1A8
Definition: Projectile.h:276
virtual bool ProcessImpacts()
std::uint32_t unk1A4
Definition: Projectile.h:275
float transparency
Definition: Projectile.h:273
virtual bool IsGrenadeProjectile()
virtual void Update3D()
std::uint32_t pad164
Definition: Projectile.h:263
virtual void Process3D()
static constexpr auto RTTI
Definition: Projectile.h:32
BSSoundHandle sndCountdown
Definition: Projectile.h:257
BSSimpleList< ImpactData * > impacts
Definition: Projectile.h:244
virtual bool IsPermanent() const
bool unk1D1
Definition: Projectile.h:285
virtual bhkShape * GetCollisionShape()
BGSProjectile * GetProjectileBase() const
void SaveGame(BGSSaveFormBuffer *a_buf) override
virtual bool ShouldBeLimited()
virtual bool IsBeamProjectile()
virtual bool IsMissileProjectile()
char unk1D2[6]
Definition: Projectile.h:286
NiPoint3 velocity
Definition: Projectile.h:249
NiPointer< BSLight > light
Definition: Projectile.h:251
virtual bool HandleHits(hkpCollidable *a_collidable)
BSSpinLock unk0E8
Definition: Projectile.h:248
bool OnAddCellPerformQueueReference(TESObjectCELL &a_cell) const override
bhkSimpleShapePhantom * unk0E0
Definition: Projectile.h:247
virtual void Unk_A6(void)
virtual void Unk_AE(void)
float GetHeight() const
virtual bool RunTargetPick()
InventoryEntryData * unk148
Definition: Projectile.h:259
static constexpr auto VTABLE
Definition: Projectile.h:33
MagicSystem::CastingSource castingSource
Definition: Projectile.h:262
void SetActorCause(ActorCause *a_cause) override
MagicCaster * GetMagicCaster(MagicSystem::CastingSource a_source) override
void InitHavok() override
bool DetachHavok(NiAVObject *a_obj3D) override
BSSoundHandle sndHandle
Definition: Projectile.h:256
bool HasKeywordHelper(const BGSKeyword *a_keyword) const override
TESAmmo * ammoSource
Definition: Projectile.h:279
virtual void AddImpact(TESObjectREFR *a_ref, const NiPoint3 &a_targetLoc, const NiPoint3 &a_velocity, hkpCollidable *a_collidable, std::int32_t a_arg6, std::uint32_t a_arg7)
void GetLinearVelocity(NiPoint3 &a_velocity) const override
static ProjectileHandle * LaunchSpell(ProjectileHandle *a_result, Actor *a_shooter, SpellItem *a_spell, MagicSystem::CastingSource a_source) noexcept
float unk0DC
Definition: Projectile.h:246
NiTransform unk0A8
Definition: Projectile.h:245
void Revert(BGSLoadFormBuffer *a_buf) override
virtual void OnKill()
float unk1AC
Definition: Projectile.h:277
virtual void UpdateImpl(float a_delta)=0
TESObjectWEAP * weaponSource
Definition: Projectile.h:278
float scale
Definition: Projectile.h:282
static ProjectileHandle * LaunchArrow(ProjectileHandle *a_result, Actor *a_shooter, TESAmmo *a_ammo, TESObjectWEAP *a_weap) noexcept
MagicItem * spell
Definition: Projectile.h:261
static ProjectileHandle * LaunchArrow(ProjectileHandle *a_result, Actor *a_shooter, TESAmmo *a_ammo, TESObjectWEAP *a_weap, const NiPoint3 &a_origin, const ProjectileRot &a_angles) noexcept
float power
Definition: Projectile.h:268
virtual bool IsFlameProjectile()
bool unk1D0
Definition: Projectile.h:284
std::uint32_t pad_1C4
Definition: Projectile.h:281
Definition: SpellItem.h:16
Definition: TESAmmo.h:52
Definition: TESFile.h:17
Definition: TESObjectCELL.h:119
Definition: TESObjectREFR.h:113
Definition: TESObjectWEAP.h:79
Definition: bhkShape.h:10
Definition: hkpCollidable.h:13
CastingSource
Definition: MagicSystem.h:27
Definition: AbsorbEffect.h:6
constexpr std::array< REL::ID, 4 > VTABLE_Projectile
Definition: Offsets_VTABLE.h:12566
ImpactResult
Definition: ImpactResults.h:6
constexpr REL::ID RTTI_Projectile(static_cast< std::uint64_t >(514046))
constexpr REL::ID RTTI_Projectile__LaunchData(static_cast< std::uint64_t >(684852))
constexpr std::array< REL::ID, 1 > VTABLE_Projectile__LaunchData
Definition: Offsets_VTABLE.h:12568
Definition: BSSoundHandle.h:10
Definition: BSTSingleton.h:50
Definition: Projectile.h:114
stl::enumeration< COL_LAYER, std::int32_t > collidedLayer
Definition: Projectile.h:123
BGSMaterialType * material
Definition: Projectile.h:121
std::int32_t damageRootNodeType
Definition: Projectile.h:122
NiPoint3 desiredTargetLoc
Definition: Projectile.h:117
std::uint16_t unk46
Definition: Projectile.h:127
NiPointer< bhkCollisionObject > colObj
Definition: Projectile.h:120
ImpactResult impactResult
Definition: Projectile.h:125
std::uint8_t unk49
Definition: Projectile.h:129
ObjectRefHandle collidee
Definition: Projectile.h:119
std::uint8_t unk48
Definition: Projectile.h:128
NiPoint3 negativeVelocity
Definition: Projectile.h:118
NiNode * damageRootNode
Definition: Projectile.h:124
std::uint16_t unk44
Definition: Projectile.h:126
Definition: Projectile.h:68
static constexpr auto RTTI
Definition: Projectile.h:70
bool chainShatter
Definition: Projectile.h:106
EnchantmentItem * enchantItem
Definition: Projectile.h:98
MagicItem * spell
Definition: Projectile.h:95
float unk60
Definition: Projectile.h:92
TESAmmo * ammoSource
Definition: Projectile.h:87
virtual ~LaunchData()=default
TESObjectREFR * desiredTarget
Definition: Projectile.h:91
float unk64
Definition: Projectile.h:93
BGSProjectile * projectileBase
Definition: Projectile.h:83
NiPoint3 origin
Definition: Projectile.h:81
std::uint32_t pad7C
Definition: Projectile.h:97
bool noDamageOutsideCombat
Definition: Projectile.h:104
std::int32_t area
Definition: Projectile.h:100
void * unk50
Definition: Projectile.h:90
bool useOrigin
Definition: Projectile.h:107
TESObjectWEAP * weaponSource
Definition: Projectile.h:86
NiPoint3 contactNormal
Definition: Projectile.h:82
LaunchData(Actor *a_shooter, const NiPoint3 &a_origin, const ProjectileRot &a_angles, MagicItem *a_spell)
float angleZ
Definition: Projectile.h:88
float power
Definition: Projectile.h:101
TESObjectREFR * shooter
Definition: Projectile.h:84
float scale
Definition: Projectile.h:102
MagicSystem::CastingSource castingSource
Definition: Projectile.h:96
float angleX
Definition: Projectile.h:89
CombatController * combatController
Definition: Projectile.h:85
bool alwaysHit
Definition: Projectile.h:103
LaunchData(Actor *a_shooter, const NiPoint3 &a_origin, const ProjectileRot &a_angles, TESAmmo *a_ammo, TESObjectWEAP *a_weap)
LaunchData(BGSProjectile *a_bproj, Actor *a_shooter, const NiPoint3 &a_origin, const ProjectileRot &a_angles)
bool forceConeOfFire
Definition: Projectile.h:109
static constexpr auto VTABLE
Definition: Projectile.h:71
bool deferInitialization
Definition: Projectile.h:108
TESObjectCELL * parentCell
Definition: Projectile.h:94
bool autoAim
Definition: Projectile.h:105
AlchemyItem * poison
Definition: Projectile.h:99
Definition: Projectile.h:59
float z
Definition: Projectile.h:63
float x
Definition: Projectile.h:62
Definition: Projectile.h:36
NiMatrix3 unk00
Definition: Projectile.h:39
float wobble
Definition: Projectile.h:41
ProjectileHandle handle
Definition: Projectile.h:40