-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplugin.cpp
More file actions
670 lines (524 loc) · 21.4 KB
/
plugin.cpp
File metadata and controls
670 lines (524 loc) · 21.4 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
#include <SimpleIni.h>
#include <spdlog/sinks/basic_file_sink.h>
namespace logger = SKSE::log;
using namespace RE;
using namespace RE::BSScript;
using namespace SKSE;
using namespace SKSE::stl;
const bool IS_DEBUG = false;
const int ACTION_MAX_RETRY = 4;
const uint64_t DUAL_ATTACK_TIME_DIFF = 130;
const int POWER_ATTACK_MIN_HOLD_TIME = 440;
const int VIBRATION_STRENGTH = 25;
const int DEFAULT_LEFT_BUTTON = 280;
const int DEFAULT_RIGHT_BUTTON = 281;
bool isEnabled = true;
bool isSoundEnabled = true;
bool isVibrationEnabled = true;
float minPowerAttackHoldMs = 0.44f;
float vibrationStrength = 0.25f;
uint64_t leftButton = DEFAULT_LEFT_BUTTON;
uint64_t rightButton = DEFAULT_RIGHT_BUTTON;
bool isMouseReversed = false;
bool dualWieldParryCompatibility = false;
const TaskInterface* tasks = NULL;
BSAudioManager* audioManager = NULL;
BGSSoundDescriptorForm* powerAttackSound;
BGSAction* actionRightAttack;
BGSAction* actionLeftAttack;
BGSAction* actionDualAttack;
BGSAction* actionRightPowerAttack;
BGSAction* actionLeftPowerAttack;
BGSAction* actionDualPowerAttack;
BGSAction* actionLeftRelease;
BGSAction* actionRightRelease;
float leftHoldTime = 0.0f;
float rightHoldTime = 0.0f;
uint64_t leftLastTime = 0;
uint64_t rightLastTime = 0;
bool isLeftDualHeld = false;
bool isRightDualHeld = false;
bool leftAltBehavior = false;
bool rightAltBehavior = false;
bool isLeftAttackIndicated = false;
bool isRightAttackIndicated = false;
void SetIsAttackIndicated(bool isLeft, bool value) {
if (isLeft) {
isLeftAttackIndicated = value;
} else {
isRightAttackIndicated = value;
}
}
void SetupLog() {
auto logsFolder = SKSE::log::log_directory();
if (!logsFolder) SKSE::stl::report_and_fail("SKSE log_directory not provided, logs disabled.");
auto pluginName = SKSE::PluginDeclaration::GetSingleton()->GetName();
auto logFilePath = *logsFolder / std::format("{}.log", pluginName);
auto log = std::make_shared<spdlog::logger>(
"Global", std::make_shared<spdlog::sinks::basic_file_sink_mt>(logFilePath.string(), true));
log->set_level(spdlog::level::trace);
log->flush_on(spdlog::level::trace);
spdlog::set_default_logger(std::move(log));
}
long Limit(long min, long value, long max) {
if (value < min) {
return min;
}
if (value > max) {
return max;
}
return value;
}
int LimitGamepadButton(int value, int defaultValue) {
if (value < 266 || value > 281) {
return defaultValue;
}
return value;
}
void LoadSettings() {
constexpr auto path = L"Data/SKSE/Plugins/HoldPowerAttackNG.ini";
CSimpleIniA ini;
ini.SetUnicode();
ini.LoadFile(path);
isEnabled = ini.GetBoolValue("Settings", "Enabled", true);
isSoundEnabled = ini.GetBoolValue("Settings", "Sound", true);
isVibrationEnabled = ini.GetBoolValue("Settings", "Vibration", true);
minPowerAttackHoldMs = ini.GetLongValue("Settings", "MinPowerAttackHoldMs", POWER_ATTACK_MIN_HOLD_TIME) / 1000.0f;
vibrationStrength = Limit(0, ini.GetLongValue("Settings", "VibrationStrength", VIBRATION_STRENGTH), 200) / 100.0f;
leftButton =
LimitGamepadButton(ini.GetLongValue("Buttons", "OverrideLeftButton", DEFAULT_LEFT_BUTTON), DEFAULT_LEFT_BUTTON);
rightButton =
LimitGamepadButton(ini.GetLongValue("Buttons", "OverrideRightButton", DEFAULT_RIGHT_BUTTON), DEFAULT_RIGHT_BUTTON);
isMouseReversed = ini.GetBoolValue("Buttons", "ReverseMouseButtons", false);
dualWieldParryCompatibility = ini.GetBoolValue("Compatibility", "BorgutDualWieldParry", false);
ini.SetBoolValue("Settings", "Enabled", isEnabled);
ini.SetBoolValue("Settings", "Sound", isSoundEnabled);
ini.SetBoolValue("Settings", "Vibration", isVibrationEnabled);
ini.SetLongValue("Settings", "MinPowerAttackHoldMs", (long)(minPowerAttackHoldMs * 1000.0f));
ini.SetLongValue("Settings", "VibrationStrength", (long)(vibrationStrength * 100.0f));
ini.SetLongValue("Buttons", "OverrideLeftButton", (long)leftButton);
ini.SetLongValue("Buttons", "OverrideRightButton", (long)rightButton);
ini.SetBoolValue("Buttons", "ReverseMouseButtons", isMouseReversed);
ini.SetBoolValue("Compatibility", "BorgutDualWieldParry", dualWieldParryCompatibility);
(void)ini.SaveFile(path);
}
uint64_t AbsDiff(uint64_t left, uint64_t right) {
if (right > left) {
return right - left;
}
return left - right;
}
float Max(float left, float right) {
if (left > right) {
return left;
}
return right;
}
float Min(float left, float right) {
if (left < right) {
return left;
}
return right;
}
uint64_t TimeMillisec() {
using namespace std::chrono;
return duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
}
bool IsActionDualAttack(BGSAction* action) {
return action == actionDualAttack || action == actionDualPowerAttack;
}
void PerformAction(BGSAction* action, Actor* actor, int index) {
if (tasks == NULL) {
logger::info("Tasks not initialized.");
return;
}
tasks->AddTask([action, actor, index]() {
std::unique_ptr<TESActionData> data(TESActionData::Create());
data->source = NiPointer<TESObjectREFR>(actor);
data->action = action;
typedef bool func_t(TESActionData*);
REL::Relocation<func_t> func{RELOCATION_ID(40551, 41557)};
bool succ = func(data.get());
if (!succ && index >= ACTION_MAX_RETRY && IS_DEBUG) {
logger::info("Failed to perform action.");
}
if (!succ && index < ACTION_MAX_RETRY) {
std::thread thread([action, actor, index]() {
std::this_thread::sleep_for(std::chrono::milliseconds(200));
if (IS_DEBUG) {
logger::info("What.");
}
PerformAction(action, actor, index + 1);
});
thread.detach();
}
});
}
void PerformActionWithDelay(BGSAction* action, Actor* actor, int index) {
std::thread thread([action, actor, index]() {
std::this_thread::sleep_for(std::chrono::milliseconds(100));
PerformAction(action, actor, index);
});
thread.detach();
}
void PerformAction(BGSAction* action, Actor* actor, bool isPowerAttack) {
int index = isPowerAttack ? 0 : ACTION_MAX_RETRY;
if (dualWieldParryCompatibility && IsActionDualAttack(action)) {
PerformActionWithDelay(action, actor, index);
return;
}
PerformAction(action, actor, index);
}
void PlayDebugSound(BGSSoundDescriptorForm* sound, PlayerCharacter* player) {
if (!isSoundEnabled) {
return;
}
if (!audioManager || !sound) {
logger::info("Audio manager: {0}, sound {1}", audioManager != NULL, sound != NULL);
return;
}
BSSoundHandle handle;
audioManager->BuildSoundDataFromDescriptor(handle, sound->soundDescriptor);
handle.SetVolume(1.0f);
handle.SetObjectToFollow(player->Get3D());
handle.Play();
}
static void VibrateImp(std::int32_t type, float power, float duration) {
using func_t = decltype(&VibrateImp);
REL::Relocation<func_t> func{REL::RelocationID(67220, 68528)};
func(type, power, duration);
}
static void Vibrate(float power, float duration) {
VibrateImp(0, power, duration);
VibrateImp(1, power, duration);
}
uint32_t GamepadKeycode(uint32_t dxScanCode) {
int dxGamepadKeycode = -1;
RE::BSWin32GamepadDevice::Key gamepadKey = static_cast<RE::BSWin32GamepadDevice::Key>(dxScanCode);
switch (gamepadKey) {
case RE::BSWin32GamepadDevice::Key::kUp:
dxGamepadKeycode = 266;
break;
case RE::BSWin32GamepadDevice::Key::kDown:
dxGamepadKeycode = 267;
break;
case RE::BSWin32GamepadDevice::Key::kLeft:
dxGamepadKeycode = 268;
break;
case RE::BSWin32GamepadDevice::Key::kRight:
dxGamepadKeycode = 269;
break;
case RE::BSWin32GamepadDevice::Key::kStart:
dxGamepadKeycode = 270;
break;
case RE::BSWin32GamepadDevice::Key::kBack:
dxGamepadKeycode = 271;
break;
case RE::BSWin32GamepadDevice::Key::kLeftThumb:
dxGamepadKeycode = 272;
break;
case RE::BSWin32GamepadDevice::Key::kRightThumb:
dxGamepadKeycode = 273;
break;
case RE::BSWin32GamepadDevice::Key::kLeftShoulder:
dxGamepadKeycode = 274;
break;
case RE::BSWin32GamepadDevice::Key::kRightShoulder:
dxGamepadKeycode = 275;
break;
case RE::BSWin32GamepadDevice::Key::kA:
dxGamepadKeycode = 276;
break;
case RE::BSWin32GamepadDevice::Key::kB:
dxGamepadKeycode = 277;
break;
case RE::BSWin32GamepadDevice::Key::kX:
dxGamepadKeycode = 278;
break;
case RE::BSWin32GamepadDevice::Key::kY:
dxGamepadKeycode = 279;
break;
case RE::BSWin32GamepadDevice::Key::kLeftTrigger:
dxGamepadKeycode = 280;
break;
case RE::BSWin32GamepadDevice::Key::kRightTrigger:
dxGamepadKeycode = 281;
break;
default:
dxGamepadKeycode = static_cast<uint32_t>(-1);
break;
}
return dxGamepadKeycode;
}
bool IsPlayerAttacking(PlayerCharacter* player) {
if (player->AsActorState()->GetSitSleepState() == SIT_SLEEP_STATE::kNormal && !player->IsInKillMove()) {
ATTACK_STATE_ENUM currentState = (player->AsActorState()->actorState1.meleeAttackState);
if (currentState >= ATTACK_STATE_ENUM::kDraw && currentState <= ATTACK_STATE_ENUM::kBash) {
return true;
} else {
return false;
}
}
return false;
}
float GetPlayerStamina(PlayerCharacter* player) {
return player->AsActorValueOwner()->GetActorValue(ActorValue::kStamina);
}
bool IsWeaponValid(TESObjectWEAP* weapon, bool isLeft) {
if (weapon == NULL) {
return false;
}
if (!weapon->IsWeapon() || weapon->IsBow() || weapon->IsCrossbow() || weapon->IsStaff()) {
return false;
}
if (isLeft && (weapon->IsTwoHandedAxe() || weapon->IsTwoHandedSword())) {
return false;
}
return true;
}
bool IsDualWielding(PlayerCharacter* player) {
auto weaponLeft = reinterpret_cast<TESObjectWEAP*>(player->GetEquippedObject(true));
auto weaponRight = reinterpret_cast<TESObjectWEAP*>(player->GetEquippedObject(false));
return IsWeaponValid(weaponLeft, true) && IsWeaponValid(weaponRight, false);
}
bool IsPowerAttackAlt(PlayerCharacter* player, float maxDuration, bool isLeftHandBusy, bool isRightHandBusy, bool isBlocking) {
if (GetPlayerStamina(player) <= 1.0f) {
return false;
}
auto isPowerAttack = maxDuration > minPowerAttackHoldMs;
bool isDualWielding = IsDualWielding(player);
if ((!dualWieldParryCompatibility || !isDualWielding) && (isLeftHandBusy || isRightHandBusy) && !isBlocking) {
isPowerAttack = false;
}
return isPowerAttack;
}
bool IsPowerAttack(PlayerCharacter* player, float maxDuration, bool isOtherHandBusy) {
if (GetPlayerStamina(player) <= 1.0f) {
return false;
}
auto isPowerAttack = maxDuration > minPowerAttackHoldMs;
if (isOtherHandBusy) {
isPowerAttack = false;
}
return isPowerAttack;
}
BGSAction* GetAttackAction(bool isLeft, uint64_t timeDiff, bool isDualWielding, bool isDualHeld, bool isPowerAttack) {
if (isDualWielding && isDualHeld && timeDiff < DUAL_ATTACK_TIME_DIFF) {
return isPowerAttack ? actionDualPowerAttack : actionDualAttack;
}
if (isLeft) {
return isPowerAttack ? actionLeftPowerAttack : actionLeftAttack;
}
return isPowerAttack ? actionRightPowerAttack : actionRightAttack;
}
bool IsEventLeft(ButtonEvent* a_event) {
auto device = a_event->device.get();
auto keyMask = a_event->GetIDCode();
if (device == INPUT_DEVICE::kMouse && keyMask == (uint32_t)(isMouseReversed ? 0 : 1)) return true;
if (device == INPUT_DEVICE::kGamepad && GamepadKeycode(keyMask) == leftButton) return true;
return false;
}
bool IsButtonEventValid(ButtonEvent* a_event) {
if (!isEnabled) {
return false;
}
auto device = a_event->device.get();
auto keyMask = a_event->GetIDCode();
if ((device != INPUT_DEVICE::kMouse && device != INPUT_DEVICE::kGamepad) ||
(device == INPUT_DEVICE::kGamepad && GamepadKeycode(keyMask) != leftButton && GamepadKeycode(keyMask) != rightButton) ||
(device == INPUT_DEVICE::kMouse && keyMask != 0 && keyMask != 1)) {
return false;
}
return true;
}
bool IsEventValid(ButtonEvent* a_event) {
if (!isEnabled) {
return false;
}
if (!IsButtonEventValid(a_event)) {
return false;
}
auto isLeft = IsEventLeft(a_event);
const auto gameUI = UI::GetSingleton();
const auto controlMap = ControlMap::GetSingleton();
if (gameUI == NULL || controlMap == NULL || (gameUI && gameUI->GameIsPaused()) || controlMap == NULL) {
return false;
}
const auto player = PlayerCharacter::GetSingleton();
if (player == NULL || player->IsInKillMove()) {
return false;
}
auto playerState = player->AsActorState();
if (playerState == NULL || (playerState && (playerState->GetWeaponState() != WEAPON_STATE::kDrawn ||
playerState->GetSitSleepState() != SIT_SLEEP_STATE::kNormal ||
playerState->GetKnockState() != KNOCK_STATE_ENUM::kNormal ||
playerState->GetFlyState() != FLY_STATE::kNone))) {
return false;
}
auto weaponLeft = reinterpret_cast<TESObjectWEAP*>(player->GetEquippedObject(true));
auto weaponRight = reinterpret_cast<TESObjectWEAP*>(player->GetEquippedObject(false));
if (dualWieldParryCompatibility && IsWeaponValid(weaponLeft, true) && !IsWeaponValid(weaponRight, false)) {
return false;
}
auto weapon = isLeft ? weaponLeft : weaponRight;
return IsWeaponValid(weapon, isLeft);
}
// Fired when the user presses the attack or block key
class HookAttackBlockHandler {
public:
typedef void (HookAttackBlockHandler::*FnProcessButton)(ButtonEvent*, void*);
void ProcessButton(ButtonEvent* a_event, void* a_data) {
FnProcessButton fn = fnHash.at(*(uintptr_t*)this);
if (IsEventValid(a_event)) {
ProcessEvent(a_event, a_data, fn);
return;
}
if (IsButtonEventValid(a_event)) {
auto isLeft = IsEventLeft(a_event);
if (isLeft) {
leftAltBehavior = a_event->IsHeld();
} else {
rightAltBehavior = a_event->IsHeld();
}
auto isAltBehavior = isLeft ? leftAltBehavior : rightAltBehavior;
if (isAltBehavior) {
SetIsAttackIndicated(isLeft, false);
}
}
if (fn) (this->*fn)(a_event, a_data);
}
static void Hook() {
REL::Relocation<uintptr_t> vtable{VTABLE_AttackBlockHandler[0]};
FnProcessButton fn =
stl::unrestricted_cast<FnProcessButton>(vtable.write_vfunc(4, &HookAttackBlockHandler::ProcessButton));
fnHash.insert(std::pair<uintptr_t, FnProcessButton>(vtable.address(), fn));
logger::info("Hooked Attack System OK...");
}
private:
static std::unordered_map<uintptr_t, FnProcessButton> fnHash;
void ProcessEventUp(PlayerCharacter* playerCharacter, bool isLeft) {
auto tempLeftHoldTime = leftHoldTime;
auto tempRightHoldTime = rightHoldTime;
auto tempIsLeftDualHeld = isLeftDualHeld;
auto tempIsRightDualHeld = isRightDualHeld;
auto isDualWielding = IsDualWielding(playerCharacter);
auto shouldAttack = false;
uint64_t timeDiff = 0;
if (isLeft) {
leftHoldTime = 0.0f;
leftLastTime = TimeMillisec();
isRightDualHeld = false;
shouldAttack = tempRightHoldTime == 0.0f;
} else {
rightHoldTime = 0.0f;
rightLastTime = TimeMillisec();
isLeftDualHeld = false;
shouldAttack = tempLeftHoldTime == 0.0f;
}
timeDiff = AbsDiff(leftLastTime, rightLastTime);
bool isBlocking = false;
playerCharacter->GetGraphVariableBool("IsBlocking", isBlocking);
if (shouldAttack || (timeDiff == 0 && isLeft)) {
if (timeDiff == 0) {
logger::info("Nice reflex!");
}
SetIsAttackIndicated(isLeft, false);
auto isDualHeld = isLeft ? tempIsRightDualHeld : tempIsLeftDualHeld;
float maxHoldTime = Max(tempLeftHoldTime, tempRightHoldTime);
auto isAttacking = IsPlayerAttacking(playerCharacter);
auto isPowerAttack =
IsPowerAttackAlt(playerCharacter, maxHoldTime, leftAltBehavior, rightAltBehavior, isBlocking);
auto attackAction = GetAttackAction(isLeft, timeDiff, isDualWielding, isDualHeld, false);
// Borgut Dual Wield Parry Compatibility
if (dualWieldParryCompatibility && isLeft && isDualWielding && !IsActionDualAttack(attackAction)) {
PerformAction(actionLeftRelease, playerCharacter, false);
return;
}
if (!isPowerAttack || (isPowerAttack && !isAttacking)) {
// Borgut Dual Wield Parry Compatibility
if (dualWieldParryCompatibility && IsActionDualAttack(attackAction)) {
PerformAction(actionLeftRelease, playerCharacter, false);
}
PerformAction(attackAction, playerCharacter, false);
if (!isLeft && !isPowerAttack && isBlocking) {
PerformAction(actionRightRelease, playerCharacter, false);
}
}
if (isPowerAttack && !isAttacking && (!isBlocking || (dualWieldParryCompatibility && isDualWielding))) {
attackAction = GetAttackAction(isLeft, timeDiff, isDualWielding, isDualHeld, true);
PerformAction(attackAction, playerCharacter, true);
}
if (!IsActionDualAttack(attackAction)) {
PerformAction(isLeft ? actionLeftRelease : actionRightAttack, playerCharacter, false);
}
}
}
void TryIndicatePowerAttack(bool isLeft, PlayerCharacter* player) {
float holdTime = isLeft ? leftHoldTime : rightHoldTime;
bool isBlocking = false;
player->GetGraphVariableBool("IsBlocking", isBlocking);
bool isPlayerAttacking = IsPlayerAttacking(player);
bool isPowerAttack = IsPowerAttackAlt(player, holdTime, leftAltBehavior, rightAltBehavior, isBlocking);
if (!isPlayerAttacking && isPowerAttack) {
if (isLeftAttackIndicated || isRightAttackIndicated) {
return;
}
SetIsAttackIndicated(isLeft, true);
PlayDebugSound(powerAttackSound, player);
Vibrate(vibrationStrength, 0.24f);
} else {
SetIsAttackIndicated(isLeft, false);
}
}
void ProcessEvent(ButtonEvent* buttonEvent, void* buttonData, FnProcessButton fn) {
const auto playerCharacter = PlayerCharacter::GetSingleton();
auto isLeft = IsEventLeft(buttonEvent);
if (buttonEvent->IsDown() || buttonEvent->IsHeld()) {
if (isLeft) {
leftHoldTime = buttonEvent->HeldDuration();
leftAltBehavior = false;
isRightDualHeld = isRightDualHeld || rightHoldTime > 0.0f;
} else {
rightHoldTime = buttonEvent->HeldDuration();
rightAltBehavior = false;
isLeftDualHeld = isLeftDualHeld || leftHoldTime > 0.0f;
}
TryIndicatePowerAttack(isLeft, playerCharacter);
if (dualWieldParryCompatibility && isLeft && IsDualWielding(playerCharacter)) {
if (fn) (this->*fn)(buttonEvent, buttonData);
}
}
if (buttonEvent->IsUp()) {
ProcessEventUp(playerCharacter, isLeft);
}
}
};
std::unordered_map<uintptr_t, HookAttackBlockHandler::FnProcessButton> HookAttackBlockHandler::fnHash;
void OnMessage(SKSE::MessagingInterface::Message* message) {
if (message->type == SKSE::MessagingInterface::kDataLoaded) {
actionRightAttack = (BGSAction*)TESForm::LookupByID(0x13005);
actionLeftAttack = (BGSAction*)TESForm::LookupByID(0x13004);
actionDualAttack = (BGSAction*)TESForm::LookupByID(0x50c96);
actionRightPowerAttack = (BGSAction*)TESForm::LookupByID(0x13383);
actionLeftPowerAttack = (BGSAction*)TESForm::LookupByID(0x2e2f6);
actionDualPowerAttack = (BGSAction*)TESForm::LookupByID(0x2e2f7);
actionLeftRelease = (BGSAction*)TESForm::LookupByID(0x13451);
actionRightRelease = (BGSAction*)TESForm::LookupByID(0x13454);
powerAttackSound = (BGSSoundDescriptorForm*)TESForm::LookupByID(0x10eb7a);
audioManager = BSAudioManager::GetSingleton();
HookAttackBlockHandler::Hook();
}
}
SKSEPluginLoad(const LoadInterface* skse) {
Init(skse);
SetupLog();
logger::info("Setup log...");
LoadSettings();
logger::info("Settings loaded...");
if (!isEnabled) {
logger::info("Mod is disabled...");
}
tasks = GetTaskInterface();
GetMessagingInterface()->RegisterListener(OnMessage);
return true;
}