Skip to content

Commit 5d99dce

Browse files
authored
Update ApexFarmer.py to v2.0
1 parent 32880b2 commit 5d99dce

File tree

1 file changed

+242
-5
lines changed

1 file changed

+242
-5
lines changed

ApexFarmer.py

Lines changed: 242 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
'Ability_Key': 'q',
3838
'Custom_Key1': '',
3939
'Custom_Key2': ''}
40+
config['FARM TOGETHER'] = {'LEADER': 'FALSE',
41+
'ACCOUNT_1': 'None',
42+
'ACCOUNT_2': 'None'}
4043

4144

4245
with open('config.ini', 'w') as configfile:
@@ -58,6 +61,14 @@
5861
custom_key1 = str(config.get('KEYBINDS', 'Custom_Key1'))
5962
custom_key2 = str(config.get('KEYBINDS', 'Custom_Key2'))
6063

64+
leader = str(config.get('FARM TOGETHER', 'LEADER'))
65+
friend1 = str(config.get('FARM TOGETHER', 'ACCOUNT_1'))
66+
friend2 = str(config.get('FARM TOGETHER', 'ACCOUNT_2'))
67+
68+
if leader=='FALSE':
69+
friend1='None'
70+
friend2='None'
71+
6172
#------------------
6273
if (custom_key1 == '') and (custom_key2 == ''):
6374
Random = ['w','a','s','d',crouch_key,heal_key,ability_key]
@@ -73,12 +84,12 @@
7384
timer_matchmaking=0
7485
timer_matchmaking_end=0
7586
timer_matchmaking_start=0
76-
time.sleep(2)
7787
window_found = 0
7888
exp=0
7989
exp_new=0
8090
exp_new1=0
8191
exp_new2=0
92+
exp_new4=0
8293
n = 1
8394
time_stuck=0
8495
time_stuck_start=0
@@ -94,6 +105,27 @@
94105
coords_auto_fill_y=0
95106
champ_list=["Bloodhound","Gibraltar","Lifeline","Pathfinder","Wraith","Bangalore","Caustic","Mirage","Octane","Wattson","Crypto","Revenant","Loba","Rampart","Horizon","Fuse","Valkyrie","Seer","Ash","MadMaggie","Newcastle","Vantage","Catalyst","Ballistic","Conduit"]
96107
champ_string=r'legends\\'+champion+'.png'
108+
friend_region=[[573,265,284,34],(573,365,284,34),(573,465,284,34),(573,565,284,34),(573,665,284,34),(573,765,284,34),(573,865,284,34),(573,965,284,34)]
109+
invite_region=[[560,265,323,82],(560,355,323,82),(560,455,323,82),(560,555,323,82),(560,655,323,82),(560,755,323,82),(560,855,323,82),(560,955,323,82)]
110+
k=0
111+
friend1_invited=0
112+
friend2_invited=0
113+
friendlist_window=0
114+
invite1='0'
115+
invite2='0'
116+
invited1='0'
117+
invited2='0'
118+
time_slept=0
119+
f1_coords=0
120+
f2_coords=0
121+
friendlist1_coords=0
122+
friendlist2_coords=0
123+
leader_text='0'
124+
apex_detected=0
125+
friend1_not_invited=1
126+
friend2_not_invited=1
127+
invite_accepted=0
128+
97129

98130

99131

@@ -152,6 +184,7 @@ def process_exists(process_name):
152184
mod = 2
153185
start_time = time.time()
154186
time_stuck_start= time.time()
187+
apex_detected=1
155188

156189
else:
157190
mod = 1
@@ -248,7 +281,7 @@ def process_exists(process_name):
248281
#print(UP, end=CLEAR)
249282
time.sleep(2)
250283
pyautogui.moveTo(200,100)
251-
mod = 3
284+
mod = 5
252285

253286
#program loop
254287
while mod == 3:
@@ -391,6 +424,11 @@ def process_exists(process_name):
391424
gray2 = cv2.cvtColor(imagenp2, cv2.COLOR_BGR2GRAY)
392425
invert2 = 255 - gray2
393426

427+
image5=pyautogui.screenshot(region=(924,311,73,35))
428+
imagenp5 = np.array(image5)
429+
gray5 = cv2.cvtColor(imagenp5, cv2.COLOR_BGR2GRAY)
430+
invert5 = 255 - gray5
431+
394432
image3=pyautogui.screenshot(region=(coords))
395433
imagenp3 = np.array(image3)
396434
gray3 = cv2.cvtColor(imagenp3, cv2.COLOR_BGR2GRAY)
@@ -406,13 +444,17 @@ def process_exists(process_name):
406444

407445
exp_new1 = pytesseract.image_to_string(invert1,lang='eng', config='--psm 6 -c tessedit_char_whitelist=0123456789')
408446
exp_new2 = pytesseract.image_to_string(invert2,lang='eng', config='--psm 6 -c tessedit_char_whitelist=0123456789')
447+
exp_new4 = pytesseract.image_to_string(invert5,lang='eng', config='--psm 6 -c tessedit_char_whitelist=0123456789')
409448

410449
if len(exp_new1) == 6 and exp_new1[0] == '4':
411450
exp_new1=int(exp_new1[1:])
412451
#print('EXP1 - 5 CHAR DETECTED')
413452
if len(exp_new2) == 6 and int(exp_new2[0]) == '4':
414453
exp_new2=int(exp_new2[1:])
415454
#print('EXP2 - 5 CHAR DETECTED')
455+
if len(exp_new4) == 4 and int(exp_new4[0]) == '4':
456+
exp_new4=int(exp_new4[1:])
457+
#print('EXP2 - 5 CHAR DETECTED')
416458

417459
try:
418460
exp_new1 = int(exp_new1)
@@ -424,7 +466,12 @@ def process_exists(process_name):
424466
except ValueError:
425467
exp_new2 = 0
426468

427-
exp_new=exp_new1+exp_new2
469+
try:
470+
exp_new4 = int(exp_new4)
471+
except ValueError:
472+
exp_new4 = 0
473+
474+
exp_new=exp_new1+exp_new2+exp_new4
428475
exp_new=str(exp_new)
429476

430477
if exp_new[0]=='4' and exp_new[1]=='4' and len(exp_new)==4:
@@ -534,14 +581,14 @@ def process_exists(process_name):
534581
print (' | TOTAL TIME FARMED | -> | ',datetime.timedelta(seconds=round(time_lapsed_absolute)))
535582
print(" ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ ")
536583
time.sleep(15)
537-
exit()
584+
sys.exit()
538585
else:
539586
print(" ___________________ ")
540587
print (' | TOTAL XP GAINED | -> | N/A')
541588
print (' | TOTAL TIME FARMED | -> | ',datetime.timedelta(seconds=round(time_lapsed_absolute)))
542589
print(" ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ ")
543590
time.sleep(15)
544-
exit()
591+
sys.exit()
545592
elif data_input == '2':
546593
print(UP, end=CLEAR)
547594
print(UP, end=CLEAR)
@@ -573,3 +620,193 @@ def process_exists(process_name):
573620
time.sleep(10)
574621
mod = 1
575622

623+
while mod==5:
624+
if leader=='FALSE':
625+
mod=3
626+
break
627+
if leader=='TRUE':
628+
pyautogui.click(200,100)
629+
pyautogui.click(200,100)
630+
if (time_slept==0) and (apex_detected==0):
631+
time.sleep(45)
632+
time_slept=1
633+
time.sleep(3)
634+
635+
if pyautogui.locateOnScreen(resource_path('ss\\friendlist.png'),region=(1483,942,461,101),confidence=0.9) != None:
636+
try:
637+
friendlist1_coords, friendlist2_coords = pyautogui.locateCenterOnScreen(resource_path('ss\\friendlist.png'),region=(1483,942,461,101),confidence=0.9)
638+
except TypeError:
639+
friendlist1_coords=0
640+
friendlist2_coords=0
641+
if (friendlist1_coords!=0) and (friendlist2_coords!=0):
642+
pyautogui.moveTo(friendlist1_coords,friendlist2_coords)
643+
pyautogui.click(friendlist1_coords,friendlist2_coords)
644+
time.sleep(2)
645+
if pyautogui.locateOnScreen(resource_path('ss\\friends_window.png'),region=(774,32,385,83),confidence=0.9) != None:
646+
friendlist_window=1
647+
while True:
648+
649+
if (friend1 != 'None') and (friend1_not_invited==1) and (friendlist_window==1):
650+
time.sleep(1)
651+
652+
if friend1 not in invite1:
653+
who_invite=pyautogui.screenshot(region=friend_region[k])
654+
who_invite_np = np.array(who_invite)
655+
gray_who_invite = cv2.cvtColor(who_invite_np, cv2.COLOR_BGR2GRAY)
656+
invert_who_invite = 255 - gray_who_invite
657+
invite1 = pytesseract.image_to_string(invert_who_invite,lang='eng', config='--psm 7')
658+
time.sleep(1)
659+
if (friend1 in invite1) and (friend1_not_invited==1):
660+
try:
661+
f1_coords, f2_coords = pyautogui.locateCenterOnScreen(resource_path('ss\\invite.png'),region=(invite_region[k]),confidence=0.9)
662+
except TypeError:
663+
f1_coords=0
664+
f2_coords=0
665+
if (f1_coords!=0) and (f2_coords!=0):
666+
pyautogui.moveTo(f1_coords,f2_coords)
667+
pyautogui.click(f1_coords,f2_coords)
668+
friend1_not_invited=0
669+
if friend2 =='None':
670+
friend2_not_invited=0
671+
time.sleep(0.5)
672+
673+
674+
if (friend2 != 'None') and (friend2_not_invited==1) and (friendlist_window==1):
675+
time.sleep(1)
676+
677+
if friend2 not in invite2:
678+
who_invite=pyautogui.screenshot(region=friend_region[k])
679+
who_invite_np = np.array(who_invite)
680+
gray_who_invite = cv2.cvtColor(who_invite_np, cv2.COLOR_BGR2GRAY)
681+
invert_who_invite = 255 - gray_who_invite
682+
invite2 = pytesseract.image_to_string(invert_who_invite,lang='eng', config='--psm 7')
683+
time.sleep(0.5)
684+
if (friend2 in invite2) and (friend2_not_invited==1):
685+
try:
686+
f1_coords, f2_coords = pyautogui.locateCenterOnScreen(resource_path('ss\\invite.png'),region=(invite_region[k]),confidence=0.9)
687+
except TypeError:
688+
f1_coords=0
689+
f2_coords=0
690+
if (f1_coords!=0) and (f2_coords!=0):
691+
pyautogui.moveTo(f1_coords,f2_coords)
692+
pyautogui.click(f1_coords,f2_coords)
693+
friend2_not_invited=0
694+
time.sleep(0.5)
695+
696+
697+
if k==6:
698+
k=0
699+
else:
700+
k=k+1
701+
702+
if (friend1_not_invited==0) and (friend2_not_invited==0):
703+
keyboard.press_and_release('esc')
704+
friendlist_window=0
705+
k=0
706+
time.sleep(2)
707+
'''if pyautogui.locateOnScreen(resource_path('ss\\friendlist.png'),region=(1483,942,461,101),confidence=0.9) != None:
708+
who_invited=pyautogui.screenshot(region=(492,163,209,27))
709+
who_invited_np = np.array(who_invited)
710+
gray_who_invited = cv2.cvtColor(who_invited_np, cv2.COLOR_BGR2GRAY)
711+
invert_who_invited = 255 - gray_who_invited
712+
invited1 = pytesseract.image_to_string(invert_who_invited,lang='eng', config='--psm 7')
713+
time.sleep(0.5)
714+
if (friend1 in invited1) and (friend1 != 'None'):
715+
friend1_invited=1
716+
if friend2=='None':
717+
friend2_invited==1
718+
719+
who_invited=pyautogui.screenshot(region=(1187,147,244,95))
720+
who_invited_np = np.array(who_invited)
721+
gray_who_invited = cv2.cvtColor(who_invited_np, cv2.COLOR_BGR2GRAY)
722+
invert_who_invited = 255 - gray_who_invited
723+
invited2 = pytesseract.image_to_string(invert_who_invited,lang='eng', config='--psm 7')
724+
time.sleep(0.5)
725+
if friend2 in invited2:
726+
friend2_invited=1
727+
728+
if (friend1_invited==1) and (friend2_invited==1):
729+
mod=3
730+
time.sleep(0.5)
731+
else:
732+
friend1_not_invited=1
733+
friend2_not_invited=1
734+
invite1='0'
735+
invite2='0'
736+
time.sleep(3)'''
737+
if pyautogui.locateOnScreen(resource_path('ss\\slave.png'), region=(398,140,334,71), confidence=0.8) != None:
738+
if (friend1 != 'None') and (friend2 == 'None'):
739+
mod=3
740+
friend1_not_invited=1
741+
friend2_not_invited=1
742+
invite1='0'
743+
invite2='0'
744+
time.sleep(3)
745+
break
746+
if (friend1 != 'None') and (friend2!='None'):
747+
if pyautogui.locateOnScreen(resource_path('ss\\slave.png'), region=(1187,147,244,95), confidence=0.8) != None:
748+
mod=3
749+
break
750+
else:
751+
friend1_not_invited=1
752+
friend2_not_invited=1
753+
invite1='0'
754+
invite2='0'
755+
time.sleep(10)
756+
break
757+
758+
759+
if leader=='SLAVE':
760+
time.sleep(5)
761+
if (friend1 not in leader_text) and (friend1 != None):
762+
leader_photo=pyautogui.screenshot(region=(1572,927,324,20))
763+
leader_photo_np = np.array(leader_photo)
764+
gray_leader_photo = cv2.cvtColor(leader_photo_np, cv2.COLOR_BGR2GRAY)
765+
invert_leader_photo = 255 - gray_leader_photo
766+
leader_text = pytesseract.image_to_string(invert_leader_photo,lang='eng', config='--psm 7')
767+
time.sleep(0.5)
768+
if (friend1 in leader_text) and (friend1 != 'None'):
769+
try:
770+
f1_coords, f2_coords = pyautogui.locateCenterOnScreen(resource_path('ss\\accept.png'),region=(1812,970,90,42),confidence=0.9)
771+
except TypeError:
772+
f1_coords=0
773+
f2_coords=0
774+
if (f1_coords!=0) and (f2_coords!=0):
775+
pyautogui.click(200,100)
776+
pyautogui.moveTo(f1_coords,f2_coords)
777+
pyautogui.click(f1_coords,f2_coords)
778+
time.sleep(0.5)
779+
780+
'''who_invited=pyautogui.screenshot(region=(492,163,209,27))
781+
who_invited_np = np.array(who_invited)
782+
gray_who_invited = cv2.cvtColor(who_invited_np, cv2.COLOR_BGR2GRAY)
783+
invert_who_invited = 255 - gray_who_invited
784+
invited1 = pytesseract.image_to_string(invert_who_invited,lang='eng', config='--psm 7')
785+
who_invited=pyautogui.screenshot(region=(1187,147,244,95))
786+
who_invited_np = np.array(who_invited)
787+
gray_who_invited = cv2.cvtColor(who_invited_np, cv2.COLOR_BGR2GRAY)
788+
invert_who_invited = 255 - gray_who_invited
789+
invited2 = pytesseract.image_to_string(invert_who_invited,lang='eng', config='--psm 7')
790+
time.sleep(0.5)
791+
print(invited1)
792+
print(invited2)
793+
794+
if (friend1 in invited1) or (friend1 in invite2):
795+
invite_accepted=1
796+
mod=3
797+
break
798+
else:
799+
leader_text='0'
800+
break'''
801+
if (pyautogui.locateOnScreen(resource_path('ss\\leader.png'), region=(398,140,334,71), confidence=0.8) != None) or (pyautogui.locateOnScreen(resource_path('ss\\leader.png'), region=(1187,147,244,95), confidence=0.8) != None):
802+
mod=3
803+
804+
805+
806+
807+
808+
809+
810+
811+
812+

0 commit comments

Comments
 (0)