/// <summary> /// Called right after a player makes a destination movement. /// </summary> public void OnPlayerMovement(SRPlayer player) { if (inTrace) { Window w = Window.Get; if (TracePlayerName.Equals(player.Name, StringComparison.OrdinalIgnoreCase) || InfoManager.inParty && w.Training_cbxTraceMaster.Checked && InfoManager.Party.Master.Name == player.Name && InfoManager.isEntityNear(player.UniqueID)) { byte distance = 0; if (w.Training_cbxTraceDistance.Checked) { w.Training_tbxTraceDistance.InvokeIfRequired(() => { distance = byte.Parse(w.Training_tbxTraceDistance.Text); }); } // Follow blind movement SRCoord Q = player.MovementPosition; if (distance > 0) { SRCoord P = InfoManager.Character.GetRealtimePosition(); double PQMod = P.DistanceTo(Q); if (distance < PQMod) { SRCoord PQUnit = new SRCoord((Q.PosX - P.PosX) / PQMod, (Q.PosY - P.PosY) / PQMod); SRCoord NewPositon; if (P.inDungeon()) { NewPositon = new SRCoord((PQMod - distance) * PQUnit.PosX + P.PosX, (PQMod - distance) * PQUnit.PosY + P.PosY, P.Region, P.Z); } else { NewPositon = new SRCoord((PQMod - distance) * PQUnit.PosX + P.PosX, (PQMod - distance) * PQUnit.PosY + P.PosY); } MoveTo(NewPositon); w.LogProcess("Tracing to [" + player.Name + "] ..."); } } else { MoveTo(Q); w.LogProcess("Tracing to [" + player.Name + "] ..."); } } } }
public void SetTraceName(string PlayerName) { // Normalize Key TracePlayerName = PlayerName.Trim().ToUpper(); if (inTrace) { // Check if player is around and move it SRPlayer player = InfoManager.Players[TracePlayerName]; if (player != null) { MoveTo(player.GetRealtimePosition()); } } }
/// <summary> /// Called when "All" message is being sent. Returns the cancel effect. /// </summary> public bool OnChatSending(string message) { switch (message) { case "PING": m_Ping = new System.Diagnostics.Stopwatch(); m_Ping.Start(); break; case "TIME": message = "[xBot] Server time : " + InfoManager.GetServerTime().ToString("HH:mm:ss | dd/MM/yyyy"); PacketBuilder.Client.SendNotice(message); if (Proxy.ClientlessMode) { Window.Get.LogChatMessage(Window.Get.Chat_rtbxAll, "xBot", message); } // cancel it return(true); case "ISEEDEADPEOPLE": if (!Proxy.ClientlessMode) { for (int i = 0; i < InfoManager.Players.Count; i++) { SRPlayer player = InfoManager.Players.GetAt(i); if (player.GameStateType != SRModel.GameState.None) { Packet p = new Packet(Agent.Opcode.SERVER_ENTITY_STATE_UPDATE); p.WriteUInt(player.UniqueID); p.WriteUShort(4); Proxy.InjectToClient(p); } } message = "[xBot] The void has been revealed!"; PacketBuilder.Client.SendNotice(message); } return(true); } return(false); }
private void CheckAutoParty(object sender, ElapsedEventArgs e) { Window w = Window.Get; if (w.Party_cbxInviteAll.Checked) { // Check players around if (InfoManager.Players.Count > 0) { if (InfoManager.inParty) { xDictionary <string, SRPlayer> PlayersNearWithNoParty = new xDictionary <string, SRPlayer>(InfoManager.Players); // Remove players nears with party for (byte j = 0; j < InfoManager.Party.Members.Count; j++) { string PlayerName = InfoManager.Party.Members.GetAt(j).Name.ToUpper(); if (PlayersNearWithNoParty.ContainsKey(PlayerName)) { PlayersNearWithNoParty.RemoveKey(PlayerName); } } if (PlayersNearWithNoParty.Count == 0) { return; } // Check invitations setup if (!w.Party_cbxInviteOnlyPartySetup.Checked || InfoManager.Party.SetupFlags == w.GetPartySetup()) { if (!InfoManager.Party.isFull) { PacketBuilder.InviteToParty(PlayersNearWithNoParty.GetAt(rand.Next(PlayersNearWithNoParty.Count)).UniqueID); tCycleAutoParty.Start(); } } } else { PacketBuilder.CreateParty(InfoManager.Players.GetAt(rand.Next(InfoManager.Players.Count)).UniqueID, InfoManager.Party.SetupFlags); tCycleAutoParty.Start(); } } else { tCycleAutoParty.Start(); } } else if (w.Party_cbxInvitePartyList.Checked) { if (InfoManager.Players.Count > 0) { List <string> PlayersToInvite = new List <string>(); w.Party_lstvPartyList.InvokeIfRequired(() => { for (int j = 0; j < w.Party_lstvPartyList.Items.Count; j++) { PlayersToInvite.Add(w.Party_lstvPartyList.Items[j].Name); } }); // Remove if are in party already for (int j = 0; j < PlayersToInvite.Count; j++) { for (byte k = 0; k < InfoManager.Party.Members.Count; k++) { if (PlayersToInvite[j].Equals(InfoManager.Party.Members.GetAt(k).Name, StringComparison.OrdinalIgnoreCase)) { PlayersToInvite.RemoveAt(j--); break; } } } if (PlayersToInvite.Count > 0) { // Shuffle and check the party list with near players PlayersToInvite.Shuffle(); SRPlayer PlayerToInvite = null; for (int j = 0; j < PlayersToInvite.Count; j++) { if ((PlayerToInvite = InfoManager.Players[PlayersToInvite[j]]) != null) { break; } } if (PlayerToInvite != null) { if (InfoManager.inParty) { if (!w.Party_cbxInviteOnlyPartySetup.Checked || InfoManager.Party.SetupFlags == w.GetPartySetup()) { if (!InfoManager.Party.isFull) { PacketBuilder.InviteToParty(PlayerToInvite.UniqueID); tCycleAutoParty.Start(); } } } else { PacketBuilder.CreateParty(PlayerToInvite.UniqueID, w.GetPartySetup()); tCycleAutoParty.Start(); } } else { // No players to invite, try later tCycleAutoParty.Start(); } } } else { // No players near to invite, try later tCycleAutoParty.Start(); } } }