First Commit

master
MickSlash 2020-05-23 14:46:31 +02:00
commit a43382d821
26 changed files with 273 additions and 0 deletions

90
find_cs_health_lol.py Normal file
View File

@ -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)

161
league_of_legends_bot.py Normal file
View File

@ -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()

View File

@ -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()

BIN
lolbot/accetta.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
lolbot/addestramento.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
lolbot/champ.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
lolbot/conferma.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
lolbot/coop.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
lolbot/coopvsia.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
lolbot/enemycreephealth.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

BIN
lolbot/enemyhealth.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 B

BIN
lolbot/gioca.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
lolbot/home.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
lolbot/introduzione.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

BIN
lolbot/login.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 B

BIN
lolbot/nomeutente.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 676 B

BIN
lolbot/oggettiiniziali.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
lolbot/password.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
lolbot/pvp.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
lolbot/shop.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 B

BIN
lolbot/tastogioca.JPG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
lolbot/template.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

BIN
lolbot/towerhealth.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

BIN
lolbot/trovapartita.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB