def GetHealthPosition(): HealthPositions = LocateCenterImage('images/PlayerSettings/health.png', Precision=0.8) if HealthPositions[0] != 0 and HealthPositions[1] != 0: return HealthPositions[0], HealthPositions[1] else: return 0, 0
def GetAccountNamePosition(): AccountName = LocateCenterImage('images/TibiaSettings/AccountName.png', Precision=0.9) if AccountName[0] != 0 and AccountName[1] != 0: return AccountName[0], AccountName[1] else: return 0, 0
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
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
def GetBattlePosition(): BattlePositions[0], BattlePositions[1] = LocateCenterImage('images/TibiaSettings/BattleList.png', Precision=0.75) BattlePositions[0] = BattlePositions[0] - 40 BattlePositions[1] = BattlePositions[1] - 5 BattlePositions[2] = BattlePositions[0] + 155 BattlePositions[3] = BattlePositions[1] + 415 if BattlePositions[0] != 0 and BattlePositions[1] != 0: return int(BattlePositions[0]), int(BattlePositions[1]), int(BattlePositions[2]), int( BattlePositions[3]) else: return 0, 0, 0, 0
def IsAttacking(BattlePosition): X, Y = LocateCenterImage('images/MonstersAttack/RedColor1.png', Precision=0.75, Region=( BattlePosition[0], BattlePosition[1], BattlePosition[2], BattlePosition[3])) if X != 0 and Y != 0: return True else: X, Y = LocateCenterImage('images/MonstersAttack/RedColor2.png', Precision=0.80, Region=( BattlePosition[0], BattlePosition[1], BattlePosition[2], BattlePosition[3])) if X != 0 and Y != 0: return True else: X, Y = LocateCenterImage('images/MonstersAttack/RedColor3.png', Precision=0.7, Region=( BattlePosition[0], BattlePosition[1], BattlePosition[2], BattlePosition[3])) if X != 0 and Y != 0: return True else: X, Y = LocateCenterImage('images/MonstersAttack/RedColor4.png', Precision=0.75, Region=( BattlePosition[0], BattlePosition[1], BattlePosition[2], BattlePosition[3])) if X != 0 and Y != 0: return True else: return False
def ScanTarget(BattlePosition, Monster): HasTarget = [0, 0] HasTarget[0], HasTarget[1] = LocateCenterImage('images/Targets/' + Monster + '.png', Precision=0.86, Region=( BattlePosition[0], BattlePosition[1], BattlePosition[2], BattlePosition[3])) if HasTarget[0] != 0 and HasTarget[1] != 0: if HasTarget[0] < BattlePosition[0]: return (BattlePosition[0] - 30) + HasTarget[0] + 1, HasTarget[1] + BattlePosition[1] + 1 else: return (BattlePosition[0] - 40) + HasTarget[0] + 1, HasTarget[1] + BattlePosition[1] + 1 else: return 0, 0
def GetBattlePosition(): 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 else: BattlePositions[0], BattlePositions[1] = LocateImage( 'images/TibiaSettings/BattleList.png', Precision=0.85) BattlePositions[2] = BattlePositions[0] + 155 BattlePositions[3] = BattlePositions[1] + 415 return int(BattlePositions[0] + 8), int(BattlePositions[1]), int( BattlePositions[2]), int(BattlePositions[3])
def GetManaPosition(): ManaPositions = LocateCenterImage('images/PlayerSettings/mana.png', Precision=0.9) if ManaPositions[0] != 0 and ManaPositions[1] != 0: return ManaPositions[0], ManaPositions[1]
def HandleCaveBot(self, data, i, Monsters): global TargetNumber MarkLocation = [0, 0] sleep(self.TimeToStand) if not IsEnable(): return ''' Disconsider This Block If You Don't Mark The Walk Option... ''' # region Walk if self.EnabledWalk: while MarkLocation[0] == 0 and MarkLocation[1] == 0: MarkLocation[0], MarkLocation[1] = LocateCenterImage('images/MapSettings/' + data[i]["mark"] + '.png', Region=( self.MapPosition[0], self.MapPosition[1], self.MapPosition[2], self.MapPosition[3]), Precision=0.8) if MarkLocation[0] == 0 and MarkLocation[1] == 0: print("Mark: { ", data[i]["mark"], " } Not Located, Try Again") if self.WalkForRefresh: sleep(.3) self.SendToClient.Press('up_arrow') sleep(.1) self.SendToClient.Press('left_arrow') sleep(.7) self.SendToClient.Press('down_arrow') sleep(.1) self.SendToClient.Press('right_arrow') sleep(.1) else: print("successfully Located The Mark: { ", data[i]["mark"], " } Clicking On Your Position") MarkLocation[0] = self.MapPosition[0] + MarkLocation[0] MarkLocation[1] = self.MapPosition[1] + MarkLocation[1] # Clicking In Mark Position if self.MOUSE_OPTION == 1: PastPosition = self.SendToClient.Position() else: PastPosition = [0, 0] self.SendToClient.LeftClick(MarkLocation[0], MarkLocation[1]) if self.MOUSE_OPTION == 1: self.SendToClient.MoveTo(PastPosition[0], PastPosition[1]) # endregion ''' The Attack, Is Every Time Enabled. ''' # region Attack for Monster in Monsters: FirstMonstersNumber = 0 SecondMonstersNumber = 0 Number = NumberOfTargets(self.BattlePosition, Monster) # NumberOfMonster.append(Number) while Number > 0: if not IsEnable(): return self.Target = ScanTarget(self.BattlePosition, Monster) if self.Target[0] != 0 and self.Target[1] != 0: # Verify If You Are Already Attacking ! if not IsAttacking(self.BattlePosition): print("Attacking The Target") if self.MOUSE_OPTION == 1: PastPosition = self.SendToClient.Position() else: PastPosition = [0, 0] self.SendToClient.LeftClick(self.Target[0], self.Target[1]) if self.MOUSE_OPTION == 1: self.SendToClient.MoveTo(PastPosition[0], PastPosition[1]) FirstMonstersNumber = NumberOfTargets(self.BattlePosition, Monster) else: print("You are attacking") FirstMonstersNumber = NumberOfTargets(self.BattlePosition, Monster) # Control Follow Mode In Attack (Follow Or Idle) if self.FollowMode: IsNeedFollow = NeedFollow() if IsNeedFollow: print("Clicking In Follow") if self.MOUSE_OPTION == 1: PastPosition = self.SendToClient.Position() else: PastPosition = [0, 0] FollowPosition = LocateCenterImage('images/TibiaSettings/NotFollow.png', Precision=0.7) self.SendToClient.LeftClick(FollowPosition[0], FollowPosition[1]) if self.MOUSE_OPTION == 1: self.SendToClient.MoveTo(PastPosition[0], PastPosition[1]) sleep(.2) self.Target = ScanTarget(self.BattlePosition, Monster) if self.Target[0] != 0 and self.Target[1] != 0: # Verify If You Are Already Attacking ! if IsAttacking(self.BattlePosition): # For Debugging # print("Attacking The Target") if self.MOUSE_OPTION == 1: PastPosition = self.SendToClient.Position() else: PastPosition = [0, 0] self.SendToClient.LeftClick(self.Target[0], self.Target[1]) if self.MOUSE_OPTION == 1: self.SendToClient.MoveTo(PastPosition[0], PastPosition[1]) SecondMonstersNumber = NumberOfTargets(self.BattlePosition, Monster) else: # For Debugging # print("You are attacking") SecondMonstersNumber = NumberOfTargets(self.BattlePosition, Monster) if SecondMonstersNumber < FirstMonstersNumber: self.TakeLoot() self.Target = [] sleep(0.2) Number = NumberOfTargets(self.BattlePosition, Monster) if Number == 0: break if self.EnabledWalk: if CheckWaypoint(data[i]["mark"], self.MapPosition): data[i]['status'] = False if i + 1 == len(data): data[i - i]['status'] = True with open('Scripts/' + self.ScriptName + '.json', 'w') as wJson: json.dump(data, wJson, indent=4) else: data[i + 1]['status'] = True with open('Scripts/' + self.ScriptName + '.json', 'w') as wJson: json.dump(data, wJson, indent=4) else: self.HandleCaveBot(data, i, Monsters)