Пример #1
0
        public bool IsMatch(WowObject wowObject)
        {
            var named = wowObject as INamed;

            if (named == null) return false;

            return (named.Name.Equals(Pattern, StringComparison.InvariantCultureIgnoreCase) ||
                    Utilities.Tracking.WildCardMatches(named.Name.ToUpperInvariant(), Pattern.ToUpperInvariant()));
        }
Пример #2
0
 /// <summary>
 /// Instantiates a new WowBlip control.  Can only be called by child classes.
 /// </summary>
 /// <param name="wowObject">WoW Object this blip represents.  The type of this object will determine the
 /// polymorphic properties of the instance blip.</param>
 protected WowBlip(WowObject wowObject)
 {
     BlipObject = wowObject;
     SetStyle(ControlStyles.SupportsTransparentBackColor, true);
     InitializeComponent();
     objectInfo.Text = string.Format("{0} | {1}",
                                     wowObject is INamed ? ((INamed) wowObject).Name : wowObject.ToString(),
                                     wowObject.Entry);
 }
        private GameObject CreateCharacterGameObjects(WowObject characterWowObject)
        {
            var containerGo = new GameObject("character_container");

            containerGo.transform.position = Vector3.zero;

            var characterGo = CreateGameObjectForCharacterWowObject("character", containerGo.transform, characterWowObject, out var rootBoneGo);

            return(containerGo);
        }
Пример #4
0
 public void InteractWithObject(WowObject obj, float turnSpeed = 20.9f, float distance = 3f)
 {
     XMemory.Write(OffsetList.ClickToMoveX, obj.Position.X);
     XMemory.Write(OffsetList.ClickToMoveY, obj.Position.Y);
     XMemory.Write(OffsetList.ClickToMoveZ, obj.Position.Z);
     XMemory.Write(OffsetList.ClickToMoveTurnSpeed, turnSpeed);
     XMemory.Write(OffsetList.ClickToMoveDistance, distance);
     XMemory.Write(OffsetList.ClickToMoveGuid, obj.Guid);
     XMemory.Write(OffsetList.ClickToMoveAction, (int)ClickToMoveType.InteractObject);
 }
Пример #5
0
        /// <summary>
        /// Check if GameObject can be found around
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public bool LookForGameObjClose(GameObject obj)
        {
            WowObject wo = ProcessManager.ObjectManager.LookForGameObj(obj.Name);

            if (wo == null)
            {
                return(false);
            }

            return(wo.Location.IsClose(ProcessManager.Player.Location));
        }
Пример #6
0
 private void RightClickQuestgiver(WowObject obj)
 {
     if (obj.GetType() == typeof(WowGameobject))
     {
         WowInterface.HookManager.WowObjectRightClick(obj);
     }
     else if (obj.GetType() == typeof(WowUnit))
     {
         WowInterface.HookManager.WowUnitRightClick((WowUnit)obj);
     }
 }
Пример #7
0
        public bool IsMatch(WowObject wowObject)
        {
            var named = wowObject as INamed;

            if (named == null)
            {
                return(false);
            }

            return(named.Name.Equals(Pattern, StringComparison.InvariantCultureIgnoreCase) ||
                   Utilities.Tracking.WildCardMatches(named.Name.ToUpperInvariant(), Pattern.ToUpperInvariant()));
        }
        private GameObject CreateSkeletonForWowObject(Transform parent, WowObject wowObject, out Transform[] boneTransforms)
        {
            var wowRootBone = wowObject.GetRootBone();

            if (wowRootBone == null)
            {
                boneTransforms = new Transform[0];
                return(null);
            }

            boneTransforms = new Transform[wowObject.Bones.Length];
            return(CreateSkeletonElementsForWowBoneAndItsChildren(parent, wowRootBone, boneTransforms));
        }
Пример #9
0
        private WowObject ReadWowObject(IntPtr activeObject, WowObjectType wowObjectType)
        {
            if (WowInterface.XMemory.Read(IntPtr.Add(activeObject, WowInterface.OffsetList.WowObjectDescriptor.ToInt32()), out IntPtr descriptorAddress) &&
                WowInterface.XMemory.ReadStruct(IntPtr.Add(activeObject, WowInterface.OffsetList.WowObjectPosition.ToInt32()), out Vector3 position))
            {
                WowObject obj = new WowObject(activeObject, wowObjectType)
                {
                    DescriptorAddress = descriptorAddress,
                    Position          = position
                };

                return(obj.UpdateRawWowObject(WowInterface.XMemory));
            }

            return(null);
        }
Пример #10
0
        public static void ReadCreateObjectBlock(Packet packet, Guid guid, short map)
        {
            var objType = packet.ReadEnum <ObjectType>("Object Type");
            var moves   = ReadMovementUpdateBlock(packet, guid);
            var updates = ReadValuesUpdateBlock(packet);

            var obj = new WowObject(guid, objType, moves);

            obj.Position = moves.Position;

            if (!Objects.ContainsKey(map))
            {
                Objects.Add(map, new Dictionary <Guid, WowObject>());
            }
            Objects[map].Add(guid, obj);
            HandleUpdateFieldChangedValues(true, guid, objType, updates, moves);
        }
Пример #11
0
        public bool SetMouseOver(WowObject wowObject)
        {
            Point objectClientPosition = new Point();

            var visible = WowCamera.ActiveCamera.WorldToScreen(wowObject.Position, ref objectClientPosition);

            if (!visible)
            {
                return(false);
            }

            Point target = NativeMethods.ClientToScreen(GameManager.WindowHandle, objectClientPosition.X, objectClientPosition.Y);

            if (IsPointOutsideScreen(target))
            {
                return(false);
            }

            if (Settings.Default.MouseTeleport)
            {
                Position = target;
                Thread.Sleep(200);
                return(wowObject.IsMouseOver);
            }

            Point     start = Position;
            float     t     = 0;
            Stopwatch timer = new Stopwatch();

            timer.Start();
            long lastTime = timer.ElapsedMilliseconds;

            while (_position.X != target.X && _position.Y != target.Y)
            {
                var   currentTime = timer.ElapsedMilliseconds;
                float deltaTime   = (currentTime - lastTime);
                lastTime = currentTime;

                Position = Utils.MathUtils.MoveTowards(start, target, t);
                t       += deltaTime;
            }
            Thread.Sleep(200);
            return(wowObject.IsMouseOver);
        }
Пример #12
0
        /// <summary>
        /// Checks if the supplied object matches any <see cref="Trackable"/> in itself.
        /// </summary>
        /// <param name="wowObject">Any object of (sub)type <see cref="WowObject"/></param>
        /// <param name="alreadyTracked">Whether or not the blip containing <paramref name="wowObject"/> is currently tracked.</param>
        /// <returns><c>TRUE</c> if any <see cref="Trackable"/> in this list matches <see cref="wowObject"/>.</returns>
        internal bool IsTracked(WowObject wowObject, bool alreadyTracked)
        {
            if (_trackables.Exists(t => t.IsMatch(wowObject)))
            {
                // Play our tracking sound if we have not done so already.
                if (!alreadyTracked)
                {
                    if (!string.IsNullOrEmpty(SoundFile))
                    {
                        Settings.Sounds.List.Sounds[SoundFile].Play();
                    }
                    else
                    {
                        Settings.Sounds.List.Default.Play();
                    }
                }

                return(true);
            }

            return(false);
        }
Пример #13
0
 public void UpdateObject(WowObjectType wowObjectType, IntPtr baseAddress)
 {
     lock (queryLock)
     {
         if (wowObjects.Count > 0)
         {
             wowObjects.RemoveAll(e => e.BaseAddress == baseAddress);
             WowObject obj = wowObjectType switch
             {
                 WowObjectType.Dynobject => ReadWowDynobject(baseAddress, wowObjectType),
                 WowObjectType.Gameobject => ReadWowGameobject(baseAddress, wowObjectType),
                 WowObjectType.Player => ReadWowPlayer(baseAddress, wowObjectType),
                 WowObjectType.Unit => ReadWowUnit(baseAddress, wowObjectType),
                 WowObjectType.Corpse => ReadWowCorpse(baseAddress, wowObjectType),
                 WowObjectType.Container => ReadWowContainer(baseAddress, wowObjectType),
                 WowObjectType.Item => ReadWowItem(baseAddress, wowObjectType),
                 _ => ReadWowObject(baseAddress, wowObjectType),
             };
             wowObjects.Add(obj);
         }
     }
 }
Пример #14
0
 public uint Interact(WowObject obj)
 {
     return(Interact(obj));
 }
Пример #15
0
 /// <summary>
 /// Helper override which takes a WowObject instance instead of base address.
 /// </summary>
 /// <param name="obj">WowObject Instance</param>
 /// <param name="method">Method offset. Note that this offset should already have been multiplied by 4 to get the absolute offset.</param>
 /// <returns>Address of the result if there is one.</returns>
 public uint CallVMT(WowObject obj, uint method)
 {
     return(CallVMT(obj.ObjectPointer, method));
 }
Пример #16
0
        public void UpdateWowObjects()
        {
            if (!XMemory.Read(OffsetList.IsWorldLoaded, out int isWorldLoaded))
            {
                IsWorldLoaded = isWorldLoaded == 1;
                return;
            }

            if (XMemory.Read(OffsetList.PlayerGuid, out ulong playerGuid))
            {
                PlayerGuid = playerGuid;
            }

            if (XMemory.Read(OffsetList.TargetGuid, out ulong targetGuid))
            {
                TargetGuid = targetGuid;
            }

            if (XMemory.Read(OffsetList.TargetGuid, out ulong lastTargetGuid))
            {
                LastTargetGuid = lastTargetGuid;
            }

            if (XMemory.Read(OffsetList.PetGuid, out ulong petGuid))
            {
                PetGuid = petGuid;
            }

            if (XMemory.Read(OffsetList.TargetGuid, out IntPtr playerbase))
            {
                PlayerBase = playerbase;
            }

            WowObjects = new List <WowObject>();
            XMemory.Read(OffsetList.ClientConnection, out IntPtr clientConnection);
            XMemory.Read(IntPtr.Add(clientConnection, OffsetList.CurrentObjectManager.ToInt32()), out IntPtr currentObjectManager);

            XMemory.Read(IntPtr.Add(currentObjectManager, OffsetList.FirstObject.ToInt32()), out IntPtr activeObject);
            XMemory.Read(IntPtr.Add(activeObject, OffsetList.WowObjectType.ToInt32()), out int objectType);

            while (isWorldLoaded == 1 && (objectType <= 7 && objectType > 0))
            {
                WowObjectType wowObjectType = (WowObjectType)objectType;
                WowObject     obj           = wowObjectType switch
                {
                    WowObjectType.Gameobject => ReadWowGameobject(activeObject, wowObjectType),
                    WowObjectType.Dynobject => ReadWowDynobject(activeObject, wowObjectType),
                    WowObjectType.Unit => ReadWowUnit(activeObject, wowObjectType),
                    WowObjectType.Player => ReadWowPlayer(activeObject, wowObjectType),
                    _ => ReadWowObject(activeObject, wowObjectType),
                };

                WowObjects.Add(obj);

                if (obj.Guid == TargetGuid)
                {
                    Target = (WowUnit)obj;
                }

                if (obj.Guid == PetGuid)
                {
                    Pet = (WowUnit)obj;
                }

                if (obj.Guid == LastTargetGuid)
                {
                    LastTarget = (WowUnit)obj;
                }

                XMemory.Read(IntPtr.Add(activeObject, OffsetList.NextObject.ToInt32()), out activeObject);
                XMemory.Read(IntPtr.Add(activeObject, OffsetList.WowObjectType.ToInt32()), out objectType);
            }

            PartyleaderGuid  = ReadPartyLeaderGuid();
            PartymemberGuids = ReadPartymemberGuids();

            if (XMemory.Read(OffsetList.MapId, out int mapId))
            {
                MapId = mapId;
            }

            if (XMemory.Read(OffsetList.ZoneId, out int zoneId))
            {
                ZoneId = zoneId;
            }

            OnObjectUpdateComplete?.Invoke(WowObjects);
        }
Пример #17
0
        public void UpdateWowObjects()
        {
            lock (queryLock)
            {
                IsWorldLoaded = UpdateGlobalVar <int>(WowInterface.OffsetList.IsWorldLoaded) == 1;

                if (!IsWorldLoaded)
                {
                    return;
                }

                PlayerGuid     = UpdateGlobalVar <ulong>(WowInterface.OffsetList.PlayerGuid);
                TargetGuid     = UpdateGlobalVar <ulong>(WowInterface.OffsetList.TargetGuid);
                LastTargetGuid = UpdateGlobalVar <ulong>(WowInterface.OffsetList.LastTargetGuid);
                PetGuid        = UpdateGlobalVar <ulong>(WowInterface.OffsetList.PetGuid);
                PlayerBase     = UpdateGlobalVar <IntPtr>(WowInterface.OffsetList.PlayerBase);
                MapId          = UpdateGlobalVar <MapId>(WowInterface.OffsetList.MapId);
                ZoneId         = UpdateGlobalVar <int>(WowInterface.OffsetList.ZoneId);

                if (WowInterface.XMemory.Read(WowInterface.OffsetList.CameraPointer, out IntPtr cameraPointer) &&
                    WowInterface.XMemory.Read(IntPtr.Add(cameraPointer, WowInterface.OffsetList.CameraOffset.ToInt32()), out cameraPointer))
                {
                    Camera = UpdateGlobalVar <CameraInfo>(cameraPointer);
                }

                if (WowInterface.XMemory.Read(WowInterface.OffsetList.ZoneText, out IntPtr zoneNamePointer))
                {
                    ZoneName = UpdateGlobalVarString(zoneNamePointer);
                }

                if (WowInterface.XMemory.Read(WowInterface.OffsetList.ZoneSubText, out IntPtr zoneSubNamePointer))
                {
                    ZoneSubName = UpdateGlobalVarString(zoneSubNamePointer);
                }

                GameState = UpdateGlobalVarString(WowInterface.OffsetList.GameState);

                wowObjects.Clear();

                // get the current objectmanager
                // better not cache it until we switched map
                WowInterface.XMemory.Read(WowInterface.OffsetList.ClientConnection, out IntPtr clientConnection);
                WowInterface.XMemory.Read(IntPtr.Add(clientConnection, WowInterface.OffsetList.CurrentObjectManager.ToInt32()), out IntPtr currentObjectManager);
                CurrentObjectManager = currentObjectManager;

                // read the first object
                WowInterface.XMemory.Read(IntPtr.Add(CurrentObjectManager, WowInterface.OffsetList.FirstObject.ToInt32()), out IntPtr activeObjectBaseAddress);
                WowInterface.XMemory.Read(IntPtr.Add(activeObjectBaseAddress, WowInterface.OffsetList.WowObjectType.ToInt32()), out int activeObjectType);

                while (IsWorldLoaded && activeObjectType <= 7 && activeObjectType > 0)
                {
                    WowObjectType wowObjectType = (WowObjectType)activeObjectType;
                    WowObject     obj           = wowObjectType switch
                    {
                        WowObjectType.Container => ReadWowContainer(activeObjectBaseAddress, wowObjectType),
                        WowObjectType.Corpse => ReadWowCorpse(activeObjectBaseAddress, wowObjectType),
                        WowObjectType.Item => ReadWowItem(activeObjectBaseAddress, wowObjectType),
                        WowObjectType.Dynobject => ReadWowDynobject(activeObjectBaseAddress, wowObjectType),
                        WowObjectType.Gameobject => ReadWowGameobject(activeObjectBaseAddress, wowObjectType),
                        WowObjectType.Player => ReadWowPlayer(activeObjectBaseAddress, wowObjectType),
                        WowObjectType.Unit => ReadWowUnit(activeObjectBaseAddress, wowObjectType),
                        _ => ReadWowObject(activeObjectBaseAddress, wowObjectType),
                    };

                    if (obj != null)
                    {
                        wowObjects.Add(obj);

                        // set the global unit properties if a guid matches it
                        if (obj.Guid == TargetGuid)
                        {
                            Target = (WowUnit)obj;
                        }
                        if (obj.Guid == PetGuid)
                        {
                            Pet = (WowUnit)obj;
                        }
                        if (obj.Guid == LastTargetGuid)
                        {
                            LastTarget = (WowUnit)obj;
                        }
                    }

                    WowInterface.XMemory.Read(IntPtr.Add(activeObjectBaseAddress, WowInterface.OffsetList.NextObject.ToInt32()), out activeObjectBaseAddress);
                    WowInterface.XMemory.Read(IntPtr.Add(activeObjectBaseAddress, WowInterface.OffsetList.WowObjectType.ToInt32()), out activeObjectType);
                }

                // read the party/raid leaders guid and if there is one, the group too
                PartyleaderGuid = ReadPartyLeaderGuid();
                if (PartyleaderGuid > 0)
                {
                    PartymemberGuids = ReadPartymemberGuids();
                }
            }

            OnObjectUpdateComplete?.Invoke(WowObjects);
        }
Пример #18
0
        string GetObjInfo(WowObject obj)
        {
            if (obj.Type == WowObjectType.Container)
                return "Num. slots: " + (obj as WowContainer).NumSlots.ToString();

            if (obj.Guid == Game.ObjMgr.ActivePlayer)
                return "<<< Me!" + " " + (obj as WowUnit).Position;

            if (obj.Type == WowObjectType.GameObject)
            {
                var go = obj as WowGameObject;
                return "GO" + " type " + go.TypeId + ", " + go.Position;
            }

            if (obj.Type == WowObjectType.Player)
                return "Home Realm: " + (obj as WowPlayer).RealmId.ToString("X8");

            if (obj.Type == WowObjectType.Unit && (obj as WowUnit).IsPet)
                return "Pet";

            return String.Empty;
        }
Пример #19
0
 public static void InteractObject(WowObject obj, float minDistance = 4f)
 {
     CTMHelper.ClickToMove(obj.X, obj.Y, 0, CTMHelper.CTMAction.InteractObject, obj.GUID);
 }
Пример #20
0
 public static bool SetMouseOver(WowObject wowObject)
 {
     return(_mouseStrategy.SetMouseOver(wowObject));
 }
Пример #21
0
 public uint Interact(WowObject obj)
 {
     return Interact(obj);
 }
Пример #22
0
 /// <summary>
 /// Helper override which takes a WowObject instance instead of base address.
 /// </summary>
 /// <param name="obj">WowObject Instance</param>
 /// <param name="method">Method offset. Note that this offset should already have been multiplied by 4 to get the absolute offset.</param>
 /// <returns>Address of the result if there is one.</returns>
 public uint CallVMT(WowObject obj, uint method)
 {
     return CallVMT(obj.ObjectPointer, method);
 }
Пример #23
0
 public bool SetMouseOver(WowObject wowObject)
 {
     GameManager.GameMemory.Write(new IntPtr(GameManager.BaseAddress + Addresses.Player.MouseOverGuid), wowObject.Guid.ToArray());
     return(wowObject.IsMouseOver);
 }
Пример #24
0
        /// <summary>
        /// Checks if the supplied object matches any <see cref="Trackable"/> in itself.
        /// </summary>
        /// <param name="wowObject">Any object of (sub)type <see cref="WowObject"/></param>
        /// <param name="alreadyTracked">Whether or not the blip containing <paramref name="wowObject"/> is currently tracked.</param>
        /// <returns><c>TRUE</c> if any <see cref="Trackable"/> in this list matches <see cref="wowObject"/>.</returns>
        internal bool IsTracked(WowObject wowObject, bool alreadyTracked)
        {
            if (_trackables.Exists(t => t.IsMatch(wowObject)))
            {
                // Play our tracking sound if we have not done so already.
                if (!alreadyTracked)
                {
                    if (!string.IsNullOrEmpty(SoundFile))
                        Settings.Sounds.List.Sounds[SoundFile].Play();
                    else
                        Settings.Sounds.List.Default.Play();
                }

                return true;
            }

            return false;
        }
Пример #25
0
        public WowUnit ReadWowUnit(IntPtr activeObject, WowObjectType wowObjectType = WowObjectType.Unit)
        {
            WowObject wowObject = ReadWowObject(activeObject, wowObjectType);

            if (wowObject != null &&
                XMemory.Read(IntPtr.Add(wowObject.DescriptorAddress, OffsetList.DescriptorTargetGuid.ToInt32()), out ulong targetGuid) &&
                XMemory.ReadStruct(IntPtr.Add(activeObject, OffsetList.WowUnitPosition.ToInt32()), out Vector3 wowPosition) &&
                XMemory.Read(IntPtr.Add(activeObject, OffsetList.PlayerRotation.ToInt32()), out float rotation) &&
                XMemory.Read(IntPtr.Add(activeObject, OffsetList.IsAutoAttacking.ToInt32()), out int isAutoAttacking) &&
                XMemory.Read(IntPtr.Add(wowObject.DescriptorAddress, OffsetList.DescriptorCombatReach.ToInt32()), out int combatReach) &&
                XMemory.Read(IntPtr.Add(wowObject.DescriptorAddress, OffsetList.DescriptorFactionTemplate.ToInt32()), out int factionTemplate) &&
                XMemory.Read(IntPtr.Add(wowObject.DescriptorAddress, OffsetList.DescriptorUnitFlags.ToInt32()), out BitVector32 unitFlags) &&
                XMemory.Read(IntPtr.Add(wowObject.DescriptorAddress, OffsetList.DescriptorUnitFlagsDynamic.ToInt32()), out BitVector32 dynamicUnitFlags) &&
                XMemory.Read(IntPtr.Add(wowObject.DescriptorAddress, OffsetList.DescriptorNpcFlags.ToInt32()), out BitVector32 npcFlags) &&
                XMemory.Read(IntPtr.Add(wowObject.DescriptorAddress, OffsetList.DescriptorHealth.ToInt32()), out int health) &&
                XMemory.Read(IntPtr.Add(wowObject.DescriptorAddress, OffsetList.DescriptorMaxHealth.ToInt32()), out int maxHealth) &&
                XMemory.Read(IntPtr.Add(wowObject.DescriptorAddress, OffsetList.DescriptorMana.ToInt32()), out int mana) &&
                XMemory.Read(IntPtr.Add(wowObject.DescriptorAddress, OffsetList.DescriptorMaxMana.ToInt32()), out int maxMana) &&
                XMemory.Read(IntPtr.Add(wowObject.DescriptorAddress, OffsetList.DescriptorRage.ToInt32()), out int rage) &&
                XMemory.Read(IntPtr.Add(wowObject.DescriptorAddress, OffsetList.DescriptorMaxRage.ToInt32()), out int maxRage) &&
                XMemory.Read(IntPtr.Add(wowObject.DescriptorAddress, OffsetList.DescriptorEnergy.ToInt32()), out int energy) &&
                XMemory.Read(IntPtr.Add(wowObject.DescriptorAddress, OffsetList.DescriptorMaxEnergy.ToInt32()), out int maxEnergy) &&
                XMemory.Read(IntPtr.Add(wowObject.DescriptorAddress, OffsetList.DescriptorRuneenergy.ToInt32()), out int runeenergy) &&
                XMemory.Read(IntPtr.Add(wowObject.DescriptorAddress, OffsetList.DescriptorMaxRuneenergy.ToInt32()), out int maxRuneenergy) &&
                XMemory.Read(IntPtr.Add(wowObject.DescriptorAddress, OffsetList.DescriptorLevel.ToInt32()), out int level) &&
                XMemory.Read(IntPtr.Add(wowObject.DescriptorAddress, OffsetList.DescriptorInfoFlags.ToInt32()), out int infoFlags) &&
                XMemory.Read(IntPtr.Add(activeObject, OffsetList.CurrentlyCastingSpellId.ToInt32()), out int currentlyCastingSpellId) &&
                XMemory.Read(IntPtr.Add(activeObject, OffsetList.CurrentlyChannelingSpellId.ToInt32()), out int currentlyChannelingSpellId))
            {
                return(new WowUnit()
                {
                    BaseAddress = activeObject,
                    CombatReach = combatReach,
                    DescriptorAddress = wowObject.DescriptorAddress,
                    Guid = wowObject.Guid,
                    Type = wowObjectType,
                    Name = ReadUnitName(activeObject, wowObject.Guid),
                    TargetGuid = targetGuid,
                    Position = wowPosition,
                    Rotation = rotation,
                    FactionTemplate = factionTemplate,
                    UnitFlags = unitFlags,
                    UnitFlagsDynamic = dynamicUnitFlags,
                    Health = health,
                    MaxHealth = maxHealth,
                    Mana = mana,
                    MaxMana = maxMana,
                    NpcFlags = npcFlags,
                    Energy = energy,
                    MaxEnergy = maxEnergy,
                    Rage = rage / 10,
                    MaxRage = maxRage / 10,
                    Runeenergy = runeenergy / 10,
                    MaxRuneenergy = maxRuneenergy / 10,
                    Level = level,
                    Race = Enum.IsDefined(typeof(WowRace), (WowRace)((infoFlags >> 0) & 0xFF)) ? (WowRace)((infoFlags >> 0) & 0xFF) : WowRace.Unknown,
                    Class = Enum.IsDefined(typeof(WowClass), (WowClass)((infoFlags >> 8) & 0xFF)) ? (WowClass)((infoFlags >> 8) & 0xFF) : WowClass.Unknown,
                    Gender = Enum.IsDefined(typeof(WowGender), (WowGender)((infoFlags >> 16) & 0xFF)) ? (WowGender)((infoFlags >> 16) & 0xFF) : WowGender.Unknown,
                    PowerType = Enum.IsDefined(typeof(WowPowertype), (WowPowertype)((infoFlags >> 24) & 0xFF)) ? (WowPowertype)((infoFlags >> 24) & 0xFF) : WowPowertype.Unknown,
                    IsAutoAttacking = isAutoAttacking == 1,
                    CurrentlyCastingSpellId = currentlyCastingSpellId,
                    CurrentlyChannelingSpellId = currentlyChannelingSpellId
                });
            }

            return(null);
        }
Пример #26
0
 public static void InteractObject(WowObject obj, float minDistance = 4f)
 {
     CTMHelper.ClickToMove(obj.X, obj.Y, 0, CTMHelper.CTMAction.InteractObject, obj.GUID);
 }
        private GameObject CreateGameObjectForCharacterWowObject(string name, Transform parent, WowObject characterWowObject, out GameObject rootBoneGo)
        {
            var mesh      = CreateMeshFromWowMeshWithMaterials(characterWowObject.MainMesh);
            var materials = CreateMaterialsFromWowMeshWithMaterials(characterWowObject.MainMesh);

            var go = new GameObject(name);

            go.transform.position = new Vector3(characterWowObject.GlobalPosition.X, characterWowObject.GlobalPosition.Y, characterWowObject.GlobalPosition.Z);
            go.transform.parent   = parent;

            var skinnedMeshRenderer = go.AddComponent <SkinnedMeshRenderer>();

            skinnedMeshRenderer.sharedMesh = mesh;
            skinnedMeshRenderer.materials  = materials;

            rootBoneGo = CreateSkeletonForWowObject(parent, characterWowObject, out var boneTransforms);

            ApplyMeshBindposesFromBoneHierarchy(mesh, boneTransforms, rootBoneGo.transform);

            skinnedMeshRenderer.bones = boneTransforms;

            return(go);
        }
Пример #28
0
 public string GetName(WowObject obj)
 {
     return(GetName(obj.ObjectPointer));
 }
Пример #29
0
 /// <summary>
 /// Helper override which takes a WowObject instance instead of GUID.
 /// </summary>
 /// <param name="obj">WowObject Instance</param>
 public void SelectUnit(WowObject obj)
 {
     SelectUnit(obj.Guid);
 }
Пример #30
0
        private void UpdateRadar(RadarData RadarData)
        {
            if (ResizingRadar) return;
            try
            {
                lock (this.lockdevice)
                {
                    if (this.device != null && RadarData.Me != null)
                    {
                        this.focusObject = null;

                        if (focusObjectOverrideGuid != null)
                        {
                            var focusObjectOverride = RadarData.GetWowObjectByGuid(focusObjectOverrideGuid.Value);

                            if (focusObjectOverride != null)
                                this.focusObject = focusObjectOverride;
                            //else
                            // focusObjectOverrideGuid = null;
                        }

                        if (this.focusObject == null)
                            this.focusObject = RadarData.Me;

                        var zoneId = ((WowPlayerMe)RadarData.Me).ZoneID;

                        this.device.Clear(ClearFlags.Target, Color.Black, 1f, 0);

                        float valueZ = 100000f;
                        Microsoft.DirectX.Vector3 cameraPosition = new Microsoft.DirectX.Vector3(0f, 0f, valueZ);
                        Microsoft.DirectX.Vector3 cameraTarget = new Microsoft.DirectX.Vector3(0f, 0f, 0f);
                        Microsoft.DirectX.Vector3 cameraUpVector = new Microsoft.DirectX.Vector3(0f, -1f, 0f);

                        Microsoft.DirectX.Matrix sourceMatrix = Microsoft.DirectX.Matrix.RotationY(Rotation) * Microsoft.DirectX.Matrix.RotationX(Rotation);
                        if (this.settings.RotateMap)
                        {
                            sourceMatrix *= Microsoft.DirectX.Matrix.RotationZ(6.283185f - this.focusObject.Facing);
                        }

                        cameraPosition.TransformCoordinate(sourceMatrix);
                        cameraTarget.TransformCoordinate(sourceMatrix);
                        cameraUpVector.TransformCoordinate(sourceMatrix);
                        cameraTarget.Add(new Microsoft.DirectX.Vector3(this.focusObject.X, this.focusObject.Y, this.focusObject.Z));
                        cameraPosition.Add(new Microsoft.DirectX.Vector3(this.focusObject.X, this.focusObject.Y, this.focusObject.Z));

                        this.device.Transform.View = Microsoft.DirectX.Matrix.LookAtLH(cameraPosition, cameraTarget, cameraUpVector);
                        this.device.Transform.Projection = Microsoft.DirectX.Matrix.PerspectiveLH(((float)base.Width) / (valueZ * this.scale), ((float)base.Height) / (valueZ * this.scale), 1f, 1000000f);
                        this.device.BeginScene();

                        if (this.showMapTexturesOverride && this.settings.ShowMinimap)
                        {
                            this.DrawMinimap();
                        }

                        foreach (var WowObject in RadarData.Objects)
                        {
                            PresentWowObject(WowObject);
                        }

                        PresentWowObject(RadarData.Me);

                        var ArchaeologyCacheList = BlackRain.Cache.ArchaeologyCache.ObjList.Where(t => t.ZoneID == zoneId);

                        foreach (var WowGameObject in ArchaeologyCacheList)
                        {
                            PresentWowObject(WowGameObject);
                        }

                        this.device.EndScene();
                        this.device.Present();

                        ClearAlerts(RadarData);
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);

                this.InitializeDXDevice();

            }

        }
Пример #31
0
        public static bool IsInRange(WowObject a, WowObject b, double maxDistance)
        {
            double distance = a.Position.GetDistance(b.Position);

            return(distance < maxDistance && distance > maxDistance);
        }
Пример #32
0
 public void GameobjectOnRightClick(WowObject gameobject)
 => CallObjectFunction(gameobject.BaseAddress, WowInterface.OffsetList.FunctionGameobjectOnRightClick);
Пример #33
0
        public override void Save(StreamHandler Writer)
        {
            Writer.WriteUInt16((ushort)this.Map);

            EnsureRead();

            long nUpdatesPos = Writer.BaseStream.Position;
            uint nUpdates    = 0;

            Writer.WriteUInt32(nUpdates);

            if (this.DestroyedObjects.Count > 0)
            {
                ++nUpdates;
                Writer.WriteByte((byte)UpdateTypes.DestroyObjects);

                Writer.WriteInt32(this.DestroyedObjects.Count);
                foreach (WowGuid guid in this.DestroyedObjects)
                {
                    Writer.WritePackedGuid(guid);
                }
            }

            foreach (var pair in this.ValuesUpdates)
            {
                ++nUpdates;
                Writer.WriteByte((byte)UpdateTypes.UpdateValues);

                Writer.WritePackedGuid(pair.Key);
                WriteValues(Writer, pair.Value, WowObject.GetTypeId(pair.Key.Type));
            }

            foreach (var pair in this.CreatedObjects)
            {
                ++nUpdates;
                var type = UpdateTypes.CreateObjects;

                var obj = pair.Value;

                if (obj.MovementData.HavePosition)
                {
                    if (obj.TypeId == ObjectTypeId.DynamicObject ||
                        obj.TypeId == ObjectTypeId.Corpse ||
                        obj.TypeId == ObjectTypeId.Player)
                    {
                        type = UpdateTypes.CreateObjects2;
                    }

                    if (obj.TypeId == ObjectTypeId.GameObject && obj is WowGameObject)
                    {
                        switch ((obj as WowGameObject).GameObjectType)
                        {
                        case GameObjectTypes.Trap:
                        case GameObjectTypes.DuelArbiter:
                        case GameObjectTypes.FlagStand:
                        case GameObjectTypes.FlagDrop:
                            type = UpdateTypes.CreateObjects2;
                            break;
                        }
                    }
                }

                var guid = obj.Guid;

                Writer.WriteByte((byte)type);
                Writer.WritePackedGuid(guid);
                Writer.WriteByte((byte)obj.TypeId);
                obj.MovementData.Save(Writer);
                WriteValues(Writer, obj.GetValues(), obj.TypeId);
            }

            long pos = Writer.BaseStream.Position;

            Writer.BaseStream.Position = nUpdatesPos;
            Writer.WriteUInt32(nUpdates);
            Writer.BaseStream.Position = pos;
        }
Пример #34
0
        public WowObject ProcessObject(IntPtr ptr)
        {
            if (WowInterface.XMemory.Read(IntPtr.Add(ptr, WowInterface.OffsetList.WowObjectType.ToInt32()), out WowObjectType type) &&
                WowInterface.XMemory.Read(IntPtr.Add(ptr, WowInterface.OffsetList.WowObjectDescriptor.ToInt32()), out IntPtr descriptorAddress))
            {
                WowObject obj = type switch
                {
                    WowObjectType.Container => new WowContainer(ptr, type, descriptorAddress),
                    WowObjectType.Corpse => new WowCorpse(ptr, type, descriptorAddress),
                    WowObjectType.Item => new WowItem(ptr, type, descriptorAddress),
                    WowObjectType.Dynobject => new WowDynobject(ptr, type, descriptorAddress),
                    WowObjectType.Gameobject => new WowGameobject(ptr, type, descriptorAddress),
                    WowObjectType.Player => new WowPlayer(ptr, type, descriptorAddress),
                    WowObjectType.Unit => new WowUnit(ptr, type, descriptorAddress),
                    _ => new WowObject(ptr, type, descriptorAddress),
                };

                obj.Update();

                if (obj != null && (type == WowObjectType.Unit || type == WowObjectType.Player))
                {
                    if (obj.Guid == PlayerGuid)
                    {
                        PlayerGuidIsVehicle = obj.GetType() != typeof(WowPlayer);

                        if (!PlayerGuidIsVehicle)
                        {
                            if (WowInterface.XMemory.Read(WowInterface.OffsetList.ComboPoints, out byte comboPoints))
                            {
                                ((WowPlayer)obj).ComboPoints = comboPoints;
                            }

                            Player  = (WowPlayer)obj;
                            Vehicle = null;
                        }
                        else
                        {
                            Vehicle = (WowUnit)obj;
                        }
                    }

                    if (obj.Guid == TargetGuid)
                    {
                        Target = (WowUnit)obj;
                    }
                    if (obj.Guid == PetGuid)
                    {
                        Pet = (WowUnit)obj;
                    }
                    if (obj.Guid == LastTargetGuid)
                    {
                        LastTarget = (WowUnit)obj;
                    }
                    if (obj.Guid == PartyleaderGuid)
                    {
                        Partyleader = (WowUnit)obj;
                    }
                }

                return(obj);
            }

            return(null);
        }
Пример #35
0
        private static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            CmdLine = new CommandLine(args);

            string file;
            string loader;
            string nodump;
            string nohex;
            string tosql;
            string skiplarge;
            bool   _toSQL = false;

            try
            {
                file      = CmdLine.GetValue("-file");
                loader    = CmdLine.GetValue("-loader");
                nodump    = CmdLine.GetValue("-nodump");
                nohex     = CmdLine.GetValue("-nohex");
                tosql     = CmdLine.GetValue("-tosql");
                skiplarge = CmdLine.GetValue("-skiplarge");
                if (tosql.Equals(bool.TrueString, StringComparison.InvariantCultureIgnoreCase))
                {
                    _toSQL = true;
                }
            }
            catch (IndexOutOfRangeException)
            {
                PrintUsage("All command line options require an argument.");
                return;
            }

            try
            {
                var packets = Reader.Read(loader, file);
                if (packets == null)
                {
                    PrintUsage("Could not open file " + file + " for reading.");
                    return;
                }

                if (packets.Count() > 0)
                {
                    var fullPath = Utilities.GetPathFromFullPath(file);
                    Handler.InitializeLogFile(Path.Combine(fullPath, file + ".txt"), nodump, nohex, skiplarge);

                    foreach (var packet in packets)
                    {
                        Handler.Parse(packet);
                    }
                    Handler.WriteToFile();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.GetType());
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }

            Console.ResetColor();
            if (_toSQL)
            {
                var fullPath = Utilities.GetPathFromFullPath(file);
                QuestStorage.GetSingleton().Output(Path.Combine(fullPath, file + "_questcache.sql"));
                CreatureStorage.GetSingleton().Output(Path.Combine(fullPath, file + "_creaturecache.sql"));
                GameObjectStorage.GetSingleton().Output(Path.Combine(fullPath, file + "_gameobjectcache.sql"));
                CreatureTemplateUpdateStorage.GetSingleton().Output(Path.Combine(fullPath, file + "_creaturecacheupdates.sql"));
                CreatureSpawnStorage   css = CreatureSpawnStorage.GetSingleton();
                GameObjectSpawnStorage gss = GameObjectSpawnStorage.GetSingleton();
                Dictionary <int, Dictionary <Guid, WowObject> > dict = ObjectHandler.Objects;
                foreach (int map in dict.Keys)
                {
                    Dictionary <Guid, WowObject> objectsInMap = dict[map];
                    foreach (Guid guid in objectsInMap.Keys)
                    {
                        WowObject obj = objectsInMap[guid];
                        if (obj.Type == ObjectType.Unit)
                        {
                            CreatureSpawn spawn = new CreatureSpawn();
                            spawn.Entry = guid.GetEntry();
                            spawn.Map   = map;
                            spawn.X     = obj.Position.X;
                            spawn.Y     = obj.Position.Y;
                            spawn.Z     = obj.Position.Z;
                            spawn.O     = obj.Movement.Orientation;
                            css.Add(spawn);
                        }
                        else if (obj.Type == ObjectType.GameObject)
                        {
                            GameObjectSpawn spawn = new GameObjectSpawn();
                            spawn.Entry = guid.GetEntry();
                            spawn.Map   = map;
                            spawn.X     = obj.Position.X;
                            spawn.Y     = obj.Position.Y;
                            spawn.Z     = obj.Position.Z;
                            spawn.O     = obj.Movement.Orientation;
                            gss.Add(spawn);
                        }
                    }
                }
                css.Output(Path.Combine(fullPath, file + "_creaturesniffedspawns.sql"));
                gss.Output(Path.Combine(fullPath, file + "_gameobjectsniffedspawns.sql"));
            }
        }
Пример #36
0
        public void PresentWowObject(WowObject WowObject)
        {
            var context = new RadarObjectContext();

            context.di = this.settings.GetDisplayItem("[Object: Other]", null);
            context.vBuffer = this.vbObject;
            context.name = WowObject.Name;
            context.obj = WowObject;

            switch (WowObject.Type)
            {
                case ObjectType.Unit:
                    this.GetUnitDisplayData(context);
                    break;

                case ObjectType.Player:
                    this.GetPlayerDisplayData(context);
                    break;

                case ObjectType.GameObject:
                    this.GetGameObjectDisplayData(context);
                    break;

                //case ObjectType.Corpse:
                //    this.GetCorpseDisplayData(context);
                //    break;
            }

            if (context.visible)
            {

                if (WowObject.Name != null)
                {
                    context.di = this.settings.GetDisplayItem(WowObject.Name.ToLower(), context.di);
                }

                if ((context.di != null) && context.di.Visible)
                {
                    int color = context.di.Color;
                    if (WowObject.IsAlert)
                    {
                        RadarAlert alert = null;
                        if (this.alerts.ContainsKey(WowObject.GUID))
                        {
                            alert = this.alerts[WowObject.GUID];
                        }
                        else
                        {
                            alert = new RadarAlert();
                            alert.flash = context.di.AlertColor;
                            this.alerts.Add(WowObject.GUID, alert);
                        }
                        color = alert.GetAlertColor(context.di.Color);
                    }

                    float x = 2f * (2f / this.scale);
                    this.device.Transform.World = Microsoft.DirectX.Matrix.Scaling(x, x, x);

                    if (context.rotate)
                    {
                        var transforms1 = this.device.Transform;
                        transforms1.World *= Microsoft.DirectX.Matrix.RotationZ(6.283185f - WowObject.Facing);
                    }
                    else if (this.settings.RotateMap)
                    {
                        var transforms2 = this.device.Transform;
                        transforms2.World *= Microsoft.DirectX.Matrix.RotationZ(6.283185f - this.focusObject.Facing);
                    }

                    var transform = this.device.Transform;

                    transform.World *= Microsoft.DirectX.Matrix.Translation(new Microsoft.DirectX.Vector3(WowObject.X, WowObject.Y, WowObject.Z));

                    this.device.RenderState.TextureFactor = color;
                    this.device.TextureState[0].ColorOperation = TextureOperation.Modulate;
                    this.device.TextureState[0].ColorArgument0 = TextureArgument.TextureColor;
                    this.device.TextureState[0].ColorArgument1 = TextureArgument.TFactor;
                    this.device.VertexFormat = VertexFormats.Diffuse | VertexFormats.Position;
                    this.device.SetTexture(0, null);
                    this.device.SetStreamSource(0, context.vBuffer, 0);
                    this.device.DrawPrimitives(PrimitiveType.TriangleList, 0, context.noVertexs);

                    var v = Microsoft.DirectX.Vector3.Project(new Microsoft.DirectX.Vector3(0f, 0f, 0f), this.device.Viewport, this.device.Transform.Projection, this.device.Transform.View, this.device.Transform.World);

                    if (((context.name != null) && !this.hideName) && (context.di.DisplayText != DisplayText.Nothing))
                    {
                        this.font.DrawText(null, context.name, (int)(((int)v.X) + 10), (int)(((int)v.Y) - 4), color);
                    }
                }
            }
        }
Пример #37
0
        private void DoAction()
        {
            List <WowObject> wowObjects = new List <WowObject>();
            List <WowNpc>    wowNpcs    = new List <WowNpc>();
            WoWPlayerMe      me         = game.GetGameObjects(wowObjects, null, wowNpcs);

            if (me != null)
            {
                DoAction action = actionsList[counter];
                if (action.ActionType != DoActionType.Move)
                {
                    unstuckDictionary.Clear();
                }
                switch (action.ActionType)
                {
                case DoActionType.Move:
                    double distance2D = me.Location.Distance2D(action.WowPoint);
                    double distance3D = me.Location.Distance(action.WowPoint);
                    if (me.IsFlying && (distance3D > precision3D || (distance3D <= precision3D && GetNextAction().ActionType != DoActionType.Move && me.IsMoving)))
                    {
                        UnstuckIfNeeded(me.Location, action.ActionType);
                        this.LogPrint($"Flying to point --> [{action.WowPoint}]; distance: {distance3D}");
                        game.Move3D(action.WowPoint, precision3D, precision3D, 1000, true, GetNextAction().ActionType == DoActionType.Move);
                    }
                    else if (!me.IsFlying && (distance2D > precision2D || (distance2D <= precision2D && GetNextAction().ActionType != DoActionType.Move && me.IsMoving)))
                    {
                        UnstuckIfNeeded(me.Location, action.ActionType);
                        this.LogPrint(string.Format("Moving to point --> [{0}]; my loc: [{3}]; distance2D: {1}; speed: {2}", action.WowPoint, distance2D, me.Speed, me.Location));
                        game.Move2D(action.WowPoint, precision2D, 1000, true, GetNextAction().ActionType == DoActionType.Move);
                    }
                    else
                    {
                        IncreaseCounterAndDoAction();
                    }
                    break;

                case DoActionType.StopProfile:
                    if (loopPath)
                    {
                        IncreaseCounterAndDoAction();
                    }
                    break;

                case DoActionType.RunLua:
                    Thread.Sleep(500);     // player should be stopped before interact
                    game.SendToChat("/run " + string.Concat(action.Data.TakeWhile(l => l != '\r' && l != '\n')));
                    IncreaseCounterAndDoAction();
                    break;

                case DoActionType.SendChat:
                    Thread.Sleep(500);     // player should be stopped before interact
                    game.SendToChat(action.Data);
                    IncreaseCounterAndDoAction();
                    break;

                case DoActionType.SelectGossipOption:
                    Thread.Sleep(1000);     // player should be stopped before interact
                    game.SelectDialogOption(action.Data);
                    IncreaseCounterAndDoAction();
                    break;

                case DoActionType.Interact:
                    WowObject[] objectsWithCorrectName = wowObjects.Where(l => l.Name == action.Data).ToArray();
                    if (objectsWithCorrectName.Length > 0)
                    {
                        WowObject nearestObject = objectsWithCorrectName.Aggregate((minItem, nextItem) => me.Location.Distance(minItem.Location) < me.Location.Distance(nextItem.Location) ? minItem : nextItem);
                        Thread.Sleep(500);     // player should be stopped before interact
                        nearestObject.Interact();
                    }
                    WowNpc[] npcsWithCorrectName = wowNpcs.Where(l => l.Name == action.Data).ToArray();
                    if (npcsWithCorrectName.Length > 0)
                    {
                        WowNpc nearestNpc = npcsWithCorrectName.Aggregate((minItem, nextItem) => me.Location.Distance(minItem.Location) < me.Location.Distance(nextItem.Location) ? minItem : nextItem);
                        Thread.Sleep(500);     // player should be stopped before interact
                        nearestNpc.Interact();
                    }
                    IncreaseCounterAndDoAction();
                    break;

                case DoActionType.Wait:
                    int timeToWait = int.Parse(action.Data);
                    while (timeToWait > 0 && timer.IsRunning)
                    {
                        Thread.Sleep(100);
                        timeToWait -= 100;
                    }
                    IncreaseCounterAndDoAction();
                    break;

                case DoActionType.SetPrecision2D:
                    if (!float.TryParse(action.Data, out precision2D))
                    {
                        precision2D = 3f;
                    }
                    IncreaseCounterAndDoAction();
                    break;

                case DoActionType.SetPrecision3D:
                    if (!float.TryParse(action.Data, out precision3D))
                    {
                        precision3D = 8f;
                    }
                    IncreaseCounterAndDoAction();
                    break;

                case DoActionType.WaitWhile:
                    if (!game.LuaIsTrue(action.Data))
                    {
                        IncreaseCounterAndDoAction();
                    }
                    else if (!string.IsNullOrWhiteSpace(action.AdditionalData) && int.TryParse(action.AdditionalData, out int lag))
                    {
                        Thread.Sleep(lag);
                    }
                    break;

                case DoActionType.SendToChatWhile:
                    string[] p         = action.Data.Split(new[] { "##@##" }, StringSplitOptions.RemoveEmptyEntries);
                    string   _action   = p[0];
                    string   condition = p[1];
                    if (game.LuaIsTrue(condition))
                    {
                        game.SendToChat(_action);
                    }
                    else
                    {
                        IncreaseCounterAndDoAction();
                    }
                    break;

                case DoActionType.StopProfileIf:
                    if (game.LuaIsTrue(action.Data))
                    {
                        counter = actionsList.Count - 1;
                    }
                    IncreaseCounterAndDoAction();
                    break;

                case DoActionType.NotifyUser:
                    this.ShowNotify(action.Data, false, false);
                    IncreaseCounterAndDoAction();
                    break;

                case DoActionType.NotifyUserIf:
                    if (game.LuaIsTrue(action.AdditionalData))
                    {
                        this.ShowNotify(action.Data, false, false);
                    }
                    IncreaseCounterAndDoAction();
                    break;

                default:
                    IncreaseCounterAndDoAction();
                    break;
                }
            }
            else
            {
                this.LogPrint("Local player is null");
            }
        }
Пример #38
0
        public void Execute()
        {
            WowInterface.CombatClass.OutOfCombatExecute();
            if (WowInterface.ObjectManager.Player.IsCasting)
            {
                return;
            }
            // set new state
            if (hasStateChanged)
            {
                hasStateChanged = false;
                //hasFlag = WowInterface.HookManager.GetBuffs(WowLuaUnit.Player).Any(e => e.Contains("flag") || e.Contains("Flag"));
                hasFlag     = WowInterface.ObjectManager.Player.Auras != null && WowInterface.ObjectManager.Player.Auras.Any(e => e.SpellId == 23333 || e.SpellId == 23335);
                FlagCarrier = hasFlag ? WowInterface.ObjectManager.Player : GetFlagCarrier();
                if (FlagCarrier == null)
                {
                    FlagObject = GetFlagObject();
                    if (FlagObject == null)
                    {
                        hasStateChanged = true;
                    }
                    else
                    {
                        FlagState = 0;
                        WowInterface.HookManager.LuaSendChatMessage("/y The flag just lies around! Let's take it!");
                    }
                }
                else
                {
                    FlagState = PICKED_UP;
                    if (hasFlag || WowInterface.HookManager.WowGetUnitReaction(WowInterface.ObjectManager.Player, FlagCarrier) == WowUnitReaction.Friendly || WowInterface.HookManager.WowGetUnitReaction(WowInterface.ObjectManager.Player, FlagCarrier) == WowUnitReaction.Neutral)
                    {
                        FlagState |= OWN_TEAM_FLAG;
                        WowInterface.HookManager.LuaSendChatMessage("/y We got it!");
                    }
                    else
                    {
                        WowInterface.HookManager.LuaSendChatMessage("/y They've got the flag!");
                    }
                }
            }

            // reaction
            if ((FlagState & PICKED_UP) > 0)
            {
                if ((FlagState & OWN_TEAM_FLAG) > 0)
                {
                    // own team has flag
                    if (hasFlag)
                    {
                        WowObject ownFlag = GetFlagObject();
                        if (ownFlag != null)
                        {
                            WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, ownFlag.Position);
                            if (WowInterface.MovementEngine.IsAtTargetPosition)
                            {
                                WowInterface.HookManager.WowObjectRightClick(FlagObject);
                            }
                        }
                        else
                        {
                            WowUnit enemyFlagCarrier = GetFlagCarrier();
                            if (enemyFlagCarrier != null)
                            {
                                WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, enemyFlagCarrier.Position);
                            }
                            else if (startPosition != default)
                            {
                                WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, ausgangAlly);
                            }
                        }
                    }
                    else if (FlagCarrier != null)
                    {
                        FlagCarrier = GetFlagCarrier();
                        if (FlagCarrier != null)
                        {
                            WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, FlagCarrier.Position);
                        }
                        else
                        {
                            WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, baseHord);
                        }
                    }
                }
                else
                {
                    // enemy team has flag
                    FlagCarrier = GetFlagCarrier();
                    if (FlagCarrier != null)
                    {
                        WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, FlagCarrier.Position);
                    }
                    else
                    {
                        WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, baseHord);
                    }
                }
            }
            else if (FlagObject != null)
            {
                // flag lies on the ground
                WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, FlagObject.Position);
                if (WowInterface.MovementEngine.IsAtTargetPosition) // limit the executions
                {
                    WowInterface.HookManager.WowObjectRightClick(FlagObject);
                }
            }
            else if (startPosition != default)
            {
                WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, ausgangHord);
            }
        }
Пример #39
0
 public string GetName(WowObject obj)
 {
     return GetName(obj.ObjectPointer);
 }
Пример #40
0
        public void Execute()
        {
            if (!IsGateOpen())
            {
                WowInterface.CombatClass.OutOfCombatExecute();
                return;
            }

            // --- set new state ---
            if (hasStateChanged)
            {
                hasStateChanged = false;
                hasFlag         = WowInterface.ObjectManager.Player.Auras != null && WowInterface.ObjectManager.Player.Auras.Any(e => e.SpellId == 23333 || e.SpellId == 23335);
                WowUnit teamFlagCarrier = GetTeamFlagCarrier();
                ownTeamHasFlag = teamFlagCarrier != null;
                if (ownTeamHasFlag)
                {
                    TeamFlagCarrierGuid = teamFlagCarrier.Guid;
                }
                WowUnit enemyFlagCarrier = GetEnemyFlagCarrier();
                enemyTeamHasFlag = enemyFlagCarrier != null;
                if (enemyTeamHasFlag)
                {
                    EnemyFlagCarrierGuid = enemyFlagCarrier.Guid;
                }
            }

            // --- reaction ---
            if (hasFlag)
            {
                // you've got the flag!
                WowObject tmpFlag = GetOwnFlagObject();
                ownFlag = tmpFlag ?? ownFlag;
                if (ownFlag != null)
                {
                    // own flag lies around
                    WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, ownFlag.Position);
                    if (isAtPosition(ownFlag.Position))
                    {
                        // own flag reached, save it!
                        WowInterface.HookManager.WowObjectRightClick(ownFlag);
                        hasStateChanged = true;
                    }
                }
                else
                {
                    // bring it outside!
                    WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, this.isHorde ? baseHord : baseAlly);
                }
            }
            else if (ownTeamHasFlag && enemyTeamHasFlag)
            {
                // team mate and enemy got the flag
                if (WowInterface.CombatClass.Role == Statemachine.Enums.CombatClassRole.Dps)
                {
                    // run to the enemy
                    WowUnit enemyFlagCarrier = WowInterface.ObjectManager.GetWowObjectByGuid <WowUnit>(EnemyFlagCarrierGuid);
                    if (enemyFlagCarrier != null)
                    {
                        WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving,
                                                                      BotUtils.MoveAhead(enemyFlagCarrier.Position, enemyFlagCarrier.Rotation, ((float)WowInterface.ObjectManager.Player.Position.GetDistance2D(enemyFlagCarrier.Position)) / 2f));
                        if (isInCombatReach(enemyFlagCarrier.Position))
                        {
                            WowInterface.HookManager.WowTargetGuid(enemyFlagCarrier.Guid);
                        }
                        if (isEnemyClose())
                        {
                            WowInterface.Globals.ForceCombat = true;
                            return;
                        }
                    }
                    else
                    {
                        WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, this.isHorde ? baseAlly : baseHord);
                    }
                    WowInterface.CombatClass.OutOfCombatExecute();
                }
                else
                {
                    // run to the own flag carrier
                    WowUnit teamFlagCarrier = WowInterface.ObjectManager.GetWowObjectByGuid <WowUnit>(TeamFlagCarrierGuid);
                    if (teamFlagCarrier != null)
                    {
                        if (WowInterface.CombatClass.Role == Statemachine.Enums.CombatClassRole.Dps)
                        {
                            WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, BotMath.CalculatePositionBehind(teamFlagCarrier.Position, teamFlagCarrier.Rotation, 1f));
                        }
                        else if (WowInterface.CombatClass.Role == Statemachine.Enums.CombatClassRole.Tank)
                        {
                            WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, BotUtils.MoveAhead(teamFlagCarrier.Position, teamFlagCarrier.Rotation, 2f));
                        }
                        else if (WowInterface.CombatClass.Role == Statemachine.Enums.CombatClassRole.Heal)
                        {
                            WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, teamFlagCarrier.Position);
                        }
                        if (isEnemyClose())
                        {
                            WowInterface.Globals.ForceCombat = true;
                            return;
                        }
                    }
                    else
                    {
                        // run to the enemy
                        WowUnit enemyFlagCarrier = WowInterface.ObjectManager.GetWowObjectByGuid <WowUnit>(EnemyFlagCarrierGuid);
                        if (enemyFlagCarrier != null)
                        {
                            WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving,
                                                                          BotUtils.MoveAhead(enemyFlagCarrier.Position, enemyFlagCarrier.Rotation, ((float)WowInterface.ObjectManager.Player.Position.GetDistance2D(enemyFlagCarrier.Position)) / 2f));
                            if (WowInterface.CombatClass.Role != Statemachine.Enums.CombatClassRole.Heal && isInCombatReach(enemyFlagCarrier.Position))
                            {
                                WowInterface.HookManager.WowTargetGuid(enemyFlagCarrier.Guid);
                            }
                            if (isEnemyClose())
                            {
                                WowInterface.Globals.ForceCombat = true;
                                return;
                            }
                        }
                        else
                        {
                            WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, this.isHorde ? baseHord : baseAlly);
                        }
                        WowInterface.CombatClass.OutOfCombatExecute();
                    }
                }
            }
            else if (ownTeamHasFlag)
            {
                // a team mate got the flag
                WowUnit teamFlagCarrier = WowInterface.ObjectManager.GetWowObjectByGuid <WowUnit>(TeamFlagCarrierGuid);
                if (teamFlagCarrier != null)
                {
                    if (WowInterface.CombatClass.Role == Statemachine.Enums.CombatClassRole.Dps)
                    {
                        WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, BotMath.CalculatePositionBehind(teamFlagCarrier.Position, teamFlagCarrier.Rotation, 1f));
                    }
                    else if (WowInterface.CombatClass.Role == Statemachine.Enums.CombatClassRole.Tank)
                    {
                        WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, BotUtils.MoveAhead(teamFlagCarrier.Position, teamFlagCarrier.Rotation, 2f));
                    }
                    else if (WowInterface.CombatClass.Role == Statemachine.Enums.CombatClassRole.Heal)
                    {
                        WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, teamFlagCarrier.Position);
                    }
                    if (isEnemyClose())
                    {
                        WowInterface.Globals.ForceCombat = true;
                        return;
                    }
                }
                else
                {
                    WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, this.isHorde ? baseHord : baseAlly);
                }
                if (WowInterface.CombatClass.Role == Statemachine.Enums.CombatClassRole.Dps)
                {
                    if (isEnemyClose())
                    {
                        WowInterface.Globals.ForceCombat = true;
                        return;
                    }
                }
                WowInterface.CombatClass.OutOfCombatExecute();
            }
            else if (enemyTeamHasFlag)
            {
                // the enemy got the flag
                if (WowInterface.CombatClass.Role == Statemachine.Enums.CombatClassRole.Tank)
                {
                    WowObject tmpFlag = getEnemyFlagObject();
                    enemyFlag = tmpFlag == null ? enemyFlag : tmpFlag;
                    if (enemyFlag != null)
                    {
                        // flag lies around
                        WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, enemyFlag.Position);
                        if (isAtPosition(enemyFlag.Position))
                        {
                            // flag reached, save it!
                            hasStateChanged = true;
                            WowInterface.HookManager.WowObjectRightClick(enemyFlag);
                        }
                    }
                    else
                    {
                        // go outside!
                        WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, this.isHorde ? baseAlly : baseHord);
                        WowInterface.CombatClass.OutOfCombatExecute();
                    }
                }
                else
                {
                    WowUnit enemyFlagCarrier = WowInterface.ObjectManager.GetWowObjectByGuid <WowUnit>(EnemyFlagCarrierGuid);
                    if (enemyFlagCarrier != null)
                    {
                        WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving,
                                                                      BotUtils.MoveAhead(enemyFlagCarrier.Position, enemyFlagCarrier.Rotation, ((float)WowInterface.ObjectManager.Player.Position.GetDistance2D(enemyFlagCarrier.Position)) / 2f));
                        if (WowInterface.CombatClass.Role != Statemachine.Enums.CombatClassRole.Heal && isInCombatReach(enemyFlagCarrier.Position))
                        {
                            WowInterface.HookManager.WowTargetGuid(enemyFlagCarrier.Guid);
                        }
                        if (isEnemyClose())
                        {
                            WowInterface.Globals.ForceCombat = true;
                            return;
                        }
                    }
                    WowInterface.CombatClass.OutOfCombatExecute();
                }
            }
            else
            {
                // go and get the enemy flag!!!
                WowObject tmpFlag = getEnemyFlagObject();
                enemyFlag = tmpFlag ?? enemyFlag;
                if (enemyFlag != null)
                {
                    // flag lies around
                    WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, enemyFlag.Position);
                    if (isAtPosition(enemyFlag.Position))
                    {
                        // flag reached, save it!
                        hasStateChanged = true;
                        WowInterface.HookManager.WowObjectRightClick(enemyFlag);
                    }
                }
                else
                {
                    // go outside!
                    WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, this.isHorde ? baseAlly : baseHord);
                    WowInterface.CombatClass.OutOfCombatExecute();
                }
            }
            if (WowInterface.MovementEngine.MovementAction == Movement.Enums.MovementAction.None)
            {
                hasStateChanged = true;
                WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, this.isHorde ? baseAlly : baseHord);
                if (isEnemyClose())
                {
                    WowInterface.Globals.ForceCombat = true;
                    return;
                }
                WowInterface.CombatClass.OutOfCombatExecute();
            }
        }
Пример #41
0
 /// <summary>
 /// Helper override which takes a WowObject instance instead of GUID.
 /// </summary>
 /// <param name="obj">WowObject Instance</param>
 public void SelectUnit(WowObject obj)
 {
     SelectUnit(obj.Guid);
 }
Пример #42
0
        void TestBoober()
        {
            var objManager = Memory.Read<IntPtr>(Memory.Rebase(Settings.ObjectMgr));
            var playerGuid = Memory.Read<WowGuid>(objManager + Settings.PlayerGuid);

            var baseAddr   = Memory.Read<IntPtr>(objManager + Settings.FirstObject);
            var state      = Memory.Read<byte>(Memory.Rebase(Settings.TestClient));

            var cur = new WowObject(Memory, baseAddr);

            Debug.WriteLine($"Player: {playerGuid}");

            byte found = 0;
            while (cur.IsValid)
            {
                if (cur.Type == 5) // OBJECT_TYPE_GAMEOBJECT
                {
                    Debug.WriteLine($"Guid: {cur.Guid}, Type: {cur.Type}, CreatedBy: {cur.CreatedBy}, {cur.IsBoobing}");
                    if (cur.IsBoobing && cur.CreatedBy == playerGuid)
                    {
                        Console.WriteLine("Found boober: " + cur.Guid);

                        found = 1;
                        Memory.SendMessage(0x100, new IntPtr(0x13), IntPtr.Zero); // Break/Pause
                        Memory.SendMessage(0x101, new IntPtr(0x13), IntPtr.Zero); // Break/Pause

                        // write boobers guid to "mouseover"
                        Memory.Write(Memory.Rebase(Settings.ObjectTrack), cur.Guid);
                        break;
                    }
                }

                cur.BaseAddress = Memory.Read<IntPtr>(cur.BaseAddress + Settings.NextObject);
            }

            // lua_pushboolean(state, found)
            // 6A 00          push    found ; change
            // FF 75 08       push    [ebp+arg_0]
            // E8 9F B2 CD FF call    lua_pushboolean
            if (state != found)
            {
                Console.WriteLine($"Write state: state {state} / found {found}");
                Memory.Write(Memory.Rebase(Settings.TestClient), found);
            }
        }