4
4
5
5
6
6
class Jinhsi (BaseChar ):
7
+
7
8
def __init__ (self , * args , ** kwargs ):
8
9
super ().__init__ (* args , ** kwargs )
9
10
self .last_free_intro = 0 # free intro every 25 sec
10
11
self .has_free_intro = False
11
- self .incarnation = 0
12
+ self .incarnation = False
13
+ self .incarnation_cd = False
12
14
self .last_fly_e_time = 0
13
- self .e2_last = 0
14
15
15
- def do_perform (self ):
16
- self .has_free_intro = False
17
- if self .has_intro :
18
- if self .incarnation == 0 :
19
- self .e2_last = time .time ()
20
- self .sleep (0.8 )
21
- self .click_echo ()
22
- if self .incarnation == 2 :
16
+ def do_perform (self ):
17
+ if self .incarnation :
23
18
self .handle_incarnation ()
24
- return self .switch_next_char (free_intro = self . has_free_intro )
25
- if ( self .time_elapsed_accounting_for_freeze ( self . e2_last ) < 4.5 and self . incarnation == 0 ) or self .resonance_light () or self . incarnation == 1 :
19
+ return self .switch_next_char ()
20
+ elif self .has_intro or self .incarnation_cd :
26
21
self .handle_intro ()
27
- return self .switch_next_char (free_intro = self .has_free_intro )
28
- if self .check_team_con () and not self .need_fast_perform () and self .resonance_available () and self .time_elapsed_accounting_for_freeze (self .last_fly_e_time ) > 12 :
29
- if self .attack_until_resonance ():
30
- self .e2_last = time .time ()
31
- self .handle_intro ()
32
- return self .switch_next_char (free_intro = self .has_free_intro )
33
- self .continues_normal_attack (0.1 )
34
- self .switch_next_char (free_intro = self .has_free_intro )
22
+ return self .switch_next_char ()
23
+ self .click_echo ()
24
+ return self .switch_next_char ()
35
25
36
26
def reset_state (self ):
37
27
super ().reset_state ()
38
- self .incarnation = 0
28
+ self .incarnation = False
39
29
self .has_free_intro = False
40
- self .e2_last = 0
41
- self .last_fly_e_time = 0
42
-
30
+ self .incarnation_cd = False
31
+
32
+ def switch_next_char (self , ** args ):
33
+ super ().switch_next_char (free_intro = self .has_free_intro , target_low_con = True )
34
+ self .has_free_intro = False
35
+
43
36
def do_get_switch_priority (self , current_char : BaseChar , has_intro = False , target_low_con = False ):
44
- if has_intro or self .incarnation > 0 or self .time_elapsed_accounting_for_freeze ( self . e2_last ) < 4.5 :
37
+ if has_intro or self .incarnation or self .incarnation_cd :
45
38
self .logger .info (
46
- f'switch priority max because has_intro { has_intro } incarnation { self .incarnation } e2_cd { self .e2_last } ' )
39
+ f'switch priority max because has_intro { has_intro } incarnation { self .incarnation } incarnation_cd { self .incarnation_cd } ' )
47
40
return Priority .MAX
48
41
else :
49
- return super ().do_get_switch_priority (current_char , has_intro )
50
-
42
+ return Priority .MIN
43
+
44
+ def count_base_priority (self ):
45
+ return - 3
46
+
51
47
def count_resonance_priority (self ):
52
- if self .time_elapsed_accounting_for_freeze (self .last_fly_e_time ) > 12 :
53
- return 10
54
48
return 0
55
49
50
+ def count_echo_priority (self ):
51
+ return 10
52
+
56
53
def count_liberation_priority (self ):
57
54
return 0
58
-
55
+
59
56
def handle_incarnation (self ):
60
- self .incarnation = 0
61
- self .logger .info ('handle_incarnation click_resonance start' )
57
+ self .incarnation = False
58
+ self .logger .info (f 'handle_incarnation click_resonance start' )
62
59
start = time .time ()
63
- while self .time_elapsed_accounting_for_freeze (self .last_fly_e_time ) < 10.5 :
64
- self .click (interval = 0.1 )
65
- if time .time () - start > 8 :
66
- return
67
- if self .resonance_light ():
68
- self .e2_last = time .time ()
69
- result = self .resonance_until_not_light ()
70
- if result == 1 :
71
- self .last_fly_e_time = time .time ()
72
- self .incarnation = 1
73
- if result > 0 :
74
- return
60
+ animation_start = 0
61
+ last_op = 'resonance'
62
+ self .task .in_liberation = True
63
+ while True :
64
+ if time .time () - start > 6 :
65
+ self .logger .info (f'handle incarnation too long' )
66
+ break
67
+ if self .task .in_team ()[0 ]:
68
+ if last_op == 'resonance' :
69
+ self .task .click (interval = 0.1 )
70
+ last_op = 'click'
71
+ else :
72
+ self .send_resonance_key ()
73
+ last_op = 'resonance'
74
+ if animation_start != 0 :
75
+ self .logger .info (f'Jinhsi handle_incarnation done' )
76
+ break
77
+ else :
78
+ if animation_start == 0 :
79
+ self .logger .info (f'Jinhsi handle_incarnation start animation' )
80
+ animation_start = time .time ()
81
+ self .task .in_liberation = True
75
82
self .check_combat ()
76
- self .task .next_frame ()
83
+ self .task .next_frame ()
84
+ self .task .in_liberation = False
85
+
86
+ if not self .click_echo ():
87
+ self .task .click ()
88
+
89
+ self .add_freeze_duration (animation_start )
90
+ # if self.task.debug:
91
+ # self.task.screenshot(f'handle_incarnation click_resonance end {time.time() - start}')
92
+ self .logger .info (f'handle_incarnation click_resonance end { time .time () - start } ' )
77
93
78
94
def handle_intro (self ):
79
- self .logger .info ('handle_intro start' )
95
+ self .logger .info (f 'handle_intro start' )
80
96
start = time .time ()
81
- if self .has_cd ('resonance' ) and self .time_elapsed_accounting_for_freeze (self .last_fly_e_time ) < 12 :
82
- self .logger .info ('e2 has cd' )
83
- return
84
- if self .incarnation == 0 :
85
- if self .resonance_until_not_light () == 1 :
86
- self .last_fly_e_time = time .time ()
87
- if not self .click_liberation ():
88
- self .dodge ()
89
- self .continues_normal_attack (0.1 )
90
- self .incarnation = 1
91
- if self .check_outro () in {'char_zhezhi' ,'char_taoqi' ,'char_cantarella' ,'char_brant' }:
92
- self .incarnation = 2
93
- self .handle_incarnation ()
94
- return
95
- if self .incarnation == 1 :
96
- if self .check_outro () in {'char_zhezhi' ,'char_taoqi' ,'char_cantarella' ,'char_brant' }:
97
- self .incarnation = 2
98
- self .handle_incarnation ()
99
- return
100
- while self .time_elapsed_accounting_for_freeze (self .last_fly_e_time ) < 11 :
101
- if self .resonance_available ():
102
- self .click_resonance ()
103
- self .incarnation = 2
104
- self .check_animation ()
97
+ while True :
98
+ elapsed = time .time () - start
99
+ if self .has_cd ('resonance' ):
100
+ if 0.3 < elapsed < 1.5 :
101
+ self .incarnation_cd = True
102
+ # self.task.screenshot('incarnation_cd')
103
+ if not self .click_echo ():
104
+ self .click ()
105
105
return
106
- self .task .click (interval = 0.1 )
107
- self .check_combat ()
108
- self .task .next_frame ()
109
- self .incarnation = 0
110
-
111
-
112
- def dodge (self , duration = 0.1 ):
113
- self .check_combat ()
114
- self .task .send_key_down (key = 'w' )
115
- self .task .mouse_down (key = 'right' )
116
- self .sleep (duration )
117
- self .task .mouse_up (key = 'right' )
118
- self .task .send_key_up (key = 'w' )
119
-
120
- def resonance_light (self ):
121
- box = self .task .box_of_screen_scaled (3840 , 2160 , 3105 , 1845 , 3285 , 2010 , name = 'jinhsi_resonance' , hcenter = False )
122
- yellow_percent = self .task .calculate_color_percentage (jinhsi_yellow_color , box )
123
- return yellow_percent > 0.03
124
-
125
- def attack_until_resonance (self ):
126
- start = time .time ()
127
- last = start
128
- while time .time () - start < 7 :
129
- self .click (interval = 0.1 )
130
- if self .resonance_light ():
131
- if time .time ()- last > 0.1 :
132
- return True
106
+ elif elapsed > 1.5 :
107
+ # self.task.screenshot('incarnation_finished')
108
+ break
133
109
else :
134
- last = time .time ()
135
- self .task .next_frame ()
136
- self .check_combat ()
137
- return False
138
-
139
-
140
- def check_team_con (self ):
141
- for i , char in enumerate (self .task .chars ):
142
- self .logger .debug (f'find char: { char } ' )
143
- if char == self or char .current_con < 0.8 :
144
- continue
145
- return False
146
- return True
147
-
148
-
149
- def resonance_until_not_light (self ):
150
- start = time .time ()
151
- b = 0
152
- while not self .resonance_light () or not self .resonance_available ():
153
- if time .time () - start > 1 :
154
- break
155
- self .check_combat ()
110
+ self .send_resonance_key (interval = 0.1 )
156
111
self .task .next_frame ()
157
- while self .resonance_available () and self .resonance_light ():
158
- self .send_resonance_key ()
159
- b = 1
160
- if time .time () - start > 2 :
161
- return 0
162
- if self .check_animation ():
163
- return 2
164
112
self .check_combat ()
165
- self .task .next_frame ()
166
- if self .check_animation ():
167
- return 2
168
- return b
169
-
170
- def check_animation (self ):
171
- if self .task .in_team ()[0 ]:
172
- return False
173
- animation_start = 0
174
- self .task .in_liberation = True
175
- while not self .task .in_team ()[0 ]:
176
- if animation_start == 0 :
177
- self .logger .info ('Jinhsi handle_incarnation start animation' )
178
- animation_start = time .time ()
179
- self .check_combat ()
180
- self .task .next_frame ()
181
- self .task .in_liberation = False
182
- if animation_start == 0 :
183
- return False
184
- self .add_freeze_duration (animation_start )
185
- self .incarnation = 0
186
- self .e2_last = 0
187
- if self .time_elapsed_accounting_for_freeze (self .last_free_intro ) > 25 :
188
- self .has_free_intro = True
189
- self .last_free_intro = time .time ()
190
- return True
191
-
192
- jinhsi_yellow_color = {
193
- 'r' : (235 , 255 ), # Red range
194
- 'g' : (235 , 255 ), # Green range
195
- 'b' : (200 , 230 ) # Blue range
196
- }
113
+
114
+ self .last_fly_e_time = start
115
+ if self .click_liberation (send_click = True ):
116
+ self .continues_normal_attack (0.3 )
117
+ else :
118
+ self .continues_normal_attack (1.4 )
119
+ # self.task.screenshot(f'handle_intro end {time.time() - start}')
120
+ self .logger .info (f'handle_intro end { time .time () - start } ' )
121
+ self .incarnation = True
122
+ self .incarnation_cd = False
123
+
124
+ def wait_resonance (self ):
125
+ while not self .resonance_available (check_ready = True ):
126
+ self .send_resonance_key (interval = 0.1 )
0 commit comments