private void MainForm_Load(object sender, EventArgs e) { client = ClientChooser.ShowBox(); if (client != null) if (client.LoggedIn) { player = client.GetPlayer(); uxMap.Markers.Add(new MapViewer.MapMarker(player)); } }
private void frmMain_Load(object sender, EventArgs e) { Client = ClientChooser.ShowBox(); if (Client == null || !Client.LoggedIn) { MessageBox.Show("You must have at least one client open and logged in."); Application.Exit(); } else { Player = Client.GetPlayer(); } }
public void Approach() { Player p = client.GetPlayer(); p.GoTo = Location; }
private void frmMapView_Load(object sender, EventArgs e) { Client = Client.GetClients()[0]; Player = Client.GetPlayer(); }
public bool Login(string login, string password, string charName) { //if the player is logged or the window is minimazed return false. if (client.Window.IsMinimized) { if (Report != null) { Report.Invoke(State.Minimized); } return(false); } else if (client.LoggedIn) { if (client.GetPlayer().HasFlag(Tibia.Constants.Flag.InBattle)) { if (Report != null) { Report.Invoke(State.InBattle); } return(false); } //send CTRL+G, or however it is done //TO DO /* * client.Input.SendMessage(Hooks.WM_KEYDOWN, (int)Keys.Control, 0); * client.Input.SendMessage(Hooks.WM_KEYDOWN, (int)Keys.G, 0); * client.Input.SendMessage(Hooks.WM_CHAR, (int)Keys.G, 0); * client.Input.SendMessage(Hooks.WM_KEYUP, (int)Keys.G, 0); * client.Input.SendMessage(Hooks.WM_KEYUP, (int)Keys.Control, 0); * Thread.Sleep(300);*/ return(false); } else { //assure the screen is clean, no dialog open client.Input.SendKey(Keys.Escape); client.Input.SendKey(Keys.Escape); if (Report != null) { Report.Invoke(State.DialogsCleaned); } //reset the selected char value.. client.Memory.WriteUInt32(Tibia.Addresses.Client.LoginSelectedChar, 0); if (Report != null) { Report.Invoke(State.ResetSelectedCharValue); } //reset the char count value.. client.Memory.WriteInt32(Tibia.Addresses.Client.LoginCharListLength, 0); if (Report != null) { Report.Invoke(State.ResetSelectedCharCount); } //click the enter the game button client.Input.Click(120, client.Window.Size.Height - 250); if (Report != null) { Report.Invoke(State.ClickEnterButton); } //wait the dialog open int waitTime = 2000; while (!client.IsDialogOpen && client.DialogCaption != "Enter Game") { Thread.Sleep(100); waitTime -= 100; if (waitTime <= 0) { if (Report != null) { Report.Invoke(State.LoginDialogDidntOpen); } return(false); } } if (Report != null) { Report.Invoke(State.LoginDialogOpened); } //now we have to send the login and the password client.Input.SendString(login); if (Report != null) { Report.Invoke(State.InputAccName); } //press tab client.Input.SendKey(Keys.Tab); if (Report != null) { Report.Invoke(State.PressTab); } //put the pass client.Input.SendString(password); if (Report != null) { Report.Invoke(State.InputPassword); } //press enter.. client.Input.SendKey(Keys.Enter); if (Report != null) { Report.Invoke(State.PressEnter); } //wait for the charlist dialog waitTime = 4000; while (CharListCount == 0) { Thread.Sleep(100); waitTime -= 100; if (waitTime <= 0) { if (Report != null) { Report.Invoke(State.CharListNotReceived); } return(false); } } if (Report != null) { Report.Invoke(State.CharListReceived); } waitTime = 1000; while (client.DialogCaption == "Connecting") { Thread.Sleep(100); waitTime -= 100; if (waitTime <= 0) { if (Report != null) { Report.Invoke(State.ConnectingDialogNotGone); } return(false); } } if (Report != null) { Report.Invoke(State.ConnectingDialogGone); } Thread.Sleep(100); // Check if there is a message of the day if (client.DialogCaption != "Select Character") { client.Input.SendKey(Keys.Enter); Thread.Sleep(100); if (Report != null) { Report.Invoke(State.Motd); } } } //now we loop at the charlist to find the selected char.. foreach (var ch in CharacterList) { Thread.Sleep(100); //make sure the client process the msg //we start at position 0 if (string.Compare(ch.CharName, charName, true) == 0) { //we found the char //lets press the entrer key client.Input.SendKey(Keys.Enter); if (Report != null) { Report.Invoke(State.SelectedCharFound); } return(true); } //move to the next char client.Input.SendKey(Keys.Down); if (Report != null) { Report.Invoke(State.GoToNextChar); } } //char not found. if (Report != null) { Report.Invoke(State.SelectedCharNotFound); } return(false); }