Exemplo n.º 1
0
 public void CombatLogChanged(BasicCombatLogEntry entry)
 {
     if (entry.Subtype == CombatLogEntrySubtype.KILL && NpcIds.Contains(WowGUID.NpcId(entry.DestinationGuid)))
     {
         ++Killed;
     }
 }
        public void CombatLogChanged(BasicCombatLogEntry entry)
        {
            var wowUnit = WowInterface.ObjectManager.GetWowObjectByGuid <WowUnit>(entry.DestinationGuid);

            if (entry.Subtype == CombatLogEntrySubtype.KILL && NpcIds.Contains(WowGUID.NpcId(entry.DestinationGuid)) &&
                wowUnit != null && wowUnit.IsTaggedByMe)
            {
                ++Killed;
            }
        }
        public void Execute()
        {
            if (Finished || WowInterface.ObjectManager.Player.IsCasting)
            {
                return;
            }

            if (!WowInterface.ObjectManager.Player.IsInCombat && DateTime.Now.Subtract(LastUnitCheck).TotalMilliseconds >= 1250.0)
            {
                LastUnitCheck = DateTime.Now;
                WowUnit       = WowInterface.ObjectManager.WowObjects
                                .OfType <WowUnit>()
                                .Where(e => !e.IsDead && NpcIds.Contains(WowGUID.NpcId(e.Guid)) && !e.IsNotAttackable &&
                                       WowInterface.HookManager.WowGetUnitReaction(WowInterface.ObjectManager.Player, e) != WowUnitReaction.Friendly)
                                .OrderBy(e => e.Position.GetDistance(WowInterface.ObjectManager.Player.Position))
                                .Take(3)
                                .OrderBy(e => WowInterface.PathfindingHandler.GetPathDistance((int)WowInterface.ObjectManager.MapId, WowInterface.ObjectManager.Player.Position, e.Position))
                                .FirstOrDefault();

                // Kill enemies in the path
                if (WowUnit != null && !WowInterface.CombatClass.IsTargetAttackable(WowUnit))
                {
                    var path = WowInterface.PathfindingHandler.GetPath((int)WowInterface.ObjectManager.MapId,
                                                                       WowInterface.ObjectManager.Player.Position, WowUnit.Position);
                    if (path != null)
                    {
                        var nearEnemies =
                            WowInterface.ObjectManager.GetEnemiesInPath <WowUnit>(path, 10.0);
                        if (nearEnemies.Any())
                        {
                            WowUnit = nearEnemies.FirstOrDefault();
                        }
                    }
                }

                if (WowUnit != null)
                {
                    WowInterface.HookManager.WowTargetGuid(WowUnit.Guid);
                }
            }

            if (WowUnit != null)
            {
                SearchAreas.NotifyDetour();
                WowInterface.CombatClass.AttackTarget();
            }
            else if (WowInterface.Player.Position.GetDistance(CurrentSpot) < 3.0f || SearchAreas.HasAbortedPath() || WowInterface.MovementEngine.Status == MovementAction.None)
            {
                CurrentSpot = SearchAreas.GetNextPosition(WowInterface);
                WowInterface.MovementEngine.SetMovementAction(MovementAction.Move, CurrentSpot);
            }
        }
Exemplo n.º 4
0
 public WowUnit GetClosestWowUnitByNpcId(IEnumerable <int> npcIds, bool onlyQuestgiver = true)
 {
     lock (queryLock)
     {
         return(wowObjects.OfType <WowUnit>()
                .Where(e => (e.IsQuestgiver || !onlyQuestgiver) && npcIds.Contains(WowGUID.NpcId(e.Guid)))
                .OrderBy(e => e.Position.GetDistance(WowInterface.ObjectManager.Player.Position))
                .FirstOrDefault());
     }
 }