Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
Adding food eater module
Browse files Browse the repository at this point in the history
  • Loading branch information
MuriloChianfa committed May 6, 2022
1 parent b6896ac commit 3fe1da1
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 6 deletions.
3 changes: 3 additions & 0 deletions core/GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ def addRadioImage(self, text, variable, value, position, command=None, image=Non
def After(self, Time, Function):
return self.windowID.after(Time, Function)

def deiconify(self):
return self.windowID.deiconify()

@staticmethod
def openImage(image, size):
ImageID = Image.open(image)
Expand Down
4 changes: 4 additions & 0 deletions core/SendToClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import win32api
import win32con

from time import sleep

from conf.HexMapKeys import KeyToHex
from conf.conf_manager import ConfManager

Expand Down Expand Up @@ -81,8 +83,10 @@ def Press(self, Key):

def PressHotkey(self, Option, Key):
win32api.keybd_event(KeyToHex.get(Option, ""), 0, 0, 0)
sleep(.05)
win32api.SendMessage(self.hwnd, win32con.WM_KEYDOWN, KeyToHex.get(Key, ""), 0)
win32api.SendMessage(self.hwnd, win32con.WM_KEYUP, KeyToHex.get(Key, ""), 0)
sleep(.05)
win32api.keybd_event(KeyToHex.get(Option, ""), 0, win32con.KEYEVENTF_KEYUP, 0)

'''
Expand Down
12 changes: 12 additions & 0 deletions engine/ScanFood.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from core.HookWindow import LocateImage


def scan_food(stats_positions):
starving = [0, 0]

starving[0], starving[1] = LocateImage('images/PlayerStats/Starving.png', Precision=0.9, Region=(
stats_positions[0], stats_positions[1], stats_positions[2], stats_positions[3]))

if starving[0] != 0 and starving[1] != 0:
return True
return False
16 changes: 12 additions & 4 deletions modules/FoodEater.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,32 @@
Food eater module
"""

from time import sleep

from conf.Hotkeys import Hotkey

from core.GUI import *
from core.GUIManager import *
from core.GUISetter import GUISetter, check_gui
from core.ThreadManager import ThreadManager

from engine.ScanFood import scan_food


class FoodEater:
started = False
enabled = False

gui_changes = []

def __init__(self, root, MOUSE_OPTION):
def __init__(self, root, stats_positions, MOUSE_OPTION):
self.root = root
self.window = GUI('FoodEater', 'Module: Food Eater')
self.window.DefaultWindow('FoodEater', [306, 191], [1.2, 2.29])
self.Setter = GUISetter("FoodEaterLoader")
self.SendToClient = Hotkey(MOUSE_OPTION)
self.ThreadManager = ThreadManager("ThreadFoodEater")
self.stats_positions = stats_positions

self.gui_vars()
self.gui()
Expand Down Expand Up @@ -60,7 +65,10 @@ def pause(self):

def execute(self):
while FoodEater.enabled:
print('Hotkey to eat food: ', self.food_hotkey.get())
if scan_food(self.stats_positions):
self.SendToClient.Press(self.food_hotkey.get())
print("Starving... pressing: ", self.food_hotkey.get())
sleep(0.5)

def destroy(self):
check_gui(FoodEater.gui_changes, self.init_check_print, self.check_print.get(), 'CheckPrint')
Expand Down Expand Up @@ -96,8 +104,8 @@ def gui(self):
if not FoodEater.enabled:
self.enabled_button = self.window.addButton('FoodEater: OFF', self.trigger, [287, 23], [11, 132])
else:
self.enabled_button = self.window.addButton('FoodEater: ON', self.trigger, [287, 23], [11, 132]) \
.configure(relief=SUNKEN, bg=rgb((158, 46, 34)))
self.enabled_button = self.window.addButton('FoodEater: ON', self.trigger, [287, 23], [11, 132])
self.enabled_button.configure(relief=SUNKEN, bg=rgb((158, 46, 34)))

self.ok_button = self.window.addButton('Ok', self.destroy, [73, 21], [115, 161])

Expand Down
3 changes: 2 additions & 1 deletion modules/Root.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class root:
def __init__(self, CharName, LoadedJson):
self.root = GUI('root', 'TibiaAuto V12')
self.root.MainWindow('Main', [357, 530], [2, 2.36])
self.root.deiconify()

self.root.addMinimalLabel(f'Logged as: {CharName}', [14, 14])

Expand Down Expand Up @@ -292,7 +293,7 @@ def OpenCreatureInfo():


def OpenFoodEater():
FoodEater(root, MOUSE_OPTION)
FoodEater(root, StatsPositions, MOUSE_OPTION)


def OpenFPSChanger():
Expand Down
2 changes: 1 addition & 1 deletion scripts/conf.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"configured": true,
"configured": false,
"hwnd": 460820,
"preferences_name": "NewConfig.json",
"platform": "windows"
Expand Down

0 comments on commit 3fe1da1

Please sign in to comment.