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

Contato #108

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions conf/Constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 4 additions & 0 deletions conf/Hotkeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
32 changes: 20 additions & 12 deletions core/GUI.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
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):
self.windowID = windowID
self.name = name

def MainWindow(self, BackgroundImage, sizes, positions):
global MainWindow

self.windowID = tk.Tk()
w = sizes[0]
h = sizes[1]
Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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()

Expand Down
82 changes: 61 additions & 21 deletions core/Getters.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
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]
Player = [0, 0]
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

Expand All @@ -31,36 +40,43 @@ 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")
return -1, -1, -1, -1


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
Expand All @@ -71,35 +87,58 @@ 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])
GameWindow[1] = int(LeftGameWindow[1])
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:
Expand All @@ -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")
Expand Down Expand Up @@ -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[
Expand Down
Loading