Exemple #1
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);
        }
Exemple #2
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);
        }
Exemple #3
0
        public void UpdateWowObjects()
        {
            IsWorldLoaded = UpdateGlobalVar <int>(WowInterface.OffsetList.IsWorldLoaded) == 1;

            if (!IsWorldLoaded)
            {
                return;
            }

            lock (queryLock)
            {
                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);
                GameState      = UpdateGlobalVarString(WowInterface.OffsetList.GameState);

                if (WowInterface.XMemory.Read(WowInterface.OffsetList.CameraPointer, out IntPtr cameraPointer) &&
                    WowInterface.XMemory.Read(IntPtr.Add(cameraPointer, (int)WowInterface.OffsetList.CameraOffset), 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);
                }

                if (TargetGuid == 0)
                {
                    Target = null;
                }
                if (PetGuid == 0)
                {
                    Pet = null;
                }
                if (LastTargetGuid == 0)
                {
                    LastTarget = null;
                }
                if (PartyleaderGuid == 0)
                {
                    Partyleader = null;
                }

                WowInterface.XMemory.Read(WowInterface.OffsetList.ClientConnection, out IntPtr clientConnection);
                WowInterface.XMemory.Read(IntPtr.Add(clientConnection, WowInterface.OffsetList.CurrentObjectManager.ToInt32()), out IntPtr currentObjectManager);

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

                int count = 0;

                while (activeObjectBaseAddress.ToInt32() > 0 && count < MAX_OBJECT_COUNT)
                {
                    wowObjectPointers[count] = activeObjectBaseAddress;
                    ++count;

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

                ObjectCount = count;

                Array.Clear(wowObjects, 0, wowObjects.Length);
                Parallel.For(0, count, x => wowObjects[x] = ProcessObject(wowObjectPointers[x]));

                if (PlayerGuidIsVehicle)
                {
                    // get the object with last known "good" guid
                    WowPlayer lastKnownPlayer = wowObjects.OfType <WowPlayer>().FirstOrDefault(e => e.Guid == Player.Guid);

                    if (lastKnownPlayer != null)
                    {
                        Player = lastKnownPlayer;
                    }
                }

                // read the party/raid leaders guid and if there is one, the group too
                PartyleaderGuid = ReadLeaderGuid();

                if (PartyleaderGuid > 0)
                {
                    PartymemberGuids = ReadPartymemberGuids();
                    Partymembers     = wowObjects.OfType <WowUnit>().Where(e => PartymemberGuids.Contains(e.Guid));

                    MeanGroupPosition = GetMeanGroupPosition();

                    PartyPetGuids = PartyPets.Select(e => e.Guid);
                    PartyPets     = wowObjects.OfType <WowUnit>().Where(e => PartymemberGuids.Contains(e.SummonedByGuid));
                }
            }

            if (Config.CachePointsOfInterest && PoiCacheEvent.Run())
            {
                CachePois();
            }

            // if (RelationshipEvent.Run())
            // {
            //     CheckGroupRelationships();
            // }

            OnObjectUpdateComplete?.Invoke(wowObjects);
        }