Open DouglasSMartins opened 2 years ago
quando eu fiz o modulo de ring, o energy ring era da maneira antiga ainda kkk, mas da pra fazer isso sim, seria bem massa.
Ah saquei, por isso então kkk.
Poise, essa melhoria seria bem bacana, o ring em alguns casos é pra te salvar, mas depois que salvou ele pode desequipar, ficaria bem massa.
Salve meu mano @MuriloChianfa
Talvez não seja a melhor forma de ter sido implementado, até porque sou da área de infra, não manjo tanto de programação, mexo de teimoso mesmo kkkk, mas acho que consegui fazer essa melhoria, fiz vários testes e pra mim funcionou muito bem.
O que eu fiz foi jogar mais pra esquerda o Life <= e adicionei do lado um Life >= para quando ele deve remover. Implementei também as variáveis e verificações, e agora ele está equipando e desequipando de acordo com a configuração.
Segue o código pra quem quiser testar e para você commitar no projeto se passar nos seus testes e você ver que está bom xD
GUILoarder.json
"RingLoader": { "CheckPrint": false, "CheckBuff": false, "RadioButton": 0, "NameRing": "EnergyRing", "HotkeyRing": "F2", "TextEntryX": "0", "TextEntryY": "0", "LifeBellowThan": true, "LifeAboveThan": true, "BellowThan": 90, "AboveThan": 95, "CheckStageOne": true
AutoRing.py
import time import keyboard import pygetwindow
from conf.Hotkeys import Hotkey from conf.Constants import LifeColor, LifeColorFull, Percentage, Rings
from core.GUI import from core.GUIManager import from core.GUISetter import GUISetter from core.ThreadManager import ThreadManager
from engine.ScanRing import ScanRing
GUIChanges = []
FoundedImg = False EnabledAutoRing = False WaitingForClick = False ThreadStarted = False
Ring = 'MightRing' RingLocate = [0, 0] MaxLen = 4 RingsPath = None
class AutoRing: def init(self, root, RingPositions, HealthLocation, MOUSE_OPTION, ItemsPath): self.AutoRing = GUI('AutoRing', 'Module: Auto Ring') self.AutoRing.DefaultWindow('AutoRing', [306, 397], [1.2, 2.29]) self.Setter = GUISetter("RingLoader") self.SendToClient = Hotkey(MOUSE_OPTION) self.ThreadManager = ThreadManager("ThreadAutoRing")
def SetAutoRing():
global EnabledAutoRing
if not EnabledAutoRing:
EnabledAutoRing = True
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()
else:
EnabledAutoRing = False
print('AutoRing: OFF')
ButtonEnabled.configure(text='AutoRing: OFF', relief=RAISED, bg=rgb((127, 17, 8)))
Checking()
CheckingButtons()
self.ThreadManager.PauseThread()
def ScanAutoRing():
global Ring
Ring = NameRing.get()
if CheckLifeBellowThan.get():
BellowThan = LifeBellowThan.get()
AboveThan = LifeAboveThan.get()
from modules.AutoHeal import EnabledAutoHeal
if EnabledAutoHeal:
while EnabledAutoRing and EnabledAutoHeal:
NoHasRing = ScanRing(RingPositions)
from modules.AutoHeal import Life
if NoHasRing and Life <= BellowThan:
Execute()
elif not NoHasRing and Life >= AboveThan:
Execute()
else:
from engine.ScanStages import ScanStages
while EnabledAutoRing:
Life = ScanStages('Life From AutoRing').ScanStages(HealthLocation, LifeColor, LifeColorFull)
if Life is None:
Life = 0
NoHasRing = ScanRing(RingPositions)
if NoHasRing and Life <= BellowThan:
Execute()
elif not NoHasRing and Life >= AboveThan:
Execute()
else:
while EnabledAutoRing:
NoHasRing = ScanRing(RingPositions)
if NoHasRing:
Execute()
def Execute():
if RadioButton.get() == 0:
self.SendToClient.Press(HotkeyRing.get())
print("Pressed ", HotkeyRing.get(), " To Reallocated Your Ring")
time.sleep(1)
elif RadioButton.get() == 1:
try:
X = int(TextEntryX.get())
Y = int(TextEntryY.get())
except Exception:
X = None
Y = None
print("Error To Get Type Of Position")
time.sleep(1)
if X and Y is not None:
if X < WidthScreen and Y < HeightScreen:
if MOUSE_OPTION == 1:
MousePosition = self.SendToClient.Position()
else:
MousePosition = [0, 0]
self.SendToClient.DragTo([X, Y], [RingPositions[0] + 16, RingPositions[1] + 16])
if MOUSE_OPTION == 1:
self.SendToClient.MoveTo(MousePosition[0], MousePosition[1])
print("Ring Reallocated On: X =", RingPositions[0] + 16, "Y =", RingPositions[1] + 16,
"From: X =",
X, "Y =", Y)
time.sleep(0.3)
else:
print("Lower Resolution Than Entered")
time.sleep(1)
def Recapture():
global WaitingForClick, Ring
WaitingForClick = True
Ring = NameRing.get()
AutoRingWindow = pygetwindow.getWindowsWithTitle("Module: Auto Ring")[0]
TibiaAuto = pygetwindow.getWindowsWithTitle("TibiaAuto V12")[0]
AutoRingWindowX = self.AutoRing.PositionOfWindow('X')
AutoRingWindowY = self.AutoRing.PositionOfWindow('Y')
time.sleep(0.1)
TibiaAuto.minimize()
AutoRingWindow.minimize()
Invisible = GUI('InvisibleWindow', 'InvisibleWindow')
Invisible.InvisibleWindow('Recapture')
while WaitingForClick:
X, Y = GetPosition()
if keyboard.is_pressed("c"):
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))
WaitingForClick = False
Invisible.destroyWindow()
TibiaAuto.maximize()
time.sleep(0.04)
AutoRingWindow.maximize()
AutoRingWindow.moveTo(AutoRingWindowX, AutoRingWindowY)
UpdateImg()
break
Invisible.UpdateWindow(X, Y)
def AddNewAmulet():
print('Option In Development...')
def CheckClick():
Checking()
def ReturnGetPosition():
global WaitingForClick
WaitingForClick = True
AutoRingWindow = pygetwindow.getWindowsWithTitle("Module: Auto Ring")[0]
TibiaAuto = pygetwindow.getWindowsWithTitle("TibiaAuto V12")[0]
AutoRingWindowX = self.AutoRing.PositionOfWindow('X')
AutoRingWindowY = self.AutoRing.PositionOfWindow('Y')
time.sleep(0.1)
TibiaAuto.minimize()
AutoRingWindow.minimize()
Invisible = GUI('InvisibleWindow', 'InvisibleWindow')
Invisible.InvisibleWindow('GetPosition')
while WaitingForClick:
X, Y = GetPosition()
if keyboard.is_pressed("c"):
X, Y = GetPosition()
WaitingForClick = False
print(f"Your Click Is Located In: [X: {X}, Y: {Y}]")
TextEntryX.set(X)
TextEntryY.set(Y)
Invisible.destroyWindow()
TibiaAuto.maximize()
time.sleep(0.08)
AutoRingWindow.maximize()
AutoRingWindow.moveTo(AutoRingWindowX, AutoRingWindowY)
break
Invisible.UpdateWindow(X, Y)
def ValidateEntryX(*args):
s = TextEntryX.get()
if len(s) > MaxLen:
if not s[-1].isdigit():
TextEntryX.set(s[:-1])
else:
TextEntryX.set(s[:MaxLen])
def ValidateEntryY(*args):
s = TextEntryY.get()
if len(s) > MaxLen:
if not s[-1].isdigit():
TextEntryY.set(s[:-1])
else:
TextEntryY.set(s[:MaxLen])
VarCheckPrint, InitiatedCheckPrint = self.Setter.Variables.Bool('CheckPrint')
VarCheckBuff, InitiatedCheckBuff = self.Setter.Variables.Bool('CheckBuff')
RadioButton, InitiatedRadioButton = self.Setter.Variables.Int('RadioButton')
NameRing, InitiatedNameRing = self.Setter.Variables.Str('NameRing')
HotkeyRing, InitiatedHotkeyRing = self.Setter.Variables.Str('HotkeyRing')
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')
CheckLifeAboveThan, InitiatedLifeAboveThan = self.Setter.Variables.Bool('LifeAboveThan')
LifeAboveThan, InitiatedAboveThan = self.Setter.Variables.Int('AboveThan')
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(InitiatedRadioButton, RadioButton.get(), 'RadioButton')
CheckingGUI(InitiatedNameRing, NameRing.get(), 'NameRing')
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(InitiatedLifeAboveThan, CheckLifeAboveThan.get(), 'LifeAboveThan')
CheckingGUI(InitiatedAboveThan, LifeAboveThan.get(), 'AboveThan')
if len(GUIChanges) != 0:
for EachChange in range(len(GUIChanges)):
self.Setter.SetVariables.SetVar(GUIChanges[EachChange][0], GUIChanges[EachChange][1])
self.AutoRing.destroyWindow()
self.AutoRing.addButton('Ok', Destroy, [73, 21], [115, 365])
global EnabledAutoRing
if not EnabledAutoRing:
ButtonEnabled = self.AutoRing.addButton('AutoRing: OFF', SetAutoRing, [287, 23], [11, 336])
else:
ButtonEnabled = self.AutoRing.addButton('AutoRing: ON', SetAutoRing, [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)))
BackImage = 'images/Fundo.png'
Back = self.AutoRing.openImage(BackImage, [150, 45])
RingImages = []
RingName = []
for NameOfCurrentRing in Rings:
CurrentRingName = ItemsPath + 'Rings/' + NameOfCurrentRing + '.png'
CurrentRingImage = self.AutoRing.openImage(CurrentRingName, [64, 64])
RingImages.append(CurrentRingImage)
RingName.append(NameOfCurrentRing)
ImgLabel = self.AutoRing.addLabel('Image To Search', [16, 22])
def UpdateImg():
for XRing in Rings:
if NameRing.get() == XRing:
self.AutoRing.addImage(RingImages[RingName.index(XRing)], [28, 43])
global Ring
Ring = NameRing.get()
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)
ButtonAddNewRing = self.AutoRing.addButton('Add New Ring', AddNewAmulet, [167, 24], [120, 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)
CheckBoxLifeBellowThan = self.AutoRing.addCheck(CheckLifeBellowThan, [40, 210], InitiatedLifeBellowThan,
'Use Only If Life Is Bellow and Above Than')
LabelLifeBellowThan = self.AutoRing.addLabel('Life <= ', [26, 245])
LabelLifeAboveThan = self.AutoRing.addLabel('Life >= ', [160, 245])
PercentageLifeBellowThan = self.AutoRing.addOption(LifeBellowThan, Percentage, [76, 240])
PercentageLifeAboveThan = self.AutoRing.addOption(LifeAboveThan, Percentage, [210, 240])
def Checking():
global FoundedImg, Ring
if RadioButton.get() == 0:
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)
if EnabledAutoRing:
Disable(HotkeyOption)
else:
Enable(HotkeyOption)
elif RadioButton.get() == 1:
DescLabel.configure(text='Position To Search')
self.AutoRing.addImage(Back, [120, 165])
FoundedImg = False
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)
TextEntryX.trace("w", ValidateEntryX)
LabelY = self.AutoRing.addLabel('Y:', [135, 185])
EntryY = self.AutoRing.addEntry([150, 185], TextEntryY, width=4)
TextEntryY.trace("w", ValidateEntryY)
if EnabledAutoRing:
Disable(ButtonGetPosition)
Disable(LabelX)
Disable(EntryX)
Disable(LabelY)
Disable(EntryY)
else:
Enable(ButtonGetPosition)
Enable(LabelX)
Enable(EntryX)
Enable(LabelY)
Enable(EntryY)
if not CheckLifeBellowThan.get():
Disable(LabelLifeBellowThan)
Disable(PercentageLifeBellowThan)
Disable(LabelLifeAboveThan)
Disable(PercentageLifeAboveThan)
elif CheckLifeBellowThan.get():
Enable(LabelLifeBellowThan)
Enable(PercentageLifeBellowThan)
Enable(LabelLifeAboveThan)
Enable(PercentageLifeAboveThan)
ExecGUITrigger()
def CheckingButtons():
if EnabledAutoRing:
Disable(CheckPrint)
Disable(CheckBuff)
Disable(DescLabel)
Disable(ImgLabel)
Disable(ButtonRecapture)
Disable(ButtonAddNewRing)
Disable(RButton1)
Disable(RButton2)
Disable(RingLabel)
Disable(OptionNameRing)
Disable(CheckBoxLifeBellowThan)
Disable(LabelLifeBellowThan)
Disable(PercentageLifeBellowThan)
Disable(LabelLifeAboveThan)
Disable(PercentageLifeAboveThan)
else:
Enable(CheckPrint)
Enable(CheckBuff)
Enable(DescLabel)
Enable(ImgLabel)
Enable(ButtonRecapture)
Enable(ButtonAddNewRing)
Enable(RButton1)
Enable(RButton2)
Enable(RingLabel)
Enable(OptionNameRing)
Enable(CheckBoxLifeBellowThan)
if not CheckLifeBellowThan.get():
Disable(LabelLifeBellowThan)
Disable(PercentageLifeBellowThan)
Disable(LabelLifeAboveThan)
Disable(PercentageLifeAboveThan)
elif CheckLifeBellowThan.get():
Enable(LabelLifeBellowThan)
Enable(PercentageLifeBellowThan)
Enable(LabelLifeAboveThan)
Enable(PercentageLifeAboveThan)
ExecGUITrigger()
def ConstantVerify():
if not EnabledAutoRing:
if not CheckLifeBellowThan.get():
Disable(LabelLifeBellowThan)
Disable(PercentageLifeBellowThan)
Disable(LabelLifeAboveThan)
Disable(PercentageLifeAboveThan)
elif CheckLifeBellowThan.get():
Enable(LabelLifeBellowThan)
Enable(PercentageLifeBellowThan)
Enable(LabelLifeAboveThan)
Enable(PercentageLifeAboveThan)
if NameRing.get() != Ring:
UpdateImg()
ExecGUITrigger()
self.AutoRing.After(200, ConstantVerify)
Checking()
CheckingButtons()
ConstantVerify()
self.AutoRing.Protocol(Destroy)
self.AutoRing.loop()
Esbarrei com um problema nos testes que ainda to pensando em como resolver, se eu quiser usar outro ring não da.
Exemplo: To na hunt usando dwarven ring, e quero que quando fique fudido ele equipe o energy ring pra se curar e depois volte pro dwarven ou só tire.
Ele não está deixando da forma que implementei, se eu equipo o dwarven ring, ele equipa o energy e depois retira porque viu que a vida esta dentro do >=
Vou seguir testando e tentando fazer, se tiver algum resultado posto, de toda forma, assim já funciona parcialmente conforme a ideia que eu dei xD
A funcionalidade é muito bacana, mas acho que pra ficar perfeito, faltava uma configuração, a de quando remover o ring.
Exemplo, eu configuro para quando chegar em 30% de vida ele equipar o energy ring, porem não queria que fique pra sempre equipado, quando o bot conseguir curar a vida e ela tiver em por exemplo, 50% ou mais ele desequipe o ring, para voltar a tomar dano na vida, no caso ele equiparia o ring para segurar a porrada enquanto cura a vida.
Seria possivel algo assim? Acredito que agregaria mais ainda ao bot.