public void OnPartyKill(ulong sourceGuid, ulong npcGuid)
        {
            IWowUnit wowUnit = Bot.GetWowObjectByGuid <IWowUnit>(npcGuid);

            if (wowUnit != null &&
                (Bot.Player.Guid == sourceGuid || Bot.Objects.PartymemberGuids.Contains(sourceGuid)) &&
                NpcIds.Contains(BotUtils.GuidToNpcId(npcGuid)))
            {
                ++Killed;
            }
        }
        public void Execute()
        {
            if (Finished || Bot.Player.IsCasting)
            {
                return;
            }

            if (!Bot.Player.IsInCombat && DateTime.UtcNow.Subtract(LastUnitCheck).TotalMilliseconds >= 1250.0)
            {
                LastUnitCheck = DateTime.UtcNow;
                IWowUnit      = Bot.Objects.All
                                .OfType <IWowUnit>()
                                .Where(e => !e.IsDead && NpcIds.Contains(BotUtils.GuidToNpcId(e.Guid)) && !e.IsNotAttackable &&
                                       Bot.Db.GetReaction(Bot.Player, e) != WowUnitReaction.Friendly)
                                .OrderBy(e => e.Position.GetDistance(Bot.Player.Position))
                                .Take(3)
                                .OrderBy(e => Bot.Player.DistanceTo(e))
                                .FirstOrDefault();

                // Kill enemies in the path
                if (IWowUnit != null && Bot.Db.GetReaction(Bot.Player, IWowUnit) == WowUnitReaction.Hostile)
                {
                    IEnumerable <Vector3> path = Bot.PathfindingHandler.GetPath((int)Bot.Objects.MapId,
                                                                                Bot.Player.Position, IWowUnit.Position);

                    if (path != null)
                    {
                        IEnumerable <IWowUnit> nearEnemies = Bot.GetEnemiesInPath <IWowUnit>(path, 10.0f);

                        if (nearEnemies.Any())
                        {
                            IWowUnit = nearEnemies.FirstOrDefault();
                        }
                    }
                }

                if (IWowUnit != null)
                {
                    Bot.Wow.ChangeTarget(IWowUnit.Guid);
                }
            }

            if (IWowUnit != null)
            {
                SearchAreas.NotifyDetour();
                Bot.CombatClass.AttackTarget();
            }
            else if (Bot.Player.Position.GetDistance(CurrentSpot) < 3.0f || SearchAreas.HasAbortedPath() || Bot.Movement.Status == MovementAction.None)
            {
                CurrentSpot = SearchAreas.GetNextPosition(Bot);
                Bot.Movement.SetMovementAction(MovementAction.Move, CurrentSpot);
            }
        }
示例#3
0
 public IWowUnit GetClosestQuestGiverByNpcId(Vector3 position, IEnumerable <int> npcIds, bool onlyQuestGivers = true)
 {
     return(Objects.WowObjects.OfType <IWowUnit>()
            .Where(e => !e.IsDead && (!onlyQuestGivers || e.IsQuestgiver) && npcIds.Contains(BotUtils.GuidToNpcId(e.Guid)))
            .OrderBy(e => e.Position.GetDistance(position))
            .FirstOrDefault());
 }