What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

[Fix][CC devs] Detecting procs (spell auras) - solution provided

cowdude

Active Member
Joined
Feb 17, 2010
Messages
337
Reaction score
27
I got some issues detecting spell procs like Decimation for warlocks or The Art of War.

Me.ActiveAuras won't list them, and all you can get is the PASSIVE aura which allow the given spell to proc.

Relying on LUA seems a nice workaround, even though it generates a few injection failed in the debug log. Here's the idea:

PHP:
public string HAX_Aura(string name)
        {
            var lua = "return select(1, UnitBuff('player', \"{0}\"))";
            var r = Lua.GetReturnVal<string>(string.Format(lua, name), 0);
            if (r == null || r == "nil")
                return string.Empty;
            else
                return r;
        }

public bool HasAura (string name) { return HAX_Aura(name).Length > 0; }
 
that would be very slow, since it queueries the WoW process, and depends on latency, like addons do.

What i've did so far for my Warlock CC(still developing) is this:

Code:
public static bool HasBuff(WoWUnit unit, WoWSpell buff)
        {
            //Stopwatch timer = new Stopwatch();
            //timer.Start();
            try
            {
                if (unit.HasAura(buff.Name))
                {
                    //Debug(MethodBase.GetCurrentMethod(), timer);
                    return true;
                }
                return false;
            }
            catch (Exception ex)
            {
                Logging.WriteException(ex);
                //Debug(MethodBase.GetCurrentMethod(), timer);
                return false;
                //throw;
            }

        }

or if you want to add additional checks, like owner, then this is what i did for debuff checking:

Code:
public static bool HasDebuff(WoWUnit unit, WoWSpell buff)
        {
            Stopwatch timer = new Stopwatch();
            timer.Start();
            try
            {
                if (unit != null)
                {
                    if (unit.HasAura(buff.Name))
                    {
                        Debug(MethodBase.GetCurrentMethod(), timer);
                        bool filler = unit.GetAllAuras().Count(ret => ret.SpellId == buff.Id && ret.CreatorGuid == Me.Guid) > 0;
                        return filler;
                    }
                }

                return false;
            }
            catch (Exception ex)
            {
                Logging.WriteException(ex);
                Debug(MethodBase.GetCurrentMethod(), timer);
                return false;
                //throw;
            }

        }

the GetAllAuras was a workaround since apparently not all debuffs were included in Me.target.Debuffs
 
Just add a timer on it if it's too spammy. It's still damn fast and won't eat that much memory.

Anyway, I've tried every single way to detect spell procs and all failed.

Me.HasAura("Decimation") isn't reliable. It may sometimes work but still, it will end up detecting the talent spell instead of the proc itself.

Talking about operation costs by the way: myIEnumerableClass.Any (x => ...) is slightly better than .Count(x => ...) > 0.
 
Back
Top