コード例 #1
0
        private static void HandleErrorMessage(object sender, LuaEventArgs args)
        {
            bool handled = false;

            if (StyxWoW.Me.Class == WoWClass.Rogue && args.Args[0].ToString() == LocalizedAlreadyPickPocketedError)
            {
                if (StyxWoW.Me.GotTarget)
                {
                    WoWUnit unit = StyxWoW.Me.CurrentTarget;
                    Logging.WriteDiagnostic("[WowErrorMessage] already pick pocketed {0}, blacklisting from pick pocket for 2 minutes", unit.SafeName());
                    Blacklist.Add(unit.Guid, BlacklistFlags.Node, TimeSpan.FromMinutes(2));
                    handled = true;
                }
            }

            if (StyxWoW.Me.Class == WoWClass.Druid)
            {
                if (LocalizedShapeshiftMessages.ContainsKey(args.Args[0].ToString()))
                {
                    string symbolicName = LocalizedShapeshiftMessages[args.Args[0].ToString()];
                    LastShapeshiftFailure = DateTime.Now;
                    Logging.WriteDiagnostic("[WowErrorMessage] cast fail due to shapeshift error '{0}' while questing reported at {1}", symbolicName, LastShapeshiftFailure.ToString("HH:mm:ss.fff"));
                    handled = true;
                }
            }

            if (!handled)
            {
                Logging.WriteDiagnostic("[WoWRedError] {0}", args.Args[0].ToString());
            }
        }
コード例 #2
0
        private static void HandleCombatLog(object sender, LuaEventArgs args)
        {
            if (RoutineManager.Current.Name != AdvancedAI.Instance.Name)
            {
                return;
            }

            var e = new CombatLogEventArgs(args.EventName, args.FireTimeStamp, args.Args);

            if (e.SourceGuid != StyxWoW.Me.Guid)
            {
                return;
            }

            // Logger.WriteDebug("[CombatLog] " + e.Event + " - " + e.SourceName + " - " + e.SpellName);

            switch (e.Event)
            {
            // spell_cast_failed only passes filter in Singular debug mode
            case "SPELL_CAST_FAILED":
                Logging.WriteDiagnostic("[CombatLog] {0} {1}#{2} failure: '{3}'", e.Event, e.Spell.Name, e.SpellId, e.Args[14]);

                if (e.Args[14].ToString() == LocalizedLineOfSightFailure)
                {
                    ulong guid;
                    try
                    {
                        LastLineOfSightTarget = e.DestUnit;
                        guid = LastLineOfSightTarget == null ? 0 : LastLineOfSightTarget.Guid;
                    }
                    catch
                    {
                        LastLineOfSightTarget = StyxWoW.Me.CurrentTarget;
                        guid = StyxWoW.Me.CurrentTargetGuid;
                    }

                    LastLineOfSightFailure = DateTime.Now;
                    Logging.WriteDiagnostic("[CombatLog] cast fail due to los reported at {0} on target {1:X}", LastLineOfSightFailure.ToString("HH:mm:ss.fff"), e.DestGuid);
                }
                else if (StyxWoW.Me.Class == WoWClass.Druid)
                {
                    if (LocalizedShapeshiftMessages.ContainsKey(e.Args[14].ToString()))
                    {
                        string symbolicName = LocalizedShapeshiftMessages[e.Args[14].ToString()];
                        LastShapeshiftFailure = DateTime.Now;
                        Logging.WriteDiagnostic("[CombatLog] cast fail due to shapeshift error '{0}' while questing reported at {1}", symbolicName, LastShapeshiftFailure.ToString("HH:mm:ss.fff"));
                    }
                }
                else if (StyxWoW.Me.Class == WoWClass.Rogue)
                {
                    if (e.Args[14].ToString() == LocalizedNoPocketsToPickFailure)
                    {
                        // args on this event don't match standard SPELL_CAST_FAIL
                        // -- so, Singular only casts on current target so use that assumption
                        WoWUnit unit = StyxWoW.Me.CurrentTarget;
                        if (unit == null)
                        {
                            Logging.WriteDiagnostic("[CombatLog] has no pockets event did not have a valid unit");
                        }
                        else
                        {
                            Logging.WriteDiagnostic("[CombatLog] {0} has no pockets, blacklisting from pick pocket for 2 minutes", unit.SafeName());
                            Blacklist.Add(unit.Guid, BlacklistFlags.Node, TimeSpan.FromMinutes(2));
                        }
                    }
                }
                break;

#if SOMEONE_USES_LAST_SPELL_AT_SOME_POINT
            case "SPELL_AURA_APPLIED":
            case "SPELL_CAST_SUCCESS":
                if (e.SourceGuid != StyxWoW.Me.Guid)
                {
                    return;
                }

                // Update the last spell we cast. So certain classes can 'switch' their logic around.
                Spell.LastSpellCast = e.SpellName;
                //Logger.WriteDebug("Successfully cast " + Spell.LastSpellCast);

                // following commented block should not be needed since rewrite of Pet summon
                //
                //// Force a wait for all summoned minions. This prevents double-casting it.
                //if (StyxWoW.Me.Class == WoWClass.Warlock && e.SpellName.StartsWith("Summon "))
                //{
                //    StyxWoW.SleepForLagDuration();
                //}
                break;
#endif

            case "SWING_MISSED":
                if (e.Args[11].ToString() == "EVADE")
                {
                    HandleEvadeBuggedMob(args, e);
                }
                else if (e.Args[11].ToString() == "IMMUNE")
                {
                    WoWUnit unit = e.DestUnit;
                    if (unit != null && !unit.IsPlayer)
                    {
                        Logging.WriteDiagnostic("{0} is immune to Physical spell school", unit.Name);
                        SpellImmunityManager.Add(unit.Entry, WoWSpellSchool.Physical);
                    }
                }
                break;

            case "SPELL_MISSED":
            case "RANGE_MISSED":

                if (e.Args[14].ToString() == "EVADE")
                {
                    HandleEvadeBuggedMob(args, e);
                }
                else if (e.Args[14].ToString() == "IMMUNE")
                {
                    WoWUnit unit = e.DestUnit;
                    if (unit != null && !unit.IsPlayer)
                    {
                        Logging.WriteDiagnostic("{0} is immune to {1} spell school", unit.Name, e.SpellSchool);
                        SpellImmunityManager.Add(unit.Entry, e.SpellSchool);
                    }
                }
                break;
            }
        }