コード例 #1
0
        private void FilterAbilities(long tick, List <BossSpawnAbilities> phaseAbilities)
        {
            foreach (var ability in phaseAbilities)
            {
                var t      = ConditionManager.GetType();
                var method = t.GetMethod(ability.Condition);
                _logger.Debug($"Checking condition: {ability.Condition} ");
                var conditionTrue = (bool)method.Invoke(ConditionManager, null);
                if (conditionTrue)
                {
                    // If the ability is not in the ability tracker, add it
                    if (!AbilityTracker.ContainsKey(ability))
                    {
                        lock (AbilityTracker)
                        {
                            AbilityTracker.Add(ability, TCPManager.GetTimeStamp() + NEXT_ATTACK_COOLDOWN);
                        }

                        _logger.Debug($"Adding ability to the tracker : {AbilityTracker.Count} {ability.Name} 0");
                    }
                    else // If this ability is already in the abilitytracker  -- can probably remove this as it should be removed on execution.
                    {
                        long nextInvocation = 0;

                        // If it's next invocation > now, dont add.
                        AbilityTracker.TryGetValue(ability, out nextInvocation);
                        if (nextInvocation > tick)
                        {
                            // Do nothing
                        }
                    }
                }
            }
        }
コード例 #2
0
        public override void Think(long tick)
        {
            if (_unit.IsDead)
            {
                return;
            }

            base.Think(tick);

            // Only bother to seek targets if we're actually being observed by a player
            if (Combat.CurrentTarget == null && _unit.PlayersInRange.Count > 0)
            {
                if (_pet != null && (_pet.IsHeeling || ((CombatInterface_Pet)_pet.CbtInterface).IgnoreDamageEvents))
                {
                    return;
                }

                var target = _unit.AiInterface.GetAttackableUnit();
                if (target != null)
                {
                    _unit.AiInterface.ProcessCombatStart(target);
                }
            }

            if (Combat.IsFighting && Combat.CurrentTarget != null &&
                _unit.AbtInterface.CanCastCooldown(0) &&
                tick > NextTryCastTime)
            {
                var phaseAbilities = GetPhaseAbilities();

                // Get abilities that can fire now.
                FilterAbilities(tick, phaseAbilities);

                // Sort dictionary in value (time) order.
                var myList = AbilityTracker.ToList();
                myList.Sort((pair1, pair2) => pair1.Value.CompareTo(pair2.Value));

                foreach (var keyValuePair in myList)
                {
                    _logger.Debug($"***{keyValuePair.Key.Name} => {keyValuePair.Value}");
                }

                ExecuteNextAbilityFromList(tick, myList);
            }
        }
コード例 #3
0
ファイル: NpcBrain.cs プロジェクト: cooler-SAI/ProjectWAR
        private void FilterAbilities(long tick)
        {
            foreach (var ability in Abilities)
            {
                var t      = ConditionManager.GetType();
                var method = t.GetMethod(ability.Condition);
                _logger.Debug($"Checking condition: {ability.Condition} ");
                if (method == null)
                {
                    _logger.Error($"Method is null: {ability.Condition} ");
                    return;
                }
                var conditionTrue = (bool)method.Invoke(ConditionManager, null);
                if (conditionTrue)
                {
                    // If the ability is not in the ability tracker, add it
                    if (!AbilityTracker.ContainsKey(ability))
                    {
                        lock (AbilityTracker)
                        {
                            AbilityTracker.Add(ability, 0);
                        }

                        _logger.Debug($"Adding ability to the tracker : {AbilityTracker.Count} {ability.Name} 0");
                    }
                    else // If this ability is already in the abilitytracker  -- can probably remove this as it should be removed on execution.
                    {
                        long nextInvocation = 0;

                        // If it's next invocation > now, dont add.
                        AbilityTracker.TryGetValue(ability, out nextInvocation);
                        if (nextInvocation > tick)
                        {
                            // Do nothing
                        }
                    }
                }
                else
                {
                    // Condition is no longer true - remove it from the AbilityTracker
                    AbilityTracker.Remove(ability);
                }
            }
        }