Exemple #1
0
        public static void Display()
        {
            Color c = Color.Yellow;
            List <KeyValuePair <string, int> > list = elapseds.ToList();

            list.Sort(
                delegate(KeyValuePair <string, int> p1, KeyValuePair <string, int> p2)
            {
                int compareDate = p2.Value.CompareTo(p1.Value);
                if (compareDate == 0)
                {
                    return(p1.Key.CompareTo(p2.Key));
                }
                ;
                return(compareDate);
            }
                );
            FTWLogger.debug(c, "Timings:");
            int total = 0;

            foreach (KeyValuePair <string, int> kvp in list)
            {
                total += kvp.Value;
            }
            foreach (KeyValuePair <string, int> kvp in list)
            {
                FTWLogger.debug(c, "    {0}: total time {1} ms, ({2:0.0}%), loops {3}, avgtime {4:0} ms", kvp.Key, kvp.Value, kvp.Value * 100 / total, count[kvp.Key], kvp.Value / count[kvp.Key]);
            }
        }
Exemple #2
0
 public static void printAuras(this WoWUnit unit)
 {
     foreach (WoWAura aura in unit.Auras.Values)
     {
         FTWLogger.debug(aura.Name + ' ' + aura.CreatorGuid);
     }
 }
Exemple #3
0
        public static void Stop(string s, bool displaynow = false)
        {
            int elapsedtime = (int)(DateTime.Now - starts[s]).TotalMilliseconds;

            if (!elapseds.ContainsKey(s))
            {
                elapseds.Add(s, elapsedtime);
                count.Add(s, 1);
            }
            else
            {
                elapseds[s] += elapsedtime;
                count[s]    += 1;
            }
            if (displaynow && elapsedtime > 0)
            {
                FTWLogger.debug(Color.SeaShell, string.Format("-------------------- {0} ({1}) {2}", s, elapsedtime, BotPoi.Current.ToString()));
            }
        }
Exemple #4
0
        public static void Pulse()
        {
            int      currenthealth = (int)StyxWoW.Me.HealthPercent;
            DateTime currenttime   = DateTime.Now;
            double   healthchange  = currenthealth - lasthealth;
            double   elapsedms     = (currenttime - lastauraupdate).TotalMilliseconds;

            double r = healthchange * 1000 / elapsedms;

            //if (r < 0)
            //    debug(Color.Orange, "Current health: {0:0.0}, Last health: {1:0.0}, Diff: {2:0.0}, Ms: {3:0.0}, Rate: {4:0.0} ", currenthealth, lasthealth, healthchange, elapsedms, r);

            lasthealth     = currenthealth;
            lastauraupdate = currenttime;

            foreach (WoWAura aura in StyxWoW.Me.Auras.Values.ToList())
            {
                if (!auras.ContainsKey(aura.Name))
                {
                    if (aura.TimeLeft.TotalSeconds > 0)
                    {
                        if (aura.IsHarmful)
                        {
                            FTWLogger.debug(Color.Pink, "+++ {0} - {1} stacks, {2:0.0} seconds remaining", aura.Name, aura.StackCount, aura.TimeLeft.TotalSeconds);
                        }
                        else
                        {
                            FTWLogger.debug(Color.LightGreen, "+++ {0} - {1} stacks, {2:0.0} seconds remaining", aura.Name, aura.StackCount, aura.TimeLeft.TotalSeconds);
                        }
                        auras[aura.Name] = aura;
                    }
                }
            }

            foreach (WoWAura aura in auras.Values.ToList())
            {
                if (!StyxWoW.Me.Auras.ContainsKey(aura.Name))
                {
                    FTWLogger.debug(Color.Gray, "----- {0}", aura.Name);
                    auras.Remove(aura.Name);
                }
            }
        }
Exemple #5
0
        public static bool IsValidUnit(this WoWUnit unit)
        {
            string fnname = "FTWExtensionMethods.IsValidUnit";

            if (unit == null)
            {
                return(false);
            }
            MyTimer.Start(fnname);
            bool   retval = true;
            string ispet  = unit.IsPet.ToString();
            string owner  = "<none>";
            string reason = "";

            if (Blacklist.Contains(unit.Guid))
            {
                if (unit.Combat && (
                        unit.IsTargetingMeOrPet ||
                        unit.IsTargetingMyPartyMember ||
                        unit.IsTargetingAnyMinion ||
                        unit.IsTargetingMyRaidMember ||
                        FTWCoreUnits.IsTargetingPartyPets(unit)
                        ))
                {
                    // ignore  blacklist
                    // HB will keep feeding you that target anyway.
                }
                else
                {
                    reason = "{0} is blacklisted";
                }
            }
            else if (!unit.CanSelect || !unit.Attackable)
            {
                reason = "can't select or attack {0}";
            }
            else if (unit.IsFriendly)
            {
                reason = "{0} is friendly";
            }
            else if (unit.IsDead)
            {
                reason = "{0} is dead";
            }
            // The following line causes you to ignore mobs your party is fighting.
            //else if (unit.TaggedByOther) reason = "{0} is tagged by other.";
            else if (unit.HealthPercent == 0)
            {
                reason = "{0}'s health is 0";
            }
            else if ((unit.IsPet && ((unit.OwnedByUnit != null && unit.OwnedByUnit.IsPlayer == true) || unit.OwnedByRoot == null || unit.OwnedByRoot.IsDead == false)))
            {
                reason = "{0} is pet";
            }
            else if (unit.IsNonCombatPet)
            {
                reason = "{0} is noncombat pet";
            }
            else if (unit.IsCritter)
            {
                reason = "{0} is critter";
            }
            else if (Battlegrounds.IsInsideBattleground && FTWProps.IgnoreMobsBattleground.Contains(unit.Name))
            {
                reason = "{0} is in ignored battleground mobs";
            }
            MyTimer.Stop(fnname);
            if (reason == "")
            {
                retval = true;
                if (false && unit.IsPet)
                {
                    if (unit.OwnedByRoot != null)
                    {
                        string prefix = "npc";
                        if (unit.OwnedByRoot.IsPlayer)
                        {
                            prefix = "player";
                        }
                        owner = string.Format("pet {0} owned by {1} {2}", unit.Name, prefix, unit.OwnedByRoot.Name);
                    }
                    else
                    {
                        owner = string.Format("pet {0} owned by no one", unit.Name);
                    }
                    FTWLogger.debug(Color.MediumVioletRed, owner);
                }
            }
            else
            {
                FTWLogger.debug(Color.MediumVioletRed, reason, unit.Name);
                retval = false;
            }
            return(retval);
        }