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

Methods i found usefull

Thacai

Member
Joined
Jan 15, 2010
Messages
71
Reaction score
0
I'm currently working on a universal rotationbot(only rotation), and currently i've made quite some methods i find very usefull for CC developing:

Get your /Focus as a WoWUnit:
Code:
public WoWUnit GetFocus()
        {
                string name = Lua.GetReturnVal<string>("return GetUnitName(\"" + "focus" + "\");", 0);
                var units = ObjectManager.GetObjectsOfType<WoWUnit>(true, true).First((unit) => unit.Name == name && name != null && name != string.Empty && name.ToLower() != "nil");
                if (units != null)
                {
                    return units;
                }
                return null;
        }

Check if a WoWUnit have a buff casts by yourself:

Code:
public bool HasBuff(WoWUnit unit, WoWSpell buff)
        {
            if(unit.GetAllAuras().First((aura) => aura.SpellId == buff.Id && 
                aura.CreatorGuid==Me.Guid) != null && unit != null)
            {
                return true;
            }
            return false;
        }

Get buff/debuff of spells which is casts by you, usefull for timing of spellcasts for dot classes:

Code:
public double BuffDurationLeft(WoWUnit who, WoWSpell whatspell)
        {
            var matchingAura = who.GetAllAuras().First((aura) => aura.SpellId == whatspell.Id && aura.CreatorGuid == Me.Guid);
            if(matchingAura != null && who != null)
            {
               return matchingAura.TimeLeft.TotalMilliseconds;
            }
            return 0;
        }

And last but not least, i toyed around with this new Composite, "DecoratorContinue", and found a pretty nice use for it!:

Code:
private Composite DrainLife()
        {
            return new Decorator(ret => !Me.IsMoving && Core.CanCast(WarlockSpells.DrainLife) && Me.CurrentTarget.HealthPercent > 25,
                new Sequence(
                    new DecoratorContinue(ret => Core.CanCast(WarlockSpells.Soulburn) && Settings.SoulBurnDrainLife && !Core.CheckBloodlust(),
                        new Action(ret => SpellManager.Cast(WarlockSpells.Soulburn))),
                        new Action(ret => SpellManager.Cast(WarlockSpells.DrainLife))));
        }

it will try to use soulburn if everything is true, and then afterwards use drainlife, if it cant use soulburn it will just use drainlife, without having to use multiple methods for the same thing like having 1 named "NormalDrainLife" and another named "SoulBurnDrainLife" etc

Enjoy, Thacai out :)
 
Small update:
Easy debugging of performance:

Code:
public static void Debug(MethodBase method, Stopwatch watch)
        {
            watch.Stop();
            Logging.WriteDebug("Method: {0} Took: {1} ms", method.Name, watch.Elapsed.TotalMilliseconds.ToString());
            watch.Start();
        }

By using that, then in the methods you want to check performance on you can go like:

Code:
public static bool CheckBloodlust
        {
            get
            {
                Stopwatch timer = new Stopwatch();
                timer.Start();
                string[] auras = { WarlockSpells.Heroism.Name, WarlockSpells.Bloodlust.Name, WarlockSpells.Ancient_Hysteria.Name, WarlockSpells.Time_Warp.Name };
                Debug(MethodBase.GetCurrentMethod(), timer);
                bool filler = Me.Auras.Values.Any(ret => auras.Contains(ret.Name));
                Debug(MethodBase.GetCurrentMethod(), timer);
                return filler;
            }

        }

Then you can compare the timer before and after it have done something :)
 
Back
Top