Example #1
0
 public static Vector3D operator *(Vector3D v, Matrix m)
 {
     var res = new Vector3D(m._x1*v.X + m._y1*v.Y + m._z1*v.Z,
                          m._x2*v.X + m._y2*v.Y + m._z2*v.Z,
                          m._x3*v.X + m._y3*v.Y + m._z3*v.Z);
     return res;
 }
Example #2
0
        public static bool MoveMouseToWoWCoords(float x, float y, float z)
        {
            var pseudoVec = new Vector3D(x, y, z); //not really a vector. its the location we want to click
            IntPtr hwnd = ProcessManager.WowProcess.WindowHandle; //windowhandle for getting size
            var camera = new CameraInfo();
            //Read information
            uint pAddr2 =
                ProcessManager.WowProcess.ReadUInt((ProcessManager.WowProcess.ReadUInt(
                    ProcessManager.GlobalOffsets.CameraPointer)) +
                        ProcessManager.GlobalOffsets.CameraOffset);
            var bCamera = new byte[68];
            bCamera = ProcessManager.WowProcess.ReadBytes(pAddr2, 68);

            //Convert bytes to usable data
            camera.Pos = new Vector3D(BitConverter.ToSingle(bCamera, 8),
                                    BitConverter.ToSingle(bCamera, 12),
                                        BitConverter.ToSingle(bCamera, 16));
            camera.ViewMat = new Matrix(BitConverter.ToSingle(bCamera, 20),
                BitConverter.ToSingle(bCamera, 24), BitConverter.ToSingle(bCamera, 28),
                BitConverter.ToSingle(bCamera, 32), BitConverter.ToSingle(bCamera, 36),
                BitConverter.ToSingle(bCamera, 40), BitConverter.ToSingle(bCamera, 44),
                BitConverter.ToSingle(bCamera, 48), BitConverter.ToSingle(bCamera, 52));
            camera.Foc = BitConverter.ToSingle(bCamera, 64);
            //Get windoesize
            var rc = new Rect();
            GetClientRect(hwnd, ref rc);

            //Vector camera -> object
            Vector3D Diff = pseudoVec - camera.Pos;

            if ((Diff*camera.ViewMat.getFirstColumn) < 0)
            {
                return false;
            }

            Vector3D View = Diff * camera.ViewMat.inverse();
            var Cam = new Vector3D(-View.Y, -View.Z, View.X);

            float fScreenX = (rc.right - rc.left)/2.0f;
            float fScreenY = (rc.bottom - rc.top)/2.0f;
            //Aspect ratio
            float fTmpX = fScreenX/(float) Math.Tan(((camera.Foc*44.0f)/2.0f)*Deg2Rad);
            float fTmpY = fScreenY/(float) Math.Tan(((camera.Foc*35.0f)/2.0f)*Deg2Rad);

            var pctMouse = new Point();
            pctMouse.X = (int) (fScreenX + Cam.X*fTmpX/Cam.Z);
            pctMouse.Y = (int) (fScreenY + Cam.Y*fTmpY/Cam.Z);

            if (pctMouse.X < 0 || pctMouse.Y < 0 || pctMouse.X > rc.right || pctMouse.Y > rc.bottom)
            {
                return false;
            }

            ProcessManager.CommandManager.MoveMouse(pctMouse.X, pctMouse.Y);
            return true;
        }
Example #3
0
 public static float GetDistance(Vector3D dest, Vector3D currentPos, bool UseZ)
 {
     float num = currentPos.X - dest.X;
     float num2 = currentPos.Y - dest.Y;
     float num3 = (dest.Z != 0f) ? (currentPos.Z - dest.Z) : 0f;
     if (UseZ)
     {
         return (float) Math.Sqrt((double) (((num * num) + (num2 * num2)) + (num3 * num3)));
     }
     return (float) Math.Sqrt((double) ((num * num) + (num2 * num2)));
 }
Example #4
0
        /// <summary>
        /// Makes the player walk from the current location to the location of "dest"
        /// </summary>
        /// <param name="dest">Destination</param>
        /// <param name="tolerance">A value indicating the tolerance. i.e. if we pass
        /// 3.0f as tolerance, the bot will stop moving when reaching 3 yards from the
        /// destination.</param>
        /// <returns>A NavigationState indicating what the result of the movement was</returns>
        public NavigationState MoveTo(Vector3D dest, float tolerance)
        {
            // TODO: add PPather usage here as well
            const CommandManager.ArrowKey key = CommandManager.ArrowKey.Up;

            //isMoving = true;

            if (!dest.IsValid())
            {
                //isMoving = false;
                return NavigationState.Ready;
            }

            // Random jump
            // TODO: make this configurable
            int rndJmp = MathFuncs.RandomNumber(1, 8);
            bool doJmp = false;
            if (rndJmp == 1 || rndJmp == 3)
            {
                doJmp = true;
            }

            // Move on...
            float distance = MathFuncs.GetDistance(dest, Location, false);
            PlayerCM.ArrowKeyDown(key);

            /// We face our destination waypoint while we are already moving, so that it looks
            /// more human-like
            float angle = MathFuncs.GetFaceRadian(dest, Location);
            Face(angle);

            // Start profiler for WayPointTimeOut
            DateTime start = DateTime.Now;

            NavigationState res = NavigationState.Roaming;

            while (distance > tolerance)
            {
                float currentDistance = distance;

                if (doJmp)
                {
                    doJmp = false;
                    PlayerCM.SendKeys(" ");
                }

                if (StopMovement)
                {
                    res = NavigationState.Ready;
                    StopMovement = false;
                    break;
                }

                distance = MathFuncs.GetDistance(dest, Location, false);

                Thread.Sleep(50);
                Application.DoEvents();

                DateTime end = DateTime.Now;
                TimeSpan tsTravelTime = end - start;

                TravelTime = tsTravelTime.Milliseconds + tsTravelTime.Seconds*1000;

                // we take as granted that we should move at least 0.1 yards
                // per cycle (might be a good idea to get this routine synchronized so that
                // we can actually know exactly how much we move "per-tick")
                if (Math.Abs(currentDistance - distance) < 0.1f &&
                            Math.Abs(currentDistance - distance) > 0.0001f)
                {
                    Output.Instance.Debug(string.Format("Stuck! Distance difference: {0}",
                                                Math.Abs(currentDistance - distance)), this);
                    Unstuck();
                }
                else if (TravelTime >= MAX_REACHTIME)
                {
                    TravelTime = 0;
                    res = NavigationState.WayPointTimeout;
                    break;
                }
                Output.Instance.Debug(string.Format("Tolerance: {0} - Distance: {1}",
                                                            tolerance, distance), this);
            }

            PlayerCM.ArrowKeyUp(key);
            //isMoving = false;
            return res;
        }
Example #5
0
 public override Endpoint GetEndpoint(string ZoneText, Vector3D waypoint)
 {
     return new Endpoint(EType, ZoneText, waypoint);
 }
Example #6
0
 public override Endpoint GetEndpoint(string ZoneText, Vector3D waypoint)
 {
     BotDataSet.QuestListRow q_row = (BotDataSet.QuestListRow)((DataRowView)
         ((BindingSource)cb_list[0].DataSource).Current).Row;
     BotDataSet.QuestItemsRow obj_row = (BotDataSet.QuestItemsRow)((DataRowView)
         ((BindingSource)cb_list[1].DataSource).Current).Row;
     return new QuestObjEndpoint(EType, q_row.ID, obj_row.IDX, ZoneText, waypoint);
 }
Example #7
0
 public abstract Endpoint GetEndpoint(string ZoneText, Vector3D waypoint);
Example #8
0
 public RadarItem AddItem(ulong id, Vector3D coord, Color color, byte radius, bool is_hollow)
 {
     return AddItem(id, coord, color, radius, is_hollow, null);
 }
Example #9
0
 /// <summary>
 /// Add triangle item to radar
 /// </summary>
 /// <param name="id">Object GUID</param>
 /// <param name="coord">Object absolute coordinated</param>
 /// <param name="dir">Direction (orientation) in radians</param>
 /// <param name="color">Triangle color</param>
 public void AddItem(ulong id, Vector3D coord, double dir, Color color, RadarItem link)
 {
     PointF p = GetXY(coord.X, coord.Y);
     _items.Add(new TriangleRadarItem(id, _r, p, coord.Z, dir, color, link));
 }
Example #10
0
 public static Vector3D operator -(Vector3D v1, Vector3D v2)
 {
     var v3 = new Vector3D((v1.X - v2.X), (v1.Y - v2.Y), (v1.Z - v2.Z));
     return v3;
 }
Example #11
0
 public static Location Vector3DToLocation(Vector3D Vector)
 {
     return new Location(Vector.X, Vector.Y, Vector.Z);
 }
Example #12
0
        /// <summary>
        /// Constructor
        /// </summary>
        public WowPlayer(uint ObjectPointer)
            : base(ObjectPointer)
        {
            LastLocation = new Vector3D();

            //State = PlayerState.Start;
            PlayerCM = ProcessManager.CommandManager;
            LastDistance = 0.0f;
            LastFaceRadian = 0.0f;
            StopMovement = false;
            TravelTime = 0;
            LootableList = new List<WowUnit>();
            //isMoving = false;
            MobBlackList = new List<WowUnit>();

            //create toon's state machine
            StateMachine = new StateMachine<WowPlayer>(this);
            StateMachine.StateChangedEvent += ProcessManager.OnUpdateBotStatus;
        }
Example #13
0
 public void Face(Vector3D dest)
 {
     // NOTE: tanis - begin test
     //float angle = GetFaceAngle(dest);
     //Face(angle);
     float angle = MathFuncs.GetFaceRadian(dest, Location);
     FaceUsingMemoryWrite(angle, false);
     // NOTE: tanis - end
 }
Example #14
0
 public void ClickToMove(Vector3D dest)
 {
     ProcessManager.WowProcess.SuspendThread();
     ProcessManager.WowProcess.WriteFloat(ProcessManager.
                                 GlobalOffsets.ClickToMoveUnknown, 9.0f);
     ProcessManager.WowProcess.WriteFloat(ProcessManager.
                                 GlobalOffsets.ClickToMoveTurnScale, 13.962634f);
     ProcessManager.WowProcess.WriteFloat(ProcessManager.
                                 GlobalOffsets.ClickToMoveUnknown2, 14.0f);
     ProcessManager.WowProcess.WriteFloat(ProcessManager.
                                 GlobalOffsets.ClickToMoveInteractDistance, 0.5f);
     ProcessManager.WowProcess.WriteUInt(ProcessManager.
                                 GlobalOffsets.ClickToMoveActionType,
                             (uint)Descriptor.eClickToMoveActionType.WalkTo);
     ProcessManager.WowProcess.WriteFloat(ProcessManager.
                                 GlobalOffsets.ClickToMoveDestX, dest.X);
     ProcessManager.WowProcess.WriteFloat(ProcessManager.
                                 GlobalOffsets.ClickToMoveDestY, dest.Y);
     ProcessManager.WowProcess.WriteFloat(ProcessManager.
                                 GlobalOffsets.ClickToMoveDestZ, dest.Z);
     ProcessManager.WowProcess.ResumeThread();
 }
Example #15
0
        protected float GetFaceAngle(Vector3D dest)
        {
            float angle = MathFuncs.GetFaceRadian(dest, Location);

            return GetFaceAngle(angle);
        }
Example #16
0
        public void AddCenter(ulong id, Vector3D coord, double dir)
        {
            _ccoord = new PointF(coord.X, coord.Y);
            _items.Clear();

            _center = new TriangleRadarItem(id, _r, new PointF((float)(_size / 2),
                                            (float)(_size / 2)), coord.Z, dir, CustomLineColor);
            _items.Add(_center);
        }
Example #17
0
 public void AddItem(ulong id, Vector3D coord, double dir, Color color)
 {
     AddItem(id, coord, dir, color, null);
 }
Example #18
0
        public bool Equals(Vector3D obj)
        {
            if (ReferenceEquals(null, obj))
                return false;

            return IsEqualTo(obj);
        }
Example #19
0
 /// <summary>
 /// Add circle item to radar
 /// </summary>
 /// <param name="id">Object GUID</param>
 /// <param name="coord">Object absolute coordinated</param>
 /// <param name="color">Circle color</param>
 public void AddItem(ulong id, Vector3D coord, Color color)
 {
     AddItem(id, coord, color, _r, false);
 }
Example #20
0
 /// <summary>
 /// Get distance to destination vector
 /// </summary>
 /// <param name="l">Destination vector</param>
 /// <returns>Distance to destination</returns>
 public float GetDistanceTo(Vector3D l)
 {
     float dx = X - l.X;
     float dy = Y - l.Y;
     float dz = Z - l.Z;
     return (float)Math.Sqrt(dx * dx + dy * dy + dz * dz);
 }
Example #21
0
        /// <summary>
        /// Add circle item to radar
        /// </summary>
        /// <param name="id">Object GUID</param>
        /// <param name="coord">Object absolute coordinated</param>
        /// <param name="color">Circle color</param>
        /// <param name="radius">Circle radius</param>
        /// <param name="is_hollow">Is circle hollow. 
        /// Please note that circle outer width is 1 pixels
        /// so if radius is 2 pixels than it can't be hollow</param>
        public RadarItem AddItem(ulong id, Vector3D coord, 
                    Color color, byte radius, bool is_hollow, RadarItem link)
        {
            PointF p = GetXY(coord.X, coord.Y);
            RadarItem ri = new CircleRadarItem(id, radius, p, coord.Z, color, is_hollow, link);
            _items.Add(ri);

            return ri;
        }
Example #22
0
 /// <summary>
 /// Check if 2 vectors located in 5 yards distance from each other
 /// </summary>
 /// <param name="v">Destination vector</param>
 /// <returns>TRUE if 2 vectors located in 5 yards range between each other
 /// and FALSE if not</returns>
 public bool IsClose(Vector3D v)
 {
     return IsClose(v, 5F);
 }
Example #23
0
 public static float GetFaceRadian(Vector3D dest, Vector3D currentPos)
 {
     return negativeAngle((float) Math.Atan2((double) (dest.Y - currentPos.Y), (double) (dest.X - currentPos.X)));
 }
Example #24
0
 /// <summary>
 /// Check if 2 vectors located close to each other
 /// </summary>
 /// <param name="v">Destination vector</param>
 /// <param name="distance">Distance between vectors 
 /// that considered to be "close distance"</param>
 /// <returns>TRUE if 2 vectors located in given distance between each other
 /// and FALSE if not</returns>
 public bool IsClose(Vector3D v, float distance)
 {
     return (GetDistanceTo(v) <= distance);
 }
Example #25
0
 public override Endpoint GetEndpoint(string ZoneText, Vector3D waypoint)
 {
     return new GameObjEndpoint(EType, cb_list[0].Text, ZoneText, waypoint);
 }
Example #26
0
 /// <summary>
 /// Normalize vector i.e divide each coordinate on vector length (from center)
 /// so lenth of new vector is always 1
 /// </summary>
 /// <returns>Normalized vector</returns>
 public Vector3D Normalize()
 {
     double length = Length;
     var v = new Vector3D();
     v.X = (float) (X/length);
     v.Y = (float) (Y/length);
     v.Z = (float) (Z/length);
     return v;
 }
Example #27
0
        public Route GetRoute(Vector3D a, Vector3D b)
        {
            // Check if B is set
            if (!(CheckEndpoints() &&
                ((AbstractListEndpoint)cbTypeA.SelectedItem).Check &&
                ((AbstractListEndpoint)cbTypeB.SelectedItem).Check))
                    return null;

            // Make route
            AbstractListEndpoint point_a = cbTypeA.SelectedItem as AbstractListEndpoint;
            AbstractListEndpoint point_b = cbTypeB.SelectedItem as AbstractListEndpoint;

            // Make new route
            Route route = new Route(
                    point_a.GetEndpoint(tbZoneA.Text, a),
                    point_b.GetEndpoint(tbZoneB.Text, b),
                        tbDescr.Text, cbReversible.Checked);

            return route;
        }
Example #28
0
 /// <summary>
 /// Compare itself with destination vector
 /// Used stricly internally assumed all verification done and
 /// destination vector not null and the same object type
 /// </summary>
 /// <param name="v"></param>
 /// <returns></returns>
 private bool IsEqualTo(Vector3D v)
 {
     return (ReferenceEquals(this, v) ||
        v.X == X && v.Y == Y && v.Z == Z && v.VType == VType);
 }
Example #29
0
 private void AddGameObjCoord(string zone, Vector3D v)
 {
     AddGameObjCoord(zone, v.X, v.Y, v.Z, v.Type);
 }
Example #30
0
 /// <summary>
 /// Makes the player walk from the current location to the location of "dest" with 
 /// a default tolerance of 1 yard.
 /// </summary>
 /// <param name="dest">Destination</param>
 /// <returns>A NavigationState indicating what the result of the movement was</returns>
 public NavigationState MoveTo(Vector3D dest)
 {
     return MoveTo(dest, 1.0f);
 }