-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathComponent.h
More file actions
1082 lines (1062 loc) · 37.6 KB
/
Component.h
File metadata and controls
1082 lines (1062 loc) · 37.6 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 <io.h>
#include <filesystem>
#include"tlhelp32.h"
#include "md5.h"
using namespace std;
using namespace loader;
namespace Component {
struct Effect {
bool Enable = false;
int group = 0;
int record = 0;
};
/*
将目标移动到坐标点
适用于玩家、怪物、环境生物、环境采集物、环境实体
注:
速度值越大,速度越慢
玩家和怪物推荐使用MovePlayerToPoint和MoveMonsterToPoint进行操作
*/
#pragma region MoveTargetToPoint
static void MoveTargetToPoint(void* Target, Base::Vector3 Point,bool Instant = true,float speed = 100.0) {
if (Target == nullptr)
return;
if (Instant) {
*offsetPtr<float>(Target, 0x160) = Point.x;
*offsetPtr<float>(Target, 0x164) = Point.y;
*offsetPtr<float>(Target, 0x168) = Point.z;
}
else {
Base::Commission::MoveEntity::CommissionList[Target] = Base::Commission::MoveEntity::Parameter{
Base::Vector3{ Point.x, Point.y, Point.z },
nullptr,
speed
};
}
}
#pragma endregion
/*
将目标移动到目标
适用于玩家、怪物、环境生物、环境采集物、环境实体
注:
速度值越大,速度越慢
玩家和怪物推荐使用MovePlayerToTarget和MoveMonsterToTarget进行操作
*/
#pragma region MoveTargetToTarget
static void MoveTargetToTarget(void* Target, void* ToTarget, bool Instant = true, float speed = 100.0) {
if (Target == nullptr || ToTarget == nullptr)
return;
float TargetPointX = *offsetPtr<float>(Target, 0x160);
float TargetPointY = *offsetPtr<float>(Target, 0x164);
float TargetPointZ = *offsetPtr<float>(Target, 0x168);
if (Instant) {
*offsetPtr<float>(Target, 0x160) = TargetPointX;
*offsetPtr<float>(Target, 0x164) = TargetPointY;
*offsetPtr<float>(Target, 0x168) = TargetPointZ;
}
else {
Base::Commission::MoveEntity::CommissionList[Target] = Base::Commission::MoveEntity::Parameter{
Base::Vector3{ TargetPointX, TargetPointY, TargetPointZ },
ToTarget,
speed
};
}
}
#pragma endregion
/*
将玩家移动到目标
注:
速度值越大,速度越慢
*/
#pragma region MovePlayerToPoint
static void MovePlayerToPoint(Base::Vector3 Point, Effect effect = Effect{false}, bool Instant = true, float speed = 100.0) {
if (effect.Enable) {
Base::PlayerData::Effects::GenerateSpecialEffects(effect.group, effect.record);
}
if (Instant) {
Base::PlayerData::Coordinate::TransportCoordinate(Point.x,Point.y,Point.z,true);
}
else {
MoveTargetToPoint(Base::BasicGameData::PlayerPlot, Point, false, speed);
}
}
#pragma endregion
/*
向游戏内发送消息
*/
#pragma region ShowMessage
static void ShowMessage(std::string message) {
MH::Chat::ShowGameMessage(*(undefined**)MH::Chat::MainPtr, (undefined*)&message[0], -1, -1, 0);
}
#pragma endregion
/*
设置怪物筛选器
*/
#pragma region SetMonsterFilter
static void SetMonsterFilter(int monsterId, int monsterSubId) {
Base::Monster::Filter = pair<int, int>(monsterId, monsterSubId);
}
#pragma endregion
/*
清除怪物筛选器
*/
#pragma region DisableMonsterFilter
static void DisableMonsterFilter() {
Base::Monster::Filter = pair<int, int>(255, 255);
}
#pragma endregion
/*
获取导航的怪物
*/
#pragma region GetNavigationMonster
static void* GetNavigationMonster() {
for (auto [monster, monsterData] : Base::Monster::Monsters) {
if (monster != nullptr) {
Base::Vector3 monsterCoordinates(
*offsetPtr<float>(monster, 0x160),
*offsetPtr<float>(monster, 0x164),
*offsetPtr<float>(monster, 0x168)
);
float distance = Base::Calculation::DistanceBetweenTwoCoordinates(Base::PlayerData::Coordinate::Navigation, monsterCoordinates);
if (distance < 5) {
return monster;
}
}
}
return nullptr;
}
#pragma endregion
/*
获取距离最近的怪物
*/
#pragma region GetNearestMonster
static void* GetNearestMonster(float MinRange = 0, float MaxRange = 9999999.0) {
pair<void*, float> tempMonster (nullptr,0);
for (auto [monster, monsterData] : Base::Monster::Monsters) {
if (monster != nullptr) {
if (
monsterData.Id != Base::Monster::Filter.first and
monsterData.SubId != Base::Monster::Filter.second and
Base::Monster::Filter.first != 255 and
Base::Monster::Filter.second != 255
)
continue;
Base::Vector3 monsterCoordinates(
*offsetPtr<float>(monster, 0x160),
*offsetPtr<float>(monster, 0x164),
*offsetPtr<float>(monster, 0x168)
);
float distance = Base::Calculation::DistanceBetweenTwoCoordinates(Base::PlayerData::Coordinate::Entity, monsterCoordinates);
if (distance < MaxRange and distance > MinRange) {
if (tempMonster.first != nullptr) {
if (tempMonster.second > distance)
tempMonster = pair<void*, float>(monster, distance);
}
else
tempMonster = pair<void*, float>(monster, distance);
}
}
}
return tempMonster.first;
}
#pragma endregion
/*
杀死导航标记的怪物
*/
#pragma region KillNavigationMonster
static bool KillNavigationMonster() {
void* monster = GetNavigationMonster();
if (monster != nullptr) {
void* healthMgr = *offsetPtr<void*>(monster, 0x7670);
float health = *offsetPtr<float>(healthMgr, 0x64);
if (health > 1) {
*offsetPtr<float>(healthMgr, 0x60) = 0.1;
return true;
}
}
return false;
}
#pragma endregion
/*
杀死距离最近的怪物
*/
#pragma region KillNearestMonster
static bool KillNearestMonster(float MinRange = 0, float MaxRange = 9999999.0) {
void* monster = GetNearestMonster(MinRange,MaxRange);
if (monster != nullptr) {
void* healthMgr = *offsetPtr<void*>(monster, 0x7670);
float health = *offsetPtr<float>(healthMgr, 0x64);
if (health > 1) {
*offsetPtr<float>(healthMgr, 0x60) = 0.1;
return true;
}
}
return false;
}
#pragma endregion
/*
杀死最后一次击中的怪物
*/
#pragma region KillLastHitMonster
static bool KillLastHitMonster() {
if (Base::PlayerData::AttackMonsterPlot != nullptr) {
void* healthMgr = *offsetPtr<void*>(Base::PlayerData::AttackMonsterPlot, 0x7670);
float health = *offsetPtr<float>(healthMgr, 0x64);
if (health > 1) {
*offsetPtr<float>(healthMgr, 0x60) = 0.1;
return true;
}
}
return false;
}
#pragma endregion
/*
设置导航怪物的行为
*/
#pragma region NavigationMonsterBehaviorControl
static bool NavigationMonsterBehaviorControl(int fsm) {
void* monster = GetNavigationMonster();
if (monster != nullptr) {
Base::Monster::BehaviorControl(monster, fsm);
return true;
}
return false;
}
#pragma endregion
/*
设置距离最近的怪物的行为
*/
#pragma region NearestMonsterBehaviorControl
static bool NearestMonsterBehaviorControl(int fsm) {
void* monster = GetNearestMonster();
if (monster != nullptr) {
Base::Monster::BehaviorControl(monster, fsm);
return true;
}
return false;
}
#pragma endregion
/*
设置最近击中的怪物的行为
*/
#pragma region LastHitMonsterBehaviorControl
static bool LastHitMonsterBehaviorControl(int fsm) {
if (Base::PlayerData::AttackMonsterPlot != nullptr) {
Base::Monster::BehaviorControl(Base::PlayerData::AttackMonsterPlot, fsm);
return true;
}
return false;
}
#pragma endregion
/*
设置导航怪物的Buff
*/
#pragma region SetNavigationMonsterBuff
static bool SetNavigationMonsterBuff(string buff) {
void* monster = GetNavigationMonster();
if (monster != nullptr) {
Base::Monster::SetBuff(monster, buff);
return true;
}
return false;
}
#pragma endregion
/*
设置距离最近的怪物的Buff
*/
#pragma region SetNearestMonsterBuff
static bool SetNearestMonsterBuff(string buff, float MinRange = 0, float MaxRange = 9999999.0) {
void* monster = GetNearestMonster(MinRange, MaxRange);
if (monster != nullptr) {
Base::Monster::SetBuff(monster, buff);
return true;
}
return false;
}
#pragma endregion
/*
设置最近击中的怪物的Buff
*/
#pragma region SetLastHitMonsterBuff
static bool SetLastHitMonsterBuff(string buff) {
if (Base::PlayerData::AttackMonsterPlot != nullptr) {
Base::Monster::SetBuff(Base::PlayerData::AttackMonsterPlot, buff);
return true;
}
return false;
}
#pragma endregion
/*
设置范围内所有的怪物的Buff
*/
#pragma region SetAllMonsterBuff
static void SetAllMonsterBuff(string buff, float MinRange = 0, float MaxRange = 9999999.0) {
for (auto [monster, monsterData] : Base::Monster::Monsters) {
if (monster != nullptr) {
if (
monsterData.Id != Base::Monster::Filter.first and
monsterData.SubId != Base::Monster::Filter.second and
Base::Monster::Filter.first != 255 and
Base::Monster::Filter.second != 255
)
continue;
Base::Vector3 monsterCoordinates(
*offsetPtr<float>(monster, 0x160),
*offsetPtr<float>(monster, 0x164),
*offsetPtr<float>(monster, 0x168)
);
float distance = Base::Calculation::DistanceBetweenTwoCoordinates(Base::PlayerData::Coordinate::Entity, monsterCoordinates);
if (distance < MaxRange and distance > MinRange) {
Base::Monster::SetBuff(monster, buff);
}
}
}
}
#pragma endregion
/*
杀死范围内所有怪物
*/
#pragma region KillAllMonster
static void KillAllMonster(float MinRange = 0, float MaxRange = 9999999.0) {
for (auto [monster, monsterData] : Base::Monster::Monsters) {
if (monster != nullptr) {
if (
monsterData.Id != Base::Monster::Filter.first and
monsterData.SubId != Base::Monster::Filter.second and
Base::Monster::Filter.first != 255 and
Base::Monster::Filter.second != 255
)
continue;
Base::Vector3 monsterCoordinates(
*offsetPtr<float>(monster, 0x160),
*offsetPtr<float>(monster, 0x164),
*offsetPtr<float>(monster, 0x168)
);
float distance = Base::Calculation::DistanceBetweenTwoCoordinates(Base::PlayerData::Coordinate::Entity, monsterCoordinates);
if (distance < MaxRange and distance > MinRange) {
void* healthMgr = *offsetPtr<void*>(monster, 0x7670);
float health = *offsetPtr<float>(healthMgr, 0x64);
if (health > 1) {
*offsetPtr<float>(healthMgr, 0x60) = 0.1;
}
}
}
}
}
#pragma endregion
/*
获取导航怪物的坐标
*/
#pragma region GetNavigationMonsterCoordinates
static Base::Vector3 GetNavigationMonsterCoordinates() {
void* monster = GetNavigationMonster();
if (monster != nullptr) {
return Base::Vector3(
*offsetPtr<float>(monster, 0x160),
*offsetPtr<float>(monster, 0x164),
*offsetPtr<float>(monster, 0x168)
);
}
return Base::Vector3();
}
#pragma endregion
/*
获取距离最近的怪物的坐标
*/
#pragma region GetNearestMonsterCoordinates
static Base::Vector3 GetNearestMonsterCoordinates(float MinRange = 0, float MaxRange = 9999999.0) {
void* monster = GetNearestMonster(MinRange, MaxRange);
if (monster != nullptr) {
return Base::Vector3(
*offsetPtr<float>(monster, 0x160),
*offsetPtr<float>(monster, 0x164),
*offsetPtr<float>(monster, 0x168)
);
}
return Base::Vector3();
}
#pragma endregion
/*
获取最后一次击中的怪物的坐标
*/
#pragma region GetLastHitMonsterCoordinates
static Base::Vector3 GetLastHitMonsterCoordinates() {
if (Base::PlayerData::AttackMonsterPlot != nullptr) {
return Base::Vector3(
*offsetPtr<float>(Base::PlayerData::AttackMonsterPlot, 0x160),
*offsetPtr<float>(Base::PlayerData::AttackMonsterPlot, 0x164),
*offsetPtr<float>(Base::PlayerData::AttackMonsterPlot, 0x168)
);
}
return Base::Vector3();
}
#pragma endregion
/*
设置怪物筛选器
*/
#pragma region SetEnvironmentalFilter
static void SetEnvironmentalFilter(int environmentalId, int environmentalSubId) {
Base::World::EnvironmentalData::Filter = pair<int, int>(environmentalId, environmentalSubId);
}
#pragma endregion
/*
清除怪物筛选器
*/
#pragma region DisableEnvironmentalFilter
static void DisableEnvironmentalFilter() {
Base::World::EnvironmentalData::Filter = pair<int, int>(255, 255);
}
#pragma endregion
/*
设置范围内所有环境生物的坐标
*/
#pragma region SetAllEnvironmentalCoordinates
static void SetAllEnvironmentalCoordinates(Base::Vector3 Coordinates, float MinRange = 0, float MaxRange = 9999999.0) {
for (auto [environmental, environmentalData] : Base::World::EnvironmentalData::Environmentals) {
if (environmental != nullptr) {
if (
environmentalData.Id != Base::World::EnvironmentalData::Filter.first and
environmentalData.SubId != Base::World::EnvironmentalData::Filter.second and
Base::World::EnvironmentalData::Filter.first != 255 and
Base::World::EnvironmentalData::Filter.second != 255
)
continue;
Base::Vector3 environmentalCoordinates(
*offsetPtr<float>(environmental, 0x160),
*offsetPtr<float>(environmental, 0x164),
*offsetPtr<float>(environmental, 0x168)
);
float distance = Base::Calculation::DistanceBetweenTwoCoordinates(Base::PlayerData::Coordinate::Entity, environmentalCoordinates);
if (distance < MaxRange and distance > MinRange) {
*offsetPtr<float>(environmental, 0x160) = Coordinates.x;
*offsetPtr<float>(environmental, 0x164) = Coordinates.y;
*offsetPtr<float>(environmental, 0x168) = Coordinates.z;
//MoveTargetToPoint(environmental, environmentalCoordinates);
}
}
}
}
#pragma endregion
/*
设置玩家血量和耐力
*/
#pragma region SetPlayerHealthAndEndurance
static void SetPlayerBasicHealth(float health) {
*offsetPtr<float>(Base::BasicGameData::PlayerPlot, 0x7628) = health;
}
static void SetPlayerHealth(float health) {
void* StatusManagementPlot = *offsetPtr<undefined**>((undefined(*)())Base::BasicGameData::PlayerPlot, 0x7630);
if (StatusManagementPlot != nullptr)
*offsetPtr<float>(StatusManagementPlot, 0x64) = health;
}
static void SetPlayerMaxEndurance(float endurance) {
void* StatusManagementPlot = *offsetPtr<undefined**>((undefined(*)())Base::BasicGameData::PlayerPlot, 0x7630);
if (StatusManagementPlot != nullptr)
*offsetPtr<float>(StatusManagementPlot, 0x144) = endurance;
}
static void SetPlayerEndurance(float endurance) {
void* StatusManagementPlot = *offsetPtr<undefined**>((undefined(*)())Base::BasicGameData::PlayerPlot, 0x7630);
if (StatusManagementPlot != nullptr)
*offsetPtr<float>(StatusManagementPlot, 0x13C) = endurance;
}
#pragma endregion
/*
获取所有怪物的坐标
*/
#pragma region GetAllMonsterCoordinates
static map<int, Base::Monster::MonsterData> GetAllMonsterCoordinates() {
map<int, Base::Monster::MonsterData> monsterList;
int installcount = 0;
for (auto [monster, monsterData] : Base::Monster::Monsters) {
if (monster != nullptr) {
if (
monsterData.Id != Base::Monster::Filter.first and
monsterData.SubId != Base::Monster::Filter.second and
Base::Monster::Filter.first != 255 and
Base::Monster::Filter.second != 255
)
continue;
monsterList[installcount] = monsterData;
installcount++;
}
}
return monsterList;
}
static map<int, Base::Monster::MonsterData> GetAllMonsterCoordinatesRelativeToTarget(Base::Vector3 Target, float MinRange = 0, float MaxRange = 9999999.0) {
map<int, Base::Monster::MonsterData> monsterList;
int installcount = 0;
for (auto [monster, monsterData] : Base::Monster::Monsters) {
if (monster != nullptr) {
if (
monsterData.Id != Base::Monster::Filter.first and
monsterData.SubId != Base::Monster::Filter.second and
Base::Monster::Filter.first != 255 and
Base::Monster::Filter.second != 255
)
continue;
float distance = Base::Calculation::DistanceBetweenTwoCoordinates(Target,
Base::Vector3(monsterData.CoordinatesX, monsterData.CoordinatesY, monsterData.CoordinatesZ));
if (distance < MaxRange and distance > MinRange) {
monsterList[installcount] = monsterData;
installcount++;
}
}
}
return monsterList;
}
static map<int, Base::Monster::MonsterData> GetAllMonsterCoordinatesRelativeToPlayers(float MinRange = 0, float MaxRange = 9999999.0) {
map<int, Base::Monster::MonsterData> monsterList;
int installcount = 0;
for (auto [monster, monsterData] : Base::Monster::Monsters) {
if (monster != nullptr) {
if (
monsterData.Id != Base::Monster::Filter.first and
monsterData.SubId != Base::Monster::Filter.second and
Base::Monster::Filter.first != 255 and
Base::Monster::Filter.second != 255
)
continue;
float distance = Base::Calculation::DistanceBetweenTwoCoordinates(Base::PlayerData::Coordinate::Entity,
Base::Vector3(monsterData.CoordinatesX, monsterData.CoordinatesY, monsterData.CoordinatesZ));
if (distance < MaxRange and distance > MinRange) {
monsterList[installcount] = monsterData;
installcount++;
}
}
}
return monsterList;
}
#pragma endregion
/*
获取所有怪物的生命
*/
#pragma region GetAllMonsterHealth
struct MonsterHealth {
void* Plot;
float Health;
float MaxHealth;
int Id;
int SubId;
MonsterHealth(
void* Plot = nullptr,
float Health = 0,
float MaxHealth = 0,
int Id = 0,
int SubId = 0)
:Plot(Plot), Health(Health), MaxHealth(MaxHealth), Id(Id), SubId(SubId) {
};
};
static map<int, MonsterHealth> GetAllMonsterHealth() {
map<int, MonsterHealth> monsterList;
int installcount = 0;
for (auto [monster, monsterData] : Base::Monster::Monsters) {
if (monster != nullptr) {
if (
monsterData.Id != Base::Monster::Filter.first and
monsterData.SubId != Base::Monster::Filter.second and
Base::Monster::Filter.first != 255 and
Base::Monster::Filter.second != 255
)
continue;
void* healthMgr = *offsetPtr<void*>(monster, 0x7670);
float health = *offsetPtr<float>(healthMgr, 0x64);
float maxHealth = *offsetPtr<float>(healthMgr, 0x60);
monsterList[installcount] = MonsterHealth(monster, health, maxHealth, monsterData.Id, monsterData.SubId);
installcount++;
}
}
return monsterList;
}
static map<int, MonsterHealth> GetAllMonsterHealthRelativeToTarget(Base::Vector3 Target, float MinRange = 0, float MaxRange = 9999999.0) {
map<int, MonsterHealth> monsterList;
int installcount = 0;
for (auto [monster, monsterData] : Base::Monster::Monsters) {
if (monster != nullptr) {
if (
monsterData.Id != Base::Monster::Filter.first and
monsterData.SubId != Base::Monster::Filter.second and
Base::Monster::Filter.first != 255 and
Base::Monster::Filter.second != 255
)
continue;
float distance = Base::Calculation::DistanceBetweenTwoCoordinates(Target,
Base::Vector3(monsterData.CoordinatesX, monsterData.CoordinatesY, monsterData.CoordinatesZ));
if (distance < MaxRange and distance > MinRange) {
void* healthMgr = *offsetPtr<void*>(monster, 0x7670);
float health = *offsetPtr<float>(healthMgr, 0x64);
float maxHealth = *offsetPtr<float>(healthMgr, 0x60);
monsterList[installcount] = MonsterHealth(monster, health, maxHealth, monsterData.Id, monsterData.SubId);
installcount++;
}
}
}
return monsterList;
}
static map<int, MonsterHealth> GetAllMonsterHealthRelativeToPlayers(float MinRange = 0, float MaxRange = 9999999.0) {
map<int, MonsterHealth> monsterList;
int installcount = 0;
for (auto [monster, monsterData] : Base::Monster::Monsters) {
if (monster != nullptr) {
if (
monsterData.Id != Base::Monster::Filter.first and
monsterData.SubId != Base::Monster::Filter.second and
Base::Monster::Filter.first != 255 and
Base::Monster::Filter.second != 255
)
continue;
float distance = Base::Calculation::DistanceBetweenTwoCoordinates(Base::PlayerData::Coordinate::Entity,
Base::Vector3(monsterData.CoordinatesX, monsterData.CoordinatesY, monsterData.CoordinatesZ));
if (distance < MaxRange and distance > MinRange) {
void* healthMgr = *offsetPtr<void*>(monster, 0x7670);
float health = *offsetPtr<float>(healthMgr, 0x64);
float maxHealth = *offsetPtr<float>(healthMgr, 0x60);
monsterList[installcount] = MonsterHealth(monster, health, maxHealth, monsterData.Id, monsterData.SubId);
installcount++;
}
}
}
return monsterList;
}
#pragma endregion
/*
获取范围内所有环境生物的坐标
*/
#pragma region GetAllEnvironmentalCoordinates
static map<int, Base::World::EnvironmentalData::EnvironmentalData> GetAllEnvironmentalCoordinates(float MinRange = 0, float MaxRange = 9999999.0) {
map<int, Base::World::EnvironmentalData::EnvironmentalData> environmentaList;
int installcount = 0;
for (auto [environmental, environmentalData] : Base::World::EnvironmentalData::Environmentals) {
if (environmental != nullptr) {
if (
environmentalData.Id != Base::World::EnvironmentalData::Filter.first and
environmentalData.SubId != Base::World::EnvironmentalData::Filter.second and
Base::World::EnvironmentalData::Filter.first != 255 and
Base::World::EnvironmentalData::Filter.second != 255
)
continue;
float distance = Base::Calculation::DistanceBetweenTwoCoordinates(Base::PlayerData::Coordinate::Entity,
Base::Vector3(environmentalData.CoordinatesX, environmentalData.CoordinatesY, environmentalData.CoordinatesZ));
if (distance < MaxRange and distance > MinRange) {
environmentaList[installcount] = environmentalData;
installcount++;
}
}
}
return environmentaList;
}
#pragma endregion
/*
获取怪物的异常状态
*/
#pragma region GetAllMonsterDeBuff
struct MonsterDeBuff {
void* Plot;
map<string, MonsterBuff::MonsterBuffState> DeBuff;
int Id;
int SubId;
MonsterDeBuff(
void* Plot = nullptr,
map<string, MonsterBuff::MonsterBuffState> DeBuff = {},
int Id = 0,
int SubId = 0)
:Plot(Plot), DeBuff(DeBuff), Id(Id), SubId(SubId) {
};
};
static map<int, MonsterDeBuff> GetAllMonsterDeBuff() {
map<int, MonsterDeBuff> monsterList;
int installcount = 0;
for (auto [monster, monsterData] : Base::Monster::Monsters) {
if (monster != nullptr) {
if (
monsterData.Id != Base::Monster::Filter.first and
monsterData.SubId != Base::Monster::Filter.second and
Base::Monster::Filter.first != 255 and
Base::Monster::Filter.second != 255
)
continue;
map<string, MonsterBuff::MonsterBuffState> DeBuff;
for (string debuff : vector<string>{"Covet","Dizziness","Paralysis","Sleep","Poisoning","Ride","Ridedowna","Reducebreath","Explode","Flicker","FlickerG","Smoke","Traphole","Stasistrap"}) {
DeBuff[debuff] = MonsterBuff::GetMonsterBuffState(monster, debuff);
}
monsterList[installcount] = MonsterDeBuff(monster, DeBuff, monsterData.Id, monsterData.SubId);
installcount++;
}
}
return monsterList;
}
static map<int, MonsterDeBuff> GetAllMonsterDeBuffRelativeToTarget(Base::Vector3 Target, float MinRange = 0, float MaxRange = 9999999.0) {
map<int, MonsterDeBuff> monsterList;
int installcount = 0;
for (auto [monster, monsterData] : Base::Monster::Monsters) {
if (monster != nullptr) {
if (
monsterData.Id != Base::Monster::Filter.first and
monsterData.SubId != Base::Monster::Filter.second and
Base::Monster::Filter.first != 255 and
Base::Monster::Filter.second != 255
)
continue;
float distance = Base::Calculation::DistanceBetweenTwoCoordinates(Target,
Base::Vector3(monsterData.CoordinatesX, monsterData.CoordinatesY, monsterData.CoordinatesZ));
if (distance < MaxRange and distance > MinRange) {
map<string, MonsterBuff::MonsterBuffState> DeBuff;
for (string debuff : vector<string>{ "Covet","Dizziness","Paralysis","Sleep","Poisoning","Ride","Ridedowna","Reducebreath","Explode","Flicker","FlickerG","Smoke","Traphole","Stasistrap" }) {
DeBuff[debuff] = MonsterBuff::GetMonsterBuffState(monster, debuff);
}
monsterList[installcount] = MonsterDeBuff(monster, DeBuff, monsterData.Id, monsterData.SubId);
installcount++;
}
}
}
return monsterList;
}
static map<int, MonsterDeBuff> GetAllMonsterDebuffRelativeToPlayers(float MinRange = 0, float MaxRange = 9999999.0) {
map<int, MonsterDeBuff> monsterList;
int installcount = 0;
for (auto [monster, monsterData] : Base::Monster::Monsters) {
if (monster != nullptr) {
if (
monsterData.Id != Base::Monster::Filter.first and
monsterData.SubId != Base::Monster::Filter.second and
Base::Monster::Filter.first != 255 and
Base::Monster::Filter.second != 255
)
continue;
float distance = Base::Calculation::DistanceBetweenTwoCoordinates(Base::PlayerData::Coordinate::Entity,
Base::Vector3(monsterData.CoordinatesX, monsterData.CoordinatesY, monsterData.CoordinatesZ));
if (distance < MaxRange and distance > MinRange) {
map<string, MonsterBuff::MonsterBuffState> DeBuff;
for (string debuff : vector<string>{ "Covet","Dizziness","Paralysis","Sleep","Poisoning","Ride","Ridedowna","Reducebreath","Explode","Flicker","FlickerG","Smoke","Traphole","Stasistrap" }) {
DeBuff[debuff] = MonsterBuff::GetMonsterBuffState(monster, debuff);
}
monsterList[installcount] = MonsterDeBuff(monster, DeBuff, monsterData.Id, monsterData.SubId);
installcount++;
}
}
}
return monsterList;
}
#pragma endregion
/*
获取武器特性值
*/
#pragma region GetWeaponCharacteristicValue
static int GetWeaponCharacteristicIntValue(string ptr) {
long long Ptr = 0;
sscanf_s(ptr.c_str(), "%p", &Ptr, sizeof(long long));
void* ptrAddress = (void*)Ptr;
if (ptrAddress != nullptr) {
void* WeaponEntityPlot = *offsetPtr<void*>(Base::BasicGameData::PlayerPlot, 0x76B0);
if (WeaponEntityPlot != nullptr) {
return *offsetPtr<int>(WeaponEntityPlot, Ptr);
}
}
return 0;
}
static float GetWeaponCharacteristicFloatValue(string ptr) {
long long Ptr = 0;
sscanf_s(ptr.c_str(), "%p", &Ptr, sizeof(long long));
void* ptrAddress = (void*)Ptr;
if (ptrAddress != nullptr) {
void* WeaponEntityPlot = *offsetPtr<void*>(Base::BasicGameData::PlayerPlot, 0x76B0);
if (WeaponEntityPlot != nullptr) {
return *offsetPtr<float>(WeaponEntityPlot, Ptr);
}
}
return 0;
}
static char GetWeaponCharacteristicByteValue(string ptr) {
long long Ptr = 0;
sscanf_s(ptr.c_str(), "%p", &Ptr, sizeof(long long));
void* ptrAddress = (void*)Ptr;
if (ptrAddress != nullptr) {
void* WeaponEntityPlot = *offsetPtr<void*>(Base::BasicGameData::PlayerPlot, 0x76B0);
if (WeaponEntityPlot != nullptr) {
return *offsetPtr<char>(WeaponEntityPlot, Ptr);
}
}
return 0;
}
#pragma endregion
/*
获取对玩家仇恨的怪物
*/
#pragma region GetMonstersHateToPlayers
static vector<void*> GetMonstersHateToPlayers() {
vector<void*> monsterList;
for (auto [monster, monsterData] : Base::Monster::Monsters) {
if (monster != nullptr) {
if (
monsterData.Id != Base::Monster::Filter.first and
monsterData.SubId != Base::Monster::Filter.second and
Base::Monster::Filter.first != 255 and
Base::Monster::Filter.second != 255
)
continue;
if(Base::Monster::GetHateTarget(monster) != nullptr)
monsterList.push_back(Base::Monster::GetHateTarget(monster));
}
}
return monsterList;
}
#pragma endregion
/*
修改钩爪牵引坐标
*/
#pragma region SetHookCoordinateChange
static void SetHookCoordinateChange(Base::Vector3 Coordinates) {
*offsetPtr<float>(Base::BasicGameData::PlayerPlot, 0xE530) = Coordinates.x;
*offsetPtr<float>(Base::BasicGameData::PlayerPlot, 0xE534) = Coordinates.y;
*offsetPtr<float>(Base::BasicGameData::PlayerPlot, 0xE538) = Coordinates.z;
Base::PlayerData::HookCoordinateChange = Coordinates;
Base::PlayerData::HookChange = true;
}
#pragma endregion
/*
实体属性操作
*/
#pragma region EntityProperties
struct EntityProperties {
Base::Vector3 Coordinate;
Base::Vector3 Size;
Base::Vector3 Action;
float Angle;
EntityProperties(
Base::Vector3 Coordinate = Base::Vector3(),
Base::Vector3 Size = Base::Vector3(),
Base::Vector3 Action = Base::Vector3(),
float Angle = 0)
:Coordinate(Coordinate), Size(Size), Action(Action), Angle(Angle) {
};
};
static EntityProperties GetEntityProperties(string ptr) {
long long Ptr = 0;
sscanf_s(ptr.c_str(), "%p", &Ptr, sizeof(long long));
void* EntityAddress = (double*)Ptr;
if (EntityAddress != nullptr) {
void* ActionPlot = *offsetPtr<undefined**>((undefined(*)())Ptr, 0x468);
Base::Vector3 Action = Base::Vector3();
if (ActionPlot != nullptr) {
Action = Base::Vector3(
*offsetPtr<float>(ActionPlot, 0xE9C4),
*offsetPtr<float>(ActionPlot, 0x10c),
*offsetPtr<float>(ActionPlot, 0x114)
);
}
return EntityProperties(
Base::Vector3(
*(float*)(Ptr + 0x160),
*(float*)(Ptr + 0x164),
*(float*)(Ptr + 0x168)
),
Base::Vector3(
*(float*)(Ptr + 0x180),
*(float*)(Ptr + 0x184),
*(float*)(Ptr + 0x188)
),
Action,
Base::Calculation::QuaternionToAngle(Base::Vector4(
*(float*)(Ptr + 0x174),
*(float*)(Ptr + 0x178),
*(float*)(Ptr + 0x17C),
*(float*)(Ptr + 0x180)
))
);
}
return EntityProperties();
}
static void SetEntityCoordinate(string ptr, Base::Vector3 Coordinate) {
long long Ptr = 0;
sscanf_s(ptr.c_str(), "%p", &Ptr, sizeof(long long));
void* EntityAddress = (double*)Ptr;
if (EntityAddress != nullptr) {
*(float*)(Ptr + 0x160) = Coordinate.x;
*(float*)(Ptr + 0x164) = Coordinate.y;
*(float*)(Ptr + 0x168) = Coordinate.z;
}
}
static void SetEntitySize(string ptr, Base::Vector3 Size) {
long long Ptr = 0;
sscanf_s(ptr.c_str(), "%p", &Ptr, sizeof(long long));
void* EntityAddress = (double*)Ptr;
if (EntityAddress != nullptr) {
*(float*)(Ptr + 0x180) = Size.x;
*(float*)(Ptr + 0x184) = Size.y;
*(float*)(Ptr + 0x188) = Size.z;
}
}
static void SetEntityActionFrame(string ptr, float ActionFrame) {
long long Ptr = 0;
sscanf_s(ptr.c_str(), "%p", &Ptr, sizeof(long long));
void* EntityAddress = (double*)Ptr;
if (EntityAddress != nullptr) {
void* ActionPlot = *offsetPtr<undefined**>((undefined(*)())Ptr, 0x468);
if (ActionPlot != nullptr)
*offsetPtr<float>(ActionPlot, 0x10c) = ActionFrame;
}
}
static void SetEntityAngle(string ptr, float angle) {
long long Ptr = 0;
sscanf_s(ptr.c_str(), "%p", &Ptr, sizeof(long long));
void* EntityAddress = (double*)Ptr;
if (EntityAddress != nullptr) {
Base::Vector4 quaternion = Base::Calculation::AngleToQuaternion(angle);
*(float*)(Ptr + 0x174) = quaternion.x;
*(float*)(Ptr + 0x17C) = quaternion.z;
}
}
static void SetEntityAimCoordinate(string ptr, Base::Vector2 aim) {
long long Ptr = 0;
sscanf_s(ptr.c_str(), "%p", &Ptr, sizeof(long long));
void* EntityAddress = (double*)Ptr;
if (EntityAddress != nullptr) {
float direction_x = (aim.x - *(float*)(Ptr + 0x180));
float direction_z = (aim.y - *(float*)(Ptr + 0x188));
float aim_angle = std::atan(direction_x / direction_z);
aim_angle = aim_angle + sign(direction_x) * (1 - sign(direction_z)) * M_PI / 2;
SetEntityAngle(ptr,aim_angle);//设置角度
}
}
static void SetEntityFrameSpeed(string ptr, float frameSpeed) {
long long Ptr = 0;
sscanf_s(ptr.c_str(), "%p", &Ptr, sizeof(long long));
void* EntityAddress = (double*)Ptr;
if (EntityAddress != nullptr) {
Base::World::FrameSpeed[EntityAddress] = frameSpeed;
}
}
static void EntityBehaviorControl(string ptr, int fsm) {
long long Ptr = 0;
sscanf_s(ptr.c_str(), "%p", &Ptr, sizeof(long long));
void* EntityAddress = (double*)Ptr;
if (EntityAddress != nullptr) {
Base::Monster::BehaviorControl(EntityAddress, fsm);
}
}
static void EntityRunDerivedAction(string ptr, int type, int id) {
long long Ptr = 0;
sscanf_s(ptr.c_str(), "%p", &Ptr, sizeof(long long));
void* EntityAddress = (double*)Ptr;
if (EntityAddress != nullptr) {
*offsetPtr<int>(EntityAddress, 0x6284) = type;
*offsetPtr<int>(EntityAddress, 0x6288) = id;
*offsetPtr<int>(EntityAddress, 0x628C) = type;
*offsetPtr<int>(EntityAddress, 0x6290) = id;
}
}
#pragma endregion
#pragma region GetMonstersName_CN
static string GetMonstersName_CN(int id) {
if( id == 0 ) return u8"蠻顎龍"; if( id == 1 ) return u8"火龍"; if( id == 2 ) return u8"草食龍"; if( id == 3 ) return u8"凶豺龍";
if( id == 4 ) return u8"熔山龍"; if( id == 5 ) return u8"菌豬"; if( id == 6 ) return u8"咬魚"; if( id == 7 ) return u8"大凶豺龍";
if( id == 8 ) return u8"冠突龍♂"; if( id == 9 ) return u8"雌火龍"; if( id == 10 ) return u8"櫻火龍"; if( id == 11 ) return u8"蒼火龍";
if( id == 12 ) return u8"角龍"; if( id == 13 ) return u8"黑角龍"; if( id == 14 ) return u8"麒麟"; if( id == 15 ) return u8"貝希摩斯";
if( id == 16 ) return u8"鋼龍"; if( id == 17 ) return u8"炎妃龍"; if( id == 18 ) return u8"炎王龍"; if( id == 19 ) return u8"熔岩龍";
if( id == 20 ) return u8"恐暴龍"; if( id == 21 ) return u8"土砂龍"; if( id == 22 ) return u8"爆鎚龍"; if( id == 23 ) return u8"鹿首精";
if( id == 24 ) return u8"毒妖鳥"; if( id == 25 ) return u8"滅盡龍"; if( id == 26 ) return u8"冥燈龍"; if( id == 27 ) return u8"搔鳥";
if( id == 28 ) return u8"眩鳥"; if( id == 29 ) return u8"泥魚龍"; if( id == 30 ) return u8"飛雷龍"; if( id == 31 ) return u8"浮空龍";
if( id == 32 ) return u8"風漂龍"; if( id == 33 ) return u8"大凶顎龍"; if( id == 34 ) return u8"慘爪龍"; if( id == 35 ) return u8"骨鎚龍";
if( id == 36 ) return u8"屍套龍"; if( id == 37 ) return u8"岩賊龍"; if( id == 38 ) return u8"絢輝龍"; if( id == 39 ) return u8"爆鱗龍";
if( id == 40 ) return u8"背甲龍"; if( id == 41 ) return u8"精靈鹿"; if( id == 42 ) return u8"精靈鹿"; if( id == 43 ) return u8"巨甲蟲";
if( id == 44 ) return u8"巨蜂"; if( id == 45 ) return u8"行翼龍"; if( id == 46 ) return u8"冠突龍♀"; if( id == 47 ) return u8"芳翼龍";
if( id == 48 ) return u8"貓蜥龍"; if( id == 49 ) return u8"酸翼龍"; if( id == 50 ) return u8"凶顎龍"; if( id == 51 ) return u8"古代鹿首精";
if( id == 52 ) return u8"突擊龍"; if( id == 53 ) return u8"響翼龍"; if( id == 54 ) return u8"散熱器官"; if( id == 55 ) return u8"×副散熱器官";
if( id == 56 ) return u8"奇面族"; if( id == 57 ) return u8"???"; if( id == 58 ) return u8"雌火龍???"; if( id == 59 ) return u8"冠突龍";
if( id == 60 ) return u8"黃金奇面族"; if( id == 61 ) return u8"轟龍"; if( id == 62 ) return u8"迅龍"; if( id == 63 ) return u8"冰牙龍";
if( id == 64 ) return u8"惶怒恐暴龍"; if( id == 65 ) return u8"碎龍"; if( id == 66 ) return u8"斬龍"; if( id == 67 ) return u8"硫斬龍";
if( id == 68 ) return u8"雷顎龍"; if( id == 69 ) return u8"水妖鳥"; if( id == 70 ) return u8"殲世滅盡龍"; if( id == 71 ) return u8"痺毒龍";
if( id == 72 ) return u8"浮眠龍"; if( id == 73 ) return u8"霜翼風漂龍"; if( id == 74 ) return u8"兇爪龍"; if( id == 75 ) return u8"霧瘴屍套龍";
if( id == 76 ) return u8"紅蓮爆鱗龍"; if( id == 77 ) return u8"冰魚龍"; if( id == 78 ) return u8"猛牛龍"; if( id == 79 ) return u8"冰呪龍";
if( id == 80 ) return u8"溟波龍"; if( id == 81 ) return u8"天地煌啼龍"; if( id == 82 ) return u8"波波"; if( id == 83 ) return u8"雪鹿";
if( id == 84 ) return u8"冰豺狼"; if( id == 85 ) return u8"冬翼龍"; if( id == 86 ) return u8"獸纏族"; if( id == 87 ) return u8"煌黑龍";
if( id == 88 ) return u8"金火龍"; if( id == 89 ) return u8"銀火龍"; if( id == 90 ) return u8"黑狼鳥"; if( id == 91 ) return u8"金獅子";
if( id == 92 ) return u8"激昂金獅子"; if( id == 93 ) return u8"黑轟龍"; if( id == 94 ) return u8"雷狼龍"; if( id == 95 ) return u8"獄狼龍";
if( id == 96 ) return u8"猛爆碎龍"; if( id == 97 ) return u8"冥赤龍"; if( id == 98 ) return u8"Unavailable"; if( id == 99 ) return u8"戰痕黑狼鳥";
if( id == 100 ) return u8"霜刃冰牙龍"; if( id == 101 ) return u8"黑龍";
return "未知";
}
#pragma endregion
//获取目录中的文件
static void getFiles(string path, vector<string>& files)
{
using namespace std::filesystem;
if (exists(path) && is_directory(path))
{
for (auto& fe : directory_iterator(path))
{
auto fp = fe.path();
auto temp = fp.filename();
if (fp.extension().string() == ".lua") {
Base::LuaHandle::LuaCode[temp.stem().string()] = Base::LuaHandle::LuaCodeData(
temp.stem().string(),