Skip to content

Commit 44687a1

Browse files
authored
Merge pull request #42 from AzimovUA/fix-autosmite
smooth autosmite + fix
2 parents 7ff53bc + a5f59ad commit 44687a1

File tree

7 files changed

+43
-57
lines changed

7 files changed

+43
-57
lines changed

vakscript/autoconfig.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
},
4747
'AutoSmite' : {
4848
'smite' : 'f',
49-
'update' : 'q',
5049
'randb' : False
5150
},
5251
"Scripts" : {

vakscript/autosmite.py

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
#built-in
22
from ctypes import windll
3-
from urllib.request import urlopen
4-
from urllib.parse import quote
53
from collections import namedtuple
64
from gc import collect as del_mem
75
from time import sleep
86

97
#ext
108
from pyMeow import open_process, get_module
11-
from pyMeow import r_int, r_float
12-
from orjson import loads
13-
from win32api import GetSystemMetrics, GetAsyncKeyState
9+
from pyMeow import r_int, r_float, r_uint64
10+
from win32api import GetSystemMetrics, GetCursorPos
1411

1512

1613
#own
1714
from data import Offsets, Info, VK_CODES
1815
from world_to_screen import World
1916
from utils import send_key, debug_info
17+
from entities import AttributesReader
2018

2119
"""
2220
TODO:
@@ -28,30 +26,15 @@ class Asmite:
2826

2927
def __init__(self, settings):
3028
self.settings = settings
31-
self.raw_names = Info.asmite_raw_names
32-
self.url_active_player_name = Info.url_activeplayer_name
33-
self.url_request = Info.asmite_url_request
3429

3530
self.obj_health = Offsets.obj_health
3631
self.obj_spawn_count = Offsets.obj_spawn_count
3732
self.obj_x = Offsets.obj_x
3833
self.obj_y = Offsets.obj_y
3934
self.obj_z = Offsets.obj_z
40-
41-
def get_username(self):
42-
return loads(urlopen(self.url_active_player_name).read())
4335

4436
def get_settings(self):
45-
return VK_CODES[self.settings['smite']], VK_CODES[self.settings['update']]
46-
47-
def get_damage(self, username):
48-
spells = loads(urlopen(self.url_request.format(username=username)).read())
49-
sp1, sp2 = spells["summonerSpellOne"], spells["summonerSpellTwo"]
50-
for v, v2 in zip(sp1.values(), sp2.values()):
51-
if v in self.raw_names:
52-
return self.raw_names[v]
53-
if v2 in self.raw_names:
54-
return self.raw_names[v2]
37+
return VK_CODES[self.settings['smite']]
5538

5639
def _read_attr(self, process, address, nt):
5740
attributes = nt(
@@ -65,22 +48,20 @@ def _read_attr(self, process, address, nt):
6548
return attributes
6649

6750
def autosmite(terminate, settings, jungle_pointers, on_window):
68-
import ssl
69-
import requests
70-
71-
requests.packages.urllib3.disable_warnings()
72-
ssl._create_default_https_context = ssl._create_unverified_context
73-
7451
while not terminate.value:
7552
if on_window.value:
7653
del_mem()
7754
try:
7855
process = open_process(process=Info.game_name_executable)
7956
base_address = get_module(process, Info.game_name_executable)['base']
57+
local_player = r_uint64(process, base_address + Offsets.local_player)
58+
attr_reader = AttributesReader(process, base_address)
8059
asmite = Asmite(settings)
81-
username = quote(asmite.get_username())
82-
smite_key, update_key = asmite.get_settings()
83-
damage = asmite.get_damage(username)
60+
smite_key = asmite.get_settings()
61+
62+
damage = 0
63+
smite_charges = 0
64+
8465
width, height = GetSystemMetrics(0), GetSystemMetrics(1)
8566
world = World(process, base_address, width, height)
8667
set_cursor_pos = windll.user32.SetCursorPos
@@ -92,20 +73,34 @@ def autosmite(terminate, settings, jungle_pointers, on_window):
9273

9374
else:
9475
try:
95-
while 1:
76+
while 1 and on_window.value:
77+
player = attr_reader.read_player(local_player)
78+
79+
for buff in player.buffs:
80+
if 'smitedamagetracker' in str(buff.name).lower():
81+
damage = buff.count2
82+
9683
entities = [asmite._read_attr(process, pointer, nt) for pointer in jungle_pointers]
9784
target = [entity for entity in entities if entity.health <= damage and entity.alive]
98-
99-
if target:
85+
86+
spells = attr_reader.read_spells(local_player)
87+
if 'smite' in spells[4]['name'].lower():
88+
smite_charges = spells[4]['charges']
89+
elif 'smite' in spells[5]['name'].lower():
90+
smite_charges = spells[5]['charges']
91+
92+
if target and smite_charges > 0:
10093
pos = world.world_to_screen(world.get_view_proj_matrix(), target[0].x, target[0].z, target[0].y)
94+
mouse_pos = GetCursorPos()
10195
if pos:
10296
set_cursor_pos(pos[0], pos[1])
10397
send_key(smite_key)
104-
sleep(0.03)
98+
sleep(0.01)
99+
set_cursor_pos(mouse_pos[0], mouse_pos[1])
105100

106-
elif GetAsyncKeyState(update_key):
107-
damage = asmite.get_damage(username)
101+
sleep(0.03)
108102
except Exception as asmite_loop:
109103
debug_info(asmite_loop, True)
110104
sleep(0.1)
111105

106+

vakscript/data.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class Offsets:
4646
spell_name = int(offsets_file.get("offsets", "spell_name"), 16)
4747
spell_level = int(offsets_file.get("offsets", "spell_level"), 16)
4848
spell_cooldown = int(offsets_file.get("offsets", "spell_cooldown"), 16)
49+
spell_charges = int(offsets_file.get("offsets", "spell_charges"), 16)
4950

5051
buff_manager = int(offsets_file.get("offsets", "buff_manager"), 16)
5152
buff_count = int(offsets_file.get("offsets", "buff_count"), 16)
@@ -70,19 +71,9 @@ class Info:
7071
persisted_settings = 'Config\PersistedSettings.json'
7172
settings_to_persist_path = path.join(game_files_path, settings_to_persist)
7273
persisted_settings_path = path.join(game_files_path, persisted_settings)
73-
url_activeplayer = 'https://127.0.0.1:2999/liveclientdata/activeplayer'
74-
url_activeplayer_name = 'https://127.0.0.1:2999/liveclientdata/activeplayername'
7574
url_allgamedata = 'https://127.0.0.1:2999/liveclientdata/allgamedata'
7675
url_comunitydragon = 'https://raw.communitydragon.org/latest/game/data/characters/{name}/{name}.bin.json'
7776
root_key = 'characters/{}/characterrecords/root'
78-
asmite_raw_names = {
79-
"GeneratedTip_SummonerSpell_SummonerSmite_DisplayName":600.,
80-
"GeneratedTip_SummonerSpell_S5_SummonerSmitePlayerGanker_DisplayName":900.,
81-
"GeneratedTip_SummonerSpell_SummonerSmiteAvatarOffensive_DisplayName":1200.,
82-
"GeneratedTip_SummonerSpell_SummonerSmiteAvatarDefensive_DisplayName":1200.,
83-
"GeneratedTip_SummonerSpell_SummonerSmiteAvatarUtility_DisplayName":1200.
84-
}
85-
asmite_url_request = 'https://127.0.0.1:2999/liveclientdata/playersummonerspells?summonerName={username}'
8677

8778
VK_CODES = {'backspace':0x08,
8879
'tab':0x09,

vakscript/entities.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,20 @@ def read_turret(self, pointer):
173173

174174
def read_spells(self, pointer):
175175
spells, process = [], self.process
176-
spell_book = r_ints64(process, pointer + self.obj_spell_book, 0x4)
176+
spell_book = r_ints64(process, pointer + self.obj_spell_book, 0x6)
177177
for spell_slot in spell_book:
178+
spell_info_ptr = r_uint64(process, spell_slot + self.spell_info)
179+
spell_data_ptr = r_uint64(process, spell_info_ptr + self.spell_data)
180+
spell_name_ptr = r_uint64(process, spell_data_ptr + self.spell_name)
181+
name = r_string(process, spell_name_ptr, 50)
182+
charges = r_int(process, spell_slot + self.spell_charges)
183+
178184
level = r_int(process, spell_slot + self.spell_level)
179185
cooldown = r_float(process, spell_slot + self.spell_cooldown)
180-
spell = dict(level=level, cooldown=cooldown)
186+
spell = dict(name=name, charges=charges, level=level, cooldown=cooldown)
181187
spells.append(spell)
182188
# to use spells: spells[0]['level'] or spells[0]['cooldown']
183-
# where 0 is Q, 3 is R
189+
# where 0 is Q, 3 is R, 4 and 5 are summoner spells
184190
return spells
185191

186192

vakscript/gui.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def show_gui(main_instance, scripts_tabs, loaded_scripts):
164164

165165
with tab(label='AutoSmite'):
166166
add_checkbox(label='Use Auto Smite', callback=main_instance.start_autosmite_process)
167-
with child_window(width=GUI_WIDTH * 0.8, height=83):
167+
with child_window(width=GUI_WIDTH * 0.8, height=63):
168168
add_checkbox(
169169
label='Consider Blue / Red / Crab',
170170
default_value=jsonGetter().get_data('randb'),
@@ -175,11 +175,6 @@ def show_gui(main_instance, scripts_tabs, loaded_scripts):
175175
hint=jsonGetter().get_data('smite').upper(),
176176
callback=lambda _, data: GUIFunctions.set_autosmite_data('smite', data)
177177
)
178-
add_input_text(
179-
label='Update Key', width=30, no_spaces=True,
180-
hint=jsonGetter().get_data('update').upper(),
181-
callback=lambda _, data: GUIFunctions.set_autosmite_data('update', data)
182-
)
183178

184179
with tab(label='Scripts'):
185180
add_checkbox(label='Turn on external scripts', callback=main_instance.start_scripts_process, user_data=loaded_scripts)

vakscript/offsets.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ spell_data: 0x60
3232
spell_name: 0x80
3333
spell_level: 0x28
3434
spell_cooldown: 0x30
35+
spell_charges: 0x5C
3536
obj_item_list: 0x4070
3637
item_info: 0x38
3738
item_info_id: 0x9C

vakscript/settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
},
2828
"AutoSmite": {
2929
"smite": "f",
30-
"update": "q",
3130
"randb": true
3231
},
3332
"Scripts": {

0 commit comments

Comments
 (0)