Code:
from BotBase import BotBase
from UIComponents import Component
import Movement, Data
import chat, ui, chr, m2netm2g, background, time, player
import OpenLib
import eXLib
import re
Mode = "Walk"
class Radar(BotBase):
def __init__(self):
BotBase.__init__(self, 0.5)
self.BuildWindow()
self.path = []
self.path2 = []
def BuildWindow(self):
self.Board = ui.BoardWithTitleBar()
self.Board.SetSize(290, 120)
self.Board.SetPosition(52, 40)
self.Board.AddFlag('movable')
self.Board.SetTitleName('Go To')
self.Board.SetCloseEvent(self.switch_state)
self.Board.Hide()
comp = Component()
#WaponsDealer
self.text_lineEditLine = comp.TextLine(self.Board, 'WeaponsNpc :', 20, 40, comp.RGB(255, 255, 255))
self.barItems, self.fileListBox_Weapons, self.ScrollBar = comp.ListBoxEx2(self.Board, 100, 40, 80, 15)
self.GoToWeapons = comp.Button(self.Board, 'Go', '', 225, 35, self.GoToWeaponsDealer,
'd:/ymir work/ui/public/small_button_01.sub',
'd:/ymir work/ui/public/small_button_02.sub',
'd:/ymir work/ui/public/small_button_03.sub')
self.GetWeaponsPos = comp.Button(self.Board, 'Get', '', 180, 35, self.get_weaponspos,
'd:/ymir work/ui/public/small_Button_01.sub',
'd:/ymir work/ui/public/small_Button_02.sub',
'd:/ymir work/ui/public/small_Button_03.sub')
#Alchemist
self.text_lineEditLine2 = comp.TextLine(self.Board, 'AlchemistNpc :', 20, 60, comp.RGB(255, 255, 255))
self.barItems2, self.fileListBox_Alchemist, self.ScrollBar = comp.ListBoxEx2(self.Board, 100, 60, 80, 15)
self.GoToAlchemist = comp.Button(self.Board, 'Go', '', 225, 55, self.GoToAlchemistDealer,
'd:/ymir work/ui/public/small_button_01.sub',
'd:/ymir work/ui/public/small_button_02.sub',
'd:/ymir work/ui/public/small_button_03.sub')
self.GetAlchemistPos = comp.Button(self.Board, 'Get', '', 180, 55, self.get_alchemistpos,
'd:/ymir work/ui/public/small_Button_01.sub',
'd:/ymir work/ui/public/small_Button_02.sub',
'd:/ymir work/ui/public/small_Button_03.sub')
self.PositionTxt = comp.TextLine(self.Board, 'Actual Position :', 20, 80, comp.RGB(255, 255, 255))
self.PositionText = ui.TextLine()
self.PositionText.SetParent(self.Board)
self.PositionText.SetFontColor(1, 1, 1)
self.PositionText.SetText("(200, 800)")
self.PositionText.SetPosition(100, 80)
self.PositionText.Show()
global Mode
self.ModeButton = ui.Button()
self.ModeButton.SetParent(self.Board)
self.ModeButtonText = comp.TextLine(self.Board, 'Mode :', 180, 80, comp.RGB(255, 255, 255))
self.ModeButton.SetUpVisual("d:/ymir work/ui/public/small_button_01.sub")
self.ModeButton.SetOverVisual("d:/ymir work/ui/public/small_button_02.sub")
self.ModeButton.SetDownVisual("d:/ymir work/ui/public/small_button_03.sub")
self.ModeButton.SetText(Mode)
self.ModeButton.SetEvent(lambda : self.ChangeMode())
self.ModeButton.SetPosition(225, 75)
self.ModeButton.Show()
x_size = 235
y_size = 100
def OnUpdate(self):
(PlayerX, PlayerY, PlayerZ) = player.GetMainCharacterPosition()
self.PositionText.SetText("%s, %s" % (int(PlayerX / 100), int(PlayerY / 100)))
def ChangeMode(self):
global Mode
if Mode == "Warp":
Mode = "Walk"
else:
Mode = "Warp"
self.ModeButton.SetText(Mode)
def get_weaponspos(self):
self.fileListBox_Weapons.RemoveAllItems()
self.path = []
x, y, z = player.GetMainCharacterPosition()
self.path.append((x / 100, y / 100))
self.update_weaponspos()
def get_alchemistpos(self):
self.fileListBox_Alchemist.RemoveAllItems()
self.path2 = []
x, y, z = player.GetMainCharacterPosition()
self.path2.append((x / 100, y / 100))
self.update_alchemistpos()
def update_weaponspos(self):
self.fileListBox_Weapons.RemoveAllItems()
for position in self.path:
x, y = int(position[0]), int(position[1])
self.fileListBox_Weapons.AppendItem(OpenLib.Item(str(x) + ', ' + str(y)))
def update_alchemistpos(self):
self.fileListBox_Alchemist.RemoveAllItems()
for position in self.path2:
x, y = int(position[0]), int(position[1])
self.fileListBox_Alchemist.AppendItem(OpenLib.Item(str(x) + ', ' + str(y)))
def GoToWeaponsDealer(self):
global Mode
for position in self.path:
x, y = int(position[0]), int(position[1])
if Mode == "Walk":
Movement.GoToPositionAvoidingObjects(x * 100, y * 100)
else:
Movement.TeleportToPosition(x * 100, y * 100)
def GoToAlchemistDealer(self):
for position in self.path2:
x, y = int(position[0]), int(position[1])
if Mode == "Walk":
Movement.GoToPositionAvoidingObjects(x * 100, y * 100)
else:
Movement.TeleportToPosition(x * 100, y * 100)
def switch_state(self):
if self.Board.IsShow():
self.Board.Hide()
else:
self.Board.Show()
def switch_state():
radar.switch_state()
radar = Radar()