commit a43382d82150180a1edef092ff2c144476146b3e Author: MickSlash Date: Sat May 23 14:46:31 2020 +0200 First Commit diff --git a/find_cs_health_lol.py b/find_cs_health_lol.py new file mode 100644 index 0000000..eff1756 --- /dev/null +++ b/find_cs_health_lol.py @@ -0,0 +1,90 @@ +from ahk import AHK +import os +import subprocess +from random import randint +import time +from league_of_legends_bot import combo +from league_of_legends_requests import league_of_legends_client_api +# Inizializziamo AHK AutoScript +ahk = AHK() + + +# Cartella dove é contenuta l'immagine +script_dir = os.path.dirname(__file__) +cs_life_path = os.path.join( + script_dir, + 'lolbot', + 'enemycreephealth.png' + ) +my_cs_life_path = os.path.join( + script_dir, + 'lolbot', + 'alliedcreephealth.png' + ) + + +shop_path = os.path.join( + script_dir, + 'lolbot', + 'shop.png' + ) + + +enemy_path = os.path.join( + script_dir, + 'lolbot', + 'enemyhealth.png' + ) + +""" +Creo uno script per identificare la vita dei CS + +""" + +def cs_life(cs_life_path,my_cs_life_path): + print("Starting",end="") + for _ in range(0,10): + print(".",end="",flush=True) + time.sleep(1) + print("Go") + last_time = time.time() + while True: + try: + # ahk.key_down("space") + mouse_position = ahk.mouse_position + data = league_of_legends_client_api() + health = data['championStats']['currentHealth'] + gold = data["currentGold"] + cs = ahk.image_search(cs_life_path) + enemy = ahk.image_search(enemy_path) + my_cs_life = ahk.image_search(my_cs_life_path) + print(f"Miei Minion : {my_cs_life}") + print(enemy) + if cs == None and my_cs_life == None: + ahk.key_down("b") + elif my_cs_life is not None and cs == None: + lol_move = ahk.mouse_move(my_cs_life[0], my_cs_life[1], speed=10) + ahk.right_click(lol_move) + elif health <= 300: + ahk.key_down("b") + if gold >= 1300: + shop = ahk.image_search(shop_path) + lol_move = ahk.mouse_move(my_cs_life[0], my_cs_life[1], speed=10) + ahk.right_click(lol_move) + elif cs != None and enemy != None: + lol_move = ahk.mouse_move(cs[0], cs[1], speed=10) + enemy_move = ahk.mouse_move(enemy[0], enemy[1], speed=10) + ahk.right_click(lol_move) + ahk.right_click(enemy_move) + combo() + # cs_life(cs_life_path,my_cs_life_path) + print("Loop took {} seconds".format(time.time()-last_time)) + last_time = time.time() + except: + print("Qualcosa é andato storto, riprovo...") + cs_life(cs_life_path,my_cs_life_path) + + + +if __name__ == "__main__": + cs_life(cs_life_path,my_cs_life_path) \ No newline at end of file diff --git a/league_of_legends_bot.py b/league_of_legends_bot.py new file mode 100644 index 0000000..276c76f --- /dev/null +++ b/league_of_legends_bot.py @@ -0,0 +1,161 @@ +from ahk import AHK +import os +from random import randint +from league_of_legends_requests import league_of_legends_client_api + +ahk = AHK() + +import time + +account = "" +psw = "" + + +def main(): + + # Countdown Timer + print("Starting",end="") + for _ in range(0,10): + print(".",end="",flush=True) + time.sleep(1) + print("Go") + + nome_utente_password(account,psw) + time.sleep(120) + first_queque() + + # ahk.mouse_move(x=100, y=100, blocking=True) # Blocks until mouse finishes moving (the default) + # ahk.mouse_move(x=150, y=150, speed=10, blocking=True) # Moves the mouse to x, y taking 'speed' seconds to move + # print(ahk.mouse_position) # (150, 150)\ + # queque() + while True: + try: + if ahk.key_state("space") == True: + combo() + except: + print("Uscita dal Bot...") + break + # Done + print('Done') + + +def combo(): + while True: + try: + data = league_of_legends_client_api() + health = data['championStats']['currentHealth'] + gold = data["currentGold"] + lvl = data["level"] + abilities_E = data["abilities"]["E"]["abilityLevel"] + abilities_Q = data["abilities"]["Q"]["abilityLevel"] + abilities_W = data["abilities"]["W"]["abilityLevel"] + abilities_R = data["abilities"]["R"]["abilityLevel"] + sum_abilities = abilities_E + abilities_Q + abilities_W + abilities_R + if sum_abilities != lvl: + ahk.key_down('Control') + ahk.key_down('q') + time.sleep(0.3) + ahk.key_up('Control') + ahk.key_up('q') + if abilities_Q > 0: + ahk.key_press('q') + if abilities_E > 0: + ahk.key_press('e') + if abilities_R > 0: + ahk.key_press('r') + break + except: + break + + +def nome_utente_password(account,psw): + script_dir = os.path.dirname(__file__) + nome_utente_path = os.path.join( + script_dir, + 'lolbot', + 'nomeutente.png' + ) + password_path = os.path.join( + script_dir, + 'lolbot', + 'password.png' + ) + login_path = os.path.join( + script_dir, + 'lolbot', + 'login.png' + ) + + time.sleep(1) + nome_utente = ahk.image_search(nome_utente_path) + ahk.click(nome_utente[0],nome_utente[1]) + ahk.type(account) + time.sleep(2) + ahk.click(nome_utente[0],nome_utente[1] + 66) + ahk.type(psw) + ahk.key_press('enter') + # login = ahk.image_search(login_path) + # ahk.click(login[0],login[1]) + + +def first_queque(): + script_dir = os.path.dirname(__file__) + play_image_path = os.path.join( + script_dir, + 'lolbot', + 'gioca.png' + ) + coopvsia_image_path = os.path.join( + script_dir, + 'lolbot', + 'coopvsia.png' + ) + select_coop_mode = os.path.join( + script_dir, + 'lolbot', + 'introduzione.png' + ) + confirm = os.path.join( + script_dir, + 'lolbot', + 'conferma.png' + ) + found_match = os.path.join( + script_dir, + 'lolbot', + 'trovapartita.png' + ) + accept_match = os.path.join( + script_dir, + 'lolbot', + 'accetta.png' + ) + # image_positon = pyautogui.locateOnScreen(image_path) + play_image_positon = ahk.image_search(play_image_path) + ahk.click(play_image_positon[0],play_image_positon[1]) + time.sleep(2) + coopvsia_positon = ahk.image_search(coopvsia_image_path) + ahk.click(coopvsia_positon[0] + 20,coopvsia_positon[1] + 25) + time.sleep(2) + introduction_positon = ahk.image_search(select_coop_mode) + ahk.click(introduction_positon[0],introduction_positon[1]) + # print(introduction_positon) + time.sleep(2) + confirm_position = ahk.image_search(confirm) + ahk.click(confirm_position[0],confirm_position[1]) + # print(confirm_postion) + time.sleep(2) + ahk.mouse_move(-100, -100, speed=10, relative=True) + time.sleep(2) + found_match_position = ahk.image_search(found_match) + ahk.click(found_match_position[0],found_match_position[1]) + time.sleep(2) + accept_match_position = ahk.image_search(accept_match) + ahk.click(accept_match_position[0],accept_match_position[1]) + + # coopvsia_image_position = ahk.image_search(coopvsia_image_path) + # ahk.click(coopvsia_image_position[0],coopvsia_image_position[1]) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/league_of_legends_requests.py b/league_of_legends_requests.py new file mode 100644 index 0000000..8580f13 --- /dev/null +++ b/league_of_legends_requests.py @@ -0,0 +1,22 @@ +import requests +import urllib3 + +urllib3.disable_warnings() + + + +def league_of_legends_client_api(): + try: + api_endpoint = "https://127.0.0.1:2999/liveclientdata/activeplayer" + response = requests.get(api_endpoint,verify=False) + if response.ok: + data = response.json() + return data + else: + print(f"Errore : {response.status_code}") + except: + print("Giocatore Non in Partita...") + return data == None + + +league_of_legends_client_api() \ No newline at end of file diff --git a/lolbot/accetta.PNG b/lolbot/accetta.PNG new file mode 100644 index 0000000..91a2782 Binary files /dev/null and b/lolbot/accetta.PNG differ diff --git a/lolbot/addestramento.PNG b/lolbot/addestramento.PNG new file mode 100644 index 0000000..56d7e55 Binary files /dev/null and b/lolbot/addestramento.PNG differ diff --git a/lolbot/alliedcreephealth.png b/lolbot/alliedcreephealth.png new file mode 100644 index 0000000..19ca0a6 Binary files /dev/null and b/lolbot/alliedcreephealth.png differ diff --git a/lolbot/casterminionhealth.png b/lolbot/casterminionhealth.png new file mode 100644 index 0000000..27c7abc Binary files /dev/null and b/lolbot/casterminionhealth.png differ diff --git a/lolbot/champ.PNG b/lolbot/champ.PNG new file mode 100644 index 0000000..557ac76 Binary files /dev/null and b/lolbot/champ.PNG differ diff --git a/lolbot/conferma.PNG b/lolbot/conferma.PNG new file mode 100644 index 0000000..7bb5981 Binary files /dev/null and b/lolbot/conferma.PNG differ diff --git a/lolbot/coop.PNG b/lolbot/coop.PNG new file mode 100644 index 0000000..1309a44 Binary files /dev/null and b/lolbot/coop.PNG differ diff --git a/lolbot/coopvsia.PNG b/lolbot/coopvsia.PNG new file mode 100644 index 0000000..fe0bea3 Binary files /dev/null and b/lolbot/coopvsia.PNG differ diff --git a/lolbot/enemycreephealth.png b/lolbot/enemycreephealth.png new file mode 100644 index 0000000..0e2c845 Binary files /dev/null and b/lolbot/enemycreephealth.png differ diff --git a/lolbot/enemyhealth.png b/lolbot/enemyhealth.png new file mode 100644 index 0000000..9dd7335 Binary files /dev/null and b/lolbot/enemyhealth.png differ diff --git a/lolbot/gioca.PNG b/lolbot/gioca.PNG new file mode 100644 index 0000000..be0ec5d Binary files /dev/null and b/lolbot/gioca.PNG differ diff --git a/lolbot/home.PNG b/lolbot/home.PNG new file mode 100644 index 0000000..0180c83 Binary files /dev/null and b/lolbot/home.PNG differ diff --git a/lolbot/introduzione.PNG b/lolbot/introduzione.PNG new file mode 100644 index 0000000..22a6e4b Binary files /dev/null and b/lolbot/introduzione.PNG differ diff --git a/lolbot/login.PNG b/lolbot/login.PNG new file mode 100644 index 0000000..2789602 Binary files /dev/null and b/lolbot/login.PNG differ diff --git a/lolbot/nomeutente.PNG b/lolbot/nomeutente.PNG new file mode 100644 index 0000000..61183f0 Binary files /dev/null and b/lolbot/nomeutente.PNG differ diff --git a/lolbot/oggettiiniziali.png b/lolbot/oggettiiniziali.png new file mode 100644 index 0000000..aa30620 Binary files /dev/null and b/lolbot/oggettiiniziali.png differ diff --git a/lolbot/password.PNG b/lolbot/password.PNG new file mode 100644 index 0000000..3932329 Binary files /dev/null and b/lolbot/password.PNG differ diff --git a/lolbot/pvp.PNG b/lolbot/pvp.PNG new file mode 100644 index 0000000..317f0a6 Binary files /dev/null and b/lolbot/pvp.PNG differ diff --git a/lolbot/shop.png b/lolbot/shop.png new file mode 100644 index 0000000..48add47 Binary files /dev/null and b/lolbot/shop.png differ diff --git a/lolbot/tastogioca.JPG b/lolbot/tastogioca.JPG new file mode 100644 index 0000000..ea62e6c Binary files /dev/null and b/lolbot/tastogioca.JPG differ diff --git a/lolbot/template.PNG b/lolbot/template.PNG new file mode 100644 index 0000000..55a054b Binary files /dev/null and b/lolbot/template.PNG differ diff --git a/lolbot/towerhealth.png b/lolbot/towerhealth.png new file mode 100644 index 0000000..d8fd672 Binary files /dev/null and b/lolbot/towerhealth.png differ diff --git a/lolbot/trovapartita.PNG b/lolbot/trovapartita.PNG new file mode 100644 index 0000000..03c522c Binary files /dev/null and b/lolbot/trovapartita.PNG differ