Skip to content

Commit 49a24ec

Browse files
authored
feat: misc ai (#293)
- my magnum opus: `AIProcess`
1 parent 81e1f08 commit 49a24ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1043
-210
lines changed

include/RE/A/AIProcess.h

Lines changed: 254 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,266 @@
11
#pragma once
22

3-
#include "ActorPackage.h"
3+
#include "RE/A/ActorPackage.h"
4+
#include "RE/B/BSFixedString.h"
5+
#include "RE/B/BSLock.h"
6+
#include "RE/B/BSPointerHandle.h"
7+
#include "RE/B/BSTArray.h"
8+
#include "RE/B/BSTList.h"
9+
#include "RE/N/NiPoint3.h"
10+
#include "RE/N/NiSmartPointer.h"
411

512
namespace RE
613
{
7-
struct MiddleLowProcessData;
8-
struct MiddleHighProcessData;
9-
struct HighProcessData;
14+
class ActorKnowledge;
15+
class bhkCharacterController;
16+
class DialogueItem;
17+
class MagicItem;
18+
class ObjectsToAcquire;
19+
class TESBoundObject;
20+
class TESIdleForm;
21+
class TESObjectREFR;
22+
class TESObjectWEAP;
23+
24+
enum class COMMAND_TYPE : std::int32_t
25+
{
26+
kNone = 0,
27+
kCall = 1,
28+
kFollow = 2,
29+
kMove = 3,
30+
kAttack = 4,
31+
kInspect = 5,
32+
kRetrieve = 6,
33+
kStay = 7,
34+
kRelease = 8,
35+
kHeal = 9,
36+
kAssign = 10,
37+
kRide = 11,
38+
kEnter = 12,
39+
};
40+
41+
struct HighProcessData
42+
{
43+
enum class FADE_STATE : std::int32_t
44+
{
45+
kNormal = 0,
46+
kIn = 1,
47+
kOut = 2,
48+
kTeleportIn = 3,
49+
kTeleportOut = 4,
50+
kOutDisable = 5,
51+
kOutDelete = 6
52+
};
53+
54+
// members
55+
std::byte pad000[0x13C]; // 000
56+
FADE_STATE fadeState; // 13C
57+
std::byte pad140[0x1B8]; // 140
58+
BSFixedStringCS strVoiceSubtitle; // 2F8
59+
std::byte pad300[0x14]; // 300
60+
BSReadWriteLock knowledgeLock; // 314
61+
std::byte pad31C[0x2E]; // 31C
62+
NiPoint3 deathForceDirection; // 34C
63+
float deathForce; // 358
64+
std::byte pad35C[0x28]; // 35C
65+
float packageEvalTimer; // 384
66+
float useItemTimer; // 388
67+
float procedureEvalTimer; // 38C
68+
std::byte pad390[0x40]; // 390
69+
float greetingTimer; // 3D0
70+
std::byte pad3D4[0x4]; // 3D4
71+
float idleTimer; // 3D8
72+
std::byte pad3DC[0x2C]; // 3DC
73+
TESIdleForm* idleToPlay; // 408
74+
std::byte pad410[0x8]; // 410
75+
TESPackage* commandPackage; // 418
76+
std::byte pad420[0x18]; // 420
77+
BSPointerHandle<TESObjectREFR> idleTarget; // 438
78+
std::byte pad43C[0x4]; // 43C
79+
DialogueItem* greetTopic; // 440
80+
std::byte pad448[0x30]; // 448
81+
float lightLevel; // 478
82+
std::byte pad47C[0x84]; // 47C
83+
float tryTalkIdleTimer; // 500
84+
std::uint16_t tryTalk; // 504
85+
std::byte pad506[0xA]; // 506
86+
COMMAND_TYPE commandType; // 510
87+
std::byte pad514[0x47]; // 514
88+
bool greetingFlag; // 55B
89+
bool pickNewIdle; // 55C
90+
bool skipVoiceEndIdleStop; // 55D
91+
bool weaponAlertDrawn; // 55E
92+
bool dialoguewithPlayer; // 55F
93+
bool inCommandState; // 560
94+
bool inWorkshopCommandState; // 561
95+
bool continuingPackageForPC; // 562
96+
bool activateAnim; // 563
97+
bool stop; // 564
98+
std::byte pad562[0x18]; // 562
99+
bool playerActivated; // 57D
100+
bool itemEquipQueued; // 57E
101+
bool doingCommand; // 57F
102+
bool capLineFired; // 580
103+
std::byte pad581[0x2]; // 581
104+
bool processingForceEquip; // 583
105+
bool capLinePlaying; // 584
106+
};
107+
static_assert(offsetof(HighProcessData, fadeState) == 0x13C);
108+
static_assert(offsetof(HighProcessData, strVoiceSubtitle) == 0x2F8);
109+
static_assert(offsetof(HighProcessData, knowledgeLock) == 0x314);
110+
static_assert(offsetof(HighProcessData, deathForceDirection) == 0x34C);
111+
static_assert(offsetof(HighProcessData, packageEvalTimer) == 0x384);
112+
static_assert(offsetof(HighProcessData, idleTimer) == 0x3D8);
113+
static_assert(offsetof(HighProcessData, idleToPlay) == 0x408);
114+
static_assert(offsetof(HighProcessData, greetTopic) == 0x440);
115+
static_assert(offsetof(HighProcessData, lightLevel) == 0x478);
116+
static_assert(offsetof(HighProcessData, tryTalkIdleTimer) == 0x500);
117+
static_assert(offsetof(HighProcessData, commandType) == 0x510);
118+
static_assert(offsetof(HighProcessData, pickNewIdle) == 0x55C);
119+
static_assert(offsetof(HighProcessData, inCommandState) == 0x560);
120+
static_assert(offsetof(HighProcessData, stop) == 0x564);
121+
static_assert(offsetof(HighProcessData, playerActivated) == 0x57D);
122+
static_assert(offsetof(HighProcessData, capLineFired) == 0x580);
123+
static_assert(offsetof(HighProcessData, capLinePlaying) == 0x584);
124+
125+
struct MiddleLowProcessData
126+
{
127+
// members
128+
std::int32_t hourPackageEvaluated; // 00
129+
};
130+
131+
struct MiddleHighProcessData
132+
{
133+
// members
134+
std::byte pad000[0x38]; // 000
135+
ActorPackage runOncePackage; // 038
136+
std::byte pad068[0x200]; // 068
137+
BSReadWriteLock equippedItemsLock; // 268
138+
std::byte pad270[0x1B4]; // 270
139+
BSPointerHandle<TESObjectREFR> currentFurniture; // 424
140+
BSPointerHandle<TESObjectREFR> occupiedFurniture; // 428
141+
std::byte pad42C[0x1C]; // 42C
142+
MagicItem* currentPackageSpell; // 448
143+
TESObjectWEAP* lastBoundWeapon; // 450
144+
NiPointer<bhkCharacterController> charController; // 458
145+
std::byte pad460[0xA8]; // 460
146+
std::uint32_t deferredKill; // 508
147+
std::byte pad50C[0x74]; // 50C
148+
std::int16_t animActionSuccess; // 580
149+
std::byte pad582[0x7]; // 582
150+
bool aimingTarget; // 589
151+
bool doneClothesChange; // 58A
152+
std::byte pad58B[0x6]; // 58B
153+
bool playedBeginIdles; // 591
154+
std::byte pad592[0x7]; // 592
155+
bool eating; // 599
156+
bool calcLight; // 59A
157+
std::byte pad59B[0x6]; // 59B
158+
bool killQueued; // 5A1
159+
bool ragdollInstant; // 5A2
160+
bool scriptDeferredKill; // 5A3
161+
bool furnitureEntryLeftFootFirst; // 5A4
162+
bool furnitureAnimationPlayed; // 5A5
163+
bool queuedInstantInteractionAnimation; // 5A6
164+
bool queuedModifyInitialAnimationPose; // 5A7
165+
bool avoidPlayer; // 5A8
166+
};
167+
static_assert(offsetof(MiddleHighProcessData, runOncePackage) == 0x38);
168+
static_assert(offsetof(MiddleHighProcessData, equippedItemsLock) == 0x268);
169+
static_assert(offsetof(MiddleHighProcessData, currentFurniture) == 0x424);
170+
static_assert(offsetof(MiddleHighProcessData, occupiedFurniture) == 0x428);
171+
static_assert(offsetof(MiddleHighProcessData, currentPackageSpell) == 0x448);
172+
static_assert(offsetof(MiddleHighProcessData, charController) == 0x458);
173+
static_assert(offsetof(MiddleHighProcessData, deferredKill) == 0x508);
174+
static_assert(offsetof(MiddleHighProcessData, animActionSuccess) == 0x580);
175+
static_assert(offsetof(MiddleHighProcessData, doneClothesChange) == 0x58A);
176+
static_assert(offsetof(MiddleHighProcessData, playedBeginIdles) == 0x591);
177+
static_assert(offsetof(MiddleHighProcessData, calcLight) == 0x59A);
178+
static_assert(offsetof(MiddleHighProcessData, killQueued) == 0x5A1);
179+
static_assert(offsetof(MiddleHighProcessData, avoidPlayer) == 0x5A8);
10180

11-
// F8
12181
class AIProcess
13182
{
14183
public:
15-
MiddleLowProcessData* middleLow; // 00
16-
MiddleHighProcessData* middleHigh; // 08
17-
HighProcessData* high; // 10
18-
ActorPackage currentPackage; // 18
19-
float hourLastProcessed; // 48
20-
std::uint32_t unk4C; // 4C
21-
std::uint64_t unk50; // 50
22-
std::uint64_t unk58; // 58
23-
std::uint64_t unk60; // 60
24-
std::uint64_t unk68; // 68
25-
std::uint64_t unk70; // 70
26-
std::uint64_t unk78; // 78
27-
std::uint64_t unk80; // 80
28-
std::uint64_t unk88; // 88
29-
std::uint64_t unk90; // 90
30-
std::uint64_t unk98; // 98
31-
std::uint64_t unkA0; // A0
32-
std::uint64_t unkA8; // A8
33-
std::uint64_t unkB0; // B0
34-
std::uint64_t unkB8; // B8
35-
std::uint64_t unkC0; // C0
36-
std::uint64_t unkC8; // C8
37-
std::uint64_t unkD0; // D0
38-
std::uint64_t unkD8; // D8
39-
std::uint64_t unkE0; // E0
40-
std::uint64_t unkE8; // E8
41-
std::uint64_t unkF0; // F0
184+
float GetActorLightLevel() const
185+
{
186+
return high ? high->lightLevel : 0.0f;
187+
}
188+
189+
ActorPackage* GetActorPackage()
190+
{
191+
return std::addressof(currentPackage);
192+
}
193+
194+
ActorPackage* GetActorPackageRunning()
195+
{
196+
if (middleHigh && middleHigh->runOncePackage.package)
197+
return std::addressof(middleHigh->runOncePackage);
198+
199+
return std::addressof(currentPackage);
200+
}
201+
202+
bool GetCommandState() const
203+
{
204+
return high && high->inCommandState;
205+
}
206+
207+
bool GetCommandWorkshopState() const
208+
{
209+
return high && high->inWorkshopCommandState;
210+
}
211+
212+
COMMAND_TYPE GetCommandType() const
213+
{
214+
return high ? high->commandType : COMMAND_TYPE::kNone;
215+
}
216+
217+
bool IsPlayingPCap() const
218+
{
219+
return high && high->capLinePlaying;
220+
}
221+
222+
bool IsRunningRunOnce() const
223+
{
224+
return middleHigh && middleHigh->runOncePackage.package;
225+
}
226+
227+
// members
228+
MiddleLowProcessData* middleLow; // 00
229+
MiddleHighProcessData* middleHigh; // 08
230+
HighProcessData* high; // 10
231+
ActorPackage currentPackage; // 18
232+
float hourLastProcessed; // 48
233+
float timeAdjustmentsMade; // 4C
234+
std::uint64_t unk50; // 50
235+
std::uint64_t unk58; // 58
236+
std::uint64_t unk60; // 60
237+
BSSimpleList<ObjectsToAcquire*> objectList; // 68
238+
BSSimpleList<TESObjectREFR*> genericLocationsList; // 78
239+
ObjectsToAcquire* acquireObject; // 88
240+
ObjectsToAcquire* savedAcquireObject; // 90
241+
std::uint64_t unk98; // 98
242+
std::uint64_t unkA0; // A0
243+
std::uint64_t unkA8; // A8
244+
std::uint64_t unkB0; // B0
245+
TESBoundObject* itemBeingUsed; // B8
246+
BSPointerHandle<TESObjectREFR> followTarget; // C0
247+
BSPointerHandle<TESObjectREFR> target; // C4
248+
std::uint64_t unkC8; // C8
249+
std::uint64_t unkD0; // D0
250+
std::uint64_t unkD8; // D8
251+
std::byte unkE0[0x6]; // E0
252+
std::uint8_t lowProcessFlags; // E6
253+
std::uint8_t unkE7; // E7
254+
std::byte padE8[0x3]; // E8
255+
bool ignoringCombat; // EB
256+
std::byte padEC[0x5]; // EC
257+
bool escortingPlayer; // F1
258+
std::byte padF2[0x6]; // F2
42259
};
43260
static_assert(sizeof(AIProcess) == 0xF8);
261+
static_assert(offsetof(AIProcess, objectList) == 0x68);
262+
static_assert(offsetof(AIProcess, acquireObject) == 0x88);
263+
static_assert(offsetof(AIProcess, lowProcessFlags) == 0xE6);
264+
static_assert(offsetof(AIProcess, ignoringCombat) == 0xEB);
265+
static_assert(offsetof(AIProcess, escortingPlayer) == 0xF1);
44266
}

include/RE/A/AITimeStamp.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#pragma once
2+
3+
namespace RE
4+
{
5+
class AITimeStamp
6+
{
7+
public:
8+
// members
9+
float timeStamp{ -3.4028235e38f }; // 00
10+
};
11+
static_assert(sizeof(AITimeStamp) == 0x4);
12+
}

0 commit comments

Comments
 (0)