コード例 #1
0
        public static bool Safe_CastSpell(WoWUnit unit, int spellId, SpellRange chkRng, SpellWait chkWait)
        {
            try
            {
                WoWSpell spell = WoWSpell.FromId(spellId);
                if (spell != null)
                    return Safe_CastSpell(unit, spell, chkRng, chkWait);
            }
            catch
            {
                ;
            }

            Slog("Error:  attempt to cast unknown spell #{0}", spellId);
            return false;
        }
コード例 #2
0
        public static bool Safe_CastSpell(WoWUnit unit, string sSpellName, SpellRange chkRng, SpellWait chkWait)
        {
            WoWSpell spell = null;

            try
            {
                // spell = SpellManager.Spells[sSpellName];
                spell = SpellManager.Spells[sSpellName];
                System.Diagnostics.Debug.Assert(spell != null);
            }
            catch (ThreadAbortException) { throw; }
            catch (Exception e)
            {
                Log(Color.Red, "An Exception occured. Check debug log for details.");
                Logging.WriteDebug(">>> HB EXCEPTION in SpellManager.Spells[" + sSpellName + "]");
                Logging.WriteDebug(">>> Spell '" + sSpellName + "' believed to be " + (SpellManager.HasSpell(sSpellName) ? "KNOWN" : "UNKNOWN") + " was used ");
                Logging.WriteException(e);
                throw;
                // return false;
            }

            return Safe_CastSpell(unit, spell, chkRng, chkWait);
        }
コード例 #3
0
 public static bool Safe_CastSpell(string sSpellName, SpellRange chkRng, SpellWait chkWait)
 {
     return Safe_CastSpell(null, sSpellName, chkRng, chkWait);
 }
コード例 #4
0
        public static bool Safe_CastSpell(WoWUnit unit, WoWSpell spell, SpellRange chkRng, SpellWait chkWait)
        {
            bool bCastSuccessful = false;

            // enoughPower = (_me.GetCurrentPower(spell.PowerType) >= spell.PowerCost);
            if (MeSilenced())
                ;
            else if (chkRng == SpellRange.Check && spell.HasRange
                && ((unit != null && unit.Distance >= spell.MaxRange) || (unit == null && _me.GotTarget && _me.CurrentTarget.Distance >= spell.MaxRange)))
                Dlog("Safe_CastSpell: Spell '{0}' has max range of {1:F1} but target is {2:F1} yds away - not cast", spell.Name, spell.MaxRange, unit != null ? unit.Distance : (_me.GotTarget ? _me.CurrentTarget.Distance : -1));
            else
            {
                WaitForCurrentSpell(spell);
                if (!SpellManager.CanCast(spell))
                {
                    Dlog("Safe_CastSpell: cannot cast spell '{0}' yet - cd={1}, gcd={2}, casting={3}, cost={4}, mana={5}, ", 
                        spell.Name, 
                        spell.Cooldown, 
                        SpellManager.GlobalCooldown, 
                        _me.IsCasting,
                        spell.PowerCost,
                        _me.CurrentMana
                        );
                }
                //      else if (SpellManager.GlobalCooldown)
                //      Dlog("status:  GCD is active -- not cast");
                //      else if (spell.Cooldown)
                //      Dlog("status:  spell [{0}] on cooldown - not cast", spell.Name );
                //      else if (!enoughPower)
                //      Dlog("warning:  not enough mana/energy for spell - " + spell.Name);
                //      else if ( !SpellManager.CastableSpell( spell ))
                //      Dlog("status:  missing proc/reagent/totem to cast spell - " + spell.Name);
                //      else if (!SpellManager.CanCast( spell.Id ))                    // unclear what this spell does other than periodically
                //      Dlog("warning:  cannot cast spell {0} due to missing proc/reagent/totem", spell.Name  );       // .. block casting which otherwise can occur... disabled
                else
                {
                    double udist = -1;
                    double uhealth = -1;
                  
                    try
                    {
                        if (unit == null)
                            bCastSuccessful = SpellManager.Cast(spell);
                        else
                        {
                            udist = unit.Distance;
                            uhealth = unit.HealthPercent;
                            bCastSuccessful = SpellManager.Cast(spell, unit);
                        }
                    }

                    catch (ThreadAbortException) { throw; }
                    catch (Exception e)
                    {
                        Log(Color.Red, "An Exception occured. Check debug log for details.");
                        Logging.WriteDebug("HB EXCEPTION in spell.Cast([" + spell.Id + ":" + spell.Name + "])");
                        Logging.WriteException(e);
                        return false;
                    }

                    unitLastSpellTarget = unit;

                    if (!bCastSuccessful)
                        Dlog("Safe_CastSpell: cast of {0} failed", spell.Name);
                    else
                    {
                        string info = "";
                        System.Drawing.Color clr = spell.Mechanic == WoWSpellMechanic.Healing ?
                            Color.ForestGreen : Color.DodgerBlue;

                        // spell.Mechanic always equals None currently
                        if (unit != null) // && spell.Mechanic == WoWSpellMechanic.Healing)
                            info = string.Format(" on {0} at {1:F1} yds at {2:F1}%", Safe_UnitName(unit), udist, uhealth);

                        Log(clr, "*" + spell.Name + info);

                        StyxWoW.SleepForLagDuration();
                        if (chkWait == SpellWait.Complete)
                        {
                            WaitForCurrentSpell(null);
                        }
                    }
                }
            }

            return bCastSuccessful;
        }
コード例 #5
0
        public static bool Safe_CastSpell(WoWUnit unit, int spellId, SpellRange chkRng, SpellWait chkWait)
        {
            try
            {
                WoWSpell spell = WoWSpell.FromId(spellId);
                if (spell != null)
                {
                    return(Safe_CastSpell(unit, spell, chkRng, chkWait));
                }
            }
            catch
            {
                ;
            }

            Slog("Error:  attempt to cast unknown spell #{0}", spellId);
            return(false);
        }
コード例 #6
0
 public static bool Safe_CastSpell(string sSpellName, SpellRange chkRng, SpellWait chkWait)
 {
     return(Safe_CastSpell(null, sSpellName, chkRng, chkWait));
 }
コード例 #7
0
        public static bool Safe_CastSpell(WoWUnit unit, WoWSpell spell, SpellRange chkRng, SpellWait chkWait)
        {
            bool bCastSuccessful = false;

            // enoughPower = (_me.GetCurrentPower(spell.PowerType) >= spell.PowerCost);
            if (MeSilenced())
            {
                ;
            }
            else if (chkRng == SpellRange.Check && spell.HasRange &&
                     ((unit != null && unit.Distance >= spell.MaxRange) || (unit == null && _me.GotTarget && _me.CurrentTarget.Distance >= spell.MaxRange)))
            {
                Dlog("Safe_CastSpell: Spell '{0}' has max range of {1:F1} but target is {2:F1} yds away - not cast", spell.Name, spell.MaxRange, unit != null ? unit.Distance : (_me.GotTarget ? _me.CurrentTarget.Distance : -1));
            }
            else
            {
                WaitForCurrentSpell(spell);
                if (!SpellManager.CanCast(spell))
                {
                    Dlog("Safe_CastSpell: cannot cast spell '{0}' yet - cd={1}, gcd={2}, casting={3}, cost={4}, mana={5}, ",
                         spell.Name,
                         spell.Cooldown,
                         SpellManager.GlobalCooldown,
                         _me.IsCasting,
                         spell.PowerCost,
                         _me.CurrentMana
                         );
                }
                //      else if (SpellManager.GlobalCooldown)
                //      Dlog("status:  GCD is active -- not cast");
                //      else if (spell.Cooldown)
                //      Dlog("status:  spell [{0}] on cooldown - not cast", spell.Name );
                //      else if (!enoughPower)
                //      Dlog("warning:  not enough mana/energy for spell - " + spell.Name);
                //      else if ( !SpellManager.CastableSpell( spell ))
                //      Dlog("status:  missing proc/reagent/totem to cast spell - " + spell.Name);
                //      else if (!SpellManager.CanCast( spell.Id ))                    // unclear what this spell does other than periodically
                //      Dlog("warning:  cannot cast spell {0} due to missing proc/reagent/totem", spell.Name  );       // .. block casting which otherwise can occur... disabled
                else
                {
                    double udist   = -1;
                    double uhealth = -1;

                    try
                    {
                        if (unit == null)
                        {
                            bCastSuccessful = SpellManager.Cast(spell);
                        }
                        else
                        {
                            udist           = unit.Distance;
                            uhealth         = unit.HealthPercent;
                            bCastSuccessful = SpellManager.Cast(spell, unit);
                        }
                    }

                    catch (ThreadAbortException) { throw; }
                    catch (Exception e)
                    {
                        Log(Color.Red, "An Exception occured. Check debug log for details.");
                        Logging.WriteDebug("HB EXCEPTION in spell.Cast([" + spell.Id + ":" + spell.Name + "])");
                        Logging.WriteException(e);
                        return(false);
                    }

                    unitLastSpellTarget = unit;

                    if (!bCastSuccessful)
                    {
                        Dlog("Safe_CastSpell: cast of {0} failed", spell.Name);
                    }
                    else
                    {
                        string info = "";
                        System.Drawing.Color clr = spell.Mechanic == WoWSpellMechanic.Healing ?
                                                   Color.ForestGreen : Color.DodgerBlue;

                        // spell.Mechanic always equals None currently
                        if (unit != null) // && spell.Mechanic == WoWSpellMechanic.Healing)
                        {
                            info = string.Format(" on {0} at {1:F1} yds at {2:F1}%", Safe_UnitName(unit), udist, uhealth);
                        }

                        Log(clr, "*" + spell.Name + info);

                        StyxWoW.SleepForLagDuration();
                        if (chkWait == SpellWait.Complete)
                        {
                            WaitForCurrentSpell(null);
                        }
                    }
                }
            }

            return(bCastSuccessful);
        }
コード例 #8
0
        public static bool Safe_CastSpell(WoWUnit unit, string sSpellName, SpellRange chkRng, SpellWait chkWait)
        {
            WoWSpell spell = null;

            try
            {
                // spell = SpellManager.Spells[sSpellName];
                spell = SpellManager.Spells[sSpellName];
                System.Diagnostics.Debug.Assert(spell != null);
            }
            catch (ThreadAbortException) { throw; }
            catch (Exception e)
            {
                Log(Color.Red, "An Exception occured. Check debug log for details.");
                Logging.WriteDebug(">>> HB EXCEPTION in SpellManager.Spells[" + sSpellName + "]");
                Logging.WriteDebug(">>> Spell '" + sSpellName + "' believed to be " + (SpellManager.HasSpell(sSpellName) ? "KNOWN" : "UNKNOWN") + " was used ");
                Logging.WriteException(e);
                throw;
                // return false;
            }

            return(Safe_CastSpell(unit, spell, chkRng, chkWait));
        }