public override void Start() { try { Specialisation = WoWSpec.None; NamedComposite.Sequence = ""; TreeRoot.TicksPerSecond = 8; ProfileManager.LoadEmpty(); //_oldRoutine = RoutineManager.Current; //Save it so we can restore it later RoutineManager.Current = new ProxyRoutine(); Lua.Events.RemoveFilter("COMBATLOG_EVENT_UNFILTERED"); Lua.Events.AttachEvent("UNIT_SPELLCAST_SUCCEEDED", UNIT_SPELLCAST_SUCCEEDED); Lua.Events.AttachEvent("COMBATLOG_EVENT_UNFILTERED", COMBATLOG_EVENT_UNFILTERED); Lua.Events.AttachEvent("CHARACTER_POINTS_CHANGED", ContextChange); Lua.Events.AttachEvent("PLAYER_LOGOUT", ContextChange); Lua.Events.AttachEvent("PLAYER_TALENT_UPDATE", ContextChange); Lua.Events.AttachEvent("UNIT_AURA", PlayerAuras.UNIT_AURA); Lua.Events.AttachEvent("UNIT_AURA", PetAuras.UNIT_AURA); ContextChange(null, null); RegisterHotkeys(); } catch (Exception e) { SimcraftImpl.Write(e.ToString()); } }
public void RebuildBehaviors() { Composite simcRoot = null; NameCount = 'A'; simcRoot = new PrioritySelector( new Action(context => { iterationCounter++; return(RunStatus.Failure); }), new Decorator(ret => IsPaused, new Action(ret => RunStatus.Success)), CallActionList(ActionProxy.ActionImpl.oocapl, ret => !StyxWoW.Me.Combat), new Decorator(ret => StyxWoW.Me.Combat, new LockSelector( new Decorator( ret => StyxWoW.Me.CurrentTarget != null && StyxWoW.Me.Combat, new PrioritySelector(CombatIteration(), actions.Selector, IterationEnd()))))); TreeHooks.Instance.ReplaceHook(SimcraftHookName, simcRoot); if (Me.Specialization != Specialisation) { SelectorWindow.ShowDialog(); } Specialisation = Me.Specialization; }
public BehaviorAttribute(BehaviorType type, WoWClass @class = WoWClass.None, WoWSpec spec =(WoWSpec) int.MaxValue, WoWContext context = WoWContext.All, int priority = 0) { Type = type; SpecificClass = @class; SpecificSpec = spec; SpecificContext = context; PriorityLevel = priority; }
public BehaviorAttribute(BehaviorType type, WoWClass @class = WoWClass.None, WoWSpec spec = (WoWSpec)int.MaxValue, WoWContext context = WoWContext.All, int priority = 0) { Type = type; SpecificClass = @class; SpecificSpec = spec; SpecificContext = context; PriorityLevel = priority; }
public static Composite GetComposite(WoWClass wowClass, WoWSpec spec, BehaviorType behavior, WoWContext context, out int behaviourCount) { behaviourCount = 0; if (_methods.Count <= 0) { Logger.Write("Building method list"); foreach (var type in Assembly.GetExecutingAssembly().GetTypes()) { // All behavior methods should not be generic, and should have zero parameters, with their return types being of type Composite. _methods.AddRange( type.GetMethods(BindingFlags.Static | BindingFlags.Public).Where( mi => !mi.IsGenericMethod && mi.GetParameters().Length == 0).Where( mi => mi.ReturnType.IsAssignableFrom(typeof (Composite)))); } Logger.Write("Added " + _methods.Count + " methods"); } var matchedMethods = new Dictionary<BehaviorAttribute, Composite>(); foreach (MethodInfo mi in _methods) { // If the behavior is set as ignore. Don't use it? Duh? if (mi.GetCustomAttributes(typeof(IgnoreBehaviorCountAttribute), false).Any()) continue; // If there's no behavior attrib, then move along. foreach (var a in mi.GetCustomAttributes(typeof(BehaviorAttribute), false)) { var attribute = a as BehaviorAttribute; if (attribute == null) continue; // Check if our behavior matches with what we want. If not, don't add it! if (IsMatchingMethod(attribute, wowClass, spec, behavior, context)) { Logger.Write(string.Format("Matched {0} to behavior {1} for {2} {3} with priority {4}", mi.Name, behavior, wowClass.ToString().CamelToSpaced(), spec.ToString().CamelToSpaced(), attribute.PriorityLevel)); // if it blows up here, you defined a method with the exact same attribute and priority as one already found matchedMethods.Add(attribute, mi.Invoke(null, null) as Composite); } } } // If we found no methods, rofls! if (matchedMethods.Count <= 0) { return null; } var result = new PrioritySelector(); foreach (var kvp in matchedMethods.OrderByDescending(mm => mm.Key.PriorityLevel)) { result.AddChild(kvp.Value); behaviourCount++; } return result; }
public static WoWItem FindBestHealingPotion(WoWSpec spec) { return(Me.BagItems ?.Where(hp => hp.ItemInfo.ItemClass == WoWItemClass.Consumable && hp.ItemInfo.ConsumableClass == WoWItemConsumableClass.Potion && (hp.ItemInfo.RequiredSkillId == 0 || Me.GetSkill(hp.ItemInfo.RequiredSkillId).CurrentValue >= hp.ItemInfo.RequiredSkillLevel) && hp.ItemInfo.RequiredLevel <= Me.Level && CanUseItem(hp) && (spec == WoWSpec.DemonHunterHavoc && hp.ItemInfo.Id == HavocSettings.Instance.HavocHealthPotionID)) ?.OrderBy(l => l.ItemInfo.Level) ?.ThenByDescending(hp => hp.ItemInfo.RequiredSkillLevel) .FirstOrDefault()); }
private static void UpdateTalentManager(object sender, LuaEventArgs args) { WoWSpec oldSpec = CurrentSpec; Update(); if (CurrentSpec != oldSpec) { CLULogger.TroubleshootLog("Your spec has been changed. Rebuilding rotation"); //SpellManager.Update(); CLU.Instance.CreateBehaviors(); } }
private IRotation GetRotation(WoWSpec spec) { switch (spec) { case WoWSpec.DeathKnightBlood: return(new Blood()); case WoWSpec.DeathKnightUnholy: return(new Unholy()); case WoWSpec.RogueOutlaw: return(new Outlaw()); default: return(new Blood()); } }
private IRotation GetRotation(WoWSpec spec) { switch (spec) { case WoWSpec.PaladinProtection: return(new Protection()); case WoWSpec.PaladinHoly: return(new Holy()); case WoWSpec.PaladinRetribution: return(new Retribution()); default: return(new None()); } }
// 25Nov2013 HighVoltz public static bool IsRangeSpec(WoWSpec spec) { switch (spec) { case WoWSpec.HunterBeastMastery: case WoWSpec.HunterMarksmanship: case WoWSpec.HunterSurvival: case WoWSpec.MageArcane: case WoWSpec.MageFire: case WoWSpec.MageFrost: case WoWSpec.PriestDiscipline: case WoWSpec.PriestHoly: case WoWSpec.PriestShadow: case WoWSpec.WarlockAffliction: case WoWSpec.WarlockDemonology: case WoWSpec.WarlockDestruction: case WoWSpec.ShamanElemental: case WoWSpec.ShamanRestoration: case WoWSpec.PaladinHoly: case WoWSpec.DruidBalance: case WoWSpec.DruidRestoration: case WoWSpec.MonkMistweaver: return(true); default: return(false); } }
// 25Nov2013 HighVoltz public static bool IsMeleeSpec(WoWSpec spec) { return(!IsRangeSpec(spec)); }
public bool Match(WoWClass cl, WoWSpec sp, WoWContext cont) { return (cl == _class && cont == _context); }
static Rogue() { pickCount = 3; if (Helpers.Rogue.me == null && StyxWoW.Me != null) { Helpers.Rogue.me = StyxWoW.Me; } if (Helpers.Rogue.me != null) { mCurrentSpec = Helpers.Rogue.me.Specialization; Lua.Events.AttachEvent("CHARACTER_POINTS_CHANGED", delegate { Logging.Write(LogLevel.Normal, "Your spec has been updated. Rebuilding behaviors..."); Helpers.Rogue.CreateWaitForLagDuration(); Helpers.Rogue.CreateWaitForLagDuration(); Helpers.Rogue.CreateWaitForLagDuration(); Helpers.Rogue.CreateWaitForLagDuration(); mCurrentSpec = Helpers.Rogue.me.Specialization; if (Helpers.Spells.FindSpell(108211)) { for (int i = 1; i < 6; i++) { Settings.Mode.mPoisonsMain[i] = Helpers.Enum.LeathalPoisonSpellId.Deadly; Settings.Mode.mPoisonsOff[i] = Helpers.Enum.NonLeathalPoisonSpellId.Leeching; } } else if (Helpers.Spells.FindSpell(108215)) { for (int i = 1; i < 6; i++) { Settings.Mode.mPoisonsMain[i] = Helpers.Enum.LeathalPoisonSpellId.Deadly; Settings.Mode.mPoisonsOff[i] = Helpers.Enum.NonLeathalPoisonSpellId.Paralytic; } } else { for (int i = 1; i < 6; i++) { Settings.Mode.mPoisonsMain[i] = Helpers.Enum.LeathalPoisonSpellId.Deadly; Settings.Mode.mPoisonsOff[i] = Helpers.Enum.NonLeathalPoisonSpellId.MindNumbing; } } } ); Lua.Events.AttachEvent("ACTIVE_TALENT_GROUP_CHANGED", delegate { Logging.Write(LogLevel.Normal, "Your spec has changed. Rebuilding behaviors..."); Helpers.Rogue.CreateWaitForLagDuration(); Helpers.Rogue.CreateWaitForLagDuration(); Helpers.Rogue.CreateWaitForLagDuration(); Helpers.Rogue.CreateWaitForLagDuration(); mCurrentSpec = Helpers.Rogue.me.Specialization; if (Helpers.Spells.FindSpell(108211)) { for (int i = 1; i < 6; i++) { Settings.Mode.mPoisonsMain[i] = Helpers.Enum.LeathalPoisonSpellId.Deadly; Settings.Mode.mPoisonsOff[i] = Helpers.Enum.NonLeathalPoisonSpellId.Leeching; } } else if (Helpers.Spells.FindSpell(108215)) { for (int i = 1; i < 6; i++) { Settings.Mode.mPoisonsMain[i] = Helpers.Enum.LeathalPoisonSpellId.Deadly; Settings.Mode.mPoisonsOff[i] = Helpers.Enum.NonLeathalPoisonSpellId.Paralytic; } } else { for (int i = 1; i < 6; i++) { Settings.Mode.mPoisonsMain[i] = Helpers.Enum.LeathalPoisonSpellId.Deadly; Settings.Mode.mPoisonsOff[i] = Helpers.Enum.NonLeathalPoisonSpellId.MindNumbing; } } if (Helpers.Rogue.me.Inventory.Equipped.MainHand != null && !Helpers.Rogue.me.Inventory.Equipped.MainHand.ItemInfo.WeaponClass.Equals(WoWItemWeaponClass.Dagger) && !Helpers.Rogue.me.Specialization.Equals(Styx.WoWSpec.RogueCombat)) { Logging.Write(LogLevel.Normal, "No dagger in MainHand!!! Only Combat supports none dagger weapons!"); } } ); } }
// ctor for list item public HealContextItem(HealingContext context, WoWSpec spec, HealerSettings stgs) { Context = context; Spec = spec; Settings = stgs; }
public void RebuildBehaviors() { Composite simcRoot = null; NameCount = 'A'; simcRoot = new PrioritySelector( new Action(context => { iterationCounter++; return RunStatus.Failure; }), new Decorator(ret => IsPaused, new Action(ret => RunStatus.Success)), CallActionList(ActionProxy.ActionImpl.oocapl, ret => !StyxWoW.Me.Combat), new Decorator(ret => StyxWoW.Me.Combat, new LockSelector( new Decorator( ret => StyxWoW.Me.CurrentTarget != null && StyxWoW.Me.Combat, new PrioritySelector(CombatIteration(), actions.Selector, IterationEnd()))))); TreeHooks.Instance.ReplaceHook(SimcraftHookName, simcRoot); //if (Me.Specialization != Specialisation) //{ // SelectorWindow.ShowDialog(); //} Specialisation = Me.Specialization; }
public static void InvokeInitializers(WoWClass wowClass, WoWSpec spec, WoWContext context, bool silent = false) { BehaviorType behavior = BehaviorType.Initialize; if (context == WoWContext.None) { return; } SilentBehaviorCreation = silent; // only load methods once if (_methods.Count <= 0) { // Logger.WriteDebug("Singular Behaviors: building method list"); foreach (var type in Assembly.GetExecutingAssembly().GetTypes()) { // All behavior methods should not be generic, and should have zero parameters, with their return types being of type Composite. _methods.AddRange( type.GetMethods(BindingFlags.Static | BindingFlags.Public).Where( mi => !mi.IsGenericMethod && mi.GetParameters().Length == 0).Where( mi => mi.ReturnType.IsAssignableFrom(typeof(Composite)))); } Logger.WriteFile("Singular Behaviors: Added " + _methods.Count + " behaviors"); } // find all initialization methods for this class/spec/context var matchedMethods = new Dictionary<BehaviorAttribute, MethodInfo>(); foreach (MethodInfo mi in _methods) { // If the behavior is set as ignore. Don't use it? Duh? if (mi.GetCustomAttributes(typeof(IgnoreBehaviorCountAttribute), false).Any()) continue; // If there's no behavior attrib, then move along. foreach (var a in mi.GetCustomAttributes(typeof(BehaviorAttribute), false)) { var attribute = a as BehaviorAttribute; if (attribute == null) continue; // Check if our Initialization behavior matches. If not, don't add it! if (IsMatchingMethod(attribute, wowClass, spec, behavior, context)) { if (matchedMethods.ContainsKey(attribute)) { Logger.Write(LogColor.Hilite, "PROGRAM ERROR: duplicate behaviors. Notify Singular Devs!!!"); Logger.WriteDiagnostic("PROGRAM ERROR: duplicate behaviors. Notify Singular Devs!!!"); Logger.WriteDiagnostic("Error for Attribute: class={0} spec={1} type={2} context={3} priority={4} ", attribute.SpecificClass, attribute.SpecificSpec, attribute.Type, attribute.SpecificContext, attribute.PriorityLevel ); Logger.WriteDiagnostic(" exists {0}:{1}", matchedMethods[attribute].DeclaringType, matchedMethods[attribute].Name ); Logger.WriteDiagnostic(" adding {0}:{1}", mi.DeclaringType, mi.Name ); } matchedMethods.Add( attribute, mi); } } } // invoke each initialization behavior in priority order foreach (var kvp in matchedMethods.OrderByDescending(mm => mm.Key.PriorityLevel)) { CurrentBehaviorType = behavior; CurrentBehaviorPriority = kvp.Key.PriorityLevel; CurrentBehaviorName = kvp.Value.Name; string invokeInfo = string.Format("{0} {1} {2}", kvp.Key.PriorityLevel.ToString().AlignRight(5), behavior.ToString().AlignLeft(15), kvp.Value.Name); if (!silent) Logger.WriteFile(invokeInfo); kvp.Value.Invoke(null, null); CurrentBehaviorType = 0; CurrentBehaviorPriority = 0; CurrentBehaviorName = string.Empty; } return; }
public static Composite GetComposite(WoWClass wowClass, WoWSpec spec, BehaviorType behavior, WoWContext context, out int behaviourCount, bool silent = false) { if (context == WoWContext.None) { // None is an invalid context, but rather than stopping bot wait it out with donothing logic Logger.Write( LogColor.Hilite, "No Active Context -{0}{1} for{2} set to DoNothingBehavior temporarily", wowClass.ToString().CamelToSpaced(), behavior.ToString().CamelToSpaced(), spec.ToString().CamelToSpaced()); behaviourCount = 1; return NoContextAvailable.CreateDoNothingBehavior(); } SilentBehaviorCreation = silent; behaviourCount = 0; var matchedMethods = new Dictionary<BehaviorAttribute, Composite>(); foreach (MethodInfo mi in _methods) { // If the behavior is set as ignore. Don't use it? Duh? if (mi.GetCustomAttributes(typeof(IgnoreBehaviorCountAttribute), false).Any()) continue; // If there's no behavior attrib, then move along. foreach (var a in mi.GetCustomAttributes(typeof(BehaviorAttribute), false)) { var attribute = a as BehaviorAttribute; if (attribute == null) continue; // Check if our behavior matches with what we want. If not, don't add it! if (IsMatchingMethod(attribute, wowClass, spec, behavior, context)) { if (!silent) Logger.WriteFile("{0} {1} {2}", attribute.PriorityLevel.ToString().AlignRight(4), behavior.ToString().AlignLeft(15), mi.Name); CurrentBehaviorType = behavior; CurrentBehaviorPriority = attribute.PriorityLevel; CurrentBehaviorName = mi.Name; // if it blows up here, you defined a method with the exact same attribute and priority as one already found // wrap in trace class Composite comp = mi.Invoke(null, null) as Composite; string name = behavior.ToString() + "." + mi.Name + "." + attribute.PriorityLevel.ToString(); if (SingularSettings.Trace) comp = new CallTrace( name, comp); if (matchedMethods.ContainsKey(attribute)) { Logger.Write(LogColor.Hilite, "Internal Error: method '{0}' has attribute that already exists", name); Logger.WriteDiagnostic(" "); Logger.WriteDiagnostic("Dump Methods"); Logger.WriteDiagnostic("==========================="); foreach (var v in matchedMethods) { Logger.WriteDiagnostic("{0} {1} {2} {3}", v.Key.SpecificClass, v.Key.SpecificSpec, v.Key.SpecificContext, v.Key.PriorityLevel); } Logger.WriteDiagnostic("==========================="); Logger.WriteDiagnostic("{0} {1} {2} {3} == add attempt for {4}", attribute.SpecificClass, attribute.SpecificSpec, attribute.SpecificContext, attribute.PriorityLevel, name); Logger.WriteDiagnostic(" "); } matchedMethods.Add(attribute, comp); CurrentBehaviorType = 0; CurrentBehaviorPriority = 0; CurrentBehaviorName = string.Empty; } } } // If we found no methods, rofls! if (matchedMethods.Count <= 0) { return null; } var result = new PrioritySelector(); foreach (var kvp in matchedMethods.OrderByDescending(mm => mm.Key.PriorityLevel)) { result.AddChild(kvp.Value); behaviourCount++; } return result; }
public static Composite GetComposite(WoWClass wowClass, WoWSpec spec, BehaviorType behavior, WoWContext context, out int behaviourCount) { behaviourCount = 0; if (_methods.Count <= 0) { Logger.Write("Building method list"); foreach (var type in Assembly.GetExecutingAssembly().GetTypes()) { // All behavior methods should not be generic, and should have zero parameters, with their return types being of type Composite. _methods.AddRange( type.GetMethods(BindingFlags.Static | BindingFlags.Public).Where( mi => !mi.IsGenericMethod && mi.GetParameters().Length == 0).Where( mi => mi.ReturnType.IsAssignableFrom(typeof(Composite)))); } Logger.WriteDebug("Added " + _methods.Count + " methods"); } var matchedMethods = new Dictionary <BehaviorAttribute, Composite>(); foreach (MethodInfo mi in _methods) { // If the behavior is set as ignore. Don't use it? Duh? if (mi.GetCustomAttributes(typeof(IgnoreBehaviorCountAttribute), false).Any()) { continue; } // If there's no behavior attrib, then move along. foreach (var a in mi.GetCustomAttributes(typeof(BehaviorAttribute), false)) { var attribute = a as BehaviorAttribute; if (attribute == null) { continue; } // Check if our behavior matches with what we want. If not, don't add it! if (IsMatchingMethod(attribute, wowClass, spec, behavior, context)) { Logger.WriteDebug(string.Format("Matched {0} to behavior {1} for {2} {3} with priority {4}", mi.Name, behavior, wowClass.ToString().CamelToSpaced(), spec.ToString().CamelToSpaced(), attribute.PriorityLevel)); // if it blows up here, you defined a method with the exact same attribute and priority as one already found matchedMethods.Add(attribute, mi.Invoke(null, null) as Composite); } } } // If we found no methods, rofls! if (matchedMethods.Count <= 0) { return(null); } var result = new PrioritySelector(); foreach (var kvp in matchedMethods.OrderByDescending(mm => mm.Key.PriorityLevel)) { result.AddChild(kvp.Value); behaviourCount++; } return(result); }
public static void InvokeInitializers(WoWClass wowClass, WoWSpec spec, WoWContext context, bool silent = false) { BehaviorType behavior = BehaviorType.Initialize; if (context == WoWContext.None) { return; } SilentBehaviorCreation = silent; // only load methods once if (_methods.Count <= 0) { // Logger.WriteDebug("Singular Behaviors: building method list"); foreach (var type in Assembly.GetExecutingAssembly().GetTypes()) { // All behavior methods should not be generic, and should have zero parameters, with their return types being of type Composite. _methods.AddRange( type.GetMethods(BindingFlags.Static | BindingFlags.Public).Where( mi => !mi.IsGenericMethod && mi.GetCustomAttributes(typeof(BehaviorAttribute)).Any()).Where( mi => typeof(Composite).IsAssignableFrom(mi.ReturnType) || mi.ReturnType == typeof(Task <bool>))); } Logger.WriteFile("Singular Behaviors: Added " + _methods.Count + " behaviors"); } // find all initialization methods for this class/spec/context var matchedMethods = new Dictionary <BehaviorAttribute, MethodInfo>(); foreach (MethodInfo mi in _methods) { // If the behavior is set as ignore. Don't use it? Duh? if (mi.GetCustomAttributes(typeof(IgnoreBehaviorCountAttribute), false).Any()) { continue; } // If there's no behavior attrib, then move along. foreach (var a in mi.GetCustomAttributes(typeof(BehaviorAttribute), false)) { var attribute = a as BehaviorAttribute; if (attribute == null) { continue; } // Check if our Initialization behavior matches. If not, don't add it! if (IsMatchingMethod(attribute, wowClass, spec, behavior, context)) { if (matchedMethods.ContainsKey(attribute)) { Logger.Write(LogColor.Hilite, "PROGRAM ERROR: duplicate behaviors. Notify Singular Devs!!!"); Logger.WriteDiagnostic("PROGRAM ERROR: duplicate behaviors. Notify Singular Devs!!!"); Logger.WriteDiagnostic("Error for Attribute: class={0} spec={1} type={2} context={3} priority={4} ", attribute.SpecificClass, attribute.SpecificSpec, attribute.Type, attribute.SpecificContext, attribute.PriorityLevel ); Logger.WriteDiagnostic(" exists {0}:{1}", matchedMethods[attribute].DeclaringType, matchedMethods[attribute].Name ); Logger.WriteDiagnostic(" adding {0}:{1}", mi.DeclaringType, mi.Name ); } matchedMethods.Add(attribute, mi); } } } // invoke each initialization behavior in priority order foreach (var kvp in matchedMethods.OrderByDescending(mm => mm.Key.PriorityLevel)) { CurrentBehaviorType = behavior; CurrentBehaviorPriority = kvp.Key.PriorityLevel; CurrentBehaviorName = kvp.Value.Name; string invokeInfo = string.Format("{0} {1} {2}", kvp.Key.PriorityLevel.ToString().AlignRight(5), behavior.ToString().AlignLeft(15), kvp.Value.Name); if (!silent) { Logger.WriteFile(invokeInfo); } kvp.Value.Invoke(null, null); CurrentBehaviorType = 0; CurrentBehaviorPriority = 0; CurrentBehaviorName = string.Empty; } return; }
private static bool IsMatchingMethod(BehaviorAttribute attribute, WoWClass wowClass, WoWSpec spec, BehaviorType behavior, WoWContext context) { if (attribute.SpecificClass != wowClass && attribute.SpecificClass != WoWClass.None) { return(false); } if ((attribute.Type & behavior) == 0) { return(false); } if ((attribute.SpecificContext & context) == 0) { return(false); } if (attribute.SpecificSpec != (WoWSpec)int.MaxValue && attribute.SpecificSpec != spec) { return(false); } /* Logger.WriteDebug("IsMatchingMethod({0}, {1}, {2}, {3}) - {4}, {5}, {6}, {7}, {8}", wowClass, spec, behavior, * context, attribute.SpecificClass, attribute.SpecificSpec, attribute.Type, attribute.SpecificContext, * attribute.PriorityLevel); */ return(true); }
public static Composite GetComposite(WoWClass wowClass, WoWSpec spec, BehaviorType behavior, WoWContext context, out int behaviourCount, bool silent = false) { if (context == WoWContext.None) { // None is an invalid context, but rather than stopping bot wait it out with donothing logic Logger.Write(LogColor.Hilite, "No Active Context -{0}{1} for{2} set to DoNothingBehavior temporarily", wowClass.ToString().CamelToSpaced(), behavior.ToString().CamelToSpaced(), spec.ToString().CamelToSpaced()); behaviourCount = 1; return(NoContextAvailable.CreateDoNothingBehavior()); } SilentBehaviorCreation = silent; behaviourCount = 0; var matchedMethods = new Dictionary <BehaviorAttribute, Composite>(); foreach (MethodInfo mi in _methods) { // If the behavior is set as ignore. Don't use it? Duh? if (mi.GetCustomAttributes(typeof(IgnoreBehaviorCountAttribute), false).Any()) { continue; } // If there's no behavior attrib, then move along. foreach (var a in mi.GetCustomAttributes(typeof(BehaviorAttribute), false)) { var attribute = a as BehaviorAttribute; if (attribute == null) { continue; } // Check if our behavior matches with what we want. If not, don't add it! if (IsMatchingMethod(attribute, wowClass, spec, behavior, context)) { if (!silent) { Logger.WriteFile("{0} {1} {2}", attribute.PriorityLevel.ToString().AlignRight(4), behavior.ToString().AlignLeft(15), mi.Name); } CurrentBehaviorType = behavior; CurrentBehaviorPriority = attribute.PriorityLevel; CurrentBehaviorName = mi.Name; // if it blows up here, you defined a method with the exact same attribute and priority as one already found Composite comp; if (typeof(Composite).IsAssignableFrom(mi.ReturnType)) { comp = mi.Invoke(null, null) as Composite; } else { Beta.Assert(mi.ReturnType == typeof(Task <bool>)); comp = new ActionRunCoroutine(o => mi.Invoke(null, null) as Task <bool>); } string name = behavior + "." + mi.Name + "." + attribute.PriorityLevel; if (SingularSettings.Trace) { comp = new CallTrace(name, comp); } if (matchedMethods.ContainsKey(attribute)) { Logger.Write(LogColor.Hilite, "Internal Error: method '{0}' has attribute that already exists", name); Logger.WriteDiagnostic(" "); Logger.WriteDiagnostic("Dump Methods"); Logger.WriteDiagnostic("==========================="); foreach (var v in matchedMethods) { Logger.WriteDiagnostic("{0} {1} {2} {3}", v.Key.SpecificClass, v.Key.SpecificSpec, v.Key.SpecificContext, v.Key.PriorityLevel); } Logger.WriteDiagnostic("==========================="); Logger.WriteDiagnostic("{0} {1} {2} {3} == add attempt for {4}", attribute.SpecificClass, attribute.SpecificSpec, attribute.SpecificContext, attribute.PriorityLevel, name); Logger.WriteDiagnostic(" "); } matchedMethods.Add(attribute, comp); CurrentBehaviorType = 0; CurrentBehaviorPriority = 0; CurrentBehaviorName = string.Empty; } } } // If we found no methods, rofls! if (matchedMethods.Count <= 0) { return(null); } var result = new PrioritySelector(); foreach (var kvp in matchedMethods.OrderByDescending(mm => mm.Key.PriorityLevel)) { result.AddChild(kvp.Value); behaviourCount++; } return(result); }
// ctor for lookup only public HealContextItem(HealingContext context, WoWSpec spec) { Context = context; Spec = spec; }
public MyExpectedSpecializationCondition(WoWSpec expectedSpecialization) { ExpectedSpecialization = expectedSpecialization; }
private static bool IsMatchingMethod(BehaviorAttribute attribute, WoWClass wowClass, WoWSpec spec, BehaviorType behavior, WoWContext context) { if (attribute.SpecificClass != wowClass && attribute.SpecificClass != WoWClass.None) return false; if ((attribute.Type & behavior) == 0) return false; if ((attribute.SpecificContext & context) == 0) return false; if (attribute.SpecificSpec != (WoWSpec)int.MaxValue && attribute.SpecificSpec != spec) return false; Logger.WriteDebug("IsMatchingMethod({0}, {1}, {2}, {3}) - {4}, {5}, {6}, {7}, {8}", wowClass, spec, behavior, context, attribute.SpecificClass, attribute.SpecificSpec, attribute.Type, attribute.SpecificContext, attribute.PriorityLevel); return true; }
public IsInCurrentSpecializationCondition(WoWSpec currentSpec) { this._currentSpec = currentSpec; }
public override void Start() { try { Specialisation = WoWSpec.None; NamedComposite.Sequence = ""; TreeRoot.TicksPerSecond = 8; ProfileManager.LoadEmpty(); //_oldRoutine = RoutineManager.Current; //Save it so we can restore it later RoutineManager.Current = new ProxyRoutine(); Lua.Events.DetachEvent("COMBATLOG_EVENT_UNFILTERED", COMBATLOG_EVENT_UNFILTERED); Lua.Events.AttachEvent("UNIT_SPELLCAST_SUCCEEDED", UNIT_SPELLCAST_SUCCEEDED); Lua.Events.AttachEvent("COMBATLOG_EVENT_UNFILTERED", COMBATLOG_EVENT_UNFILTERED); Lua.Events.AttachEvent("CHARACTER_POINTS_CHANGED", ContextChange); Lua.Events.AttachEvent("PLAYER_LOGOUT", ContextChange); Lua.Events.AttachEvent("PLAYER_TALENT_UPDATE", ContextChange); Lua.Events.AttachEvent("UNIT_AURA", PlayerAuras.UNIT_AURA); Lua.Events.AttachEvent("UNIT_AURA", PetAuras.UNIT_AURA); ContextChange(null, null); RegisterHotkeys(); } catch (Exception e) { SimcraftImpl.Write(e.ToString()); } }
public static void BestPullMoreSettingsForToon( WoWSpec spec, out int mobCount, out int distMelee, out int distRanged, out int minHealth) { mobCount = 0; distMelee = 30; distRanged = 55; minHealth = 60; switch (spec) { case WoWSpec.None: break; case WoWSpec.DeathKnightBlood: mobCount = 3; minHealth = 60; break; case WoWSpec.DeathKnightFrost: mobCount = 2; minHealth = 75; break; case WoWSpec.DeathKnightUnholy: mobCount = 2; minHealth = 75; break; case WoWSpec.DruidBalance: mobCount = 2; minHealth = 60; break; case WoWSpec.DruidFeral: mobCount = 2; minHealth = 75; break; case WoWSpec.DruidGuardian: mobCount = 3; minHealth = 60; break; case WoWSpec.DruidRestoration: mobCount = 0; break; case WoWSpec.HunterBeastMastery: mobCount = 3; minHealth = 60; break; case WoWSpec.HunterMarksmanship: mobCount = 3; minHealth = 60; break; case WoWSpec.HunterSurvival: mobCount = 3; minHealth = 60; break; case WoWSpec.MageArcane: mobCount = 2; minHealth = 70; break; case WoWSpec.MageFire: mobCount = 2; minHealth = 70; break; case WoWSpec.MageFrost: mobCount = 3; minHealth = 60; break; case WoWSpec.MonkBrewmaster: mobCount = 3; minHealth = 60; break; case WoWSpec.MonkMistweaver: mobCount = 2; minHealth = 80; break; case WoWSpec.MonkWindwalker: mobCount = 3; minHealth = 60; break; case WoWSpec.PaladinHoly: mobCount = 3; minHealth = 60; break; case WoWSpec.PaladinProtection: mobCount = 3; minHealth = 60; break; case WoWSpec.PaladinRetribution: mobCount = 3; minHealth = 60; break; case WoWSpec.PriestDiscipline: mobCount = 0; minHealth = 100; break; case WoWSpec.PriestHoly: mobCount = 0; minHealth = 100; break; case WoWSpec.PriestShadow: mobCount = 2; minHealth = 75; break; case WoWSpec.RogueAssassination: mobCount = 0; minHealth = 75; break; case WoWSpec.RogueCombat: mobCount = 0; minHealth = 75; break; case WoWSpec.RogueSubtlety: mobCount = 0; minHealth = 75; break; case WoWSpec.ShamanElemental: mobCount = 2; minHealth = 75; break; case WoWSpec.ShamanEnhancement: mobCount = 2; minHealth = 75; break; case WoWSpec.ShamanRestoration: mobCount = 0; minHealth = 100; break; case WoWSpec.WarlockAffliction: mobCount = 2; minHealth = 80; break; case WoWSpec.WarlockDemonology: mobCount = 2; minHealth = 80; break; case WoWSpec.WarlockDestruction: mobCount = 2; minHealth = 80; break; case WoWSpec.WarriorArms: mobCount = 2; minHealth = 75; break; case WoWSpec.WarriorFury: mobCount = 2; minHealth = 75; break; case WoWSpec.WarriorProtection: mobCount = 3; minHealth = 60; break; } return; }
public Behavior(WoWClass cl, WoWSpec sp, WoWContext cont) { _class = cl; _spec = sp; _context = cont; }
public bool Match(WoWClass cl, WoWSpec sp, WoWContext cont) { return(cl == _class && cont == _context); }
public static Composite GetComposite(WoWClass wowClass, WoWSpec spec, BehaviorType behavior, WoWContext context, out int behaviourCount, bool silent = false) { if (context == WoWContext.None) { // None is an invalid context, but rather than stopping bot wait it out with donothing logic Logger.Write(Color.White, "No Active Context -{0}{1} for{2} set to DoNothingBehavior temporarily", wowClass.ToString().CamelToSpaced(), behavior.ToString().CamelToSpaced(), spec.ToString().CamelToSpaced()); behaviourCount = 1; return NoContextAvailable.CreateDoNothingBehavior(); } SilentBehaviorCreation = silent; behaviourCount = 0; if (_methods.Count <= 0) { // Logger.WriteDebug("Singular Behaviors: building method list"); foreach (var type in Assembly.GetExecutingAssembly().GetTypes()) { // All behavior methods should not be generic, and should have zero parameters, with their return types being of type Composite. _methods.AddRange( type.GetMethods(BindingFlags.Static | BindingFlags.Public).Where( mi => !mi.IsGenericMethod && mi.GetParameters().Length == 0).Where( mi => mi.ReturnType.IsAssignableFrom(typeof (Composite)))); } Logger.WriteFile("Singular Behaviors: Added " + _methods.Count + " behaviors"); } var matchedMethods = new Dictionary<BehaviorAttribute, Composite>(); foreach (MethodInfo mi in _methods) { // If the behavior is set as ignore. Don't use it? Duh? if (mi.GetCustomAttributes(typeof(IgnoreBehaviorCountAttribute), false).Any()) continue; // If there's no behavior attrib, then move along. foreach (var a in mi.GetCustomAttributes(typeof(BehaviorAttribute), false)) { var attribute = a as BehaviorAttribute; if (attribute == null) continue; // Check if our behavior matches with what we want. If not, don't add it! if (IsMatchingMethod(attribute, wowClass, spec, behavior, context)) { if (!silent) Logger.WriteFile("{0} {1} {2}", attribute.PriorityLevel.ToString().AlignRight(4), behavior.ToString().AlignLeft(15), mi.Name); CurrentBehaviorType = behavior; // if it blows up here, you defined a method with the exact same attribute and priority as one already found // wrap in trace class Composite comp = mi.Invoke(null, null) as Composite; string name = behavior.ToString() + "." + mi.Name + "." + attribute.PriorityLevel.ToString(); if (SingularSettings.Trace) comp = new CallTrace( name, comp); matchedMethods.Add(attribute, comp); CurrentBehaviorType = 0; } } } // If we found no methods, rofls! if (matchedMethods.Count <= 0) { return null; } var result = new PrioritySelector(); foreach (var kvp in matchedMethods.OrderByDescending(mm => mm.Key.PriorityLevel)) { result.AddChild(kvp.Value); behaviourCount++; } return result; }