public MoveResult move() { if (GiveUpIfUnsafe) // fixme { //if (!pather.IsItSafeAt(Me.Target, Me.Location)) // return MoveResult.Unsafe; } if (PathTimeout.IsReady) { MoveAlong = null; } BoogieCore.Log(LogType.System, "[Mover] MoveAlong = {0}", MoveAlong); if (MoveAlong == null) { Location from = new Location(Me.Location); mover.Stop(); Path path = world.CreatePath(from, target, (float)4.5, PPather.radar); //fixme PathTimeout.Reset(); BoogieCore.Log(LogType.System, "[Mover (New)] PathCount = {0}", path.Count()); if (path == null || path.Count() == 0) { //Context.Log("EasyMover: Can not create path . giving up"); mover.MoveRandom(); Thread.Sleep(200); mover.Stop(); return(MoveResult.CantFindPath); } else { //Context.Log("Save path to " + pathfile); //path.Save(pathfile); MoveAlong = new MoveAlonger(pather, path); } } if (MoveAlong != null) { Location from = new Location(Me.Location); BoogieCore.Log(LogType.System, "[Mover ] PathCount = {0}", MoveAlong.path.Count()); if (MoveAlong.path.Count() == 0 || from.GetDistanceTo(target) < (float)5.0) { BoogieCore.Log(LogType.System, "[Mover] Count = 0 or Dist < 5.0"); MoveAlong = null; mover.Stop(); return(MoveResult.GotThere); } else if (!MoveAlong.MoveAlong()) { BoogieCore.Log(LogType.System, "[Mover] Stuck!!"); MoveAlong = null; // got stuck! if (GiveUpIfStuck) { return(MoveResult.Stuck); } } } return(MoveResult.Moving); }
public UnitData(GUnit u) { unit = u; guid = u.GUID; movementSpeed = 0.0; oldLocation = u.Location; lastSeen = new GSpellTimer(120 * 1000); lastSeen.Reset(); }
public MoveResult move(double howClose) { if (GiveUpIfUnsafe) { if (!pather.IsItSafeAt(Me.Target, Me.Location)) { return(MoveResult.Unsafe); } } if (PathTimeout.IsReady) { MoveAlong = null; } if (MoveAlong == null) { Location from = new Location(Me.Location); mover.Stop(); Path path = world.CreatePath(from, target, (float)howClose, PPather.radar); PathTimeout.Reset(); if (path == null || path.Count() == 0) { PPather.WriteLine("EasyMover: Can not create path . giving up"); mover.MoveRandom(); Thread.Sleep(200); mover.Stop(); return(MoveResult.CantFindPath); } else { //PPather.WriteLine("Save path to " + pathfile); //path.Save(pathfile); MoveAlong = new MoveAlonger(pather, path); } } if (MoveAlong != null) { Location from = new Location(Me.Location); if (MoveAlong.path.Count() == 0 || from.GetDistanceTo(target) < howClose) { //PPather.WriteLine("Move along used up"); MoveAlong = null; mover.Stop(); return(MoveResult.GotThere); } else if (!MoveAlong.MoveAlong()) { MoveAlong = null; // got stuck! if (GiveUpIfStuck) { return(MoveResult.Stuck); } } } return(MoveResult.Moving); }
private void MyPather() { GSpellTimer taskTimer = new GSpellTimer(300); GSpellTimer updateStatusTimer = new GSpellTimer(2000); GSpellTimer nothingToDoTimer = new GSpellTimer(3 * 1000); bool exit = false; GSpellTimer Tick = new GSpellTimer(100); do { if (RunState != WantedState) { RunState = WantedState; } if (updateStatusTimer.IsReady) { UpdateXP(); updateStatusTimer.Reset(); } if (RunState == RunState_e.Stopped) { //Context.Log("Stop wanted. Stopping glide"); //Context.KillAction("PPather wants to stop", false); Thread.Sleep(500); // pause } else if (RunState == RunState_e.Paused) { UpdateMyPos(); Thread.Sleep(100); // pause } else if (RunState == RunState_e.Running) { UpdateMyPos(); if (Me.IsDead) { Thread.Sleep(1000); GhostRun(); Thread.Sleep(1500); if (Me.IsDead) { //!!! } else { //Rest(); } } Tick.Wait(); Thread.Sleep(10); // min sleep time Tick.Reset(); } } while (!exit); }
public void Update(int dt) // dt is milliseconds { if (dt == 0) { return; } double ds = (double)dt / 1000.0; double d = oldLocation.GetDistanceTo(unit.Location); movementSpeed = d / ds; oldLocation = unit.Location; lastSeen.Reset(); }
public void Update(GUnit[] units) { int dt = -updateTimer.TicksLeft; foreach (GUnit u in units) { if (u.Reaction == GReaction.Hostile) { if (!u.IsDead && !PPather.IsStupidItem(u)) { UnitData ud; if (dic.TryGetValue(u.GUID, out ud)) { ud.Update(dt); } else { // new one ud = new UnitData(u); dic.Add(u.GUID, ud); } } } } List <long> rem = new List <long>(); foreach (UnitData ud in dic.Values) { if (!ud.unit.IsValid && ud.lastSeen.IsReady) { rem.Add(ud.guid); } else if (ud.unit.IsDead) { rem.Add(ud.guid); } } foreach (long guid in rem) { dic.Remove(guid); } updateTimer.Reset(); }
public void Update(BoogieBot.Common.Object[] units) { int dt = (int)-updateTimer.TicksLeft; foreach (BoogieBot.Common.Object u in units) { if (!u.IsDead && !PPather.IsStupidItem(u)) { UnitData ud; if (dic.TryGetValue((long)u.GUID.GetOldGuid(), out ud)) { ud.Update((int)dt); } else { // new one ud = new UnitData(u); dic.Add((long)u.GUID.GetOldGuid(), ud); } } } List <long> rem = new List <long>(); foreach (UnitData ud in dic.Values) { if (!ud.unit.IsValid) { rem.Add(ud.guid); } } foreach (long guid in rem) { dic.Remove(guid); } updateTimer.Reset(); }
void PushKeys() { if (old_runForwards != runForwards) { if (runForwards) { BoogieCore.WorldServerClient.StartMoveForward(); } else { BoogieCore.WorldServerClient.StopMoveForward(); } //Context.Log("Forwards: " + runForwards); } /* * * if(runForwards) * { * GContext.Main.StartRun(); // * } * else * { * GContext.Main.ReleaseRun(); // * } */ if (old_runBackwards != runBackwards) { KeyT.Wait(); KeyT.Reset(); if (runBackwards) { PressKey("Common.Back"); } else { ReleaseKey("Common.Back"); } //Context.Log("Backwards: " + runBackwards); } if (old_strafeLeft != strafeLeft) { KeyT.Wait(); KeyT.Reset(); if (strafeLeft) { PressKey("Common.StrafeLeft"); } else { ReleaseKey("Common.StrafeLeft"); } //Context.Log("StrageLeft: " + strafeLeft); } if (old_strafeRight != strafeRight) { KeyT.Wait(); KeyT.Reset(); if (strafeRight) { PressKey("Common.StrafeRight"); } else { ReleaseKey("Common.StrafeRight"); } //Context.Log("StrageRight: " + strafeRight); } /* * if(rotateRight || rotateLeft) * { * double head = GContext.Main.Me.Heading; * if(rotateRight) head -= Math.PI/2; * else if(rotateLeft) head += Math.PI/2; * GContext.Main.StartSpinTowards(head); * } * else * { * GContext.Main.ReleaseSpin(); * } */ if (old_rotateLeft != rotateLeft) { KeyT.Wait(); KeyT.Reset(); if (rotateLeft) { PressKey("Common.RotateLeft"); } else { ReleaseKey("Common.RotateLeft"); } //Context.Log("RotateLeft: " + rotateLeft); } if (old_rotateRight != rotateRight) { KeyT.Wait(); KeyT.Reset(); if (rotateRight) { PressKey("Common.RotateRight"); } else { ReleaseKey("Common.RotateRight"); } //Context.Log("RotateRight: " + rotateRight); } old_runForwards = runForwards; old_runBackwards = runBackwards; old_strafeLeft = strafeLeft; old_strafeRight = strafeRight; old_rotateLeft = rotateLeft; old_rotateRight = rotateRight; }
public bool checkStuck() { if (firstStuckCheck) { oldLocation = GContext.Main.Me.Location; predictedDX = 0; predictedDY = 0; firstStuckCheck = false; lastStuckCheck.Reset(); } else { // update predicted location double h; double speed; h = mover.GetMoveHeading(out speed); float dt = (float)-lastStuckCheck.TicksLeft / 1000f; float dx = (float)Math.Cos(h) * (float)speed * dt; float dy = (float)Math.Sin(h) * (float)speed * dt; //PPather.WriteLine("speed: " + speed + " dt: " + dt + " dx: " + dx + " dy : " + dy); predictedDX += dx; predictedDY += dy; lastStuckCheck.Reset(); if (StuckTimeout.IsReady) { // Check stuck GLocation loc = Me.Location; float realDX = loc.X - oldLocation.X; float realDY = loc.Y - oldLocation.Y; //PPather.WriteLine(" dx: " + predictedDX + " dy : " + predictedDY + " Real dx: " + realDX + " dy : " + realDY ); float predictDist = (float)Math.Sqrt(predictedDX * predictedDX + predictedDY * predictedDY); float realDist = (float)Math.Sqrt(realDX * realDX + realDY * realDY); //PPather.WriteLine(" pd " + predictDist + " rd " + realDist); int multiplier = 3; if (GPlayerSelf.Me.IsStealth) { multiplier = 4; } if (predictDist > realDist * multiplier) { // moving a lot slower than predicted // check direction GLocation excpected = new GLocation(loc.X + predictedDX, loc.Y + predictedDY); PPather.WriteLine("I am stuck " + stuckMove); //. Jumping to get free"); if (stuckMove == 0) { mover.Forwards(false); mover.Forwards(true); mover.StrafeLeft(true); //mover.Jump(); //mover.StrafeRight(false); } else if (stuckMove == 1) { mover.Forwards(false); mover.Forwards(true); mover.StrafeLeft(true); //PPather.WriteLine(" strafe left"); //mover.Jump(); //mover.StrafeLeft(false); } else if (stuckMove == 2) { mover.Forwards(false); mover.Forwards(true); mover.StrafeRight(true); //PPather.WriteLine(" strafe left"); //mover.StrafeLeft(true); } else if (stuckMove == 2) { mover.Forwards(false); mover.Forwards(true); mover.StrafeRight(true); //PPather.WriteLine(" strafe left"); //mover.StrafeLeft(true); } stuckMove++; if (stuckMove >= abortSensitivity) { return(true); } } else { stuckMove = 0; } predictedDX = 0; predictedDY = 0; oldLocation = loc; StuckTimeout.Reset(); } } return(false); }