Esempio n. 1
0
        private void CheckGroupRelationships()
        {
            IEnumerable <WowPlayer> wowPlayers = wowObjects.OfType <WowPlayer>();

            foreach (WowPlayer player in wowPlayers)
            {
                if (player.Guid != PlayerGuid)
                {
                    // check wether its a new player old someone we know
                    if (!WowInterface.Db.IsPlayerKnown(player))
                    {
                        WowInterface.Db.AddPlayerRelationship(player,
                                                              // is the player in my friend list
                                                              Config.Friends.Contains(player.Name, StringComparison.OrdinalIgnoreCase) ?
                                                              RelationshipLevel.Friend :
                                                              // is the player in my group
                                                              PartymemberGuids.Contains(player.Guid) ?
                                                              RelationshipLevel.Positive :
                                                              // is the player hostile
                                                              WowInterface.HookManager.WowGetUnitReaction(Player, player) == WowUnitReaction.Hostile ?
                                                              RelationshipLevel.Negative :
                                                              RelationshipLevel.Neutral);
                    }
                    else
                    {
                        WowInterface.Db.UpdatePlayerRelationship(player);
                    }
                }
            }
        }
Esempio n. 2
0
 public IEnumerable <T> GetEnemiesTargetingPartymembers <T>(Vector3 position, double distance) where T : WowUnit
 {
     lock (queryLock)
     {
         return(GetNearEnemies <T>(position, distance)
                .Where(e => e.IsInCombat && (PartymemberGuids.Contains(e.TargetGuid) || PartyPetGuids.Contains(e.TargetGuid))));
     }
 }
Esempio n. 3
0
 public IEnumerable <T> GetNearPartymembers <T>(Vector3 position, double distance) where T : WowUnit
 {
     lock (queryLock)
     {
         return(wowObjects.OfType <T>()
                .Where(e => !e.IsDead &&
                       !e.IsNotAttackable &&
                       (PartymemberGuids.Contains(e.Guid) || PartyPetGuids.Contains(e.Guid)) &&
                       e.Position.GetDistance(position) < distance));
     }
 }
Esempio n. 4
0
 public List <WowPlayer> GetNearPartymembers(Vector3 position, double distance)
 {
     lock (queryLock)
     {
         return(wowObjects.OfType <WowPlayer>()
                .Where(e => e != null &&
                       e.Guid != PlayerGuid &&
                       !e.IsDead &&
                       !e.IsNotAttackable &&
                       PartymemberGuids.Contains(e.Guid) &&
                       e.Position.GetDistance(position) < distance)
                .ToList());
     }
 }
Esempio n. 5
0
        private WowPlayer ReadWowPlayer(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.WowUnitPosition.ToInt32()), out Vector3 position) &&
                WowInterface.XMemory.Read(IntPtr.Add(activeObject, WowInterface.OffsetList.WowUnitRotation.ToInt32()), out float rotation) &&
                WowInterface.XMemory.Read(IntPtr.Add(activeObject, WowInterface.OffsetList.WowUnitIsAutoAttacking.ToInt32()), out int isAutoAttacking))
            {
                WowPlayer player = new WowPlayer(activeObject, wowObjectType)
                {
                    DescriptorAddress = descriptorAddress,
                    Position          = position,
                    Rotation          = rotation,
                    IsAutoAttacking   = isAutoAttacking == 1
                };

                // first read the descriptor, then lookup the Name by GUID
                player.UpdateRawWowPlayer(WowInterface.XMemory);
                player.Name = ReadPlayerName(player.Guid);

                if (player.Guid == PlayerGuid)
                {
                    if (WowInterface.XMemory.Read(WowInterface.OffsetList.ComboPoints, out byte comboPoints))
                    {
                        player.ComboPoints = comboPoints;
                    }

                    Player = player;
                }

                if (player.Guid == TargetGuid ||
                    player.Guid == PlayerGuid ||
                    PartymemberGuids.Contains(player.Guid))
                {
                    player.Auras = WowInterface.HookManager.GetUnitAuras(activeObject);
                }

                return(player);
            }

            return(null);
        }
Esempio n. 6
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));
            }
        }
Esempio n. 7
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));
            }
        }
Esempio n. 8
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);
        }