-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperation.py
More file actions
8127 lines (7511 loc) · 319 KB
/
operation.py
File metadata and controls
8127 lines (7511 loc) · 319 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
import json
import math
import os, unittest
import random
import threading
import time
import traceback
import numpy as np
import psutil
import requests
import random
from skywalks_auto.core.auto import *
from skywalks_auto.util.tool import get_self_ip, make_random_account_uuid
from skywalks_auto.util.server_tools import write_log_and_upload_file_v2, write_log_and_upload_file
from skywalks_auto.util.time_util import tu
from operation_tools.multiplayer_op import MultiplayerOperation, get_server_list
from soc_util import project_file_path_info
from soc_util.soc_tools import read_xlsx, table_string_2_int_list, soc_down_perf_str_2_info, \
soc_perf_list_to_performance_platform, ProFiler, soc_down_perf_str_2_info_v2, \
soc_down_common_str_2_info, soc_down_memory_str_2_info, soc_down_dc_str_2_info_v2, soc_read_performance_data, \
soc_read_origin_url_data, soc_performance_data_update
from soc_util.time_util import TimeUtil
from soc_util.uwa_tools import read_excel_for_phone, find_report_by_iphone, get_recent_report_list, get_overview_report, \
tidy_report_v1
def err_win_filter(auto: Automation = None, **kwargs):
"""
异常窗口过滤
:return:
"""
return
# 里面的逻辑不能少
if auto is None:
auto = Automation(__file__, client_type=TestEnv.pc_poco,
rpc=True) # 走到这里一般都进游戏了,这种函数要根据不同游戏进行初始化,后续可以把case_init的逻辑加进来
print("err_win_filter auto 初始化")
auto.set_kwargs(**kwargs)
print("err_win_filter", auto.init_kwargs)
device_ip = ""
platform = auto.init_kwargs.get("task_info", {}).get('platform', "pc")
if platform == "android":
device_ip = auto.init_kwargs.get('device_ip', "")
client_type = get_test_env(2)
elif auto.init_kwargs.get("rpc", False):
client_type = get_test_env(6)
elif platform == "exe" or platform == "editor" or platform == "remoteDevices":
client_type = get_test_env(6)
else:
client_type = get_test_env(
auto.init_kwargs.get('client_type', 5)) # todo 这里可以优化一下,改成根据任务的类型和包体命名规则去拿默认链接类型
print("err_win_filter client_type", auto.get_client_type(), client_type)
if auto.get_client_type() != client_type:
auto.set_client_type(client_type, device_ip)
# 这里开始是业务逻辑
# 判断摄像机高度,看看有没有掉到地下
result_data, result, msg = auto.send_rpc_and_read_result({"camera": {"get": ""}})
if result:
if result_data["position"]["y"] < -5:
raise Exception("掉到地下了")
return auto
class Operation:
def __init__(self, auto: Automation):
self.auto = auto
#7号地图
self.transmit_list = [[1830, 4, -1447], [-46, 4, -1661]]
#12号地图
self.transmit_list_12 = [[815, 4, -1225], [935, 4, -955]]
self.build_name_dict = {'foundation': "地基", 'roof': "屋顶", 'steps': "地基楼梯", 'ramp': "斜坡",
'floor': "地板", 'floor-triangle': "三角地板", 'floor-frame': "地板框架",
'floor-triangle-frame': "三角地板框架", 'wall': "墙壁", 'doorway': "门框墙壁",
'window': "窗框墙壁", 'wall-frame': "墙壁框架", 'half-wall': "半墙",
'low-wall': "1/3墙",
'u-shaped-stairs': "U型楼梯", 'stairs-l-shape': "L型楼梯", 'stairs-spiral': "矩形楼梯",
'stairs-spiral-triangle': "三角楼梯", 'roof-triangle': "三角屋顶",
'triangle-foundation': "三角地基"}
self.build_lv_dict = {'twig': 0, 'wooden': 1, 'stone': 2, 'metal': 3, 'armored': 4}
# 建筑等级与材质的对照表 0 通用 11 是wood 6是rock 7是metal
self.build_lv_material = {'twig': 0, 'wooden': 11, 'stone': 6, 'metal': 7, 'armored': 7}
self.build_condition_lost = {1: [1, 1, 0.6, 0.6], 2: 0.5, 3: 0.334, 4: 0.334,
5: [0.334, 0.334, 0.334, 0.5], 8: [0.334, 0.2, 0.334, 0.2]}
#7号地图
self.horse_transmit_list_7 = [[-550.75, 3.064265, -930.4453], [470.9986, 4.009006, 1285.353], [-1249, 11, 363],
[-926, 3, -1610], [1153, 22, 1418]]
#12号地图
self.horse_transmit_list_12 = [[894.8229, 5.099393, -900.1647], [709.724, 24.67768, -279.3724], [238.6402, 26.73364, 79.367],
[-104.6042, 23.82739, 23.26936], [801.024, 9.095385, 1064.549]]
self.tree_transmit_list = [[1834.186, 2.054282, -1438.386], [-295.1662, 8.539398, 155.4172]]
self.robot_list = []
self.role_id = 0 # 角色idw
self.multi_language_info = {} # 多语言装备信息
self.weapon_id_info = {} # 装备缓存信息
self.item_info = {} # 物品缓存信息,用来读取道具总表的内容
self.weapon_name_info = {}
self.parts_id_info = {} # 配件缓存信息
self.parts_name_info = {}
self.building_id_info = {} # 建筑缓存信息
self.building_name_info = {}
self.battle_numerical_value_id_info = {}
self.battle_numerical_value_name_info = {}
self.case_is_pass = False
self.case_name = ""
self.damage_disable = False
self.performance_test_init_info = {}
self.account = ""
self.platform = "pc"
self.server_name = ""
self.performance_test = False
self.perf_info_list = []
self.perf_start_time = 0
self.perf_end_time = 0
self.perf_tag_time_info_list = []
self.memory_monitor_time = 0
self.is_2hours = False
self.server_num = None # 用来记录服务器是哪个数字
self.memory_downpath = ''
self.memory_info_list = []
def robot_new_some(self, new_num, server_name, branch="new", run_time=10, damage_disable=True, is_yc=False,
is_self=False,
soc_git_path="", self_ip=""):
"""
创建一些机器人
@param new_num:
@param server_name:
@param branch:
@param is_self: 是否在本地启动机器人服务,如果传入是,需要传入soc_git_path,可从project_file_path_info中导入
@param soc_git_path:本地a4工程路径,到.git文件夹那一层
@param self_ip:也可以手动启动本地机器人服务,就不用传soc_git_path了,只需要传入机器人服务的IP和端口就行了
@param run_time:
@param is_yc:
@param damage_disable:
@return:
"""
for i in range(new_num):
account = int("1" + make_random_account_uuid())
robot = MultiplayerOperation(account, branch=branch, is_yc=is_yc, run_time=run_time)
# robot.auto_server_multiplayer_run_url = "http://192.168.180.156:5885/runCase"
thread = threading.Thread(target=robot.start_server,
args=(server_name, False, is_self, soc_git_path, self_ip))
thread.start()
self.robot_list.append(robot)
time.sleep(15)
for robot in self.robot_list:
if "失败" in robot.login_msg_info.get("data", "失败"):
self.auto.add_log(f"第{i + 1}个机器人登录失败")
continue
if damage_disable:
print("开启无敌")
robot.set_player_damage_disable(damage_disable)
def robot_transmit_to_random_all(self, x, y, z, random_num, is_ground):
"""
传送到指定的坐标位置附近,以x, y, z为中心,以random_num为边长的方型范围
@param x: 编辑器中SceneCamera的x轴
@param y: 编辑器中SceneCamera的y轴
@param z: 编辑器中SceneCamera的z轴
@param is_ground: 是否落到地面
@param random_num: 坐标随机范围
@return:
"""
for robot in self.robot_list:
thread = threading.Thread(target=robot.transmit_to_random, args=(x, y, z, random_num, is_ground))
thread.start()
def robot_transmit_to_random_list(self, robot_list, x, y, z, random_num, is_ground):
"""
传送到指定的坐标位置附近,以x, y, z为中心,以random_num为边长的方型范围
@param x: 编辑器中SceneCamera的x轴
@param y: 编辑器中SceneCamera的y轴
@param z: 编辑器中SceneCamera的z轴
@param is_ground: 是否落到地面
@param random_num: 坐标随机范围
@param robot_list:
@return:
"""
for robot in robot_list:
thread = threading.Thread(target=robot.transmit_to_random, args=(x, y, z, random_num, is_ground))
thread.start()
def robot_transmit_to(self, robot, x, y, z, is_ground):
"""
传送到指定的坐标位置附近,以x, y, z为中心,以random_num为边长的方型范围
@param x: 编辑器中SceneCamera的x轴
@param y: 编辑器中SceneCamera的y轴
@param z: 编辑器中SceneCamera的z轴
@param is_ground: 是否落到地面
@param robot: 机器人对象
@return:
"""
thread = threading.Thread(target=robot.transmit_to, args=(x, y, z, is_ground))
thread.start()
def robot_transmit_to_all(self, x, y, z, is_ground):
"""
让所有的机器人传送到指定位置
@param x:
@param y:
@param z:
@param is_ground:是否在地面,t是在地面
@return:
"""
for robot in self.robot_list:
thread = threading.Thread(target=robot.transmit_to, args=(x, y, z, is_ground))
thread.start()
time.sleep(2)
def robot_transmit_to_list(self, robot_list, x, y, z, is_ground):
"""
让所有的机器人传送到指定位置
@param x:
@param y:
@param z:
@param is_ground:是否在地面,t是在地面
@param robot_list:
@return:
"""
for robot in robot_list:
thread = threading.Thread(target=robot.transmit_to, args=(x, y, z, is_ground))
thread.start()
def robot_move_to_pos(self, robot, x, y, z):
"""
移动到指定坐标
@param x: 编辑器中SceneCamera的x轴
@param y: 编辑器中SceneCamera的y轴
@param z: 编辑器中SceneCamera的z轴
@param robot: 机器人对象
@return:
"""
thread = threading.Thread(target=robot.move_to_pos, args=(x, y, z))
thread.start()
def robot_move_to_pos_all(self, x, y, z):
"""
移动到指定坐标
@param x: 编辑器中SceneCamera的x轴
@param y: 编辑器中SceneCamera的y轴
@param z: 编辑器中SceneCamera的z轴
@return:
"""
for robot in self.robot_list:
thread = threading.Thread(target=robot.move_to_pos, args=(x, y, z))
thread.start()
def robot_move_to_pos_list(self, robot_list, x, y, z):
"""
移动到指定坐标
@param x: 编辑器中SceneCamera的x轴
@param y: 编辑器中SceneCamera的y轴
@param z: 编辑器中SceneCamera的z轴
@param robot_list:
@return:
"""
for robot in robot_list:
thread = threading.Thread(target=robot.move_to_pos, args=(x, y, z))
thread.start()
def robot_move_pos(self, robot, x, y, z, run_num=5, direction="MoveForward"):
"""
朝指定坐标移动
@param x: 编辑器中SceneCamera的x轴
@param y: 编辑器中SceneCamera的y轴
@param z: 编辑器中SceneCamera的z轴
@param robot: 机器人对象
@param run_num:cmd连发次数
@param direction:前后左右移动 MoveForward MoveBackward MoveRight MoveLeft
@return:
"""
thread = threading.Thread(target=robot.move_pos, args=(x, y, z, run_num, direction))
thread.start()
def robot_move_pos_all(self, x, y, z, run_num=5, direction="MoveForward"):
"""
朝指定坐标移动
@param x: 编辑器中SceneCamera的x轴
@param y: 编辑器中SceneCamera的y轴
@param z: 编辑器中SceneCamera的z轴
@param run_num:cmd连发次数
@param direction:前后左右移动 MoveForward MoveBackward MoveRight MoveLeft
@return:
"""
for robot in self.robot_list:
thread = threading.Thread(target=robot.move_pos, args=(x, y, z, run_num, direction))
thread.start()
def robot_move_pos_list(self, robot_list, x, y, z, run_num=5, direction="MoveForward"):
"""
朝指定坐标移动
@param x: 编辑器中SceneCamera的x轴
@param y: 编辑器中SceneCamera的y轴
@param z: 编辑器中SceneCamera的z轴
@param run_num:cmd连发次数
@param direction:前后左右移动 MoveForward MoveBackward MoveRight MoveLeft
@param robot_list:
@return:
"""
for robot in robot_list:
thread = threading.Thread(target=robot.move_pos, args=(x, y, z, run_num, direction))
thread.start()
def robot_move(self, robot, yaw, run_num=5, direction="MoveForward"):
"""
朝指定方向移动
@param yaw: 方向,如果方向大于360,会按照当前方向移动
@param run_num:cmd连发次数
@param direction:前后左右移动 MoveForward MoveBackward MoveRight MoveLeft
@return:
"""
thread = threading.Thread(target=robot.move, args=(yaw, run_num, direction))
thread.start()
def robot_move_all(self, yaw, run_num=5, direction="MoveForward"):
"""
朝指定方向移动
@param yaw: 方向,如果方向大于360,会按照当前方向移动
@param run_num:cmd连发次数
@param direction:前后左右移动 MoveForward MoveBackward MoveRight MoveLeft
@return:
"""
for robot in self.robot_list:
thread = threading.Thread(target=robot.move, args=(yaw, run_num, direction))
thread.start()
def robot_move_list(self, robot_list, yaw, run_num=5, direction="MoveForward"):
"""
朝指定方向移动
@param yaw: 方向,如果方向大于360,会按照当前方向移动
@param run_num:cmd连发次数
@param direction:前后左右移动 MoveForward MoveBackward MoveRight MoveLeft
@param robot_list:
@return:
"""
for robot in robot_list:
thread = threading.Thread(target=robot.move, args=(yaw, run_num, direction))
thread.start()
def robot_make_part_all(self, part_path):
"""
造死羊建筑
@param part_path:死羊建筑id
@return:
"""
for robot in self.robot_list:
thread = threading.Thread(target=robot.make_part, args=(part_path,))
thread.start()
def robot_make_part_list(self, robot_list, part_path):
"""
造死羊建筑
@param part_path:死羊建筑id
@param robot_list:
@return:
"""
for robot in robot_list:
thread = threading.Thread(target=robot.make_part, args=(part_path,))
thread.start()
def robot_make_part(self, robot, part_path):
"""
造死羊建筑
@param robot:
@param part_path:死羊建筑id
@return:
"""
thread = threading.Thread(target=robot.make_part, args=(part_path,))
thread.start()
def robot_suicide_list(self, robot_list, ):
"""
自杀
@param robot_list:
@return:
"""
for robot in robot_list:
thread = threading.Thread(target=robot.suicide, args=())
thread.start()
def robot_suicide(self, robot, ):
"""
自杀
@param robot:
@return:
"""
thread = threading.Thread(target=robot.suicide, args=())
thread.start()
def robot_suicide_all(self, ):
"""
自杀
@return:
"""
for robot in self.robot_list:
thread = threading.Thread(target=robot.suicide, args=())
thread.start()
def robot_reborn_list(self, robot_list, ):
"""
复活
@param robot_list:
@return:
"""
for robot in robot_list:
thread = threading.Thread(target=robot.reborn, args=())
thread.start()
def robot_switch_headlights(self, robot, enable: bool):
"""
开头灯
"""
thread = threading.Thread(target=robot.switch_headlights, args=(enable,))
thread.start()
def robot_switch_headlights_list(self, robot_list, enable: bool):
"""
开头灯
"""
for robot in robot_list:
thread = threading.Thread(target=robot.switch_headlights, args=(enable,))
thread.start()
def robot_switch_headlights_all(self, enable: bool):
"""
开头灯
"""
for robot in self.robot_list:
thread = threading.Thread(target=robot.switch_headlights, args=(enable,))
thread.start()
def robot_switch_weaponlights(self, robot, enable: bool):
"""
开头灯
"""
thread = threading.Thread(target=robot.switch_weaponlights, args=(enable,))
thread.start()
def robot_switch_weaponlights_list(self, robot_list, enable: bool):
"""
开头灯
"""
for robot in robot_list:
thread = threading.Thread(target=robot.switch_weaponlights, args=(enable,))
thread.start()
def robot_switch_weaponlights_all(self, enable: bool):
"""
开头灯
"""
for robot in self.robot_list:
thread = threading.Thread(target=robot.switch_weaponlights, args=(enable,))
thread.start()
def robot_reborn(self, robot, ):
"""
复活
@param robot:
@return:
"""
thread = threading.Thread(target=robot.reborn, args=())
thread.start()
def robot_reborn_all(self, ):
"""
复活
@return:
"""
for robot in self.robot_list:
thread = threading.Thread(target=robot.reborn, args=())
thread.start()
def robot_wake_up_list(self, robot_list, ):
"""
起床
@param robot_list:
@return:
"""
for robot in robot_list:
thread = threading.Thread(target=robot.wake_up, args=())
thread.start()
def robot_wake_up(self, robot, ):
"""
起床
@param robot:
@return:
"""
thread = threading.Thread(target=robot.wake_up, args=())
thread.start()
def robot_wake_up_all(self, ):
"""
起床
@return:
"""
for robot in self.robot_list:
thread = threading.Thread(target=robot.wake_up, args=())
thread.start()
def robot_gm_add_item(self, robot, resource_name, add_num):
"""
添加资源
@param resource_name:
@param add_num:
@param robot: 机器人对象
@return:
"""
thread = threading.Thread(target=robot.gm_add_item, args=(resource_name, add_num))
thread.start()
def robot_move_item_all(self, move_type, move_index, target_index, accessory_to_index=-1):
"""
移动道具
@param move_index:
@param move_type:
@param target_index:
@param accessory_to_index:
@return:
"""
for robot in self.robot_list:
thread = threading.Thread(target=robot.move_item,
args=(move_type, move_index, target_index, accessory_to_index))
thread.start()
def robot_move_item_list(self, robot_list, move_type, move_index, target_index, accessory_to_index=-1):
"""
移动道具
@param move_index:
@param move_type:
@param target_index:
@param accessory_to_index:
@param robot_list:
@return:
"""
for robot in robot_list:
thread = threading.Thread(target=robot.move_item,
args=(move_type, move_index, target_index, accessory_to_index))
thread.start()
def robot_move_item(self, robot, move_type, move_index, target_index, accessory_to_index=-1):
"""
移动道具
@param robot: 机器人对象
@param move_index:
@param move_type:
@param target_index:
@param accessory_to_index:
@return:
"""
thread = threading.Thread(target=robot.move_item,
args=(move_type, move_index, target_index, accessory_to_index))
thread.start()
def robot_gm_add_item_all(self, resource_name, add_num):
"""
添加资源
@param resource_name:
@param add_num:
@return:
"""
for robot in self.robot_list:
thread = threading.Thread(target=robot.gm_add_item, args=(resource_name, add_num))
thread.start()
def robot_gm_add_item_list(self, robot_list, resource_name, add_num):
"""
添加资源
@param resource_name:
@param add_num:
@param robot_list:
@return:
"""
for robot in robot_list:
thread = threading.Thread(target=robot.gm_add_item, args=(resource_name, add_num))
thread.start()
def robot_out_login(self):
"""
让所有的机器人退出游戏
@return:
"""
for robot_instance in self.robot_list:
robot_instance.out_login()
self.robot_list = []
def robot_reload_ammo_all(self, ammo_id):
"""
机器人换弹
@param ammo_id:
@return:
"""
for robot in self.robot_list:
thread = threading.Thread(target=robot.reload_ammo, args=(ammo_id,))
thread.start()
def robot_reload_ammo_list(self, robot_list, ammo_id):
"""
机器人换弹
@param ammo_id:
@param robot_list:
@return:
"""
for robot in robot_list:
thread = threading.Thread(target=robot.reload_ammo, args=(ammo_id,))
thread.start()
def robot_reload_ammo(self, robot, ammo_id):
"""
机器人换弹
@param robot:
@param ammo_id:弹药id
@return:
"""
thread = threading.Thread(target=robot.reload_ammo, args=(ammo_id,))
thread.start()
def robot_fire1(self, robot, x, y, z, is_fire_continus, throw, fire_num):
"""
控制机器人集体开火
@param robot:
@param x:
@param y:
@param z:
@param is_fire_continus:
@param throw:
@param fire_num:
@return:
"""
thread = threading.Thread(target=robot.fire1,
args=(x, y, z, is_fire_continus, throw, fire_num))
thread.start()
def robot_fire1_all(self, x, y, z, is_fire_continus, throw, fire_num):
"""
控制机器人集体开火
@param x:
@param y:
@param z:
@param is_fire_continus:是否连续开火 ,手雷火箭筒用F
@param throw: 是否投掷物
@param fire_num:
@return:
"""
for robot in self.robot_list:
thread = threading.Thread(target=robot.fire1,
args=(x, y, z, is_fire_continus, throw, fire_num))
thread.start()
def robot_fire1_list(self, robot_list, x, y, z, is_fire_continus, throw, fire_num):
"""
控制机器人集体开火
@param x:
@param y:
@param z:
@param is_fire_continus:是否连续开火 ,手雷火箭筒用F
@param throw: 是否投掷物
@param fire_num:
@param robot_list:
@return:
"""
for robot in robot_list:
thread = threading.Thread(target=robot.fire1,
args=(x, y, z, is_fire_continus, throw, fire_num))
thread.start()
def robot_fire2(self, robot, ):
"""
控制机器人集体开镜
@param robot:
@return:
"""
thread = threading.Thread(target=robot.fire2, args=())
thread.start()
def robot_fire2_all(self, ):
"""
控制机器人集体开镜
@return:
"""
for robot in self.robot_list:
thread = threading.Thread(target=robot.fire2, args=())
thread.start()
def robot_fire2_list(self, robot_list):
"""
控制机器人集体开镜
@param robot_list:
@return:
"""
for robot in robot_list:
thread = threading.Thread(target=robot.fire2, args=())
thread.start()
def robot_up_carrier(self, robot, mountable_id, seat_type, seat_index):
"""
控制机器人集体上载具
@param robot:
@return:
"""
thread = threading.Thread(target=robot.up_carrier, args=(mountable_id, seat_type, seat_index))
thread.start()
def robot_up_carrier_all(self, mountable_id, seat_type, seat_index):
"""
控制机器人集体上载具
@return:
"""
for robot in self.robot_list:
thread = threading.Thread(target=robot.up_carrier, args=(mountable_id, seat_type, seat_index))
thread.start()
def robot_up_carrier_list(self, robot_list, mountable_id, seat_type, seat_index):
"""
控制机器人集体上载具
@param robot_list:
@return:
"""
for robot in robot_list:
thread = threading.Thread(target=robot.up_carrier, args=(mountable_id, seat_type, seat_index))
thread.start()
def robot_down_carrier(self, robot):
"""
控制机器人集体下载具
@param robot:
@return:
"""
thread = threading.Thread(target=robot.down_carrier, args=())
thread.start()
def robot_down_carrier_all(self, ):
"""
控制机器人集体下载具
@return:
"""
for robot in self.robot_list:
thread = threading.Thread(target=robot.down_carrier, args=())
thread.start()
def robot_down_carrier_list(self, robot_list):
"""
控制机器人集体下载具
@param robot_list:
@return:
"""
for robot in robot_list:
thread = threading.Thread(target=robot.down_carrier, args=())
thread.start()
def robot_drop_item_list(self, robot_list, box1_id: int, box2_id: int, index_id: int, drop_num: int):
"""
丢弃指定容器的道具。快捷栏和背包可以丢,身上的需要先移动到背包再丢
@param robot_list:
@param box1_id: 主容器id:快捷栏是1,背包是1,装备是1
@param box2_id: 子容器id:快捷栏是1,背包是0,装备是2
@param index_id: 道具的位置:从0开始数。装备栏:头盔0,手套5,背心4,上衣3,裤子6,护裙7,鞋子8,眼镜1,面巾2,背包9
@param drop_num: 丢弃的数量
@return:
"""
for robot in robot_list:
thread = threading.Thread(target=robot.drop_item,
args=(box1_id, box2_id, index_id, drop_num))
thread.start()
def robot_use_shortcut_iteam_all(self, iteam_index: int, un_equip: bool = False):
"""
使用快捷栏
@param iteam_index:
@param un_equip:
@return:
"""
for robot in self.robot_list:
thread = threading.Thread(target=robot.use_shortcut_iteam,
args=(iteam_index, un_equip))
thread.start()
def robot_use_shortcut_iteam_list(self, robot_list, iteam_index: int, un_equip: bool = False):
"""
使用快捷栏
@param iteam_index:
@param un_equip:
@param robot_list:
@return:
"""
for robot in robot_list:
thread = threading.Thread(target=robot.use_shortcut_iteam,
args=(iteam_index, un_equip))
thread.start()
def robot_use_shortcut_iteam(self, robot, iteam_index: int, un_equip: bool = False):
"""
使用快捷栏
@param robot:
@param iteam_index:
@param un_equip:
@return:
"""
thread = threading.Thread(target=robot.use_shortcut_iteam,
args=(iteam_index, un_equip))
thread.start()
def robot_gm_clear_inventory_all(self, bagType):
"""
清空背包
@param bagType:
@return:
"""
for robot in self.robot_list:
thread = threading.Thread(target=robot.gm_clear_inventory, args=(bagType,))
thread.start()
def robot_gm_clear_inventory_list(self, robot_list, bagType):
"""
清空背包
@param bagType:
@param robot_list:
@return:
"""
for robot in robot_list:
thread = threading.Thread(target=robot.gm_clear_inventory, args=(bagType,))
thread.start()
def robot_gm_clear_inventory(self, robot, bagType):
"""
清空背包
@param robot:
@param bagType:
@return:
"""
thread = threading.Thread(target=robot.gm_clear_inventory, args=(bagType,))
thread.start()
def get_camera(self, is_log=True):
result_data, result, msg = self.auto.send_rpc_and_read_result({"getLocalValue": {"name": "camera"}})
if not result:
return {}, False
else:
if is_log:
self.auto.add_log(f"获取属性camera:{msg},值为{result_data}")
return result_data, result
def set_visual_angle(self, direction, angle):
"""
旋转视角
:param direction:方向 up down left right
:param angle: 角度
:return:
"""
# 上下视野在-86.5 到86.5 之间
# 方向在0-360之间
camera_info, is_get = self.get_camera()
if is_get:
look_pitch = camera_info["rotation"]["y"]
look_yaw = camera_info["rotation"]["x"]
if direction == "up":
if look_pitch >= 86.5:
print("视角高度到上限,无需修改")
return
look_pitch += angle
if look_pitch > 86.5:
look_pitch = 86.5
self.set_role_pitch(look_pitch)
elif direction == "down":
if look_pitch <= -86.5:
print("视角高度到上限,无需修改")
return
look_pitch -= angle
if look_pitch < -86.5:
look_pitch = -86.5
self.set_role_pitch(look_pitch)
elif direction == "parallel":
if look_pitch <= -86.5:
print("视角高度到上限,无需修改")
return
look_pitch -= look_pitch
self.set_role_pitch(look_pitch)
elif direction == "left":
look_yaw -= angle
self.set_role_yaw(look_yaw)
elif direction == "right":
look_yaw += angle
self.set_role_yaw(look_yaw)
else:
raise Exception("输入的方向不对")
time.sleep(0.4)
else:
raise self.auto.raise_err_and_write_log("视角数据获取失败", 5)
def hotmap_set_visual_angle(self):
"""
热力图版_旋转视角4次
:return:
"""
angle_array = [0, 90, 180, 270]
for i in range(4):
first_angle = angle_array[0]
angle_array = angle_array[1:] + [first_angle]
self.set_role_yaw(first_angle)
time.sleep(0.5)
def add_resource(self, resource_name, add_num):
"""
添加道具
:param resource_name: 资源名
:param add_num: 数量
:return:
"""
resource_id = resource_name # todo 后续加名字转id的
try:
self.gm_rpc("add", f"GMAddItem {resource_id} {add_num}")
except Exception:
return False
return True
def get_resource(self, resource_name):
"""
获取资源数量
@param resource_name:
@return:
"""
resource_id = resource_name # todo 后续加名字转id的
return self.gm_rpc("get_resource", resource_id, "")
def get_poco_text(self, poco_name):
result_data, result, msg = self.poco_text(poco_name, "", "get")
if not result:
raise Exception(f"节点{poco_name}text属性获取失败,err:{msg}")
return result_data
def get_poco_exist(self, poco_name):
result_data, result, msg = self.poco_text(poco_name, "", "get")
if not result:
return False
return True
def poco_text(self, poco_name, set_text, ui_type):
"""
根据节点获取或者设置节点的text属性
:param poco_name:
:param ui_type: get/set
:param set_text:
:return:
"""
return self.auto.send_rpc_and_read_result(
{"classUI": {"name": poco_name, "value": set_text, "type": ui_type}})
def set_poco_text(self, poco_name, set_text):
"""
根据节点获取或者设置节点的text属性
:param poco_name:
:param set_text:
:return:
"""
result_data, result, msg = self.poco_text(poco_name, set_text, "set")
if not result:
print("设置失败", msg)
return result
def fire(self):
"""
开火
:return:
"""
self.set_rpc_value("Mc.UserCmd.NowCmd.Fire1", True)
def fire_V2(self):
"""
开火,火箭筒
:return:
"""
self.controls_role_v2(["Fire1", ], 1, True)
self.auto.add_log("火箭筒开火")
time.sleep(1)
def reload(self):
"""
换弹
:return:
"""
self.touch_key_action(12)
time.sleep(8)
def fire2(self):
"""
开镜
:return:
"""
self.touch_key_action(10)
def check_deserialization_error(self):
# 检测是否有表格反序列化窗口报错
# TODO 这个窗口可能是使用的通用提示,以后或许会导致某些窗口出现了但是被点掉
name = "Stage/GRoot/(Popup) L601-LO601/UiMsgBox(CommonGlobal-UiMsgBox)/ContentPane/ComPopMsgBox/GList/Container/Container/BtnPopupBtn"
if self.get_poco_exist(name):