-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBase.h
1919 lines (1873 loc) · 68.9 KB
/
Base.h
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 <map>
#include "Base64.h"
#include "MonsterBuff.h"
#include "PlayerBuff.h"
#include "Network.h"
#include "AobAddress.h"
#include "sound/Player.h"
#include <io.h>
#define _USE_MATH_DEFINES
#define sign(x) (((x) < 0) ? -1 : ((x) > 0))
#define M_PI 3.14159265358979323846
#define GUID_LEN 64
using namespace std;
using namespace loader;
extern "C" long long _stdcall Navigation(float*, float*, float*);
extern "C" void* _stdcall GetRAXPtr(void*);
extern "C" void* _stdcall GetRBXPtr(void*);
extern "C" void* _stdcall GetRDIPtr(void*);
extern "C" void* _stdcall GetHitPtr(void*);
extern "C" void* _stdcall SetEDX(float*);
extern "C" void* _stdcall SetR14D(int*);
namespace Base {
//常用结构
struct Vector4 {
float x, y, z, w;
Vector4(float x = 0, float y = 0, float z = 0, float w = 0) :x(x), y(y), z(z), w(w) { };
};
struct Vector3 {
float x, y, z;
Vector3(float x = 0, float y = 0, float z = 0) :x(x), y(y), z(z) { };
};
struct Vector2 {
float x, y;
Vector2(float x = 0, float y = 0) :x(x), y(y) { };
};
#pragma region ModConfig
namespace ModConfig {
//内置参数
bool GameDataInit = false;
bool DrawInit = false;
bool InitErrInfo = true;
int InitErrCount = 0;
vector<string> LuaFiles;
vector<string> LuaError;
bool ModConsole = false;
bool HotKeyEdit = false;
bool About = false;
bool SecurityModel = false;
//可设置参数
string ModName = "LuaScript";
string ModAuthor = "Alcedo";
string ModVersion = "v1.2.9";
long long ModBuild = 129002172340;
string Version = "421471";
}
#pragma endregion
#pragma region LuaHandle
namespace LuaHandle {
struct LuaCodeData {
string name;
string code;
string file;
bool start;
bool hotReload;//hotReload模式下lua会直接读取文件而不通过缓存的数据执行代码
void Update()
{
ifstream ifile(file);
ostringstream buf;
char ch;
while (buf && ifile.get(ch))
buf.put(ch);
code = buf.str();
if (string _Tmpy = "--NotHotReload"; string::npos != code.find(_Tmpy))
hotReload = false;
if (string _Tmpy = "--Disable"; string::npos != code.find(_Tmpy))
start = false;
if (string _Tmpy = "--About"; string::npos != code.find(_Tmpy))
ModConfig::About = true;
};
LuaCodeData(
string name = "",
string code = "",
string file = "",
bool start = true,
bool hotReload = true
) :name(name), code(code), file(file), start(start), hotReload(hotReload) { };
};
vector<string> LuaFiles;
vector<string> LuaError;
map<string, LuaCodeData> LuaCode;
}
#pragma endregion
//游戏基础地址
#pragma region BasicGameData
//游戏基址数据
namespace BasicGameData {
void* PlayerPlot = nullptr;
void* PlayerInfoPlot = nullptr;
void* PlayerDataPlot = nullptr;
void* PlayerArchivePlot = nullptr;
void* OtomoPlot = nullptr;
void* MapPlot = nullptr;
void* GameTimePlot = nullptr;
void* XboxPadPlot = nullptr;
void* Quest = nullptr;
}
#pragma endregion
//世界信息
#pragma region World
namespace World {
//缓存数据
namespace TempData {
float t_SetFrameSpeed = -1;
}
//环境生物
namespace EnvironmentalData {
struct EnvironmentalData {
void* Plot = nullptr;
float CoordinatesX = 0;
float CoordinatesY = 0;
float CoordinatesZ = 0;
int Id = 0;
int SubId = 0;
EnvironmentalData(
void* Plot = nullptr,
float CoordinatesX = 0,
float CoordinatesY = 0,
float CoordinatesZ = 0,
int Id = 0,
int SubId = 0)
:Plot(Plot), CoordinatesX(CoordinatesX), CoordinatesY(CoordinatesY), CoordinatesZ(CoordinatesZ), Id(Id), SubId(SubId) {
};
};
//环境生物列表
map<void*, EnvironmentalData> Environmentals;
//怪物筛选器
pair<int, int> Filter(255, 255);
}
int MapId = 0;
string Massage = "";
map<void*, float> FrameSpeed;
int SteamId = 0;
string Assembly = "";
vector<string> ProcessList;
}
#pragma endregion
//任务信息
#pragma region Quest
namespace Quest {
int NextQuest = -1;
int QuestId = 0;
int QuestState = 0;//0不在任务、1准备中、2任务中、3任务成功、4任务结算、5任务失败
}
#pragma endregion
//计时器
#pragma region Chronoscope
namespace Chronoscope {
struct ChronoscopeData {
float StartTime = 0;
float EndTime = 0;
};
//现在的时间
float NowTime = 0;
//计时器列表
map<string, ChronoscopeData> ChronoscopeList;
//添加计时器(时长,计时器名称,是否覆盖)
static bool AddChronoscope(float duration, string name, bool Overlay = false) {
if (ChronoscopeList.find(name) == ChronoscopeList.end() || Overlay) {
ChronoscopeList[name].EndTime = NowTime + duration;
ChronoscopeList[name].StartTime = NowTime;
return true;
}
else
return false;
}
//删除计时器
static void DelChronoscope(string name) {
if (ChronoscopeList.find(name) != ChronoscopeList.end()) {
ChronoscopeList.erase(name);
}
}
//检查计时器是否存在
static bool CheckPresenceChronoscope(string name) {
if (ChronoscopeList.find(name) != ChronoscopeList.end()) {
return true;
}
return false;
}
//检查计时器是否结束
static bool CheckChronoscope(string name) {
if (ChronoscopeList.find(name) != ChronoscopeList.end()) {
if (ChronoscopeList[name].EndTime < NowTime) {
DelChronoscope(name);
return true;
}
else
return false;
}
return false;
}
}
#pragma endregion
//计算
#pragma region Calculation
namespace Calculation {
static Vector3 GetVector(Vector3 p1, Vector3 p2, float l) {
float a = (p2.x - p1.x);
float b = (p2.y - p1.y);
float c = (p2.z - p1.z);
l = l * l / (a * a + b * b + c * c);
float k = sqrt(l);
float newx1 = k * a + p1.x;
float newy1 = k * b + p1.y;
float newz1 = k * c + p1.z;
return Vector3(newx1, newy1, newz1);
}
static Vector2 GetExtensionVector2D(Vector2 Coordinate, float r, float angle) {
float x, y;
x = Coordinate.x + r * cos((4 * atan(1.0) / 180 * angle));
y = Coordinate.y + r * sin((4 * atan(1.0) / 180 * angle));
return Vector2(x, y);
}
static float myRander(float min, float max)
{
std::random_device rd;
std::mt19937 eng(rd());
std::uniform_real_distribution<float> dist(min, max);
return dist(eng);
}
static float DistanceBetweenTwoCoordinates(Vector3 point1, Vector3 point2) {
float RangeDistance = sqrt((point1.x - point2.x) * (point1.x - point2.x)) + sqrt((point1.z - point2.z) * (point1.z - point2.z));
RangeDistance = sqrt((RangeDistance * RangeDistance) + sqrt((point1.y - point2.y) * (point1.y - point2.y)));
return RangeDistance;
}
static string GetUUID() {
char buffer[GUID_LEN] = { 0 };
GUID guid;
if (CoCreateGuid(&guid))
{
return "create guid error";
}
_snprintf_s(buffer, sizeof(buffer),
"%08X-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X",
guid.Data1, guid.Data2, guid.Data3,
guid.Data4[0], guid.Data4[1], guid.Data4[2],
guid.Data4[3], guid.Data4[4], guid.Data4[5],
guid.Data4[6], guid.Data4[7]);
return buffer;
}
Vector3 inline ToEulerAngles(Vector4 quaternion)
{
Vector3 eulerangles;
// roll (x-axis rotation)
float sinr_cosp = 2 * (quaternion.w * quaternion.x + quaternion.y * quaternion.z);
float cosr_cosp = 1 - 2 * (quaternion.x * quaternion.x + quaternion.y * quaternion.y);
eulerangles.x = std::atan2(sinr_cosp, cosr_cosp);
// pitch (y-axis rotation)
float sinp = 2 * (quaternion.w * quaternion.y - quaternion.z * quaternion.x);
if (std::abs(sinp) >= 1)
eulerangles.y = std::copysign(M_PI / 2, sinp);
else
eulerangles.y = std::asin(sinp);
// yaw (z-axis rotation)
float siny_cosp = 2 * (quaternion.w * quaternion.z + quaternion.x * quaternion.y);
float cosy_cosp = 1 - 2 * (quaternion.y * quaternion.y + quaternion.z * quaternion.z);
eulerangles.z = std::atan2(siny_cosp, cosy_cosp);
return eulerangles;
}
Vector4 inline ToQuaternion(Vector3 eulerangles)
{
float cr = cos(eulerangles.x * 0.5);
float sr = sin(eulerangles.x * 0.5);
float cp = cos(eulerangles.y * 0.5);
float sp = sin(eulerangles.y * 0.5);
float cy = cos(eulerangles.z * 0.5);
float sy = sin(eulerangles.z * 0.5);
Vector4 quaternion;
quaternion.w = cy * cp * cr + sy * sp * sr;
quaternion.x = cy * cp * sr - sy * sp * cr;
quaternion.y = sy * cp * sr + cy * sp * cr;
quaternion.z = sy * cp * cr - cy * sp * sr;
return quaternion;
}
float QuaternionToAngle(Vector4 quaternion)
{
Vector4 input;
input.w = 0;
input.x = quaternion.x;
input.y = 0;
input.z = quaternion.z;
float result = 0 - ToEulerAngles(input).y;
if (ToEulerAngles(input).x == 0)
{
if (result > 0.0)
return result;
else
return result;
}
else
{
if (result > 0.0)
return M_PI - result;
else
return -M_PI - result;
}
}
Vector4 AngleToQuaternion(float angle)//输入与z轴正方向夹角的弧度值,得到对应方向的四元数
{
Vector3 input;
if (angle / M_PI > 0.5)
{
input.x = M_PI;
input.y = angle - M_PI;
input.z = 0;
}
else if (angle / M_PI < -0.5)
{
input.x = M_PI;
input.y = angle + M_PI;
input.z = 0;
}
else
{
input.x = 0;
input.y = -angle;
input.z = M_PI;
}
Vector4 result;
result = ToQuaternion(input);
return result;
}
static unsigned char* Base64ToImg(string Base64Data) {
vector<BYTE> decodedData = base64_decode(Base64Data);
unsigned char* img = new unsigned char[decodedData.size()];
copy(decodedData.begin(), decodedData.end(), img);
return (img);
}
}
#pragma endregion
//图形绘制
#pragma region Draw
namespace Draw {
struct NewImage {
float BgAlpha = 1;
Vector3 Channel = Vector3();
Vector2 Pos = Vector2();
string Name = "";
string ImageFile = "";
bool Base64 = false;
int Width = 0;
int Height = 0;
int DisplayWidth = 0;
int DisplayHeight = 0;
NewImage(
float BgAlpha = 1,
Vector3 Channel = Vector3(1, 1, 1),
Vector2 Pos = Vector2(),
string Name = "",
string ImageFile = "",
bool Base64 = false,
int Width = 0,
int Height = 0,
int DisplayWidth = 0,
int DisplayHeight = 0
) :BgAlpha(BgAlpha), Channel(Channel), Pos(Pos), Name(Name), ImageFile(ImageFile), Base64(Base64), Width(Width), Height(Height), DisplayWidth(DisplayWidth), DisplayHeight(DisplayHeight) { };
};
struct NewText {
float BgAlpha = 1;
Vector3 Color = Vector3();
Vector2 Pos = Vector2();
string Name = "";
string Text = "";
float Size = 1;
NewText(
float BgAlpha = 1,
Vector3 Color = Vector3(1, 1, 1),
Vector2 Pos = Vector2(),
string Name = "",
string Text = "",
float Size = 1
) :BgAlpha(BgAlpha), Color(Color), Pos(Pos), Name(Name), Text(Text), Size(Size) { };
};
map<string, NewImage> Img;
map<string, NewText> Text;
map<string, string> About;
Vector2 MouseDelta = Vector2(0, 0);
}
#pragma endregion
//音频播放
#pragma region SoundPlay
namespace SoundPlay {
vector<string> SoundList;
}
#pragma endregion
//委托
#pragma region Commission
namespace Commission {
namespace MoveEntity {
struct Parameter {
Vector3 Vector;
void* Entity = nullptr;
float speed = 100.0;
};
map<void*, Parameter> CommissionList;
static void MoveEntityToTarget() {
for (auto [entity, parameter] : CommissionList) {
if (entity != nullptr) {
//移动到目标
if (parameter.Entity != nullptr) {
float EntityX = *offsetPtr<float>(entity, 0x160);
float EntityY = *offsetPtr<float>(entity, 0x160);
float EntityZ = *offsetPtr<float>(entity, 0x160);
float ToEntityX = *offsetPtr<float>(parameter.Entity, 0x160);
float ToEntityY = *offsetPtr<float>(parameter.Entity, 0x160);
float ToEntityZ = *offsetPtr<float>(parameter.Entity, 0x160);
if (fabs(ToEntityX - EntityX) > float(10)) {
if (ToEntityX < EntityX)
EntityX -= float(fabs(ToEntityX - EntityX) / 10);
else
EntityX += float(fabs(ToEntityX - EntityX) / 10);
}
else
EntityX = ToEntityX;
if (fabs(ToEntityY - EntityY) > float(10)) {
if (ToEntityY < EntityY)
EntityY -= float(fabs(ToEntityY - EntityY) / parameter.speed);
else
EntityY += float(fabs(ToEntityY - EntityY) / parameter.speed);
}
else
EntityY = ToEntityY;
if (fabs(ToEntityZ - EntityZ) > float(10)) {
if (ToEntityZ < EntityZ)
EntityZ -= float(fabs(ToEntityZ - EntityZ) / 10);
else
EntityZ += float(fabs(ToEntityZ - EntityZ) / 10);
}
else
EntityZ = ToEntityZ;
*offsetPtr<float>(entity, 0x160) = ToEntityX;
*offsetPtr<float>(entity, 0x164) = ToEntityY;
*offsetPtr<float>(entity, 0x168) = ToEntityZ;
if (
*offsetPtr<float>(entity, 0x160) == ToEntityX and
*offsetPtr<float>(entity, 0x164) == ToEntityY and
*offsetPtr<float>(entity, 0x168) == ToEntityZ
)
CommissionList.erase(entity);
}
//移动到点
else {
float EntityX = *offsetPtr<float>(entity, 0x160);
float EntityY = *offsetPtr<float>(entity, 0x160);
float EntityZ = *offsetPtr<float>(entity, 0x160);
float ToEntityX = parameter.Vector.x;
float ToEntityY = parameter.Vector.y;
float ToEntityZ = parameter.Vector.z;
if (EntityX - ToEntityX > 10) {
if (EntityX > ToEntityX)
*offsetPtr<float>(entity, 0x160) -= (EntityX - ToEntityX) / parameter.speed;
else
*offsetPtr<float>(entity, 0x160) += (EntityX - ToEntityX) / parameter.speed;
}
else
*offsetPtr<float>(entity, 0x160) = ToEntityX;
if (EntityY - ToEntityY > 10) {
if (EntityY > ToEntityY)
*offsetPtr<float>(entity, 0x164) -= (EntityY - ToEntityY) / parameter.speed;
else
*offsetPtr<float>(entity, 0x164) += (EntityY - ToEntityY) / parameter.speed;
}
else
*offsetPtr<float>(entity, 0x164) = ToEntityY;
if (EntityZ - ToEntityZ > 10) {
if (EntityZ > ToEntityZ)
*offsetPtr<float>(entity, 0x168) -= (EntityZ - ToEntityZ) / parameter.speed;
else
*offsetPtr<float>(entity, 0x168) += (EntityZ - ToEntityZ) / parameter.speed;
}
else
*offsetPtr<float>(entity, 0x168) = ToEntityZ;
if (
*offsetPtr<float>(entity, 0x160) == ToEntityX and
*offsetPtr<float>(entity, 0x164) == ToEntityY and
*offsetPtr<float>(entity, 0x168) == ToEntityZ
)
CommissionList.erase(entity);
}
}
}
}
}
static void CleanCommission() {
MoveEntity::CommissionList.clear();
}
static void Run() {
MoveEntity::MoveEntityToTarget();
}
}
#pragma endregion
//怪物信息
#pragma region Monster
namespace Monster {
struct MonsterData {
void* Plot;
float CoordinatesX;
float CoordinatesY;
float CoordinatesZ;
int Id;
int SubId;
MonsterData(
void* Plot = nullptr,
float CoordinatesX = 0,
float CoordinatesY = 0,
float CoordinatesZ = 0,
int Id = 0,
int SubId = 0)
:Plot(Plot), CoordinatesX(CoordinatesX), CoordinatesY(CoordinatesY), CoordinatesZ(CoordinatesZ), Id(Id), SubId(SubId) {
};
};
//怪物列表
map<void*, MonsterData> Monsters;
//怪物筛选器
pair<int, int> Filter(255, 255);
//给怪物设置buff
static void SetBuff(void* monster, string buff) {
MonsterBuff::MonsterBuffState monsterBuff = MonsterBuff::GetMonsterBuffState(monster, buff);
if (monsterBuff.MaxStateValue != 0) {
MonsterBuff::SetMonsterBuffState(monster, buff);
}
}
//获取怪物buff状态
static MonsterBuff::MonsterBuffState GetBuff(void* monster, string buff) {
return MonsterBuff::GetMonsterBuffState(monster, buff);
}
//获取怪物buff状态
static void* GetHateTarget(void* monster) {
void* HateTargetOffset1 = *offsetPtr<undefined**>((undefined(*)())monster, 0x98);
void* HateTargetOffset2 = nullptr;
if (HateTargetOffset1 != nullptr)
HateTargetOffset2 = *offsetPtr<undefined**>((undefined(*)())HateTargetOffset1, 0x1B0);
void* HateTargetOffset3 = nullptr;
if (HateTargetOffset2 != nullptr)
HateTargetOffset3 = *offsetPtr<undefined**>((undefined(*)())HateTargetOffset2, 0x8);
void* HateTargetOffset4 = nullptr;
if (HateTargetOffset3 != nullptr)
HateTargetOffset4 = *offsetPtr<undefined**>((undefined(*)())HateTargetOffset3, 0x970);
if (HateTargetOffset4 != nullptr)
return *offsetPtr<void*>(HateTargetOffset4, 0x5D0);
return nullptr;
}
//设置怪物派生动作
static void BehaviorControl(void* monster, int Fsm) {
//感谢南风焓大佬提供的地址
MH::Monster::BehaviorControl((undefined*)monster, Fsm);
}
}
#pragma endregion
//艾露猫信息
#pragma region Otomo
namespace Otomo {
struct OtomoData {
void* Plot;
float CoordinatesX;
float CoordinatesY;
float CoordinatesZ;
OtomoData(
void* Plot = nullptr,
float CoordinatesX = 0,
float CoordinatesY = 0,
float CoordinatesZ = 0
)
:Plot(Plot), CoordinatesX(CoordinatesX), CoordinatesY(CoordinatesY), CoordinatesZ(CoordinatesZ) {
};
};
struct FsmData {
//对象
int Target = 0;
//执行Id
int Id = 0;
FsmData(int Target = 0, int Id = 0) :Target(Target), Id(Id) {
};
};
//坐标
namespace Coordinate {
//玩家坐标
Vector3 Entity = Vector3();
//碰撞返回坐标
Vector3 Collision = Vector3();
//增量坐标
Vector3 Increment = Vector3();
}
//朝向角度
float Angle = 0;
//动作id
int ActionId = 0;
//当前动作帧
float ActionFrame = 0;
float ActionFrameEnd = 0;
float ActionFrameSpeed = 0;
//派生信息
FsmData Fsm = FsmData();
FsmData NowFsm = FsmData();
//执行派生动作(执行对象,执行Id)
static void RunDerivedAction(int type, int id) {
*offsetPtr<int>(BasicGameData::OtomoPlot, 0x6284) = type;
*offsetPtr<int>(BasicGameData::OtomoPlot, 0x6288) = id;
*offsetPtr<int>(BasicGameData::OtomoPlot, 0x628C) = type;
*offsetPtr<int>(BasicGameData::OtomoPlot, 0x6290) = id;
}
//设置当前动作帧
static void SetActionFrame(float Frame) {
void* ActionFramePlot = *offsetPtr<void*>(BasicGameData::OtomoPlot, 0x468);
*offsetPtr<float>(ActionFramePlot, 0x10c) = Frame;
}
//设置朝向角度、坐标
static void SetPlayerAimAngle(float angle)//输入与Z轴正方向夹角
{
Vector4 quaternion = Calculation::AngleToQuaternion(angle);
*offsetPtr<float>(BasicGameData::OtomoPlot, 0x174) = quaternion.x;
*offsetPtr<float>(BasicGameData::OtomoPlot, 0x17C) = quaternion.z;
}
static void SetPlayerAimCoordinate(float aim_x, float aim_z)//输入目标的x轴,z轴坐标
{
float direction_x = (aim_x - Otomo::Coordinate::Entity.x);//目标x轴 减去 人物x轴
float direction_z = (aim_z - Otomo::Coordinate::Entity.z);//目标z轴 减去 人物z轴
float aim_angle = std::atan(direction_x / direction_z);
aim_angle = aim_angle + sign(direction_x) * (1 - sign(direction_z)) * M_PI / 2;
SetPlayerAimAngle(aim_angle);//设置角度
}
//数据更新
static void Updata() {
Coordinate::Entity = Vector3(
*offsetPtr<float>(BasicGameData::OtomoPlot, 0x160),
*offsetPtr<float>(BasicGameData::OtomoPlot, 0x164),
*offsetPtr<float>(BasicGameData::OtomoPlot, 0x168)
);
Coordinate::Collision = Vector3(
*offsetPtr<float>(BasicGameData::OtomoPlot, 0xA50),
*offsetPtr<float>(BasicGameData::OtomoPlot, 0xA54),
*offsetPtr<float>(BasicGameData::OtomoPlot, 0xA58)
);
void* IncrementPlot = *offsetPtr<undefined**>((undefined(*)())BasicGameData::OtomoPlot, 0x468);
if (IncrementPlot != nullptr) {
Coordinate::Increment.x = *offsetPtr<float>(IncrementPlot, 0xE250);
Coordinate::Increment.y = *offsetPtr<float>(IncrementPlot, 0xE254);
Coordinate::Increment.z = *offsetPtr<float>(IncrementPlot, 0xE258);
}
else {
Coordinate::Increment.x = 0.0;
Coordinate::Increment.y = 0.0;
Coordinate::Increment.z = 0.0;
}
Angle = Calculation::QuaternionToAngle(Vector4(
*offsetPtr<float>(BasicGameData::OtomoPlot, 0x174),
*offsetPtr<float>(BasicGameData::OtomoPlot, 0x178),
*offsetPtr<float>(BasicGameData::OtomoPlot, 0x17C),
*offsetPtr<float>(BasicGameData::OtomoPlot, 0x180)
));
void* ActionPlot = *offsetPtr<undefined**>((undefined(*)())BasicGameData::OtomoPlot, 0x468);
if (ActionPlot != nullptr) {
ActionId = *offsetPtr<int>(ActionPlot, 0xE9C4);
}
else {
ActionId = 0;
}
Fsm = FsmData(
*offsetPtr<int>(BasicGameData::OtomoPlot, 0x628C),
*offsetPtr<int>(BasicGameData::OtomoPlot, 0x6290)
);
NowFsm = FsmData(
*offsetPtr<int>(BasicGameData::OtomoPlot, 0x6274),
*offsetPtr<int>(BasicGameData::OtomoPlot, 0x6278)
);
void* ActionFramePlot = *offsetPtr<void*>(BasicGameData::OtomoPlot, 0x468);
if (ActionFramePlot != nullptr) {
ActionFrame = *offsetPtr<float>(ActionFramePlot, 0x10C);
ActionFrameEnd = *offsetPtr<float>(ActionFramePlot, 0x114);
ActionFrameSpeed = *offsetPtr<float>(BasicGameData::OtomoPlot, 0x6c);
}
}
}
#pragma endregion
//玩家信息
#pragma region PlayerData
namespace PlayerData {
struct FsmData {
//对象 0为人物3为武器
int Target = 0;
//执行Id
int Id = 0;
FsmData(int Target = 0, int Id = 0) :Target(Target), Id(Id) {
};
};
//缓存数据
namespace TempData {
FsmData t_ManualFsmAction;
bool t_executingFsmAction = false;
void* t_HookCoordinate = nullptr;
float t_ActionFrameSpeed = 0;
bool t_SetActionFrameSpeed = false;
int t_ActionFrameSpeedTarget = 0;
}
//坐标
namespace Coordinate {
//缓存数据
namespace TempData {
void* t_visual = nullptr;
Vector3 t_SetVisualCoordinate;
void* t_SetVisualBind = nullptr;
bool t_SetVisual = false;
}
//玩家坐标
Vector3 Entity = Vector3();
//准星坐标
Vector3 Collimator = Vector3();
//抛物线准星坐标
Vector3 Parabola = Vector3();
//碰撞返回坐标
Vector3 Collision = Vector3();
//增量坐标
Vector3 Increment = Vector3();
//导航坐标
Vector3 Navigation = Vector3();
//相机坐标
Vector3 Visual = Vector3();
//武器坐标
Vector3 Weapon = Vector3();
//空中下帧位移坐标
Vector3 Param = Vector3();
//钩爪坐标
Vector3 Hook = Vector3();
//玩家传送(X坐标,Y坐标,Z坐标,是否穿墙)
static void TransportCoordinate(float X, float Y, float Z, bool Across = false) {
*offsetPtr<float>(BasicGameData::PlayerPlot, 0x160) = X;
*offsetPtr<float>(BasicGameData::PlayerPlot, 0x164) = Y;
*offsetPtr<float>(BasicGameData::PlayerPlot, 0x168) = Z;
if (Across) {
*offsetPtr<float>(BasicGameData::PlayerPlot, 0xA50) = X;
*offsetPtr<float>(BasicGameData::PlayerPlot, 0xA54) = Y;
*offsetPtr<float>(BasicGameData::PlayerPlot, 0xA58) = Z;
}
}
}
//武器装饰物
namespace WeaponOrnaments {
//缓存数据
namespace TempData {
void* t_ornaments = nullptr;
bool t_setOrnamentsCoordinate = false;
Vector3 t_SetOrnamentsCoordinate;
bool t_setOrnamentsSize = false;
Vector3 t_SetOrnamentsSize;
}
//装饰物坐标
Vector3 OrnamentsCoordinate = Vector3();
//装饰物模型大小
Vector3 OrnamentsSize = Vector3();
//解除装饰物坐标控制
static void DecontrolOrnamentsCoordinate() {
TempData::t_setOrnamentsCoordinate = false;
}
//解除装饰物大小控制
static void DecontrolOrnamentsSize() {
TempData::t_setOrnamentsSize = false;
}
//装饰物坐标设置(X坐标,Y坐标,Z坐标)
static void SetOrnamentsCoordinate(float X, float Y, float Z) {
TempData::t_SetOrnamentsCoordinate = Vector3(X, Y, Z);
TempData::t_setOrnamentsCoordinate = true;
}
//装饰物大小设置(X坐标,Y坐标,Z坐标)
static void SetOrnamentsSize(float X, float Y, float Z) {
TempData::t_SetOrnamentsSize = Vector3(X, Y, Z);
TempData::t_setOrnamentsSize = true;
}
}
//武器
namespace Weapons {
//缓存数据
namespace TempData {
void* t_mainWeapon = nullptr;
void* t_secondaryWeapon = nullptr;
void* t_weaponHit = nullptr;
bool t_setMainWeaponCoordinate = false;
Vector3 t_SetMainWeaponCoordinate;
bool t_setMainWeaponSize = false;
Vector3 t_SetMainWeaponSize;
bool t_setSecondaryWeaponCoordinate = false;
Vector3 t_SetSecondaryWeaponCoordinate;
bool t_setSecondaryWeaponSize = false;
Vector3 t_SetSecondaryWeaponSize;
}
//武器类型
int WeaponType = 0;
//武器ID
int WeaponId = 0;
//主武器坐标
Vector3 MainWeaponCoordinate = Vector3();
//主武器模型大小
Vector3 MainWeaponSize = Vector3();
//副武器坐标
Vector3 SecondaryWeaponCoordinate = Vector3();
//副武器模型大小
Vector3 SecondaryWeaponSize = Vector3();
//武器命中坐标
Vector3 HitCoordinate = Vector3();
//更换武器(武器类型,武器ID)
static void ChangeWeapons(int type, int id, bool Complete = true) {
if (type <= 13 and type >= 0 and id >= 0) {
if (Complete) {
*offsetPtr<int>(BasicGameData::PlayerPlot, 0x13860) = type;
*offsetPtr<int>(BasicGameData::PlayerPlot, 0x13864) = id;
MH::Weapon::CompleteChangeWeapon(BasicGameData::PlayerPlot, 1, 0);
}
else
MH::Weapon::ChangeWeapon(BasicGameData::PlayerPlot, type, id);
}
}
//解除主武器坐标控制
static void DecontrolMainWeaponCoordinate() {
TempData::t_setMainWeaponCoordinate = false;
}
//解除主武器大小控制
static void DecontrolMainWeaponSize() {
TempData::t_setMainWeaponSize = false;
}
//主武器坐标设置(X坐标,Y坐标,Z坐标)
static void SetMainWeaponCoordinate(float X, float Y, float Z) {
TempData::t_SetMainWeaponCoordinate = Vector3(X, Y, Z);
TempData::t_setMainWeaponCoordinate = true;
}
//主武器大小设置(X坐标,Y坐标,Z坐标)
static void SetMainWeaponSize(float X, float Y, float Z) {
TempData::t_SetMainWeaponSize = Vector3(X, Y, Z);
TempData::t_setMainWeaponSize = true;
}
//解除副武器坐标控制
static void DecontrolSecondaryWeaponCoordinate() {
TempData::t_setSecondaryWeaponCoordinate = false;
}
//解除副武器大小控制
static void DecontrolSecondaryWeaponSize() {
TempData::t_setSecondaryWeaponSize = false;
}
//副武器坐标设置(X坐标,Y坐标,Z坐标)
static void SetSecondaryWeaponCoordinate(float X, float Y, float Z) {
TempData::t_SetSecondaryWeaponCoordinate = Vector3(X, Y, Z);
TempData::t_setSecondaryWeaponCoordinate = true;
}
//副武器大小设置(X坐标,Y坐标,Z坐标)
static void SetSecondaryWeaponSize(float X, float Y, float Z) {
TempData::t_SetSecondaryWeaponSize = Vector3(X, Y, Z);
TempData::t_setSecondaryWeaponSize = true;
}
}
//特效
namespace Effects {
//生成特效(特效组,特效id)
static void GenerateSpecialEffects(int group, int record) {
//感谢南风焓大佬提供的地址
void* Effects = *offsetPtr<void*>(BasicGameData::PlayerPlot, 0x8808);
//特效添加
MH::Player::Effects((undefined*)Effects, group, record);
}
}
//相机绑定
static void SetVisual(void* bind, float Duration = 0) {
Coordinate::TempData::t_SetVisualBind = bind;
Coordinate::TempData::t_SetVisual = true;
}
//解除相机设置
static void UnbindVisual() {
Coordinate::TempData::t_SetVisual = false;
Coordinate::TempData::t_SetVisualBind = nullptr;
}
//相机设置(X坐标,Y坐标,Z坐标,持续时间0=长期)
static void SetVisual(float X, float Y, float Z, float Duration = 0) {
Coordinate::TempData::t_SetVisualCoordinate.x = X;
Coordinate::TempData::t_SetVisualCoordinate.y = Y;
Coordinate::TempData::t_SetVisualCoordinate.z = Z;
Coordinate::TempData::t_SetVisual = true;
}
//朝向角度
float Angle = 0;
//朝向弧度
float Radian = 0;
//欧拉角
Vector3 EulerAngle = Vector3();
//重力加速度
float Gravity = 0;
//下落速率
float Fallspeedrate = 0;
//相机距离
float VisualDistance = 0;
//是否处于瞄准状态
bool AimingState = false;
//空中状态
bool PlayerAirState = false;
//最后一次击中的怪物地址
void* AttackMonsterPlot = nullptr;
//动作id
int ActionId = 0;
//当前动作帧
float ActionFrame = 0;
float ActionFrameEnd = 0;
float ActionFrameSpeed = 0;
//派生信息
FsmData Fsm = FsmData();
FsmData NowFsm = FsmData();
//玩家名称
string Name = "";
//hr等级
int Hr = 0;
//mr等级
int Mr = 0;
//当前血量
float CurrentHealth = 0;
//基础血量(0-150)
float BasicHealth = 0;
//血量上限
float MaxHealth = 0;
//当前耐力
float CurrentEndurance = 0;
//耐力上限(25-150)
float MaxEndurance = 0;
//执行派生动作(执行对象,执行Id)
static void RunDerivedAction(int type, int id) {
TempData::t_ManualFsmAction = FsmData(type, id);
TempData::t_executingFsmAction = true;
*offsetPtr<int>(BasicGameData::PlayerPlot, 0x6284) = type;
*offsetPtr<int>(BasicGameData::PlayerPlot, 0x6288) = id;
*offsetPtr<int>(BasicGameData::PlayerPlot, 0x628C) = type;
*offsetPtr<int>(BasicGameData::PlayerPlot, 0x6290) = id;
Fsm = FsmData(type, id);
}
//检查执行派生动作是否结束
static bool CheckDerivedAction() {
if (TempData::t_executingFsmAction) {
if (NowFsm.Id != TempData::t_ManualFsmAction.Id and NowFsm.Target != TempData::t_ManualFsmAction.Target) {
TempData::t_executingFsmAction = false;
return true;
}
else
return false;
}
return false;
}
//执行动作(执行Id)
static void RunAction(int id) {
MH::Player::CallLmt((undefined*)BasicGameData::PlayerPlot, id, 0);
}
//设置当前动作帧
static void SetActionFrame(float Frame) {
void* ActionFramePlot = *offsetPtr<void*>(BasicGameData::PlayerPlot, 0x468);
*offsetPtr<float>(ActionFramePlot, 0x10c) = Frame;
}
//获取玩家Buff持续时间
static float GetPlayerBuff(string buff) {
void* BuffsPlot = *offsetPtr<void*>(BasicGameData::PlayerPlot, 0x7D20);
int buffPtr = PlayerBuff::GetBuffPtr(buff);
return *offsetPtr<float>(BuffsPlot, buffPtr);
}
//设置玩家Buff持续时间
static void SetPlayerBuff(string buff, float duration) {
void* BuffsPlot = *offsetPtr<void*>(BasicGameData::PlayerPlot, 0x7D20);
int buffPtr = PlayerBuff::GetBuffPtr(buff);
*offsetPtr<float>(BuffsPlot, buffPtr) = duration;