Exemplo n.º 1
0
        protected override void ReadParty()
        {
            if (ReadPartyPointer(out IntPtr party) &&
                Memory.Read(IntPtr.Add(party, 0xC4), out int count) && count > 0)
            {
                PartymemberGuids = ReadPartymemberGuids(party);
                Partymembers     = wowObjects.OfType <IWowUnit>().Where(e => PartymemberGuids.Contains(e.Guid));

                Vector3 pos = new();

                foreach (Vector3 vec in Partymembers.Select(e => e.Position))
                {
                    pos += vec;
                }

                CenterPartyPosition = pos / Partymembers.Count();

                PartyPetGuids = PartyPets.Select(e => e.Guid);
                PartyPets     = wowObjects.OfType <IWowUnit>().Where(e => PartymemberGuids.Contains(e.SummonedByGuid));
            }
        }
Exemplo n.º 2
0
        protected override void ReadParty()
        {
            PartyleaderGuid = ReadLeaderGuid();

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

                Vector3 pos = new();

                foreach (Vector3 vec in Partymembers.Select(e => e.Position))
                {
                    pos += vec;
                }

                CenterPartyPosition = pos / Partymembers.Count();

                PartyPetGuids = PartyPets.Select(e => e.Guid);
                PartyPets     = wowObjects.OfType <IWowUnit>().Where(e => PartymemberGuids.Contains(e.SummonedByGuid));
            }
        }
Exemplo n.º 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);
        }