public void RegisterAbilityChain(AbilityChain abilityChain) { if (Main.Product != Product.Premium) { return; } if (HotkeysManager.Hotkeys.Any(o => o.Name == "Paws_" + abilityChain.Name)) { return; } AbilityChains.Add(abilityChain); var hotKey = HotkeysManager.Hotkeys.FirstOrDefault(o => o.Name == abilityChain.Name); if (hotKey != null) { HotkeysManager.Unregister(hotKey); } var registeredHotKey = HotkeysManager.Register("Paws_" + abilityChain.Name, abilityChain.HotKey, abilityChain.ModiferKey, KeyIsPressed); Log.AbilityChain(string.Format("Ability chain successfully registered ({0}: {1} + {2}).", registeredHotKey.Name, registeredHotKey.ModifierKeys, registeredHotKey.Key)); }
public void Trigger(AbilityChain abilityChain) { if (TriggerInAction) { return; } foreach (var link in abilityChain.ChainedAbilities.Where(link => link.MustBeReady).Where(link => link.Instance.Spell.CooldownTimeLeft.TotalMilliseconds > 2000)) { Log.AbilityChain( string.Format( "NOTICE: The {0} ability chain has been canceled. {1} is still on cooldown (Time left: {2})", abilityChain.Name, link.Instance.Spell.Name, link.Instance.Spell.CooldownTimeLeft)); return; } Log.AbilityChain("The " + abilityChain.Name + " ability chain has been triggered."); TriggerInAction = true; TriggeredAbilityChain = abilityChain; _abilityQueue = new Queue <ChainedAbility>(TriggeredAbilityChain.ChainedAbilities); TriggerTimerElapsedMs = 2000; // give each ability 2 seconds to cast before moving on to the next ability. _triggerTimer.Restart(); }
/// <summary> /// The internal method used to handle hotkeys that are pressed. This will subsequently call the Trigger method /// provided the various checks and balances pass. /// </summary> private void KeyIsPressed(Hotkey hotKey) { // Ability Chain Check... placing a "Paws_" prefix ensures that no other registered hotkeys are messed with in the system. var abilityChain = AbilityChains.SingleOrDefault(o => "Paws_" + o.Name == hotKey.Name); if (abilityChain == null) { return; } if (StyxWoW.Me.Specialization == abilityChain.Specialization) { // We have a triggered Ability Chain Trigger(abilityChain); } else { Log.AbilityChain( string.Format( "Hotkey detected, but your specialization must be {0} to trigger the {1} ability chain.", abilityChain.Specialization.ToString().Replace("Druid", string.Empty), hotKey.Name)); } }
public async Task <bool> TriggeredRotation() { try { if (TriggeredAbilityChain != null) { if (!_triggerTimer.IsRunning) { _triggerTimer.Start(); } if (_abilityQueue.Count > 0) { var ability = _abilityQueue.Peek(); Log.Diagnostics(string.Format("Peeking ability: {0}", ability.FriendlyName)); if (await ability.Instance.CastOnTarget(UnitManager.TargetTypeConverter(ability.TargetType))) { Log.Diagnostics(string.Format("ability cast successful: {0}", ability.FriendlyName)); _abilityQueue.Dequeue(); _triggerTimer.Restart(); return(await TriggeredRotation()); } if (_triggerTimer.ElapsedMilliseconds > TriggerTimerElapsedMs) { Log.Diagnostics( string.Format( "Ability cast failed: {0}, skipping to the next link in the ability chain.", ability.FriendlyName)); _abilityQueue.Dequeue(); _triggerTimer.Restart(); return(await TriggeredRotation()); } } else { Log.AbilityChain("The " + TriggeredAbilityChain.Name + " ability chain finished."); TriggerInAction = false; TriggeredAbilityChain = null; _triggerTimer.Reset(); } } } catch (Exception ex) { if (TriggeredAbilityChain != null) { Log.AbilityChain(string.Format("{0} ability chain failed. Exception raised: {1}", TriggeredAbilityChain.Name, ex)); TriggerInAction = false; } TriggeredAbilityChain = null; _triggerTimer.Reset(); } return(false); }