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; }
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; }
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))); }
/// <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; }
public override Endpoint GetEndpoint(string ZoneText, Vector3D waypoint) { return new Endpoint(EType, ZoneText, waypoint); }
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); }
public abstract Endpoint GetEndpoint(string ZoneText, Vector3D waypoint);
public RadarItem AddItem(ulong id, Vector3D coord, Color color, byte radius, bool is_hollow) { return AddItem(id, coord, color, radius, is_hollow, null); }
/// <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)); }
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; }
public static Location Vector3DToLocation(Vector3D Vector) { return new Location(Vector.X, Vector.Y, Vector.Z); }
/// <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; }
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 }
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(); }
protected float GetFaceAngle(Vector3D dest) { float angle = MathFuncs.GetFaceRadian(dest, Location); return GetFaceAngle(angle); }
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); }
public void AddItem(ulong id, Vector3D coord, double dir, Color color) { AddItem(id, coord, dir, color, null); }
public bool Equals(Vector3D obj) { if (ReferenceEquals(null, obj)) return false; return IsEqualTo(obj); }
/// <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); }
/// <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); }
/// <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; }
/// <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); }
public static float GetFaceRadian(Vector3D dest, Vector3D currentPos) { return negativeAngle((float) Math.Atan2((double) (dest.Y - currentPos.Y), (double) (dest.X - currentPos.X))); }
/// <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); }
public override Endpoint GetEndpoint(string ZoneText, Vector3D waypoint) { return new GameObjEndpoint(EType, cb_list[0].Text, ZoneText, waypoint); }
/// <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; }
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; }
/// <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); }
private void AddGameObjCoord(string zone, Vector3D v) { AddGameObjCoord(zone, v.X, v.Y, v.Z, v.Type); }
/// <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); }