Exemple #1
0
 /// <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);
     }
 }
Exemple #2
0
        public void CombatLogEventsOnStarted(object o)
        {
            try
            {
                CLULogger.TroubleshootLog("CombatLogEvents: Connected to the Grid");

                // means spell was cast (did not hit target yet)
                CLULogger.TroubleshootLog("CombatLogEvents: Connect UNIT_SPELLCAST_SUCCEEDED");
                Lua.Events.AttachEvent("UNIT_SPELLCAST_SUCCEEDED", this.OnSpellFired_ACK);

                // user got stunned, silenced, kicked...
                CLULogger.TroubleshootLog("CombatLogEvents: Connect UNIT_SPELLCAST_INTERRUPTED");
                Lua.Events.AttachEvent("UNIT_SPELLCAST_INTERRUPTED", this.OnSpellFired_NACK);

                // misc fails, due to stopcast, spell spam, etc.
                CLULogger.TroubleshootLog("CombatLogEvents: Connect UNIT_SPELLCAST_FAILED");
                Lua.Events.AttachEvent("UNIT_SPELLCAST_FAILED", this.OnSpellFired_FAIL);
                CLULogger.TroubleshootLog("CombatLogEvents: Connect UNIT_SPELLCAST_FAILED_QUIET");
                Lua.Events.AttachEvent("UNIT_SPELLCAST_FAILED_QUIET", this.OnSpellFired_FAIL);
                CLULogger.TroubleshootLog("CombatLogEvents: Connect UNIT_SPELLCAST_STOP");
                Lua.Events.AttachEvent("UNIT_SPELLCAST_STOP", this.OnSpellFired_FAIL);
                CLULogger.TroubleshootLog("CombatLogEvents: Connect PARTY_MEMBERS_CHANGED");
                Lua.Events.AttachEvent("PARTY_MEMBERS_CHANGED", this.HandlePartyMembersChanged);

                if ((CLU.LocationContext != GroupLogic.Battleground && CLU.LocationContext != GroupLogic.PVE) || TalentManager.CurrentSpec == WoWSpec.DruidFeral)
                {
                    AttachCombatLogEvent();
                }
            }
            catch (Exception ex)
            {
                CLULogger.DiagnosticLog("HandlePartyMembersChanged : {0}", ex);
            }
        }
Exemple #3
0
 /// <summary>
 /// Resets individual MultiCastMacro int's from one(1) to zero(0)
 /// </summary>
 /// <param name="Which">Spell name</param>
 public static void resetMacro(string Which)
 {
     try
     {
         Lua.DoString(Which + " = 0;");
     }
     catch
     {
         CLULogger.DiagnosticLog("Lua failed in Macro.resetMacro");
     }
 }
Exemple #4
0
        /*--------------------------------------------------------
         * Spells
         *--------------------------------------------------------
         */

        /// <summary>Returns the Pet spell cooldown using Timespan (00:00:00.0000000)
        /// gtfo if the Pet dosn't have the spell.</summary>
        /// <param name="name">the name of the spell to check for</param>
        /// <returns>The spell cooldown.</returns>
        public static TimeSpan PetSpellCooldown(string name)
        {
            WoWPetSpell petAction = PetSpells.FirstOrDefault(p => p.ToString() == name);

            if (petAction == null || petAction.Spell == null)
            {
                return(TimeSpan.Zero);
            }

            CLULogger.DiagnosticLog(" [PetSpellCooldown] {0} : {1}", name, petAction.Spell.CooldownTimeLeft);
            return(petAction.Spell.CooldownTimeLeft);
        }
Exemple #5
0
        /// <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);
        }
Exemple #6
0
 /// <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);
     }
 }
Exemple #7
0
        // 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);
            }
        }
Exemple #8
0
        /// <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);
            }
        }
Exemple #9
0
        /// <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");
            }
        }
Exemple #10
0
        /// <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");
            }
        }
Exemple #11
0
        /// <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);
            }
        }
Exemple #12
0
        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);
            }
        }
Exemple #13
0
        /// <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);
            }
        }
Exemple #14
0
        /// <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);
            }
        }
Exemple #15
0
        /// <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);
        }
Exemple #16
0
        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);
            }
        }
Exemple #17
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);
     }
 }
Exemple #18
0
 /// <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);
     }
 }
Exemple #19
0
        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);
            }
        }
Exemple #20
0
        /// <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");
                }
            }
        }
Exemple #21
0
        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);
                        }
                    }
                }
            }
        }
Exemple #22
0
        private void OnSpellFired(bool success, bool spellCast, LuaEventArgs raw)
        {
            var args   = raw.Args;
            var player = Convert.ToString(args[0]);

            if (player != "player")
            {
                return;
            }

            // get the english spell name, not the localized one!
            var spellId    = Convert.ToInt32(args[4]);
            var spellName  = WoWSpell.FromId(spellId).Name;
            var sourceGuid = ulong.Parse(args[3].ToString().Replace("0x", string.Empty), NumberStyles.HexNumber);

            if (!success && spellCast)
            {
                CLULogger.DiagnosticLog("Woops, '{0}' cast failed: {1}", spellName, raw.EventName);
            }

            // if the spell is locked, let's extend it (spell travel time + client lag) / or reset it...
            if (Locks.ContainsKey(spellName))
            {
                if (success)
                {
                    // yay!
                    Locks[spellName] = DateTime.Now.AddSeconds(ClientLag + 4.0);
                }
                else
                {
                    if (spellCast)
                    {
                        // interrupted while casting
                        Locks[spellName] = DateTime.Now;
                    }
                    else
                    {
                        // failed to cast it. moar spam!
                        Locks[spellName] = DateTime.Now;
                    }
                }
            }

            // We need to 'sleep' for these spells. Otherwise, we'll end up double-casting them. Which will cause issues
            switch (spellName)
            {
            case "Rejuvenation":
            case "Lifebloom":
            case "Regrowth":
            case "Nourish":
            case "Healing Touch":
            case "Remove Corruption":
            case "Holy Light":
            case "Holy Radiance":
            case "Divine Light":
            case "Holy Shock":
                CLULogger.DiagnosticLog("Sleeping for heal success. ({0})", spellName);
                StyxWoW.SleepForLagDuration();
                break;

            case "Nature's Swiftness":
                CLULogger.DiagnosticLog("PrevNaturesSwiftness. ({0})", spellName);
                if (sourceGuid == StyxWoW.Me.Guid)
                {
                    Classes.Druid.Common.PrevNaturesSwiftness = spellId == 132158;
                }
                break;
            }
        }