forked from CasualCoderGuy/FO4-ModSwitchFramework-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMSF_Shared.h
More file actions
1405 lines (1253 loc) · 48 KB
/
MSF_Shared.h
File metadata and controls
1405 lines (1253 loc) · 48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#pragma once
#include "Config.h"
#include "f4se/GameData.h"
#include "f4se/GameExtraData.h"
#include "f4se/GameFormComponents.h"
#include "f4se/GameObjects.h"
#include "f4se/GameReferences.h"
#include "f4se/ScaleformMovie.h"
#include "f4se/GameMenus.h"
#include "f4se/GameRTTI.h"
#include "f4se/PapyrusNativeFunctions.h"
#include "f4se/PapyrusUtilities.h"
#include "f4se/PapyrusEvents.h"
#include "f4se/GameCamera.h"
#include "f4se/ScaleformLoader.h"
#include "old\MSF_misc.h"
#include "rva/RVA.h"
//#include "decomp\BSPointerHandle.h"
#include "RNG.h"
#include <thread>
#include <chrono>
#include <sstream>
#include <algorithm>
#include <condition_variable>
extern IDebugLog gLog;
extern PluginHandle g_pluginHandle;
extern F4SEPapyrusInterface* g_papyrus;
extern F4SEMessagingInterface* g_messaging;
extern F4SEScaleformInterface* g_scaleform;
extern F4SESerializationInterface* g_serialization;
extern F4SETaskInterface* g_threading;
UInt32 roundp(float a);
UInt32 inttover(UInt32 input);
BGSObjectInstanceExtra* CreateObjectInstanceExtra(BGSObjectInstanceExtra::Data* data);
ExtraUniqueID* CreateExtraUniqueID(UInt16 id, UInt32 form);
typedef unsigned short KeywordValue;
typedef UInt32 ObjectRefHandle;
namespace InventoryInterface
{
struct CountChangedEvent
{
public:
// members
std::uint32_t inventoryOwnerID; // 00
std::uint32_t itemID; // 04
std::int32_t newCount; // 08
std::int32_t oldCount; // 0C
};
STATIC_ASSERT(sizeof(CountChangedEvent) == 0x10);
struct FavoriteChangedEvent
{
public:
~FavoriteChangedEvent() noexcept {} // intentional
// members
BGSInventoryItem* itemAffected; // 0
};
STATIC_ASSERT(sizeof(FavoriteChangedEvent) == 0x8);
}
class BGSInventoryInterface
{
public:
struct Agent
{
public:
// members
std::uint32_t handleID; // 0
ObjectRefHandle itemOwner; // 4
std::uint16_t listIndex; // 8
std::uint16_t refCount; // A
};
STATIC_ASSERT(sizeof(Agent) == 0xC);
UInt64 pad;
BSTEventDispatcher<InventoryInterface::CountChangedEvent> countChangedEventSource; // 08
BSTEventDispatcher<InventoryInterface::FavoriteChangedEvent> favChangedEventSource; // 60
tArray<Agent> agentArray; // B8
};
STATIC_ASSERT(sizeof(BGSInventoryInterface) == 0xD0);
class NiFormArray;
class TESConditionItem;
class TESCondition
{
public:
TESConditionItem* head;
};
struct IDLE_DATA
{
public:
// members
std::int8_t loopMin; // 0
std::int8_t loopMax; // 1
std::int8_t flags; // 2
std::uint16_t replayDelay; // 4
};
STATIC_ASSERT(sizeof(IDLE_DATA) == 0x6);
class TESIdleForm : public TESForm
{
public:
enum { kTypeID = kFormType_IDLE };
// members
TESCondition conditions; // 20
IDLE_DATA data; // 28
NiFormArray* childIdles; // 30
TESIdleForm* parentIdle; // 38
TESIdleForm* prevIdle; // 40
BSFixedString behaviorGraphName; // 48
BSFixedString animEventName; // 50
BSFixedString animFileName; // 58
BSString formEditorID; // 60
};
STATIC_ASSERT(sizeof(TESIdleForm) == 0x70);
class TESImageSpaceModifiableForm :
public BaseFormComponent // 00
{
public:
// members
TESImageSpaceModifier* formImageSpaceModifying; // 08
};
STATIC_ASSERT(sizeof(TESImageSpaceModifiableForm) == 0x10);
struct BGSExplosionData
{
public:
// members
TESObjectLIGH* light; // 00
BGSSoundDescriptorForm* sound1; // 08
BGSSoundDescriptorForm* sound2; // 10
BGSImpactDataSet* impactDataSet; // 18
TESBoundObject* impactPlacedObject; // 20
BGSProjectile* spawnProjectile; // 28
NiPoint3 projectileVector; // 30
float projectileSpread; // 3C
std::uint32_t projectileCount; // 40
float force; // 44
float damage; // 48
float innerRadius; // 4C
float outerRadius; // 50
float imageSpaceRadius; // 54
float verticalOffsetMult; // 58
UInt32 flags; // 5C
UInt32 soundLevel; // 60
float placedObjectFadeDelay; // 64
UInt32 staggerMagnitude; // 68
};
STATIC_ASSERT(sizeof(BGSExplosionData) == 0x70);
class BGSExplosion :
public TESBoundObject, // 000
public TESFullName, // 068
public TESModel, // 078
public TESEnchantableForm, // 0A8
public BGSPreloadable, // 0C0
public TESImageSpaceModifiableForm // 0C8
{
public:
// members
BGSExplosionData data; // 0D8
};
STATIC_ASSERT(sizeof(BGSExplosion) == 0x148);
class MSFAimModel : public TESForm //https://github.com/isathar/F4SE_AmmoTweaksExtension cast AimModel as MSFAimModel, edit result
{
public:
enum { kTypeID = kFormType_AMDL };
// CoF_ = spread/cone of fire, Rec_ = recoil:
float CoF_MinAngle; //20 - min. spread angle (crosshair size)
float CoF_MaxAngle; //24 - max. spread angle
float CoF_IncrPerShot; //28 - spread increase per shot
float CoF_DecrPerSec; //2C - spread decrease per second (after delay)
UInt32 CoF_DecrDelayMS; //30 - delay in ms before spread starts to decrease after firing
float CoF_SneakMult; //34 - multiplier applied to spread while sneaking/crouched
float Rec_DimSpringForce; //38 - amount of automatic aim correction after recoil
float Rec_DimSightsMult; //3C - amount of automatic aim correction after recoil while aiming
float Rec_MaxPerShot; //40 - max. amount of recoil per shot
float Rec_MinPerShot; //44 - min. amount of recoil per shot
float Rec_HipMult; //48 - multiplier applied to recoil while firing from the hip
UInt32 Rec_RunawayShots; //4C - the number of shots before recoil becomes unbearable?
float Rec_ArcMaxDegrees; //50 - max. difference from the base recoil angle per shot in degrees
float Rec_ArcRotate; //54 - angle for the recoil direction (clock-wise from 12:00)
float CoF_IronSightsMult; //58 - multiplier applied to spread while aiming without a scope
float BaseStability; //5C - multiplier applied to the amount of camera movement while using a scope
};
class MSFZoomData : public TESForm
{
public:
enum { kTypeID = kFormType_ZOOM };
float FOVmult; //20
UInt32 overlay; //24
UInt32 imageSpaceFormID; //28
float offsetX; //2C
float offsetY; //30
float offsetZ; //34
TESImageSpaceModifier* imageSpace; //38
};
STATIC_ASSERT(sizeof(MSFZoomData) == 0x40);
class BGSSoundKeywordMapping : public TESForm//, BSISoundDescriptor
{
public:
enum { kTypeID = kFormType_KSSM };
UInt64 unk20; //20
UInt32 unk28; //28
UInt32 unk2C; //2C
UInt32 unk30; //30
UInt32 unk34; //34
void* unk38; //38 to vtbl?
UInt64 unk40; //40
void* unk48; //48 to keywords?
UInt64 unk50[3]; //50
void* unk68; //68 to vtbl?
UInt64 unk70; //70
UInt64 unk78; //78
BGSSoundDescriptorForm* primarySound; //80
BGSSoundDescriptorForm* exteriorTail; //88
BGSSoundDescriptorForm* VATS_Sound; //90
float VATS_threshold; //98
};
STATIC_ASSERT(offsetof(BGSSoundKeywordMapping, primarySound) == 0x80);
class EquipWeaponData : public EquippedItemData
{
public:
virtual ~EquipWeaponData();
TESAmmo* ammo; // 10
volatile int loadedAmmoCount; // 18
MSFAimModel* aimModel; // 20
void* muzzleFlash; // 28
NiAVObject* fireNode; // 30
UInt64 attackState; // 38
void* fireLocations[3]; // 40
void* weaponPreload; // 58
void* projectilePreload; // 60
void* reserveProjectileClones; // 68
void* idleSound; // 70
void* attackSound; // 78
void* reverbSound; // 80
void* prevAttack; // 88
void* prevReverb; // 90
BGSSoundKeywordMapping* attackSoundData; // 98
bool reverbSoundIsTail;
//TESAmmo* ammo; // 10
//UInt64 loadedAmmoCount; // 18
//void* unk20; // 20
//UInt64 unk28; // 28
//NiAVObject* object; // 30
//UInt64 unk38[4]; // 38
//void* unk58; // 58 QueuedFile
//void* unk60; // 60 QueuedFile
//void* unk68; // 68 BSCloneReserver
//UInt64 unk70[5]; // 70
//BGSSoundKeywordMapping* firingSound;// 98
//BGSKeyword* unkKeyword; // A0
};
STATIC_ASSERT(offsetof(EquipWeaponData, attackSoundData) == 0x98);
class CheckStackIDFunctor
{
private:
void* vtbl; //00
public:
CheckStackIDFunctor(UInt32 ID);
UInt32 stackID; //08
};
class StackDataWriteFunctor
{
protected:
void* vtbl; // 00
public:
bool shouldSplitStacks{ true }; // 08
bool transferEquippedToSplitStack{ false }; // 09
};
STATIC_ASSERT(sizeof(StackDataWriteFunctor) == 0x10);
class ModifyModDataFunctor : public StackDataWriteFunctor
{
public:
ModifyModDataFunctor(BGSMod::Attachment::Mod* mod, UInt8 slotIndex, bool bAttach, bool* success);
BGSMod::Attachment::Mod* mod; // 10
TESBoundObject* foundObject{ nullptr }; // 18 not needed to set in advance
bool* success; // 20 set to 1, return value
const UInt8 slotIndex; // 28
const bool attach; // 29
bool equipLocked{ false }; // 2A
};
STATIC_ASSERT(sizeof(ModifyModDataFunctor) == 0x30);
STATIC_ASSERT(offsetof(ModifyModDataFunctor, mod) == 0x10);
class SplitStackFunctor
{
public:
SplitStackFunctor(bool transferEquipped, UInt32 newCount, BGSInventoryItem::Stack* oldStack);
virtual bool Apply(TESBoundObject* item, BGSInventoryItem::Stack* newStack);
bool shouldSplitStacks{ true }; // 08
bool transferEquippedToSplitStack{ false }; // 09
bool preventUnequip{ false };
UInt32 stackCount;
BGSInventoryItem::Stack* stack;
};
class ApplyChangesFunctor : public StackDataWriteFunctor
{
public:
ApplyChangesFunctor(TESBoundObject* foundObject, BGSObjectInstanceExtra* moddata, BGSMod::Attachment::Mod* mod, bool ignoreWeapon, bool remove, bool equipLocked, UInt8 setExtraData);
BGSObjectInstanceExtra* moddata; // 10
TESBoundObject* foundObject; // 18
BGSMod::Attachment::Mod* mod; // 20
bool ignoreWeapon; // 28 true
bool remove; // 29
bool equipLocked; // 2A false
UInt8 setExtraData; // 2B FE (ignored when FE)
};
STATIC_ASSERT(sizeof(ApplyChangesFunctor) == 0x30);
STATIC_ASSERT(offsetof(ApplyChangesFunctor, remove) == 0x29);
class BGSEquipIndex
{
public:
std::uint32_t index; // 0
};
STATIC_ASSERT(sizeof(BGSEquipIndex) == 0x4);
class ExtraEnchantment : public BSExtraData
{
public:
ExtraEnchantment();
virtual ~ExtraEnchantment();
EnchantmentItem* enchant; // 08
UInt16 maxCharge; // 0C
UInt8 unk0E; // 0E - usually 0
UInt8 pad0F; // 0F
static ExtraEnchantment* Create();
};
class ExtraModRank : public BSExtraData
{
public:
UInt32 rank; // 18
static ExtraModRank* Create(UInt32 modrank);
};
class ExtraRank : public BSExtraData
{
public:
UInt32 rank; // 18
static ExtraRank* Create(UInt32 rank);
};
class ExtraAmmo : public BSExtraData
{
public:
UInt32 ammo; // 18
static ExtraAmmo* Create(UInt32 ammo);
};
struct unkTBOStruct
{
TESBoundObject* baseForm;
UInt64 unk08;
};
struct ActorStruct
{
Actor* actor;
UInt8* unk08;
};
struct unkItemStruct
{
TESForm* item;
UInt16 unk08;
};
struct unkEquipSlotStruct
{
UInt64 unk00; //=1 or 0
BGSEquipSlot* equipSlot;
UInt64 unk10; //=0
UInt64 unk18; //=0x10001 or 0x10000
};
class RemoveItemData
{
public:
};
class RemoveItemData2
{
public:
};
template <typename T> class TypedKeywordValueArray
{
public:
T* entries;
UInt32 count;
//T& operator[](int idx) { return *(ptr + idx); }
TypedKeywordValueArray() : entries(NULL), count(0) { }
T& operator[](UInt64 index)
{
return entries[index];
}
bool GetNthItem(UInt64 index, T& pT) const
{
if (index < count) {
pT = entries[index];
return true;
}
return false;
}
SInt64 GetItemIndex(T & pFind) const
{
for (UInt64 n = 0; n < count; n++) {
T& pT = entries[n];
if (pT == pFind)
return n;
}
return -1;
}
void Clear()
{
Heap_Free(entries);
entries = NULL;
count = 0;
}
bool Push(const T & entry)
{
UInt32 idx = count;
if (!Grow())
return false;
entries[idx] = entry;
return true;
};
bool Insert(UInt32 index, const T & entry)
{
if (!entries)
return false;
UInt32 lastSize = count;
if (!Grow())
return false;
if (index != lastSize) // Not inserting onto the end, need to move everything down
{
UInt32 remaining = count - index;
memmove_s(&entries[index + 1], sizeof(T) * remaining, &entries[index], sizeof(T) * remaining); // Move the rest up
}
entries[index] = entry;
return true;
};
bool Remove(UInt32 index)
{
if (!entries || index >= count)
return false;
// This might not be right for pointer types...
(&entries[index])->~T();
if (index + 1 < count) {
UInt32 remaining = count - index;
memmove_s(&entries[index], sizeof(T) * remaining, &entries[index + 1], sizeof(T) * remaining); // Move the rest up
}
count--;
if (count == 0)
Clear();
else
Shrink();
return true;
}
private:
bool Shrink()
{
if (!entries) return false;
try {
UInt32 newSize = count;
T * oldArray = entries;
T * newArray = (T *)Heap_Allocate(sizeof(T) * newSize); // Allocate new block
memmove_s(newArray, sizeof(T) * newSize, entries, sizeof(T) * newSize); // Move the old block
entries = newArray;
Heap_Free(oldArray); // Free the old block
return true;
}
catch (...) {
return false;
}
return false;
}
bool Grow()
{
if (!entries) {
entries = (T *)Heap_Allocate(sizeof(T));
count = 1;
return true;
}
try {
UInt32 oldSize = count;
UInt32 newSize = oldSize + 1;
T * oldArray = entries;
T * newArray = (T *)Heap_Allocate(sizeof(T) * newSize); // Allocate new block
if (oldArray)
memmove_s(newArray, sizeof(T) * newSize, entries, sizeof(T) * oldSize); // Move the old block
entries = newArray;
count = newSize;
if (oldArray)
Heap_Free(oldArray); // Free the old block
for (UInt32 i = oldSize; i < newSize; i++) // Allocate the rest of the free blocks
new (&entries[i]) T;
return true;
}
catch (...) {
return false;
}
return false;
}
DEFINE_STATIC_HEAP(Heap_Allocate, Heap_Free)
};
typedef TypedKeywordValueArray<KeywordValue> KeywordValueArray;
class AttachParentArray : public BaseFormComponent
{
public:
KeywordValueArray kewordValueArray;
enum
{
iDataType = 2
};
};
namespace Utilities
{
TESForm* GetFormFromIdentifier(const std::string& identifier);
const char* GetIdentifierFromForm(TESForm* form);
bool AddToFormList(BGSListForm* flst, TESForm* form, SInt64 idx);
UInt32 GetLoadedAmmoCount(Actor* owner);
UInt32 GetEquippedItemFormID(Actor * ownerActor, UInt32 iEquipSlot = 41);
TESObjectWEAP::InstanceData* GetEquippedWeaponInstanceData(Actor* ownerActor);
TESObjectWEAP::InstanceData* GetEquippedInstanceData(Actor * ownerActor, UInt32 iEquipSlot = 41);
BGSObjectInstanceExtra* GetEquippedModData(Actor * ownerActor, UInt32 iEquipSlot = 41);
BGSObjectInstanceExtra* GetEquippedWeaponModData(Actor* ownerActor);
BGSInventoryItem::Stack* GetEquippedStack(Actor* owner, UInt32 slotIndex);
BGSInventoryItem::Stack* GetEquippedWeaponStack(Actor* owner);
BGSInventoryItem* GetEquippedInventoryWeapon(Actor* owner);
TESObjectWEAP* GetEquippedGun(Actor* ownerActor);
TESObjectWEAP* GetEquippedWeapon(Actor* ownerActor);
UInt8 GetEquippedWeaponSlotIndex(Actor* ownerActor);
UInt32 GetStackID(BGSInventoryItem* item, BGSInventoryItem::Stack* stack);
BGSInventoryItem::Stack* GetStack(BGSInventoryItem* item, UInt32 stackID);
BGSInventoryItem::Stack* GetStackFromItem(TESObjectREFR* owner, TESForm* item, UInt32 stackID);
UInt64 GetInventoryItemCount(BGSInventoryList* inventory, TESForm* item);
EquipWeaponData* GetEquippedWeaponData(Actor* owner);
TESObjectMISC* GetLooseMod(BGSMod::Attachment::Mod* thisMod);
BGSMod::Attachment::Mod* FindModByUniqueKeyword(BGSObjectInstanceExtra* modData, BGSKeyword* keyword);
std::vector<BGSMod::Attachment::Mod*> FindModsByUniqueKeyword(BGSObjectInstanceExtra* modData, BGSKeyword* keyword);
BGSMod::Attachment::Mod* GetFirstModWithPriority(BGSObjectInstanceExtra* modData, UInt8 priority);
bool HasObjectMod(BGSObjectInstanceExtra* modData, BGSMod::Attachment::Mod* mod);
BGSKeyword* GetAttachParent(BGSMod::Attachment::Mod* mod);
bool GetParentMods(BGSObjectInstanceExtra* modData, BGSMod::Attachment::Mod* mod, std::vector<BGSMod::Attachment::Mod*>* parents);
BGSMod::Attachment::Mod* GetParentMod(BGSObjectInstanceExtra* modData, BGSMod::Attachment::Mod* mod);
KeywordValue GetAttachValueForTypedKeyword(BGSKeyword* keyword);
KeywordValue GetInstantiationValueForTypedKeyword(BGSKeyword* keyword);
KeywordValue GetAnimFlavorValueForTypedKeyword(BGSKeyword* keyword);
bool HasAttachPoint(AttachParentArray* attachPoints, BGSKeyword* attachPointKW);
bool HasAttachPoint(AttachParentArray* attachPoints, KeywordValue attachPointKW);
bool ObjectInstanceHasAttachPoint(BGSObjectInstanceExtra* modData, BGSKeyword* attachPointKW);
bool ObjectInstanceHasAttachPoint(BGSObjectInstanceExtra* modData, KeywordValue attachPointKW);
std::vector<KeywordValue> GetAllAttachPoints(BGSObjectInstanceExtra* modData, AttachParentArray* attachPoints);
BGSMod::Attachment::Mod* GetModAtAttachPoint(BGSObjectInstanceExtra* modData, KeywordValue keywordValue);
bool GetParentInstantiationValues(BGSObjectInstanceExtra* modData, KeywordValue parentValue, std::vector<KeywordValue>* instantiationValues);
bool AddAttachPoint(AttachParentArray* attachPoints, BGSKeyword* attachPointKW);
bool AddAttachValue(AttachParentArray* attachPoints, KeywordValue attachValue);
bool WeaponInstanceHasKeyword(TESObjectWEAP::InstanceData* instanceData, BGSKeyword* checkKW);
bool HasKeyword(BGSKeywordForm* keywordForm, BGSKeyword* checkKW);
bool UpdateAimModel(MSFAimModel* oldModel, MSFAimModel* newModel);
bool UpdateZoomData(MSFZoomData* oldData, MSFZoomData* newData);
UInt32 PlaySoundInternal(BGSSoundDescriptorForm* sound, TESObjectREFR* target);
bool PlayIdle(Actor* actor, TESIdleForm* idle);
bool PlayIdleAction(Actor* actor, BGSAction* action);
void DrawWeapon(Actor* actor);
void FireWeapon(Actor* actor, UInt32 shots);
void ReloadWeapon(Actor* actor);
void SetAnimationVariableBool(TESObjectREFR* ref, BSFixedString asVariableName, bool newVal);
void SetAnimationVariableInt(TESObjectREFR* ref, BSFixedString asVariableName, SInt32 newVal);
void SetAnimationVariableFloat(TESObjectREFR* ref, BSFixedString asVariableName, float newVal);
bool GetAnimationVariableBool(TESObjectREFR* ref, BSFixedString asVariableName);
SInt32 GetAnimationVariableInt(TESObjectREFR* ref, BSFixedString asVariableName);
float GetAnimationVariableFloat(TESObjectREFR* ref, BSFixedString asVariableName);
void SendNotification(std::string asNotificationText);
//void ShowMessagebox(std::string asText);
void AddItem(TESObjectREFR* target, TESForm* form, SInt32 count, bool bSilent);
void RemoveItem(TESObjectREFR* target, TESForm* form, SInt32 count, bool bSilent, TESObjectREFR* toContainer = nullptr);
void AttachModToInventoryItem(TESObjectREFR* objRef, TESForm* invItem, BGSMod::Attachment::Mod* mod);
bool ModActorValue(Actor* actor, ActorValueInfo* av, float val);
bool AddRemActorValue(Actor* actor, ActorValueInfo* av, bool bAdd);
bool AddRemKeyword(BGSKeywordForm* keywordForm, BGSKeyword* keyword, bool bAdd);
UInt32 AddRemFlag(UInt32 flagHolder, UInt32 flag, UInt8 bAdd, UInt8 op = 0);
float GetActorValue(tArray<Actor::ActorValueData>* avdata, UInt32 formId);
class Timer
{
public:
void start()
{
countStart = std::chrono::steady_clock::now();
_IsRunning = true;
}
long long int getElapsed()
{
if (!_IsRunning)
return 0;
countEnd = std::chrono::steady_clock::now();
return std::chrono::duration_cast<std::chrono::milliseconds>(countEnd - countStart).count();
}
long long int stop()
{
if (!_IsRunning)
return 0;
_IsRunning = false;
countEnd = std::chrono::steady_clock::now();
return std::chrono::duration_cast<std::chrono::milliseconds>(countEnd - countStart).count();
}
long long int getLast()
{
if (_IsRunning)
return 0;
return std::chrono::duration_cast<std::chrono::milliseconds>(countEnd - countStart).count();
}
bool IsRunning()
{
return _IsRunning;
}
private:
std::chrono::steady_clock::time_point countStart, countEnd;
bool _IsRunning;
};
}
class TlsShare
{
private:
std::vector<std::pair<DWORD, void*>> TlsValues;
public:
TlsShare();
void CopyTls();
};
class delayTask
{
public:
template <class callable, class... arguments>
delayTask(int delay, bool async, callable&& f, arguments&&... args)
{
std::function<typename std::result_of<callable(arguments...)>::type()> task(std::bind(std::forward<callable>(f), std::forward<arguments>(args)...));
if (async)
{
TlsShare* tlsShare = new TlsShare;
std::thread([delay, task, tlsShare]() {
tlsShare->CopyTls();
std::this_thread::sleep_for(std::chrono::milliseconds(delay));
task();
delete tlsShare;
}).detach();
}
else
{
std::this_thread::sleep_for(std::chrono::milliseconds(delay));
task();
}
}
};
class DelayedExecutor
{
public:
DelayedExecutor() : cancelled(false), running(false), id(0)
{}
~DelayedExecutor()
{
cancel();
}
template <class callable, class... arguments>
void start(int delay_ms, callable&& f, arguments&&... args)
{
cancel();
std::function<typename std::result_of<callable(arguments...)>::type()> func(std::bind(std::forward<callable>(f), std::forward<arguments>(args)...));
worker = std::thread([=] {
std::unique_lock<std::mutex> lock(mtx);
cancelled = false;
running = true;
int selfid = id;
id++;
if (cv.wait_for(lock, std::chrono::milliseconds(delay_ms), [&] { return cancelled.load(); }))
return;
if (!cancelled)
{
_DEBUG("selfid: %i", selfid);
func();
}
running = false;
});
worker.detach();
}
void cancel()
{
{
std::lock_guard<std::mutex> lock(mtx);
cancelled = true;
running = false;
}
cv.notify_all();
}
bool is_running() {
std::lock_guard<std::mutex> lock(mtx);
return running;
}
private:
std::atomic<bool> cancelled;
std::atomic<bool> running;
std::atomic<int> id;
std::thread worker;
std::condition_variable cv;
std::mutex mtx;
};
typedef void(*_AttachModToInventoryItem)(VirtualMachine* vm, UInt32 stackId, TESObjectREFR* objRef, TESForm* invItem, BGSMod::Attachment::Mod* mod, bool unkbool);
typedef void(*_AttachRemoveModInternal)(Actor* actor, TESBoundObject* baseItem, CheckStackIDFunctor* CheckStackIDFunctor, StackDataWriteFunctor* ModifyModDataFunctor, void* arg_1, void* arg_2, void* arg_3, void* arg_4, void* arg_5, void* arg_6, void* arg_7);
typedef void(*_EquipItemPapyrus)(Actor* actor, TESBoundObject* baseItem, UInt32 r8d);
typedef bool(*_AttachModToStack)(BGSInventoryItem* invItem, CheckStackIDFunctor* IDfunctor, StackDataWriteFunctor* modFuntor, UInt32 unk_r9d, UInt32* unk_rsp20); //, UInt32 unk_rsp50
typedef bool(*_ModifyStackData)(BGSInventoryItem* invItem, BGSInventoryItem::Stack** stack, StackDataWriteFunctor* modFuntor);
typedef bool(*_UpdMidProc)(Actor::AIProcess* midProc, Actor* actor, BGSObjectInstance weaponBaseStruct, BGSEquipSlot* equipSlot);
typedef void(*_UpdateEquipData)(BipedAnim* equipData, BGSObjectInstance instance, UInt32* r8d);
typedef void*(*_UpdateAnimGraph)(Actor* actor, bool rdx);
typedef void(*_PlayEquipAction)(Actor* actor, bool rdx);
typedef void(*_UpdateEnchantments)(Actor* actor, BGSObjectInstance BGSObjectInstance, ExtraDataList* extraDataList);
typedef void(*_UpdateAVModifiers)(ActorStruct actorStruct, tArray<TBO_InstanceData::ValueModifier>* valueModifiers);
typedef void(*_UpdateAnimValueFloat)(IAnimationGraphManagerHolder* animManager, void* dataHolder, float newValue);
typedef bool(*_DeleteExtraData)(BSExtraData** extraDataHead, ExtraDataType type);
typedef void (*_ExtraRankCtor)(ExtraDataList* parentList, UInt32 rank);
typedef ExtraRank* (*_ExtraRankDtor)(ExtraRank* extra, bool cast);
typedef bool(*_LoadMovieEx)(BSScaleformManager* mgr, IMenu* menu, GFxMovieView*&, const char* name, const char* stagePath, UInt32 a_scaleMode, float a_backgroundAlpha);
typedef BGSObjectInstanceExtra::Data*(*_CreateInstanceModsFromTemplate)(void* scrapHeap, void* rdx, TESObjectWEAP* templateWeap, void* r9);
typedef BGSObjectInstanceExtra*(*_BGSObjectInstanceExtra_ctor)(BGSObjectInstanceExtra* allocatedHeap, BGSMod::Template::Item* templateItem, TESBoundObject* parentForm, void* instanceFilter);
typedef void(*_AttachMod)(TESObjectREFR* ref, BGSMod::Attachment::Mod* newMod, UInt8 attachIndex, UInt8 rank);
typedef void(*_AddMod)(BGSObjectInstanceExtra* extraModList, BGSMod::Attachment::Mod* newMod, UInt8 attachIndex, UInt8 rank, bool removeInvalidMods);
typedef UInt32(*_RemoveMod)(BGSObjectInstanceExtra* extraModList, BGSMod::Attachment::Mod* modToRemove, UInt8 attachIndex);
typedef UInt32(*_RemoveInvalidMods)(BGSObjectInstanceExtra* extraModList, AttachParentArray* baseObjectParents);
typedef void(*_UpdateEquippedWeaponData)(EquippedWeaponData* data, UInt32 edx);
typedef bool(*_MainEquipHandler)(void* unkmanager, Actor* actor, BGSObjectInstance weaponBaseStruct, unkEquipSlotStruct equipSlotStruct);
typedef bool(*_EquipHandler)(void* unkmanager, Actor* actor, BGSObjectInstance weaponBaseStruct, unkEquipSlotStruct equipSlotStruct);
typedef void(*_UniversalEquipHandler)(Actor* actor, BGSObjectInstance weaponBaseStruct, unkEquipSlotStruct equipSlotStruct);
typedef void(*_NiStuff)(PlayerCharacter* player, TESObjectWEAP* weapBase, ExtraDataList** extraDataList, UInt32 r9d, bool rbp20, UInt32 rbp28);
typedef void(*_UnkSub_EFF9D0)(Actor* actor);
typedef void(*_UnkSub_DFE930)(Actor* actor, bool rdx);
// //virtual void AttachWeapon(const BGSObjectInstanceT<TESObjectWEAP>& a_weapon, BGSEquipIndex a_equipIndex); // A5
//virtual void DoReparentWeapon(const TESObjectWEAP* a_weapon, BGSEquipIndex a_equipIndex, bool a_weaponDrawn); // 118
typedef void(*_SetDelete)(TESForm* form, bool a_deleted);
typedef TESForm* (*_CreateDuplicateForm)(TESForm* original, bool a_createEditorID, tHashSet<TESForm*, TESForm*>* a_copyMap);
typedef BGSKeyword*(*_GetKeywordFromValueArray)(UInt32 valueArrayBase, KeywordValue value);
typedef bool(*_HasPerkInternal)(Actor* actor, BGSPerk* perk);
typedef bool(*_IKeywordFormBase_HasKeyword)(IKeywordFormBase* keywordFormBase, BGSKeyword* keyword, UInt32 unk3); //https://github.com/shavkacagarikia/ExtraItemInfo
typedef void(*_AddItem_Native)(VirtualMachine* vm, UInt32 stackId, TESObjectREFR* target, unkItemStruct itemStruct, SInt32 count, bool bSilent);
typedef void(*_RemoveItem_Native)(VirtualMachine* vm, UInt32 stackId, TESObjectREFR* target, unkItemStruct itemStruct, SInt32 count, bool bSilent, TESObjectREFR* toContainer);
typedef ObjectRefHandle(*_RemoveItem_Virtual)(TESObjectREFR* ref, RemoveItemData& a_data, RemoveItemData2& a_data2); // 6D, ObjREF
typedef void(*_SetAnimationVariableBool)(VirtualMachine* vm, UInt32 stackId, TESObjectREFR* ref, BSFixedString asVariableName, bool newVal);
typedef void(*_SetAnimationVariableInt)(VirtualMachine* vm, UInt32 stackId, TESObjectREFR* ref, BSFixedString asVariableName, SInt32 newVal);
typedef void(*_SetAnimationVariableFloat)(VirtualMachine* vm, UInt32 stackId, TESObjectREFR* ref, BSFixedString asVariableName, float newVal);
typedef bool(*_GetAnimationVariableBool)(VirtualMachine* vm, UInt32 stackId, TESObjectREFR* ref, BSFixedString asVariableName);
typedef SInt32(*_GetAnimationVariableInt)(VirtualMachine* vm, UInt32 stackId, TESObjectREFR* ref, BSFixedString asVariableName);
typedef float(*_GetAnimationVariableFloat)(VirtualMachine* vm, UInt32 stackId, TESObjectREFR* ref, BSFixedString asVariableName);
typedef bool(*_PlayIdle)(VirtualMachine* vm, UInt32 stackId, Actor* actor, TESIdleForm* idle);
typedef bool(*_PlayIdle2)(Actor* actor, TESIdleForm* idle, UInt64 unk, VirtualMachine* vm, UInt32 stackId);
typedef UInt32(*_PlaySoundVM)(VirtualMachine* vm, UInt32 stackId, BGSSoundDescriptorForm* sound, TESObjectREFR* ref);
typedef UInt32(*_PlaySoundInt)(BGSSoundDescriptorForm* sound, TESObjectREFR* ref);
#ifndef NEXTGEN
typedef bool(*_PlayIdleAction)(Actor* actor, BGSAction* action, TESObjectREFR* target, VirtualMachine* vm, UInt32 stackId);
#else
typedef bool(*_PlayIdleAction)(VirtualMachine* vm, UInt32 stackId, Actor* actor, BGSAction* action, TESObjectREFR* target);
#endif
typedef void(*_PlaySubgraphAnimation)(VirtualMachine* vm, UInt32 stackId, Actor* target, BSFixedString asEventName);
typedef bool(*_InitializeActorInstant)(Actor* actor, UInt32 edx);
typedef void(*_UpdateAnimation)(PlayerCharacter* player, float delta);
typedef void (*_PlayEquipSound)(Actor* target, TESBoundObject* a_boundObj, bool a_pickUp, bool a_use);
typedef bool(*_FireWeaponInternal)(Actor* actor);
typedef void(*_ChangeAnimArchetype)(Actor* target, BGSKeyword* archetypeKW);
typedef void(*_ChangeAnimFlavor)(Actor* target, BGSKeyword* flavorKW);
typedef void(*_CheckKeywordType)(BGSKeyword* keyword, UInt32 type); //7: AnimArchetype; 13: AnimFlavor
typedef bool(*_IsInIronSights)(VirtualMachine* vm, Actor* actor);
typedef bool(*_IsInPowerArmor)(Actor* actor);
typedef void(*_DrawWeapon)(VirtualMachine* vm, UInt32 stackId, Actor* actor);
typedef bool(*_FireWeaponInternal)(Actor* actor);
typedef bool(*_ReloadWeapon)(Actor* actor, const BGSObjectInstance& a_weapon, UInt32 a_equipIndex); // 0EF E9BE00
typedef UInt32(*_UseAmmo)(Actor* actor, const BGSObjectInstance& a_weapon, UInt32 a_equipIndex, UInt32 a_shotCount); // 0F0 EFCE90
typedef void(*_EjectShellCasing)(TESObjectREFR* ref, TESObjectWEAP::InstanceData* instanceData, BGSEquipIndex eqIdx);
//typedef void(*_ShowNotification)(const char* text, const char* context, UInt32 r8d, UInt32 r9b);
typedef void(*_ShowNotification)(const char* text, const char* context, UInt32 r8d, bool r9b);
typedef bool(*_EquipItem)(void* actorEquipManager, Actor* actor, const BGSObjectInstance& a_object, UInt32 stackID, UInt32 number, const BGSEquipSlot* slot, bool queue, bool forceEquip, bool playSound, bool applyNow, bool preventUnequip);
typedef bool(*_UnEquipItem)(void* actorEquipManager, Actor* actor, const BGSObjectInstance& a_object, SInt32 number, const BGSEquipSlot* slot, UInt32 stackID, bool queue, bool forceEquip, bool playSound, bool applyNow, const BGSEquipSlot* a_slotBeingReplaced);
typedef ObjectRefHandle*(*_GetHandle)(ObjectRefHandle* handleOut, TESObjectREFR* ref);
extern RelocAddr <_GetHandle> GetHandle;
typedef bool(*_GetNiSmartPointer)(ObjectRefHandle* a_handle, TESObjectREFR** a_smartPointerOut);
extern RelocAddr <_GetNiSmartPointer> GetNiSmartPointer;
typedef bool(*_GetSmartPointer)(ObjectRefHandle* a_handle, TESObjectREFR** a_smartPointerOut);
extern RelocAddr <_GetSmartPointer> GetSmartPointer;
typedef BGSInventoryItem*(*_RequestInventoryItem)(BGSInventoryInterface* itfc, UInt32* a_handleID);
extern RelocAddr <_RequestInventoryItem> RequestInventoryItem;
extern RelocAddr <_CreateDuplicateForm> CreateDuplicateForm;
extern RelocAddr <_SetDelete> SetDeleteForm;
extern RelocAddr <uintptr_t> s_BGSObjectInstanceExtraVtbl;
extern RelocAddr <uintptr_t> s_ExtraUniqueIDVtbl;
extern RelocAddr <uintptr_t> s_ExtraModRankVtbl;
extern RelocAddr <uintptr_t> s_ExtraRankVtbl;
extern RelocAddr <uintptr_t> s_ExtraAmmoVtbl;
extern RelocAddr <_EquipItem> EquipItemInternal;
extern RelocAddr <_UnEquipItem> UnequipItemInternal;
extern RelocAddr <_HasPerkInternal> HasPerkInternal;
extern RelocAddr <_AddItem_Native> AddItemNative;
extern RelocAddr <_RemoveItem_Native> RemoveItemNative;
extern RelocAddr <_SetAnimationVariableBool> SetAnimationVariableBoolInternal;
extern RelocAddr <_SetAnimationVariableInt> SetAnimationVariableIntInternal;
extern RelocAddr <_SetAnimationVariableFloat> SetAnimationVariableFloatInternal;
extern RelocAddr <_GetAnimationVariableBool> GetAnimationVariableBoolInternal;
extern RelocAddr <_GetAnimationVariableInt> GetAnimationVariableIntInternal;
extern RelocAddr <_GetAnimationVariableFloat> GetAnimationVariableFloatInternal;
extern RelocAddr <_PlayIdle> PlayIdleInternal; //0x13863A0
extern RelocAddr <_PlayIdle2> PlayIdleInternal2;
extern RelocAddr <_PlaySoundVM> PlaySoundVM;
extern RelocAddr <_PlaySoundInt> PlaySoundInt;
extern RelocAddr <_PlayIdleAction> PlayIdleActionInternal; //0x13864A0
extern RelocAddr <_PlaySubgraphAnimation> PlaySubgraphAnimationInternal; //0x138A130
extern RelocAddr <_InitializeActorInstant> InitializeActorInstant;
extern RelocAddr <_UpdateAnimation> UpdateAnimation;
extern RelocAddr <_PlayEquipSound> PlayEquipSound;
extern RelocAddr <_ChangeAnimArchetype> ChangeAnimArchetype; //1387C10(vm*,0,actor*,kw*)
extern RelocAddr <_ChangeAnimFlavor> ChangeAnimFlavor; //1387CA0(vm*,0,actor*,kw*)
extern RelocAddr <_CheckKeywordType> CheckKeywordType;
extern RelocAddr <_IsInIronSights> IsInIronSights;
extern RelocAddr <_IsInPowerArmor> IsInPowerArmor;
extern RelocAddr <_DrawWeapon> DrawWeaponInternal;
extern RelocAddr <_UseAmmo> FireWeaponInternal;
extern RelocAddr <_EjectShellCasing> EjectShellCasing;
extern RelocAddr <_ReloadWeapon> ReloadWeaponInternal;
extern RelocAddr <_ShowNotification> ShowNotification;
extern RelocAddr <_GetKeywordFromValueArray> GetKeywordFromValueArray;
extern RelocAddr <_AttachRemoveModInternal> AttachRemoveModInternal;
extern RelocAddr <_EquipItemPapyrus> EquipItemPapyrus;
extern RelocAddr <_AttachModToInventoryItem> AttachModToInventoryItem_Internal;
extern RelocAddr <_AttachModToStack> AttachRemoveModStack;
extern RelocAddr <_ModifyStackData> ModifyStackData;
extern RelocAddr <_UpdMidProc> UpdateMiddleProcess;
extern RelocAddr <_UpdateEquipData> UpdateEquipData;
extern RelocAddr <_UpdateAnimGraph> UpdateAnimGraph;
extern RelocAddr <_PlayEquipAction> PlayEquipAction;
extern RelocAddr <_UpdateEnchantments> UpdateEnchantments;
extern RelocAddr <_UpdateAVModifiers> UpdateAVModifiers;
extern RelocAddr <_UpdateAnimValueFloat> UpdateAnimValueFloat;
extern RelocAddr <_EquipHandler> EquipHandler;
extern RelocAddr <_UniversalEquipHandler> UniversalEquipHandler;
extern RelocAddr <_UnkSub_EFF9D0> UnkSub_EFF9D0;
extern RelocAddr <_UnkSub_DFE930> UnkSub_DFE930;
extern RelocAddr <_MainEquipHandler> MainEquipHandler;
extern RelocAddr <_NiStuff> NiStuff;
extern RelocAddr <_UpdateEquippedWeaponData> UpdateEquippedWeaponData;
extern RelocAddr <_CreateInstanceModsFromTemplate> CreateInstanceModsFromTemplate;
extern RelocAddr <_BGSObjectInstanceExtra_ctor> BGSObjectInstanceExtra_ctor;
extern RelocAddr <_AttachMod> AttachMod;
extern RelocAddr <_AddMod> AddMod;
extern RelocAddr <_RemoveMod> RemoveMod;
extern RelocAddr <_RemoveInvalidMods> RemoveInvalidMods;
extern RelocAddr <_LoadMovieEx> LoadMovieEx;
extern RelocPtr <void*> g_pipboyInventoryData;
extern RelocPtr <void*> g_CheckStackIDFunctor;
extern RelocPtr <void*> g_ModifyModDataFunctor;
extern RelocPtr <void*> g_ApplyChangesFunctor;
extern RelocPtr <tArray<BGSKeyword*>> g_AttachPointKeywordArray;
extern RelocPtr <tArray<BGSKeyword*>> g_InstantiationKeywordArray;
extern RelocPtr <tArray<BGSKeyword*>> g_ModAssociationKeywordArray;
extern RelocPtr <tArray<BGSKeyword*>> g_AnimArchetypeKeywordArray;
extern RelocPtr <tArray<BGSKeyword*>> g_RecipeFilterKeywordArray;
extern RelocPtr <tArray<BGSKeyword*>> g_AnimFlavorKeywordArray;
extern RelocPtr <void*> g_sightedTransitionAnimValueHolder;
extern RelocPtr <void*> g_reloadSpeedAnimValueHolder;
extern RelocPtr <float> g_reloadSpeedMultiplier;
extern RelocPtr <std::unordered_map<UInt32, TESForm*>> g_FormMap;
extern RelocPtr <BSReadWriteLock*> g_FormMapLock;
extern RelocPtr <BGSInventoryInterface*> g_InventoryInterface;
extern RelocPtr <DWORD> hkLifoAllocator_TLS;
extern RelocPtr <DWORD> unk1_TLS;
extern RelocPtr <void*> hkLifoAllocator_vtbl;
class ModColData
{
public:
enum
{
kFlag_Optional = 1,
kFlag_Unk = 2
};
BGSMod::Attachment::Mod* mod;
UInt8 minlvl;
UInt8 flags;
//UInt16 padA;
//UInt32 padC;
};
enum FormFlags
{
kType_ModCol = 0x80
};
enum ActorStateFlags08
{
kActorState_Sprint = 0x100,
kActorState_Walk = 0x60,
kActorState_Run = 0xA0,
kActorState_Bashing = 0x6000000, //2, 4 or 6
kActorState_Movement = 0xF, //different for directions
kActorState_Freeroam = 0x80000000 //0 when in furniture
};
enum ActorStateFlags0C
{
kWeaponState_Holstered = 0,
kWeaponState_Drawn = 0x2,
kWeaponState_Draw = 0x4,
kWeaponState_Sheathing = 0x8,
kWeaponState_Aim = 0x18000,
kWeaponState_Lowered1stP = 0x08000,
kWeaponState_Lowered3rdP = 0x04000,
kWeaponState_Ready1stP = 0,
kWeaponState_Ready3rdP = 0x14000,