Beispiel #1
0
        public bool ExecuteStep(bool globalActive)
        {
            //can't execute this, because global is still active
            //can't execute this because we can't stop the current cast to execute this
            if ((globalActive && !_action.IgnoresGlobal()) || (RotationFramework.IsCast && !_forceCast))
            {
                return(false);
            }

            //predicate is executed separately from targetfinder predicate
            //this way we can select one target, then check which spell to cast on the target
            //as opposed to finding a target to cast a specific spell on (not the desired result)
            Func <WoWUnit, bool> targetFinderPredicate = _checkRange ? (Func <WoWUnit, bool>)((u) => u.GetDistance <= _action.Range()) : ((u) => true);

            var    watch     = System.Diagnostics.Stopwatch.StartNew();
            string spellName = "<noname>";

            if (_action.GetType() == typeof(RotationSpell))
            {
                RotationSpell spell = (RotationSpell)_action;
                spellName = spell.FullName();
            }

            WoWUnit target = _targetFinder(targetFinderPredicate);

            watch.Stop();
            RotationLogger.Trace($"({spellName}) targetFinder ({_targetFinder.Method.Name}) - {target?.Name}: {watch.ElapsedMilliseconds} ms");

            watch.Restart();
            if (target != null && _predicate(_action, target))
            {
                watch.Stop();
                RotationLogger.Trace($"({spellName}) predicate ({_targetFinder.Method.Name}): on {target.Name} {watch.ElapsedMilliseconds} ms");

                watch.Restart();
                var returnValue = _action.Execute(target, _forceCast);

                watch.Stop();
                RotationLogger.Trace($"action ({spellName}): {watch.ElapsedMilliseconds} ms");

                return(returnValue);
            }

            return(false);
        }
        public static void NotifyCombatLog(List <string> args)
        {
            lock (_verificationLock)
            {
                string timestamp   = args[0];
                string eventName   = args[1];
                string sourceGuid  = args[2];
                string sourceName  = args[3];
                string sourceFlags = args[4];
                string destGuid    = args[5];
                string destName    = args[6];
                string destFlags   = args[7];

                // we have to check that the event fired is an expected event for the type of spell being casted
                // so that spells expecting an aura will only be verified on aura appliance
                RotationSpell.VerificationType type = GetVerificationType();
                if (_successEvents[type].Contains(eventName))
                {
                    string spellId     = args[8];
                    string spellName   = args[9];
                    string spellSchool = args[10];

                    RotationLogger.Trace($"{eventName} {sourceGuid} {sourceName} {destGuid} {destName} {spellId} {spellName} {spellSchool}");

                    ulong castedBy = GetGUIDForLuaGUID(sourceGuid);
                    if (castedBy == _playerGuid && IsSpellWaitingForVerification(spellName))
                    {
                        var delegated = _eventDelegates.FirstOrDefault(e => e.Item1 == eventName);
                        if (delegated != null)
                        {
                            string delegatedEvent = delegated.Item2;
                            RotationLogger.Debug($"Delegating {eventName} to {delegatedEvent}");
                            CreatePassiveEventDelegate(delegatedEvent);
                        }
                        else
                        {
                            RotationLogger.Debug($"Clearing verification for {spellName}");
                            _verification = _emptyVerify;
                        }
                    }

                    ulong spellTarget = GetGUIDForLuaGUID(destGuid);
                    if (castedBy == 0 && IsWaitingForSpellOnTarget(spellName, spellTarget))
                    {
                        var delegated = _eventDelegates.FirstOrDefault(e => e.Item1 == eventName);
                        if (delegated != null)
                        {
                            string delegatedEvent = delegated.Item2;
                            RotationLogger.Debug($"Delegating {eventName} to {delegatedEvent}");
                            CreatePassiveEventDelegate(delegatedEvent);
                        }
                        else
                        {
                            RotationLogger.Debug($"Clearing verification for spell with no source {spellName}");
                            _verification = _emptyVerify;
                        }
                    }
                }

                if (eventName == "SPELL_CAST_FAILED")
                {
                    string spellId     = args[8];
                    string spellName   = args[9];
                    string spellSchool = args[10];
                    string failedType  = args[11];

                    ulong castedBy = GetGUIDForLuaGUID(sourceGuid);
                    if (castedBy == _playerGuid && IsSpellWaitingForVerification(spellName) && failedType != "Another action is in progress")
                    {
                        RotationLogger.Debug($"Clearing verification for {spellName} because {failedType}");
                        _verification = _emptyVerify;
                    }
                }

                if (eventName == "UNIT_DIED")
                {
                    ulong deadUnit = GetGUIDForLuaGUID(destGuid);
                    if (IsWaitingOnTarget(deadUnit))
                    {
                        RotationLogger.Debug($"Clearing verification because target died");
                        _verification = _emptyVerify;
                    }

                    if (deadUnit == _playerGuid)
                    {
                        RotationLogger.Debug($"Clearing verification because we died");
                        _verification = _emptyVerify;
                    }
                }

                ClearVerificationOlderThan(10);
            }
        }