public static Composite CreateUseHealTrinketsBehaviour() { if (SingularSettings.IsTrinketUsageWanted(TrinketUsage.LowHealth)) { return(new Decorator( ret => StyxWoW.Me.HealthPercent < SingularSettings.Instance.PotionHealth, Item.UseEquippedTrinket(TrinketUsage.LowHealth) )); } return(new Action(ret => { return RunStatus.Failure; })); }
// [Behavior(BehaviorType.Combat, priority: 999)] public static Composite CreateUseTrinketsBehaviour() { // Saving Settings via GUI will now force reinitialize so we can build the behaviors // basead upon the settings rather than continually checking the settings in the Btree // // if (SingularSettings.Instance.Trinket1Usage == TrinketUsage.Never && SingularSettings.Instance.Trinket2Usage == TrinketUsage.Never) { return(new Action(ret => { return RunStatus.Failure; })); } PrioritySelector ps = new PrioritySelector(); if (SingularSettings.IsTrinketUsageWanted(TrinketUsage.OnCooldown)) { ps.AddChild(Item.UseEquippedTrinket(TrinketUsage.OnCooldown)); } if (SingularSettings.IsTrinketUsageWanted(TrinketUsage.OnCooldownInCombat)) { ps.AddChild(Item.UseEquippedTrinket(TrinketUsage.OnCooldownInCombat)); } if (SingularSettings.IsTrinketUsageWanted(TrinketUsage.LowHealth)) { ps.AddChild(new Decorator(ret => StyxWoW.Me.HealthPercent < SingularSettings.Instance.PotionHealth, Item.UseEquippedTrinket(TrinketUsage.LowHealth))); } if (SingularSettings.IsTrinketUsageWanted(TrinketUsage.LowPower)) { ps.AddChild(new Decorator(ret => StyxWoW.Me.PowerPercent < SingularSettings.Instance.PotionMana, Item.UseEquippedTrinket(TrinketUsage.LowPower))); } if (SingularSettings.IsTrinketUsageWanted(TrinketUsage.CrowdControlled)) { ps.AddChild(new Decorator(ret => Unit.IsCrowdControlled(StyxWoW.Me), Item.UseEquippedTrinket(TrinketUsage.CrowdControlled))); } if (SingularSettings.IsTrinketUsageWanted(TrinketUsage.CrowdControlledSilenced)) { ps.AddChild(new Decorator(ret => StyxWoW.Me.Silenced && Unit.IsCrowdControlled(StyxWoW.Me), Item.UseEquippedTrinket(TrinketUsage.CrowdControlledSilenced))); } return(ps); }
private void ConfigurationForm_Load(object sender, EventArgs e) { lblVersion.Text = string.Format("v{0}", Assembly.GetExecutingAssembly().GetName().Version) + " [$Revision: 235 $]"; //HealTargeting.Instance.OnTargetListUpdateFinished += new Styx.Logic.TargetListUpdateFinishedDelegate(Instance_OnTargetListUpdateFinished); pgGeneral.SelectedObject = SingularSettings.Instance; SingularSettings main = SingularSettings.Instance; Styx.Helpers.Settings toSelect = null; switch (StyxWoW.Me.Class) { case WoWClass.Warrior: toSelect = main.Warrior; break; case WoWClass.Paladin: toSelect = main.Paladin; break; case WoWClass.Hunter: toSelect = main.Hunter; break; case WoWClass.Rogue: toSelect = main.Rogue; break; case WoWClass.Priest: toSelect = main.Priest; break; case WoWClass.DeathKnight: toSelect = main.DeathKnight; break; case WoWClass.Shaman: toSelect = main.Shaman; break; case WoWClass.Mage: toSelect = main.Mage; break; case WoWClass.Warlock: toSelect = main.Warlock; break; case WoWClass.Druid: toSelect = main.Druid; break; default: break; } if (toSelect != null) { pgClass.SelectedObject = toSelect; } if (!timer1.Enabled) { timer1.Start(); } }
public override void Initialize() { DateTime timeStart = DateTime.UtcNow; Logger.WriteFile("Initialize: started"); // cannot call method which references SingularSettings TalentManager.Init(); // initializes CurrentSpec which is referenced everywhere SingularSettings.Initialize(); // loads Singular global and spec-specific settings (must determine spec first) DetermineCurrentWoWContext(); Task.Run(() => WriteSupportInfo()); _lastLogLevel = GlobalSettings.Instance.LogLevel; // When we actually need to use it, we will. Spell.Init(); Spell.GcdInitialize(); EventHandlers.Init(); MountManager.Init(); HotkeyDirector.Init(); MovementManager.Init(); // SoulstoneManager.Init(); // switch to using Death behavior Dispelling.Init(); PartyBuff.Init(); Singular.Lists.BossList.Init(); Targeting.Instance.WeighTargetsFilter += PullMoreWeighTargetsFilter; //Logger.Write("Combat log event handler started."); // Do this now, so we ensure we update our context when needed. BotEvents.Player.OnMapChanged += e => { // Don't run this handler if we're not the current routine! if (!WeAreTheCurrentCombatRoutine) { return; } // Only ever update the context. All our internal handlers will use the context changed event // so we're not reliant on anything outside of ourselves for updates. UpdateContext(); }; TreeHooks.Instance.HooksCleared += () => { // Don't run this handler if we're not the current routine! if (!WeAreTheCurrentCombatRoutine) { return; } Logger.Write(LogColor.Hilite, "Hooks cleared, re-creating behaviors"); RebuildBehaviors(silent: true); Spell.GcdInitialize(); // probably not needed, but quick }; GlobalSettings.Instance.PropertyChanged += (sender, e) => { // Don't run this handler if we're not the current routine! if (!WeAreTheCurrentCombatRoutine) { return; } // only LogLevel change will impact our behav trees // .. as we conditionally include/omit some diagnostic nodes if debugging // also need to keep a cached copy of prior value as the event // .. fires on the settor, not when the value is different if (e.PropertyName == "LogLevel" && _lastLogLevel != GlobalSettings.Instance.LogLevel) { _lastLogLevel = GlobalSettings.Instance.LogLevel; Logger.Write(LogColor.Hilite, "HonorBuddy {0} setting changed to {1}, re-creating behaviors", e.PropertyName, _lastLogLevel.ToString()); RebuildBehaviors(); Spell.GcdInitialize(); // probably not needed, but quick } }; // install botevent handler so we can consolidate validation on whether // .. local botevent handlers should be called or not SingularBotEventInitialize(); Logger.Write("Determining talent spec."); try { TalentManager.Update(); } catch (Exception e) { StopBot(e.ToString()); } Logger.Write("Current spec is " + SpecName()); // write current settings to log file... only written at startup and when Save press in Settings UI Task.Run(() => SingularSettings.Instance.LogSettings()); // Update the current WoWContext, and fire an event for the change. UpdateContext(); // NOTE: Hook these events AFTER the context update. OnWoWContextChanged += (orig, ne) => { Logger.Write(LogColor.Hilite, "Context changed, re-creating behaviors"); SingularRoutine.DescribeContext(); RebuildBehaviors(); Spell.GcdInitialize(); Singular.Lists.BossList.Init(); }; RoutineManager.Reloaded += (s, e) => { Logger.Write(LogColor.Hilite, "Routines were reloaded, re-creating behaviors"); RebuildBehaviors(silent: true); Spell.GcdInitialize(); }; // create silently since Start button will create a context change (at least first Start) // .. which will build behaviors again if (!Instance.RebuildBehaviors()) { return; } // if (IsPluginEnabled("DrinkPotions")) { Logger.Write(LogColor.Hilite, "info: disabling DrinkPotions plugin, conflicts with Singular potion support"); SetPluginEnabled("DrinkPotions", false); } SpellImmunityManager.Add(16292, WoWSpellSchool.Frost); // http://www.wowhead.com/npc=16292/aquantion Logger.WriteDebug(Color.White, "Verified behaviors can be created!"); Logger.Write("Initialization complete!"); Logger.WriteDiagnostic(Color.White, "Initialize: completed taking {0:F2} seconds", (DateTime.UtcNow - timeStart).TotalSeconds); }