forked from TCRoid/Stand-Lua-RScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRScript2.lua
More file actions
2212 lines (1842 loc) · 74.8 KB
/
Copy pathRScript2.lua
File metadata and controls
2212 lines (1842 loc) · 74.8 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
--------------------------------
-- Author: Rostal
--------------------------------
util.require_natives("3095a", "init")
local SCRIPT_VERSION <const> = "2023/12/23"
local SUPPORT_GTAO <const> = 1.68
--------------------------------------
---------- File & Dir ----------
--------------------------------------
-- Lib
local SCRIPT_LIB_DIR <const> = filesystem.scripts_dir() .. "lib\\RScript\\"
local REQUIRED_FILES <const> = {
"Tables.lua",
"alternatives.lua",
"functions.lua",
"functions2.lua",
"libs2.lua",
"utils.lua",
"Menu\\Player.lua",
}
for _, file in pairs(REQUIRED_FILES) do
local file_path = SCRIPT_LIB_DIR .. file
if not filesystem.exists(file_path) then
util.toast("[RScript] 缺少文件: " .. file_path, TOAST_ALL)
util.toast("脚本已停止运行")
util.stop_script()
end
end
-- Require
require "RScript.Tables"
require "RScript.alternatives"
require "RScript.functions"
require "RScript.functions2"
require "RScript.libs2"
require "RScript.utils"
local Tunables <const> = {
XM22_GUN_VAN_SLOT_WEAPON_TYPE_0 = 34328,
-- Contact Mission
CONTACT_MISSION_TIME_PERIOD_1 = 8529,
CONTACT_MISSION_CASH_TIME_PERIOD_1_PERCENTAGE = 8538,
CONTACT_MISSION_CASH_PLAYER_MULTIPLIER_1 = 8545,
CONTACT_MISSION_CASH_DIFFICULTY_MULTIPLIER_EASY = 8556,
CONTACT_MISSION_FAIL_CASH_TIME_PERIOD_2_DIVIDER = 8560,
CONTACT_MISSION_RP_TIME_PERIOD_1_PERCENTAGE = 8580,
CONTACT_MISSION_RP_DIFFICULTY_MULTIPLIER_EASY = 8591,
CONTACT_MISSION_FAIL_RP_TIME_PERIOD_2_DIVIDER = 8570,
-- Health & Armour
MAX_HEALTH_MULTIPLIER = 107,
HEALTH_REGEN_RATE_MULTIPLIER = 109,
HEALTH_REGEN_MAX_MULTIPLIER = 110,
MAX_ARMOR_MULTIPLIER = 112,
CasinoHeist = {
TargetWeighting = {
29086, -- CH_VAULT_WEIGHTING_CASH
29087, -- CH_VAULT_WEIGHTING_ART
29088, -- CH_VAULT_WEIGHTING_GOLD
29089, -- CH_VAULT_WEIGHTING_DIAMONDS
},
},
PericoHeist = {
TargetWeighting = {
30188, -- H4_TARGET_WEIGHTING_TEQUILA
30189, -- H4_TARGET_WEIGHTING_PEARL_NECKLACE
30190, -- H4_TARGET_WEIGHTING_BEARER_BONDS
30191, -- H4_TARGET_WEIGHTING_PINK_DIAMOND
30192, -- H4_TARGET_WEIGHTING_SAPPHIRE_PANTHER_STATUE
},
},
}
local Globals <const> = {
GunVanSpawnPoint = 1948900,
}
local Loop_Handler = {
Tunables = {
ContactMission = {},
},
}
---------------------------------------------
---------- Script Menu Start ----------
---------------------------------------------
if not SCRIPT_SILENT_START then
local GTAO = tonumber(NETWORK.GET_ONLINE_VERSION())
if SUPPORT_GTAO ~= GTAO then
util.toast("支持的GTA线上版本: " .. SUPPORT_GTAO .. "\n当前GTA线上版本: " .. GTAO)
end
end
Menu_Root = menu.my_root()
menu.divider(Menu_Root, "RScript2")
----------------------------------------------
---------- Nearby Ped Options ----------
----------------------------------------------
local Nearby_Ped_Options <const> = menu.list(Menu_Root, "附近NPC选项", {}, "")
--#region Nearby Ped Options
local NearbyPed = {
can_handler_run = false,
is_handler_runing = false,
setting = {
radius = 60.0,
ped_select = 1,
time_delay = 1000,
exclude_ped_in_vehicle = true,
exclude_friendly = true,
exclude_mission = true,
exclude_dead = true,
},
toggles = {},
data = {
forward_degree = 30,
drop_money_amount = 100,
weapon_hash = 4130548542,
launch_height = 30.0,
force_field = {
strength = 1.0,
direction = 1,
ragdoll = true,
},
},
callback = {},
}
function NearbyPed.CheckPed(ped)
-- 排除 玩家
if is_player_ped(ped) then
return false
end
-- 排除 载具内NPC
if NearbyPed.setting.exclude_ped_in_vehicle and PED.IS_PED_IN_ANY_VEHICLE(ped, false) then
return false
end
-- 排除 友好NPC
if NearbyPed.setting.exclude_friendly and is_friendly_ped(ped) then
return false
end
-- 排除 任务NPC
if NearbyPed.setting.exclude_mission and ENTITY.IS_ENTITY_A_MISSION_ENTITY(ped) then
return false
end
-- 排除 已死亡实体
if NearbyPed.setting.exclude_dead and ENTITY.IS_ENTITY_DEAD(ped) then
return false
end
-- 敌对NPC
if NearbyPed.setting.ped_select == 2 and not is_hostile_ped(ped) then
return false
end
return true
end
function NearbyPed.GetPeds()
local peds = {}
local player_pos = ENTITY.GET_ENTITY_COORDS(players.user_ped())
local radius = NearbyPed.setting.radius
for k, ent in pairs(entities.get_all_peds_as_handles()) do
local ped = 0
local ent_pos = ENTITY.GET_ENTITY_COORDS(ent)
if radius <= 0 then
ped = ent
elseif v3.distance(player_pos, ent_pos) <= radius then
ped = ent
end
if ped ~= 0 and NearbyPed.CheckPed(ped) then
table.insert(peds, ped)
end
end
return peds
end
function NearbyPed.ToggleChanged(key, toggle)
NearbyPed.toggles[key] = toggle
NearbyPed.TickHandler()
end
function NearbyPed.TickHandler()
local is_all_false = true
for key, bool in pairs(NearbyPed.toggles) do
if bool then
is_all_false = false
break
end
end
if is_all_false then
NearbyPed.can_handler_run = false
else
if not NearbyPed.is_handler_running then
NearbyPed.can_handler_run = true
NearbyPed.ControlPeds()
end
end
end
function NearbyPed.ControlPeds()
util.create_tick_handler(function()
if not NearbyPed.can_handler_run then
NearbyPed.is_handler_running = false
util.log("[RScript] Control Nearby Peds: Stop Tick Handler")
return false
end
NearbyPed.is_handler_runing = true
for _, ped in pairs(NearbyPed.GetPeds()) do
request_control(ped)
for key, bool in pairs(NearbyPed.toggles) do
if bool then
if NearbyPed.callback[key] ~= nil then
NearbyPed.callback[key](ped)
end
end
end
end
util.yield(NearbyPed.setting.time_delay)
end)
end
menu.slider_float(Nearby_Ped_Options, "范围半径", { "radius_nearby_ped" },
"若半径是0, 则为全部范围", 0, 100000, 6000, 1000, function(value)
NearbyPed.setting.radius = value * 0.01
end)
menu.toggle_loop(Nearby_Ped_Options, "绘制范围", {}, "", function()
local coords = ENTITY.GET_ENTITY_COORDS(players.user_ped())
DRAW_MARKER_SPHERE(coords, NearbyPed.setting.radius)
end)
menu.list_select(Nearby_Ped_Options, "NPC类型", {}, "", {
{ "全部NPC", {}, "" },
{ "敌对NPC", {}, "" },
}, 1, function(value)
NearbyPed.setting.ped_select = value
end)
--#region Nearby Ped Setting
local Nearby_Ped_Setting <const> = menu.list(Nearby_Ped_Options, "设置", {}, "")
menu.slider(Nearby_Ped_Setting, "循环时间间隔", { "delay_nearby_ped" }, "单位: ms",
0, 5000, 1000, 100, function(value)
NearbyPed.setting.time_delay = value
end)
menu.divider(Nearby_Ped_Setting, "排除")
menu.toggle(Nearby_Ped_Setting, "排除 载具内NPC", {}, "", function(toggle)
NearbyPed.setting.exclude_ped_in_vehicle = toggle
end, true)
menu.toggle(Nearby_Ped_Setting, "排除 友好NPC", {}, "", function(toggle)
NearbyPed.setting.exclude_friendly = toggle
end, true)
menu.toggle(Nearby_Ped_Setting, "排除 任务NPC", {}, "", function(toggle)
NearbyPed.setting.exclude_mission = toggle
end, true)
menu.toggle(Nearby_Ped_Setting, "排除 已死亡实体", {}, "", function(toggle)
NearbyPed.setting.exclude_dead = toggle
end, true)
--#endregion Nearby Ped Setting
--#region Nearby Ped Trolling
local Nearby_Ped_Trolling <const> = menu.list(Nearby_Ped_Options, "恶搞选项", {}, "")
--------------------
-- Delay Loop
--------------------
menu.slider(Nearby_Ped_Trolling, "推进程度", { "nearby_ped_forward_degree" }, "",
0, 1000, 30, 10, function(value)
NearbyPed.data.forward_speed = value
end)
menu.toggle(Nearby_Ped_Trolling, "设置向前推进", {}, "", function(toggle)
NearbyPed.ToggleChanged("force_forward", toggle)
NearbyPed.callback["force_forward"] = function(ped)
ENTITY.SET_ENTITY_MAX_SPEED(ped, 99999)
local vector = ENTITY.GET_ENTITY_FORWARD_VECTOR(ped)
local force = Vector.mult(vector, NearbyPed.data.forward_degree)
ENTITY.APPLY_FORCE_TO_ENTITY(ped,
1,
force.x, force.y, force.z,
0.0, 0.0, 0.0,
1,
false, true, true, true, true)
end
end)
menu.toggle(Nearby_Ped_Trolling, "丢弃武器", {}, "", function(toggle)
NearbyPed.ToggleChanged("drop_weapon", toggle)
NearbyPed.callback["drop_weapon"] = function(ped)
WEAPON.SET_PED_DROPS_WEAPONS_WHEN_DEAD(ped)
WEAPON.SET_PED_AMMO_TO_DROP(ped, 9999)
WEAPON.SET_PED_DROPS_WEAPON(ped)
end
end)
menu.toggle(Nearby_Ped_Trolling, "爆头", {}, "", function(toggle)
NearbyPed.ToggleChanged("explode_head", toggle)
NearbyPed.callback["explode_head"] = function(ped)
local weaponHash = util.joaat("WEAPON_APPISTOL")
PED.EXPLODE_PED_HEAD(ped, weaponHash)
end
end)
menu.toggle(Nearby_Ped_Trolling, "摔倒", {}, "", function(toggle)
NearbyPed.ToggleChanged("ragdoll", toggle)
NearbyPed.callback["ragdoll"] = function(ped)
PED.SET_PED_TO_RAGDOLL(ped, 500, 500, 0, false, false, false)
end
end)
menu.toggle(Nearby_Ped_Trolling, "忽略临时事件", {}, "", function(toggle)
NearbyPed.ToggleChanged("block_temporary", toggle)
NearbyPed.callback["block_temporary"] = function(ped)
PED.SET_BLOCKING_OF_NON_TEMPORARY_EVENTS(ped, true)
TASK.TASK_SET_BLOCKING_OF_NON_TEMPORARY_EVENTS(ped, true)
PED.SET_BLOCKING_OF_NON_TEMPORARY_EVENTS_FOR_AMBIENT_PEDS_THIS_FRAME(true)
end
end)
menu.toggle(Nearby_Ped_Trolling, "清除任务", {}, "", function(toggle)
NearbyPed.ToggleChanged("clear_task", toggle)
NearbyPed.callback["clear_task"] = function(ped)
TASK.CLEAR_PED_TASKS(ped)
TASK.CLEAR_DEFAULT_PRIMARY_TASK(ped)
TASK.CLEAR_PED_SECONDARY_TASK(ped)
end
end)
menu.toggle(Nearby_Ped_Trolling, "立即清除任务", {}, "", function(toggle)
NearbyPed.ToggleChanged("clear_task_immediately", toggle)
NearbyPed.callback["clear_task_immediately"] = function(ped)
TASK.CLEAR_PED_TASKS_IMMEDIATELY(ped)
end
end)
--------------------
-- Once
--------------------
menu.divider(Nearby_Ped_Trolling, "")
menu.slider(Nearby_Ped_Trolling, "上天高度", { "nearby_ped_launch" }, "",
0, 1000, 30, 10, function(value)
NearbyPed.data.launch_height = value
end)
menu.action(Nearby_Ped_Trolling, "发射上天", {}, "", function()
for k, ped in pairs(NearbyPed.GetPeds()) do
ENTITY.APPLY_FORCE_TO_ENTITY(ped,
1,
0.0, 0.0, NearbyPed.data.launch_height,
0.0, 0.0, 0.0,
0,
false, false, true, false, false)
end
end)
menu.action(Nearby_Ped_Trolling, "坠落爆炸", {}, "", function()
for k, ped in pairs(NearbyPed.GetPeds()) do
util.create_thread(function()
fall_entity_explosion(ped)
end)
end
end)
--------------------
-- No Delay Loop
--------------------
menu.divider(Nearby_Ped_Trolling, "力场")
menu.slider_float(Nearby_Ped_Trolling, "强度", { "nearby_ped_forcefield_strength" }, "",
100, 10000, 100, 100, function(value)
NearbyPed.data.force_field.strength = value * 0.01
end)
menu.textslider_stateful(Nearby_Ped_Trolling, "方向", {}, "", { "推开", "拉进" }, function(value)
NearbyPed.data.force_field.direction = value
end)
menu.toggle(Nearby_Ped_Trolling, "摔倒", {}, "", function(toggle)
NearbyPed.data.force_field.ragdoll = toggle
end, true)
menu.toggle_loop(Nearby_Ped_Trolling, "开启力场", {}, "", function()
for k, ped in pairs(NearbyPed.GetPeds()) do
local force = ENTITY.GET_ENTITY_COORDS(ped)
v3.sub(force, ENTITY.GET_ENTITY_COORDS(players.user_ped()))
v3.normalise(force)
v3.mul(force, NearbyPed.data.force_field.strength)
if NearbyPed.data.force_field.direction == 2 then
v3.mul(force, -1)
end
if NearbyPed.data.force_field.ragdoll then
PED.SET_PED_TO_RAGDOLL(ped, 500, 500, 0, false, false, false)
end
ENTITY.APPLY_FORCE_TO_ENTITY(ped,
3,
force.x, force.y, force.z,
0, 0, 0.5,
0,
false, false, true, false, false)
end
end)
--#endregion Nearby Ped Trolling
--#region Nearby Ped Friendly
local Nearby_Ped_Friendly <const> = menu.list(Nearby_Ped_Options, "友好选项", {}, "")
--------------------
-- Delay Loop
--------------------
menu.slider(Nearby_Ped_Friendly, "现金数量", { "nearby_ped_drop_money_amonut" }, "",
0, 2000, 100, 100, function(value)
NearbyPed.data.drop_money_amount = value
end)
menu.toggle(Nearby_Ped_Friendly, "设置掉落现金", {}, "", function(toggle)
NearbyPed.ToggleChanged("drop_money", toggle)
NearbyPed.callback["drop_money"] = function(ped)
PED.SET_PED_MONEY(ped, NearbyPed.data.drop_money_amount)
PED.SET_AMBIENT_PEDS_DROP_MONEY(true)
end
end)
menu.list_select(Nearby_Ped_Friendly, "武器", {}, "", RS_T.CommonWeapons, RS_T.CommonWeapons[1][1], function(value)
NearbyPed.data.weapon_hash = value
end)
menu.toggle(Nearby_Ped_Friendly, "给予武器", {}, "", function(toggle)
NearbyPed.ToggleChanged("give_weapon", toggle)
NearbyPed.callback["give_weapon"] = function(ped)
WEAPON.GIVE_WEAPON_TO_PED(ped, NearbyPed.data.weapon_hash, -1, false, true)
WEAPON.SET_CURRENT_PED_WEAPON(ped, NearbyPed.data.weapon_hash, false)
end
end)
--#endregion Nearby Ped Friendly
--#region Nearby Ped Combat
local Nearby_Ped_Combat <const> = menu.list(Nearby_Ped_Options, "作战能力选项", {}, "")
NearbyPed.Combat = {
health = 100,
investigate = 1,
weapon = 1,
ability = 1,
range = 1,
movement = 1,
target_loss_response = 1,
behavior = 1,
}
menu.toggle_loop(Nearby_Ped_Combat, "设置作战能力", {}, "", function()
local combat_data = NearbyPed.Combat
for k, ped in pairs(NearbyPed.GetPeds()) do
-- 生命值
if combat_data.health >= 100 then
SET_ENTITY_HEALTH(ped, combat_data.health)
end
-- 侦查能力
if combat_data.investigate > 1 then
if combat_data.investigate == 2 then
-- 弱化
PED.SET_PED_SEEING_RANGE(ped, 0)
PED.SET_PED_HEARING_RANGE(ped, 0)
PED.SET_PED_ID_RANGE(ped, 0)
PED.SET_PED_VISUAL_FIELD_PERIPHERAL_RANGE(ped, 0)
PED.SET_PED_VISUAL_FIELD_MIN_ANGLE(ped, 0)
PED.SET_PED_VISUAL_FIELD_MAX_ANGLE(ped, 0)
PED.SET_PED_VISUAL_FIELD_MIN_ELEVATION_ANGLE(ped, 0)
PED.SET_PED_VISUAL_FIELD_MAX_ELEVATION_ANGLE(ped, 0)
PED.SET_PED_VISUAL_FIELD_CENTER_ANGLE(ped, 0)
PED.SET_PED_HIGHLY_PERCEPTIVE(ped, false)
PED.SET_PED_COMBAT_ATTRIBUTES(ped, 14, false) -- CA_CAN_INVESTIGATE
PED.SET_PED_COMBAT_ATTRIBUTES(ped, 79, false) -- CA_WILL_GENERATE_DEAD_PED_SEEN_SCRIPT_EVENTS
PED.SET_PED_COMBAT_ATTRIBUTES(ped, 80, false) -- CA_USE_MAX_SENSE_RANGE_WHEN_RECEIVING_EVENTS
PED.SET_COMBAT_FLOAT(ped, 14, 0) -- CCF_BULLET_IMPACT_DETECTION_RANGE
PED.SET_COMBAT_FLOAT(ped, 21, 0) -- CCF_MAX_DISTANCE_TO_HEAR_EVENTS
PED.SET_COMBAT_FLOAT(ped, 22, 0) -- CCF_MAX_DISTANCE_TO_HEAR_EVENTS_USING_LOS
PED.SET_PED_CONFIG_FLAG(ped, 213, false) -- PCF_ListensToSoundEvents
PED.SET_PED_CONFIG_FLAG(ped, 294, true) -- PCF_DisableShockingEvents
PED.SET_PED_CONFIG_FLAG(ped, 315, false) -- PCF_CheckLoSForSoundEvents
else
-- 强化
PED.SET_PED_SEEING_RANGE(ped, 500)
PED.SET_PED_HEARING_RANGE(ped, 500)
PED.SET_PED_ID_RANGE(ped, 500)
PED.SET_PED_VISUAL_FIELD_PERIPHERAL_RANGE(ped, 100)
PED.SET_PED_VISUAL_FIELD_MIN_ANGLE(ped, 90)
PED.SET_PED_VISUAL_FIELD_MAX_ANGLE(ped, 90)
PED.SET_PED_VISUAL_FIELD_MIN_ELEVATION_ANGLE(ped, 90)
PED.SET_PED_VISUAL_FIELD_MAX_ELEVATION_ANGLE(ped, 90)
PED.SET_PED_VISUAL_FIELD_CENTER_ANGLE(ped, 90)
PED.SET_PED_HIGHLY_PERCEPTIVE(ped, true)
PED.SET_PED_COMBAT_ATTRIBUTES(ped, 14, true) -- CA_CAN_INVESTIGATE
PED.SET_PED_COMBAT_ATTRIBUTES(ped, 79, true) -- CA_WILL_GENERATE_DEAD_PED_SEEN_SCRIPT_EVENTS
PED.SET_PED_COMBAT_ATTRIBUTES(ped, 80, true) -- CA_USE_MAX_SENSE_RANGE_WHEN_RECEIVING_EVENTS
PED.SET_COMBAT_FLOAT(ped, 14, 100) -- CCF_BULLET_IMPACT_DETECTION_RANGE
PED.SET_COMBAT_FLOAT(ped, 21, 100) -- CCF_MAX_DISTANCE_TO_HEAR_EVENTS
PED.SET_COMBAT_FLOAT(ped, 22, 100) -- CCF_MAX_DISTANCE_TO_HEAR_EVENTS_USING_LOS
PED.SET_PED_CONFIG_FLAG(ped, 213, true) -- PCF_ListensToSoundEvents
PED.SET_PED_CONFIG_FLAG(ped, 294, false) -- PCF_DisableShockingEvents
PED.SET_PED_CONFIG_FLAG(ped, 315, true) -- PCF_CheckLoSForSoundEvents
end
end
-- 武器能力
if combat_data.weapon > 1 then
if combat_data.weapon == 2 then
-- 弱化
PED.SET_PED_ACCURACY(ped, 0)
PED.SET_PED_SHOOT_RATE(ped, 0)
PED.SET_PED_COMBAT_ATTRIBUTES(ped, 27, false) -- CA_PERFECT_ACCURACY
PED.SET_COMBAT_FLOAT(ped, 6, 0) -- CCF_WEAPON_ACCURACY
else
-- 强化
PED.SET_PED_ACCURACY(ped, 100)
PED.SET_PED_SHOOT_RATE(ped, 1000)
PED.SET_PED_COMBAT_ATTRIBUTES(ped, 27, true) -- CA_PERFECT_ACCURACY
PED.SET_COMBAT_FLOAT(ped, 6, 1.0) -- CCF_WEAPON_ACCURACY
end
end
-- 作战技能
if combat_data.ability > 1 then
PED.SET_PED_COMBAT_ABILITY(ped, combat_data.ability - 2)
end
-- 作战范围
if combat_data.range > 1 then
PED.SET_PED_COMBAT_RANGE(ped, combat_data.range - 2)
end
-- 作战走位
if combat_data.movement > 1 then
PED.SET_PED_COMBAT_MOVEMENT(ped, combat_data.movement - 2)
end
-- 失去目标时反应
if combat_data.target_loss_response > 1 then
PED.SET_PED_TARGET_LOSS_RESPONSE(ped, combat_data.target_loss_response - 2)
end
-- 其它行为
if NearbyPed.Combat.behavior == 2 then
PED.STOP_PED_WEAPON_FIRING_WHEN_DROPPED(ped)
PED.DISABLE_PED_INJURED_ON_GROUND_BEHAVIOUR(ped)
PED.REMOVE_PED_DEFENSIVE_AREA(ped, false)
end
end
util.yield(NearbyPed.setting.time_delay)
end)
menu.divider(Nearby_Ped_Combat, "设置")
menu.slider(Nearby_Ped_Combat, "生命值", { "nearby_ped_combat_health" }, "数值低于100则不进行修改",
0, 10000, 100, 100, function(value)
NearbyPed.Combat.health = value
end)
menu.list_select(Nearby_Ped_Combat, "侦查能力", {},
"视力、听力、识别、锥形视野、视野角度、高度警觉性 等等", {
{ "无操作", {}, "" },
{ "弱化", {}, "" },
{ "强化", {}, "" },
}, 1, function(value)
NearbyPed.Combat.investigate = value
end)
menu.list_select(Nearby_Ped_Combat, "武器能力", {},
"精准度、射击频率", {
{ "无操作", {}, "" },
{ "弱化", {}, "" },
{ "强化", {}, "" },
}, 1, function(value)
NearbyPed.Combat.weapon = value
end)
menu.list_select(Nearby_Ped_Combat, "作战技能", {}, "", {
"无操作", "弱", "普通", "专业"
}, 1, function(value)
NearbyPed.Combat.ability = value
end)
menu.list_select(Nearby_Ped_Combat, "作战范围", {}, "", {
"无操作", "近", "中等", "远", "非常远"
}, 1, function(value)
NearbyPed.Combat.range = value
end)
menu.list_select(Nearby_Ped_Combat, "作战走位", {}, "", {
"无操作", "站立", "防卫", "会前进", "会后退"
}, 1, function(value)
NearbyPed.Combat.movement = value
end)
menu.list_select(Nearby_Ped_Combat, "失去目标时反应", {}, "", {
"无操作", "退出战斗", "从不失去目标", "寻找目标"
}, 1, function(value)
NearbyPed.Combat.target_loss_response = value
end)
menu.list_select(Nearby_Ped_Combat, "其它行为", {},
"武器掉落时走火、受伤时在地面打滚、防卫区域", {
{ "无操作", {}, "" },
{ "禁用", {}, "" },
}, 1, function(value)
NearbyPed.Combat.behavior = value
end)
--#endregion Nearby Ped Combat
--#endregion Nearby Ped Options
--------------------------------------------------
---------- Nearby Vehicle Options ----------
--------------------------------------------------
local Nearby_Vehicle_Options <const> = menu.list(Menu_Root, "附近载具选项", {}, "")
--#region Nearby Vehicle Options
local NearbyVehicle = {
can_handler_run = false,
is_handler_runing = false,
setting = {
radius = 60.0,
vehicle_select = 1,
time_delay = 1000,
exclude_player = true,
exclude_mission = true,
exclude_dead = true,
},
toggles = {},
data = {
forward_speed = 30,
max_speed = 0,
alpha = 0,
force_field = 1.0,
launch_height = 30.0,
},
callback = {},
}
function NearbyVehicle.CheckVehicle(vehicle)
-- 排除 玩家载具
if NearbyVehicle.setting.exclude_player and is_player_vehicle(vehicle) then
return false
end
-- 排除 任务载具
if NearbyVehicle.setting.exclude_mission and ENTITY.IS_ENTITY_A_MISSION_ENTITY(vehicle) then
return false
end
-- 排除 已死亡实体
if NearbyVehicle.setting.exclude_dead and ENTITY.IS_ENTITY_DEAD(vehicle) then
return false
end
-- NPC载具
if NearbyVehicle.setting.vehicle_select == 2 then
local driver = VEHICLE.GET_PED_IN_VEHICLE_SEAT(vehicle, -1, false)
if not ENTITY.IS_ENTITY_A_PED(driver) then
return false
end
end
-- 敌对载具
if NearbyVehicle.setting.vehicle_select == 3 and not is_hostile_entity(vehicle) then
return false
end
-- 空载具
if NearbyVehicle.setting.vehicle_select == 4 and not VEHICLE.IS_VEHICLE_SEAT_FREE(vehicle, -1, false) then
return false
end
return true
end
function NearbyVehicle.GetVehicles()
local vehicles = {}
local player_pos = ENTITY.GET_ENTITY_COORDS(players.user_ped())
local radius = NearbyVehicle.setting.radius
for k, ent in pairs(entities.get_all_vehicles_as_handles()) do
local vehicle = 0
local ent_pos = ENTITY.GET_ENTITY_COORDS(ent)
if radius <= 0 then
vehicle = ent
elseif v3.distance(player_pos, ent_pos) <= radius then
vehicle = ent
end
if vehicle ~= 0 and NearbyVehicle.CheckVehicle(vehicle) then
table.insert(vehicles, vehicle)
end
end
return vehicles
end
function NearbyVehicle.ToggleChanged(key, toggle)
NearbyVehicle.toggles[key] = toggle
NearbyVehicle.TickHandler()
end
function NearbyVehicle.SelectChanged(key, value)
if value == 1 then
NearbyVehicle.toggles[key] = false
else
NearbyVehicle.toggles[key] = true
end
NearbyVehicle.TickHandler()
end
function NearbyVehicle.TickHandler()
local is_all_false = true
for key, bool in pairs(NearbyVehicle.toggles) do
if bool then
is_all_false = false
break
end
end
if is_all_false then
NearbyVehicle.can_handler_run = false
else
if not NearbyVehicle.is_handler_running then
NearbyVehicle.can_handler_run = true
NearbyVehicle.ControlVehicles()
end
end
end
function NearbyVehicle.ControlVehicles()
util.create_tick_handler(function()
if not NearbyVehicle.can_handler_run then
NearbyVehicle.is_handler_running = false
util.log("[RScript] Control Nearby Vehicles: Stop Tick Handler")
return false
end
NearbyVehicle.is_handler_running = true
for _, vehicle in pairs(NearbyVehicle.GetVehicles()) do
request_control(vehicle)
for key, bool in pairs(NearbyVehicle.toggles) do
if bool then
if NearbyVehicle.callback[key] ~= nil then
NearbyVehicle.callback[key](vehicle)
end
end
end
end
util.yield(NearbyVehicle.setting.time_delay)
end)
end
menu.slider_float(Nearby_Vehicle_Options, "范围半径", { "radius_nearby_vehicle" },
"若半径是0, 则为全部范围", 0, 100000, 6000, 1000, function(value)
NearbyVehicle.setting.radius = value * 0.01
end)
menu.toggle_loop(Nearby_Vehicle_Options, "绘制范围", {}, "", function()
local coords = ENTITY.GET_ENTITY_COORDS(players.user_ped())
DRAW_MARKER_SPHERE(coords, NearbyVehicle.setting.radius)
end)
menu.list_select(Nearby_Vehicle_Options, "载具类型", {}, "", {
{ "全部载具", {}, "" },
{ "NPC载具", {}, "有NPC作为司机驾驶的载具" },
{ "敌对载具", {}, "有敌对地图标记点或敌对NPC驾驶的载具" },
{ "空载具", {}, "无人驾驶的载具" },
}, 1, function(value)
NearbyVehicle.setting.vehicle_select = value
end)
--#region Nearby Vehicle Setting
local Nearby_Vehicle_Setting <const> = menu.list(Nearby_Vehicle_Options, "设置", {}, "")
menu.slider(Nearby_Vehicle_Setting, "循环时间间隔", { "delay_nearby_vehicle" }, "单位: ms",
0, 5000, 1000, 100, function(value)
NearbyVehicle.setting.time_delay = value
end)
menu.divider(Nearby_Vehicle_Setting, "排除")
menu.toggle(Nearby_Vehicle_Setting, "排除 玩家载具", {}, "", function(toggle)
NearbyVehicle.setting.exclude_player = toggle
end, true)
menu.toggle(Nearby_Vehicle_Setting, "排除 任务载具", {}, "", function(toggle)
NearbyVehicle.setting.exclude_mission = toggle
end, true)
menu.toggle(Nearby_Vehicle_Setting, "排除 已死亡实体", {}, "", function(toggle)
NearbyVehicle.setting.exclude_dead = toggle
end, true)
--#endregion Nearby Vehicle Setting
--#region Nearby Vehicle Trolling
local Nearby_Vehicle_Trolling <const> = menu.list(Nearby_Vehicle_Options, "恶搞选项", {}, "")
----------------------
-- Delay Loop
----------------------
menu.toggle(Nearby_Vehicle_Trolling, "移除无敌", {}, "", function(toggle)
NearbyVehicle.ToggleChanged("remove_godmode", toggle)
NearbyVehicle.callback["remove_godmode"] = function(vehicle)
set_entity_godmode(vehicle, false)
end
end)
menu.list_select(Nearby_Vehicle_Trolling, "车门", {}, "", {
"无操作", "打开", "拆下", "删除"
}, 1, function(value)
NearbyVehicle.SelectChanged("door", value)
if value == 2 then
NearbyVehicle.callback["door"] = function(vehicle)
for i = 0, 3 do
if VEHICLE.GET_IS_DOOR_VALID(vehicle, i) then
VEHICLE.SET_VEHICLE_DOOR_OPEN(vehicle, i, false, false)
end
end
end
elseif value == 3 then
NearbyVehicle.callback["door"] = function(vehicle)
for i = 0, 3 do
if VEHICLE.GET_IS_DOOR_VALID(vehicle, i) then
VEHICLE.SET_VEHICLE_DOOR_BROKEN(vehicle, i, false)
end
end
end
elseif value == 4 then
NearbyVehicle.callback["door"] = function(vehicle)
for i = 0, 3 do
if VEHICLE.GET_IS_DOOR_VALID(vehicle, i) then
VEHICLE.SET_VEHICLE_DOOR_BROKEN(vehicle, i, true)
end
end
end
end
end)
menu.list_select(Nearby_Vehicle_Trolling, "车窗", {}, "", {
"无操作", "删除", "破坏"
}, 1, function(value)
NearbyVehicle.SelectChanged("window", value)
if value == 2 then
NearbyVehicle.callback["window"] = function(vehicle)
for i = 0, 7 do
VEHICLE.REMOVE_VEHICLE_WINDOW(vehicle, i)
end
end
elseif value == 3 then
NearbyVehicle.callback["window"] = function(vehicle)
for i = 0, 7 do
VEHICLE.SMASH_VEHICLE_WINDOW(vehicle, i)
end
end
end
end)
menu.toggle(Nearby_Vehicle_Trolling, "破坏引擎", {}, "", function(toggle)
NearbyVehicle.ToggleChanged("kill_engine", toggle)
NearbyVehicle.callback["kill_engine"] = function(vehicle)
VEHICLE.SET_VEHICLE_ENGINE_HEALTH(vehicle, -4000)
end
end)
menu.toggle(Nearby_Vehicle_Trolling, "爆胎", {}, "", function(toggle)
NearbyVehicle.ToggleChanged("burst_tyre", toggle)
NearbyVehicle.callback["burst_tyre"] = function(vehicle)
for i = 0, 5 do
if not VEHICLE.IS_VEHICLE_TYRE_BURST(vehicle, i, true) then
VEHICLE.SET_VEHICLE_TYRE_BURST(vehicle, i, true, 1000.0)
end
end
end
end)
menu.toggle(Nearby_Vehicle_Trolling, "布满灰尘", {}, "", function(toggle)
NearbyVehicle.ToggleChanged("full_dirt", toggle)
NearbyVehicle.callback["full_dirt"] = function(vehicle)
VEHICLE.SET_VEHICLE_DIRT_LEVEL(vehicle, 15.0)
end
end)
menu.toggle(Nearby_Vehicle_Trolling, "分离车轮", {}, "", function(toggle)
NearbyVehicle.ToggleChanged("detach_wheel", toggle)
NearbyVehicle.callback["detach_wheel"] = function(vehicle)
for i = 0, 5 do
entities.detach_wheel(vehicle, i)
end
end
end)
menu.toggle(Nearby_Vehicle_Trolling, "司机跳出载具", {}, "", function(toggle)
NearbyVehicle.ToggleChanged("leave_vehicle", toggle)
NearbyVehicle.callback["leave_vehicle"] = function(vehicle)
local ped = VEHICLE.GET_PED_IN_VEHICLE_SEAT(vehicle, -1)
if ped ~= 0 and not TASK.GET_IS_TASK_ACTIVE(ped, 176) then
TASK.TASK_LEAVE_VEHICLE(ped, vehicle, 4160)
end
end
end)
menu.list_select(Nearby_Vehicle_Trolling, "爆炸", {}, "", {
"无操作", "匿名爆炸", "署名爆炸"
}, 1, function(value)
NearbyVehicle.SelectChanged("explosion", value)
if value == 2 then
NearbyVehicle.callback["explosion"] = function(vehicle)
local pos = ENTITY.GET_ENTITY_COORDS(vehicle)
add_explosion(pos)
end
elseif value == 3 then
NearbyVehicle.callback["explosion"] = function(vehicle)
local pos = ENTITY.GET_ENTITY_COORDS(vehicle)
add_owned_explosion(players.user_ped(), pos)
end
end
end)
menu.slider(Nearby_Vehicle_Trolling, "加速度", { "nearby_veh_forward_speed" }, "",
0, 1000, 30, 10, function(value)
NearbyVehicle.data.forward_speed = value
end)
menu.toggle(Nearby_Vehicle_Trolling, "设置向前加速", {}, "", function(toggle)
NearbyVehicle.ToggleChanged("forward_speed", toggle)
NearbyVehicle.callback["forward_speed"] = function(vehicle)
VEHICLE.SET_VEHICLE_FORWARD_SPEED(vehicle, NearbyVehicle.data.forward_speed)
end
end)
menu.slider(Nearby_Vehicle_Trolling, "最大速度", { "nearby_veh_max_speed" }, "",
0, 1000, 0, 10, function(value)
NearbyVehicle.data.max_speed = value
end)
menu.toggle(Nearby_Vehicle_Trolling, "设置实体最大速度", {}, "", function(toggle)
NearbyVehicle.ToggleChanged("max_speed", toggle)