static void find() { string targetName = findArgument; homeX = fface.Player.PosX; homeZ = fface.Player.PosZ; fface.Navigator.DistanceTolerance = 10; WriteLine("home is " + homeX + "," + homeZ); int counter = 0; do { counter++; if (counter % 200 == 0) WriteLine("Find " + findArgument); Thread.Sleep(100); while (!terminated && inTown()) { Thread.Sleep(1000); continue; } if (terminated) break; FindNearestWanted(); int targetId = fface.Target.ID; bool noTarget = !isWanted() || isClaimed(); DoHoming(); if (match("Standing", fface.Player.Status.ToString()) && noTarget) { Throttle throttleRotate = new Throttle(5,true); while (match("Standing", fface.Player.Status.ToString())) { Thread.Sleep(100); if (isWanted()) { // added 2012/10/10 if (!isClaimed()) break; } if (terminated) break; if (throttleRotate.isReady()) { RotateView(); Thread.Sleep(1000); } if (fface.Menu.IsOpen) Thread.Sleep(1000); else { if (fface.Target.IsLocked) SendString("/lockon"); Fap(); } } } tryLock(); bool timedOut = false; if (follow) { short npcid = (short)fface.Target.ID; if (fface.Target.IsLocked) { float dx = fface.Target.PosX - fface.Player.PosX; float dz = fface.Target.PosZ - fface.Player.PosZ; double dd = Math.Sqrt(dx * dx + dz * dz); double dh = Math.Abs(fface.Target.PosH - fface.Player.PosH); DateTime t1 = DateTime.Now; if (!facingEnemy() && match("Fighting", fface.Player.Status.ToString())) { WriteLine("!facing & fighting, adjusting"); KeyPress(KeyCode.NP_Number2); KeyPress(KeyCode.NP_Number4); KeyPress(KeyCode.NP_Number8); } if (far() && fface.Target.IsLocked) { WriteLine("Far & Locked, chasing target" + fface.Player.Status); windower.SendKey(KeyCode.NP_Number8, true); double lastdd = dd; while (far() && fface.Target.IsLocked) { dx = fface.Target.PosX - fface.Player.PosX; dz = fface.Target.PosZ - fface.Player.PosZ; dd = Math.Sqrt(dx * dx + dz * dz); double dddd = Math.Abs(lastdd - dd); dh = Math.Abs(fface.Target.PosH - fface.Player.PosH); DateTime t2 = DateTime.Now; TimeSpan time = t2 - t1; if (time.TotalSeconds > timeOut) { WriteLine("Timed out, giving up"); SendString("/lockon"); Thread.Sleep(100); SendString("/a off"); Thread.Sleep(100); KeyPress(KeyCode.EscapeKey); KeyPress(KeyCode.NP_Number2); timedOut = true; break; } //WriteLine("Running dd=" + string.Format("{0:0.0}", dd) // + " dh=" + string.Format("{0:0.00}", dh) + " time=" + time.TotalSeconds + " dddd=" + dddd); //fface.Navigator.GotoNPCXZ(npcid); Thread.Sleep(100); lastdd = dd; if (terminated) break; } windower.SendKey(KeyCode.NP_Number8, false); WriteLine("Done chasing ..."); if (!timedOut) { findI++; printWantedTarget(); } } } } if (terminated) break; if (isWanted()) { if (!match(noexec, fface.Player.Status.ToString()) || !follow) { if (isWeakened()) { WriteLine("weakened ... waiting"); Thread.Sleep(10000); continue; } doExec(); } } } while (loop); }
static void locate() { Console.WriteLine("target="+target); string[] ids = target.Split(','); Throttle throttleLog = new Throttle(10, true); while (!terminated) { bool throttleLogIsReady = throttleLog.isReady(); if (throttleLogIsReady) { Console.WriteLine("player=" + ToString(fface.Player.Position)); Console.WriteLine("target=" + ToString(fface.Target.Position) + " " + String.Format("{0:X}", fface.Target.ID) + "\t" + fface.Target.Name); } foreach (string id in ids) { int i = Int32.Parse(id, System.Globalization.NumberStyles.HexNumber); if (throttleLogIsReady) Console.WriteLine("npc =" + ToString(fface.NPC.GetPosition(i)) + " " + String.Format("{0:X}", i) + " " + (fface.NPC.IsActive(i) ? "O" : "X") + " " + fface.NPC.Status(i) + "\t" + fface.NPC.Name(i)); if ((match("standing", fface.NPC.Status(i).ToString()) || match("fighting", fface.NPC.Status(i).ToString())) && fface.NPC.IsActive(i)) { if (execParameter != null && throttleLogIsReady) doExec(); } } } }
static void npc() { string[] ids = npcArgument.Split(','); Throttle throttleLog = new Throttle(10, true); while (!terminated) { bool throttleLogIsReady = throttleLog.isReady(); if (throttleLogIsReady) { Console.WriteLine("player=" + ToString(fface.Player.Position)); Console.WriteLine("target=" + ToString(fface.Target.Position) + " " + String.Format("{0:X}", fface.Target.ID) + "\t" + fface.Target.Name); } foreach (string id in ids) { int i = Int32.Parse(id, System.Globalization.NumberStyles.HexNumber); if (throttleLogIsReady) Console.WriteLine("npc =" + ToString(fface.NPC.GetPosition(i)) + " " + String.Format("{0:X}", i) + " " + (fface.NPC.IsActive(i)?"O":"X") + " " + fface.NPC.Status(i) + "\t" + fface.NPC.Name(i)); TurnMe turnMe = new TurnMe(fface); while ((match("standing", fface.NPC.Status(i).ToString()) || match("fighting", fface.NPC.Status(i).ToString())) && fface.Player.ViewMode == FFACETools.ViewMode.FirstPerson && fface.NPC.IsActive(i)) { throttleLogIsReady = throttleLog.isReady(); double distanceToGoal = distanceArgument; if (terminated) break; FFACE.Position p = fface.NPC.GetPosition(i); if (match("fighting", fface.Player.Status.ToString())) { p = fface.Target.Position; } double dx = p.X - fface.Player.PosX; double dz = fface.Player.PosZ - p.Z; double h = Math.Atan2(dz, dx); double dd = Math.Sqrt(dx * dx + dz * dz); if (throttleLogIsReady) { Console.WriteLine("goal h=" + h + " dd=" + dd + " dest= " + p.X + "," + p.Z); } if (dd < distanceToGoal) { if (execParameter != null) { doExec(); } break; } double dh = h - fface.Player.PosH; if (dh < -Math.PI) dh = 2 * Math.PI + dh; if (dh > Math.PI) dh = 2 * Math.PI - dh; double distanceError = 0.15; bool goalFar = dd > distanceToGoal; if (!goalFar || (-distanceError < dh && dh < distanceError)) { } else { turnMe.stopIt(); Thread.Sleep(100); SetNPCPosH(fface._InstanceID, fface.Player.ID, (float)h); Thread.Sleep(100); } if (dd > distanceToGoal) { turnMe.startRunning(); } } turnMe.stopIt(); } } }
static void go() { string[] destinations = goArgument.Split(';'); TurnMe turnMe = new TurnMe(fface); foreach (string destination in destinations) { string[] xy = destination.Split(','); double distanceToGoal = 1; FFACE.Position p = new FFACE.Position(); p.X = float.Parse(xy[0]); p.Z = float.Parse(xy[1]); Console.WriteLine("player =" + ToString(fface.Player.Position)); Console.WriteLine("destination=" + ToString(p)); Throttle throttleLog = new Throttle(3, true); while (!terminated) { double dx = p.X - fface.Player.PosX; double dz = p.Z - fface.Player.PosZ; double h = Math.Atan2(-dz, dx); double dd = Math.Sqrt(dx * dx + dz * dz); double dh = h - fface.Player.PosH; if (dh < -Math.PI) dh = 2 * Math.PI + dh; if (dh > Math.PI) dh = 2 * Math.PI - dh; if (dd <= distanceToGoal) { // WriteLine("stopIt dd=" + dd + " distanceToGoal=" + distanceToGoal); // turnMe.stopIt(); break; } double directionError = 0.14; /* if (dd < 20) { directionError = 0.1+(dd / 100.0); } if (dd < 10) { directionError = 3*dd/10.0; } if (dd < 6) { directionError = Math.PI; } */ if (throttleLog.isReady()) { WriteLine("please face " + String.Format("{0:0.00}", h) + " dd = " + String.Format("{00:0.00}", dd) + " dh = " + String.Format("{00:0.00}", dh)); // WriteLine("directionError=" + directionError); } if ((-directionError < dh) && (dh < directionError)) { // turnMe.stopTurning(); } else { WriteLine("Turning dh="+dh); turnMe.stopIt(); Thread.Sleep(100); SetNPCPosH(fface._InstanceID, fface.Player.ID, (float)h); Thread.Sleep(100); if (fface.Player.ViewMode != ViewMode.FirstPerson) { fface.Windower.SendKeyPress(KeyCode.NP_Number5); Thread.Sleep(100); } //WriteLine("Turning Done"); } if (dd > distanceToGoal) { turnMe.startRunning(); } } if (terminated) { break; } } turnMe.stopIt(); }