/// <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 override SRCoord GetRealtimePosition() { if (MovementPosition != null) { SRCoord P = Position; SRCoord Q = MovementPosition; // Check if it's updated.. if (!P.Equals(Q)) { // Scale 1920units:192px = 10:1 => To Ms double MilisecondsPerUnit = GetMovementSpeed(); // Checking update times! long milisecondsTranscurred = PositionUpdateTimer.ElapsedMilliseconds; long milisecondsMaximum = P.TimeTo(Q, MilisecondsPerUnit); if (milisecondsTranscurred >= milisecondsMaximum) { // The entity has reached the position long ago Position = Q; } else { // Create vector unit double PQMod = P.DistanceTo(Q); SRCoord PQUnit = new SRCoord((Q.PosX - P.PosX) / PQMod, (Q.PosY - P.PosY) / PQMod); double DistanceTillNow = milisecondsTranscurred * MilisecondsPerUnit; if (P.inDungeon()) { Position = new SRCoord(PQUnit.PosX * DistanceTillNow + P.PosX, PQUnit.PosY * DistanceTillNow + P.PosY, P.Region, P.Z); } else { Position = new SRCoord(PQUnit.PosX * DistanceTillNow + P.PosX, PQUnit.PosY * DistanceTillNow + P.PosY); } } PositionUpdateTimer.Restart(); } } return(Position); }
private void ThreadBotting() { // 1.1 TOWN ? // 1.1.1 Do TOWN // 1.1.2 Wait at starting script // 1.2 TRAINING AREA ? // 1.2.1 Kill Mobs // 1.3 OUTSIDE TOWN AND OUTSIDE TRAINING AREA ? // 1.3.1 Find the walking nearest point // 1.3.1.1 Follow it // 1.3.1.2 Go to 1.2 // 1.3.2 Use return scroll Window w = Window.Get; while (true) { // Checking where am I ? w.LogProcess("Checking current location..."); SRCoord myPosition = InfoManager.Character.GetRealtimePosition(); currentScript = Script.GetNearestTownScript(myPosition, 50); if (currentScript != null) { // I'm near town loop script TownLoop(currentScript); } else { // Checking training area SRCoord trainingPosition = w.TrainingArea_GetPosition(); if (trainingPosition == null) { w.Log("Training area it's not activated"); Stop(); return; } else { // Check if I'm inside training area int trainingRadius = w.TrainingArea_GetRadius(); if (myPosition.DistanceTo(trainingPosition) <= trainingRadius) { AttackLoop(); } else { // Check through script string scriptPath = w.TrainingArea_GetScript(); if (scriptPath != "") { w.Log("Script support not implemented yet!!"); Stop(); return; //currentScript = new Script(scriptPath); //int nearIndex = currentScript.GetNearMovement(myPosition, 50); //if (nearIndex != -1) //{ // currentScript.Run(nearIndex); //} //else //{ // w.Log("Too far away from script!"); // Stop(); // return; //} } else { w.Log("Script not found"); Stop(); return; } } } } } }