diff --git a/conf/Constants.py b/conf/Constants.py index 6afe3e0..cea9445 100644 --- a/conf/Constants.py +++ b/conf/Constants.py @@ -4,6 +4,45 @@ Percentage = [100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5] Priority = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] +# Auto healing types +HealingType = ["Life", "Mana"] + +# Containers +Containers = [ + "Backpack", + "Bag", + "Basket", + "BeachBackpack", + "BlueBackpack", + "BrocadeBag", + "BuggyBackpack", + "CamouflageBackpack", + "CrownBackpack", + "DeeplingBackpack", + "DemonBackpack", + "DragonBackpack", + "ExpeditionBackpack", + "FurBackpack", + "FurBag", + "GloothBackpack", + "GoldenBackpack", + "GreenBackpack", + "GreenBag", + "GreyBackpack", + "JewelledBackpack", + "MinotaurBackpack", + "OrangeBackpack", + "PirateBackpack", + "PirateBag", + "Present", + "PurpleBackpack", + "RedBackpack", + "RedBag", + "ShoppingBag", + "StampedParcel", + "YellowBackpack" +] + # RGB Of Life Color Pixel For Analyze In ScanStages.py LifeColorFull = [194, 74, 74] LifeColor = [219, 79, 79] diff --git a/conf/Hotkeys.py b/conf/Hotkeys.py index 026ab7d..52285ea 100644 --- a/conf/Hotkeys.py +++ b/conf/Hotkeys.py @@ -74,6 +74,10 @@ def LeftClick(self, X, Y): def RightClick(self, X, Y): Position = X, Y self.SendToClient.RightClick(Position) + + def RawRightClick(self, X, Y): + Position = X, Y + self.SendToClient.RawRightClick(Position) def MoveTo(self, X, Y): self.SendToClient.MoveTo(X, Y) diff --git a/core/GUI.py b/core/GUI.py index 36b2f7a..48ce480 100644 --- a/core/GUI.py +++ b/core/GUI.py @@ -1,10 +1,12 @@ import pyautogui import tkinter as tk -from tkinter import SUNKEN, RAISED, ttk +from tkinter import ttk from PIL import Image, ImageTk from core.Defaults import * +MainWindow = None + class GUI: def __init__(self, windowID, name): @@ -12,6 +14,8 @@ def __init__(self, windowID, name): self.name = name def MainWindow(self, BackgroundImage, sizes, positions): + global MainWindow + self.windowID = tk.Tk() w = sizes[0] h = sizes[1] @@ -24,11 +28,12 @@ def MainWindow(self, BackgroundImage, sizes, positions): self.windowID.resizable(width=False, height=False) self.windowID.configure(background='#000', takefocus=True) self.windowID.iconbitmap('images/icon.ico') - image = Image.open('images/Modules/' + BackgroundImage + '.png') + image = Image.open(f'images/Modules/{BackgroundImage}.png') photo = ImageTk.PhotoImage(image) label = tk.Label(self.windowID, image=photo, bg='#000') label.image = photo label.pack() + MainWindow = self.windowID def DefaultWindow(self, BackgroundImage, sizes, positions): self.windowID = tk.Toplevel() @@ -57,7 +62,8 @@ def InvisibleWindow(self, BackgroundImage): self.windowID.grab_set() self.windowID.resizable(width=False, height=False) self.windowID.geometry('130x130') - self.windowID.image = tk.PhotoImage(file='images/BackgroundImages/' + BackgroundImage + '.png') + self.windowID.image = tk.PhotoImage( + file='images/BackgroundImages/' + BackgroundImage + '.png') label = tk.Label(self.windowID, image=self.windowID.image, bg='black') label.place(x=0, y=0) self.windowID.overrideredirect(True) @@ -139,7 +145,8 @@ def addList(self, columns, height, sizes, position): frame = tk.Frame(self.windowID, height=sizes[1], width=sizes[0]) frame.place(x=position[0], y=position[1]) - table = ttk.Treeview(self.windowID, columns=columns, height=height, show='headings') + table = ttk.Treeview(self.windowID, columns=columns, + height=height, show='headings') table.place(x=position[0], y=position[1]) return table @@ -179,14 +186,11 @@ def addEntry(self, position, var, width=12): entryID.place(x=position[0], y=position[1]) return entryID - def addOption(self, variable, options, position, width=4): - optionID = tk.OptionMenu(self.windowID, variable, *options) - optionID['bg'] = rgb((114, 0, 0)) - optionID['fg'] = 'white' - optionID['activebackground'] = rgb((103, 13, 5)) - optionID["highlightthickness"] = 0 - optionID['width'] = width - optionID['cursor'] = "hand2" + def addOption(self, variable, options, position, width=4, command=None): + optionID = tk.OptionMenu( + self.windowID, variable, *options, command=command) + optionID.config(bg=rgb((114, 0, 0)), fg='white', activebackground=rgb( + (103, 13, 5)), highlightthickness=0, width=width, cursor='hand2', ) optionID.place(x=position[0], y=position[1]) return optionID @@ -224,6 +228,10 @@ def addRadioImage(self, text, variable, value, position, command=None, image=Non def After(self, Time, Function): return self.windowID.after(Time, Function) + def ExitGUI(): + MainWindow.destroy() + raise SystemExit + def deiconify(self): return self.windowID.deiconify() diff --git a/core/Getters.py b/core/Getters.py index 1d025f8..a087016 100644 --- a/core/Getters.py +++ b/core/Getters.py @@ -1,6 +1,7 @@ -from core.HookWindow import LocateCenterImage, LocateImage +from core.HookWindow import LocateCenterImage, LocateImage, TakeImage BattlePositions = [0, 0, 0, 0] +MainContainerPositions = [0, 0, 0, 0] MapPositions = [0, 0, 0, 0] StatsPositions = [0, 0, 0, 0] GameWindow = [0, 0, 0, 0] @@ -8,16 +9,24 @@ SQMs = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] SQMsSizes = [0, 0] +SavedTakenImage = [] + + +def GetClientScreenshot(): + TakeImage().save('screen.jpg') + def GetAccountNamePosition(): - AccountName = LocateCenterImage('images/TibiaSettings/AccountName.png', Precision=0.9) + AccountName = LocateCenterImage( + 'images/TibiaSettings/AccountName.png', Precision=0.9) if AccountName[0] != 0 and AccountName[1] != 0: return AccountName[0], AccountName[1] return 0, 0 def GetBattlePosition(): - BattlePositions[0], BattlePositions[1] = LocateCenterImage('images/TibiaSettings/BattleList.png', Precision=0.85) + BattlePositions[0], BattlePositions[1] = LocateCenterImage( + 'images/TibiaSettings/BattleList.png', Precision=0.85) if BattlePositions[0] == 0 and BattlePositions[1] == 0: return 0, 0, 0, 0 @@ -31,28 +40,34 @@ def GetBattlePosition(): def GetHealthPosition(): - HealthPositions = LocateCenterImage('images/PlayerSettings/health.png', Precision=0.8) + HealthPositions = LocateCenterImage( + 'images/PlayerSettings/health.png', Precision=0.8) if HealthPositions[0] != 0 and HealthPositions[1] != 0: return HealthPositions[0], HealthPositions[1] return 0, 0 def GetManaPosition(): - ManaPositions = LocateCenterImage('images/PlayerSettings/mana.png', Precision=0.8) + ManaPositions = LocateCenterImage( + 'images/PlayerSettings/mana.png', Precision=0.8) if ManaPositions[0] != 0 and ManaPositions[1] != 0: return ManaPositions[0], ManaPositions[1] def GetMapPosition(): - top_right = LocateImage("images/MapSettings/MapSettings.png", Precision=0.8) + top_right = LocateImage( + "images/MapSettings/MapSettings.png", Precision=0.8) map_size = 110 # 110px square - MapPositions[0], MapPositions[1] = top_right[0] - map_size + 4, top_right[1] + 1 - MapPositions[2], MapPositions[3] = top_right[0] - 1, top_right[1] + map_size - 1 + MapPositions[0], MapPositions[1] = top_right[0] - \ + map_size + 4, top_right[1] + 1 + MapPositions[2], MapPositions[3] = top_right[0] - \ + 1, top_right[1] + map_size - 1 if top_right[0] != -1: print(f"MiniMap Start [X: {MapPositions[0]}, Y: {MapPositions[1]}]") print(f"MiniMap End [X: {MapPositions[2]}, Y: {MapPositions[3]}]") print("") - print(f"Size of MiniMap [X: {MapPositions[2] - MapPositions[0]}, Y: {MapPositions[3] - MapPositions[1]}]") + print( + f"Size of MiniMap [X: {MapPositions[2] - MapPositions[0]}, Y: {MapPositions[3] - MapPositions[1]}]") return MapPositions[0], MapPositions[1], MapPositions[2], MapPositions[3] print("Error To Get Map Positions") @@ -60,7 +75,8 @@ def GetMapPosition(): def GetStatsPosition(): - StatsPositions[0], StatsPositions[1] = LocateImage('images/TibiaSettings/Stop.png', Precision=0.8) + StatsPositions[0], StatsPositions[1] = LocateImage( + 'images/TibiaSettings/Stop.png', Precision=0.8) if StatsPositions[0] != 0 and StatsPositions[1] != 0: StatsPositions[0] = StatsPositions[0] - 117 StatsPositions[1] = StatsPositions[1] + 1 @@ -71,13 +87,31 @@ def GetStatsPosition(): return 0, 0, 0, 0 +def GetMainContainerPosition(name='Bag'): + main_container_position = LocateImage( + f'images/Items/ContainersName/{name}.png', Precision=.9) + print('main_container_position', main_container_position) + MainContainerPositions[0], MainContainerPositions[1] = main_container_position[0], main_container_position[1] + if main_container_position[0] != -1: + print( + f"Main Container Start [X: {MainContainerPositions[0]}, Y: {MainContainerPositions[1]}]") + print("") + return MainContainerPositions[0], MainContainerPositions[1] + + print("Error To Get Container Positions") + return -1, -1 + + def GetPlayerPosition(): - LeftGameWindow = LocateImage("images/PlayerSettings/LeftOption1.png", Precision=0.75) + LeftGameWindow = LocateImage( + "images/PlayerSettings/LeftOption1.png", Precision=0.75) if LeftGameWindow[0] == 0 and LeftGameWindow[1] == 0: - LeftGameWindow = LocateImage("images/PlayerSettings/LeftOption2.png", Precision=0.75) + LeftGameWindow = LocateImage( + "images/PlayerSettings/LeftOption2.png", Precision=0.75) if LeftGameWindow[0] == 0 and LeftGameWindow[1] == 0: - LeftGameWindow = LocateImage("images/PlayerSettings/LeftOption3.png", Precision=0.75) + LeftGameWindow = LocateImage( + "images/PlayerSettings/LeftOption3.png", Precision=0.75) try: GameWindow[0] = int(LeftGameWindow[0]) @@ -85,21 +119,26 @@ def GetPlayerPosition(): except Exception as errno: return 0, 0, 0, 0, 0, 0 - RightGameWindow = LocateImage("images/PlayerSettings/RightOption1.png", Precision=0.75) + RightGameWindow = LocateImage( + "images/PlayerSettings/RightOption1.png", Precision=0.75) if RightGameWindow[0] == 0 and RightGameWindow[1] == 0: - RightGameWindow = LocateImage("images/PlayerSettings/RightOption2.png", Precision=0.75) + RightGameWindow = LocateImage( + "images/PlayerSettings/RightOption2.png", Precision=0.75) if RightGameWindow[0] == 0 and RightGameWindow[1] == 0: - RightGameWindow = LocateImage("images/PlayerSettings/RightOption3.png", Precision=0.75) + RightGameWindow = LocateImage( + "images/PlayerSettings/RightOption3.png", Precision=0.75) if RightGameWindow[0] == 0 and RightGameWindow[1] == 0: - RightGameWindow = LocateImage("images/PlayerSettings/RightOption4.png", Precision=0.75) + RightGameWindow = LocateImage( + "images/PlayerSettings/RightOption4.png", Precision=0.75) try: GameWindow[2] = int(RightGameWindow[0]) except Exception as errno: return 0, 0, 0, 0, 0, 0 - ButtomGameWindow = LocateImage("images/PlayerSettings/EndLocation.png", Precision=0.7) + ButtomGameWindow = LocateImage( + "images/PlayerSettings/EndLocation.png", Precision=0.7) if ButtomGameWindow[0] == 0 and ButtomGameWindow[1] == 0: return 0, 0, 0, 0, 0, 0 else: @@ -126,7 +165,8 @@ def SetSQMs(): if GameWindow[0] and GameWindow[1] != 0: SQMsSizes[0] = int((GameWindow[2] - GameWindow[0]) / 15) SQMsSizes[1] = int((GameWindow[3] - GameWindow[1]) / 11) - print(f"Size of Your SQM [Width: {SQMsSizes[0]}px, Height: {SQMsSizes[1]}px]") + print( + f"Size of Your SQM [Width: {SQMsSizes[0]}px, Height: {SQMsSizes[1]}px]") print('') else: print("Reconfiguring The Player Position") @@ -155,8 +195,8 @@ def SetSQMs(): SQMs[16] = Player[0] + SQMsSizes[0] SQMs[17] = Player[1] - SQMsSizes[1] return SQMs[0], SQMs[1], SQMs[2], SQMs[3], SQMs[4], SQMs[5], SQMs[6], \ - SQMs[7], SQMs[8], SQMs[9], SQMs[10], SQMs[11], SQMs[12], SQMs[13], \ - SQMs[14], SQMs[15], SQMs[16], SQMs[17] + SQMs[7], SQMs[8], SQMs[9], SQMs[10], SQMs[11], SQMs[12], SQMs[13], \ + SQMs[14], SQMs[15], SQMs[16], SQMs[17] print("Setting Player Position...") Player[0], Player[1], GameWindow[0], GameWindow[1], GameWindow[2], GameWindow[ diff --git a/core/HookWindow.py b/core/HookWindow.py index baa96cd..5ffd992 100644 --- a/core/HookWindow.py +++ b/core/HookWindow.py @@ -1,19 +1,22 @@ -import numpy as np +import time import cv2 -from PIL import Image, ImageOps +import multiprocessing as mp +import numpy as np +from datetime import datetime +from tkinter import messagebox +from PIL import ImageOps -from conf.conf_manager import ConfManager +from core.GUI import * +from conf.conf_manager import ConfManager -data = ConfManager.get('conf.json') +platform = ConfManager.get('conf.json')['platform'] -if data['platform'] == "windows": +if platform == "windows": from ctypes import windll import win32ui import win32gui - - hwnd = data['hwnd'] -elif data['platform'] == "linux": +elif platform == "linux": import os from core.LinuxClient import Execute, FindAnotherWindow, FindWindow @@ -24,58 +27,58 @@ class Hooker: - if data['platform'] == 'windows': + if platform == 'windows': def __init__(self): - self.hwnd = hwnd - self.win32gui = win32gui - self.win32ui = win32ui + self.hwnd = ConfManager.get('conf.json')['hwnd'] + while win32gui.IsIconic(self.hwnd): + time.sleep(1) self.dll = windll.user32 - self.hwndDC = self.win32gui.GetWindowDC(self.hwnd) - self.mfcDC = self.win32ui.CreateDCFromHandle(self.hwndDC) + try: + self.hwndDC = win32gui.GetWindowDC(self.hwnd) + except: + messagebox.showerror( + 'Tibia window not detected!', 'Please open a Tibia instance or focus the existing window again.') + GUI.ExitGUI() + self.mfcDC = win32ui.CreateDCFromHandle(self.hwndDC) self.saveDC = self.mfcDC.CreateCompatibleDC() - self.saveBitMap = self.win32ui.CreateBitmap() - self.left, self.top, self.right, self.bot = self.win32gui.GetClientRect(self.hwnd) + self.saveBitMap = win32ui.CreateBitmap() + self.left, self.top, self.right, self.bot = win32gui.GetClientRect( + self.hwnd) self.left = self.left + 8 self.top = self.top + 8 self.right = self.right + 8 self.bot = self.bot + 8 self.w = self.right - self.left self.h = self.bot - self.top - self.saveBitMap.CreateCompatibleBitmap(self.mfcDC, self.w, self.h) + self.saveBitMap.CreateCompatibleBitmap( + self.mfcDC, self.w, self.h) self.saveDC.SelectObject(self.saveBitMap) - self.result = self.dll.PrintWindow(self.hwnd, self.saveDC.GetSafeHdc(), 1) + self.targetWindowIsFocused = self.dll.PrintWindow( + self.hwnd, self.saveDC.GetSafeHdc(), 1) self.bmpinfo = self.saveBitMap.GetInfo() self.bmpstr = self.saveBitMap.GetBitmapBits(True) - self.TakedImage = Image.frombuffer( + self.TakenImage = Image.frombuffer( 'RGB', (self.bmpinfo['bmWidth'], self.bmpinfo['bmHeight']), self.bmpstr, 'raw', 'BGRX', 0, 1) - self.win32gui.DeleteObject(self.saveBitMap.GetHandle()) + win32gui.DeleteObject(self.saveBitMap.GetHandle()) self.saveDC.DeleteDC() self.mfcDC.DeleteDC() - self.win32gui.ReleaseDC(self.hwnd, self.hwndDC) + win32gui.ReleaseDC(self.hwnd, self.hwndDC) - elif data['platform'] == 'linux': - def __init__(self, FileName="images/tmp_screen.png"): - Execute(["scrot", "-u", FileName]) - self.TakedImage = cv2.imread(FileName) + elif platform == 'linux': + def __init__(self, Filename="images/tmp_screen.png"): + Execute(["scrot", "-u", Filename]) + self.TakenImage = cv2.imread(Filename) - if self.TakedImage is not None: - self.result = 1 + if self.TakenImage is not None: + self.targetWindowIsFocused = 1 def HookWindow(self): - if self.result == 1: - return self.TakedImage - else: - self.win32gui.SetForegroundWindow(self.hwnd) - self.TakedImage = Hooker().HookWindow() - if self.result == 1: - return self.TakedImage - else: - return print('Debugged From HookWindow') + return self.TakenImage ''' @@ -88,14 +91,17 @@ def TakeImage(Region=None): Except = True while Except: try: - TakedImage = Hooker().HookWindow() + TakenImage = Hooker().HookWindow() if Region is not None: - TakedImage = TakedImage.crop( + TakenImage = TakenImage.crop( (Region[0], Region[1], Region[0] + (Region[2] - Region[0]), Region[1] + (Region[3] - Region[1]))) - return TakedImage + Except = False + return TakenImage else: - return TakedImage + Except = False + return TakenImage except Exception as Ex: + print('Ex', Ex) # print("Debugged From TakeImage: ", Ex) Except = True pass @@ -117,9 +123,9 @@ def TakeImage(Region=None): def LocateImage(image, Region=None, Precision=0.8): - TakedImage = TakeImage(Region) + TakenImage = TakeImage(Region) - img_rgb = np.array(TakedImage) + img_rgb = np.array(TakenImage) img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY) template = cv2.imread(image, 0) @@ -140,9 +146,9 @@ def LocateImage(image, Region=None, Precision=0.8): def LocateCenterImage(image, Region=None, Precision=0.8): - TakedImage = TakeImage(Region) + TakenImage = TakeImage(Region) - img_rgb = np.array(TakedImage) + img_rgb = np.array(TakenImage) img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY) template = cv2.imread(image, 0) @@ -169,10 +175,10 @@ def LocateCenterImage(image, Region=None, Precision=0.8): def LocateAllImages(image, Region=None, Precision=0.8): - TakedImage = TakeImage(Region) + TakenImage = TakeImage(Region) - TakedImage = np.array(TakedImage) - img_gray = cv2.cvtColor(TakedImage, cv2.COLOR_BGR2GRAY) + TakenImage = np.array(TakenImage) + img_gray = cv2.cvtColor(TakenImage, cv2.COLOR_BGR2GRAY) template = cv2.imread(image, 0) w, h = template.shape[::-1] @@ -210,8 +216,8 @@ def LocateBoolRGBImage(image, Region=None, Precision=0.9): def PixelMatchesColor(X, Y, expectedRGBColor): - TakedImage = TakeImage(Region=(X, Y, X + 1, Y + 1)) - rgb = TakedImage.getpixel((0, 0)) + TakenImage = TakeImage(Region=(X, Y, X + 1, Y + 1)) + rgb = TakenImage.getpixel((0, 0)) if rgb == expectedRGBColor: return True else: @@ -221,15 +227,15 @@ def PixelMatchesColor(X, Y, expectedRGBColor): ''' When Called, It Save The Image On Folder And Name Passed Per Argument, Examples: - 1°: SaveImage('TakedImage.png') == Save The Image In Current Directory, + 1°: SaveImage('TakenImage.png') == Save The Image In Current Directory, 2°: SaveImage('images/Foods/Cheese.png', (1234, 435, 1280, 460)) == Save The Image On Passed Folder, And Crop Then In X: 1234 Up Until 1280 And Y: 435 Up Until 460. ''' def SaveImage(Name, Region=None): - TakedImage = TakeImage(Region) - return TakedImage.save(Name) + TakenImage = TakeImage(Region) + return TakenImage.save(Name) def GetImageSize(needleImage): diff --git a/core/MoveMouse.py b/core/MoveMouse.py index bc34518..988a1aa 100644 --- a/core/MoveMouse.py +++ b/core/MoveMouse.py @@ -1,6 +1,7 @@ -import json import ctypes import ctypes.wintypes +import win32api +import win32con from conf.HexMapKeys import KeyToHex from conf.conf_manager import ConfManager @@ -39,36 +40,48 @@ def Position(self): return Cursor.x, Cursor.y - 24 def Press(self, Key): - self.DLL.keybd_event(KeyToHex.get(Key, ""), 0, self.KEYEVENTF_KEYDOWN, 0) + self.DLL.keybd_event(KeyToHex.get(Key, ""), 0, + self.KEYEVENTF_KEYDOWN, 0) self.DLL.keybd_event(KeyToHex.get(Key, ""), 0, self.KEYEVENTF_KEYUP, 0) def PressHotkey(self, Option, Key): - self.DLL.keybd_event(KeyToHex.get(Option, ""), 0, self.KEYEVENTF_KEYDOWN, 0) - self.DLL.keybd_event(KeyToHex.get(Key, ""), 0, self.KEYEVENTF_KEYDOWN, 0) + self.DLL.keybd_event(KeyToHex.get(Option, ""), 0, + self.KEYEVENTF_KEYDOWN, 0) + self.DLL.keybd_event(KeyToHex.get(Key, ""), 0, + self.KEYEVENTF_KEYDOWN, 0) self.DLL.keybd_event(KeyToHex.get(Key, ""), 0, self.KEYEVENTF_KEYUP, 0) - self.DLL.keybd_event(KeyToHex.get(Option, ""), 0, self.KEYEVENTF_KEYUP, 0) + self.DLL.keybd_event(KeyToHex.get(Option, ""), + 0, self.KEYEVENTF_KEYUP, 0) def LeftClick(self, Position): self.DLL.SetCursorPos(Position[0], Position[1] + 24) - self.DLL.mouse_event(self.MOUSEEVENTF_LEFTCLICK, ctypes.c_long(Position[0]), ctypes.c_long(Position[1] + 24), 0, 0) + self.DLL.mouse_event(self.MOUSEEVENTF_LEFTCLICK, ctypes.c_long( + Position[0]), ctypes.c_long(Position[1] + 24), 0, 0) def RightClick(self, Position): self.DLL.SetCursorPos(Position[0], Position[1] + 24) - self.DLL.mouse_event(self.MOUSEEVENTF_RIGHTCLICK, ctypes.c_long(Position[0]), ctypes.c_long(Position[1] + 24), 0, 0) + self.DLL.mouse_event(self.MOUSEEVENTF_RIGHTCLICK, ctypes.c_long( + Position[0]), ctypes.c_long(Position[1] + 24), 0, 0) def MoveTo(self, X, Y): self.DLL.SetCursorPos(X, Y + 24) def DragTo(self, From, To): self.DLL.SetCursorPos(From[0], From[1]) - self.DLL.mouse_event(self.MOUSEEVENTF_LEFTDOWN, ctypes.c_long(From[0]), ctypes.c_long(From[1] + 24), 0, 0) + self.DLL.mouse_event(self.MOUSEEVENTF_LEFTDOWN, ctypes.c_long( + From[0]), ctypes.c_long(From[1] + 24), 0, 0) self.DLL.SetCursorPos(To[0], To[1] + 24) - self.DLL.mouse_event(self.MOUSEEVENTF_LEFTUP, ctypes.c_long(To[0]), ctypes.c_long(To[1] + 24), 0, 0) + self.DLL.mouse_event(self.MOUSEEVENTF_LEFTUP, ctypes.c_long( + To[0]), ctypes.c_long(To[1] + 24), 0, 0) def UseOn(self, From, To): self.DLL.SetCursorPos(From[0], From[1] + 24) - self.DLL.mouse_event(self.MOUSEEVENTF_RIGHTDOWN, ctypes.c_long(From[0]), ctypes.c_long(From[1] + 24), 0, 0) - self.DLL.mouse_event(self.MOUSEEVENTF_RIGHTUP, ctypes.c_long(From[0]), ctypes.c_long(From[1] + 24), 0, 0) + self.DLL.mouse_event(self.MOUSEEVENTF_RIGHTDOWN, ctypes.c_long( + From[0]), ctypes.c_long(From[1] + 24), 0, 0) + self.DLL.mouse_event(self.MOUSEEVENTF_RIGHTUP, ctypes.c_long( + From[0]), ctypes.c_long(From[1] + 24), 0, 0) self.DLL.SetCursorPos(To[0], To[1] + 24) - self.DLL.mouse_event(self.MOUSEEVENTF_LEFTDOWN, ctypes.c_long(To[0]), ctypes.c_long(To[1] + 24), 0, 0) - self.DLL.mouse_event(self.MOUSEEVENTF_LEFTUP, ctypes.c_long(To[0]), ctypes.c_long(To[1] + 24), 0, 0) + self.DLL.mouse_event(self.MOUSEEVENTF_LEFTDOWN, ctypes.c_long( + To[0]), ctypes.c_long(To[1] + 24), 0, 0) + self.DLL.mouse_event(self.MOUSEEVENTF_LEFTUP, ctypes.c_long( + To[0]), ctypes.c_long(To[1] + 24), 0, 0) diff --git a/core/SendToClient.py b/core/SendToClient.py index b4256df..db45270 100644 --- a/core/SendToClient.py +++ b/core/SendToClient.py @@ -69,8 +69,10 @@ def IsFocused(self): ''' def Press(self, Key): - win32api.SendMessage(self.hwnd, win32con.WM_KEYDOWN, KeyToHex.get(Key, ""), 0) - win32api.SendMessage(self.hwnd, win32con.WM_KEYUP, KeyToHex.get(Key, ""), 0) + win32api.SendMessage(self.hwnd, win32con.WM_KEYDOWN, + KeyToHex.get(Key, ""), 0) + win32api.SendMessage(self.hwnd, win32con.WM_KEYUP, + KeyToHex.get(Key, ""), 0) ''' Send One Press HotKey For Client @@ -84,10 +86,13 @@ 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) + 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) + win32api.keybd_event(KeyToHex.get(Option, ""), 0, + win32con.KEYEVENTF_KEYUP, 0) ''' Here He Send One Mouse Click At One Position Received From Arg @@ -100,17 +105,35 @@ def PressHotkey(self, Option, Key): def LeftClick(self, Position): ClientPosition = win32gui.ScreenToClient(self.hwnd, Position) - PositionToClick = win32api.MAKELONG(ClientPosition[0], ClientPosition[1]) - win32api.PostMessage(self.hwnd, win32con.WM_MOUSEMOVE, 0, PositionToClick) - win32api.SendMessage(self.hwnd, win32con.WM_LBUTTONDOWN, win32con.MK_LBUTTON, PositionToClick) - win32api.SendMessage(self.hwnd, win32con.WM_LBUTTONUP, win32con.MK_LBUTTON, PositionToClick) + PositionToClick = win32api.MAKELONG( + ClientPosition[0], ClientPosition[1]) + win32api.PostMessage( + self.hwnd, win32con.WM_MOUSEMOVE, 0, PositionToClick) + win32api.SendMessage(self.hwnd, win32con.WM_LBUTTONDOWN, + win32con.MK_LBUTTON, PositionToClick) + win32api.SendMessage(self.hwnd, win32con.WM_LBUTTONUP, + win32con.MK_LBUTTON, PositionToClick) def RightClick(self, Position): ClientPosition = win32gui.ScreenToClient(self.hwnd, Position) - PositionToClick = win32api.MAKELONG(ClientPosition[0], ClientPosition[1]) - win32api.PostMessage(self.hwnd, win32con.WM_MOUSEMOVE, 0, PositionToClick) - win32api.SendMessage(self.hwnd, win32con.WM_RBUTTONDOWN, win32con.MK_RBUTTON, PositionToClick) - win32api.SendMessage(self.hwnd, win32con.WM_RBUTTONUP, win32con.MK_RBUTTON, PositionToClick) + PositionToClick = win32api.MAKELONG( + ClientPosition[0], ClientPosition[1]) + win32api.PostMessage( + self.hwnd, win32con.WM_MOUSEMOVE, 0, PositionToClick) + win32api.SendMessage(self.hwnd, win32con.WM_RBUTTONDOWN, + win32con.MK_RBUTTON, PositionToClick) + win32api.SendMessage(self.hwnd, win32con.WM_RBUTTONUP, + win32con.MK_RBUTTON, PositionToClick) + + def RawRightClick(self, Position): + if (self.IsFocused()): + (previousCursorX, previousCursorY) = win32api.GetCursorPos() + win32api.SetCursorPos((Position[0], Position[1] + 24)) + win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, + Position[0], Position[1] + 24, 0, 0) + win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, + Position[0], Position[1] + 24, 0, 0) + win32api.SetCursorPos((previousCursorX, previousCursorY)) ''' Usage Just For Tibia... @@ -125,21 +148,27 @@ def DragTo(self, From, To): FromPosition = win32api.MAKELONG(ClientFrom[0], ClientFrom[1]) ClientTo = win32gui.ScreenToClient(self.hwnd, To) ToPosition = win32api.MAKELONG(ClientTo[0], ClientTo[1]) - win32api.SendMessage(self.hwnd, win32con.WM_LBUTTONDOWN, win32con.MK_LBUTTON, FromPosition) + win32api.SendMessage(self.hwnd, win32con.WM_LBUTTONDOWN, + win32con.MK_LBUTTON, FromPosition) win32api.SendMessage(self.hwnd, win32con.WM_MOUSEMOVE, 0, ToPosition) - win32api.SendMessage(self.hwnd, win32con.WM_LBUTTONUP, win32con.MK_LBUTTON, ToPosition) + win32api.SendMessage(self.hwnd, win32con.WM_LBUTTONUP, + win32con.MK_LBUTTON, ToPosition) def UseOn(self, From, To): ClientFrom = win32gui.ScreenToClient(self.hwnd, From) FromPosition = win32api.MAKELONG(ClientFrom[0], ClientFrom[1]) win32api.PostMessage(self.hwnd, win32con.WM_MOUSEMOVE, 0, FromPosition) - win32api.SendMessage(self.hwnd, win32con.WM_RBUTTONDOWN, win32con.MK_RBUTTON, FromPosition) - win32api.SendMessage(self.hwnd, win32con.WM_RBUTTONUP, win32con.MK_RBUTTON, FromPosition) + win32api.SendMessage(self.hwnd, win32con.WM_RBUTTONDOWN, + win32con.MK_RBUTTON, FromPosition) + win32api.SendMessage(self.hwnd, win32con.WM_RBUTTONUP, + win32con.MK_RBUTTON, FromPosition) ClientTo = win32gui.ScreenToClient(self.hwnd, To) ToPosition = win32api.MAKELONG(ClientTo[0], ClientTo[1]) win32api.PostMessage(self.hwnd, win32con.WM_MOUSEMOVE, 0, ToPosition) - win32api.SendMessage(self.hwnd, win32con.WM_LBUTTONDOWN, win32con.MK_LBUTTON, ToPosition) - win32api.SendMessage(self.hwnd, win32con.WM_LBUTTONUP, win32con.MK_LBUTTON, ToPosition) + win32api.SendMessage(self.hwnd, win32con.WM_LBUTTONDOWN, + win32con.MK_LBUTTON, ToPosition) + win32api.SendMessage(self.hwnd, win32con.WM_LBUTTONUP, + win32con.MK_LBUTTON, ToPosition) @staticmethod def MainWindowSize(): diff --git a/core/ThreadManager.py b/core/ThreadManager.py index f9a03fa..af97518 100644 --- a/core/ThreadManager.py +++ b/core/ThreadManager.py @@ -1,124 +1,39 @@ -from threading import Event, Thread -from queue import Queue +import threading +from multiprocessing import Process -ActivatedThreads = [] -Queue = Queue(maxsize=19) -Event = Event() +ActiveThreads = {} class ThreadManager: - """ - This Class Has Been Rewritten So That We Can Pause The Modules Enabled, - In Original Class, It's Not Possible, There He Had To Keep Creating New Threads - And That, Overloads The System. - - Example For Usage: - - # Import The Module Fist - from Core.ThreadManager import ThreadManager - - # And Create The Instance - ThreadManager = ThreadManager("NameOfYourThread") - - # For Start The New Thread - ThreadManager.NewThread(TargetFunctionHere) [DOES NOT ACCEPT ARGUMENTS YET] - - # For Pause All Threads - ThreadManager.PauseThread() - - # For UnPause All Threads - ThreadManager.UnPauseThread() - - # - # The Kill Threads Functions Not Ready Yet !!! Sorry - # - """ - - def __init__(self, Name): - self.Name = Name - self.Queue = Queue - self.Target = None - - # Create One New Thread And Put Them In The Pipeline - def NewThread(self, _Target): - # The Handle Need The 1st Arg to Work.. - def HandleTarget(PipeOBJ): - # print(f"PipeObject: {PipeOBJ}") - _Target() - - self.Target = Pipeline(HandleTarget) - self.Queue.put(self.Target) - Event.set() - TheThread = self.ThreadHandler(Target=self.Target, Qqueue=Queue, Name=self.Name) - - # This thread dies when main thread - TheThread.daemon = True - - TheThread.start() - ActivatedThreads.append((TheThread, str(self.Name))) - - # Pause The All Threads Created From Manager Object - def PauseThread(self): - for i in range(len(ActivatedThreads)): - if ActivatedThreads[i][1] == self.Name: - ActivatedThreads[i][0].PauseOn() - # print(self.Queue.queue) - - # UnPause The All Threads Created From Manager Object - def UnPauseThread(self): - for i in range(len(ActivatedThreads)): - if ActivatedThreads[i][1] == self.Name: - ActivatedThreads[i][0].PauseOff() - - # This Function Is Not Ready To Use !!! - def KillThread(self): - for i in range(len(ActivatedThreads)): - if 1 not in ActivatedThreads[i] and ActivatedThreads[i][1] == self.Name: - ActivatedThreads.remove(ActivatedThreads[i]) - Queue.put('Kill') - # print(f"{self.Name} Killed") - - def __repr__(self) -> str: - return str(self.Name) - - ''' - This Is Thread Class Rewrited, To Can Pause Them. - ''' - - class ThreadHandler(Thread): - def __init__(self, Target, Qqueue, *, Name='Handler'): - super().__init__() - self.Name = Name - self.Queue = Qqueue - self._target = Target - self._stoped = False - # print(self.Name, "Created") - - def run(self): - # Event.wait() - while not self.Queue.empty(): - SelectedThread = self.Queue.get() - # print(self.Name, "Pipeline To Handle:",SelectedThread) - if SelectedThread == 'Kill': - self.Queue.put(SelectedThread) - self._stoped = True - # self.Queue.pop(-1) - break - self._target(SelectedThread) - - def PauseOn(self): - self._stoped = False - - def PauseOff(self): - self._stoped = True - - def __repr__(self) -> str: - return str(self.Name) - - -def Pipeline(*funcs): - def Inner(argument): - state = argument - for func in funcs: - state = func(state) - return Inner + def __init__(self, ThreadName): + self.ThreadName = ThreadName + self.Thread = None + + def NewThread(self, fn): + global ActiveThreads + self.Thread = MyThread(fn) + target = self.Thread.start() + ActiveThreads[self.ThreadName] = self.Thread + + def StopThread(self): + ActiveThreads[self.ThreadName].stop() + ActiveThreads.pop(self.ThreadName) + + +class MyThread(threading.Thread): + def __init__(self, target): + super(MyThread, self).__init__(group=None, target=target, daemon=True) + self.target = target + self._stop = threading.Event() + + def stop(self): + self._stop.set() + + def stopped(self): + return self._stop.isSet() + + def run(self): + while True: + if self.stopped(): + return + self.target() diff --git a/engine/Scanners/ScanAmulet.py b/engine/Scanners/ScanAmulet.py new file mode 100644 index 0000000..fc114a9 --- /dev/null +++ b/engine/Scanners/ScanAmulet.py @@ -0,0 +1,16 @@ +from core.HookWindow import LocateCenterImage, LocateBoolRGBImage + + +def ScanAmulet(AmuletPositions, Amulet, Precision): + return not LocateBoolRGBImage('images/Amulets/' + Amulet + '.png', Precision=Precision, Region=( + AmuletPositions[0] - 1, AmuletPositions[1] - 1, AmuletPositions[2] + 1, AmuletPositions[3] + 1)) + + +def SearchForAmulet(Amulet): + FoundAmulet = [0, 0] + + FoundAmulet[0], FoundAmulet[1] = LocateCenterImage('images/Amulets/' + Amulet + '.png', Precision=0.9) + if FoundAmulet[0] != 0 and FoundAmulet[1] != 0: + return FoundAmulet[0], FoundAmulet[1] + else: + return 0, 0 diff --git a/engine/Scanners/ScanAutoExchangeGold.py b/engine/Scanners/ScanAutoExchangeGold.py new file mode 100644 index 0000000..8175d39 --- /dev/null +++ b/engine/Scanners/ScanAutoExchangeGold.py @@ -0,0 +1,37 @@ +import time + +from core.HookWindow import LocateImage + +CoinsImagePath = 'images/Items/Gold' + + +def ScanAutoExchangeGold(enabled_auto_exchange_gold, main_container_position, main_container_size, right_click): + while True: + ExchangePositions = [0, 0] + MainContainerRegion = main_container_position[0], main_container_position[1], main_container_position[ + 0] + main_container_size[0], main_container_position[1] + main_container_size[1] + + # look for platinum coins to exchange + ExchangePositions[0], ExchangePositions[1] = LocateImage( + f'{CoinsImagePath}/platinum.png', Precision=.92, Region=(MainContainerRegion)) + + # look for gold coins to exchange only if platinum coins were not found + if ExchangePositions[0] != 0 and ExchangePositions[1] != 0: + ExchangePositions[0], ExchangePositions[1] = LocateImage( + f'{CoinsImagePath}/gold.png', Precision=.9, Region=(MainContainerRegion)) + + if ExchangePositions[0] == 0 and ExchangePositions[1] == 0: + # break the loop if no exchangeable money found + break + else: + # else, exchange money + x = ( + main_container_position[0] + ExchangePositions[0]) + y = ( + main_container_position[1] + ExchangePositions[1]) + 24 + right_click(x, y) + + time.sleep(.3) + + if not enabled_auto_exchange_gold: + break diff --git a/engine/Scanners/ScanBars.py b/engine/Scanners/ScanBars.py new file mode 100644 index 0000000..a08a857 --- /dev/null +++ b/engine/Scanners/ScanBars.py @@ -0,0 +1,6 @@ +from conf.Constants import LifeColor, LifeColorFull, ManaColor, ManaColorFull +from engine.Scanners.ScanStages import ScanStages + + +def ScanBars(health_location, mana_location): + return (ScanStages('Life').ScanStages(health_location, LifeColor, LifeColorFull), ScanStages('Mana').ScanStages(mana_location, ManaColor, ManaColorFull)) diff --git a/engine/Scanners/ScanCap.py b/engine/Scanners/ScanCap.py new file mode 100644 index 0000000..9bf0940 --- /dev/null +++ b/engine/Scanners/ScanCap.py @@ -0,0 +1,10 @@ +import pyautogui + + +def ScanCap(NumberBox, EndNumberBox): + for i in range(9, -1, -1): + FirstNumber = pyautogui.locateOnScreen('images/PlayerStats/Numbers/' + str(i) + '.png', region=( + NumberBox[0], NumberBox[1], EndNumberBox[0], EndNumberBox[1]), + confidence=0.92) + if FirstNumber: + return int(i) diff --git a/engine/Scanners/ScanFood.py b/engine/Scanners/ScanFood.py new file mode 100644 index 0000000..a0ae7e4 --- /dev/null +++ b/engine/Scanners/ScanFood.py @@ -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 diff --git a/engine/Scanners/ScanHur.py b/engine/Scanners/ScanHur.py new file mode 100644 index 0000000..a79f3cf --- /dev/null +++ b/engine/Scanners/ScanHur.py @@ -0,0 +1,32 @@ +from core.HookWindow import LocateImage + + +def ScanHur(stats_position, check_pz, check_low_mana, current_mana, minimum_mana): + is_in_pz = False + is_low_mana = False + + stats_region = stats_position[0], stats_position[1], stats_position[2], stats_position[3] + hur_pos = [0, 0] + pz_pos = [0, 0] + + if (check_pz): + pz_pos[0], pz_pos[1] = LocateImage( + 'images/PlayerStats/PZ.png', Precision=0.9, Region=(stats_region) + ) + is_in_pz = pz_pos[0] != 0 and pz_pos[1] != 0 + + if is_in_pz: + return False + + if (check_low_mana): + is_low_mana = current_mana <= minimum_mana + + if is_low_mana: + return False + + hur_pos[0], hur_pos[1] = LocateImage( + 'images/PlayerStats/Hur.png', Precision=0.9, Region=(stats_region) + ) + HasHur = hur_pos[0] != 0 and hur_pos[1] != 0 + + return not HasHur diff --git a/engine/Scanners/ScanRing.py b/engine/Scanners/ScanRing.py new file mode 100644 index 0000000..9666d40 --- /dev/null +++ b/engine/Scanners/ScanRing.py @@ -0,0 +1,16 @@ +from core.HookWindow import LocateCenterImage, LocateBoolRGBImage + + +def ScanRing(RingPositions): + return LocateBoolRGBImage('images/PlayerStats/NoRing.png', Precision=0.9, Region=( + RingPositions[0], RingPositions[1], RingPositions[2], RingPositions[3])) + + +def SearchForRing(Ring): + FoundRing = [0, 0] + + FoundRing[0], FoundRing[1] = LocateCenterImage('images/Rings/' + Ring + '.png', Precision=0.9) + if FoundRing[0] != 0 and FoundRing[1] != 0: + return FoundRing[0], FoundRing[1] + else: + return 0, 0 diff --git a/engine/Scanners/ScanStages.py b/engine/Scanners/ScanStages.py new file mode 100644 index 0000000..e9e30c9 --- /dev/null +++ b/engine/Scanners/ScanStages.py @@ -0,0 +1,18 @@ +from core.HookWindow import PixelMatchesColor + + +class ScanStages: + def __init__(self, name): + self.stage = 0 + self.name = name + + def ScanStages(self, Localization, color, colorFull): + if PixelMatchesColor(Localization[0] + 100, Localization[1], + (colorFull[0], colorFull[1], colorFull[2])): + return 100 + + for i in range(95, 5, -5): + if PixelMatchesColor(Localization[0] + i, Localization[1], (color[0], color[1], color[2])): + return i + + return 0 diff --git a/engine/Toggler.py b/engine/Toggler.py new file mode 100644 index 0000000..fc6374b --- /dev/null +++ b/engine/Toggler.py @@ -0,0 +1,20 @@ +from tkinter import RAISED, SUNKEN + +from core.Defaults import rgb + + +def ToggleState(state, button, checking_buttons, start_thread_fn, stop_thread_fn): + if not state: + state = True + button.configure( + text='AutoHealing: ON', relief=SUNKEN, bg=rgb((158, 46, 34))) + print("AutoHealing: ON") + checking_buttons() + start_thread_fn() + else: + state = False + print("AutoHealing: OFF") + checking_buttons() + button.configure( + text='AutoHealing: OFF', relief=RAISED, bg=rgb((114, 0, 0))) + stop_thread_fn() diff --git a/images/BackgroundImages/Recapture.png b/images/BackgroundImages/Recapture.png index 3041e25..e64aaf1 100644 Binary files a/images/BackgroundImages/Recapture.png and b/images/BackgroundImages/Recapture.png differ diff --git a/images/Items/Gold/gold.png b/images/Items/Gold/gold.png new file mode 100644 index 0000000..4a51702 Binary files /dev/null and b/images/Items/Gold/gold.png differ diff --git a/images/Items/Gold/platinum.png b/images/Items/Gold/platinum.png new file mode 100644 index 0000000..a12c292 Binary files /dev/null and b/images/Items/Gold/platinum.png differ diff --git a/images/Modules/AutoExchangeGold.png b/images/Modules/AutoExchangeGold.png new file mode 100644 index 0000000..53cf3e6 Binary files /dev/null and b/images/Modules/AutoExchangeGold.png differ diff --git a/images/Modules/AutoHeal.png b/images/Modules/AutoHeal.png index d93412a..8f78bd5 100644 Binary files a/images/Modules/AutoHeal.png and b/images/Modules/AutoHeal.png differ diff --git a/images/Modules/AutoHeal2.png b/images/Modules/AutoHeal2.png index 4724641..efdbb8d 100644 Binary files a/images/Modules/AutoHeal2.png and b/images/Modules/AutoHeal2.png differ diff --git a/images/Modules/AutoHur.png b/images/Modules/AutoHur.png index a49a736..48d4c76 100644 Binary files a/images/Modules/AutoHur.png and b/images/Modules/AutoHur.png differ diff --git a/modules/AutoBanker.py b/modules/AutoBanker.py index 10ff484..349285a 100644 --- a/modules/AutoBanker.py +++ b/modules/AutoBanker.py @@ -1,10 +1,11 @@ import time -from engine.GUI import * -from engine.ScanCap import ScanCap +from core.GUI import * +from engine.Scanners.ScanCap import ScanCap EnabledAutoBanker = False + class AutoBanker: def __init__(self, root): self.AutoBanker = GUI('AutoBanker', 'Module: Auto Banker') @@ -22,19 +23,24 @@ def SetAutoBanker(): def ScanAutoBanker(): if EnabledAutoBanker: - CapLocate = pyautogui.locateOnScreen('images/PlayerStats/Cap.png') + CapLocate = pyautogui.locateOnScreen( + 'images/PlayerStats/Cap.png') if CapLocate: FirstNumberBox = CapLocate[0] + 21, CapLocate[1] + 7 - EndFirstNumberBox = FirstNumberBox[0] + 7, FirstNumberBox[1] + 10 + EndFirstNumberBox = FirstNumberBox[0] + \ + 7, FirstNumberBox[1] + 10 SecondNumberBox = CapLocate[0] + 15, CapLocate[1] + 7 - EndSecondNumberBox = SecondNumberBox[0] + 7, SecondNumberBox[1] + 10 + EndSecondNumberBox = SecondNumberBox[0] + \ + 7, SecondNumberBox[1] + 10 ThirdNumberBox = CapLocate[0] + 9, CapLocate[1] + 7 - EndThirdNumberBox = ThirdNumberBox[0] + 7, ThirdNumberBox[1] + 10 + EndThirdNumberBox = ThirdNumberBox[0] + \ + 7, ThirdNumberBox[1] + 10 FourNumberBox = CapLocate[0] + 3, CapLocate[1] + 7 - EndFourNumberBox = FourNumberBox[0] + 7, FourNumberBox[1] + 10 + EndFourNumberBox = FourNumberBox[0] + \ + 7, FourNumberBox[1] + 10 FirstNumber = ScanCap(FirstNumberBox, EndFirstNumberBox) SecondNumber = ScanCap(SecondNumberBox, EndSecondNumberBox) @@ -49,19 +55,21 @@ def ScanAutoBanker(): CheckPrint = tk.BooleanVar() LowMana = tk.BooleanVar() - self.AutoBanker.addButton('Ok', self.AutoBanker.destroyWindow, [84, 29, 130, 504], [127, 17, 8], [123, 13, 5]) + self.AutoBanker.addButton('Ok', self.AutoBanker.destroyWindow, [ + 84, 29, 130, 504], [127, 17, 8], [123, 13, 5]) global EnabledAutoBanker if not EnabledAutoBanker: ButtonEnabled = self.AutoBanker.addButton('AutoBanker: OFF', SetAutoBanker, [328, 29, 12, 469], - [127, 17, 8], [123, 13, 5]) + [127, 17, 8], [123, 13, 5]) else: ButtonEnabled = self.AutoBanker.addButton('AutoBanker: ON', SetAutoBanker, [328, 29, 12, 469], - [127, 17, 8], [123, 13, 5]) + [127, 17, 8], [123, 13, 5]) - ButtonPrint = self.AutoBanker.addCheck(CheckPrint, [10, 408], [120, 98, 51], 0, "Print on Tibia's screen") + ButtonPrint = self.AutoBanker.addCheck( + CheckPrint, [10, 408], [120, 98, 51], 0, "Print on Tibia's screen") - ButtonLowMana = self.AutoBanker.addCheck(LowMana, [10, 440], [120, 98, 51], 0, "Low Mana Warnings") + ButtonLowMana = self.AutoBanker.addCheck( + LowMana, [10, 440], [120, 98, 51], 0, "Low Mana Warnings") self.AutoBanker.loop() - diff --git a/modules/AutoExchangeGold.py b/modules/AutoExchangeGold.py new file mode 100644 index 0000000..3c5470f --- /dev/null +++ b/modules/AutoExchangeGold.py @@ -0,0 +1,255 @@ +import time +import json + +from tkinter.constants import RAISED, SUNKEN +from conf.Constants import Containers + +from conf.Hotkeys import Hotkey +from conf.conf_manager import ConfManager + +from core.GUI import * +from core.GUIManager import * +from core.GUISetter import GUISetter +from core.Getters import GetMainContainerPosition +from core.ThreadManager import ThreadManager +from engine.Scanners.ScanAutoExchangeGold import ScanAutoExchangeGold + +ContainersPath = 'images/Items/None/Containers' + +EnabledAutoExchangeGold = False +NewMainContainerPosition = [0, 0, 0, 0] +BackpackImg = None +BagImg = None +BasketImg = None +BeachBackpackImg = None +BlueBackpackImg = None +BrocadeBagImg = None +BuggyBackpackImg = None +CamouflageBackpackImg = None +CrownBackpackImg = None +DeeplingBackpackImg = None +DemonBackpackImg = None +DragonBackpackImg = None +ExpeditionBackpackImg = None +FurBackpackImg = None +FurBagImg = None +GloothBackpackImg = None +GoldenBackpackImg = None +GreenBackpackImg = None +GreenBagImg = None +GreyBackpackImg = None +JewelledBackpackImg = None +MinotaurBackpackImg = None +OrangeBackpackImg = None +PirateBackpackImg = None +PirateBagImg = None +PresentImg = None +PurpleBackpackImg = None +RedBackpackImg = None +RedBagImg = None +ShoppingBagImg = None +StampedParcelImg = None +YellowBackpackImg = None + +GUIChanges = [] + + +class AutoExchangeGold: + def __init__(self, ContainerLocation, MOUSE_OPTION): + self.AutoExchangeGold = GUI( + 'AutoExchangeGold', 'Module: Auto Exchange Gold') + self.AutoExchangeGold.DefaultWindow( + 'AutoExchangeGold', [186, 252], [1.4, 2.29]) + self.Setter = GUISetter("ExchangeGoldLoader") + self.ThreadManager = ThreadManager("ThreadAutoExchangeGold") + self.SendToClient = Hotkey(MOUSE_OPTION) + self.Conf = ConfManager.get('conf.json') + preferences_path = self.Conf['preferences_name'] + preferences = ConfManager.get(preferences_path) + + _container_found = ContainerLocation[0] != 0 and ContainerLocation[1] != 0 + _container_set = not preferences['Boxes']['MainContainerBox'][0]['Stats'] + + NewMainContainerPosition = [ContainerLocation[0], ContainerLocation[1], preferences['Boxes'] + ['MainContainerBox'][0]['w'], preferences['Boxes']['MainContainerBox'][0]['h']] + + global BackpackImg, BagImg, BasketImg, BeachBackpackImg, BlueBackpackImg, BrocadeBagImg, BuggyBackpackImg, CamouflageBackpackImg, CrownBackpackImg, DeeplingBackpackImg, DemonBackpackImg, DragonBackpackImg, ExpeditionBackpackImg, FurBackpackImg, FurBagImg, GloothBackpackImg, GoldenBackpackImg, GreenBackpackImg, GreenBagImg, GreyBackpackImg, JewelledBackpackImg, MinotaurBackpackImg, OrangeBackpackImg, PirateBackpackImg, PirateBagImg, PresentImg, PurpleBackpackImg, RedBackpackImg, RedBagImg, ShoppingBagImg, StampedParcelImg, YellowBackpackImg + + BackpackImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/Backpack.png', [64, 64]) + BagImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/Bag.png', [64, 64]) + BasketImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/Basket.png', [64, 64]) + BeachBackpackImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/BeachBackpack.png', [64, 64]) + BlueBackpackImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/BlueBackpack.png', [64, 64]) + BrocadeBagImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/BrocadeBag.png', [64, 64]) + BuggyBackpackImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/BuggyBackpack.png', [64, 64]) + CamouflageBackpackImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/CamouflageBackpack.png', [64, 64]) + CrownBackpackImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/CrownBackpack.png', [64, 64]) + DeeplingBackpackImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/DeeplingBackpack.png', [64, 64]) + DemonBackpackImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/DemonBackpack.png', [64, 64]) + DragonBackpackImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/DragonBackpack.png', [64, 64]) + ExpeditionBackpackImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/ExpeditionBackpack.png', [64, 64]) + FurBackpackImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/FurBackpack.png', [64, 64]) + FurBagImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/FurBag.png', [64, 64]) + GloothBackpackImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/GloothBackpack.png', [64, 64]) + GoldenBackpackImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/GoldenBackpack.png', [64, 64]) + GreenBackpackImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/GreenBackpack.png', [64, 64]) + GreenBagImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/GreenBag.png', [64, 64]) + GreyBackpackImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/GreyBackpack.png', [64, 64]) + JewelledBackpackImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/JewelledBackpack.png', [64, 64]) + MinotaurBackpackImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/MinotaurBackpack.png', [64, 64]) + OrangeBackpackImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/OrangeBackpack.png', [64, 64]) + PirateBackpackImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/PirateBackpack.png', [64, 64]) + PirateBagImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/PirateBag.png', [64, 64]) + PresentImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/Present.png', [64, 64]) + PurpleBackpackImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/PurpleBackpack.png', [64, 64]) + RedBackpackImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/RedBackpack.png', [64, 64]) + RedBagImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/RedBag.png', [64, 64]) + ShoppingBagImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/ShoppingBag.png', [64, 64]) + StampedParcelImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/StampedParcel.png', [64, 64]) + YellowBackpackImg = self.AutoExchangeGold.openImage( + f'{ContainersPath}/YellowBackpack.png', [64, 64]) + + def SetPreferencesMainContainer(name): + BackpackVarName = f'{name}Img' + LabelImage.configure(image=globals()[BackpackVarName]) + + NewMainContainerPosition[0], NewMainContainerPosition[1] = GetMainContainerPosition( + name) + time.sleep(.2) + + preferences['Boxes']['MainContainerBox'][0]['x'] = int( + NewMainContainerPosition[0]) + preferences['Boxes']['MainContainerBox'][0]['y'] = int( + NewMainContainerPosition[1]) + preferences['Boxes']['MainContainerBox'][0]['Stats'] = True + + with open(f'scripts/{preferences_path}', 'w') as wJson: + json.dump(preferences, wJson, indent=4) + + if NewMainContainerPosition[0] != 0 and NewMainContainerPosition[1] != 0: + LabelImage.configure(bg='green') + ButtonEnabled.config(state='active') + return True + + LabelImage.configure(bg='red') + ButtonEnabled.config(state='disabled') + return False + + def ToggleState(): + global EnabledAutoExchangeGold + if not EnabledAutoExchangeGold: + EnabledAutoExchangeGold = True + CheckingButtons() + self.ThreadManager.NewThread(Scan) + ButtonEnabled.configure( + text='Auto Gold: ON', relief=SUNKEN, bg=rgb((158, 46, 34))) + print("AutoExchangeGold: ON") + else: + EnabledAutoExchangeGold = False + CheckingButtons() + self.ThreadManager.StopThread() + ButtonEnabled.configure( + text='Auto Gold: OFF', relief=RAISED, bg=rgb((127, 17, 8))) + print("AutoExchangeGold: OFF") + + def Scan(): + while EnabledAutoExchangeGold: + ScanAutoExchangeGold(EnabledAutoExchangeGold, (NewMainContainerPosition[0], NewMainContainerPosition[1]), ( + NewMainContainerPosition[2], NewMainContainerPosition[3]), self.SendToClient.RawRightClick) + + time.sleep(2) + + def CheckingGUI(Init, Get, Name): + if Get != Init: + GUIChanges.append((Name, Get)) + + def Destroy(): + CheckingGUI(InitiatedMainContainerName, + MainContainerName.get(), 'MainContainerName') + + if len(GUIChanges) != 0: + for EachChange in range(len(GUIChanges)): + self.Setter.SetVariables.SetVar( + GUIChanges[EachChange][0], GUIChanges[EachChange][1]) + + self.AutoExchangeGold.destroyWindow() + + self.AutoExchangeGold.addButton('OK', Destroy, [73, 21], [60, 227]) + + MainContainerName, InitiatedMainContainerName = self.Setter.Variables.Str( + 'MainContainerName' + ) + + global EnabledAutoExchangeGold + if not EnabledAutoExchangeGold: + ButtonEnabled = self.AutoExchangeGold.addButton( + 'Auto Gold: OFF', ToggleState, [108, 24], [44, 199]) + else: + ButtonEnabled = self.AutoExchangeGold.addButton( + 'Auto Gold: ON', ToggleState, [108, 24], [44, 199]) + ButtonEnabled.configure(relief=SUNKEN, bg=rgb((158, 46, 34))) + ButtonEnabled.config( + state='active' if _container_found else 'disabled') + + ImgContainer = f"{ContainersPath}/{MainContainerName.get() if MainContainerName.get() else 'Bag'}.png" + ImageID = self.AutoExchangeGold.openImage(ImgContainer, [64, 64]) + + ImgLabel = self.AutoExchangeGold.addLabel( + 'Current container', [44, 20]) + LabelImage = self.AutoExchangeGold.addImage(ImageID, [60, 45]) + LabelImage.configure( + borderwidth=2, bg='green' if _container_found else 'yellow' if _container_set else 'red') + SelectedContainerName = self.AutoExchangeGold.addOption( + MainContainerName, Containers, [20, 122], width=18, command=SetPreferencesMainContainer) + SearchContainerButton = self.AutoExchangeGold.addButton( + 'Search Container', lambda: SetPreferencesMainContainer(MainContainerName.get()), [126, 24], [32, 156]) + + def CheckingButtons(): + if EnabledAutoExchangeGold: + Disable(LabelImage) + Disable(ImgLabel) + Disable(SelectedContainerName) + Disable(SearchContainerButton) + else: + Enable(LabelImage) + Enable(ImgLabel) + Enable(SelectedContainerName) + Enable(SearchContainerButton) + + ExecGUITrigger() + + CheckingButtons() + + self.AutoExchangeGold.Protocol(Destroy) + self.AutoExchangeGold.loop() diff --git a/modules/AutoHeal.py b/modules/AutoHeal.py index 0b4c613..9c1ea5c 100644 --- a/modules/AutoHeal.py +++ b/modules/AutoHeal.py @@ -1,159 +1,179 @@ -import time +from multiprocessing import Process +from time import sleep +from tkinter.constants import RAISED, SUNKEN from conf.Hotkeys import Hotkey -from conf.Constants import LifeColor, LifeColorFull, Percentage, ImageStats, Stats +from conf.Constants import LifeColor, LifeColorFull, ManaColor, ManaColorFull, HealingType, Percentage, ImageStats, Stats + from core.GUI import * from core.GUIManager import * from core.GUISetter import GUISetter from core.ThreadManager import ThreadManager -from engine.ScanStages import ScanStages - EnabledAutoHeal = False ThreadStarted = False +Stages = [] GUIChanges = [] -Life = 0 - class AutoHeal: - def __init__(self, HealthLocation, MOUSE_OPTION): + def __init__(self, SetScanningHPMP, MOUSE_OPTION): self.AutoHeal = GUI('AutoHeal', 'Module: Auto Heal') - self.AutoHeal.DefaultWindow('AutoHeal2', [306, 372], [1.2, 2.29]) - self.Setter = GUISetter("HealthLoader") + self.AutoHeal.DefaultWindow('AutoHeal2', [446, 509], [1.2, 2.29]) + self.Setter = GUISetter("HealLoader") self.SendToClient = Hotkey(MOUSE_OPTION) - self.Scan = ScanStages('Life') self.ThreadManager = ThreadManager("ThreadAutoHeal") - def SetAutoHeal(): + def ToggleState(): global EnabledAutoHeal if not EnabledAutoHeal: EnabledAutoHeal = True - ButtonEnabled.configure(text='AutoHealing: ON', relief=SUNKEN, bg=rgb((158, 46, 34))) + ButtonEnabled.configure( + text='AutoHealing: ON', relief=SUNKEN, bg=rgb((158, 46, 34))) print("AutoHealing: ON") CheckingButtons() - if not ThreadStarted: - self.ThreadManager.NewThread(scanning_auto_life) - else: - self.ThreadManager.UnPauseThread() + SetScanningHPMP('AutoHeal', 'on') + self.ThreadManager.NewThread(Scan) else: EnabledAutoHeal = False print("AutoHealing: OFF") CheckingButtons() - ButtonEnabled.configure(text='AutoHealing: OFF', relief=RAISED, bg=rgb((114, 0, 0))) - self.ThreadManager.PauseThread() + ButtonEnabled.configure( + text='AutoHealing: OFF', relief=RAISED, bg=rgb((114, 0, 0))) + SetScanningHPMP('AutoHeal', 'off') + self.ThreadManager.StopThread() - def scanning_auto_life(): + def Scan(): while EnabledAutoHeal: - global Life - Life = self.Scan.ScanStages(HealthLocation, LifeColor, LifeColorFull) - - if Life is None: - Life = 0 - - if LifeCheckStageThree.get(): - stage_three = LifePercentageStageThree.get() - if stage_three > Life or stage_three == Life: - self.SendToClient.Press(LifeHotkeyStageThree.get()) - print("Pressed ", LifeHotkeyStageThree.get()) - time.sleep(.15) - elif LifeCheckStageTwo.get(): - stage_two = LifePercentageStageTwo.get() - if stage_two > Life or stage_two == Life: - self.SendToClient.Press(LifeHotkeyStageTwo.get()) - print("Pressed ", LifeHotkeyStageTwo.get()) - time.sleep(.15) - elif LifeCheckStageOne.get(): - stage_one = LifePercentageStageOne.get() - if stage_one > Life or stage_one == Life: - self.SendToClient.Press(LifeHotkeyStageOne.get()) - print("Pressed ", LifeHotkeyStageOne.get()) - time.sleep(.15) - elif LifeCheckStageOne.get(): - stage_one = LifePercentageStageOne.get() - if stage_one > Life or stage_one == Life: - self.SendToClient.Press(LifeHotkeyStageOne.get()) - print("Pressed ", LifeHotkeyStageOne.get()) - time.sleep(.15) - elif LifeCheckStageTwo.get(): - stage_two = LifePercentageStageTwo.get() - if stage_two > Life or stage_two == Life: - self.SendToClient.Press(LifeHotkeyStageTwo.get()) - print("Pressed ", LifeHotkeyStageTwo.get()) - time.sleep(.15) - elif LifeCheckStageThree.get(): - stage_three = LifePercentageStageThree.get() - if stage_three > Life or stage_three == Life: - self.SendToClient.Press(LifeHotkeyStageThree.get()) - print("Pressed ", LifeHotkeyStageThree.get()) - time.sleep(.15) - elif LifeCheckStageOne.get(): - stage_one = LifePercentageStageOne.get() - if stage_one > Life or stage_one == Life: - self.SendToClient.Press(LifeHotkeyStageOne.get()) - print("Pressed ", LifeHotkeyStageOne.get()) - time.sleep(.15) - elif LifeCheckStageOne.get(): - stage_one = LifePercentageStageOne.get() - if stage_one > Life or stage_one == Life: - self.SendToClient.Press(LifeHotkeyStageOne.get()) - print("Pressed ", LifeHotkeyStageOne.get()) - time.sleep(.15) - elif LifeCheckStageOne.get(): - stage_one = LifePercentageStageOne.get() - if stage_one > Life or stage_one == Life: - self.SendToClient.Press(LifeHotkeyStageOne.get()) - print("Pressed ", LifeHotkeyStageOne.get()) - time.sleep(.15) - elif LifeCheckStageTwo.get(): - stage_two = LifePercentageStageTwo.get() - if stage_two > Life or stage_two == Life: - self.SendToClient.Press(LifeHotkeyStageTwo.get()) - print("Pressed ", LifeHotkeyStageTwo.get()) - time.sleep(.15) - elif LifeCheckStageThree.get(): - stage_three = LifePercentageStageThree.get() - if stage_three > Life or stage_three == Life: - self.SendToClient.Press(LifeHotkeyStageThree.get()) - print("Pressed ", LifeHotkeyStageThree.get()) - time.sleep(.15) - elif LifeCheckStageThree.get(): - stage_three = LifePercentageStageThree.get() - if stage_three > Life or stage_three == Life: - self.SendToClient.Press(LifeHotkeyStageThree.get()) - print("Pressed ", LifeHotkeyStageThree.get()) - time.sleep(.15) - else: - print("Module Not Configured") - time.sleep(1) - - VarCheckPrint, InitiatedCheckPrint = self.Setter.Variables.Bool('CheckPrint') - VarCheckBuff, InitiatedCheckBuff = self.Setter.Variables.Bool('CheckBuff') - - LifeCheckStageOne, InitiatedLifeCheckStageOne = self.Setter.Variables.Bool('LifeCheckStageOne') - LifeCheckStageTwo, InitiatedLifeCheckStageTwo = self.Setter.Variables.Bool('LifeCheckStageTwo') - LifeCheckStageThree, InitiatedLifeCheckStageThree = self.Setter.Variables.Bool('LifeCheckStageThree') - - VarCheckCureStats, InitiatedCheckCureStats = self.Setter.Variables.Bool('CheckCureStats') - - VarCheckParalyze, InitiatedCheckParalyze = self.Setter.Variables.Bool('CheckParalyze') - VarCheckPoison, InitiatedCheckPoison = self.Setter.Variables.Bool('CheckPoison') - VarCheckFire, InitiatedCheckFire = self.Setter.Variables.Bool('CheckFire') - VarCheckElectrify, InitiatedCheckElectrify = self.Setter.Variables.Bool('CheckElectrify') - VarCheckMort, InitiatedCheckMort = self.Setter.Variables.Bool('CheckMort') - VarCheckBlood, InitiatedCheckBlood = self.Setter.Variables.Bool('CheckBlood') - - LifePercentageStageOne, InitiatedLifePercentageStageOne = self.Setter.Variables.Int('LifePercentageStageOne') - LifeHotkeyStageOne, InitiatedLifeHotkeyStageOne = self.Setter.Variables.Str('LifeHotkeyStageOne') - - LifePercentageStageTwo, InitiatedLifePercentageStageTwo = self.Setter.Variables.Int('LifePercentageStageTwo') - LifeHotkeyStageTwo, InitiatedLifeHotkeyStageTwo = self.Setter.Variables.Str('LifeHotkeyStageTwo') - - LifePercentageStageThree, InitiatedLifePercentageStageThree = self.Setter.Variables.Int('LifePercentageStageThree') - LifeHotkeyStageThree, InitiatedLifeHotkeyStageThree = self.Setter.Variables.Str('LifeHotkeyStageThree') + from modules.Root import Life, Mana + for StageChecked, StagePercentage, StageType, StageHotkey in Stages: + if StageChecked.get() and StagePercentage.get() >= locals()[StageType.get()]: + self.SendToClient.Press(StageHotkey.get()) + print( + f'{StageType.get()} is less than {StagePercentage.get()}.') + print(f"Pressed {StageHotkey.get()}") + sleep(.7) + break + + VarCheckPrint, InitiatedCheckPrint = self.Setter.Variables.Bool( + 'CheckPrint') + VarCheckBuff, InitiatedCheckBuff = self.Setter.Variables.Bool( + 'CheckBuff') + + LifeCheckStageOne, InitiatedLifeCheckStageOne = self.Setter.Variables.Bool( + 'LifeCheckStageOne') + LifeCheckStageTwo, InitiatedLifeCheckStageTwo = self.Setter.Variables.Bool( + 'LifeCheckStageTwo') + LifeCheckStageThree, InitiatedLifeCheckStageThree = self.Setter.Variables.Bool( + 'LifeCheckStageThree') + LifeCheckStageFour, InitiatedLifeCheckStageFour = self.Setter.Variables.Bool( + 'LifeCheckStageFour') + LifeCheckStageFive, InitiatedLifeCheckStageFive = self.Setter.Variables.Bool( + 'LifeCheckStageFive') + LifeCheckStageSix, InitiatedLifeCheckStageSix = self.Setter.Variables.Bool( + 'LifeCheckStageSix') + + VarCheckCureStats, InitiatedCheckCureStats = self.Setter.Variables.Bool( + 'CheckCureStats') + + VarCheckParalyze, InitiatedCheckParalyze = self.Setter.Variables.Bool( + 'CheckParalyze') + VarCheckPoison, InitiatedCheckPoison = self.Setter.Variables.Bool( + 'CheckPoison') + VarCheckFire, InitiatedCheckFire = self.Setter.Variables.Bool( + 'CheckFire') + VarCheckElectrify, InitiatedCheckElectrify = self.Setter.Variables.Bool( + 'CheckElectrify') + VarCheckMort, InitiatedCheckMort = self.Setter.Variables.Bool( + 'CheckMort') + VarCheckBlood, InitiatedCheckBlood = self.Setter.Variables.Bool( + 'CheckBlood') + + LifePercentageStageOne, InitiatedLifePercentageStageOne = self.Setter.Variables.Int( + 'LifePercentageStageOne') + LifeHotkeyStageOne, InitiatedLifeHotkeyStageOne = self.Setter.Variables.Str( + 'LifeHotkeyStageOne') + TypeStageOne, InitiatedTypeStageOne = self.Setter.Variables.Str( + 'TypeStageOne') + + LifePercentageStageTwo, InitiatedLifePercentageStageTwo = self.Setter.Variables.Int( + 'LifePercentageStageTwo') + LifeHotkeyStageTwo, InitiatedLifeHotkeyStageTwo = self.Setter.Variables.Str( + 'LifeHotkeyStageTwo') + TypeStageTwo, InitiatedTypeStageTwo = self.Setter.Variables.Str( + 'TypeStageTwo') + + LifePercentageStageThree, InitiatedLifePercentageStageThree = self.Setter.Variables.Int( + 'LifePercentageStageThree') + LifeHotkeyStageThree, InitiatedLifeHotkeyStageThree = self.Setter.Variables.Str( + 'LifeHotkeyStageThree') + TypeStageThree, InitiatedTypeStageThree = self.Setter.Variables.Str( + 'TypeStageThree') + + LifePercentageStageFour, InitiatedLifePercentageStageFour = self.Setter.Variables.Int( + 'LifePercentageStageFour') + LifeHotkeyStageFour, InitiatedLifeHotkeyStageFour = self.Setter.Variables.Str( + 'LifeHotkeyStageFour') + TypeStageFour, InitiatedTypeStageFour = self.Setter.Variables.Str( + 'TypeStageFour') + + LifePercentageStageFive, InitiatedLifePercentageStageFive = self.Setter.Variables.Int( + 'LifePercentageStageFive') + LifeHotkeyStageFive, InitiatedLifeHotkeyStageFive = self.Setter.Variables.Str( + 'LifeHotkeyStageFive') + TypeStageFive, InitiatedTypeStageFive = self.Setter.Variables.Str( + 'TypeStageFive') + + LifePercentageStageSix, InitiatedLifePercentageStageSix = self.Setter.Variables.Int( + 'LifePercentageStageSix') + LifeHotkeyStageSix, InitiatedLifeHotkeyStageSix = self.Setter.Variables.Str( + 'LifeHotkeyStageSix') + TypeStageSix, InitiatedTypeStageSix = self.Setter.Variables.Str( + 'TypeStageSix') + + global Stages + Stages = [ + ( + LifeCheckStageOne, + LifePercentageStageOne, + TypeStageOne, + LifeHotkeyStageOne + ), + ( + LifeCheckStageTwo, + LifePercentageStageTwo, + TypeStageTwo, + LifeHotkeyStageTwo + ), + ( + LifeCheckStageThree, + LifePercentageStageThree, + TypeStageThree, + LifeHotkeyStageThree + ), + ( + LifeCheckStageFour, + LifePercentageStageFour, + TypeStageFour, + LifeHotkeyStageFour + ), + ( + LifeCheckStageFive, + LifePercentageStageFive, + TypeStageFive, + LifeHotkeyStageFive + ), + ( + LifeCheckStageSix, + LifePercentageStageSix, + TypeStageSix, + LifeHotkeyStageSix + ), + + ] for i in range(len(Stats)): ImageStatus = Image.open('images/Stats/' + Stats[i] + '.webp') @@ -168,83 +188,199 @@ def CheckingGUI(Init, Get, Name): def Destroy(): CheckingGUI(InitiatedCheckPrint, VarCheckPrint.get(), 'CheckPrint') CheckingGUI(InitiatedCheckBuff, VarCheckBuff.get(), 'CheckBuff') - CheckingGUI(InitiatedLifeCheckStageOne, LifeCheckStageOne.get(), 'LifeCheckStageOne') - CheckingGUI(InitiatedLifeCheckStageTwo, LifeCheckStageTwo.get(), 'LifeCheckStageTwo') - CheckingGUI(InitiatedLifeCheckStageThree, LifeCheckStageThree.get(), 'LifeCheckStageThree') - CheckingGUI(InitiatedCheckCureStats, VarCheckCureStats.get(), 'CheckCureStats') - CheckingGUI(InitiatedCheckParalyze, VarCheckParalyze.get(), 'CheckParalyze') - CheckingGUI(InitiatedCheckPoison, VarCheckPoison.get(), 'CheckPoison') + CheckingGUI(InitiatedLifeCheckStageOne, + LifeCheckStageOne.get(), 'LifeCheckStageOne') + CheckingGUI(InitiatedLifeCheckStageTwo, + LifeCheckStageTwo.get(), 'LifeCheckStageTwo') + CheckingGUI(InitiatedLifeCheckStageThree, + LifeCheckStageThree.get(), 'LifeCheckStageThree') + CheckingGUI(InitiatedLifeCheckStageFour, + LifeCheckStageFour.get(), 'LifeCheckStageFour') + CheckingGUI(InitiatedLifeCheckStageFive, + LifeCheckStageFive.get(), 'LifeCheckStageFive') + CheckingGUI(InitiatedLifeCheckStageSix, + LifeCheckStageSix.get(), 'LifeCheckStageSix') + CheckingGUI(InitiatedCheckCureStats, + VarCheckCureStats.get(), 'CheckCureStats') + CheckingGUI(InitiatedCheckParalyze, + VarCheckParalyze.get(), 'CheckParalyze') + CheckingGUI(InitiatedCheckPoison, + VarCheckPoison.get(), 'CheckPoison') CheckingGUI(InitiatedCheckFire, VarCheckFire.get(), 'CheckFire') - CheckingGUI(InitiatedCheckElectrify, VarCheckElectrify.get(), 'CheckElectrify') + CheckingGUI(InitiatedCheckElectrify, + VarCheckElectrify.get(), 'CheckElectrify') CheckingGUI(InitiatedCheckMort, VarCheckMort.get(), 'CheckMort') CheckingGUI(InitiatedCheckBlood, VarCheckBlood.get(), 'CheckBlood') - CheckingGUI(InitiatedLifePercentageStageOne, LifePercentageStageOne.get(), 'LifePercentageStageOne') - CheckingGUI(InitiatedLifeHotkeyStageOne, LifeHotkeyStageOne.get(), 'LifeHotkeyStageOne') - CheckingGUI(InitiatedLifePercentageStageTwo, LifePercentageStageTwo.get(), 'LifePercentageStageTwo') - CheckingGUI(InitiatedLifeHotkeyStageTwo, LifeHotkeyStageTwo.get(), 'LifeHotkeyStageTwo') - CheckingGUI(InitiatedLifePercentageStageThree, LifePercentageStageThree.get(), 'LifePercentageStageThree') - CheckingGUI(InitiatedLifeHotkeyStageThree, LifeHotkeyStageThree.get(), 'LifeHotkeyStageThree') + CheckingGUI(InitiatedLifePercentageStageOne, + LifePercentageStageOne.get(), 'LifePercentageStageOne') + CheckingGUI(InitiatedLifeHotkeyStageOne, + LifeHotkeyStageOne.get(), 'LifeHotkeyStageOne') + CheckingGUI(InitiatedTypeStageOne, + TypeStageOne.get(), 'TypeStageOne') + CheckingGUI(InitiatedLifePercentageStageTwo, + LifePercentageStageTwo.get(), 'LifePercentageStageTwo') + CheckingGUI(InitiatedLifeHotkeyStageTwo, + LifeHotkeyStageTwo.get(), 'LifeHotkeyStageTwo') + CheckingGUI(InitiatedTypeStageTwo, + TypeStageTwo.get(), 'TypeStageTwo') + CheckingGUI(InitiatedLifePercentageStageThree, + LifePercentageStageThree.get(), 'LifePercentageStageThree') + CheckingGUI(InitiatedLifeHotkeyStageThree, + LifeHotkeyStageThree.get(), 'LifeHotkeyStageThree') + CheckingGUI(InitiatedTypeStageThree, + TypeStageThree.get(), 'TypeStageThree') + CheckingGUI(InitiatedLifePercentageStageFour, + LifePercentageStageFour.get(), 'LifePercentageStageFour') + CheckingGUI(InitiatedLifeHotkeyStageFour, + LifeHotkeyStageFour.get(), 'LifeHotkeyStageFour') + CheckingGUI(InitiatedTypeStageFour, + TypeStageFour.get(), 'TypeStageFour') + CheckingGUI(InitiatedLifePercentageStageFive, + LifePercentageStageFive.get(), 'LifePercentageStageFive') + CheckingGUI(InitiatedLifeHotkeyStageFive, + LifeHotkeyStageFive.get(), 'LifeHotkeyStageFive') + CheckingGUI(InitiatedTypeStageFive, + TypeStageFive.get(), 'TypeStageFive') + CheckingGUI(InitiatedLifePercentageStageSix, + LifePercentageStageSix.get(), 'LifePercentageStageSix') + CheckingGUI(InitiatedLifeHotkeyStageSix, + LifeHotkeyStageSix.get(), 'LifeHotkeyStageSix') + CheckingGUI(InitiatedTypeStageSix, + TypeStageSix.get(), 'TypeStageSix') if len(GUIChanges) != 0: for EachChange in range(len(GUIChanges)): - self.Setter.SetVariables.SetVar(GUIChanges[EachChange][0], GUIChanges[EachChange][1]) + self.Setter.SetVariables.SetVar( + GUIChanges[EachChange][0], GUIChanges[EachChange][1]) self.AutoHeal.destroyWindow() - self.AutoHeal.addButton('Ok', Destroy, [73, 21], [115, 340]) + self.AutoHeal.addButton('OK', Destroy, [75, 23], [196, 480]) - ''' button enable healing ''' + ''' Button enable auto healing ''' global EnabledAutoHeal if not EnabledAutoHeal: - ButtonEnabled = self.AutoHeal.addButton('AutoHealing: OFF', SetAutoHeal, [287, 23], [11, 311]) + ButtonEnabled = self.AutoHeal.addButton( + 'AutoHealing: OFF', ToggleState, [287, 23], [91, 452]) else: - ButtonEnabled = self.AutoHeal.addButton('AutoHealing: ON', SetAutoHeal, [287, 23], [11, 311]) + ButtonEnabled = self.AutoHeal.addButton( + 'AutoHealing: ON', ToggleState, [287, 23], [91, 452]) ButtonEnabled.configure(relief=SUNKEN, bg=rgb((158, 46, 34))) - CheckPrint = self.AutoHeal.addCheck(VarCheckPrint, [11, 260], InitiatedCheckPrint, "Print on Tibia's screen") - CheckPrint.configure(bg=rgb((114, 94, 48)), activebackground=rgb((114, 94, 48)), selectcolor=rgb((114, 94, 48))) - CheckBuff = self.AutoHeal.addCheck(VarCheckBuff, [11, 280], InitiatedCheckBuff, "Don't Buff") - CheckBuff.configure(bg=rgb((114, 94, 48)), activebackground=rgb((114, 94, 48)), selectcolor=rgb((114, 94, 48))) - - LabelPercentage = self.AutoHeal.addLabel('% Percentage', [145, 24]) - LabelHotkey = self.AutoHeal.addLabel('HotKey', [230, 24]) - - StageOne = self.AutoHeal.addCheck(LifeCheckStageOne, [17, 55], InitiatedLifeCheckStageOne, "Enable Stage One") - StageTwo = self.AutoHeal.addCheck(LifeCheckStageTwo, [17, 105], InitiatedLifeCheckStageTwo, "Enable Stage Two") - StageThree = self.AutoHeal.addCheck(LifeCheckStageThree, [17, 155], InitiatedLifeCheckStageThree, "Enable Stage Three") - CheckStats = self.AutoHeal.addCheck(VarCheckCureStats, [95, 192], InitiatedCheckCureStats, "Enable Cure Stats") - - Paralyze = self.AutoHeal.addCheck(VarCheckParalyze, [40, 226], InitiatedCheckParalyze, '', ImageStats[0]) - Poison = self.AutoHeal.addCheck(VarCheckPoison, [80, 226], InitiatedCheckPoison, '', ImageStats[1]) - Fire = self.AutoHeal.addCheck(VarCheckFire, [120, 226], InitiatedCheckFire, '', ImageStats[2]) - Electrify = self.AutoHeal.addCheck(VarCheckElectrify, [160, 226], InitiatedCheckElectrify, '', ImageStats[3]) - Mort = self.AutoHeal.addCheck(VarCheckMort, [200, 226], InitiatedCheckMort, '', ImageStats[4]) - Blood = self.AutoHeal.addCheck(VarCheckBlood, [240, 226], InitiatedCheckBlood, '', ImageStats[5]) - - PercentageStageOne = self.AutoHeal.addOption(LifePercentageStageOne, Percentage, [148, 54]) - HotkeyStageOne = self.AutoHeal.addOption(LifeHotkeyStageOne, self.SendToClient.Hotkeys, [223, 54]) - - PercentageStageTwo = self.AutoHeal.addOption(LifePercentageStageTwo, Percentage, [148, 104]) - HotkeyStageTwo = self.AutoHeal.addOption(LifeHotkeyStageTwo, self.SendToClient.Hotkeys, [223, 104]) - - PercentageStageThree = self.AutoHeal.addOption(LifePercentageStageThree, Percentage, [148, 154]) - HotkeyStageThree = self.AutoHeal.addOption(LifeHotkeyStageThree, self.SendToClient.Hotkeys, [223, 154]) + CheckPrint = self.AutoHeal.addCheck( + VarCheckPrint, [11, 402], InitiatedCheckPrint, "Print on Tibia's screen") + CheckPrint.configure(bg=rgb((114, 94, 48)), activebackground=rgb( + (114, 94, 48)), selectcolor=rgb((114, 94, 48))) + CheckBuff = self.AutoHeal.addCheck( + VarCheckBuff, [11, 422], InitiatedCheckBuff, "Don't Buff") + CheckBuff.configure(bg=rgb((114, 94, 48)), activebackground=rgb( + (114, 94, 48)), selectcolor=rgb((114, 94, 48))) + + LabelType = self.AutoHeal.addLabel('Type', [144, 24]) + LabelPercentage = self.AutoHeal.addLabel('% Perc.', [228, 24]) + LabelHotkey = self.AutoHeal.addLabel('Hotkey', [312, 24]) + + StageOne = self.AutoHeal.addCheck( + LifeCheckStageOne, [17, 55], InitiatedLifeCheckStageOne, "Enable Stage One") + StageTwo = self.AutoHeal.addCheck( + LifeCheckStageTwo, [17, 105], InitiatedLifeCheckStageTwo, "Enable Stage Two") + StageThree = self.AutoHeal.addCheck(LifeCheckStageThree, [ + 17, 155], InitiatedLifeCheckStageThree, "Enable Stage Three") + StageFour = self.AutoHeal.addCheck( + LifeCheckStageFour, [17, 205], InitiatedLifeCheckStageFour, "Enable Stage Four") + StageFive = self.AutoHeal.addCheck( + LifeCheckStageFive, [17, 255], InitiatedLifeCheckStageFive, "Enable Stage Five") + StageSix = self.AutoHeal.addCheck( + LifeCheckStageSix, [17, 305], InitiatedLifeCheckStageSix, "Enable Stage Six") + CheckStats = self.AutoHeal.addCheck( + VarCheckCureStats, [170, 339], InitiatedCheckCureStats, "Enable Cure Stats") + + Paralyze = self.AutoHeal.addCheck( + VarCheckParalyze, [114, 364], InitiatedCheckParalyze, '', ImageStats[0]) + Poison = self.AutoHeal.addCheck( + VarCheckPoison, [155, 364], InitiatedCheckPoison, '', ImageStats[1]) + Fire = self.AutoHeal.addCheck( + VarCheckFire, [195, 364], InitiatedCheckFire, '', ImageStats[2]) + Electrify = self.AutoHeal.addCheck( + VarCheckElectrify, [235, 364], InitiatedCheckElectrify, '', ImageStats[3]) + Mort = self.AutoHeal.addCheck( + VarCheckMort, [275, 364], InitiatedCheckMort, '', ImageStats[4]) + Blood = self.AutoHeal.addCheck( + VarCheckBlood, [315, 364], InitiatedCheckBlood, '', ImageStats[5]) + + TypeStageOneOption = self.AutoHeal.addOption( + TypeStageOne, HealingType, [148, 54], width=6) + PercentageStageOneOption = self.AutoHeal.addOption( + LifePercentageStageOne, Percentage, [232, 54], width=6) + HotkeyStageOneOption = self.AutoHeal.addOption( + LifeHotkeyStageOne, self.SendToClient.Hotkeys, [316, 54], width=6) + + TypeStageTwoOption = self.AutoHeal.addOption( + TypeStageTwo, HealingType, [148, 104], width=6) + PercentageStageTwoOption = self.AutoHeal.addOption( + LifePercentageStageTwo, Percentage, [232, 104], width=6) + HotkeyStageTwoOption = self.AutoHeal.addOption( + LifeHotkeyStageTwo, self.SendToClient.Hotkeys, [316, 104], width=6) + + TypeStageThreeOption = self.AutoHeal.addOption( + TypeStageThree, HealingType, [148, 154], width=6) + PercentageStageThreeOption = self.AutoHeal.addOption( + LifePercentageStageThree, Percentage, [232, 154], width=6) + HotkeyStageThreeOption = self.AutoHeal.addOption( + LifeHotkeyStageThree, self.SendToClient.Hotkeys, [316, 154], width=6) + + TypeStageFourOption = self.AutoHeal.addOption( + TypeStageFour, HealingType, [148, 204], width=6) + PercentageStageFourOption = self.AutoHeal.addOption( + LifePercentageStageFour, Percentage, [232, 204], width=6) + HotkeyStageFourOption = self.AutoHeal.addOption( + LifeHotkeyStageFour, self.SendToClient.Hotkeys, [316, 204], width=6) + + TypeStageFiveOption = self.AutoHeal.addOption( + TypeStageFive, HealingType, [148, 254], width=6) + PercentageStageFiveOption = self.AutoHeal.addOption( + LifePercentageStageFive, Percentage, [232, 254], width=6) + HotkeyStageFiveOption = self.AutoHeal.addOption( + LifeHotkeyStageFive, self.SendToClient.Hotkeys, [316, 254], width=6) + + TypeStageSixOption = self.AutoHeal.addOption( + TypeStageSix, HealingType, [148, 304], width=6) + PercentageStageSixOption = self.AutoHeal.addOption( + LifePercentageStageSix, Percentage, [232, 304], width=6) + HotkeyStageSixOption = self.AutoHeal.addOption( + LifeHotkeyStageSix, self.SendToClient.Hotkeys, [316, 304], width=6) def CheckingButtons(): if EnabledAutoHeal: Disable(CheckStats) + Disable(StageSix) + Disable(StageFive) + Disable(StageFour) Disable(StageThree) Disable(StageTwo) Disable(StageOne) Disable(LabelHotkey) Disable(LabelPercentage) - Disable(PercentageStageOne) - Disable(HotkeyStageOne) - Disable(PercentageStageTwo) - Disable(HotkeyStageTwo) - Disable(PercentageStageThree) - Disable(HotkeyStageThree) + Disable(LabelType) + Disable(TypeStageOneOption) + Disable(PercentageStageOneOption) + Disable(HotkeyStageOneOption) + Disable(TypeStageTwoOption) + Disable(PercentageStageTwoOption) + Disable(HotkeyStageTwoOption) + Disable(TypeStageThreeOption) + Disable(PercentageStageThreeOption) + Disable(HotkeyStageThreeOption) + Disable(TypeStageFourOption) + Disable(PercentageStageFourOption) + Disable(HotkeyStageFourOption) + Disable(TypeStageFiveOption) + Disable(PercentageStageFiveOption) + Disable(HotkeyStageFiveOption) + Disable(TypeStageSixOption) + Disable(PercentageStageSixOption) + Disable(HotkeyStageSixOption) Disable(Paralyze) Disable(Poison) Disable(Fire) @@ -255,17 +391,33 @@ def CheckingButtons(): Disable(CheckBuff) else: Enable(CheckStats) + Enable(StageSix) + Enable(StageFive) + Enable(StageFour) Enable(StageThree) Enable(StageTwo) Enable(StageOne) Enable(LabelHotkey) Enable(LabelPercentage) - Enable(PercentageStageOne) - Enable(HotkeyStageOne) - Enable(PercentageStageTwo) - Enable(HotkeyStageTwo) - Enable(PercentageStageThree) - Enable(HotkeyStageThree) + Enable(LabelType) + Enable(TypeStageOneOption) + Enable(PercentageStageOneOption) + Enable(HotkeyStageOneOption) + Enable(TypeStageTwoOption) + Enable(PercentageStageTwoOption) + Enable(HotkeyStageTwoOption) + Enable(TypeStageThreeOption) + Enable(PercentageStageThreeOption) + Enable(HotkeyStageThreeOption) + Enable(TypeStageFourOption) + Enable(PercentageStageFourOption) + Enable(HotkeyStageFourOption) + Enable(TypeStageFiveOption) + Enable(PercentageStageFiveOption) + Enable(HotkeyStageFiveOption) + Enable(TypeStageSixOption) + Enable(PercentageStageSixOption) + Enable(HotkeyStageSixOption) Enable(CheckPrint) Enable(CheckBuff) if not VarCheckCureStats.get(): diff --git a/modules/AutoHur.py b/modules/AutoHur.py index ee49b32..845f53e 100644 --- a/modules/AutoHur.py +++ b/modules/AutoHur.py @@ -1,4 +1,9 @@ import time +from datetime import datetime +from tkinter import RAISED, SUNKEN + +from pynput.keyboard import Listener as KeyboardListener +from conf.Constants import Percentage from conf.Hotkeys import Hotkey @@ -7,93 +12,122 @@ from core.GUISetter import GUISetter from core.ThreadManager import ThreadManager -from engine.ScanHur import ScanHur +from engine.Scanners.ScanHur import ScanHur EnabledAutoHur = False - ThreadStarted = False GUIChanges = [] class AutoHur: - def __init__(self, StatsPositions, MOUSE_OPTION): + def __init__(self, StatsPositions, SetScanningHPMP, MOUSE_OPTION): self.AutoHur = GUI('AutoHur', 'Module: Auto Hur') - self.AutoHur.DefaultWindow('AutoHur', [224, 258], [1.2, 2.29]) self.Setter = GUISetter("HurLoader") self.SendToClient = Hotkey(MOUSE_OPTION) self.ThreadManager = ThreadManager("ThreadAutoHur") + self.OtherThreadManager = ThreadManager("OtherThread") + self.AutoHur.DefaultWindow( + 'AutoHur', [224, 278], [1.2, 2.29]) - def SetAutoHur(): + def ToggleState(): global EnabledAutoHur if not EnabledAutoHur: EnabledAutoHur = True - ButtonEnabled.configure(text='AutoHur: ON', relief=SUNKEN, bg=rgb((158, 46, 34))) + ButtonEnabled.configure( + text='AutoHur: ON', relief=SUNKEN, bg=rgb((158, 46, 34))) print("AutoHur: ON") CheckingButtons() - if not ThreadStarted: - self.ThreadManager.NewThread(ScanAutoHur) - else: - self.ThreadManager.UnPauseThread() + SetScanningHPMP('AutoHur', 'on') + self.ThreadManager.NewThread(Scan) else: EnabledAutoHur = False CheckingButtons() print("AutoHur: OFF") - ButtonEnabled.configure(text='AutoHur: OFF', relief=RAISED, bg=rgb((127, 17, 8))) - self.ThreadManager.PauseThread() + ButtonEnabled.configure( + text='AutoHur: OFF', relief=RAISED, bg=rgb((127, 17, 8))) + SetScanningHPMP('AutoHur', 'off') + self.ThreadManager.StopThread() - def ScanAutoHur(): + def Scan(): while EnabledAutoHur: - try: - NeedHur = ScanHur(StatsPositions) - except Exception: - NeedHur = False - pass + from modules.Root import Mana + + NeedHur = ScanHur( + StatsPositions, VarCheckPZ.get(), CheckLowMana.get(), Mana, ManaLessThan.get()) + if NeedHur: self.SendToClient.Press(VarHotkeyHur.get()) print("Hur Pressed ", VarHotkeyHur.get()) - time.sleep(.3) - time.sleep(.3) + time.sleep(3) def Recapture(): print("recapture") - VarCheckPrint, InitiatedCheckPrint = self.Setter.Variables.Bool('CheckPrint') - VarCheckBuff, InitiatedCheckBuff = self.Setter.Variables.Bool('CheckBuff') + VarCheckPrint, InitiatedCheckPrint = self.Setter.Variables.Bool( + 'CheckPrint') + VarCheckBuff, InitiatedCheckBuff = self.Setter.Variables.Bool( + 'CheckBuff') + VarCheckPZ, InitiatedCheckPZ = self.Setter.Variables.Bool( + 'CheckPZ') - VarHotkeyHur, InitiatedHotkeyHur = self.Setter.Variables.Str('HotkeyHur') + VarHotkeyHur, InitiatedHotkeyHur = self.Setter.Variables.Str( + 'HotkeyHur') - CheckLowMana, InitiatedCheckLowMana = self.Setter.Variables.Bool('CheckLowMana') + CheckLowMana, InitiatedCheckLowMana = self.Setter.Variables.Bool( + 'CheckLowMana') + + ManaLessThan, InitiatedManaLessThan = self.Setter.Variables.Int( + 'ManaLessThan') def CheckingGUI(Init, Get, Name): if Get != Init: GUIChanges.append((Name, Get)) def Destroy(): - CheckingGUI(InitiatedCheckPrint, VarCheckPrint.get(), 'CheckPrint') - CheckingGUI(InitiatedCheckBuff, VarCheckBuff.get(), 'CheckBuff') - CheckingGUI(InitiatedHotkeyHur, VarHotkeyHur.get(), 'HotkeyHur') - CheckingGUI(InitiatedCheckLowMana, CheckLowMana.get(), 'CheckLowMana') + CheckingGUI(InitiatedCheckPrint, + VarCheckPrint.get(), 'CheckPrint') + CheckingGUI(InitiatedCheckBuff, + VarCheckBuff.get(), 'CheckBuff') + CheckingGUI(InitiatedCheckPZ, VarCheckPZ.get(), 'CheckPZ') + CheckingGUI(InitiatedHotkeyHur, + VarHotkeyHur.get(), 'HotkeyHur') + CheckingGUI(InitiatedCheckLowMana, + CheckLowMana.get(), 'CheckLowMana') + CheckingGUI(InitiatedManaLessThan, + ManaLessThan.get(), 'ManaLessThan') if len(GUIChanges) != 0: for EachChange in range(len(GUIChanges)): - self.Setter.SetVariables.SetVar(GUIChanges[EachChange][0], GUIChanges[EachChange][1]) + self.Setter.SetVariables.SetVar( + GUIChanges[EachChange][0], GUIChanges[EachChange][1]) self.AutoHur.destroyWindow() - self.AutoHur.addButton('Ok', Destroy, [73, 21], [75, 225]) + self.AutoHur.addButton('OK', Destroy, [74, 23], [75, 245]) global EnabledAutoHur if not EnabledAutoHur: - ButtonEnabled = self.AutoHur.addButton('AutoHur: OFF', SetAutoHur, [203, 23], [11, 195]) + ButtonEnabled = self.AutoHur.addButton( + 'AutoHur: OFF', ToggleState, [203, 24], [11, 215]) else: - ButtonEnabled = self.AutoHur.addButton('AutoHur: ON', SetAutoHur, [203, 23], [11, 195]) - ButtonEnabled.configure(relief=SUNKEN, bg=rgb((158, 46, 34))) - - CheckPrint = self.AutoHur.addCheck(VarCheckPrint, [11, 150], InitiatedCheckPrint, "Print on Tibia's screen") - CheckPrint.configure(bg=rgb((114, 94, 48)), activebackground=rgb((114, 94, 48)), selectcolor=rgb((114, 94, 48))) - CheckBuff = self.AutoHur.addCheck(VarCheckBuff, [11, 170], InitiatedCheckBuff, "Don't Buff") - CheckBuff.configure(bg=rgb((114, 94, 48)), activebackground=rgb((114, 94, 48)), selectcolor=rgb((114, 94, 48))) + ButtonEnabled = self.AutoHur.addButton( + 'AutoHur: ON', ToggleState, [203, 24], [11, 215]) + ButtonEnabled.configure( + relief=SUNKEN, bg=rgb((158, 46, 34))) + + CheckPrint = self.AutoHur.addCheck( + VarCheckPrint, [11, 150], InitiatedCheckPrint, "Print on Tibia's screen") + CheckPrint.configure(bg=rgb((114, 94, 48)), activebackground=rgb( + (114, 94, 48)), selectcolor=rgb((114, 94, 48))) + CheckBuff = self.AutoHur.addCheck( + VarCheckBuff, [11, 170], InitiatedCheckBuff, "Don't Buff") + CheckBuff.configure(bg=rgb((114, 94, 48)), activebackground=rgb( + (114, 94, 48)), selectcolor=rgb((114, 94, 48))) + CheckPZ = self.AutoHur.addCheck( + VarCheckPZ, [11, 190], InitiatedCheckPZ, "Hur only outside PZ") + CheckPZ.configure(bg=rgb((114, 94, 48)), activebackground=rgb( + (114, 94, 48)), selectcolor=rgb((114, 94, 48))) ImgHur = 'images/PlayerStats/Hur.png' ImageID = self.AutoHur.openImage(ImgHur, [64, 64]) @@ -101,34 +135,44 @@ def Destroy(): ImgLabel = self.AutoHur.addLabel('Image To Search', [16, 14]) LabelImage = self.AutoHur.addImage(ImageID, [28, 33]) - LabelHotkey = self.AutoHur.addLabel('Hotkey', [135, 48]) - HotkeyHur = self.AutoHur.addOption(VarHotkeyHur, self.SendToClient.Hotkeys, [113, 72], 8) + LabelHotkey = self.AutoHur.addLabel('Hotkey', [135, 14]) + HotkeyHur = self.AutoHur.addOption( + VarHotkeyHur, self.SendToClient.Hotkeys, [113, 34], 8) - ButtonRecapture = self.AutoHur.addButton('Recapture', Recapture, [85, 24], [20, 111]) + ButtonRecapture = self.AutoHur.addButton( + 'Recapture', Recapture, [85, 24], [20, 111]) - CheckBoxLowMana = self.AutoHur.addCheck(CheckLowMana, [118, 103], InitiatedCheckLowMana, 'Stop With\nLowMana') + CheckBoxLowMana = self.AutoHur.addCheck( + CheckLowMana, [108, 60], InitiatedCheckLowMana, 'Stop when\nMana is less\nthan (%)') + + OptionManaLessThan = self.AutoHur.addOption( + ManaLessThan, Percentage, [128, 110]) def CheckingButtons(): if EnabledAutoHur: Disable(CheckPrint) Disable(CheckBuff) + Disable(CheckPZ) Disable(LabelImage) Disable(ImgLabel) Disable(ButtonRecapture) Disable(CheckBoxLowMana) + Disable(OptionManaLessThan) Disable(LabelHotkey) Disable(HotkeyHur) else: Enable(CheckPrint) Enable(CheckBuff) + Enable(CheckPZ) Enable(LabelImage) Enable(ImgLabel) Enable(ButtonRecapture) Enable(CheckBoxLowMana) + Enable(OptionManaLessThan) Enable(LabelHotkey) Enable(HotkeyHur) ExecGUITrigger() @@ -137,4 +181,3 @@ def CheckingButtons(): self.AutoHur.Protocol(Destroy) self.AutoHur.loop() - diff --git a/modules/AutoMana.py b/modules/AutoMana.py deleted file mode 100644 index e46ad32..0000000 --- a/modules/AutoMana.py +++ /dev/null @@ -1,157 +0,0 @@ -import time - -from conf.Hotkeys import Hotkey -from conf.Constants import ManaColor, ManaColorFull, Percentage - -from core.GUI import * -from core.GUIManager import * -from core.GUISetter import GUISetter -from core.ThreadManager import ThreadManager - -from engine.ScanStages import ScanStages - -EnabledAutoMana = False -ThreadStarted = False - -GUIChanges = [] - - -class AutoMana: - def __init__(self, ManaLocation, MOUSE_OPTION): - self.AutoMana = GUI('AutoMana', 'Module: Auto Mana') - self.AutoMana.DefaultWindow('AutoMana', [306, 272], [1.2, 2.29]) - self.Setter = GUISetter("ManaLoader") - self.SendToClient = Hotkey(MOUSE_OPTION) - self.Scan = ScanStages('Mana') - self.ThreadManager = ThreadManager("ThreadAutoMana") - - def SetAutoMana(): - global EnabledAutoMana - if not EnabledAutoMana: - ButtonEnabled.configure(text='AutoMana: ON', relief=SUNKEN, bg=rgb((158, 46, 34))) - print("AutoMana: ON") - EnabledAutoMana = True - CheckingButtons() - if not ThreadStarted: - self.ThreadManager.NewThread(ScanAutoMana) - else: - self.ThreadManager.UnPauseThread() - else: - print("AutoMana: OFF") - EnabledAutoMana = False - CheckingButtons() - ButtonEnabled.configure(text='AutoMana: OFF', relief=RAISED, bg=rgb((127, 17, 8))) - self.ThreadManager.PauseThread() - - def ScanAutoMana(): - while EnabledAutoMana: - Mana = self.Scan.ScanStages(ManaLocation, ManaColor, ManaColorFull) - - if Mana is None: - Mana = 0 - - if ManaCheckStageTwo.get(): - stage_two = ManaPercentageStageTwo.get() - if stage_two > Mana or stage_two == Mana: - self.SendToClient.Press(ManaHotkeyStageTwo.get()) - print("Pressed ", ManaHotkeyStageTwo.get()) - time.sleep(.1) - elif ManaCheckStageOne.get(): - stage_one = ManaPercentageStageOne.get() - if stage_one > Mana or stage_one == Mana: - self.SendToClient.Press(ManaHotkeyStageOne.get()) - print("Pressed ", ManaHotkeyStageOne.get()) - time.sleep(.1) - else: - print("Modulo Not Configured") - time.sleep(1) - - VarCheckPrint, InitiatedCheckPrint = self.Setter.Variables.Bool('CheckPrint') - VarCheckBuff, InitiatedCheckBuff = self.Setter.Variables.Bool('CheckBuff') - - ManaCheckStageOne, InitiatedManaCheckStageOne = self.Setter.Variables.Bool('ManaCheckStageOne') - ManaCheckStageTwo, InitiatedManaCheckStageTwo = self.Setter.Variables.Bool('ManaCheckStageTwo') - - ManaPercentageStageOne, InitiatedManaPercentageStageOne = self.Setter.Variables.Int('ManaPercentageStageOne') - ManaHotkeyStageOne, InitiatedManaHotkeyStageOne = self.Setter.Variables.Str('ManaHotkeyStageOne') - - ManaPercentageStageTwo, InitiatedManaPercentageStageTwo = self.Setter.Variables.Int('ManaPercentageStageTwo') - ManaHotkeyStageTwo, InitiatedManaHotkeyStageTwo = self.Setter.Variables.Str('ManaHotkeyStageTwo') - - def CheckingGUI(Init, Get, Name): - if Get != Init: - GUIChanges.append((Name, Get)) - - def Destroy(): - CheckingGUI(InitiatedCheckPrint, VarCheckPrint.get(), 'CheckPrint') - CheckingGUI(InitiatedCheckBuff, VarCheckBuff.get(), 'CheckBuff') - CheckingGUI(InitiatedManaCheckStageOne, ManaCheckStageOne.get(), 'ManaCheckStageOne') - CheckingGUI(InitiatedManaCheckStageTwo, ManaCheckStageTwo.get(), 'ManaCheckStageTwo') - CheckingGUI(InitiatedManaPercentageStageOne, ManaPercentageStageOne.get(), 'ManaPercentageStageOne') - CheckingGUI(InitiatedManaHotkeyStageOne, ManaHotkeyStageOne.get(), 'ManaHotkeyStageOne') - CheckingGUI(InitiatedManaPercentageStageTwo, ManaPercentageStageTwo.get(), 'ManaPercentageStageTwo') - CheckingGUI(InitiatedManaHotkeyStageTwo, ManaHotkeyStageTwo.get(), 'ManaHotkeyStageTwo') - - if len(GUIChanges) != 0: - for EachChange in range(len(GUIChanges)): - self.Setter.SetVariables.SetVar(GUIChanges[EachChange][0], GUIChanges[EachChange][1]) - - self.AutoMana.destroyWindow() - - self.AutoMana.addButton('Ok', Destroy, [73, 21], [115, 240]) - - ''' button enable healing ''' - - global EnabledAutoMana - if not EnabledAutoMana: - ButtonEnabled = self.AutoMana.addButton('AutoMana: OFF', SetAutoMana, [287, 23], [11, 211]) - else: - ButtonEnabled = self.AutoMana.addButton('AutoMana: ON', SetAutoMana, [287, 23], [11, 211]) - ButtonEnabled.configure(relief=SUNKEN, bg=rgb((158, 46, 34))) - - LabelPercentage = self.AutoMana.addLabel('% Percentage', [145, 24]) - LabelHotkey = self.AutoMana.addLabel('HotKey', [230, 24]) - - CheckPrint = self.AutoMana.addCheck(VarCheckPrint, [11, 160], InitiatedCheckPrint, "Print on Tibia's screen") - CheckPrint.configure(bg=rgb((114, 94, 48)), activebackground=rgb((114, 94, 48)), selectcolor=rgb((114, 94, 48))) - CheckBuff = self.AutoMana.addCheck(VarCheckBuff, [11, 180], InitiatedCheckBuff, "Don't Buff") - CheckBuff.configure(bg=rgb((114, 94, 48)), activebackground=rgb((114, 94, 48)), selectcolor=rgb((114, 94, 48))) - - StageOne = self.AutoMana.addCheck(ManaCheckStageOne, [17, 55], InitiatedManaCheckStageOne, "Enable Stage One") - StageTwo = self.AutoMana.addCheck(ManaCheckStageTwo, [17, 105], InitiatedManaCheckStageTwo, "Enable Stage Two") - - PercentageStageOne = self.AutoMana.addOption(ManaPercentageStageOne, Percentage, [148, 54]) - HotkeyStageOne = self.AutoMana.addOption(ManaHotkeyStageOne, self.SendToClient.Hotkeys, [223, 54]) - - PercentageStageTwo = self.AutoMana.addOption(ManaPercentageStageTwo, Percentage, [148, 104]) - HotkeyStageTwo = self.AutoMana.addOption(ManaHotkeyStageTwo, self.SendToClient.Hotkeys, [223, 104]) - - def CheckingButtons(): - if EnabledAutoMana: - Disable(CheckPrint) - Disable(CheckBuff) - Disable(StageOne) - Disable(StageTwo) - Disable(PercentageStageOne) - Disable(HotkeyStageOne) - Disable(PercentageStageTwo) - Disable(HotkeyStageTwo) - Disable(LabelPercentage) - Disable(LabelHotkey) - else: - Enable(CheckPrint) - Enable(CheckBuff) - Enable(StageOne) - Enable(StageTwo) - Enable(PercentageStageOne) - Enable(HotkeyStageOne) - Enable(PercentageStageTwo) - Enable(HotkeyStageTwo) - Enable(LabelPercentage) - Enable(LabelHotkey) - ExecGUITrigger() - - CheckingButtons() - - self.AutoMana.Protocol(Destroy) - self.AutoMana.loop() diff --git a/modules/AutoRing.py b/modules/AutoRing.py index 1ac9fa6..8ce0ad2 100644 --- a/modules/AutoRing.py +++ b/modules/AutoRing.py @@ -1,4 +1,5 @@ import time +from tkinter import RAISED, SUNKEN import keyboard import pygetwindow @@ -10,7 +11,7 @@ from core.GUISetter import GUISetter from core.ThreadManager import ThreadManager -from engine.ScanRing import ScanRing +from engine.Scanners.ScanRing import ScanRing GUIChanges = [] @@ -33,30 +34,29 @@ def __init__(self, root, RingPositions, HealthLocation, MOUSE_OPTION, ItemsPath) self.SendToClient = Hotkey(MOUSE_OPTION) self.ThreadManager = ThreadManager("ThreadAutoRing") - def SetAutoRing(): + def ToggleState(): global EnabledAutoRing if not EnabledAutoRing: EnabledAutoRing = True - ButtonEnabled.configure(text='AutoRing: ON', relief=SUNKEN, bg=rgb((158, 46, 34))) + ButtonEnabled.configure( + text='AutoRing: ON', relief=SUNKEN, bg=rgb((158, 46, 34))) print("AutoRing: ON") global Ring Ring = NameRing.get() Checking() CheckingButtons() time.sleep(0.03) - if not ThreadStarted: - self.ThreadManager.NewThread(ScanAutoRing) - else: - self.ThreadManager.UnPauseThread() + self.ThreadManager.NewThread(Scan) else: EnabledAutoRing = False print('AutoRing: OFF') - ButtonEnabled.configure(text='AutoRing: OFF', relief=RAISED, bg=rgb((127, 17, 8))) + ButtonEnabled.configure( + text='AutoRing: OFF', relief=RAISED, bg=rgb((127, 17, 8))) Checking() CheckingButtons() - self.ThreadManager.PauseThread() + self.ThreadManager.StopThread() - def ScanAutoRing(): + def Scan(): global Ring Ring = NameRing.get() if CheckLifeBellowThan.get(): @@ -66,13 +66,14 @@ def ScanAutoRing(): while EnabledAutoRing and EnabledAutoHeal: NoHasRing = ScanRing(RingPositions) - from Modules.AutoHeal import Life + from .Modules import Life if NoHasRing and Life <= BellowThan: Execute() else: - from engine.ScanStages import ScanStages + from engine.Scanners.ScanStages import ScanStages while EnabledAutoRing: - Life = ScanStages('Life From AutoRing').ScanStages(HealthLocation, LifeColor, LifeColorFull) + Life = ScanStages('Life From AutoRing').ScanStages( + HealthLocation, LifeColor, LifeColorFull) if Life is None: Life = 0 @@ -91,7 +92,8 @@ def ScanAutoRing(): def Execute(): if RadioButton.get() == 0: self.SendToClient.Press(HotkeyRing.get()) - print("Pressed ", HotkeyRing.get(), " To Reallocated Your Ring") + print("Pressed ", HotkeyRing.get(), + " To Reallocated Your Ring") time.sleep(1) elif RadioButton.get() == 1: try: @@ -110,10 +112,12 @@ def Execute(): else: MousePosition = [0, 0] - self.SendToClient.DragTo([X, Y], [RingPositions[0] + 16, RingPositions[1] + 16]) + self.SendToClient.DragTo( + [X, Y], [RingPositions[0] + 16, RingPositions[1] + 16]) if MOUSE_OPTION == 1: - self.SendToClient.MoveTo(MousePosition[0], MousePosition[1]) + self.SendToClient.MoveTo( + MousePosition[0], MousePosition[1]) print("Ring Reallocated On: X =", RingPositions[0] + 16, "Y =", RingPositions[1] + 16, "From: X =", @@ -127,7 +131,8 @@ def Recapture(): global WaitingForClick, Ring WaitingForClick = True Ring = NameRing.get() - AutoRingWindow = pygetwindow.getWindowsWithTitle("Module: Auto Ring")[0] + AutoRingWindow = pygetwindow.getWindowsWithTitle("Module: Auto Ring")[ + 0] TibiaAuto = pygetwindow.getWindowsWithTitle("TibiaAuto V12")[0] AutoRingWindowX = self.AutoRing.PositionOfWindow('X') AutoRingWindowY = self.AutoRing.PositionOfWindow('Y') @@ -142,7 +147,8 @@ def Recapture(): sX, sY = GetPosition() time.sleep(0.03) from core.HookWindow import SaveImage - SaveImage(ItemsPath + 'Rings/' + Ring + '.png', Region=(sX - 6, sY - 28, sX + 6, sY - 16)) + SaveImage(ItemsPath + 'Rings/' + Ring + '.png', + Region=(sX - 6, sY - 28, sX + 6, sY - 16)) WaitingForClick = False Invisible.destroyWindow() TibiaAuto.maximize() @@ -163,7 +169,8 @@ def CheckClick(): def ReturnGetPosition(): global WaitingForClick WaitingForClick = True - AutoRingWindow = pygetwindow.getWindowsWithTitle("Module: Auto Ring")[0] + AutoRingWindow = pygetwindow.getWindowsWithTitle("Module: Auto Ring")[ + 0] TibiaAuto = pygetwindow.getWindowsWithTitle("TibiaAuto V12")[0] AutoRingWindowX = self.AutoRing.PositionOfWindow('X') AutoRingWindowY = self.AutoRing.PositionOfWindow('Y') @@ -204,19 +211,27 @@ def ValidateEntryY(*args): else: TextEntryY.set(s[:MaxLen]) - VarCheckPrint, InitiatedCheckPrint = self.Setter.Variables.Bool('CheckPrint') - VarCheckBuff, InitiatedCheckBuff = self.Setter.Variables.Bool('CheckBuff') + VarCheckPrint, InitiatedCheckPrint = self.Setter.Variables.Bool( + 'CheckPrint') + VarCheckBuff, InitiatedCheckBuff = self.Setter.Variables.Bool( + 'CheckBuff') - RadioButton, InitiatedRadioButton = self.Setter.Variables.Int('RadioButton') + RadioButton, InitiatedRadioButton = self.Setter.Variables.Int( + 'RadioButton') NameRing, InitiatedNameRing = self.Setter.Variables.Str('NameRing') - HotkeyRing, InitiatedHotkeyRing = self.Setter.Variables.Str('HotkeyRing') + HotkeyRing, InitiatedHotkeyRing = self.Setter.Variables.Str( + 'HotkeyRing') - TextEntryX, InitiatedTextEntryX = self.Setter.Variables.Str('TextEntryX') - TextEntryY, InitiatedTextEntryY = self.Setter.Variables.Str('TextEntryY') + TextEntryX, InitiatedTextEntryX = self.Setter.Variables.Str( + 'TextEntryX') + TextEntryY, InitiatedTextEntryY = self.Setter.Variables.Str( + 'TextEntryY') - CheckLifeBellowThan, InitiatedLifeBellowThan = self.Setter.Variables.Bool('LifeBellowThan') - LifeBellowThan, InitiatedBellowThan = self.Setter.Variables.Int('BellowThan') + CheckLifeBellowThan, InitiatedLifeBellowThan = self.Setter.Variables.Bool( + 'LifeBellowThan') + LifeBellowThan, InitiatedBellowThan = self.Setter.Variables.Int( + 'BellowThan') def CheckingGUI(Init, Get, Name): if Get != Init: @@ -230,12 +245,15 @@ def Destroy(): CheckingGUI(InitiatedHotkeyRing, HotkeyRing.get(), 'HotkeyRing') CheckingGUI(InitiatedTextEntryX, TextEntryX.get(), 'TextEntryX') CheckingGUI(InitiatedTextEntryY, TextEntryY.get(), 'TextEntryY') - CheckingGUI(InitiatedLifeBellowThan, CheckLifeBellowThan.get(), 'LifeBellowThan') - CheckingGUI(InitiatedBellowThan, LifeBellowThan.get(), 'BellowThan') + CheckingGUI(InitiatedLifeBellowThan, + CheckLifeBellowThan.get(), 'LifeBellowThan') + CheckingGUI(InitiatedBellowThan, + LifeBellowThan.get(), 'BellowThan') if len(GUIChanges) != 0: for EachChange in range(len(GUIChanges)): - self.Setter.SetVariables.SetVar(GUIChanges[EachChange][0], GUIChanges[EachChange][1]) + self.Setter.SetVariables.SetVar( + GUIChanges[EachChange][0], GUIChanges[EachChange][1]) self.AutoRing.destroyWindow() @@ -243,15 +261,21 @@ def Destroy(): global EnabledAutoRing if not EnabledAutoRing: - ButtonEnabled = self.AutoRing.addButton('AutoRing: OFF', SetAutoRing, [287, 23], [11, 336]) + ButtonEnabled = self.AutoRing.addButton( + 'AutoRing: OFF', ToggleState, [287, 23], [11, 336]) else: - ButtonEnabled = self.AutoRing.addButton('AutoRing: ON', SetAutoRing, [287, 23], [11, 336]) + ButtonEnabled = self.AutoRing.addButton( + 'AutoRing: ON', ToggleState, [287, 23], [11, 336]) ButtonEnabled.configure(relief=SUNKEN, bg=rgb((158, 46, 34))) - CheckPrint = self.AutoRing.addCheck(VarCheckPrint, [11, 285], InitiatedCheckPrint, "Print on Tibia's screen") - CheckPrint.configure(bg=rgb((114, 94, 48)), activebackground=rgb((114, 94, 48)), selectcolor=rgb((114, 94, 48))) - CheckBuff = self.AutoRing.addCheck(VarCheckBuff, [11, 305], InitiatedCheckBuff, "Don't Buff") - CheckBuff.configure(bg=rgb((114, 94, 48)), activebackground=rgb((114, 94, 48)), selectcolor=rgb((114, 94, 48))) + CheckPrint = self.AutoRing.addCheck( + VarCheckPrint, [11, 285], InitiatedCheckPrint, "Print on Tibia's screen") + CheckPrint.configure(bg=rgb((114, 94, 48)), activebackground=rgb( + (114, 94, 48)), selectcolor=rgb((114, 94, 48))) + CheckBuff = self.AutoRing.addCheck( + VarCheckBuff, [11, 305], InitiatedCheckBuff, "Don't Buff") + CheckBuff.configure(bg=rgb((114, 94, 48)), activebackground=rgb( + (114, 94, 48)), selectcolor=rgb((114, 94, 48))) BackImage = 'images/Fundo.png' Back = self.AutoRing.openImage(BackImage, [150, 45]) @@ -260,7 +284,8 @@ def Destroy(): RingName = [] for NameOfCurrentRing in Rings: CurrentRingName = ItemsPath + 'Rings/' + NameOfCurrentRing + '.png' - CurrentRingImage = self.AutoRing.openImage(CurrentRingName, [64, 64]) + CurrentRingImage = self.AutoRing.openImage( + CurrentRingName, [64, 64]) RingImages.append(CurrentRingImage) RingName.append(NameOfCurrentRing) @@ -270,7 +295,8 @@ def Destroy(): def UpdateImg(): for XRing in Rings: if NameRing.get() == XRing: - self.AutoRing.addImage(RingImages[RingName.index(XRing)], [28, 43]) + self.AutoRing.addImage( + RingImages[RingName.index(XRing)], [28, 43]) global Ring Ring = NameRing.get() @@ -280,21 +306,27 @@ def UpdateImg(): WidthScreen, HeightScreen = self.SendToClient.MainWindowSize() RingLabel = self.AutoRing.addLabel('Select Name Of Ring', [135, 55]) - OptionNameRing = self.AutoRing.addOption(NameRing, Rings, [120, 80], width=21) + OptionNameRing = self.AutoRing.addOption( + NameRing, Rings, [120, 80], width=21) - ButtonAddNewRing = self.AutoRing.addButton('Add New Ring', AddNewAmulet, [167, 24], [120, 115]) + ButtonAddNewRing = self.AutoRing.addButton( + 'Add New Ring', AddNewAmulet, [167, 24], [120, 115]) - ButtonRecapture = self.AutoRing.addButton('Recapture', Recapture, [88, 24], [22, 115]) + ButtonRecapture = self.AutoRing.addButton( + 'Recapture', Recapture, [88, 24], [22, 115]) DescLabel = self.AutoRing.addLabel('', [150, 140]) - RButton1 = self.AutoRing.addRadio('Hotkey', RadioButton, 0, [22, 155], CheckClick) - RButton2 = self.AutoRing.addRadio('Position', RadioButton, 1, [22, 175], CheckClick) + RButton1 = self.AutoRing.addRadio( + 'Hotkey', RadioButton, 0, [22, 155], CheckClick) + RButton2 = self.AutoRing.addRadio( + 'Position', RadioButton, 1, [22, 175], CheckClick) CheckBoxLifeBellowThan = self.AutoRing.addCheck(CheckLifeBellowThan, [60, 210], InitiatedLifeBellowThan, 'Use Only If Life Is Bellow Than') LabelLifeBellowThan = self.AutoRing.addLabel('Life <= ', [90, 245]) - PercentageLifeBellowThan = self.AutoRing.addOption(LifeBellowThan, Percentage, [140, 240]) + PercentageLifeBellowThan = self.AutoRing.addOption( + LifeBellowThan, Percentage, [140, 240]) def Checking(): global FoundedImg, Ring @@ -302,7 +334,8 @@ def Checking(): DescLabel.configure(text='Hotkey To Press') self.AutoRing.addImage(Back, [130, 165]) FoundedImg = False - HotkeyOption = self.AutoRing.addOption(HotkeyRing, self.SendToClient.Hotkeys, [145, 170], 10) + HotkeyOption = self.AutoRing.addOption( + HotkeyRing, self.SendToClient.Hotkeys, [145, 170], 10) if EnabledAutoRing: Disable(HotkeyOption) else: @@ -312,13 +345,16 @@ def Checking(): self.AutoRing.addImage(Back, [120, 165]) FoundedImg = False - ButtonGetPosition = self.AutoRing.addButton('GetPosition', ReturnGetPosition, [80, 29], [195, 173]) + ButtonGetPosition = self.AutoRing.addButton( + 'GetPosition', ReturnGetPosition, [80, 29], [195, 173]) LabelX = self.AutoRing.addLabel('X:', [135, 165]) - EntryX = self.AutoRing.addEntry([150, 165], TextEntryX, width=4) + EntryX = self.AutoRing.addEntry( + [150, 165], TextEntryX, width=4) TextEntryX.trace("w", ValidateEntryX) LabelY = self.AutoRing.addLabel('Y:', [135, 185]) - EntryY = self.AutoRing.addEntry([150, 185], TextEntryY, width=4) + EntryY = self.AutoRing.addEntry( + [150, 185], TextEntryY, width=4) TextEntryY.trace("w", ValidateEntryY) if EnabledAutoRing: Disable(ButtonGetPosition) diff --git a/modules/AutoSSA.py b/modules/AutoSSA.py index 8952708..058b01a 100644 --- a/modules/AutoSSA.py +++ b/modules/AutoSSA.py @@ -1,4 +1,5 @@ import time +from tkinter import RAISED, SUNKEN import keyboard import pygetwindow @@ -10,15 +11,14 @@ from core.GUISetter import GUISetter from core.ThreadManager import ThreadManager -from engine.ScanAmulet import ScanAmulet +from engine.Scanners.ScanAmulet import ScanAmulet GUIChanges = [] -ThreadStarted = False - FoundedImg = False EnabledAutoSSA = False WaitingForClick = False +ThreadStarted = False Amulet = 'StoneSkinAmulet' AmuletLocate = [0, 0] @@ -37,24 +37,23 @@ def SetAutoAmulet(): global EnabledAutoSSA if not EnabledAutoSSA: EnabledAutoSSA = True - ButtonEnabled.configure(text='AutoSSA: ON', relief=SUNKEN, bg=rgb((158, 46, 34))) + ButtonEnabled.configure( + text='AutoSSA: ON', relief=SUNKEN, bg=rgb((158, 46, 34))) print("AutoSSA: ON") global Amulet Amulet = NameAmulet.get() Checking() CheckingButtons() time.sleep(0.03) - if not ThreadStarted: - self.ThreadManager.NewThread(ScanAutoAmulet) - else: - self.ThreadManager.UnPauseThread() + self.ThreadManager.NewThread(ScanAutoAmulet) else: EnabledAutoSSA = False - ButtonEnabled.configure(text='AutoSSA: OFF', relief=RAISED, bg=rgb((127, 17, 8))) + ButtonEnabled.configure( + text='AutoSSA: OFF', relief=RAISED, bg=rgb((127, 17, 8))) print("AutoSSA: OFF") Checking() CheckingButtons() - self.ThreadManager.PauseThread() + self.ThreadManager.StopThread() def ScanAutoAmulet(): global Amulet @@ -64,26 +63,30 @@ def ScanAutoAmulet(): from modules.AutoHeal import EnabledAutoHeal if EnabledAutoHeal: while EnabledAutoSSA and EnabledAutoHeal: - NoHasAmulet = ScanAmulet(AmuletPositions, Amulet, Amulets[Amulet]["Precision"]) + NoHasAmulet = ScanAmulet( + AmuletPositions, Amulet, Amulets[Amulet]["Precision"]) - from Modules.AutoHeal import Life + from modules.AutoHeal import Life if NoHasAmulet and Life <= BellowThan: Execute() else: - from engine.ScanStages import ScanStages + from engine.Scanners.ScanStages import ScanStages while EnabledAutoSSA: - Life = ScanStages('Life From AutoAmulet').ScanStages(HealthLocation, LifeColor, LifeColorFull) + Life = ScanStages('Life From AutoAmulet').ScanStages( + HealthLocation, LifeColor, LifeColorFull) if Life is None: Life = 0 - NoHasAmulet = ScanAmulet(AmuletPositions, Amulet, Amulets[Amulet]["Precision"]) + NoHasAmulet = ScanAmulet( + AmuletPositions, Amulet, Amulets[Amulet]["Precision"]) if NoHasAmulet and Life < BellowThan: Execute() elif not CheckLifeBellowThan.get(): while EnabledAutoSSA: - NoHasAmulet = ScanAmulet(AmuletPositions, Amulet, Amulets[Amulet]["Precision"]) + NoHasAmulet = ScanAmulet( + AmuletPositions, Amulet, Amulets[Amulet]["Precision"]) if NoHasAmulet: Execute() @@ -91,7 +94,8 @@ def ScanAutoAmulet(): def Execute(): if RadioButton.get() == 0: self.SendToClient.Press(HotkeyAmulet.get()) - print("Pressed ", HotkeyAmulet.get(), " To Reallocated Your Amulet") + print("Pressed ", HotkeyAmulet.get(), + " To Reallocated Your Amulet") time.sleep(1) elif RadioButton.get() == 1: try: @@ -109,10 +113,12 @@ def Execute(): else: MousePosition = [0, 0] - self.SendToClient.DragTo([X, Y], [AmuletPositions[0] + 16, AmuletPositions[1] + 16]) + self.SendToClient.DragTo( + [X, Y], [AmuletPositions[0] + 16, AmuletPositions[1] + 16]) if MOUSE_OPTION == 1: - self.SendToClient.MoveTo(MousePosition[0], MousePosition[1]) + self.SendToClient.MoveTo( + MousePosition[0], MousePosition[1]) print("Amulet Reallocated On: X =", AmuletPositions[0] + 16, "Y =", AmuletPositions[1] + 16, "From: X =", @@ -126,7 +132,8 @@ def Recapture(): global WaitingForClick, Amulet WaitingForClick = True Amulet = NameAmulet.get() - AutoSSAWindow = pygetwindow.getWindowsWithTitle("Module: Auto SSA")[0] + AutoSSAWindow = pygetwindow.getWindowsWithTitle("Module: Auto SSA")[ + 0] TibiaAuto = pygetwindow.getWindowsWithTitle("TibiaAuto V12")[0] AutoSSAWindowX = self.AutoSSA.PositionOfWindow('X') AutoSSAWindowY = self.AutoSSA.PositionOfWindow('Y') @@ -141,7 +148,8 @@ def Recapture(): sX, sY = GetPosition() time.sleep(0.03) from core.HookWindow import SaveImage - SaveImage(ItemsPath + 'Amulets/' + Amulet + '.png', Region=(sX - 6, sY - 28, sX + 6, sY - 16)) + SaveImage(ItemsPath + 'Amulets/' + Amulet + '.png', + Region=(sX - 6, sY - 28, sX + 6, sY - 16)) WaitingForClick = False Invisible.destroyWindow() TibiaAuto.maximize() @@ -160,7 +168,8 @@ def CheckClick(): def ReturnGetPosition(): global WaitingForClick WaitingForClick = True - AutoSSAWindow = pygetwindow.getWindowsWithTitle("Module: Auto SSA")[0] + AutoSSAWindow = pygetwindow.getWindowsWithTitle("Module: Auto SSA")[ + 0] TibiaAuto = pygetwindow.getWindowsWithTitle("TibiaAuto V12")[0] AutoSSAWindowX = self.AutoSSA.PositionOfWindow('X') AutoSSAWindowY = self.AutoSSA.PositionOfWindow('Y') @@ -203,19 +212,28 @@ def ValidateEntryY(*args): WidthScreen, HeightScreen = pyautogui.size() - VarCheckPrint, InitiatedCheckPrint = self.Setter.Variables.Bool('CheckPrint') - VarCheckBuff, InitiatedCheckBuff = self.Setter.Variables.Bool('CheckBuff') + VarCheckPrint, InitiatedCheckPrint = self.Setter.Variables.Bool( + 'CheckPrint') + VarCheckBuff, InitiatedCheckBuff = self.Setter.Variables.Bool( + 'CheckBuff') - RadioButton, InitiatedRadioButton = self.Setter.Variables.Int('RadioButton') + RadioButton, InitiatedRadioButton = self.Setter.Variables.Int( + 'RadioButton') - NameAmulet, InitiatedNameAmulet = self.Setter.Variables.Str('NameAmulet') - HotkeyAmulet, InitiatedHotkeyAmulet = self.Setter.Variables.Str('HotkeyAmulet') + NameAmulet, InitiatedNameAmulet = self.Setter.Variables.Str( + 'NameAmulet') + HotkeyAmulet, InitiatedHotkeyAmulet = self.Setter.Variables.Str( + 'HotkeyAmulet') - TextEntryX, InitiatedTextEntryX = self.Setter.Variables.Str('TextEntryX') - TextEntryY, InitiatedTextEntryY = self.Setter.Variables.Str('TextEntryY') + TextEntryX, InitiatedTextEntryX = self.Setter.Variables.Str( + 'TextEntryX') + TextEntryY, InitiatedTextEntryY = self.Setter.Variables.Str( + 'TextEntryY') - CheckLifeBellowThan, InitiatedLifeBellowThan = self.Setter.Variables.Bool('LifeBellowThan') - LifeBellowThan, InitiatedBellowThan = self.Setter.Variables.Int('BellowThan') + CheckLifeBellowThan, InitiatedLifeBellowThan = self.Setter.Variables.Bool( + 'LifeBellowThan') + LifeBellowThan, InitiatedBellowThan = self.Setter.Variables.Int( + 'BellowThan') def CheckingGUI(Init, Get, Name): if Get != Init: @@ -226,15 +244,19 @@ def Destroy(): CheckingGUI(InitiatedCheckBuff, VarCheckBuff.get(), 'CheckBuff') CheckingGUI(InitiatedRadioButton, RadioButton.get(), 'RadioButton') CheckingGUI(InitiatedNameAmulet, NameAmulet.get(), 'NameAmulet') - CheckingGUI(InitiatedHotkeyAmulet, HotkeyAmulet.get(), 'HotkeyAmulet') + CheckingGUI(InitiatedHotkeyAmulet, + HotkeyAmulet.get(), 'HotkeyAmulet') CheckingGUI(InitiatedTextEntryX, TextEntryX.get(), 'TextEntryX') CheckingGUI(InitiatedTextEntryY, TextEntryY.get(), 'TextEntryY') - CheckingGUI(InitiatedLifeBellowThan, CheckLifeBellowThan.get(), 'LifeBellowThan') - CheckingGUI(InitiatedBellowThan, LifeBellowThan.get(), 'BellowThan') + CheckingGUI(InitiatedLifeBellowThan, + CheckLifeBellowThan.get(), 'LifeBellowThan') + CheckingGUI(InitiatedBellowThan, + LifeBellowThan.get(), 'BellowThan') if len(GUIChanges) != 0: for EachChange in range(len(GUIChanges)): - self.Setter.SetVariables.SetVar(GUIChanges[EachChange][0], GUIChanges[EachChange][1]) + self.Setter.SetVariables.SetVar( + GUIChanges[EachChange][0], GUIChanges[EachChange][1]) self.AutoSSA.destroyWindow() @@ -242,15 +264,21 @@ def Destroy(): global EnabledAutoSSA if not EnabledAutoSSA: - ButtonEnabled = self.AutoSSA.addButton('AutoSSA: OFF', SetAutoAmulet, [287, 23], [11, 336]) + ButtonEnabled = self.AutoSSA.addButton( + 'AutoSSA: OFF', SetAutoAmulet, [287, 23], [11, 336]) else: - ButtonEnabled = self.AutoSSA.addButton('AutoSSA: ON', SetAutoAmulet, [287, 23], [11, 336]) + ButtonEnabled = self.AutoSSA.addButton( + 'AutoSSA: ON', SetAutoAmulet, [287, 23], [11, 336]) ButtonEnabled.configure(relief=SUNKEN, bg=rgb((158, 46, 34))) - CheckPrint = self.AutoSSA.addCheck(VarCheckPrint, [11, 285], InitiatedCheckPrint, "Print on Tibia's screen") - CheckPrint.configure(bg=rgb((114, 94, 48)), activebackground=rgb((114, 94, 48)), selectcolor=rgb((114, 94, 48))) - CheckBuff = self.AutoSSA.addCheck(VarCheckBuff, [11, 305], InitiatedCheckBuff, "Don't Buff") - CheckBuff.configure(bg=rgb((114, 94, 48)), activebackground=rgb((114, 94, 48)), selectcolor=rgb((114, 94, 48))) + CheckPrint = self.AutoSSA.addCheck( + VarCheckPrint, [11, 285], InitiatedCheckPrint, "Print on Tibia's screen") + CheckPrint.configure(bg=rgb((114, 94, 48)), activebackground=rgb( + (114, 94, 48)), selectcolor=rgb((114, 94, 48))) + CheckBuff = self.AutoSSA.addCheck( + VarCheckBuff, [11, 305], InitiatedCheckBuff, "Don't Buff") + CheckBuff.configure(bg=rgb((114, 94, 48)), activebackground=rgb( + (114, 94, 48)), selectcolor=rgb((114, 94, 48))) BackImage = 'images/Fundo.png' Back = self.AutoSSA.openImage(BackImage, [150, 45]) @@ -259,7 +287,8 @@ def Destroy(): AmuletName = [] for NameOfCurrentAmulet in Amulets: CurrentAmuletName = ItemsPath + 'Amulets/' + NameOfCurrentAmulet + '.png' - CurrentAmuletImage = self.AutoSSA.openImage(CurrentAmuletName, [64, 64]) + CurrentAmuletImage = self.AutoSSA.openImage( + CurrentAmuletName, [64, 64]) AmuletImages.append(CurrentAmuletImage) AmuletName.append(NameOfCurrentAmulet) @@ -269,7 +298,8 @@ def Destroy(): def UpdateImg(): for XAmulet in Amulets: if NameAmulet.get() == XAmulet: - self.AutoSSA.addImage(AmuletImages[AmuletName.index(XAmulet)], [28, 43]) + self.AutoSSA.addImage( + AmuletImages[AmuletName.index(XAmulet)], [28, 43]) global Amulet Amulet = NameAmulet.get() @@ -279,21 +309,27 @@ def UpdateImg(): WidthScreen, HeightScreen = self.SendToClient.MainWindowSize() AmuletLabel = self.AutoSSA.addLabel('Select Name Of Amulet', [135, 55]) - OptionNameAmulet = self.AutoSSA.addOption(NameAmulet, Amulets, [120, 80], width=21) + OptionNameAmulet = self.AutoSSA.addOption( + NameAmulet, Amulets, [120, 80], width=21) - ButtonAddNewAmulet = self.AutoSSA.addButton('Add New Amulet', AddNewAmulet, [167, 24], [120, 115]) + ButtonAddNewAmulet = self.AutoSSA.addButton( + 'Add New Amulet', AddNewAmulet, [167, 24], [120, 115]) - ButtonRecapture = self.AutoSSA.addButton('Recapture', Recapture, [88, 24], [22, 115]) + ButtonRecapture = self.AutoSSA.addButton( + 'Recapture', Recapture, [88, 24], [22, 115]) DescLabel = self.AutoSSA.addLabel('', [150, 140]) - RButton1 = self.AutoSSA.addRadio('Hotkey', RadioButton, 0, [22, 155], CheckClick) - RButton2 = self.AutoSSA.addRadio('Position', RadioButton, 1, [22, 175], CheckClick) + RButton1 = self.AutoSSA.addRadio( + 'Hotkey', RadioButton, 0, [22, 155], CheckClick) + RButton2 = self.AutoSSA.addRadio( + 'Position', RadioButton, 1, [22, 175], CheckClick) CheckBoxLifeBellowThan = self.AutoSSA.addCheck(CheckLifeBellowThan, [60, 210], InitiatedLifeBellowThan, 'Use Only If Life Is Bellow Than') LabelLifeBellowThan = self.AutoSSA.addLabel('Life <= ', [90, 245]) - PercentageLifeBellowThan = self.AutoSSA.addOption(LifeBellowThan, Percentage, [140, 240]) + PercentageLifeBellowThan = self.AutoSSA.addOption( + LifeBellowThan, Percentage, [140, 240]) def Checking(): global FoundedImg, Amulet @@ -301,7 +337,8 @@ def Checking(): DescLabel.configure(text='Hotkey To Press') self.AutoSSA.addImage(Back, [130, 165]) FoundedImg = False - HotkeyOption = self.AutoSSA.addOption(HotkeyAmulet, self.SendToClient.Hotkeys, [145, 170], 10) + HotkeyOption = self.AutoSSA.addOption( + HotkeyAmulet, self.SendToClient.Hotkeys, [145, 170], 10) if EnabledAutoSSA: HotkeyOption.configure(state='disabled') else: @@ -311,7 +348,8 @@ def Checking(): self.AutoSSA.addImage(Back, [120, 165]) FoundedImg = False - ButtonGetPosition = self.AutoSSA.addButton('GetPosition', ReturnGetPosition, [80, 29], [195, 173]) + ButtonGetPosition = self.AutoSSA.addButton( + 'GetPosition', ReturnGetPosition, [80, 29], [195, 173]) LabelX = self.AutoSSA.addLabel('X:', [135, 165]) EntryX = self.AutoSSA.addEntry([150, 165], TextEntryX, width=4) diff --git a/modules/CaveBot.py b/modules/CaveBot.py index df20e33..531cd1a 100644 --- a/modules/CaveBot.py +++ b/modules/CaveBot.py @@ -2,6 +2,7 @@ import json import time import shutil +from tkinter import RAISED, SUNKEN from conf.MarksConf import * from conf.Constants import Monsters, Priority, Hotkeys, AttackModes @@ -16,8 +17,8 @@ GUIChanges = [] EnabledCaveBot = False -ThreadStarted = False LoadedScript = False +ThreadStarted = False class CaveBot: @@ -31,18 +32,17 @@ def SetCaveBot(): global EnabledCaveBot if not EnabledCaveBot: EnabledCaveBot = True - ButtonEnabled.configure(text='CaveBot: ON', relief=SUNKEN, bg=rgb((158, 46, 34))) + ButtonEnabled.configure( + text='CaveBot: ON', relief=SUNKEN, bg=rgb((158, 46, 34))) CheckingButtons() - if not ThreadStarted: - self.ThreadManager.NewThread(ScanCaveBot) - self.ThreadManager.NewThread(ScanForPause) - else: - self.ThreadManager.UnPauseThread() + self.ThreadManager.NewThread(ScanCaveBot) + self.ThreadManager.NewThread(ScanForPause) else: EnabledCaveBot = False CheckingButtons() - ButtonEnabled.configure(text='CaveBot: OFF', relief=RAISED, bg=rgb((127, 17, 8))) - self.ThreadManager.PauseThread() + ButtonEnabled.configure( + text='CaveBot: OFF', relief=RAISED, bg=rgb((127, 17, 8))) + self.ThreadManager.StopThread() def ScanCaveBot(): ScriptName = Script.get() @@ -78,27 +78,34 @@ def ScanForPause(): if keyboard.is_pressed("page_up"): SetCaveBot() - CheckDebugging, InitiatedDebugging = self.Setter.Variables.Bool('Debugging') + CheckDebugging, InitiatedDebugging = self.Setter.Variables.Bool( + 'Debugging') - CheckHotkeyPause, InitiatedHotkeyPause = self.Setter.Variables.Bool('HotkeyPause') - HotkeyToPause, InitiatedHotkeyToPause = self.Setter.Variables.Str('HotkeyToPause') + CheckHotkeyPause, InitiatedHotkeyPause = self.Setter.Variables.Bool( + 'HotkeyPause') + HotkeyToPause, InitiatedHotkeyToPause = self.Setter.Variables.Str( + 'HotkeyToPause') Script, InitiatedScript = self.Setter.Variables.Str('Script') global EnabledCaveBot if not EnabledCaveBot: - ButtonEnabled = self.CaveBot.addButton('CaveBot: OFF', SetCaveBot, [810, 26], [10, 570]) + ButtonEnabled = self.CaveBot.addButton( + 'CaveBot: OFF', SetCaveBot, [810, 26], [10, 570]) else: - ButtonEnabled = self.CaveBot.addButton('CaveBot: ON', SetCaveBot, [810, 26], [10, 570]) + ButtonEnabled = self.CaveBot.addButton( + 'CaveBot: ON', SetCaveBot, [810, 26], [10, 570]) - CheckboxDebugging = self.CaveBot.addCheck(CheckDebugging, [22, 511], InitiatedDebugging, "Enable Cavebot Debugging") + CheckboxDebugging = self.CaveBot.addCheck( + CheckDebugging, [22, 511], InitiatedDebugging, "Enable Cavebot Debugging") CheckboxHotkeyPause = self.CaveBot.addCheck(CheckHotkeyPause, [22, 542], InitiatedHotkeyPause, 'Enable Hotkey To Break a Cavebot') CheckboxHotkeyPause.configure(bg=rgb((114, 94, 48)), activebackground=rgb((114, 94, 48)), selectcolor=rgb((114, 94, 48))) - ButtonHotkeyPause = self.CaveBot.addOption(HotkeyToPause, Hotkeys, [232, 542], 8) + ButtonHotkeyPause = self.CaveBot.addOption( + HotkeyToPause, Hotkeys, [232, 542], 8) # region Functions Walker @@ -113,10 +120,12 @@ def ValidateStand(*args): def SetResearchMap(): if not ResearchMap.get(): ResearchMap.set(True) - ButtonResearchMap.configure(relief=SUNKEN, bg=rgb((158, 46, 34))) + ButtonResearchMap.configure( + relief=SUNKEN, bg=rgb((158, 46, 34))) else: ResearchMap.set(False) - ButtonResearchMap.configure(relief=RAISED, bg=rgb((127, 17, 8))) + ButtonResearchMap.configure( + relief=RAISED, bg=rgb((127, 17, 8))) def RemoveWalker(): global LoadedScript @@ -167,7 +176,8 @@ def AddWalker(): print(len(DataMark)) if DataMark[0]['status'] == "NotConfigured": - DataMark.insert(0, {"mark": MarkToAdd, "type": TypeToAdd, "status": True}) + DataMark.insert( + 0, {"mark": MarkToAdd, "type": TypeToAdd, "status": True}) del DataMark[1] with open('Scripts/' + Script.get() + '.json', 'w') as wJson: json.dump(DataMark, wJson, indent=4) @@ -177,7 +187,8 @@ def AddWalker(): for j in range(len(DataMark)): if DataMark[j]['status']: - DataMark.insert(j + 1, {"mark": MarkToAdd, "type": TypeToAdd, "status": False}) + DataMark.insert( + j + 1, {"mark": MarkToAdd, "type": TypeToAdd, "status": False}) with open('Scripts/' + Script.get() + '.json', 'w') as wJson: json.dump(DataMark, wJson, indent=4) DataMark[j]['status'] = False @@ -203,7 +214,8 @@ def LoadPrevious(DataMark, index): PreviousMarkData = DataMark[index - 1]['mark'] PreviousWaypoint.configure(text=PreviousMarkData) - PreviousImage.configure(image=ImageMarks[MarkDecoder.get(PreviousMarkData) - 1]) + PreviousImage.configure( + image=ImageMarks[MarkDecoder.get(PreviousMarkData) - 1]) if DataMark[index] == DataMark[0]: PreviousTypeData = DataMark[-1]['type'] @@ -214,8 +226,10 @@ def LoadPrevious(DataMark, index): def LoadCurrent(DataMark, index): CurrentMarkData = DataMark[index]['mark'] CurrentWaypoint.configure(text=CurrentMarkData) - CurrentImage.configure(image=ImageMarks[MarkDecoder.get(CurrentMarkData) - 1]) - CurrentType.configure(text=TypeDecoder.get(DataMark[index]['type'])) + CurrentImage.configure( + image=ImageMarks[MarkDecoder.get(CurrentMarkData) - 1]) + CurrentType.configure( + text=TypeDecoder.get(DataMark[index]['type'])) def LoadNext(DataMark, index): if DataMark[index] == DataMark[-1]: @@ -224,7 +238,8 @@ def LoadNext(DataMark, index): NextMarkData = DataMark[index + 1]['mark'] NextWaypoint.configure(text=NextMarkData) - NextImage.configure(image=ImageMarks[MarkDecoder.get(NextMarkData) - 1]) + NextImage.configure( + image=ImageMarks[MarkDecoder.get(NextMarkData) - 1]) if DataMark[index] == DataMark[-1]: NextTypeData = DataMark[0]['type'] @@ -362,7 +377,8 @@ def ValidateMonstersRange(*args): def SetLoadAutoSeller(): if not LoadAutoSeller.get(): LoadAutoSeller.set(True) - ButtonAutoSeller.configure(relief=SUNKEN, bg=rgb((158, 46, 34))) + ButtonAutoSeller.configure( + relief=SUNKEN, bg=rgb((158, 46, 34))) else: LoadAutoSeller.set(False) ButtonAutoSeller.configure(relief=RAISED, bg=rgb((127, 17, 8))) @@ -370,7 +386,8 @@ def SetLoadAutoSeller(): def SetLoadAutoBanker(): if not LoadAutoBanker.get(): LoadAutoBanker.set(True) - ButtonAutoBanker.configure(relief=SUNKEN, bg=rgb((158, 46, 34))) + ButtonAutoBanker.configure( + relief=SUNKEN, bg=rgb((158, 46, 34))) else: LoadAutoBanker.set(False) ButtonAutoBanker.configure(relief=RAISED, bg=rgb((127, 17, 8))) @@ -391,77 +408,123 @@ def CheckingGUI(Init, Get, Name): def Destroy(): CheckingGUI(InitiatedDebugging, CheckDebugging.get(), 'Debugging') - CheckingGUI(InitiatedHotkeyPause, CheckHotkeyPause.get(), 'HotkeyPause') - CheckingGUI(InitiatedHotkeyToPause, HotkeyToPause.get(), 'HotkeyToPause') + CheckingGUI(InitiatedHotkeyPause, + CheckHotkeyPause.get(), 'HotkeyPause') + CheckingGUI(InitiatedHotkeyToPause, + HotkeyToPause.get(), 'HotkeyToPause') CheckingGUI(InitiatedPriorityOne, PriorityOne.get(), 'PriorityOne') CheckingGUI(InitiatedPriorityTwo, PriorityTwo.get(), 'PriorityTwo') - CheckingGUI(InitiatedPriorityThree, PriorityThree.get(), 'PriorityThree') - CheckingGUI(InitiatedPriorityFour, PriorityFour.get(), 'PriorityFour') - CheckingGUI(InitiatedSelectedMonster, SelectedMonster.get(), 'SelectedMonster') - CheckingGUI(InitiatedSelectedMonster2, SelectedMonster2.get(), 'SelectedMonster2') - CheckingGUI(InitiatedSelectedMonster3, SelectedMonster3.get(), 'SelectedMonster3') - CheckingGUI(InitiatedSelectedMonster4, SelectedMonster4.get(), 'SelectedMonster4') - CheckingGUI(InitiatedSelectedAttackMode, SelectedAttackMode.get(), 'SelectedAttackMode') + CheckingGUI(InitiatedPriorityThree, + PriorityThree.get(), 'PriorityThree') + CheckingGUI(InitiatedPriorityFour, + PriorityFour.get(), 'PriorityFour') + CheckingGUI(InitiatedSelectedMonster, + SelectedMonster.get(), 'SelectedMonster') + CheckingGUI(InitiatedSelectedMonster2, + SelectedMonster2.get(), 'SelectedMonster2') + CheckingGUI(InitiatedSelectedMonster3, + SelectedMonster3.get(), 'SelectedMonster3') + CheckingGUI(InitiatedSelectedMonster4, + SelectedMonster4.get(), 'SelectedMonster4') + CheckingGUI(InitiatedSelectedAttackMode, + SelectedAttackMode.get(), 'SelectedAttackMode') CheckingGUI(InitiatedAttackOne, CheckAttackOne.get(), 'AttackOne') CheckingGUI(InitiatedAttackTwo, CheckAttackTwo.get(), 'AttackTwo') - CheckingGUI(InitiatedAttackThree, CheckAttackThree.get(), 'AttackThree') - CheckingGUI(InitiatedAttackFour, CheckAttackFour.get(), 'AttackFour') + CheckingGUI(InitiatedAttackThree, + CheckAttackThree.get(), 'AttackThree') + CheckingGUI(InitiatedAttackFour, + CheckAttackFour.get(), 'AttackFour') CheckingGUI(InitiatedFollow, CheckFollow.get(), 'Follow') - CheckingGUI(InitiatedCantAttack, CheckCantAttack.get(), 'CantAttack') - CheckingGUI(InitiatedAttackPlayers, CheckAttackPlayers.get(), 'AttackPlayers') - CheckingGUI(InitiatedPlayerSeen, CheckPlayerSeen.get(), 'PlayerSeen') - CheckingGUI(InitiatedAttackingYou, CheckAttackingYou.get(), 'AttackingYou') - CheckingGUI(InitiatedForceAttack, CheckForceAttack.get(), 'ForceAttack') - CheckingGUI(InitiatedSuspendAfter, SuspendAfter.get(), 'SuspendAfter') - CheckingGUI(InitiatedMonstersRange, MonstersRange.get(), 'MonstersRange') - CheckingGUI(InitiatedCavebotMode, RadioCavebotMode.get(), 'CavebotMode') + CheckingGUI(InitiatedCantAttack, + CheckCantAttack.get(), 'CantAttack') + CheckingGUI(InitiatedAttackPlayers, + CheckAttackPlayers.get(), 'AttackPlayers') + CheckingGUI(InitiatedPlayerSeen, + CheckPlayerSeen.get(), 'PlayerSeen') + CheckingGUI(InitiatedAttackingYou, + CheckAttackingYou.get(), 'AttackingYou') + CheckingGUI(InitiatedForceAttack, + CheckForceAttack.get(), 'ForceAttack') + CheckingGUI(InitiatedSuspendAfter, + SuspendAfter.get(), 'SuspendAfter') + CheckingGUI(InitiatedMonstersRange, + MonstersRange.get(), 'MonstersRange') + CheckingGUI(InitiatedCavebotMode, + RadioCavebotMode.get(), 'CavebotMode') CheckingGUI(InitiatedRadius, Radius.get(), 'Radius') CheckingGUI(InitiatedDelay, Delay.get(), 'Delay') - CheckingGUI(InitiatedEnableWalking, CheckEnableWalking.get(), 'EnableWalking') + CheckingGUI(InitiatedEnableWalking, + CheckEnableWalking.get(), 'EnableWalking') CheckingGUI(InitiatedTypeValue, RadioTypeValue.get(), 'TypeValue') CheckingGUI(InitiatedStand, Stand.get(), 'Stand') CheckingGUI(InitiatedResearchMap, ResearchMap.get(), 'ResearchMap') CheckingGUI(InitiatedMarkValue, RadioMarkValue.get(), 'MarkValue') CheckingGUI(InitiatedDropItems, CheckDropItems.get(), 'DropItems') - CheckingGUI(InitiatedLoadAutoSeller, LoadAutoSeller.get(), 'LoadAutoSeller') - CheckingGUI(InitiatedLoadAutoBanker, LoadAutoBanker.get(), 'LoadAutoBanker') - CheckingGUI(InitiatedLoadSortLoot, LoadSortLoot.get(), 'LoadSortLoot') - CheckingGUI(InitiatedCapBelowThan, CapBelowThan.get(), 'CapBelowThan') + CheckingGUI(InitiatedLoadAutoSeller, + LoadAutoSeller.get(), 'LoadAutoSeller') + CheckingGUI(InitiatedLoadAutoBanker, + LoadAutoBanker.get(), 'LoadAutoBanker') + CheckingGUI(InitiatedLoadSortLoot, + LoadSortLoot.get(), 'LoadSortLoot') + CheckingGUI(InitiatedCapBelowThan, + CapBelowThan.get(), 'CapBelowThan') CheckingGUI(InitiatedScript, Script.get(), 'Script') - CheckingGUI(InitiatedWalkForDebug, CheckWalkForDebug.get(), 'WalkForDebug') + CheckingGUI(InitiatedWalkForDebug, + CheckWalkForDebug.get(), 'WalkForDebug') if len(GUIChanges) != 0: for EachChange in range(len(GUIChanges)): - self.Setter.SetVariables.SetVar(GUIChanges[EachChange][0], GUIChanges[EachChange][1]) + self.Setter.SetVariables.SetVar( + GUIChanges[EachChange][0], GUIChanges[EachChange][1]) self.CaveBot.destroyWindow() # region Variables MonsterAttacking - PriorityOne, InitiatedPriorityOne = self.Setter.Variables.Int('PriorityOne') - PriorityTwo, InitiatedPriorityTwo = self.Setter.Variables.Int('PriorityTwo') - PriorityThree, InitiatedPriorityThree = self.Setter.Variables.Int('PriorityThree') - PriorityFour, InitiatedPriorityFour = self.Setter.Variables.Int('PriorityFour') - - SelectedMonster, InitiatedSelectedMonster = self.Setter.Variables.Str('SelectedMonster') - SelectedMonster2, InitiatedSelectedMonster2 = self.Setter.Variables.Str('SelectedMonster2') - SelectedMonster3, InitiatedSelectedMonster3 = self.Setter.Variables.Str('SelectedMonster3') - SelectedMonster4, InitiatedSelectedMonster4 = self.Setter.Variables.Str('SelectedMonster4') - - SelectedAttackMode, InitiatedSelectedAttackMode = self.Setter.Variables.Str('SelectedAttackMode') - CheckAttackOne, InitiatedAttackOne = self.Setter.Variables.Bool('AttackOne') - CheckAttackTwo, InitiatedAttackTwo = self.Setter.Variables.Bool('AttackTwo') - CheckAttackThree, InitiatedAttackThree = self.Setter.Variables.Bool('AttackThree') - CheckAttackFour, InitiatedAttackFour = self.Setter.Variables.Bool('AttackFour') + PriorityOne, InitiatedPriorityOne = self.Setter.Variables.Int( + 'PriorityOne') + PriorityTwo, InitiatedPriorityTwo = self.Setter.Variables.Int( + 'PriorityTwo') + PriorityThree, InitiatedPriorityThree = self.Setter.Variables.Int( + 'PriorityThree') + PriorityFour, InitiatedPriorityFour = self.Setter.Variables.Int( + 'PriorityFour') + + SelectedMonster, InitiatedSelectedMonster = self.Setter.Variables.Str( + 'SelectedMonster') + SelectedMonster2, InitiatedSelectedMonster2 = self.Setter.Variables.Str( + 'SelectedMonster2') + SelectedMonster3, InitiatedSelectedMonster3 = self.Setter.Variables.Str( + 'SelectedMonster3') + SelectedMonster4, InitiatedSelectedMonster4 = self.Setter.Variables.Str( + 'SelectedMonster4') + + SelectedAttackMode, InitiatedSelectedAttackMode = self.Setter.Variables.Str( + 'SelectedAttackMode') + CheckAttackOne, InitiatedAttackOne = self.Setter.Variables.Bool( + 'AttackOne') + CheckAttackTwo, InitiatedAttackTwo = self.Setter.Variables.Bool( + 'AttackTwo') + CheckAttackThree, InitiatedAttackThree = self.Setter.Variables.Bool( + 'AttackThree') + CheckAttackFour, InitiatedAttackFour = self.Setter.Variables.Bool( + 'AttackFour') CheckFollow, InitiatedFollow = self.Setter.Variables.Bool('Follow') - CheckCantAttack, InitiatedCantAttack = self.Setter.Variables.Bool('CantAttack') - CheckAttackPlayers, InitiatedAttackPlayers = self.Setter.Variables.Bool('AttackPlayers') - CheckPlayerSeen, InitiatedPlayerSeen = self.Setter.Variables.Bool('PlayerSeen') - CheckAttackingYou, InitiatedAttackingYou = self.Setter.Variables.Bool('AttackingYou') - CheckForceAttack, InitiatedForceAttack = self.Setter.Variables.Bool('ForceAttack') - SuspendAfter, InitiatedSuspendAfter = self.Setter.Variables.Str('SuspendAfter') - MonstersRange, InitiatedMonstersRange = self.Setter.Variables.Str('MonstersRange') + CheckCantAttack, InitiatedCantAttack = self.Setter.Variables.Bool( + 'CantAttack') + CheckAttackPlayers, InitiatedAttackPlayers = self.Setter.Variables.Bool( + 'AttackPlayers') + CheckPlayerSeen, InitiatedPlayerSeen = self.Setter.Variables.Bool( + 'PlayerSeen') + CheckAttackingYou, InitiatedAttackingYou = self.Setter.Variables.Bool( + 'AttackingYou') + CheckForceAttack, InitiatedForceAttack = self.Setter.Variables.Bool( + 'ForceAttack') + SuspendAfter, InitiatedSuspendAfter = self.Setter.Variables.Str( + 'SuspendAfter') + MonstersRange, InitiatedMonstersRange = self.Setter.Variables.Str( + 'MonstersRange') # endregion @@ -470,38 +533,50 @@ def Destroy(): BackImage = 'images/Fundo.png' Back = self.CaveBot.openImage(BackImage, [20, 20]) - RadioCavebotMode, InitiatedCavebotMode = self.Setter.Variables.Int('CavebotMode') + RadioCavebotMode, InitiatedCavebotMode = self.Setter.Variables.Int( + 'CavebotMode') Radius, InitiatedRadius = self.Setter.Variables.Int('Radius') Delay, InitiatedDelay = self.Setter.Variables.Int('Delay') Stand, InitiatedStand = self.Setter.Variables.Int('Stand') - ResearchMap, InitiatedResearchMap = self.Setter.Variables.Bool('ResearchMap') + ResearchMap, InitiatedResearchMap = self.Setter.Variables.Bool( + 'ResearchMap') - CheckWalkForDebug, InitiatedWalkForDebug = self.Setter.Variables.Bool('WalkForDebug') + CheckWalkForDebug, InitiatedWalkForDebug = self.Setter.Variables.Bool( + 'WalkForDebug') for i in range(len(NameMarks)): - ImageMark = Image.open('images/MapSettings/' + NameMarks[i] + '.png') + ImageMark = Image.open( + 'images/MapSettings/' + NameMarks[i] + '.png') ImageMark = ImageMark.resize((20, 20), Image.ANTIALIAS) ImageMark = ImageTk.PhotoImage(ImageMark) ImageMarks.append(ImageMark) - RadioMarkValue, InitiatedMarkValue = self.Setter.Variables.Int('MarkValue') - RadioTypeValue, InitiatedTypeValue = self.Setter.Variables.Int('TypeValue') + RadioMarkValue, InitiatedMarkValue = self.Setter.Variables.Int( + 'MarkValue') + RadioTypeValue, InitiatedTypeValue = self.Setter.Variables.Int( + 'TypeValue') - CheckEnableWalking, InitiatedEnableWalking = self.Setter.Variables.Bool('EnableWalking') + CheckEnableWalking, InitiatedEnableWalking = self.Setter.Variables.Bool( + 'EnableWalking') # endregion # region Variables DepotWalker - CheckDropItems, InitiatedDropItems = self.Setter.Variables.Bool('DropItems') + CheckDropItems, InitiatedDropItems = self.Setter.Variables.Bool( + 'DropItems') - LoadAutoSeller, InitiatedLoadAutoSeller = self.Setter.Variables.Bool('LoadAutoSeller') - LoadAutoBanker, InitiatedLoadAutoBanker = self.Setter.Variables.Bool('LoadAutoBanker') - LoadSortLoot, InitiatedLoadSortLoot = self.Setter.Variables.Bool('LoadSortLoot') + LoadAutoSeller, InitiatedLoadAutoSeller = self.Setter.Variables.Bool( + 'LoadAutoSeller') + LoadAutoBanker, InitiatedLoadAutoBanker = self.Setter.Variables.Bool( + 'LoadAutoBanker') + LoadSortLoot, InitiatedLoadSortLoot = self.Setter.Variables.Bool( + 'LoadSortLoot') - CapBelowThan, InitiatedCapBelowThan = self.Setter.Variables.Str('CapBelowThan') + CapBelowThan, InitiatedCapBelowThan = self.Setter.Variables.Str( + 'CapBelowThan') # endregion @@ -509,25 +584,39 @@ def Destroy(): # region GUI MonsterAttacking - OptionAttackMode = self.CaveBot.addOption(SelectedAttackMode, AttackModes, [103, 328], 10) - - CheckboxAttackOne = self.CaveBot.addCheck(CheckAttackOne, [25, 40], InitiatedAttackOne, 'Monster One') - OptionMonstersOne = self.CaveBot.addOption(SelectedMonster, Monsters, [155, 40], 16) - PriorityMonstersOne = self.CaveBot.addOption(PriorityOne, Priority, [300, 40]) - - CheckboxAttackTwo = self.CaveBot.addCheck(CheckAttackTwo, [25, 80], InitiatedAttackTwo, 'Monster Two') - OptionMonstersTwo = self.CaveBot.addOption(SelectedMonster2, Monsters, [155, 80], 16) - PriorityMonstersTwo = self.CaveBot.addOption(PriorityTwo, Priority, [300, 80]) - - CheckboxAttackThree = self.CaveBot.addCheck(CheckAttackThree, [25, 120], InitiatedAttackThree, 'Monster Three') - OptionMonstersThree = self.CaveBot.addOption(SelectedMonster3, Monsters, [155, 120], 16) - PriorityMonstersThree = self.CaveBot.addOption(PriorityThree, Priority, [300, 120]) - - CheckboxAttackFour = self.CaveBot.addCheck(CheckAttackFour, [25, 160], InitiatedAttackFour, 'Monster Four') - OptionMonstersFour = self.CaveBot.addOption(SelectedMonster4, Monsters, [155, 160], 16) - PriorityMonstersFour = self.CaveBot.addOption(PriorityFour, Priority, [300, 160]) - - CheckBoxFollow = self.CaveBot.addCheck(CheckFollow, [20, 200], InitiatedFollow, 'Auto Follow Mode') + OptionAttackMode = self.CaveBot.addOption( + SelectedAttackMode, AttackModes, [103, 328], 10) + + CheckboxAttackOne = self.CaveBot.addCheck( + CheckAttackOne, [25, 40], InitiatedAttackOne, 'Monster One') + OptionMonstersOne = self.CaveBot.addOption( + SelectedMonster, Monsters, [155, 40], 16) + PriorityMonstersOne = self.CaveBot.addOption( + PriorityOne, Priority, [300, 40]) + + CheckboxAttackTwo = self.CaveBot.addCheck( + CheckAttackTwo, [25, 80], InitiatedAttackTwo, 'Monster Two') + OptionMonstersTwo = self.CaveBot.addOption( + SelectedMonster2, Monsters, [155, 80], 16) + PriorityMonstersTwo = self.CaveBot.addOption( + PriorityTwo, Priority, [300, 80]) + + CheckboxAttackThree = self.CaveBot.addCheck( + CheckAttackThree, [25, 120], InitiatedAttackThree, 'Monster Three') + OptionMonstersThree = self.CaveBot.addOption( + SelectedMonster3, Monsters, [155, 120], 16) + PriorityMonstersThree = self.CaveBot.addOption( + PriorityThree, Priority, [300, 120]) + + CheckboxAttackFour = self.CaveBot.addCheck( + CheckAttackFour, [25, 160], InitiatedAttackFour, 'Monster Four') + OptionMonstersFour = self.CaveBot.addOption( + SelectedMonster4, Monsters, [155, 160], 16) + PriorityMonstersFour = self.CaveBot.addOption( + PriorityFour, Priority, [300, 160]) + + CheckBoxFollow = self.CaveBot.addCheck( + CheckFollow, [20, 200], InitiatedFollow, 'Auto Follow Mode') CheckBoxCantAttack = self.CaveBot.addCheck(CheckCantAttack, [20, 220], InitiatedCantAttack, "Suspend When Can't Attack") CheckBoxAttackPlayers = self.CaveBot.addCheck(CheckAttackPlayers, [20, 240], InitiatedAttackPlayers, @@ -539,13 +628,16 @@ def Destroy(): CheckBoxForceAttack = self.CaveBot.addCheck(CheckForceAttack, [195, 220], InitiatedForceAttack, 'Force Attack When Attacked') - LabelSuspendAfter = self.CaveBot.addLabel('Suspend After Unreachable:', [100, 280]) - LabelMonstersRange = self.CaveBot.addLabel('Consider Monsters In Range:', [100, 300]) + LabelSuspendAfter = self.CaveBot.addLabel( + 'Suspend After Unreachable:', [100, 280]) + LabelMonstersRange = self.CaveBot.addLabel( + 'Consider Monsters In Range:', [100, 300]) LabelAttackMode = self.CaveBot.addLabel('Attack Mode:', [20, 331]) EntrySuspendAfter = self.CaveBot.addEntry([270, 280], SuspendAfter, 5) SuspendAfter.trace("w", ValidateSuspendAfter) - EntryMonstersRange = self.CaveBot.addEntry([270, 300], MonstersRange, 5) + EntryMonstersRange = self.CaveBot.addEntry( + [270, 300], MonstersRange, 5) MonstersRange.trace("w", ValidateMonstersRange) # endregion @@ -556,44 +648,72 @@ def Destroy(): self.CaveBot.addLabel("Script Name:", [430, 160]) EntryCurrentScript = self.CaveBot.addEntry([440, 185], Script, 22) - ButtonLoadScript = self.CaveBot.addButton('Load Script', LoadScript, [110, 30], [590, 176]) - ButtonSaveScript = self.CaveBot.addButton('Save Script', SaveScript, [100, 30], [710, 176]) + ButtonLoadScript = self.CaveBot.addButton( + 'Load Script', LoadScript, [110, 30], [590, 176]) + ButtonSaveScript = self.CaveBot.addButton( + 'Save Script', SaveScript, [100, 30], [710, 176]) self.CaveBot.addLabel('Marks:', [431, 210]) - RadioImage1 = self.CaveBot.addRadioImage('', RadioMarkValue, 1, [470, 230], CheckMarkClick, ImageMarks[0]) - RadioImage2 = self.CaveBot.addRadioImage('', RadioMarkValue, 2, [510, 230], CheckMarkClick, ImageMarks[1]) - RadioImage3 = self.CaveBot.addRadioImage('', RadioMarkValue, 3, [550, 230], CheckMarkClick, ImageMarks[2]) - RadioImage4 = self.CaveBot.addRadioImage('', RadioMarkValue, 4, [590, 230], CheckMarkClick, ImageMarks[3]) - RadioImage5 = self.CaveBot.addRadioImage('', RadioMarkValue, 5, [630, 230], CheckMarkClick, ImageMarks[4]) - RadioImage6 = self.CaveBot.addRadioImage('', RadioMarkValue, 6, [670, 230], CheckMarkClick, ImageMarks[5]) - RadioImage7 = self.CaveBot.addRadioImage('', RadioMarkValue, 7, [710, 230], CheckMarkClick, ImageMarks[6]) - RadioImage8 = self.CaveBot.addRadioImage('', RadioMarkValue, 8, [470, 260], CheckMarkClick, ImageMarks[7]) - RadioImage9 = self.CaveBot.addRadioImage('', RadioMarkValue, 9, [510, 260], CheckMarkClick, ImageMarks[8]) - RadioImage10 = self.CaveBot.addRadioImage('', RadioMarkValue, 10, [550, 260], CheckMarkClick, ImageMarks[9]) - RadioImage11 = self.CaveBot.addRadioImage('', RadioMarkValue, 11, [590, 260], CheckMarkClick, ImageMarks[10]) - RadioImage12 = self.CaveBot.addRadioImage('', RadioMarkValue, 12, [630, 260], CheckMarkClick, ImageMarks[11]) - RadioImage13 = self.CaveBot.addRadioImage('', RadioMarkValue, 13, [670, 260], CheckMarkClick, ImageMarks[12]) - RadioImage14 = self.CaveBot.addRadioImage('', RadioMarkValue, 14, [710, 260], CheckMarkClick, ImageMarks[13]) - RadioImage15 = self.CaveBot.addRadioImage('', RadioMarkValue, 15, [470, 290], CheckMarkClick, ImageMarks[14]) - RadioImage16 = self.CaveBot.addRadioImage('', RadioMarkValue, 16, [510, 290], CheckMarkClick, ImageMarks[15]) - RadioImage17 = self.CaveBot.addRadioImage('', RadioMarkValue, 17, [550, 290], CheckMarkClick, ImageMarks[16]) - RadioImage18 = self.CaveBot.addRadioImage('', RadioMarkValue, 18, [590, 290], CheckMarkClick, ImageMarks[17]) - RadioImage19 = self.CaveBot.addRadioImage('', RadioMarkValue, 19, [630, 290], CheckMarkClick, ImageMarks[18]) - RadioImage20 = self.CaveBot.addRadioImage('', RadioMarkValue, 20, [670, 290], CheckMarkClick, ImageMarks[19]) + RadioImage1 = self.CaveBot.addRadioImage( + '', RadioMarkValue, 1, [470, 230], CheckMarkClick, ImageMarks[0]) + RadioImage2 = self.CaveBot.addRadioImage( + '', RadioMarkValue, 2, [510, 230], CheckMarkClick, ImageMarks[1]) + RadioImage3 = self.CaveBot.addRadioImage( + '', RadioMarkValue, 3, [550, 230], CheckMarkClick, ImageMarks[2]) + RadioImage4 = self.CaveBot.addRadioImage( + '', RadioMarkValue, 4, [590, 230], CheckMarkClick, ImageMarks[3]) + RadioImage5 = self.CaveBot.addRadioImage( + '', RadioMarkValue, 5, [630, 230], CheckMarkClick, ImageMarks[4]) + RadioImage6 = self.CaveBot.addRadioImage( + '', RadioMarkValue, 6, [670, 230], CheckMarkClick, ImageMarks[5]) + RadioImage7 = self.CaveBot.addRadioImage( + '', RadioMarkValue, 7, [710, 230], CheckMarkClick, ImageMarks[6]) + RadioImage8 = self.CaveBot.addRadioImage( + '', RadioMarkValue, 8, [470, 260], CheckMarkClick, ImageMarks[7]) + RadioImage9 = self.CaveBot.addRadioImage( + '', RadioMarkValue, 9, [510, 260], CheckMarkClick, ImageMarks[8]) + RadioImage10 = self.CaveBot.addRadioImage( + '', RadioMarkValue, 10, [550, 260], CheckMarkClick, ImageMarks[9]) + RadioImage11 = self.CaveBot.addRadioImage( + '', RadioMarkValue, 11, [590, 260], CheckMarkClick, ImageMarks[10]) + RadioImage12 = self.CaveBot.addRadioImage( + '', RadioMarkValue, 12, [630, 260], CheckMarkClick, ImageMarks[11]) + RadioImage13 = self.CaveBot.addRadioImage( + '', RadioMarkValue, 13, [670, 260], CheckMarkClick, ImageMarks[12]) + RadioImage14 = self.CaveBot.addRadioImage( + '', RadioMarkValue, 14, [710, 260], CheckMarkClick, ImageMarks[13]) + RadioImage15 = self.CaveBot.addRadioImage( + '', RadioMarkValue, 15, [470, 290], CheckMarkClick, ImageMarks[14]) + RadioImage16 = self.CaveBot.addRadioImage( + '', RadioMarkValue, 16, [510, 290], CheckMarkClick, ImageMarks[15]) + RadioImage17 = self.CaveBot.addRadioImage( + '', RadioMarkValue, 17, [550, 290], CheckMarkClick, ImageMarks[16]) + RadioImage18 = self.CaveBot.addRadioImage( + '', RadioMarkValue, 18, [590, 290], CheckMarkClick, ImageMarks[17]) + RadioImage19 = self.CaveBot.addRadioImage( + '', RadioMarkValue, 19, [630, 290], CheckMarkClick, ImageMarks[18]) + RadioImage20 = self.CaveBot.addRadioImage( + '', RadioMarkValue, 20, [670, 290], CheckMarkClick, ImageMarks[19]) self.CaveBot.addLabel('Type Of Waypoint:', [470, 325]) - RadioWalk = self.CaveBot.addRadio('Walk', RadioTypeValue, 1, [580, 324]) - RadioRope = self.CaveBot.addRadio('Rope', RadioTypeValue, 2, [635, 324]) - RadioShovel = self.CaveBot.addRadio('Shovel', RadioTypeValue, 3, [690, 324]) + RadioWalk = self.CaveBot.addRadio( + 'Walk', RadioTypeValue, 1, [580, 324]) + RadioRope = self.CaveBot.addRadio( + 'Rope', RadioTypeValue, 2, [635, 324]) + RadioShovel = self.CaveBot.addRadio( + 'Shovel', RadioTypeValue, 3, [690, 324]) - ButtonRemoveWalker = self.CaveBot.addButton("Remove", RemoveWalker, [70, 21], [615, 355]) - ButtonAddWalker = self.CaveBot.addButton("Add", AddWalker, [50, 21], [555, 355]) + ButtonRemoveWalker = self.CaveBot.addButton( + "Remove", RemoveWalker, [70, 21], [615, 355]) + ButtonAddWalker = self.CaveBot.addButton( + "Add", AddWalker, [50, 21], [555, 355]) self.CaveBot.addLabel('Waypoints In Current Script:', [431, 385]) - ButtonResetMarks = self.CaveBot.addButton('Reset Marks', ResetMarks, [100, 24], [701, 385]) + ButtonResetMarks = self.CaveBot.addButton( + 'Reset Marks', ResetMarks, [100, 24], [701, 385]) self.CaveBot.addLabel("PreviousWaypoint:", [431, 410]) self.CaveBot.addLabel("CurrentWaypoint:", [570, 410]) @@ -615,31 +735,40 @@ def Destroy(): CurrentType = self.CaveBot.addLabel("", [612, 480]) NextType = self.CaveBot.addLabel("", [752, 480]) - ButtonPreviousWaypoint = self.CaveBot.addButton('<<<', SelectPreviousWaypoint, [30, 21], [430, 456]) - ButtonNextWaypoint = self.CaveBot.addButton('>>>', SelectNextWaypoint, [30, 21], [786, 456]) + ButtonPreviousWaypoint = self.CaveBot.addButton( + '<<<', SelectPreviousWaypoint, [30, 21], [430, 456]) + ButtonNextWaypoint = self.CaveBot.addButton( + '>>>', SelectNextWaypoint, [30, 21], [786, 456]) CheckboxWalkForDebug = self.CaveBot.addCheck(CheckWalkForDebug, [431, 497], InitiatedWalkForDebug, "Enable Walk For Refresh Map (RECOMMENDED)") - self.CaveBot.addLabel('Stand Still After Reaching Waypoint Per:', [431, 520]) + self.CaveBot.addLabel( + 'Stand Still After Reaching Waypoint Per:', [431, 520]) EntryStand = self.CaveBot.addEntry([653, 521], Stand, 2) Stand.trace("w", ValidateStand) - ButtonResearchMap = self.CaveBot.addButton('Auto Research Map', SetResearchMap, [130, 37], [684, 519]) + ButtonResearchMap = self.CaveBot.addButton( + 'Auto Research Map', SetResearchMap, [130, 37], [684, 519]) # endregion # region GUI DepotWalker - CheckboxDropItems = self.CaveBot.addCheck(CheckDropItems, [425, 28], InitiatedDropItems, 'Drop Items Instead Of Deposit') - LabelGoDepot = self.CaveBot.addLabel('Go To Depot When Cap Below Than:', [480, 50]) + CheckboxDropItems = self.CaveBot.addCheck( + CheckDropItems, [425, 28], InitiatedDropItems, 'Drop Items Instead Of Deposit') + LabelGoDepot = self.CaveBot.addLabel( + 'Go To Depot When Cap Below Than:', [480, 50]) EntryCapBelowThan = self.CaveBot.addEntry([680, 50], CapBelowThan, 5) - ButtonAutoSeller = self.CaveBot.addButton('Load AutoSeller', SetLoadAutoSeller, [110, 28], [450, 80]) - ButtonAutoBanker = self.CaveBot.addButton('Load AutoBanker', SetLoadAutoBanker, [120, 28], [570, 80]) - ButtonSortLoot = self.CaveBot.addButton('Load SortLoot', SetLoadSortLoot, [100, 28], [700, 80]) + ButtonAutoSeller = self.CaveBot.addButton( + 'Load AutoSeller', SetLoadAutoSeller, [110, 28], [450, 80]) + ButtonAutoBanker = self.CaveBot.addButton( + 'Load AutoBanker', SetLoadAutoBanker, [120, 28], [570, 80]) + ButtonSortLoot = self.CaveBot.addButton( + 'Load SortLoot', SetLoadSortLoot, [100, 28], [700, 80]) # endregion @@ -680,7 +809,7 @@ def CheckingButtons(): Disable(ButtonAutoSeller) Disable(ButtonAutoBanker) Disable(ButtonSortLoot) - + Disable(CheckboxEnableWalking) Disable(EntryCurrentScript) @@ -798,21 +927,29 @@ def CheckingButtons(): Enable(ButtonSortLoot) if ResearchMap.get(): - ButtonResearchMap.configure(relief=SUNKEN, bg=rgb((158, 46, 34))) + ButtonResearchMap.configure( + relief=SUNKEN, bg=rgb((158, 46, 34))) else: - ButtonResearchMap.configure(relief=RAISED, bg=rgb((127, 17, 8))) + ButtonResearchMap.configure( + relief=RAISED, bg=rgb((127, 17, 8))) if LoadAutoSeller.get(): - ButtonAutoSeller.configure(relief=SUNKEN, bg=rgb((158, 46, 34))) + ButtonAutoSeller.configure( + relief=SUNKEN, bg=rgb((158, 46, 34))) else: - ButtonAutoSeller.configure(relief=RAISED, bg=rgb((127, 17, 8))) + ButtonAutoSeller.configure( + relief=RAISED, bg=rgb((127, 17, 8))) if LoadAutoBanker.get(): - ButtonAutoBanker.configure(relief=SUNKEN, bg=rgb((158, 46, 34))) + ButtonAutoBanker.configure( + relief=SUNKEN, bg=rgb((158, 46, 34))) else: - ButtonAutoBanker.configure(relief=RAISED, bg=rgb((127, 17, 8))) + ButtonAutoBanker.configure( + relief=RAISED, bg=rgb((127, 17, 8))) if LoadSortLoot.get(): - ButtonSortLoot.configure(relief=SUNKEN, bg=rgb((158, 46, 34))) + ButtonSortLoot.configure( + relief=SUNKEN, bg=rgb((158, 46, 34))) else: - ButtonSortLoot.configure(relief=RAISED, bg=rgb((127, 17, 8))) + ButtonSortLoot.configure( + relief=RAISED, bg=rgb((127, 17, 8))) if CheckEnableWalking.get(): Enable(EntryCurrentScript) @@ -863,7 +1000,7 @@ def CheckingButtons(): Enable(EntryStand) Enable(CheckboxWalkForDebug) - + ExecGUITrigger() def ConstantVerify(): diff --git a/modules/ChooseConfig.py b/modules/ChooseConfig.py index ad343ba..07c8596 100644 --- a/modules/ChooseConfig.py +++ b/modules/ChooseConfig.py @@ -23,7 +23,7 @@ class ChooseConfig: windows are now created from GUI.py on 'core' folder. """ - def __init__(self, selected_window_name): + def __init__(self, selected_window_name, hwnd): self.window = GUI('ChooseConfig', 'Choose your config') self.window.MainWindow('Config', [414, 202], [2, 2.36]) @@ -37,10 +37,10 @@ def bootstrap(): """ When This Function Is Called, He Takes A Name From EntryBox, To Do Some Checks In The File. - + If The File Already Exist, He Just Throws You For Root Window Because You Already Configure Your File. - + Else He Creates One File With The Name Got And Starts The Configuration """ @@ -70,7 +70,7 @@ def bootstrap(): else: os.remove(preferences_path) bootstrap() - + return ''' @@ -94,16 +94,20 @@ def bootstrap(): shutil.copyfile(Directory + '\\scripts' + '\\Json.json', os.path.join(Directory + '\\scripts' + '\\' + NameCreateJson.get() + '.json')) - TibiaAuto = pygetwindow.getWindowsWithTitle("Choose your config")[0] + TibiaAuto = pygetwindow.getWindowsWithTitle( + "Choose your config")[0] TibiaAuto.minimize() with open(preferences_path, 'r') as LoadedJson: preferences = json.load(LoadedJson) + GetClientScreenshot() + try: HealthLocation = GetHealthPosition() print('') - print(f"Health Location [X: {HealthLocation[0]} Y: {HealthLocation[1]}]") + print( + f"Health Location [X: {HealthLocation[0]} Y: {HealthLocation[1]}]") preferences['Positions']['LifePosition'][0]['x'] = HealthLocation[0] preferences['Positions']['LifePosition'][0]['y'] = HealthLocation[1] preferences['Positions']['LifePosition'][0]['Stats'] = True @@ -122,7 +126,8 @@ def bootstrap(): try: ManaLocation = GetManaPosition() print('') - print(f"Mana Location [X: {ManaLocation[0]} Y: {ManaLocation[1]}]") + print( + f"Mana Location [X: {ManaLocation[0]} Y: {ManaLocation[1]}]") print('') preferences['Positions']['ManaPosition'][0]['x'] = ManaLocation[0] preferences['Positions']['ManaPosition'][0]['y'] = ManaLocation[1] @@ -140,17 +145,23 @@ def bootstrap(): pass try: - BattlePositions[0], BattlePositions[1], BattlePositions[2], BattlePositions[3] = GetBattlePosition() + BattlePositions[0], BattlePositions[1], BattlePositions[2], BattlePositions[3] = GetBattlePosition( + ) if BattlePositions[0] and BattlePositions[1] and BattlePositions[2] and BattlePositions[3] != 0: - print(f"Battle Location [X: {BattlePositions[0]} Y: {BattlePositions[1]}]") + print( + f"Battle Location [X: {BattlePositions[0]} Y: {BattlePositions[1]}]") preferences['Positions']['BattlePosition'][0]['x'] = BattlePositions[0] preferences['Positions']['BattlePosition'][0]['y'] = BattlePositions[1] preferences['Positions']['BattlePosition'][0]['Stats'] = True time.sleep(.4) - preferences['Boxes']['BattleBox'][0]['x'] = int(BattlePositions[0]) - preferences['Boxes']['BattleBox'][0]['y'] = int(BattlePositions[1]) - preferences['Boxes']['BattleBox'][0]['w'] = int(BattlePositions[2]) - preferences['Boxes']['BattleBox'][0]['h'] = int(BattlePositions[3]) + preferences['Boxes']['BattleBox'][0]['x'] = int( + BattlePositions[0]) + preferences['Boxes']['BattleBox'][0]['y'] = int( + BattlePositions[1]) + preferences['Boxes']['BattleBox'][0]['w'] = int( + BattlePositions[2]) + preferences['Boxes']['BattleBox'][0]['h'] = int( + BattlePositions[3]) preferences['Boxes']['BattleBox'][0]['Stats'] = True with open(preferences_path, 'w') as wJson: json.dump(preferences, wJson, indent=4) @@ -167,16 +178,23 @@ def bootstrap(): pass try: - StatsPositions[0], StatsPositions[1], StatsPositions[2], StatsPositions[3] = GetStatsPosition() + StatsPositions[0], StatsPositions[1], StatsPositions[2], StatsPositions[3] = GetStatsPosition( + ) print('') - print(f"Status Bar Start [X: {StatsPositions[0]}, Y: {StatsPositions[1]}]") - print(f"Status Bar End [X: {StatsPositions[2]}, Y: {StatsPositions[3]}]") + print( + f"Status Bar Start [X: {StatsPositions[0]}, Y: {StatsPositions[1]}]") + print( + f"Status Bar End [X: {StatsPositions[2]}, Y: {StatsPositions[3]}]") print('') time.sleep(.2) - preferences['Boxes']['StatusBarBox'][0]['x'] = int(StatsPositions[0]) - preferences['Boxes']['StatusBarBox'][0]['y'] = int(StatsPositions[1]) - preferences['Boxes']['StatusBarBox'][0]['w'] = int(StatsPositions[2]) - preferences['Boxes']['StatusBarBox'][0]['h'] = int(StatsPositions[3]) + preferences['Boxes']['StatusBarBox'][0]['x'] = int( + StatsPositions[0]) + preferences['Boxes']['StatusBarBox'][0]['y'] = int( + StatsPositions[1]) + preferences['Boxes']['StatusBarBox'][0]['w'] = int( + StatsPositions[2]) + preferences['Boxes']['StatusBarBox'][0]['h'] = int( + StatsPositions[3]) preferences['Boxes']['StatusBarBox'][0]['Stats'] = True with open(preferences_path, 'w') as wJson: json.dump(preferences, wJson, indent=4) @@ -194,8 +212,10 @@ def bootstrap(): RingPositions[0], RingPositions[1] = StatsPositions[0], StatsPositions[1] - 58 RingPositions[2] = RingPositions[0] + items_square - 1 RingPositions[3] = RingPositions[1] + items_square - 1 - print(f"Ring's Square Start [X: {RingPositions[0]}, Y: {RingPositions[1]}]") - print(f"Ring's Square End [X: {RingPositions[2]}, Y: {RingPositions[3]}]") + print( + f"Ring's Square Start [X: {RingPositions[0]}, Y: {RingPositions[1]}]") + print( + f"Ring's Square End [X: {RingPositions[2]}, Y: {RingPositions[3]}]") print('') time.sleep(.2) preferences['Boxes']['RingBox'][0]['x'] = int(RingPositions[0]) @@ -219,14 +239,20 @@ def bootstrap(): AmuletPositions[0], AmuletPositions[1] = StatsPositions[0], StatsPositions[1] - 130 AmuletPositions[2] = AmuletPositions[0] + items_square - 1 AmuletPositions[3] = AmuletPositions[1] + items_square - 1 - print(f"Amulet's Square Start [X: {AmuletPositions[0]}, Y: {AmuletPositions[1]}]") - print(f"Amulet's Square End [X: {AmuletPositions[2]}, Y: {AmuletPositions[3]}]") + print( + f"Amulet's Square Start [X: {AmuletPositions[0]}, Y: {AmuletPositions[1]}]") + print( + f"Amulet's Square End [X: {AmuletPositions[2]}, Y: {AmuletPositions[3]}]") print('') time.sleep(.2) - preferences['Boxes']['AmuletBox'][0]['x'] = int(AmuletPositions[0]) - preferences['Boxes']['AmuletBox'][0]['y'] = int(AmuletPositions[1]) - preferences['Boxes']['AmuletBox'][0]['w'] = int(AmuletPositions[2]) - preferences['Boxes']['AmuletBox'][0]['h'] = int(AmuletPositions[3]) + preferences['Boxes']['AmuletBox'][0]['x'] = int( + AmuletPositions[0]) + preferences['Boxes']['AmuletBox'][0]['y'] = int( + AmuletPositions[1]) + preferences['Boxes']['AmuletBox'][0]['w'] = int( + AmuletPositions[2]) + preferences['Boxes']['AmuletBox'][0]['h'] = int( + AmuletPositions[3]) preferences['Boxes']['AmuletBox'][0]['Stats'] = True with open(preferences_path, 'w') as wJson: json.dump(preferences, wJson, indent=4) @@ -241,7 +267,8 @@ def bootstrap(): pass try: - MapPositions[0], MapPositions[1], MapPositions[2], MapPositions[3] = GetMapPosition() + MapPositions[0], MapPositions[1], MapPositions[2], MapPositions[3] = GetMapPosition( + ) time.sleep(.2) preferences['Boxes']['MapBox'][0]['x'] = int(MapPositions[0]) preferences['Boxes']['MapBox'][0]['y'] = int(MapPositions[1]) @@ -266,17 +293,23 @@ def bootstrap(): print('') print(f"Player Position [X: {Player[0]}, Y: {Player[1]}]") print('') - print(f"Game Window Start [X: {GameWindow[0]}, Y: {GameWindow[1]}]") - print(f"Game Window End [X: {GameWindow[2]}, Y: {GameWindow[3]}]") + print( + f"Game Window Start [X: {GameWindow[0]}, Y: {GameWindow[1]}]") + print( + f"Game Window End [X: {GameWindow[2]}, Y: {GameWindow[3]}]") print('') time.sleep(.2) preferences['Positions']['PlayerPosition'][0]['x'] = Player[0] preferences['Positions']['PlayerPosition'][0]['y'] = Player[1] preferences['Positions']['PlayerPosition'][0]['Stats'] = True - preferences['Boxes']['GameWindowBox'][0]['x'] = int(GameWindow[0]) - preferences['Boxes']['GameWindowBox'][0]['y'] = int(GameWindow[1]) - preferences['Boxes']['GameWindowBox'][0]['w'] = int(GameWindow[2]) - preferences['Boxes']['GameWindowBox'][0]['h'] = int(GameWindow[3]) + preferences['Boxes']['GameWindowBox'][0]['x'] = int( + GameWindow[0]) + preferences['Boxes']['GameWindowBox'][0]['y'] = int( + GameWindow[1]) + preferences['Boxes']['GameWindowBox'][0]['w'] = int( + GameWindow[2]) + preferences['Boxes']['GameWindowBox'][0]['h'] = int( + GameWindow[3]) preferences['Boxes']['GameWindowBox'][0]['Stats'] = True with open(preferences_path, 'w') as wJson: json.dump(preferences, wJson, indent=4) @@ -294,7 +327,7 @@ def bootstrap(): try: SQMs[0], SQMs[1], SQMs[2], SQMs[3], SQMs[4], SQMs[5], SQMs[6], SQMs[7], SQMs[8], SQMs[9], SQMs[10], \ - SQMs[ + SQMs[ 11], SQMs[12], SQMs[13], SQMs[14], SQMs[15], SQMs[16], SQMs[17] = SetSQMs() time.sleep(0.1) print(f"1° SQM Location [X: {SQMs[0]}, Y: {SQMs[1]}]") @@ -389,15 +422,18 @@ def bootstrap(): if len(number_of_exceptions) != 0: print("\nSome Errors Occurred... Opening The Manual Config.") - print("Unfortunately, You Will Have To Manually Configure The Following Errors:\n") + print( + "Unfortunately, You Will Have To Manually Configure The Following Errors:\n") time.sleep(.3) self.window.destroyWindow() time.sleep(.1) def ManualConfig(ErrorName): - ManualConfiguration = GUI('ManualConfiguration', 'Manual Configuration') - ManualConfiguration.MainWindow('Config', [414, 202], [2, 2.36]) + ManualConfiguration = GUI( + 'ManualConfiguration', 'Manual Configuration') + ManualConfiguration.MainWindow( + 'Config', [414, 202], [2, 2.36]) def Solving(): ManualConfiguration.destroyWindow() @@ -406,16 +442,20 @@ def Solving(): '''LabelError = ManualConfiguration.addLabel("Solving Manually: " + ErrorName, [85, 31]) LabelError.configure(font=24)''' - ManualConfiguration.addMinimalLabel("One Error Was Occured In: " + ErrorName, [35, 31], 10) - ManualConfiguration.addMinimalLabel("... But This Option Is In Development.", [35, 51]) + ManualConfiguration.addMinimalLabel( + "One Error Was Occured In: " + ErrorName, [35, 31], 10) + ManualConfiguration.addMinimalLabel( + "... But This Option Is In Development.", [35, 51]) - ManualConfiguration.addButton('Ok', Solving, [75, 23], [310, 166]) + ManualConfiguration.addButton( + 'Ok', Solving, [75, 23], [310, 166]) ManualConfiguration.Protocol(Solving) ManualConfiguration.loop() for i in range(len(number_of_exceptions)): - print("Error[" + str(i + 1) + "] =", number_of_exceptions[i]) + print("Error[" + str(i + 1) + "] =", + number_of_exceptions[i]) for i in range(len(number_of_exceptions)): ManualConfig(number_of_exceptions[i]) @@ -430,6 +470,7 @@ def Solving(): conf['configured'] = True conf['preferences_name'] = preferences_name + conf['hwnd'] = hwnd ConfManager.set(conf, 'conf.json') end_configuration = time.time() - start_configuration @@ -473,38 +514,42 @@ def Solving(): self.window.addLabel('Name Of The Json Conf', [24, 35]) - LabelSelectOP1 = self.window.addLabel('Select Your Mouse And Keyboard Option', [30, 76]) + LabelSelectOP1 = self.window.addLabel( + 'Select Your Mouse And Keyboard Option', [30, 76]) LabelSelectOP1.configure(bg=rgb((114, 94, 48)), fg='black') RadioMouseMoviment = self.window.addRadio('{Global} Movement Mouse On Focused Window', MouseMode, 1, - [10, 95]) + [10, 95]) RadioMouseMoviment.configure(bg=rgb((114, 94, 48)), activebackground=rgb((114, 94, 48)), selectcolor=rgb((114, 94, 48))) RadioSenderMouse = self.window.addRadio("{OTServer} Send Mouse Events To Tibia's Window", MouseMode, 0, - [10, 114]) + [10, 114]) RadioSenderMouse.configure(bg=rgb((114, 94, 48)), activebackground=rgb((114, 94, 48)), selectcolor=rgb((114, 94, 48))) - LabelSelectOP2 = self.window.addLabel('Select Your Hook Mode', [30, 136]) + LabelSelectOP2 = self.window.addLabel( + 'Select Your Hook Mode', [30, 136]) LabelSelectOP2.configure(bg=rgb((114, 94, 48)), fg='black') - RadioHookWindow = self.window.addRadio("{Global} Hook Directly OBS Screen", HookMode, 1, [10, 155]) + RadioHookWindow = self.window.addRadio( + "{Global} Hook Directly OBS Screen", HookMode, 1, [10, 155]) RadioHookWindow.configure(bg=rgb((114, 94, 48)), activebackground=rgb((114, 94, 48)), selectcolor=rgb((114, 94, 48))) - LabelSelectOP3 = self.window.addLabel('Select The Items Mode', [280, 76]) + LabelSelectOP3 = self.window.addLabel( + 'Select The Items Mode', [280, 76]) LabelSelectOP3.configure(bg=rgb((114, 94, 48)), fg='black') RadioFrames = self.window.addRadio('Frames', ItemsMode, "Frames", - [310, 95]) + [310, 95]) RadioFrames.configure(bg=rgb((114, 94, 48)), activebackground=rgb((114, 94, 48)), selectcolor=rgb((114, 94, 48))) RadioCorners = self.window.addRadio("Corners", ItemsMode, "Corners", - [310, 114]) + [310, 114]) RadioCorners.configure(bg=rgb((114, 94, 48)), activebackground=rgb((114, 94, 48)), selectcolor=rgb((114, 94, 48))) RadioNone = self.window.addRadio("None", ItemsMode, "None", - [310, 133]) + [310, 133]) RadioNone.configure(bg=rgb((114, 94, 48)), activebackground=rgb((114, 94, 48)), selectcolor=rgb((114, 94, 48))) diff --git a/modules/FoodEater.py b/modules/FoodEater.py index ae375a8..8f23f59 100644 --- a/modules/FoodEater.py +++ b/modules/FoodEater.py @@ -11,7 +11,7 @@ from core.GUISetter import GUISetter, check_gui from core.ThreadManager import ThreadManager -from engine.ScanFood import scan_food +from engine.Scanners.ScanFood import scan_food class FoodEater: @@ -41,11 +41,13 @@ def __init__(self, root, stats_positions, MOUSE_OPTION): def trigger(self): if FoodEater.enabled: FoodEater.enabled = False - self.enabled_button.configure(text='FoodEater: OFF', relief=RAISED, bg=rgb((127, 17, 8))) + self.enabled_button.configure( + text='FoodEater: OFF', relief=RAISED, bg=rgb((127, 17, 8))) self.pause() else: FoodEater.enabled = True - self.enabled_button.configure(text='FoodEater: ON', relief=SUNKEN, bg=rgb((158, 46, 34))) + self.enabled_button.configure( + text='FoodEater: ON', relief=SUNKEN, bg=rgb((158, 46, 34))) self.run() self.check() @@ -60,7 +62,7 @@ def run(self): print('FoodEater: ON') def pause(self): - self.ThreadManager.PauseThread() + self.ThreadManager.StopThread() print('FoodEater: OFF') def execute(self): @@ -71,8 +73,10 @@ def execute(self): sleep(0.5) def destroy(self): - check_gui(FoodEater.gui_changes, self.init_check_print, self.check_print.get(), 'CheckPrint') - check_gui(FoodEater.gui_changes, self.init_food_hotkey, self.food_hotkey.get(), 'HotkeyFood') + check_gui(FoodEater.gui_changes, self.init_check_print, + self.check_print.get(), 'CheckPrint') + check_gui(FoodEater.gui_changes, self.init_food_hotkey, + self.food_hotkey.get(), 'HotkeyFood') if len(FoodEater.gui_changes) != 0: for each_change in range(len(FoodEater.gui_changes)): @@ -88,26 +92,32 @@ def destroy(self): self.window.destroyWindow() def gui_vars(self): - self.check_print, self.init_check_print = self.Setter.Variables.Bool('CheckPrint') - self.food_hotkey, self.init_food_hotkey = self.Setter.Variables.Str('HotkeyFood') + self.check_print, self.init_check_print = self.Setter.Variables.Bool( + 'CheckPrint') + self.food_hotkey, self.init_food_hotkey = self.Setter.Variables.Str( + 'HotkeyFood') def gui(self): self.label = self.window.addLabel('Hotkey To Press', [110, 24]) - self.hotkey_button = self.window.addOption(self.food_hotkey, self.SendToClient.Hotkeys, [105, 50], 10) + self.hotkey_button = self.window.addOption( + self.food_hotkey, self.SendToClient.Hotkeys, [105, 50], 10) self.check_print_button = self.window.addCheck(self.check_print, [11, 100], self.init_check_print, "Print on Tibia's screen") self.check_print_button.configure(bg=rgb((114, 94, 48)), activebackground=rgb((114, 94, 48)), - selectcolor=rgb((114, 94, 48))) + selectcolor=rgb((114, 94, 48))) if not FoodEater.enabled: - self.enabled_button = self.window.addButton('FoodEater: OFF', self.trigger, [287, 23], [11, 132]) + 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]) + 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]) + self.ok_button = self.window.addButton( + 'Ok', self.destroy, [73, 21], [115, 161]) def check(self): if FoodEater.enabled: diff --git a/modules/Root.py b/modules/Root.py index 39565b0..d97f78d 100644 --- a/modules/Root.py +++ b/modules/Root.py @@ -1,35 +1,38 @@ import json from core.GUI import * - -# from modules.AdjustConfig import AdjustConfig -# from modules.AmmoRestack import AmmoRestack -# from modules.ShowMap import ShowMap -# from modules.AutoBanker import AutoBanker -# from modules.AutoFish import AutoFish -# from modules.AutoGrouping import AutoGrouping -from modules.AutoHeal import AutoHeal -from modules.AutoHur import AutoHur -# from modules.AutoLogin import AutoLogin -# from modules.AutoLooter import AutoLooter -from modules.AutoMana import AutoMana -from modules.AutoRing import AutoRing -# from modules.AutoSeller import AutoSeller -from modules.AutoSSA import AutoSSA -from modules.CaveBot import CaveBot -# from modules.ColorChange import ColorChange -# from modules.CreatureInfo import CreatureInfo -from modules.FoodEater import FoodEater -# from modules.FPSChanger import FPSChanger -# from modules.GeneralOptions import GeneralOptions -# from modules.HealerFriend import HealerFriend -# from modules.LoadConfig import LoadConfig -# from modules.Modules import Modules -# from modules.Monsters import Monsters -# from modules.PythonScripts import PythonScripts -# from modules.SaveConfig import SaveConfig -# from modules.SortLoot import SortLoot -from modules.TimedSpells import TimedSpells +from core.ThreadManager import ThreadManager +from engine.Scanners.ScanBars import ScanBars +# from core.GUISetter import GUISetter, GetData + +# from modules.AdjustConfig import AdjustConfig as AdjustConfigModule +# from modules.AmmoRestack import AmmoRestack as AmmoRestackModule +# from modules.ShowMap import ShowMap as ShowMapModule +# from modules.AutoBanker import AutoBanker as AutoBankerModule +# from modules.AutoFish import AutoFish as AutoFishModule +# from modules.AutoGrouping import AutoGrouping as AutoGroupingModule +from modules.AutoExchangeGold import AutoExchangeGold as AutoExchangeGoldModule +from modules.AutoHeal import AutoHeal as AutoHealModule +from modules.AutoHur import AutoHur as AutoHurModule +# from modules.AutoLogin import AutoLogin as AutoLoginModule +# from modules.AutoLooter import AutoLooter as AutoLooterModule +from modules.AutoRing import AutoRing as AutoRingModule +# from modules.AutoSeller import AutoSeller as AutoSellerModule +from modules.AutoSSA import AutoSSA as AutoSSAModule +from modules.CaveBot import CaveBot as CaveBotModule +# from modules.ColorChange import ColorChange as ColorChangeModule +# from modules.CreatureInfo import CreatureInfo as CreatureInfoModule +from modules.FoodEater import FoodEater as FoodEaterModule +# from modules.FPSChanger import FPSChanger as FPSChangerModule +# from modules.GeneralOptions import GeneralOptions as GeneralOptionsModule +# from modules.HealerFriend import HealerFriend as HealerFriendModule +# from modules.LoadConfig import LoadConfig as LoadConfigModule +# from modules.Modules import Modules as ModulesModule +# from modules.Monsters import Monsters as MonstersModule +# from modules.PythonScripts import PythonScripts as PythonScriptsModule +# from modules.SaveConfig import SaveConfig as SaveConfigModule +# from modules.SortLoot import SortLoot as SortLootModule +from modules.TimedSpells import TimedSpells as TimedSpellsModule SETTED_VARIABLES = False @@ -46,6 +49,7 @@ RingPositions = [0, 0, 0, 0] StatsPositions = [0, 0, 0, 0] HealthLocation = [0, 0] +MainContainerPositions = [0, 0, 0, 0] BattlePositions = [0, 0, 0, 0] AmuletPositions = [0, 0, 0, 0] SQMs = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] @@ -55,9 +59,43 @@ ContainersNamePath = None CavebotScriptsPath = None +ScanningHPMP = False +ModulesWatchingHPMP = [] + +Life = 100 +Mana = 100 + class root: def __init__(self, CharName, LoadedJson): + self.ThreadManager = ThreadManager("ThreadRoot") + + def SetScanningHPMP(module_name, set_to='off'): + global ScanningHPMP + global ModulesWatchingHPMP + + if set_to == 'on': + print(f'Module {module_name} started watching HP/MP') + + if ScanningHPMP == False: + self.ThreadManager.NewThread(ScanHPMP) + ModulesWatchingHPMP.append(module_name) + + ScanningHPMP = True + else: + print(f"Module {module_name} is no longer watching HP/MP") + + if len(ModulesWatchingHPMP) == 1: + self.ThreadManager.StopThread() + ModulesWatchingHPMP.remove(module_name) + + ScanningHPMP = False + + def ScanHPMP(): + global Life, Mana + while ScanningHPMP: + Life, Mana = ScanBars(HealthLocation, ManaLocation) + self.root = GUI('root', 'TibiaAuto V12') self.root.MainWindow('Main', [357, 530], [2, 2.36]) self.root.deiconify() @@ -65,41 +103,64 @@ def __init__(self, CharName, LoadedJson): self.root.addMinimalLabel(f'Logged as: {CharName}', [14, 14]) # regions Buttons - - self.root.addButton('Healer Friend', OpenHealerFriend, [92, 23], [23, 56]).configure(state='disabled') - self.root.addButton('Color Change', OpenColorChange, [92, 23], [23, 108]).configure(state='disabled') - self.root.addButton('Ammo Restack', OpenAmmoRestack, [92, 23], [23, 135]).configure(state='disabled') - self.root.addButton('Auto Looter', OpenAutoLooter, [92, 23], [23, 160]).configure(state='disabled') + self.root.addButton('Healer Friend', OpenHealerFriend, [ + 92, 23], [23, 56]).configure(state='disabled') + self.root.addButton('Color Change', OpenColorChange, [92, 23], [ + 23, 108]).configure(state='disabled') + self.root.addButton('Ammo Restack', OpenAmmoRestack, [92, 23], [ + 23, 135]).configure(state='disabled') + self.root.addButton('Auto Looter', OpenAutoLooter, [92, 23], [ + 23, 160]).configure(state='disabled') self.root.addButton('Food Eater', OpenFoodEater, [92, 23], [23, 210]) - self.root.addButton('Auto Grouping', OpenAutoGrouping, [92, 23], [23, 236]).configure(state='disabled') - self.root.addButton('Sort Loot', OpenSortLoot, [92, 23], [23, 262]).configure(state='disabled') - self.root.addButton('Auto Banker', OpenAutoBanker, [92, 23], [23, 288]).configure(state='disabled') - self.root.addButton('Auto Seller', OpenAutoSeller, [92, 23], [23, 340]).configure(state='disabled') - self.root.addButton('FPS Changer', OpenFPSChanger, [92, 23], [23, 366]).configure(state='disabled') - - self.root.addButton('Auto Life', OpenAutoHeal, [92, 23], [147, 56]) - self.root.addButton('Auto Hur', OpenAutoHur, [92, 23], [245, 56]) - self.root.addButton('Auto Mana', OpenAutoMana, [92, 23], [147, 83]) - self.root.addButton('Auto Fish', OpenAutoFish, [92, 23], [245, 83]).configure(state='disabled') + self.root.addButton('Auto Grouping', OpenAutoGrouping, [92, 23], [ + 23, 236]).configure(state='disabled') + self.root.addButton('Sort Loot', OpenSortLoot, [92, 23], [ + 23, 262]).configure(state='disabled') + self.root.addButton('Auto Banker', OpenAutoBanker, [92, 23], [ + 23, 288]).configure(state='disabled') + self.root.addButton('Auto Seller', OpenAutoSeller, [92, 23], [ + 23, 340]).configure(state='disabled') + self.root.addButton('FPS Changer', OpenFPSChanger, [92, 23], [ + 23, 366]).configure(state='disabled') + + self.root.addButton('Auto Heal', lambda: OpenAutoHeal( + SetScanningHPMP), [92, 23], [147, 56]) + self.root.addButton('Auto Hur', lambda: OpenAutoHur( + SetScanningHPMP), [92, 23], [245, 56]) + self.root.addButton('Auto Gold', OpenAutoExchangeGold, [ + 92, 23], [147, 83]) + self.root.addButton('Auto Fish', OpenAutoFish, [92, 23], [ + 245, 83]).configure(state='disabled') self.root.addButton('Auto Amulet', OpenAutoSSA, [92, 23], [147, 108]) self.root.addButton('Auto Ring', OpenAutoRing, [92, 23], [245, 108]) - self.root.addButton('Timed Spells', OpenTimedSpells, [92, 23], [147, 135]) - self.root.addButton('Auto Login', OpenAutoLogin, [92, 23], [245, 135]).configure(state='disabled') - - self.root.addButton('Creature Info', OpenCreatureInfo, [92, 23], [147, 188]).configure(state='disabled') - self.root.addButton('Monsters', OpenMonsters, [92, 23], [245, 188]).configure(state='disabled') - - self.root.addButton('Show Map', OpenShowMap, [92, 23], [147, 290]).configure(state='disabled') + self.root.addButton('Timed Spells', OpenTimedSpells, [ + 92, 23], [147, 135]) + self.root.addButton('Auto Login', OpenAutoLogin, [92, 23], [ + 245, 135]).configure(state='disabled') + + self.root.addButton('Creature Info', OpenCreatureInfo, [92, 23], [ + 147, 188]).configure(state='disabled') + self.root.addButton('Monsters', OpenMonsters, [92, 23], [ + 245, 188]).configure(state='disabled') + + self.root.addButton('Show Map', OpenShowMap, [92, 23], [ + 147, 290]).configure(state='disabled') self.root.addButton('Cave Bot', OpenCaveBot, [92, 23], [245, 290]) - self.root.addButton('Load Config', OpenLoadConfig, [92, 23], [147, 340]).configure(state='disabled') - self.root.addButton('Save Config', OpenSaveConfig, [92, 23], [245, 340]).configure(state='disabled') - self.root.addButton('Adjust Config', OpenAdjustConfig, [92, 23], [147, 366]).configure(state='disabled') - self.root.addButton('Modules', OpenModules, [92, 23], [245, 366]).configure(state='disabled') - self.root.addButton('Python Scripts', OpenPythonScripts, [92, 23], [245, 392]).configure(state='disabled') + self.root.addButton('Load Config', OpenLoadConfig, [92, 23], [ + 147, 340]).configure(state='disabled') + self.root.addButton('Save Config', OpenSaveConfig, [92, 23], [ + 245, 340]).configure(state='disabled') + self.root.addButton('Adjust Config', OpenAdjustConfig, [92, 23], [ + 147, 366]).configure(state='disabled') + self.root.addButton('Modules', OpenModules, [92, 23], [ + 245, 366]).configure(state='disabled') + self.root.addButton('Python Scripts', OpenPythonScripts, [ + 92, 23], [245, 392]).configure(state='disabled') - self.root.addButton('General Options', OpenGeneralOptions, [213, 23], [134, 426]).configure(state='disabled') + self.root.addButton('General Options', OpenGeneralOptions, [ + 213, 23], [134, 426]).configure(state='disabled') def Exit(): print("Exiting...") @@ -135,6 +196,11 @@ def SetVariablesFromLoadedJson(): if data['Positions']['ManaPosition'][0]['Stats']: ManaLocation[0] = data['Positions']['ManaPosition'][0]['x'] ManaLocation[1] = data['Positions']['ManaPosition'][0]['y'] + if data['Boxes']['MainContainerBox'][0]['Stats']: + MainContainerPositions[0] = data['Boxes']['MainContainerBox'][0]['x'] + MainContainerPositions[1] = data['Boxes']['MainContainerBox'][0]['y'] + MainContainerPositions[2] = data['Boxes']['MainContainerBox'][0]['w'] + MainContainerPositions[3] = data['Boxes']['MainContainerBox'][0]['h'] if data['Boxes']['BattleBox'][0]['Stats']: BattlePositions[0] = data['Boxes']['BattleBox'][0]['x'] - 3 BattlePositions[1] = data['Boxes']['BattleBox'][0]['y'] - 3 @@ -168,9 +234,9 @@ def SetVariablesFromLoadedJson(): Player[0] = data['Positions']['PlayerPosition'][0]['x'] Player[1] = data['Positions']['PlayerPosition'][0]['y'] if data['SQM']['SQM1'][0]['Stats'] and data['SQM']['SQM2'][0]['Stats'] and data['SQM']['SQM3'][0][ - 'Stats'] and data['SQM']['SQM4'][0]['Stats'] and data['SQM']['SQM5'][0]['Stats'] and data['SQM'][ - 'SQM6'][0]['Stats'] and data['SQM']['SQM7'][0]['Stats'] and data['SQM']['SQM8'][0][ - 'Stats'] and data['SQM']['SQM9'][0]['Stats']: + 'Stats'] and data['SQM']['SQM4'][0]['Stats'] and data['SQM']['SQM5'][0]['Stats'] and data['SQM'][ + 'SQM6'][0]['Stats'] and data['SQM']['SQM7'][0]['Stats'] and data['SQM']['SQM8'][0][ + 'Stats'] and data['SQM']['SQM9'][0]['Stats']: SQMs[0] = data['SQM']['SQM1'][0]['x'] SQMs[1] = data['SQM']['SQM1'][0]['y'] SQMs[2] = data['SQM']['SQM2'][0]['x'] @@ -242,12 +308,16 @@ def OpenAutoGrouping(): # AutoGrouping(root) -def OpenAutoHeal(): - AutoHeal(HealthLocation, MOUSE_OPTION) +def OpenAutoExchangeGold(): + AutoExchangeGoldModule(MainContainerPositions, MOUSE_OPTION) -def OpenAutoHur(): - AutoHur(StatsPositions, MOUSE_OPTION) +def OpenAutoHeal(set_scanning_hpmp): + AutoHealModule(set_scanning_hpmp, MOUSE_OPTION) + + +def OpenAutoHur(set_scanning_hpmp): + AutoHurModule(StatsPositions, set_scanning_hpmp, MOUSE_OPTION) def OpenAutoLogin(): @@ -260,12 +330,9 @@ def OpenAutoLooter(): # AutoLooter(Player, SQMs) -def OpenAutoMana(): - AutoMana(ManaLocation, MOUSE_OPTION) - - def OpenAutoRing(): - AutoRing(root, RingPositions, HealthLocation, MOUSE_OPTION, ItemsPath) + AutoRingModule(root, RingPositions, HealthLocation, + MOUSE_OPTION, ItemsPath) def OpenAutoSeller(): @@ -274,11 +341,12 @@ def OpenAutoSeller(): def OpenAutoSSA(): - AutoSSA(root, AmuletPositions, HealthLocation, MOUSE_OPTION, ItemsPath) + AutoSSAModule(root, AmuletPositions, HealthLocation, + MOUSE_OPTION, ItemsPath) def OpenCaveBot(): - CaveBot(MapPositions, BattlePositions, SQMs, MOUSE_OPTION) + CaveBotModule(MapPositions, BattlePositions, SQMs, MOUSE_OPTION) def OpenColorChange(): @@ -292,7 +360,7 @@ def OpenCreatureInfo(): def OpenFoodEater(): - FoodEater(root, StatsPositions, MOUSE_OPTION) + FoodEaterModule(root, StatsPositions, MOUSE_OPTION) def OpenFPSChanger(): @@ -341,6 +409,6 @@ def OpenSortLoot(): def OpenTimedSpells(): - TimedSpells(root, MOUSE_OPTION) + TimedSpellsModule(root, MOUSE_OPTION) # endregion diff --git a/modules/TimedSpells.py b/modules/TimedSpells.py index e146cd9..2b2c599 100644 --- a/modules/TimedSpells.py +++ b/modules/TimedSpells.py @@ -14,7 +14,7 @@ from core.ThreadManager import ThreadManager -from engine.ScanFood import scan_food +from engine.Scanners.ScanFood import scan_food class TimedSpells: @@ -43,11 +43,13 @@ def __init__(self, root, MOUSE_OPTION): def trigger(self): if TimedSpells.enabled: TimedSpells.enabled = False - self.enabled_button.configure(text='TimedSpells: OFF', relief=RAISED, bg=rgb((127, 17, 8))) + self.enabled_button.configure( + text='TimedSpells: OFF', relief=RAISED, bg=rgb((127, 17, 8))) self.pause() else: TimedSpells.enabled = True - self.enabled_button.configure(text='TimedSpells: ON', relief=SUNKEN, bg=rgb((158, 46, 34))) + self.enabled_button.configure( + text='TimedSpells: ON', relief=SUNKEN, bg=rgb((158, 46, 34))) self.run() self.check() @@ -66,7 +68,7 @@ def run(self): print('TimedSpells: ON') def pause(self): - self.ThreadManager.PauseThread() + self.ThreadManager.StopThread() print('TimedSpells: OFF') def execute(self): @@ -96,9 +98,12 @@ def execute(self): sleep(1) def destroy(self): - check_gui(TimedSpells.gui_changes, self.init_check_print, self.check_print.get(), 'CheckPrint') - check_gui(TimedSpells.gui_changes, self.init_instant, self.check_instant.get(), 'InstantExecute') - check_gui(TimedSpells.gui_changes, self.init_food_hotkey, self.food_hotkey.get(), 'Hotkey') + check_gui(TimedSpells.gui_changes, self.init_check_print, + self.check_print.get(), 'CheckPrint') + check_gui(TimedSpells.gui_changes, self.init_instant, + self.check_instant.get(), 'InstantExecute') + check_gui(TimedSpells.gui_changes, self.init_food_hotkey, + self.food_hotkey.get(), 'Hotkey') spells = [] @@ -121,10 +126,14 @@ def destroy(self): self.window.destroyWindow() def gui_vars(self): - self.check_print, self.init_check_print = self.Setter.Variables.Bool('CheckPrint') - self.check_instant, self.init_instant = self.Setter.Variables.Bool('InstantExecute') - self.food_hotkey, self.init_food_hotkey = self.Setter.Variables.Str('Hotkey') - self.cast_every, self.init_cast_every = self.Setter.Variables.Str('CastEvery') + self.check_print, self.init_check_print = self.Setter.Variables.Bool( + 'CheckPrint') + self.check_instant, self.init_instant = self.Setter.Variables.Bool( + 'InstantExecute') + self.food_hotkey, self.init_food_hotkey = self.Setter.Variables.Str( + 'Hotkey') + self.cast_every, self.init_cast_every = self.Setter.Variables.Str( + 'CastEvery') self.spells, self.init_spells = self.Setter.Variables.array('Spells') def validate_cast_every(self, *args): @@ -162,17 +171,22 @@ def add_item(self): def gui(self): self.label = self.window.addLabel('Hotkey to press', [40, 45]) - self.hotkey_button = self.window.addOption(self.food_hotkey, self.SendToClient.Hotkeys, [145, 40], 10) + self.hotkey_button = self.window.addOption( + self.food_hotkey, self.SendToClient.Hotkeys, [145, 40], 10) self.label2 = self.window.addLabel('Cast every', [40, 75]) self.label3 = self.window.addLabel('seconds', [230, 75]) - self.entry_cast_every = self.window.addEntry([145, 75], self.cast_every, 12) + self.entry_cast_every = self.window.addEntry( + [145, 75], self.cast_every, 12) self.cast_every.trace("w", self.validate_cast_every) - self.add_button = self.window.addButton('Add', self.add_item, [75, 23], [70, 110]) - self.remove_button = self.window.addButton('Remove', self.remove_item, [75, 23], [170, 110]) + self.add_button = self.window.addButton( + 'Add', self.add_item, [75, 23], [70, 110]) + self.remove_button = self.window.addButton( + 'Remove', self.remove_item, [75, 23], [170, 110]) - self.table = self.window.addList(('hotkey', 'time'), 8, [230, 100], [40, 150]) + self.table = self.window.addList( + ('hotkey', 'time'), 8, [230, 100], [40, 150]) self.table.column('hotkey', width=115) self.table.column('time', anchor=CENTER, width=115) @@ -202,12 +216,15 @@ def gui(self): selectcolor=rgb((114, 94, 48))) if not TimedSpells.enabled: - self.enabled_button = self.window.addButton('TimedSpells: OFF', self.trigger, [287, 23], [11, 411]) + self.enabled_button = self.window.addButton( + 'TimedSpells: OFF', self.trigger, [287, 23], [11, 411]) else: - self.enabled_button = self.window.addButton('TimedSpells: ON', self.trigger, [287, 23], [11, 411]) + self.enabled_button = self.window.addButton( + 'TimedSpells: ON', self.trigger, [287, 23], [11, 411]) self.enabled_button.configure(relief=SUNKEN, bg=rgb((158, 46, 34))) - self.ok_button = self.window.addButton('Ok', self.destroy, [73, 21], [115, 440]) + self.ok_button = self.window.addButton( + 'Ok', self.destroy, [73, 21], [115, 440]) def check(self): if TimedSpells.enabled: diff --git a/modules/__init__.py b/modules/__init__.py index 8243aab..62abf42 100644 --- a/modules/__init__.py +++ b/modules/__init__.py @@ -1,10 +1,7 @@ """ starts the selection page to choose window of capture """ - -import time import os -import threading from core.GUI import * from conf.conf_manager import ConfManager @@ -67,21 +64,37 @@ def bootstrap(): if conf['preferences_name'] is None: conf['preferences_name'] = 'NewConfig.json' - conf['hwnd'] = list(titles.keys())[list(titles.values()).index(selected_window.get())] + conf['hwnd'] = list(titles.keys())[list( + titles.values()).index(selected_window.get())] ConfManager.set(conf, 'conf.json') window.destroy() if not conf['configured']: - ChooseConfig(selected_window.get()) + ChooseConfig(selected_window.get(), conf['hwnd']) return root(selected_window.get(), conf['preferences_name']) + sorted_windows = {} + + for el in titles.items(): + if(el[0] == conf['hwnd']): + sorted_windows.update({el[0]: el[1]}) + + for el in titles.items(): + if(el[1].upper().__contains__('TIBIA')): + sorted_windows.update({el[0]: el[1]}) + + sorted_windows.update(titles.items()) + selected_window = tk.StringVar() - selected_window.set(list(titles.values())[1]) + selected_window.set(list(sorted_windows.values())[0]) + + select_window_list = tk.OptionMenu( + window, selected_window, *list(sorted_windows.values()), - select_window_list = tk.OptionMenu(window, selected_window, *list(titles.values())) + ) select_window_list.configure(anchor='w') select_window_list.pack() select_window_list.place(w=230, h=24, x=15, y=17) diff --git a/scripts/GUILoader.json b/scripts/GUILoader.json index ec148ef..e2ceed2 100644 --- a/scripts/GUILoader.json +++ b/scripts/GUILoader.json @@ -1,11 +1,14 @@ { "Loaders": { - "HealthLoader": { + "HealLoader": { "CheckPrint": false, "CheckBuff": false, "LifeCheckStageOne": true, "LifeCheckStageTwo": true, "LifeCheckStageThree": false, + "LifeCheckStageFour": false, + "LifeCheckStageFive": false, + "LifeCheckStageSix": false, "CheckCureStats": false, "CheckParalyze": false, "CheckPoison": false, @@ -13,30 +16,37 @@ "CheckElectrify": false, "CheckMort": false, "CheckBlood": false, - "LifePercentageStageOne": 85, - "LifeHotkeyStageOne": "F1", - "LifePercentageStageTwo": 60, - "LifeHotkeyStageTwo": "F2", - "LifePercentageStageThree": 55, - "LifeHotkeyStageThree": "F2", + "TypeStageOne": "Life", + "LifePercentageStageOne": 75, + "LifeHotkeyStageOne": "F12", + "TypeStageTwo": "Mana", + "LifePercentageStageTwo": 80, + "LifeHotkeyStageTwo": "F9", + "TypeStageThree": "Life", + "LifePercentageStageThree": 75, + "LifeHotkeyStageThree": "F12", + "TypeStageFour": "Life", + "LifePercentageStageFour": 90, + "LifeHotkeyStageFour": "F11", + "TypeStageFive": "Life", + "LifePercentageStageFive": 95, + "LifeHotkeyStageFive": "F11", + "TypeStageSix": "Life", + "LifePercentageStageSix": 70, + "LifeHotkeyStageSix": "Ctrl + F3", "HotkeyStageTwo": "Ctrl + F1" }, - "ManaLoader": { + "ExchangeGoldLoader": { "CheckPrint": false, - "CheckBuff": false, - "ManaCheckStageOne": true, - "ManaCheckStageTwo": false, - "ManaPercentageStageOne": 70, - "ManaHotkeyStageOne": "F3", - "ManaPercentageStageTwo": 45, - "ManaHotkeyStageTwo": "F3", - "CheckLowMana": false + "MainContainerName": "Bag" }, "HurLoader": { "CheckPrint": false, "CheckBuff": false, - "HotkeyHur": "F6", - "CheckLowMana": false, + "CheckPZ": true, + "HotkeyHur": "F3", + "CheckLowMana": true, + "ManaLessThan": 80, "CheckStageOne": true }, "AmuletLoader": { diff --git a/scripts/Json.json b/scripts/Json.json index be23569..4d43708 100644 --- a/scripts/Json.json +++ b/scripts/Json.json @@ -40,6 +40,15 @@ ] }, "Boxes": { + "MainContainerBox": [ + { + "x": 0, + "y": 0, + "w": 156, + "h": 198, + "Stats": false + } + ], "StatusBarBox": [ { "x": 0,