コード例 #1
0
ファイル: FTWCoreItems.cs プロジェクト: psmyth1/code-samples
        public static bool ImbueWeapon(String spellname, string slotname, int slotid)
        {
            bool retval;

            FTWLogger.log(Color.YellowGreen, "ImbueWeapon {0} {1} {2}", spellname, slotname, slotid);
            if (!SpellManager.HasSpell(spellname))
            {
                FTWLogger.log(Color.YellowGreen, "Don't have spell");
                retval = false;
            }
            else if (FTWCoreStatus.OnCooldown(spellname, true))
            {
                retval = false;
            }
            else
            {
                FTWLogger.log(Color.YellowGreen, "Imbuing {0} weapon with '{1}'", slotname, spellname);
                Lua.DoString(string.Format("CancelItemTempEnchantment({0})", slotid));
                Thread.Sleep(1000);
                FTWCoreActions.On_Cast(string.Format("Me.ImbueWeapon{0}", slotid), spellname, StyxWoW.Me, false, false);
                Thread.Sleep(1000);
                FTWCoreStatus.SaveCooldown(spellname);
                retval = true;
            }
            return(retval);
        }
コード例 #2
0
        public static bool On_FindBetterTarget(string reason)
        {
            string fnname = "FTWCore.On_FindBetterTarget";

            MyTimer.Start(fnname);
            if (FTWUtils.MovementDisabled())
            {
                FTWLogger.log(Color.Violet, "MOVEMENT DISABLED, not looking for better target");
                MyTimer.Stop(fnname);
                return(false);
            }
            WoWUnit target = StyxWoW.Me.CurrentTarget;

            if (target != null && target.IsValidUnit() && !target.IsDead && !target.IsCrowdControlled() && FTWCoreStatus.OnCooldown("FindBetterTarget"))
            {
                MyTimer.Stop(fnname);
                return(false);
            }

            bool retval = ListAndTakeNewTarget(FTWProps.adds);

            if (retval == true)
            {
                FTWCoreStatus.SaveCooldown("FindBetterTarget");
            }
            MyTimer.Stop(fnname);
            return(retval);
        }
コード例 #3
0
ファイル: FTWCoreItems.cs プロジェクト: psmyth1/code-samples
        public static bool On_Eat()
        {
            string fnname = "FTWCore.On_Eat";

            MyTimer.Start(fnname);
            bool retval;

            if (BotPoi.Current.Type != PoiType.None)
            {
                return(false);
            }

            if (StyxWoW.Me.HasAura("Food"))
            {
                retval = true;
            }
            else if (FTWCoreStatus.OnCooldown("On_Eat"))
            {
                retval = false;
            }
            else if (FTWUtils.MovementDisabled())
            {
                retval = false;
            }
            else if (StyxWoW.Me.Mounted)
            {
                retval = false;
            }
            else
            {
                WoWItem eat = Consumable.GetBestFood(false);
                if (eat == null)
                {
                    retval = false;
                }
                else
                {
                    Navigator.PlayerMover.MoveStop();
                    Styx.CommonBot.Rest.FeedImmediate();
                    DateTime stoptime = DateTime.Now.AddSeconds(10);
                    while (DateTime.Now < stoptime)
                    {
                        if (StyxWoW.Me.HasAura("Food"))
                        {
                            break;
                        }
                        Thread.Sleep(100);
                    }
                    FTWCoreStatus.SaveCooldown("On_Eat");
                    retval = true;
                }
            }
            MyTimer.Stop(fnname);
            return(retval);
        }
コード例 #4
0
        public static bool On_GrabAggro()
        {
            string fnname = "FTWCore.On_GrabAggro";

            MyTimer.Start(fnname);
            if (FTWUtils.MovementDisabled())
            {
                FTWLogger.log(Color.Violet, "MOVEMENT DISABLED - Not grabbing aggro.");
                MyTimer.Stop(fnname);
                return(false);
            }
            WoWUnit target = StyxWoW.Me.CurrentTarget;

            if (target != null && target.IsValidUnit() && FTWCoreStatus.OnCooldown("GrabAggro"))
            {
                MyTimer.Stop(fnname);
                return(false);
            }

            List <WoWUnit> units =
                (from u in FTWProps.adds
                 where u.Combat && u.IsValidUnit()
                 orderby
                 u.TargetWeight() descending,
                 u.IsCrowdControlled() ascending,
                 u.IsAttackingHealer() descending,
                 (int)u.ThreatInfo.ThreatStatus < 4 descending,
                 u.Guid == StyxWoW.Me.CurrentTargetGuid descending,
                 u.Guid == FTWProps.tank.CurrentTargetGuid descending,
                 u.Distance < 5 descending,
                 u.DistanceSqr ascending
                 select u).ToList();

            bool retval = ListAndTakeNewTarget(units);

            if (retval == true)
            {
                FTWCoreStatus.SaveCooldown("GrabAggro");
            }
            MyTimer.Stop(fnname);
            return(retval);
        }
コード例 #5
0
        public static bool Macro(string macrotext)
        {
            double cooldown = 0;
            int    c        = macrotext.IndexOf(' ');

            if (c >= 0)
            {
                string s = macrotext.Substring(0, c);
                if (Double.TryParse(s, out cooldown))
                {
                    macrotext = macrotext.Substring(c + 1);
                }
            }
            if (FTWCoreStatus.OnCooldown(macrotext, cooldown, false))
            {
                return(false);
            }
            FTWLogger.debug("    Macro: {0}", macrotext);
            Lua.DoString(string.Format("RunMacroText(\"{0}\");", macrotext));
            FTWCoreStatus.SaveCooldown(macrotext);
            return(false);
        }
コード例 #6
0
        public static bool On_Cast(string firstpart, string spellname, WoWUnit target, bool castnow, bool castonce, bool debugspell = false)
        {
            string fnname = "FTWCore.On_Cast";

            MyTimer.Start(fnname);
            LocalPlayer Me     = StyxWoW.Me;
            WoWSpell    spell  = null;
            bool        retval = true;
            Color       ds     = Color.Magenta;

            if (target != null && !target.IsFriendly && target.IsDead)
            {
                if (debugspell)
                {
                    FTWLogger.log(ds, "Target is hostile and dead");
                }
                MyTimer.Stop(fnname);
                return(false);
            }

            if (FTWCoreStatus.OnCooldown(spellname, debugspell))
            {
                MyTimer.Stop(fnname);
                return(false);
            }

            if (target != null && !target.IsFriendly && !FTWUtils.MovementDisabled())
            {
                FTWCoreMovement.Face(target);
            }

            // Clear out expired CastOnce entries (older than CastOnceTime seconds)
            foreach (KeyValuePair <String, DateTime> kvp in FTWProps.CastOnce.ToList())
            {
                if (DateTime.Now > kvp.Value)
                {
                    FTWProps.CastOnce.Remove(kvp.Key);
                }
            }

            // Leave early if CastOnce contains unexpired entry for this unit
            if (FTWProps.CastOnce.ContainsKey(spellname + target.Guid.ToString()))
            {
                if (debugspell)
                {
                    FTWLogger.log(ds, "Already cast {0} on {1}", spellname, target.Name);
                }
                MyTimer.Stop(fnname);
                return(false);
            }

            if (SpellManager.GlobalCooldown)
            {
                if (debugspell)
                {
                    FTWLogger.log(ds, "...");
                }
                MyTimer.Stop(fnname);
                return(false);
            }

            try
            {
                if (FTWProps.fakecooldowns.ContainsKey(spellname))
                {
                    spell = WoWSpell.FromId(FTWProps.fakecooldowns[spellname].SpellID);
                }
                else if (SpellManager.Spells.ContainsKey(spellname))
                {
                    spell = SpellManager.Spells[spellname];
                }
                else
                {
                    FTWLogger.debug(Color.Gray, "Unknown spell {0}", spellname);
                    MyTimer.Stop(fnname);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                FTWLogger.log(Color.Pink, "Error when getting spell {0}: {1}", spellname, ex.Message);
                MyTimer.Stop(fnname);
                return(false);
            }

            if (spell == null)
            {
                FTWLogger.debug(Color.Gray, "Unknown spell '{0}'", spellname);
                MyTimer.Stop(fnname);
                return(false);
            }

            // Check whether or not you know the spell according to WoW
            if (false) // leave commented out for now
            {
                List <string> known      = Lua.GetReturnValues(String.Format("return IsSpellKnown({0})", spell.Id), "SpellKnown.lua");
                int           knownspell = Int32.Parse(known[0]);
                if (knownspell == 0)
                {
                    FTWLogger.log(Color.Gray, "GetSpellInfo says you don't know spell {0} ({1})", spellname, known[0]);
                    MyTimer.Stop(fnname);
                    return(false);
                }
            }

            if (false)
            {
                // Check power requirements
                List <string> values = Lua.GetReturnValues(String.Format("return GetSpellInfo({0})", spell.Id), "SpellInfo.lua");
                //string[] vars = {"name", "rank", "icon", "cost", "isFunnel", "powerType", "castTime", "minRange", "maxRange"};
                int      powerType  = Int32.Parse(values[5]);
                int      powerCost  = Int32.Parse(values[3]);
                string[] powertypes = { "mana",      "rage",        "focus",           "energy",
                                        "happiness", "runes",       "runic power",     "soul shards",
                                        "eclipse",   "holy power",  "alternate power", "dark force",
                                        "chi",       "shadow orbs", "burning embers",  "demonic fury" };
                if (StyxWoW.Me.UnitPower(powerType) < powerCost)
                {
                    FTWLogger.log(Color.Orange, "NOT ENOUGH {0} - Requires: {1}, but I have: {2}", powertypes[powerType], powerCost, StyxWoW.Me.UnitPower(powerType));
                    MyTimer.Stop(fnname);
                    return(false);
                }
            }

            if (!spell.IsSelfOnlySpell)
            {
                if (target == null)
                {
                    FTWLogger.log(Color.Orange, "Can't cast {0} on null target!", spell.Name);
                    if (debugspell)
                    {
                        FTWLogger.log(ds, "Null target");
                    }
                    MyTimer.Stop(fnname);
                    return(false);
                }
                double dist = target.Distance; // target.DistanceCalc();
                if ((spell.MinRange > 0 || spell.MaxRange > 0) && !(dist >= spell.MinRange && dist <= spell.MaxRange))
                {
                    FTWLogger.log(Color.Orange, "Can't cast spell {0} {1} on {2} health {3:0.0} dist {4:0.0} minrange {5} maxrange {6}", spellname, spell.Id, target.SafeName(), target.HealthPercent, target.DistanceCalc(), spell.MinRange, spell.MaxRange);
                    if (debugspell)
                    {
                        FTWLogger.log(ds, "Out of range");
                    }
                    MyTimer.Stop(fnname);
                    return(false);
                }
                if (!target.InLineOfSight)
                {
                    FTWLogger.log(Color.Orange, "Can't cast spell {0} {1} on {2} health {3:0.0} dist {4:0.0} (not in line of sight)", spellname, spell.Id, target.SafeName(), target.HealthPercent, target.DistanceCalc());
                    if (debugspell)
                    {
                        FTWLogger.log(ds, "Not in line of sight. Attempts = {0}.", FTWProps.not_in_los_attempts);
                    }
                    MyTimer.Stop(fnname);

                    FTWProps.not_in_los_attempts += 1;
                    Navigator.MoveTo(target.Location);
                    Thread.Sleep(2000);
                    return(false);
                }

                if (spellname == "Death Pact" && Me.GotAlivePet)
                {
                    Me.Pet.Target();
                    for (int l = 0; l < 2; l++)
                    {
                        Thread.Sleep(10);
                    }
                }

                if (FTWProps.CastOver.Contains(FTWProps.lastspellcastname))
                {
                    retval = true;
                }
                else if (spell.IsSelfOnlySpell)
                {
                    retval = SpellManager.CanCast(spell, true);
                }
                else
                {
                    retval = SpellManager.CanCast(spell, target, true);
                }

                if (FTWProps.IgnoreCanCast.Contains(spellname))
                {
                    if (debugspell)
                    {
                        FTWLogger.log(ds, "Ignoring cancast for {0}", spellname);
                    }
                    retval = true;
                }
                if (retval == false)
                {
                    if (spell.IsSelfOnlySpell)
                    {
                        FTWLogger.debug(Color.Orange, "CanCast returned false for {0} {1} on me", spellname, spell.Id);
                    }
                    else
                    {
                        FTWLogger.debug(Color.Orange, "CanCast returned false for {0} {1} on {2} health {3:0.0} dist {4:0.0}", spellname, spell.Id, target.SafeName(), target.HealthPercent, target.DistanceCalc());
                    }
                    MyTimer.Stop(fnname);
                    if (debugspell)
                    {
                        FTWLogger.log(ds, "CanCast returned false");
                    }
                    return(false);
                }
            }

            // Leave early if still casting
            if (!castnow && (Me.IsCasting || Me.IsChanneling))
            {
                if (debugspell)
                {
                    FTWLogger.log(ds, "Still casting");
                }
                return(false);
            }
            // Definitely going to cast - Stop casting
            if (Me.IsCasting || Me.IsChanneling)
            {
                if (FTWProps.CastOver.Contains(FTWProps.lastspellcastname))
                {
                    FTWLogger.log("Currently casting {0} - casting over it with {1}", FTWProps.lastspellcastname, spellname);
                }
                else if (castnow)
                {
                    SpellManager.StopCasting();
                }
            }

            // Stop moving
            if (spell.CastTime > 0 && !FTWUtils.MovementDisabled())
            {
                WoWMovement.MoveStop();
            }

            // Clear target spell, if one is up
            if (StyxWoW.Me.CurrentPendingCursorSpell != null)
            {
                Lua.DoString("SpellStopTargeting()");
            }

            if (spell.IsTankOnlySpell() == true)
            {
                // Spells that are only ever cast on tanks, such as Misdirection and Tricks of the Trade.
                if (FTWProps.people.Count > 1 && FTWProps.tank.Guid != Me.Guid && FTWProps.tank.IsDead == false)
                {
                    FTWLogger.log("cast tank-only spell {0} on {1}", spell.Name, FTWProps.tank.SafeName());
                    if (SpellManager.CanCast(spell, FTWProps.tank))
                    {
                        FTWLogger.log("nope - failed cancast check.");
                        retval = SpellManager.Cast(spell, FTWProps.tank);
                    }
                }
                else if (StyxWoW.Me.GotAlivePet && Me.Pet.IsDead == false)
                {
                    FTWLogger.log("cast tank-only spell {0} on pet", spell.Name);
                    if (SpellManager.CanCast(spell, Me.Pet))
                    {
                        FTWLogger.log("nope - failed cancast check.");
                        retval = SpellManager.Cast(spell, Me.Pet);
                    }
                }
                else
                {
                    retval = false;
                }
            }
            else if (spell.IsAreaSpell() == false)
            {
                // Most normal spells
                if (spell.IsSelfOnlySpell)
                {
                    retval = SpellManager.Cast(spell);
                }
                else
                {
                    retval = SpellManager.Cast(spell, target);
                }

                // Post-spell processing
                if (spellname == "Feign Death")
                {
                    while (Me.HasAura("Feign Death"))
                    {
                        List <WoWUnit> mobs = (List <WoWUnit>)FTWCoreUnits.GetNearbyUnfriendlyUnits();
                        if (mobs.Count == 0 && StyxWoW.Me.HealthPercent > 95)
                        {
                            break;
                        }
                        Thread.Sleep(10);
                    }
                }
            }
            else
            {
                // Area spell
                WoWPoint loc;

                if (spell.IsSelfOnlySpell && !spell.Name.EndsWith(" Trap"))
                {
                    loc = StyxWoW.Me.Location;
                }
                else
                {
                    loc = target.Location;
                }
                retval = SpellManager.Cast(spell);
                DateTime stoptime = DateTime.Now.AddMilliseconds(500);
                while (DateTime.Now < stoptime)
                {
                    if (StyxWoW.Me.CurrentPendingCursorSpell != null)
                    {
                        break;
                    }
                    Thread.Sleep(10);
                }
                SpellManager.ClickRemoteLocation(loc);
                stoptime = DateTime.Now.AddMilliseconds(500);
                while (DateTime.Now < stoptime)
                {
                    // Clear target spell, if one is up
                    if (StyxWoW.Me.CurrentPendingCursorSpell == null)
                    {
                        break;
                    }
                    Thread.Sleep(10);
                }
                // Clear target spell, if one is up
                if (StyxWoW.Me.CurrentPendingCursorSpell != null)
                {
                    Lua.DoString("SpellStopTargeting()");
                }
            }

            // Add current spell to CastOnce dictionary
            if (castonce == true)
            {
                FTWProps.CastOnce[spellname + target.Guid.ToString()] = DateTime.Now.AddSeconds(FTWProps.CastOnceTime);
            }

            // Wait until spell starts casting
            if (spell.CastTime > 0)
            {
                DateTime dt = DateTime.Now.AddSeconds(1.5);
                while (DateTime.Now < dt && !StyxWoW.Me.IsCasting && !StyxWoW.Me.IsChanneling)
                {
                    Thread.Sleep(10);
                }
            }

            // Save spell cooldown
            if (retval == true)
            {
                FTWLogger.log("    {0} {1} on {2} {3} health {4:0} dist {5:0.0} aggro {6} {7} (addscount {8})", firstpart, spellname, target.SafeName(), target.ShortGuid(), target.HealthPercent, target.DistanceCalc(), (int)target.ThreatInfo.ThreatStatus, target.ThreatInfo.ThreatStatus, FTWProps.adds.Count);
                FTWCoreStatus.SaveCooldown(spellname);
                FTWProps.MovementCooldown    = DateTime.Now.Add(TimeSpan.FromMilliseconds(Math.Min(1500, spell.CastTime)));
                FTWProps.not_in_los_attempts = 0;
            }
            else
            {
                FTWLogger.log(Color.Gray, "  - Couldn't cast spell {0} on {1} {2} at dist {3:0.0}", spellname, target.SafeName(), target.ShortGuid(), target.DistanceCalc());
            }

            if (FTWProps.Stuns.Contains(spellname))
            {
                // Don't attack again for 3 seconds - hb is slow in noticing cc's.
                Blacklist.Add(target.Guid, BlacklistFlags.Combat, TimeSpan.FromSeconds(3));
                if (target.Guid == StyxWoW.Me.CurrentTargetGuid)
                {
                    StyxWoW.Me.ClearTarget();
                }
            }

            MyTimer.Stop(fnname);
            return(retval);
        }
コード例 #7
0
ファイル: FTWCore.cs プロジェクト: psmyth1/code-samples
        private string Replace(string prefix, string s, WoWUnit theunit)
        {
            string fnname = "FTWCore.Replace";

            MyTimer.Start(fnname);
            if (theunit != null && theunit.Guid == StyxWoW.Me.Guid)
            {
                if (StyxWoW.Me.HasAura("Eclipse (Solar)"))
                {
                    FTWProps._eclipsedirection = -1;
                }
                else if (StyxWoW.Me.HasAura("Eclipse (Lunar)"))
                {
                    FTWProps._eclipsedirection = 1;
                }
            }

            // Replace aura checks with parenthese (Target.HasMyAura("Bad Aura") > 3)
            string findstring             = string.Format(@"{0}\.(?<action>.*)\(""(?<aura>.*)""\)", prefix);
            Regex  rg                     = new Regex(findstring);
            Match  match                  = rg.Match(s);
            Dictionary <String, Object> d = new Dictionary <String, Object>();

            while (match.Success)
            {
                if (!d.ContainsKey(match.Value))
                {
                    string action = match.Groups["action"].Value;
                    string aura   = match.Groups["aura"].Value;
                    int    value  = 0;
                    if (false)
                    {
                    }
                    else if (action == "Weapon1HasAura")
                    {
                        value = (theunit != null && FTWCoreItems.WeaponEnchant(1) == aura) ? 1 : 0;
                    }
                    else if (action == "Weapon2HasAura")
                    {
                        value = (theunit != null && FTWCoreItems.WeaponEnchant(2) == aura) ? 1 : 0;
                    }
                    else if (action == "AuraExpiring")
                    {
                        value = (theunit != null) ? theunit.AuraExpiring(aura) : 0;
                    }
                    else if (action == "CanCast")
                    {
                        value = (theunit != null && SpellManager.CanCast(aura, theunit)) ? 1 : 0;
                    }
                    else if (action == "ClearBehindMe")
                    {
                        value = (theunit != null && StyxWoW.Me.ClearBehindMe(aura) ? 1 : 0);
                    }
                    else if (action == "HasAura")
                    {
                        value = (theunit != null && theunit.HasAura(aura)) ? 1 : 0;
                    }
                    else if (action == "HasItem")
                    {
                        value = StyxWoW.Me.HasItem(aura) ? 1 : 0;
                    }
                    else if (action == "HasMyAura")
                    {
                        value = (theunit != null && theunit.HasMyAura(aura)) ? 1 : 0;
                    }
                    else if (action == "HasSpell")
                    {
                        value = (StyxWoW.Me.HasSpell(aura)) ? 1 : 0;
                    }
                    else if (action == "HasTotem")
                    {
                        value = FTWCoreStatus.HasTotem(aura) ? 1 : 0;
                    }
                    else if (action == "IsCasting")
                    {
                        value = (theunit != null && theunit.CurrentSpellName() == aura) ? 1 : 0;
                    }
                    else if (action == "ItemOnCooldown")
                    {
                        value = FTWCoreItems.ItemOnCooldown(aura) ? 1 : 0;
                    }
                    else if (action == "MyAuraExpiring")
                    {
                        value = (theunit != null) ? theunit.MyAuraExpiring(aura) : 0;
                    }
                    else if (action == "MyStackCount")
                    {
                        value = (theunit != null) ? theunit.MyStackCount(aura) : 0;
                    }
                    else if (action == "OnCooldown")
                    {
                        value = FTWCoreStatus.OnCooldown(aura) ? 1 : 0;
                    }
                    else if (action == "PartyWithAura")
                    {
                        value = FTWCoreUnits.GetPartyWithAura(aura);
                    }
                    else if (action == "PartyWithHealth")
                    {
                        value = FTWCoreUnits.GetPartyWithHealth(aura);
                    }
                    else if (action == "StackCount")
                    {
                        value = (theunit != null) ? theunit.StackCount(aura) : 0;
                    }
                    else if (action == "NumItems")
                    {
                        value = (theunit != null) ? FTWCoreItems.NumItems(aura) : 0;
                    }
                    else
                    {
                        throw new Exception(string.Format("Unknown action {0}!", action));
                    }
                    d.Add(match.Value, 0);
                    s = s.Replace(match.Value, value.ToString());
                }
                match = match.NextMatch();
            }

            // Replace simple properties
            for (int i = 0; i < FTWProps.PropertyNames.Count(); i++)
            {
                string propname = FTWProps.PropertyNames[i].Trim();
                if (propname.Length > 0)
                {
                    string search = prefix + "." + propname;
                    if (s.Contains(search))
                    {
                        s = s.Replace(search, GetProperty(theunit, propname).ToString());
                    }
                }
            }

            // Stop the timer
            MyTimer.Stop(fnname);

            return(s);
        }
コード例 #8
0
ファイル: FTWCore.cs プロジェクト: psmyth1/code-samples
        private double GetPropValue(WoWUnit theunit, string name)
        {
            double value = 0;

            switch (name)
            {
            case "IsHostile": value = theunit != null && theunit.IsHostile ? 1 : 0; break;

            case "AvgHealth": value = FTWProps.avgHealth; break;

            case "AddsCount": value = FTWProps.adds.Count; break;

            case "StunCount": value = theunit != null?FTWCoreStatus.StunCount(theunit.Location) : 0; break;

            case "Aggro": value = theunit != null ? (int)theunit.ThreatInfo.ThreatStatus : 5; break;

            case "MovementDisabled": value = theunit != null && FTWUtils.MovementDisabled() ? 1 : 0; break;

            case "ClusterSize": value = theunit != null?theunit.ClusterSize() : 0; break;

            case "CapsLock": value = FTWUtils.CapsLockDown() ? 1 : 0; break;

            case "BearForm": value = theunit != null && theunit.HasAura("Bear Form") ? 1 : 0; break;

            case "CatForm": value = theunit != null && theunit.HasAura("Cat Form") ? 1 : 0; break;

            case "MoonkinForm": value = theunit != null && theunit.HasAura("Moonkin Form") ? 1 : 0; break;

            case "NormalForm": value = theunit != null && (theunit.HasAura("Cat Form") == false && theunit.HasAura("Bear Form") == false && theunit.HasAura("Moonkin Form") == false) ? 1 : 0; break;

            case "FlightForm": value = theunit != null && (theunit.HasAura("Flight Form") || theunit.HasAura("Swift Flight Form")) ? 1 : 0; break;

            case "FeralForm": value = theunit != null && (theunit.HasAura("Bear Form") || theunit.HasAura("Cat Form")) ? 1 : 0; break;

            case "ComboPoints": value = StyxWoW.Me.ComboPoints; break;

            case "AllComboPoints": value = StyxWoW.Me.RawComboPoints; break;

            case "Rage": value = StyxWoW.Me.RageInfo.CurrentI; break;

            case "Focus": value = StyxWoW.Me.FocusInfo.CurrentI; break;

            case "Energy": value = StyxWoW.Me.EnergyInfo.CurrentI; break;

            case "ShadowOrbs": value = StyxWoW.Me.GetPowerInfo(WoWPowerType.ShadowOrbs).CurrentI; break;

            case "SoulShards": value = StyxWoW.Me.SoulShardsInfo.CurrentI; break;

            case "Balance": value = StyxWoW.Me.UnitPower(8); break;

            case "HolyPower": value = StyxWoW.Me.GetPowerInfo(WoWPowerType.HolyPower).CurrentI; break;

            case "Chi": value = StyxWoW.Me.UnitPower(12); break;

            case "BurningEmbers": value = StyxWoW.Me.GetPowerInfo(WoWPowerType.BurningEmbers).CurrentI; break;

            case "DemonicFury": value = StyxWoW.Me.GetPowerInfo(WoWPowerType.DemonicFury).CurrentI; break;

            case "EclipseDirection": value = FTWProps._eclipsedirection; break;

            case "Distance": value = theunit != null ? theunit.Distance2D : 0; break;

            case "MeleeRange": value = 4.95; break;

            case "IsTank": value = StyxWoW.Me.IsTank() ? 1 : 0; break;

            case "IsHealer": value = StyxWoW.Me.IsHealer() ? 1 : 0; break;

            case "IsDPS": value = StyxWoW.Me.IsDPS() ? 1 : 0; break;

            case "IsDemon": value = theunit != null && theunit.CreatureType == WoWCreatureType.Demon ? 1 : 0; break;

            case "IsElemental": value = theunit != null && theunit.CreatureType == WoWCreatureType.Elemental ? 1 : 0; break;

            case "IsBeast": value = theunit != null && theunit.CreatureType == WoWCreatureType.Beast ? 1 : 0; break;

            case "IsCritter": value = theunit != null && theunit.CreatureType == WoWCreatureType.Critter ? 1 : 0; break;

            case "IsDragon": value = theunit != null && theunit.CreatureType == WoWCreatureType.Dragon ? 1 : 0; break;

            case "IsGasCloud": value = theunit != null && theunit.CreatureType == WoWCreatureType.GasCloud ? 1 : 0; break;

            case "IsGiant": value = theunit != null && theunit.CreatureType == WoWCreatureType.Giant ? 1 : 0; break;

            case "IsHumanoid": value = theunit != null && theunit.CreatureType == WoWCreatureType.Humanoid ? 1 : 0; break;

            case "IsMechanical": value = theunit != null && theunit.CreatureType == WoWCreatureType.Mechanical ? 1 : 0; break;

            case "IsNonCombatPet": value = theunit != null && theunit.CreatureType == WoWCreatureType.NonCombatPet ? 1 : 0; break;

            case "IsTotem": value = theunit != null && theunit.CreatureType == WoWCreatureType.Totem ? 1 : 0; break;

            case "IsUndead": value = theunit != null && theunit.CreatureType == WoWCreatureType.Undead ? 1 : 0; break;

            case "Health": value = theunit != null ? (int)theunit.HealthPercent : 100; break;

            case "Mana": value = theunit != null && (theunit.PowerType == WoWPowerType.Mana || theunit.Class == WoWClass.Druid) ? theunit.ManaPercent : 100; break;

            case "Mounted": value = theunit != null && (theunit.Mounted) ? 1 : 0; break;

            case "InBattleground": value = Battlegrounds.IsInsideBattleground ? 1 : 0; break;

            case "InParty": value = StyxWoW.Me.GroupInfo.IsInParty || StyxWoW.Me.GroupInfo.IsInRaid ? 1 : 0; break;

            case "InRaid": value = StyxWoW.Me.GroupInfo.IsInRaid ? 1 : 0; break;

            case "IsDiseased": value = theunit != null && theunit.IsDiseased() ? 1 : 0; break;

            case "Dead": value = theunit != null && theunit.IsDead ? 1 : 0; break;

            case "IsCasting": value = theunit != null && (theunit.IsCasting || theunit.IsChanneling) ? 1 : 0; break;

            case "IsMoving": value = theunit != null && theunit.IsMoving ? 1 : 0; break;

            case "IsFlying": value = theunit != null && theunit.IsFlying ? 1 : 0; break;

            case "LineOfSight": value = theunit != null && theunit.InLineOfSight ? 1 : 0; break;

            case "Interruptable": value = theunit != null && theunit.CanInterruptCurrentSpellCast ? 1 : 0; break;

            case "IsElite": value = theunit != null && (theunit.Elite || theunit.Name.Contains("Training Dummy")) ? 1 : 0; break;

            case "IsBehind": value = theunit != null && theunit.CurrentTarget != null && theunit.CurrentTarget.MeIsSafelyBehind ? 1 : 0; break;

            case "IsFacingTarget": value = theunit != null && theunit.CurrentTarget != null && theunit.IsSafelyFacing(theunit.CurrentTarget) ? 1 : 0; break;

            case "IsFleeing": value = theunit != null && theunit.Fleeing ? 1 : 0; break;

            case "IsIncapacitated": value = theunit != null && (theunit.IsDead || theunit.IsCrowdControlled()) ? 1 : 0; break;

            case "IsRooted": value = theunit != null && theunit.HasAuraWithMechanic(WoWSpellMechanic.Rooted, WoWSpellMechanic.Shackled) ? 1 : 0; break;

            case "IsLooting": value = BotPoi.Current.Type == PoiType.Loot ? 1 : 0; break;

            case "PetIsMissing": value = StyxWoW.Me.PetIsMissing(); break;

            case "TotemCount": value = theunit != null?FTWCoreStatus.TotemCount() : 0; break;

            case "RuneCount": value = StyxWoW.Me.DeathRuneCount +
                                      StyxWoW.Me.FrostRuneCount +
                                      StyxWoW.Me.BloodRuneCount +
                                      StyxWoW.Me.UnholyRuneCount; break;

            case "DeathRune": value = StyxWoW.Me.DeathRuneCount; break;

            case "FrostRune": value = StyxWoW.Me.FrostRuneCount; break;

            case "BloodRune": value = StyxWoW.Me.BloodRuneCount; break;

            case "UnholyRune": value = StyxWoW.Me.UnholyRuneCount; break;

            case "RunicPower": value = StyxWoW.Me.RunicPowerPercent; break;

            case "LevelDiff": value = theunit != null ? theunit.Level - StyxWoW.Me.Level : 0; break;

            case "Level": value = theunit != null ? theunit.Level : 0; break;

            default: throw new Exception(string.Format("Unknown property {0}!", name));
            }
            return(value);
        }
コード例 #9
0
ファイル: FTWCore.cs プロジェクト: psmyth1/code-samples
 public void Initialize()
 {
     Pulse();
     FTWCoreStatus.On_DumpParty();
     EvaluateRules("@INITIALIZE");
 }
コード例 #10
0
ファイル: FTWCoreItems.cs プロジェクト: psmyth1/code-samples
        public static bool On_Use(string itemname, WoWUnit target)
        {
            string fnname = "FTWCore.On_Use";

            MyTimer.Start(fnname);
            bool retval = false;

            using (StyxWoW.Memory.AcquireFrame())
            {
                if (itemname.ToLower() == "trinket1" && StyxWoW.Me.Inventory.Equipped.Trinket1 != null)
                {
                    WoWItem trinket = StyxWoW.Me.Inventory.Equipped.Trinket1;
                    if (trinket.Cooldown == 0 && trinket.Usable == true && trinket.TriggersSpell == true)
                    {
                        FTWLogger.log("Using trinket {0}", StyxWoW.Me.Inventory.Equipped.Trinket1.Name);
                        StyxWoW.Me.Inventory.Equipped.Trinket1.Use();
                    }
                }
                else if (itemname.ToLower() == "trinket2" && StyxWoW.Me.Inventory.Equipped.Trinket2 != null)
                {
                    WoWItem trinket = StyxWoW.Me.Inventory.Equipped.Trinket2;
                    if (trinket.Cooldown == 0 && trinket.Usable == true && trinket.TriggersSpell == true)
                    {
                        FTWLogger.log("Using trinket {0}", StyxWoW.Me.Inventory.Equipped.Trinket2.Name);
                        StyxWoW.Me.Inventory.Equipped.Trinket2.Use();
                    }
                }
                else
                {
                    WoWItem item = GetInventoryItem(itemname);
                    if (item == null)
                    {
                        FTWLogger.debug("Couldn't find item {0}", itemname);
                    }
                    else if (item.Usable == false)
                    {
                        FTWLogger.debug("Item {0} is not usable", item.Name);
                    }
                    else if (item.Cooldown > 0)
                    {
                        FTWLogger.debug("Item {0} is on cooldown. Time remaining: {1}", item.Name, item.CooldownTimeLeft.TotalSeconds);
                    }
                    else if (FTWCoreStatus.OnCooldown(item.Name))
                    {
                        FTWLogger.debug("Item {0} is on cooldown.", item.Name);
                    }
                    else
                    {
                        if (target != null && target.Guid != StyxWoW.Me.Guid)
                        {
                            target.Target();
                            Thread.Sleep(100);
                        }
                        FTWLogger.log("Using item '{0}'", item.Name);
                        item.Use();
                        retval = false;
                    }
                }
            }
            MyTimer.Stop(fnname);
            return(retval);
        }