コード例 #1
0
ファイル: StuckHandler.cs プロジェクト: Vipeax/cleanLayer
        public StuckHandler(List<UnstuckAction> Unstucks, Func<Location, bool> Done, Location Target)
        {
            this.Target = Target;
            this.Done = Done;
            this.Unstucks = new Queue<UnstuckAction>(Unstucks);

            Total = Unstucks.Count;
        }
コード例 #2
0
ファイル: GBGoto.cs プロジェクト: Vipeax/cleanLayer
        public override void Run()
        {
            if (_hotspot == Location.Zero)
                _hotspot = ClosestHotspot;

            if (Mover.Destination != _hotspot)
                Mover.PathTo(_hotspot);
        }
コード例 #3
0
ファイル: GBPatrol.cs プロジェクト: Vipeax/cleanLayer
        public override void Run()
        {
            if (_hotspot == Location.Zero)
                _hotspot = _parent.Hotspots[_rand.Next(0, _parent.Hotspots.Count - 1)];

            if (Manager.LocalPlayer.Location.DistanceTo(_hotspot) < 5f)
                _hotspot = _parent.Hotspots[_rand.Next(0, _parent.Hotspots.Count - 1)];

            if (Mover.Destination != _hotspot)
                Mover.PathTo(_hotspot);
        }
コード例 #4
0
ファイル: WoWWorld.cs プロジェクト: aash/cleanCore
 public static TracelineResult LineOfSightTest(Location start, Location end)
 {
     start.Z += 2;
     end.Z += 2;
     return Traceline(start, end, 0x1000024);
 }
コード例 #5
0
ファイル: WoWWorld.cs プロジェクト: aash/cleanCore
 public static TracelineResult Traceline(Location start, Location end)
 {
     return Traceline(start, end, 0x120171);
 }
コード例 #6
0
ファイル: Mover.cs プロジェクト: Vipeax/cleanLayer
        public static bool PathTo(Location from, Location to, bool preferRoads = true)
        {
            try
            {
                // Reinstate the pather with our current continent/dungeon
                _Pather = new Pather(WoWWorld.CurrentMap);
                if (_Pather == null)
                {
                    Log.WriteLine("Unable to instantiate the pather on map {0} (#{1})",
                                  WoWWorld.CurrentMap,
                                  WoWWorld.CurrentMapId);
                    return false;
                }

                if (preferRoads)
                {
                    // Use only water if necessary
                    _Pather.Filter.SetAreaCost((int) PolyArea.Water, 10);
                    // Roads and terrain keeps their priority
                    _Pather.Filter.SetAreaCost((int) PolyArea.Road, 1);
                    _Pather.Filter.SetAreaCost((int) PolyArea.Terrain, 1);

                    // Exclude flightmasters as they arent properly implemented (yet)
                    // Remember that they are implemented in the mesh, just not into the pather!
                    _Pather.Filter.ExcludeFlags = (int) PolyFlag.FlightMaster; // Eventually add (int)PolyFlag.Swim
                }

                // Convert our locations to XNA and request a path
                var hops = _Pather.FindPath(from.ToXNA(), to.ToXNA());

                if (hops == null)
                {
                    Log.WriteLine("Unable to generate path to {0}", to);
                    return false;
                }

                // Since we now know that we're ready to move, we can let the rest of the both know that we have a destination
                Destination = to;
                _lastLocation = from;

                stuckCheckTimer = DateTime.Now + TimeSpan.FromMilliseconds(5000);

                if (_GeneratedPath == null)
                    _GeneratedPath = new Queue<Location>();
                _GeneratedPath.Clear();
                foreach (var hop in hops)
                    _GeneratedPath.Enqueue(new Location(hop.Location.X, hop.Location.Y, hop.Location.Z));
            }
            catch (NavMeshException ex)
            {
                Log.WriteLine("Exception in NavMesh (Status: {0}):", ex.Status);
                Log.WriteLine(ex.Message);
                Exception inner;
                while ((inner = ex.InnerException) != null)
                {
                    Log.WriteLine(inner.Message);
                }

                Status = MovementStatus.Error;

                return false;
            }
            catch(Exception ex)
            {
                return false;
            }

            return true;
        }
コード例 #7
0
ファイル: Mover.cs プロジェクト: Vipeax/cleanLayer
 public static bool PathTo(Location to)
 {
     return PathTo(Manager.LocalPlayer.Location, to);
 }
コード例 #8
0
ファイル: Mover.cs プロジェクト: Vipeax/cleanLayer
 public static void MoveTo(Location to)
 {
     Manager.LocalPlayer.ClickToMove(to);
 }
コード例 #9
0
ファイル: Mover.cs プロジェクト: Vipeax/cleanLayer
        public static void Pulse()
        {
            if (_GeneratedPath == null)
                return;

            if (_GeneratedPath.Count == 0)
            {
                IsCorpseRunning = false;
                Destination = Location.Zero;
                _GeneratedPath = null;
                stuckCheckTimer = DateTime.MinValue;
                return;
            }

            if (SleepTime >= DateTime.Now)
                return;

            SleepTime = DateTime.Now + TimeSpan.FromMilliseconds(100);

            var nextLocation = _GeneratedPath.Peek();
            if (nextLocation != null && nextLocation != default(Location))
            {
                if (Unstuck == null)
                    Unstuck = new AutoStuckHandler(loc => Manager.LocalPlayer.Location.DistanceTo(nextLocation) <= 3f, nextLocation);

                MoveTo(nextLocation);

                if (Manager.LocalPlayer.Location.DistanceTo(nextLocation) < 3f)
                {
                    // We have a new location, dequeue
                    // and reset the unstucker
                    nextLocation = _GeneratedPath.Dequeue();
                    Unstuck = new AutoStuckHandler((loc) => Manager.LocalPlayer.Location.DistanceTo(nextLocation) <= 3f, nextLocation);
                }
            }

            if (Manager.LocalPlayer.Location.Distance2D(_lastLocation) >= .20) //.19???
            {
                Status = MovementStatus.Moving;
                _lastLocation = Manager.LocalPlayer.Location;
                stuckCheckTimer = DateTime.Now + TimeSpan.FromMilliseconds(1500);
                Manager.LocalPlayer.StopMoving(); // TODO: Implement MovementFlags (SetControlBits and that shit)
                return;
            }
            else
            {
                if (stuckCheckTimer <= DateTime.Now)
                {
                    Status = MovementStatus.Stuck;
                    if (Unstuck != null && Unstuck.Remaining > 0)
                    {
                        Log.WriteLine("Trying to unstuck (#{0}).", ((Unstuck.Total - Unstuck.Remaining)+1));
                        StopMoving();
                        Unstuck.Next();
                        stuckCheckTimer = DateTime.Now + TimeSpan.FromMilliseconds(1500);
                    }
                    else
                    {
                        Manager.LocalPlayer.StopCTM();
                        StopMoving();
                        Log.WriteLine("Unable to unstuck, stopping all movement!");
                    }
                }
            }
            _lastLocation = Manager.LocalPlayer.Location;
        }
コード例 #10
0
ファイル: AutoStuckHandler.cs プロジェクト: Vipeax/cleanLayer
        public AutoStuckHandler(Func<Location, bool> Done, Location Target)
        {
            FlyingUnstucks = FlyingUnstucks ?? new StuckList
            {
                (dest) => { Manager.LocalPlayer.Ascend(); /*Thread.Sleep(1500);*/ },
                (dest) => { Manager.LocalPlayer.Descend(); /*Thread.Sleep(1500);*/ },
                (dest) => { Manager.LocalPlayer.StrafeLeft(); /*Thread.Sleep(1500);*/ },
                (dest) => { Manager.LocalPlayer.StrafeRight(); /*Thread.Sleep(1500);*/ },
            };

            GroundUnstucks = GroundUnstucks ?? new StuckList {
                (dest) =>
                    {
                        Manager.LocalPlayer.MoveForward();
                        //Thread.Sleep(500);
                        Manager.LocalPlayer.Jump();
                        //Thread.Sleep(100);
                        Manager.LocalPlayer.Jump();
                        //Thread.Sleep(100);
                        Manager.LocalPlayer.Jump();
                        //Thread.Sleep(250);
                    },

                (dest) =>
                    {
                        Manager.LocalPlayer.Descend();
                        Manager.LocalPlayer.Dismount();
                        Manager.LocalPlayer.MoveBackward();
                        //Thread.Sleep(250);
                    },

                (dest) =>
                    {
                        int i = new Random().Next(0,1);
                        if (i==0)
                        {
                            Manager.LocalPlayer.MoveForward();
                            Manager.LocalPlayer.StrafeLeft();
                        }
                        else
                        {
                            Manager.LocalPlayer.MoveForward();
                            Manager.LocalPlayer.StrafeRight();
                        }
                        //Thread.Sleep(500);
                        Manager.LocalPlayer.MoveBackward();
                        //Thread.Sleep(500);
                        Manager.LocalPlayer.Jump();
                        //Thread.Sleep(250);
                    },

                (dest) =>
                    {
                        Manager.LocalPlayer.MoveBackward();
                        Manager.LocalPlayer.Jump();
                        //Thread.Sleep(500);
                        Manager.LocalPlayer.Jump();
                        Manager.LocalPlayer.StrafeLeft();
                        Manager.LocalPlayer.Jump();
                        //Thread.Sleep(500);
                        Manager.LocalPlayer.StopMoving();
                        Manager.LocalPlayer.MoveBackward();
                        Manager.LocalPlayer.Jump();
                        Manager.LocalPlayer.StrafeRight();
                        //Thread.Sleep(500);
                    },
            };

            GroundUnstucker = new StuckHandler(GroundUnstucks, Done, Target);
            FlyingUnstucker = new StuckHandler(FlyingUnstucks, Done, Target);
        }
コード例 #11
0
ファイル: Form1.cs プロジェクト: aash/cleanCore
        private int HandleClickToMove(IntPtr thisPointer, int clickType, ref ulong interactGuid, ref Location clickLocation, float precision)
        {
            if (Teleporter.Destination != null)
                return 0;

            if (clickType == 4)
            {
                Teleporter.SetDestination(clickLocation);
                return 0;
            }

            return (int)_ctmDetour.CallOriginal(thisPointer, clickType, interactGuid, clickLocation, precision);
        }
コード例 #12
0
ファイル: WoWLocalPlayer.cs プロジェクト: Vipeax/cleanLayer
 public void LookAt(Location loc)
 {
     var local = Location;
     var diffVector = new Location(loc.X - local.X, loc.Y - local.Y, loc.Z - local.Z);
     SetFacing(diffVector.Angle);
 }
コード例 #13
0
ファイル: WoWLocalPlayer.cs プロジェクト: Vipeax/cleanLayer
 public void ClickToMove(Location target, ClickToMoveType type = ClickToMoveType.Move, ulong guid = 0ul)
 {
     Helper.ResetHardwareAction();
     ClickToMoveFunction(Pointer, (int)type, ref guid, ref target, 0.1f);
 }
コード例 #14
0
ファイル: WoWUnit.cs プロジェクト: aash/cleanCore
 public void SetLocation(Location newLoc)
 {
     var loc = new Location { X = newLoc.X, Y = newLoc.Y, Z = newLoc.Z };
     Helper.Magic.WriteStruct(new IntPtr(MovementData + Offsets.Teleport.MovementDataPosition), loc);
 }
コード例 #15
0
ファイル: WoWWorld.cs プロジェクト: aash/cleanCore
 public static TracelineResult Traceline(Location start, Location end, uint flags)
 {
     float dist = 1.0f;
     Location result;
     return _traceline(ref start, ref end, out result, ref dist, flags, 0)
                ? TracelineResult.Collided
                : TracelineResult.NoCollision;
 }
コード例 #16
0
ファイル: Location.cs プロジェクト: Vipeax/cleanLayer
 public double DistanceTo(Location loc)
 {
     return Math.Sqrt(Math.Pow(X - loc.X, 2) + Math.Pow(Y - loc.Y, 2) + Math.Pow(Z - loc.Z, 2));
 }
コード例 #17
0
ファイル: WoWLocalPlayer.cs プロジェクト: aash/cleanCore
 public void ClickToMove(Location target)
 {
     Helper.ResetHardwareAction();
     ulong guid = 0;
     ClickToMoveFunction(Pointer, 0x4, ref guid, ref target, 0.1f);
 }