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(); } }
/// <summary> /// Saves and Closes the Configuration window. /// </summary> private void BtnSaveAndCloseClick(object sender, EventArgs e) { // prevent an exception from closing HB. try { ((Styx.Helpers.Settings)pgGeneral.SelectedObject).Save(); if (pgClass.SelectedObject != null) { ((Styx.Helpers.Settings)pgClass.SelectedObject).Save(); } this.Close(); } catch (Exception ex) { CLULogger.DiagnosticLog("ERROR saving settings: {0}", ex); } }
// Displays information about the current target on the debug tab private void button4_Click(object sender, EventArgs e) { try { var target = StyxWoW.Me.CurrentTarget; string output = target == null ? "<No target>" : "Name : " + target.Name; textBox2.Text += output + Environment.NewLine; output = target == null ? string.Empty : "Guid : " + target.Guid.ToString(CultureInfo.InvariantCulture); textBox2.Text += output + Environment.NewLine; output = target == null ? string.Empty : "Distance : " + Math.Round(target.Distance, 3).ToString(CultureInfo.InvariantCulture); textBox2.Text += output + Environment.NewLine; output = target == null ? string.Empty : "DistanceToTargetBoundingBox : " + Math.Round(Unit.DistanceToTargetBoundingBox(target), 3).ToString(CultureInfo.InvariantCulture); textBox2.Text += output + Environment.NewLine; output = "IsBehind : " + (target != null && StyxWoW.Me.IsBehind(target)).ToString(CultureInfo.InvariantCulture); textBox2.Text += output + Environment.NewLine; output = target == null ? string.Empty : "ThreatInfo : " + target.ThreatInfo.RawPercent.ToString(CultureInfo.InvariantCulture); textBox2.Text += output + Environment.NewLine; output = target == null ? string.Empty : "Location : " + target.Location; textBox2.Text += output + Environment.NewLine; output = target == null ? string.Empty : "SingleTargethealingParty : " + CLUSettings.Instance.Priest.SingleTargethealingParty; textBox2.Text += output + Environment.NewLine; output = target == null ? string.Empty : "PrayerofHealingPartymaxAH : " + CLUSettings.Instance.Priest.PrayerofHealingPartymaxAH; textBox2.Text += output + Environment.NewLine; output = target == null ? string.Empty : "Me.CurrentHolyPower : " + Me.CurrentHolyPower; textBox2.Text += output + Environment.NewLine; output = target == null ? string.Empty : "PetSlotSelection : " + (int)CLUSettings.Instance.Hunter.PetSlotSelection; textBox2.Text += output + Environment.NewLine; //output = target == null ? string.Empty : "Thunder Clap (" + SpellManager.Spells["Thunder Clap"].Id + ") Cooldown : " + Spell.SpellCooldown("Thunder Clap").TotalSeconds; //textBox2.Text += output + Environment.NewLine; //output = target == null ? string.Empty : "Thunder Clap Cooldown : " + Spell.CooldownTimeLeft6343; //textBox2.Text += output + Environment.NewLine; //output = target == null ? string.Empty : "Explosive Shot (" + SpellManager.Spells["Explosive Shot"].Id + ") Cooldown : " + Spell.SpellCooldown("Explosive Shot").TotalSeconds; //textBox2.Text += output + Environment.NewLine; //output = target == null ? string.Empty : "Explosive Shot Cooldown : " + Spell.CooldownTimeLeft33878; //textBox2.Text += output + Environment.NewLine; if (target != null) { // facing var me = StyxWoW.Me.Location; var ta = target.Location; output = "FacingTowardsUnitDegrees : " + Math.Round(Unit.FacingTowardsUnitDegrees(me, ta), 2) + "°"; } textBox2.Text += output + Environment.NewLine; } catch (Exception ex) { CLULogger.DiagnosticLog("Current Target Information : {0}", ex); } }
/// <summary> /// Frees you from movement imparing effects if a usable spell exists /// </summary> /// <returns>More win then Wulf's UseRacial call</returns> public static Composite freeMe() { return( new PrioritySelector(delegate { foreach (WoWSpell s in freeMeSpellList.Where(spell => Spell.CanCast(spell.Name, StyxWoW.Me) && freeMeSpellUsage(spell))) { CLULogger.Log(" [Freeing you via] {0} ", s.Name); SpellManager.Cast(s.Name); } return RunStatus.Success; }) ); }
/// <summary> /// Calls a pet by name, if applicable. /// </summary> /// <remarks> /// Created 2/7/2011. /// </remarks> /// <param name = "petName">Name of the pet. This parameter is ignored for mages. Warlocks should pass only the name of the pet. Hunters should pass which pet (1, 2, etc)</param> /// <returns>true if it succeeds, false if it fails.</returns> public static bool CallPet(string petName) { if (!CallPetTimer.IsFinished) { return(false); } switch (StyxWoW.Me.Class) { case WoWClass.Warlock: if (Spell.CanCast("Summon " + petName)) { CLULogger.DiagnosticLog(string.Format("[Pet] Calling out my {0}", petName)); bool result = SpellManager.Cast("Summon " + petName); //if (result) // StyxWoW.SleepForLagDuration(); return(result); } break; case WoWClass.Mage: if (Spell.CanCast("Summon Water Elemental")) { CLULogger.DiagnosticLog("[Pet] Calling out Water Elemental"); bool result = SpellManager.Cast("Summon Water Elemental"); //if (result) - All calls to this method are now placed in a sequence that uses WaitContinue // StyxWoW.SleepForLagDuration(); return(result); } break; case WoWClass.Hunter: if (Spell.CanCast("Call Pet " + petName)) { if (!StyxWoW.Me.GotAlivePet) { CLULogger.DiagnosticLog(string.Format("[Pet] Calling out pet #{0}", petName)); bool result = SpellManager.Cast("Call Pet " + petName); //if (result) // StyxWoW.SleepForLagDuration(); return(result); } } break; } return(false); }
/// <summary> /// Handle spellcast succeeded /// </summary> /// <param name="sender">sender</param> /// <param name="raw">raw Lua Events</param> public void UnitSpellcastSucceeded(object sender, LuaEventArgs raw) { var args = raw.Args; var player = Convert.ToString(args[0]); // Not me ... Im out! if (player != "player") { return; } // get the english spell name, not the localized one! var spellID = Convert.ToInt32(args[4]); var spell = WoWSpell.FromId(spellID).Name; // increments or decrements int value; if (spellList.TryGetValue(spell, out value)) { spellList[spell] = value + 1; } this.spellCasts++; // Add the spell to our spell list with a timestamp if (!this.spellInterval.ContainsKey(spell)) { this.spellInterval[spell] = new List <DateTime>(); } if (!this.spellInterval[spell].Contains(DateTime.Now)) { CLULogger.DiagnosticLog("Adding " + DateTime.Now + " for " + spell); this.spellInterval[spell].Add(DateTime.Now); } // initialize or increment the count for this item try { this.healingStats[DateTime.Now] = CLULogger.SafeName(Me.CurrentTarget) + ", " + spell + ", MaxHealth: " + Me.CurrentTarget.MaxHealth + ", CurrentHealth: " + Me.CurrentTarget.CurrentHealth + ", Deficit: " + (Me.CurrentTarget.MaxHealth - Me.CurrentTarget.CurrentHealth); CLULogger.DiagnosticLog("[CLU SUCCEED] " + CLU.Version + ": " + CLULogger.SafeName(Me.CurrentTarget) + ", " + spell + ", MaxHealth: " + Me.CurrentTarget.MaxHealth + ", CurrentHealth: " + Me.CurrentTarget.CurrentHealth + ", Deficit: " + (Me.CurrentTarget.MaxHealth - Me.CurrentTarget.CurrentHealth) + ", HealthPercent: " + Math.Round(Me.CurrentTarget.HealthPercent * 10.0) / 10.0); } catch { this.healingStats[DateTime.Now] = this.healingStats.ContainsKey(DateTime.Now) ? this.healingStats[DateTime.Now] = CLULogger.SafeName(Me.CurrentTarget) + ", " + spell + ", MaxHealth: " + Me.CurrentTarget.MaxHealth + ", CurrentHealth: " + Me.CurrentTarget.CurrentHealth + ", Deficit: " + (Me.CurrentTarget.MaxHealth - Me.CurrentTarget.CurrentHealth) : "blank"; CLULogger.DiagnosticLog("[CLU SUCCEED] " + CLU.Version + ": " + CLULogger.SafeName(Me.CurrentTarget) + ", " + spell + ", MaxHealth: " + Me.CurrentTarget.MaxHealth + ", CurrentHealth: " + Me.CurrentTarget.CurrentHealth + ", Deficit: " + (Me.CurrentTarget.MaxHealth - Me.CurrentTarget.CurrentHealth) + ", HealthPercent: " + Math.Round(Me.CurrentTarget.HealthPercent * 10.0) / 10.0); } }
/// <summary> /// Update the listOfHealableUnits /// </summary> private void updateListofHealableUnitsGrid_Click(object sender, EventArgs e) { CLULogger.TroubleshootLog("User clicked update - Re-Initialize list Of HealableUnits"); HealableUnit.ListofHealableUnits.Clear(); switch (CLUSettings.Instance.SelectedHealingAquisition) { case HealingAquisitionMethod.Proximity: HealableUnit.HealableUnitsByProximity(); break; case HealingAquisitionMethod.RaidParty: HealableUnit.HealableUnitsByPartyorRaid(); break; } }
/// <summary> /// Destroys the totem described by type. /// </summary> /// <remarks> /// Created 3/26/2011. /// </remarks> /// <param name = "type">The type.</param> public static void DestroyTotem(WoWTotemType type) { if (type == WoWTotemType.None) { return; } try { Lua.DoString("DestroyTotem({0})", (int)type); } catch { CLULogger.DiagnosticLog("Lua failed in DestroyTotem"); } }
/// <summary> /// the main cast pet spell method (uses Lua) /// </summary> /// <param name="name">the name of the spell to cast</param> private static void CastMyPetSpell(string name) { var spell = Me.PetSpells.FirstOrDefault(p => p.ToString() == name); if (spell == null) { return; } try { Lua.DoString("CastPetAction({0})", spell.ActionBarIndex + 1); } catch { CLULogger.DiagnosticLog("Lua failed in CastMyPetSpell"); } }
/// <summary> /// Blows your wad all over the floor /// </summary> /// <returns>Nothing but win</returns> public static Composite UseRacials() { return(new PrioritySelector(delegate { if (!CLUSettings.Instance.UseRacials) { return false; // gtfo if we do not want to use racials. } foreach (WoWSpell r in CurrentRacials.Where(racial => Spell.CanCast(racial.Name, StyxWoW.Me) && RacialUsageSatisfied(racial))) { CLULogger.Log(" [Racial Abilitie] {0} ", r.Name); SpellManager.Cast(r.Name); } return RunStatus.Success; })); }
/// <summary>Casts a Pet spell at the units location</summary> /// <param name="name">the name of the spell to cast</param> /// <param name="onUnit">The on Unit.</param> /// <param name="cond">The conditions that must be true</param> /// <param name="label">A descriptive label for the clients GUI logging output</param> /// <returns>The cast spell at location.</returns> public static Composite CastPetSpellAtLocation(string name, CLU.UnitSelection onUnit, CanRunDecoratorDelegate cond, string label) { // CLU.DebugLog(" [CastSpellAtLocation] name = {0} location = {1} and can we cast it? {2}", name, SysLog.SafeName(unit), CanCast(name)); return(new Decorator( delegate(object a) { if (!CLUSettings.Instance.UseAoEAbilities) { return false; } if (Me.CurrentTarget == null) { return false; } WoWPoint currTargetLocation = Me.CurrentTarget.Location; if (Unit.NearbyControlledUnits(currTargetLocation, 20, false).Any()) { return false; } if (!cond(a)) { return false; } if (!CanCastPetSpell(name)) { return false; } return onUnit != null; }, new Sequence( new Action(a => CLULogger.Log(" [Pet Casting at location] {0} ", label)), new Action(a => CastMyPetSpell(name)), // new WaitContinue( // 0, // ret => StyxWoW.Me.CurrentPendingCursorSpell != null && // StyxWoW.Me.CurrentPendingCursorSpell.Name == name, // new ActionAlwaysSucceed()), new Action(a => SpellManager.ClickRemoteLocation(onUnit(a).Location))))); }
/// <summary>Attempts to use the bag item provided it is usable and its not on cooldown</summary> /// <param name="name">the name of the bag item to use</param> /// <param name="cond">The conditions that must be true</param> /// <param name="label">A descriptive label for the clients GUI logging output</param> /// <returns>The use bag item.</returns> public static Composite UseBagItem(string name, CanRunDecoratorDelegate cond, string label) { WoWItem item = null; return(new Decorator( delegate(object a) { if (!cond(a)) { return false; } item = Me.BagItems.FirstOrDefault(x => x.Name == name && x.Usable && x.Cooldown <= 0); return item != null; }, new Sequence( new Action(a => CLULogger.Log(" [BagItem] {0} ", label)), new Action(a => item.UseContainerItem())))); }
/// <summary> /// Checks the equiped item cooldown is 0 and its usable /// </summary> /// <param name="item">the item to query</param> /// <returns>true of false</returns> private static bool CanUseEquippedItem(WoWItem item) { try { // Check for engineering tinkers! var itemSpell = Lua.GetReturnVal <string>("return GetItemSpell(" + item.Entry + ")", 0); if (string.IsNullOrEmpty(itemSpell)) { return(false); } return(item.Usable && item.Cooldown <= 0); } catch { CLULogger.DiagnosticLog("Lua failed in CanUseEquippedItem"); return(false); } }
/// <summary> /// Recalls any currently 'out' totems. This will use Totemic Recall if its known, otherwise it will destroy each totem one by one. /// </summary> /// <remarks> /// Created 3/26/2011. /// </remarks> public static void RecallTotems() { CLULogger.TroubleshootLog("Recalling totems!"); if (SpellManager.HasSpell("Totemic Recall")) { SpellManager.Cast("Totemic Recall"); return; } List <WoWTotemInfo> totems = StyxWoW.Me.Totems; foreach (WoWTotemInfo t in totems) { if (t != null && t.Unit != null) { DestroyTotem(t.Type); } } }
public void Player_OnMapChanged(BotEvents.Player.MapChangedEventArgs args) { try { if ((CLU.LocationContext == GroupLogic.Battleground || CLU.LocationContext == GroupLogic.PVE) && TalentManager.CurrentSpec != WoWSpec.DruidFeral) { DetachCombatLogEvent(); } else { AttachCombatLogEvent(); } //Why would we create same behaviors all over ? if (CLU.LastLocationContext == CLU.LocationContext) { return; } CLULogger.TroubleshootLog("Context changed. New context: " + CLU.LocationContext + ". Rebuilding behaviors."); CLU.Instance.CreateBehaviors(); if (CLU.IsHealerRotationActive && StyxWoW.IsInGame) { CLULogger.TroubleshootLog("CombatLogEvents: Party Members Changed - Re-Initialize list Of HealableUnits"); switch (CLUSettings.Instance.SelectedHealingAquisition) { case HealingAquisitionMethod.Proximity: HealableUnit.HealableUnitsByProximity(); break; case HealingAquisitionMethod.RaidParty: HealableUnit.HealableUnitsByPartyorRaid(); break; } } } catch (Exception ex) { CLULogger.DiagnosticLog("Player_OnMapChanged : {0}", ex); } }
/// <summary> /// Sets up the healing grid and binds our datasource to listOfHealableUnits /// </summary> private void InitializeHealingGrid() { try { HealingGrid.SelectionMode = DataGridViewSelectionMode.FullRowSelect; // Automatically generate the DataGridView columns. HealingGrid.AutoGenerateColumns = true; // Automatically resize the visible rows. HealingGrid.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders; // Automatically resize the visible columns HealingGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.ColumnHeader; // Set the DataGridView control's border. HealingGrid.BorderStyle = BorderStyle.Fixed3D; // Put the cells in edit mode when user enters them. HealingGrid.EditMode = DataGridViewEditMode.EditOnEnter; // Set the RowHeaders visibility to invisible HealingGrid.RowHeadersVisible = false; // Dissalow user from adding rows HealingGrid.AllowUserToAddRows = false; // Clipboard copying. HealingGrid.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText; // Bind to our Datasource (BindingList) healingGridBindingSource = new BindingSource { DataSource = HealableUnit.ListofHealableUnits }; HealingGrid.DataSource = healingGridBindingSource; // Create events for HealingGrid: HealingGrid.CurrentCellDirtyStateChanged += this.HealingGrid_CurrentCellDirtyStateChanged; //HealingGrid.CellMouseClick += this.HealingGrid_OnCellMouseUp; } catch (Exception ex) { CLULogger.DiagnosticLog("InitializeHealingGrid : {0}", ex); } }
public bool CreateBehaviors() { CLULogger.TroubleshootLog("CreateBehaviors called."); // let behaviors be notified if context changes. if (OnLocationContextChanged != null) { OnLocationContextChanged(this, new LocationContextEventArg(LocationContext, LastLocationContext)); } //Caching the context to not recreate same behaviors repeatedly. LastLocationContext = LocationContext; _rotationBase = null; if (_combatBehavior != null) { this._combatBehavior = new Decorator(ret => AllowPulse, new LockSelector(this.Rotation)); } if (_combatBuffBehavior != null) { this._combatBuffBehavior = new Decorator(ret => AllowPulse, new LockSelector(this.Medic)); } if (_preCombatBuffBehavior != null) { this._preCombatBuffBehavior = new Decorator(ret => AllowPulse, new LockSelector(this.PreCombat)); } if (_restBehavior != null) { this._restBehavior = new Decorator(ret => !(CLUSettings.Instance.NeverDismount && IsMounted) && !Me.IsFlying, new LockSelector(this.Resting)); } if (_pullBehavior != null) { this._pullBehavior = new Decorator(ret => AllowPulse, new LockSelector(this.Pulling)); } return(true); }
/// <summary>Returns a summoned pet</summary> /// <param name="name">the name of the spell</param> /// <param name="cond">The conditions that must be true</param> /// <param name="label">A descriptive label for the clients GUI logging output</param> /// <returns>The cast pet summon spell.</returns> public static Composite CastPetSummonSpell(string name, CanRunDecoratorDelegate cond, string label) { try { var isWarlock = Me.Class == WoWClass.Warlock && SpellManager.Spells[name].Name.StartsWith("Summon "); if (isWarlock) { Spell.KnownChanneledSpells.Add(name); } return(new Decorator( delegate(object a) { if (!cond(a)) { return false; } if (!Spell.CanCast(name, Me)) { return false; } return true; }, new Decorator(ret => !Me.GotAlivePet && PetTimer.IsFinished, new Sequence( new Action(a => CLULogger.Log(" {0}", label)), new Action(a => SpellManager.Cast(name)), Spell.CreateWaitForLagDuration(), new Wait(5, a => Me.GotAlivePet || !Me.IsCasting, new PrioritySelector( new Decorator(a => StyxWoW.Me.IsCasting, new Action(ret => SpellManager.StopCasting())), new ActionAlwaysSucceed())))))); } catch { CLULogger.DiagnosticLog("Summon Spell {0} not supported for your Class / Specc ({1}/{2})", name, Me.Class, Me.Specialization); return(null); } }
/// <summary> /// Checks if the player is weilding a TwoHanded Weapon /// </summary> /// <returns>returns true if the player is weilding a TwoHanded Weapon</returns> public static bool IsWieldingTwoHandedWeapon() { try { switch (Me.Inventory.Equipped.MainHand.ItemInfo.WeaponClass) { case WoWItemWeaponClass.ExoticTwoHand: case WoWItemWeaponClass.MaceTwoHand: case WoWItemWeaponClass.AxeTwoHand: case WoWItemWeaponClass.SwordTwoHand: return(true); } return(false); } catch (Exception ex) { CLULogger.DiagnosticLog("IsWieldingBigWeapon : {0}", ex); } return(false); }
private static void AttachCombatLogEvent() { if (_combatLogAttached) { return; } // DO NOT EDIT THIS UNLESS YOU KNOW WHAT YOU'RE DOING! // This ensures we only capture certain combat log events, not all of them. // This saves on performance, and possible memory leaks. (Leaks due to Lua table issues.) Lua.Events.AttachEvent("COMBAT_LOG_EVENT_UNFILTERED", HandleCombatLog); if ( !Lua.Events.AddFilter( "COMBAT_LOG_EVENT_UNFILTERED", "return args[2] == 'SPELL_CAST_SUCCESS' or args[2] == 'SPELL_AURA_APPLIED' or args[2] == 'SPELL_DAMAGE' or args[2] == 'SPELL_AURA_REFRESH' or args[2] == 'SPELL_AURA_REMOVED'or args[2] == 'SPELL_MISSED' or args[2] == 'RANGE_MISSED' or args[2] =='SWING_MISSED'")) { CLULogger.TroubleshootLog( "ERROR: Could not add combat log event filter! - Performance may be horrible, and things may not work properly!"); } CLULogger.TroubleshootLog("Attached combat log"); _combatLogAttached = true; }
/// <summary> /// Removes a unit from our listOfHealableUnits by the currently selected row /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void removeUnitHealingGrid_Click(object sender, EventArgs e) { try { if (this.HealingGrid.SelectedRows.Count > 0) { CLULogger.TroubleshootLog(" Removing: {0} because of user request.", this.HealingGrid.SelectedRows[0].Cells[6].Value); HealableUnit.ListofHealableUnits.RemoveAt(this.HealingGrid.SelectedRows[0].Index); } else { MessageBox.Show( "Please select a row to delete", "Important Note", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } this.RefreshDataGridView(); // update } catch (Exception ex) { this.RefreshDataGridView(); // update CLULogger.DiagnosticLog("removeUnitHealingGrid_Click : {0}", ex); } }
private static double Traveltime(double travelSpeed) { { if (travelSpeed < 1) { return(0); } if (Me.CurrentTarget != null && Me.CurrentTarget.Distance < 1) { return(0); } if (Me.CurrentTarget != null) { double t = Me.CurrentTarget.Distance / travelSpeed; CLULogger.DiagnosticLog("Travel time: {0}", t); return(t); } return(0); } }
// Provides information from the healing helper window on the selected row item (displays it on teh debug tab.) private void CheckerClick(object sender, EventArgs e) { try { if (this.HealingGrid.SelectedRows.Count > 0) { for (int i = 0; i < this.HealingGrid.SelectedRows[0].Cells.Count; i++) { textBox1.Text += string.Format(" {0} : {1}", this.HealingGrid.SelectedRows[0].Cells[i].OwningColumn.HeaderText, this.HealingGrid.SelectedRows[0].Cells[i].Value) + Environment.NewLine; } } else { MessageBox.Show( "Please select a row to gather information. check the debug log for the output.", "Important Note for Healing Helper", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } } catch (Exception ex) { CLULogger.DiagnosticLog("Checker_Click : {0}", ex); } }
public void PrintReport() { // var spells = spellList.OrderByDescending(x => x.Value); // var seconds = DateTime.Now.Subtract(start).TotalSeconds; var minutes = DateTime.Now.Subtract(this.start).TotalMinutes; var apm = (int)(this.spellCasts / minutes); CLULogger.Log("CLU stats report:"); CLULogger.Log("Runtime: {0} minutes", Math.Round(minutes * 10.0) / 10.0); CLULogger.Log("Spells cast: {0}", this.spellCasts > 1000 ? ((Math.Round(this.spellCasts / 100.0) * 10) + "k") : this.spellCasts.ToString(CultureInfo.InvariantCulture)); CLULogger.Log("Average APM: {0}", apm); CLULogger.Log("------------------------------------------"); foreach (KeyValuePair <string, int> spell in this.spellList) { CLULogger.Log(spell.Key + " was cast " + spell.Value + " time(s)."); } CLULogger.Log("------------------------------------------"); foreach (KeyValuePair <string, List <DateTime> > spell in this.spellInterval) { var lastInterval = this.start; var output = "0 "; for (int x = 0; x < spell.Value.Count - 1; ++x) { var interval = spell.Value[x]; var difference = interval - lastInterval; output = output + string.Format(", {0} ", Math.Round(difference.TotalSeconds * 100.0) / 100.0); lastInterval = interval; } CLULogger.Log(spell.Key + " intervals: "); Logging.Write(" " + output); } }
private static void StealthedCombat() { if (Me.CurrentTarget == null || Me.CurrentTarget.IsDead || (!Me.CurrentTarget.IsHostile && !Unit.IsTrainingDummy(Me.CurrentTarget)) || !Me.CurrentTarget.Attackable) { return; } if ((!Me.IsStealthed && !Buff.PlayerHasActiveBuff("Vanish")) || !SafeToBreakStealth) { return; } // If we're not behind, attempt to shadowstep and wait for next pulse. if (SpellManager.HasSpell("Shadowstep") && !StyxWoW.Me.IsBehind(Me.CurrentTarget) && Spell.CanCast("Shadowstep", Me.CurrentTarget)) { CLULogger.Log(" [Casting] Shadowstep on {0} @ StealthedCombat", CLULogger.SafeName(Me.CurrentTarget)); SpellManager.Cast("Shadowstep"); } else if (Me.Behind(Me.CurrentTarget) && (Me.CurrentEnergy >= 60 || HasShadowFocus)) { CLULogger.Log(" [Casting] Mutilate on {0} @ StealthCombat", CLULogger.SafeName(Me.CurrentTarget)); SpellManager.Cast("Mutilate"); } else if (Me.CurrentTarget.HealthPercent < 35 || Buff.PlayerHasBuff("Blindside")) { CLULogger.Log(" [Casting] Dispatch on {0} @ StealthedCombat", CLULogger.SafeName(Me.CurrentTarget)); SpellManager.Cast(DispatchOverride); } else { CLULogger.Log(" [Casting] Mutilate on {0} @ StealthedCombat", CLULogger.SafeName(Me.CurrentTarget)); SpellManager.Cast("Mutilate"); } }
private void HandlePartyMembersChanged(object sender, LuaEventArgs args) { try { if (CLU.IsHealerRotationActive && StyxWoW.IsInGame) { CLULogger.TroubleshootLog("CombatLogEvents: Party Members Changed - Re-Initialize list Of HealableUnits"); switch (CLUSettings.Instance.SelectedHealingAquisition) { case HealingAquisitionMethod.Proximity: HealableUnit.HealableUnitsByProximity(); break; case HealingAquisitionMethod.RaidParty: HealableUnit.HealableUnitsByPartyorRaid(); break; } } } catch (Exception ex) { CLULogger.DiagnosticLog("HandlePartyMembersChanged : {0}", ex); } }
/// <summary> /// Main MultiCastMacro call: checks if MultiCastMacro MT or FT is active, also checks for LoS and if we can cast the specified spell /// If zero(0) is present: return to primary or previous rotation /// If one(1) is present: run MT or FT then return to primary or previous rotation /// </summary> public static void isMultiCastMacroInUse() { using (StyxWoW.Memory.AcquireFrame()) { try { MultiCastMacroMT = Lua.GetReturnVal <int>("return MultiCastMT", 0); MultiCastMacroFT = Lua.GetReturnVal <int>("return MultiCastFT", 0); whatSpell = Lua.GetReturnVal <String>("return spellName", 0); } catch { CLULogger.DiagnosticLog("Lua failed in Macro.isMultiCastMacroInUse"); } } if (MultiCastMacroMT > 0 || MultiCastMacroFT > 0) { if (whatSpell == null) { CLULogger.Log("Please enter a spell!"); resetAllMacros(); } else { SpellManager.Spells.TryGetValue(whatSpell, out _Spell); if (!_Spell.IsValid) { CLULogger.Log("Can't Cast Spell, invalid!"); resetAllMacros(); } if (_Spell.CooldownTimeLeft > SpellManager.GlobalCooldownLeft) { CLULogger.Log("Can't Cast Spell, on CD!"); resetAllMacros(); } } } if (MultiCastMacroMT > 0) { if (SpellManager.GlobalCooldown || Me.IsCasting) { return; } if (Me.CurrentTarget.InLineOfSight) { if (SpellManager.CanCast(whatSpell)) { try { Lua.DoString("RunMacroText(\"/cast " + whatSpell + "\")"); } catch { CLULogger.DiagnosticLog("Lua failed in Macro.isMultiCastMacroInUse"); } SpellManager.ClickRemoteLocation(Me.CurrentTarget.Location); CLULogger.Log("Casting " + whatSpell); resetMacro("MultiCastMT"); } } else { resetMacro("MultiCastMT"); } } else if (MultiCastMacroFT > 0) { if (SpellManager.GlobalCooldown || Me.IsCasting) { return; } if (Me.FocusedUnit.InLineOfSight) { if (SpellManager.CanCast(whatSpell)) { try { Lua.DoString("RunMacroText(\"/cast [@focus] " + whatSpell + "\")"); } catch { CLULogger.DiagnosticLog("Lua failed in Macro.isMultiCastMacroInUse"); } SpellManager.ClickRemoteLocation(Me.FocusedUnit.Location); CLULogger.Log("Casting " + whatSpell); resetMacro("MultiCastFT"); } } else { resetMacro("MultiCastFT"); } } }
public static void Update() { // Don't bother if we're < 10 if (StyxWoW.Me.Level < 10) { CurrentSpec = WoWSpec.None; return; } // Keep the frame stuck so we can do a bunch of injecting at once. using (StyxWoW.Memory.AcquireFrame()) { CurrentSpec = StyxWoW.Me.Specialization; Talents.Clear(); var numTalents = Lua.GetReturnVal <int>("return GetNumTalents()", 0); for (int index = 0; index <= numTalents; index++) { var selected = Lua.GetReturnVal <int>(string.Format("return GetTalentInfo({0})", index), 4); switch (selected) { case 1: { var t = new Talent { Index = index, Count = 1 }; //Name = talentName CLULogger.TroubleshootLog("[TalentManager] - Talent {0} chosen", index); Talents.Add(t); } break; } } foreach (var talent in Talents) { if (StyxWoW.Me.Class == WoWClass.DeathKnight) { // Set the Blood DK Tier one Talent here switch (talent.Index) { case 1: CLUSettings.Instance.DeathKnight.DeathKnightTierOneTalent = DeathKnightTierOneTalent.RoilingBlood; CLULogger.TroubleshootLog("TalentManager - Setting DeathKnightTierOneTalent to {0}", DeathKnightTierOneTalent.RoilingBlood); break; case 2: CLUSettings.Instance.DeathKnight.DeathKnightTierOneTalent = DeathKnightTierOneTalent.PlagueLeech; CLULogger.TroubleshootLog("TalentManager - Setting DeathKnightTierOneTalent to {0}", DeathKnightTierOneTalent.PlagueLeech); break; case 3: CLUSettings.Instance.DeathKnight.DeathKnightTierOneTalent = DeathKnightTierOneTalent.UnholyBlight; CLULogger.TroubleshootLog("TalentManager - Setting DeathKnightTierOneTalent to {0}", DeathKnightTierOneTalent.UnholyBlight); break; } } } Glyphs.Clear(); var glyphCount = Lua.GetReturnVal <int>("return GetNumGlyphSockets()", 0); CLULogger.TroubleshootLog("Glyphdetection - GetNumGlyphSockets {0}", glyphCount); if (glyphCount != 0) { for (int i = 1; i <= glyphCount; i++) { List <string> glyphInfo = Lua.GetReturnValues(String.Format("return GetGlyphSocketInfo({0})", i), "glyphs.lua"); var lua = String.Format("local enabled, glyphType, glyphTooltipIndex, glyphSpellID, icon = GetGlyphSocketInfo({0});if (enabled) then return glyphSpellID else return 0 end", i); var glyphSpellId = Lua.GetReturnVal <int>(lua, 0); try { if (glyphSpellId > 0) { CLULogger.TroubleshootLog("Glyphdetection - SpellId: {0},Name:{1} ,WoWSpell: {2}", glyphSpellId, WoWSpell.FromId(glyphSpellId).Name, WoWSpell.FromId(glyphSpellId)); Glyphs.Add(WoWSpell.FromId(glyphSpellId).Name.Replace("Glyph of ", "")); } else { CLULogger.TroubleshootLog("Glyphdetection - Couldn't find all values to detect the Glyph in slot {0}", i); } } catch (Exception ex) { CLULogger.DiagnosticLog("We couldn't detect your Glyphs"); CLULogger.DiagnosticLog("Report this message to us: " + ex); } } } } }
// Thanks to Singular Devs for the CombatLogEventArgs class and SpellImmunityManager. private static void HandleCombatLog(object sender, LuaEventArgs args) { var e = new CombatLogEventArgs(args.EventName, args.FireTimeStamp, args.Args); //var missType = Convert.ToString(e.Args[14]); switch (e.Event) { case "SWING_MISSED": if (e.Args[11].ToString() == "EVADE") { CLULogger.TroubleshootLog("Mob is evading swing. Blacklisting it!"); Blacklist.Add(e.DestGuid, TimeSpan.FromMinutes(30)); if (StyxWoW.Me.CurrentTargetGuid == e.DestGuid) { StyxWoW.Me.ClearTarget(); } BotPoi.Clear("Blacklisting evading mob"); StyxWoW.SleepForLagDuration(); } else if (e.Args[11].ToString() == "IMMUNE") { WoWUnit unit = e.DestUnit; if (unit != null && !unit.IsPlayer) { CLULogger.TroubleshootLog("{0} is immune to {1} spell school", unit.Name, e.SpellSchool); SpellImmunityManager.Add(unit.Entry, e.SpellSchool); } } break; case "SPELL_MISSED": case "RANGE_MISSED": if (e.Args[14].ToString() == "EVADE") { CLULogger.TroubleshootLog("Mob is evading ranged attack. Blacklisting it!"); Blacklist.Add(e.DestGuid, TimeSpan.FromMinutes(30)); if (StyxWoW.Me.CurrentTargetGuid == e.DestGuid) { StyxWoW.Me.ClearTarget(); } BotPoi.Clear("Blacklisting evading mob"); StyxWoW.SleepForLagDuration(); } else if (e.Args[14].ToString() == "IMMUNE") { WoWUnit unit = e.DestUnit; if (unit != null && !unit.IsPlayer) { CLULogger.TroubleshootLog("{0} is immune to {1} spell school", unit.Name, e.SpellSchool); SpellImmunityManager.Add(unit.Entry, e.SpellSchool); } } break; case "SPELL_AURA_REFRESH": if (e.SourceGuid == StyxWoW.Me.Guid) { if (e.SpellId == 1822) { Classes.Druid.Common.RakeMultiplier = 1; //TF if (StyxWoW.Me.HasAura(5217)) { Classes.Druid.Common.RakeMultiplier = Classes.Druid.Common.RakeMultiplier * 1.15; } //Savage Roar if (StyxWoW.Me.HasAura(127538)) { Classes.Druid.Common.RakeMultiplier = Classes.Druid.Common.RakeMultiplier * 1.3; } //Doc if (StyxWoW.Me.HasAura(108373)) { Classes.Druid.Common.RakeMultiplier = Classes.Druid.Common.RakeMultiplier * 1.25; } } if (e.SpellId == 1079) { Classes.Druid.Common.ExtendedRip = 0; Classes.Druid.Common.RipMultiplier = 1; //TF if (StyxWoW.Me.HasAura(5217)) { Classes.Druid.Common.RipMultiplier = Classes.Druid.Common.RipMultiplier * 1.15; } //Savage Roar if (StyxWoW.Me.HasAura(127538)) { Classes.Druid.Common.RipMultiplier = Classes.Druid.Common.RipMultiplier * 1.3; } //Doc if (StyxWoW.Me.HasAura(108373)) { Classes.Druid.Common.RipMultiplier = Classes.Druid.Common.RipMultiplier * 1.25; } } } break; case "SPELL_AURA_APPLIED": if (e.SourceGuid == StyxWoW.Me.Guid) { if (e.SpellId == 1822) { Classes.Druid.Common.RakeMultiplier = 1; //TF if (StyxWoW.Me.HasAura(5217)) { Classes.Druid.Common.RakeMultiplier = Classes.Druid.Common.RakeMultiplier * 1.15; } //Savage Roar if (StyxWoW.Me.HasAura(127538)) { Classes.Druid.Common.RakeMultiplier = Classes.Druid.Common.RakeMultiplier * 1.3; } //Doc if (StyxWoW.Me.HasAura(108373)) { Classes.Druid.Common.RakeMultiplier = Classes.Druid.Common.RakeMultiplier * 1.25; } } if (e.SpellId == 1079) { Classes.Druid.Common.ExtendedRip = 0; Classes.Druid.Common.RipMultiplier = 1; //TF if (StyxWoW.Me.HasAura(5217)) { Classes.Druid.Common.RipMultiplier = Classes.Druid.Common.RipMultiplier * 1.15; } //Savage Roar if (StyxWoW.Me.HasAura(127538)) { Classes.Druid.Common.RipMultiplier = Classes.Druid.Common.RipMultiplier * 1.3; } //Doc if (StyxWoW.Me.HasAura(108373)) { Classes.Druid.Common.RipMultiplier = Classes.Druid.Common.RipMultiplier * 1.25; } } } break; case "SPELL_AURA_REMOVED": if (e.SourceGuid == StyxWoW.Me.Guid) { if (e.SpellId == 1822) { Classes.Druid.Common.RakeMultiplier = 0; } if (e.SpellId == 1079) { Classes.Druid.Common.ExtendedRip = 0; Classes.Druid.Common.RipMultiplier = 0; } } break; } }
/// <summary> /// Adds our current target to our listOfHealableUnits /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void addHealableUnit_Click(object sender, EventArgs e) { try { // Add a couple of HealableUnits to the list. if (Me.CurrentTarget != null && HealableUnit.Filter(Me.CurrentTarget)) { if (!HealableUnit.Contains(Me.CurrentTarget)) { CLULogger.TroubleshootLog(" Adding: {0} because of user request.", CLULogger.SafeName(Me.CurrentTarget)); HealableUnit.ListofHealableUnits.Add(new HealableUnit(Me.CurrentTarget)); } } else { MessageBox.Show( "Please make sure that you have a CurrentTarget", "Important Note", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } this.RefreshDataGridView(); } catch (Exception ex) { CLULogger.DiagnosticLog("addHealableUnit_Click : {0}", ex); } }