当前位置: 首页>>代码示例>>C#>>正文


C# WoWUnit.SafeName方法代码示例

本文整理汇总了C#中WoWUnit.SafeName方法的典型用法代码示例。如果您正苦于以下问题:C# WoWUnit.SafeName方法的具体用法?C# WoWUnit.SafeName怎么用?C# WoWUnit.SafeName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WoWUnit的用法示例。


在下文中一共展示了WoWUnit.SafeName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LogCast

 public static void LogCast(string sname, WoWUnit unit, double health, double dist)
 {
     if (unit.IsMe)
         Logger.Write("Casting {0} on Me @ {1:F1}%", sname, health);
     else
         Logger.Write("Casting {0} on {1} @ {2:F1}% at {3:F1} yds", sname, unit.SafeName(), health, dist);
 }
开发者ID:superkhung,项目名称:SingularMod3,代码行数:7,代码来源:Spell.cs

示例2: Face

 public static void Face(WoWUnit mob)
 {
     DateTime stoptime = DateTime.Now.AddSeconds(1);
     if (StyxWoW.Me.Location == mob.Location)
     {
         KeyboardManager.PressKey((char)Keys.Back);
         Thread.Sleep(50);
         KeyboardManager.ReleaseKey((char)Keys.Back);
         return;
     }
     while (!StyxWoW.Me.IsSafelyFacing(mob) && DateTime.Now < stoptime)
     {
         FTWLogger.debug(Color.Violet, "Facing {0}", mob.SafeName());
         mob.Face();
         Thread.Sleep(10);
     }
 }
开发者ID:psmyth1,项目名称:code-samples,代码行数:17,代码来源:FTWCoreMovement.cs

示例3: On_Cast


//.........这里部分代码省略.........
            if (false)
            {
                // Check power requirements
                List<string> values = Lua.GetReturnValues(String.Format("return GetSpellInfo({0})", spell.Id), "SpellInfo.lua");
                //string[] vars = {"name", "rank", "icon", "cost", "isFunnel", "powerType", "castTime", "minRange", "maxRange"};
                int powerType = Int32.Parse(values[5]);
                int powerCost = Int32.Parse(values[3]);
                string[] powertypes = { "mana", "rage", "focus", "energy",
                                        "happiness", "runes", "runic power", "soul shards",
                                        "eclipse", "holy power", "alternate power", "dark force",
                                        "chi", "shadow orbs", "burning embers", "demonic fury"
                                      };
                if (StyxWoW.Me.UnitPower(powerType) < powerCost)
                {
                    FTWLogger.log(Color.Orange, "NOT ENOUGH {0} - Requires: {1}, but I have: {2}", powertypes[powerType], powerCost, StyxWoW.Me.UnitPower(powerType));
                    MyTimer.Stop(fnname);
                    return false;
                }
            }

            if (!spell.IsSelfOnlySpell)
            {
                if (target == null)
                {
                    FTWLogger.log(Color.Orange, "Can't cast {0} on null target!", spell.Name);
                    if (debugspell)
                        FTWLogger.log(ds, "Null target");
                    MyTimer.Stop(fnname);
                    return false;
                }
                double dist = target.Distance; // target.DistanceCalc();
                if ((spell.MinRange > 0 || spell.MaxRange > 0) && !(dist >= spell.MinRange && dist <= spell.MaxRange))
                {
                    FTWLogger.log(Color.Orange, "Can't cast spell {0} {1} on {2} health {3:0.0} dist {4:0.0} minrange {5} maxrange {6}", spellname, spell.Id, target.SafeName(), target.HealthPercent, target.DistanceCalc(), spell.MinRange, spell.MaxRange);
                    if (debugspell)
                        FTWLogger.log(ds, "Out of range");
                    MyTimer.Stop(fnname);
                    return false;
                }
                if (!target.InLineOfSight)
                {
                    FTWLogger.log(Color.Orange, "Can't cast spell {0} {1} on {2} health {3:0.0} dist {4:0.0} (not in line of sight)", spellname, spell.Id, target.SafeName(), target.HealthPercent, target.DistanceCalc());
                    if (debugspell)
                        FTWLogger.log(ds, "Not in line of sight. Attempts = {0}.", FTWProps.not_in_los_attempts);
                    MyTimer.Stop(fnname);

                    FTWProps.not_in_los_attempts += 1;
                    Navigator.MoveTo(target.Location);
                    Thread.Sleep(2000);
                    return false;
                }

                if (spellname == "Death Pact" && Me.GotAlivePet)
                {
                    Me.Pet.Target();
                    for (int l = 0; l < 2; l++)
                        Thread.Sleep(10);
                }

                if (FTWProps.CastOver.Contains(FTWProps.lastspellcastname))
                    retval = true;
                else if (spell.IsSelfOnlySpell)
                    retval = SpellManager.CanCast(spell, true);
                else
                    retval = SpellManager.CanCast(spell, target, true);
开发者ID:psmyth1,项目名称:code-samples,代码行数:66,代码来源:FTWCoreActions.cs

示例4: ValidUnit

        public static bool ValidUnit(WoWUnit p, bool showReason = false)
        {
            if (p == null || !p.IsValid)
                return false;

            if (StyxWoW.Me.IsInInstance && IgnoreMobs.Contains(p.Entry))
            {
                if (showReason) Logger.Write(invalidColor, "invalid attack unit {0} is an Instance Ignore Mob", p.SafeName());
                return false;
            }

            // Ignore shit we can't select
            if (!p.CanSelect )
            {
                if (showReason) Logger.Write(invalidColor, "invalid attack unit {0} cannot be Selected", p.SafeName());
                return false;
            }

            // Ignore shit we can't attack
            if (!p.Attackable)
            {
                if (showReason) Logger.Write(invalidColor, "invalid attack unit {0} cannot be Attacked", p.SafeName());
                return false;
            }

            // Duh
            if (p.IsDead)
            {
                if (showReason) Logger.Write(invalidColor, "invalid attack unit {0} is already Dead", p.SafeName());
                return false;
            }

            // check for enemy players here as friendly only seems to work on npc's
            if (p.IsPlayer)
                return p.ToPlayer().IsHorde != StyxWoW.Me.IsHorde;

            // Ignore friendlies!
            if (p.IsFriendly)
            {
                if (showReason) Logger.Write(invalidColor, "invalid attack unit {0} is Friendly", p.SafeName());
                return false;
            }

            // Dummies/bosses are valid by default. Period.
            if (p.IsTrainingDummy() || p.IsBoss())
                return true;

            // If it is a pet/minion/totem, lets find the root of ownership chain
            WoWUnit pOwner = GetPlayerParent(p);

            // ignore if owner is player, alive, and not blacklisted then ignore (since killing owner kills it)
            if (pOwner != null && pOwner.IsAlive && !Blacklist.Contains(pOwner, BlacklistFlags.Combat))
            {
                if (showReason) Logger.Write(invalidColor, "invalid attack unit {0} has a Player as Parent", p.SafeName());
                return false;
            }

            // And ignore critters (except for those ferocious ones) /non-combat pets
            if (p.IsNonCombatPet)
            {
                if (showReason) Logger.Write(invalidColor, "{0} is a Noncombat Pet", p.SafeName());
                return false;
            }

            // And ignore critters (except for those ferocious ones) /non-combat pets
            if (p.IsCritter && p.ThreatInfo.ThreatValue == 0 && !p.IsTargetingMyRaidMember)
            {
                if (showReason) Logger.Write(invalidColor, "{0} is a Critter", p.SafeName());
                return false;
            }
            /*
                        if (p.CreatedByUnitGuid != 0 || p.SummonedByUnitGuid != 0)
                            return false;
            */
            return true;
        }
开发者ID:superkhung,项目名称:SingularMod3,代码行数:76,代码来源:Unit.cs

示例5: CreateInterruptBehavior

        /// <summary>Creates an interrupt spell cast composite. This attempts to use spells in order of range (shortest to longest).  
        /// behavior consists only of spells that apply to current toon based upon class, spec, and race
        /// </summary>
        public static Composite CreateInterruptBehavior()
        {
            if ( SingularSettings.Instance.InterruptTarget == CheckTargets.None )
                return new ActionAlwaysFail();

            Composite actionSelectTarget;
            if (SingularSettings.Instance.InterruptTarget == CheckTargets.Current)
                actionSelectTarget = new Action(
                    ret => {
                        WoWUnit u = Me.CurrentTarget;
                        _unitInterrupt = IsInterruptTarget(u) ? u : null;
                        if (_unitInterrupt != null && SingularSettings.Debug)
                            Logger.WriteDebug("Possible Interrupt Target: {0} @ {1:F1} yds casting {2} #{3} for {4} ms", _unitInterrupt.SafeName(), _unitInterrupt.Distance, _unitInterrupt.CastingSpell.Name, _unitInterrupt.CastingSpell.Id, _unitInterrupt.CurrentCastTimeLeft.TotalMilliseconds );
                    }
                    );
            else // if ( SingularSettings.Instance.InterruptTarget == InterruptType.All )
            {
                actionSelectTarget = new Action(
                    ret => {
                        _unitInterrupt = Unit.NearbyUnitsInCombatWithMeOrMyStuff.Where(u => IsInterruptTarget(u)).OrderBy( u => u.Distance ).FirstOrDefault();
                        if (_unitInterrupt != null && SingularSettings.Debug)
                            Logger.WriteDebug("Possible Interrupt Target: {0} @ {1:F1} yds casting {2} #{3} for {4} ms", _unitInterrupt.SafeName(), _unitInterrupt.Distance, _unitInterrupt.CastingSpell.Name, _unitInterrupt.CastingSpell.Id, _unitInterrupt.CurrentCastTimeLeft.TotalMilliseconds);
                        }
                    );
            }

            PrioritySelector prioSpell = new PrioritySelector();

            #region Pet Spells First!

            if (Me.Class == WoWClass.Warlock)
            {
                // this will be either a Optical Blast or Spell Lock
                prioSpell.AddChild(
                    Spell.Cast(
                        "Command Demon",
                        on => _unitInterrupt,
                        ret => _unitInterrupt != null
                            && _unitInterrupt.Distance < 40
                            && Singular.ClassSpecific.Warlock.Common.GetCurrentPet() == WarlockPet.Felhunter
                        )
                    );
            }

            #endregion

            #region Melee Range

            if ( Me.Class == WoWClass.Paladin )
                prioSpell.AddChild( Spell.Cast("Rebuke", ctx => _unitInterrupt));

            if ( Me.Class == WoWClass.Rogue)
            {
                prioSpell.AddChild( Spell.Cast("Kick", ctx => _unitInterrupt));
                prioSpell.AddChild( Spell.Cast("Gouge", ctx => _unitInterrupt, ret => !_unitInterrupt.IsBoss() && Me.IsSafelyFacing(_unitInterrupt)));
            }

            if ( Me.Class == WoWClass.Warrior)
                prioSpell.AddChild( Spell.Cast("Pummel", ctx => _unitInterrupt));

            if ( Me.Class == WoWClass.Monk )
                prioSpell.AddChild( Spell.Cast("Spear Hand Strike", ctx => _unitInterrupt));

            if ( Me.Class == WoWClass.Druid)
            {
                // Spell.Cast("Skull Bash (Cat)", ctx => _unitInterrupt, ret => StyxWoW.Me.Shapeshift == ShapeshiftForm.Cat));
                // Spell.Cast("Skull Bash (Bear)", ctx => _unitInterrupt, ret => StyxWoW.Me.Shapeshift == ShapeshiftForm.Bear));
                prioSpell.AddChild( Spell.Cast("Skull Bash", ctx => _unitInterrupt, ret => StyxWoW.Me.Shapeshift == ShapeshiftForm.Bear || StyxWoW.Me.Shapeshift == ShapeshiftForm.Cat));
                prioSpell.AddChild( Spell.Cast("Mighty Bash", ctx => _unitInterrupt, ret => !_unitInterrupt.IsBoss() && _unitInterrupt.IsWithinMeleeRange));
            }

            if ( Me.Class == WoWClass.DeathKnight)
                prioSpell.AddChild( Spell.Cast("Mind Freeze", ctx => _unitInterrupt));

            if ( Me.Race == WoWRace.Pandaren )
                prioSpell.AddChild( Spell.Cast("Quaking Palm", ctx => _unitInterrupt));

            #endregion

            #region 8 Yard Range

            if ( Me.Race == WoWRace.BloodElf )
                prioSpell.AddChild(Spell.Cast("Arcane Torrent", ctx => _unitInterrupt, req => _unitInterrupt.Distance < 8 && !Unit.NearbyUnfriendlyUnits.Any(u => u.IsSensitiveDamage( 8))));

            if ( Me.Race == WoWRace.Tauren)
                prioSpell.AddChild(Spell.Cast("War Stomp", ctx => _unitInterrupt, ret => _unitInterrupt.Distance < 8 && !_unitInterrupt.IsBoss() && !Unit.NearbyUnfriendlyUnits.Any(u => u.IsSensitiveDamage( 8))));

            #endregion

            #region 10 Yards

            if (Me.Class == WoWClass.Paladin)
                prioSpell.AddChild( Spell.Cast("Hammer of Justice", ctx => _unitInterrupt));

            if (Me.Specialization == WoWSpec.DruidBalance )
                prioSpell.AddChild( Spell.Cast("Hammer of Justice", ctx => _unitInterrupt));

//.........这里部分代码省略.........
开发者ID:superkhung,项目名称:SingularMod3,代码行数:101,代码来源:Common.cs

示例6: CanWeDisengage

        public static bool CanWeDisengage(string spell, Direction dir, int distance)
        {
            if (!SpellManager.HasSpell(spell))
                return false;

            if (DateTime.Now < NextDisengageAllowed)
                return false;

            if (!Me.IsAlive || Me.IsFalling || Me.IsCasting || Me.IsSwimming)
                return false;

            if (Me.Stunned || Me.Rooted || Me.IsStunned() || Me.IsRooted())
                return false;

            if (!Spell.CanCastHack(spell, Me))
                return false;

            mobToGetAwayFrom = SafeArea.NearestEnemyMobAttackingMe;
            if (mobToGetAwayFrom == null)
                return false;

            if (SingularRoutine.CurrentWoWContext == WoWContext.Normal)
            {
                List<WoWUnit> attackers = SafeArea.AllEnemyMobsAttackingMe.ToList();
                if ((attackers.Sum(a => a.MaxHealth) / 3) < Me.MaxHealth && Me.HealthPercent > 40)
                {
                    return false;
                }
            }
            else if (SingularRoutine.CurrentWoWContext == WoWContext.Battlegrounds)
            {
                switch (mobToGetAwayFrom.Class)
                {
                    default:
                        return false;

                    case WoWClass.DeathKnight:
                    case WoWClass.Druid:
                    case WoWClass.Monk:
                    case WoWClass.Paladin:
                    case WoWClass.Rogue:
                    case WoWClass.Shaman:
                        break;
                }
            }

            if (mobToGetAwayFrom.Distance > mobToGetAwayFrom.MeleeDistance() + 3f)
                return false;

            SafeArea sa = new SafeArea();
            sa.MinScanDistance = distance;    // average distance on flat ground
            sa.MaxScanDistance = sa.MinScanDistance;
            sa.RaysToCheck = 36;
            sa.LineOfSightMob = Target;
            sa.MobToRunFrom = mobToGetAwayFrom;
            sa.CheckLineOfSightToSafeLocation = true;
            sa.CheckSpellLineOfSightToMob = false;

            safeSpot = sa.FindLocation();
            if (safeSpot == WoWPoint.Empty)
            {
                Logger.WriteDebug(Color.Cyan, "DIS: no safe landing spots found for {0}", spell);
                return false;
            }

            Logger.WriteDebug(Color.Cyan, "DIS: Attempt safe {0} due to {1} @ {2:F1} yds",
                spell,
                mobToGetAwayFrom.SafeName(),
                mobToGetAwayFrom.Distance);

            return true;
        }
开发者ID:superkhung,项目名称:SingularMod3,代码行数:72,代码来源:Kite.cs

示例7: CastWithLog

 protected void CastWithLog(WoWSpell spell, WoWUnit onTarget)
 {
     CastingSpellTarget = onTarget; // save current spell target, reset by SPELL_CAST_SUCCESS event
     if (onTarget == null)
     {
         Logger.Write(string.Format("Casting {0}", spell.Name));
         SpellManager.Cast(spell);
     }
     else if (spell.Mechanic == WoWSpellMechanic.Healing)
     {
         Logger.Write(string.Format("Casting {0} on {1} @ {2:F1}%", spell.Name, onTarget.SafeName(), onTarget.HealthPercent));
         SpellManager.Cast(spell, onTarget);
     }
     else
     {
         Logger.Write(string.Format("Casting {0} on {1}", spell.Name, onTarget.SafeName()));
         SpellManager.Cast(spell, onTarget);
     }
 }
开发者ID:naacra,项目名称:wowhbbotcracked,代码行数:19,代码来源:SingularRoutine.CompositeHelpers.cs

示例8: IsDisengageNeeded

        public static bool IsDisengageNeeded()
        {
            if (SingularRoutine.CurrentWoWContext == WoWContext.Instances)
                return false;

            if (!Me.IsAlive || Me.IsFalling || Me.IsCasting)
                return false;

            if (Me.Stunned || Me.Rooted || Me.IsStunned() || Me.IsRooted())
                return false;

            if (NextDisengageAllowed > DateTime.Now)
                return false;

            useRocketJump = false;
            if (!Spell.CanCastHack("Disengage", Me))
            {
                if (!SingularSettings.Instance.UseRacials || Me.Race != WoWRace.Goblin || !Spell.CanCastHack("Rocket Jump", Me))
                    return false;

                useRocketJump = true;
            }

            mobToGetAwayFrom = SafeArea.NearestEnemyMobAttackingMe;
            if (mobToGetAwayFrom == null)
                return false;

            if (SingularRoutine.CurrentWoWContext == WoWContext.Normal )
            {
                List<WoWUnit> attackers = SafeArea.AllEnemyMobsAttackingMe.ToList();
                if ((attackers.Sum( a => a.MaxHealth ) / 4) < Me.MaxHealth &&  Me.HealthPercent > 40)
                    return false;
            }
            else if (SingularRoutine.CurrentWoWContext == WoWContext.Battlegrounds)
            {
                switch (mobToGetAwayFrom.Class)
                {
                    default:
                        return false;

                    case WoWClass.DeathKnight:
                    case WoWClass.Druid:
                    case WoWClass.Monk:
                    case WoWClass.Paladin:
                    case WoWClass.Rogue:
                    case WoWClass.Shaman:
                        break;
                }
            }

            if (mobToGetAwayFrom.Distance > mobToGetAwayFrom.MeleeDistance() + 3f)
                return false;

            SafeArea sa = new SafeArea();
            sa.MinScanDistance = TalentManager.HasGlyph("Disengage") ? 21 : 16;    // average disengage distance on flat ground
            sa.MaxScanDistance = sa.MinScanDistance;
            sa.RaysToCheck = 36;
            sa.LineOfSightMob = Target;
            sa.MobToRunFrom = mobToGetAwayFrom;
            sa.CheckLineOfSightToSafeLocation = true;
            sa.CheckSpellLineOfSightToMob = false;

            safeSpot = sa.FindLocation();
            if (safeSpot == WoWPoint.Empty)
            {
                Logger.WriteDebug(Color.Cyan, "DIS: no safe landing spots found for {0}", useRocketJump ? "Rocket Jump" : "Disengage");
                return false;
            }

            Logger.WriteDebug(Color.Cyan, "DIS: Attempt safe {0} due to {1} @ {2:F1} yds",
                useRocketJump ? "Rocket Jump" : "Disengage",
                mobToGetAwayFrom.SafeName(),
                mobToGetAwayFrom.Distance);

            return true;
        }
开发者ID:superkhung,项目名称:SingularMod3,代码行数:76,代码来源:Common.cs

示例9: LogCast

        public static void LogCast(string sname, WoWUnit unit, double health, double dist, bool isHeal = false)
        {
            Color clr;

            if (isHeal)
                clr = LogColor.SpellHeal;
            else
                clr = LogColor.SpellNonHeal;

            if (unit.IsMe)
                Logger.Write(clr, "*{0} on Me @ {1:F1}%", sname, health);
            else
                Logger.Write(clr, "*{0} on {1} @ {2:F1}% at {3:F1} yds", sname, unit.SafeName(), health, dist);
        }
开发者ID:aash,项目名称:Singular,代码行数:14,代码来源:Spell.cs

示例10: Attack

        public static bool Attack(WoWUnit unit)
        {
            if (unit == null || StyxWoW.Me.Pet == null || !IsPetUseAllowed)
                return false;

            if (StyxWoW.Me.Pet.CurrentTargetGuid != unit.Guid && (lastPetAttack != unit.Guid || waitNextPetAttack.IsFinished))
            {
                lastPetAttack = unit.Guid;
                if (SingularSettings.Debug)
                    Logger.WriteDebug("PetAttack: on {0} @ {1:F1} yds", unit.SafeName(), unit.SpellDistance());
                PetManager.CastPetAction("Attack", unit);
                waitNextPetAttack.Reset();
                return true;
            }

            return false;
        }
开发者ID:aash,项目名称:Singular,代码行数:17,代码来源:PetManager.cs

示例11: ValidUnit

        public static bool ValidUnit(WoWUnit p, bool showReason = false)
        {
            if (p == null || !p.IsValid)
                return false;

            if (StyxWoW.Me.IsInInstance && IgnoreMobs.Contains(p.Entry))
            {
                if (showReason) Logger.Write(invalidColor, "invalid attack unit {0} is an Instance Ignore Mob", p.SafeName());
                return false;
            }

            // Ignore shit we can't select
            if (!p.CanSelect )
            {
                if (showReason) Logger.Write(invalidColor, "invalid attack unit {0} cannot be Selected", p.SafeName());
                return false;
            }

            // Ignore shit we can't attack
            if (!p.Attackable)
            {
                if (showReason) Logger.Write(invalidColor, "invalid attack unit {0} cannot be Attacked", p.SafeName());
                return false;
            }

            // Duh
            if (p.IsDead)
            {
                if (showReason) Logger.Write(invalidColor, "invalid attack unit {0} is already Dead", p.SafeName());
                return false;
            }

            // check for enemy players here as friendly only seems to work on npc's
            if (p.IsPlayer)
            {
                WoWPlayer pp = p.ToPlayer();
                if (pp.IsHorde == StyxWoW.Me.IsHorde && !pp.IsHostile)
                {
                    if (showReason)
                        Logger.Write(invalidColor, "invalid attack player {0} not a hostile enemy", p.SafeName());
                    return false;
                }

                if (!pp.CanWeAttack())
                {
                    if (showReason)
                        Logger.Write(invalidColor, "invalid attack player {0} cannot be Attacked currently", p.SafeName());
                    return false;
                }

                return true;
            }

            // Ignore evading NPCs
            if (p.IsEvading())
            {
                if (showReason)
                    Logger.Write(invalidColor, "invalid unit, {0} game flagged as evading", p.SafeName());
                return false;
            }

            // Ignore friendlies!
            if (p.IsFriendly)
            {
                if (showReason) Logger.Write(invalidColor, "invalid attack unit {0} is Friendly", p.SafeName());
                return false;
            }

            // Dummies/bosses are valid by default. Period.
            if (p.IsTrainingDummy() || p.IsBoss())
                return true;

            // If it is a pet/minion/totem, lets find the root of ownership chain
            WoWPlayer pOwner = GetPlayerParent(p);

            // ignore if owner is player, alive, and not blacklisted then ignore (since killing owner kills it)
            // .. following .IsMe check to prevent treating quest mob summoned by us that we need to kill as invalid
            if (pOwner != null && pOwner.IsAlive && !pOwner.IsMe)
            {
                if (!ValidUnit(pOwner))
                {
                    if (showReason)
                        Logger.Write(invalidColor, "invalid attack unit {0} - pets parent not an attackable Player", p.SafeName());
                    return false;
                }
                if (!StyxWoW.Me.IsPvPFlagged)
                {
                    if (showReason)
                        Logger.Write(invalidColor, "valid attackable player {0} but I am not PvP Flagged", p.SafeName());
                    return false;
                }
                if (Blacklist.Contains(pOwner, BlacklistFlags.Combat))
                {
                    if (showReason)
                        Logger.Write(invalidColor, "invalid attack unit {0} - Parent blacklisted for combat", p.SafeName());
                    return false;
                }

                return true;
            }
//.........这里部分代码省略.........
开发者ID:aash,项目名称:Singular,代码行数:101,代码来源:Unit.cs

示例12: CanCastHack

        /// <summary>
        /// CastHack following done because CanCast() wants spell as "Metamorphosis: Doom" while Cast() and aura name are "Doom"
        /// </summary>
        /// <param name="castName"></param>
        /// <param name="onUnit"></param>
        /// <param name="requirements"></param>
        /// <returns></returns>
        public static bool CanCastHack(string castName, WoWUnit unit, bool skipWowCheck = false)
        {
            SpellFindResults sfr;
            if (!SpellManager.FindSpell(castName, out sfr))
            {
                // Logger.WriteDebug("CanCast: spell [{0}] not known", castName);
                return false;
            }
 
            WoWSpell spell = sfr.Override ?? sfr.Original;
            
            // check range
            if (unit != null && !spell.IsSelfOnlySpell && !unit.IsMe)
            {
                if (spell.IsMeleeSpell && !unit.IsWithinMeleeRange)
                {
                    if (SingularSettings.Instance.DebugSpellCanCast )
                        Logger.WriteFile(LogLevel.Diagnostic, "CanCast[{0}]: target @ {1:F1} yds not in melee range", castName, unit.Distance);
                    return false;
                }
                if (spell.HasRange )
                {
                    if (unit.Distance > spell.ActualMaxRange(unit))
                    {
                        if (SingularSettings.Instance.DebugSpellCanCast)
                            Logger.WriteFile(LogLevel.Diagnostic, "CanCast[{0}]: out of range - further than {1:F1}", castName, spell.ActualMaxRange(unit));
                        return false;
                    }
                    if (unit.Distance < spell.ActualMinRange(unit))
                    {
                        if (SingularSettings.Instance.DebugSpellCanCast)
                            Logger.WriteFile(LogLevel.Diagnostic, "CanCast[{0}]: out of range - closer than {1:F1}", castName, spell.ActualMinRange(unit));
                        return false;
                    }
                }

                if (!unit.InLineOfSpellSight)
                {
                    if (SingularSettings.Instance.DebugSpellCanCast)
                        Logger.WriteFile(LogLevel.Diagnostic, "CanCast[{0}]: not in spell line of {1}", castName, unit.SafeName());
                    return false;
                }
            }

            if ((spell.CastTime != 0u || IsFunnel(spell)) && Me.IsMoving && !AllowMovingWhileCasting(spell))
            {
                if (SingularSettings.Instance.DebugSpellCanCast)
                    Logger.WriteFile(LogLevel.Diagnostic, "CanCast[{0}]: cannot cast while moving", castName);
                return false;
            }

            if (Me.ChanneledCastingSpellId == 0)
            {
                uint num = StyxWoW.WoWClient.Latency * 2u;
                if (StyxWoW.Me.IsCasting && Me.CurrentCastTimeLeft.TotalMilliseconds > num)
                {
                    if (SingularSettings.Instance.DebugSpellCanCast)
                        Logger.WriteFile(LogLevel.Diagnostic, "CanCast[{0}]: current cast of {1} has {2:F0} ms left", castName, Me.CurrentCastId, Me.CurrentCastTimeLeft.TotalMilliseconds - num);
                    return false;
                }

                if (spell.CooldownTimeLeft.TotalMilliseconds > num)
                {
                    if (SingularSettings.Instance.DebugSpellCanCast)
                        Logger.WriteFile(LogLevel.Diagnostic, "CanCast[{0}]: still on cooldown for {1:F0} ms", castName, spell.CooldownTimeLeft.TotalMilliseconds - num);
                    return false;
                }
            }

            bool formSwitch = false;
            uint currentPower = Me.CurrentPower;
            if (Me.Class == WoWClass.Druid)
            {
                if (Me.Shapeshift == ShapeshiftForm.Cat || Me.Shapeshift == ShapeshiftForm.Bear || Me.Shapeshift == ShapeshiftForm.DireBear )
                {
                    if ( Me.HealingSpellIds.Contains( spell.Id))
                    {
                        formSwitch = true;
                        currentPower = Me.CurrentMana;
                    }
                    else if (spell.PowerCost >= 100)
                    {
                        formSwitch = true;
                        currentPower = Me.CurrentMana;
                    }
                }
            }

            if (currentPower < (uint) spell.PowerCost)
            {
                if (SingularSettings.Instance.DebugSpellCanCast)
                    Logger.WriteFile(LogLevel.Diagnostic, "CanCast[{0}]: insufficient power (need {1:F0}, have {2:F0} {3})", castName, spell.PowerCost, currentPower, formSwitch ? "Mana in Form" : Me.PowerType.ToString() );
                return false;
//.........这里部分代码省略.........
开发者ID:superkhung,项目名称:SingularMod3,代码行数:101,代码来源:Spell.cs

示例13: CastPetAction

        public static void CastPetAction(string action, WoWUnit on)
        {
            // target is currenttarget, then use simplified version (to avoid setfocus/setfocus
            if (on == StyxWoW.Me.CurrentTarget)
            {
                CastPetAction(action);
                return;
            }

            WoWPetSpell spell = PetSpells.FirstOrDefault(p => p.ToString() == action);
            if (spell == null)
                return;

            Logger.Write(string.Format("[Pet] Casting {0} on {1}", action, on.SafeName()));
            WoWUnit save = StyxWoW.Me.FocusedUnit;
            StyxWoW.Me.SetFocus(on);
            Lua.DoString("CastPetAction({0}, 'focus')", spell.ActionBarIndex + 1);
            StyxWoW.Me.SetFocus( save == null ? 0 : save.Guid );
        }
开发者ID:superkhung,项目名称:SingularMod3,代码行数:19,代码来源:PetManager.cs

示例14: On_PetCast

        public static bool On_PetCast(string spellname, WoWUnit target, bool castnow)
        {
            string fnname = "FTWCore.On_PetCast";
            MyTimer.Start(fnname);
            LocalPlayer Me = StyxWoW.Me;
            WoWPetSpell spell = null;

            // Don't even try to cast if I don't have a pet.
            if (!Me.GotAlivePet)
            {
                MyTimer.Stop(fnname);
                return false;
            }

            foreach (WoWPetSpell sp in StyxWoW.Me.PetSpells)
            {
                if (sp.Action.ToString() == spellname)
                {
                    Lua.DoString("CastPetAction({0})", sp.ActionBarIndex + 1);
                    FTWLogger.log("[Pet] Action = {0}", sp.Action.ToString());
                    break;
                }

                else if (sp.Spell != null && sp.Spell.Name == spellname)
                {
                    spell = sp;
                    break;
                }
            }
            if (spell == null)
            {
                FTWLogger.debug(Color.Gray, "[Pet] Unknown spell {0}", spellname);
                MyTimer.Stop(fnname);
                return false;
            }

            if (FTWCoreStatus.OnPetCooldown(spellname))
            {
                MyTimer.Stop(fnname);
                return false;
            }

            if (!castnow && (Me.Pet.IsCasting || Me.Pet.IsChanneling))
            {
                MyTimer.Stop(fnname);
                return false;
            }

            if (spell.Spell.MinRange > 0 && target.DistanceCalc() < spell.Spell.MinRange)
            {
                FTWLogger.debug(Color.Yellow, "[Pet] Too close to {0} to cast {1}.", target.SafeName(), spell.Spell.Name);
                MyTimer.Stop(fnname);
                return false;
            }
            if (spell.Spell.MaxRange > 0 && target.DistanceCalc() > spell.Spell.MaxRange)
            {
                FTWLogger.debug(Color.Yellow, "[Pet] Too far away to {0} to cast {1}.", target.SafeName(), spell.Spell.Name);
                MyTimer.Stop(fnname);
                return false;
            }

            string strTarget;
            if (target.Guid == StyxWoW.Me.Guid)
                strTarget = "player";
            else if (target.Guid == StyxWoW.Me.Pet.Guid)
                strTarget = "pet";
            else if (target.Guid == StyxWoW.Me.CurrentTargetGuid)
                strTarget = "target";
            else
                strTarget = null;

            if (strTarget == null)
            {
                Lua.DoString("CastPetAction({0})", spell.ActionBarIndex + 1);
                FTWLogger.log("    [Pet] Cast {0}", spell.Spell.Name);
            }
            else
            {
                Lua.DoString("CastPetAction({0}, {1})", spell.ActionBarIndex + 1, strTarget);
                FTWLogger.log("    [Pet] Cast {0} on {1} health {2:0.0} dist {3:0.0}", spell.Spell.Name, strTarget, target.HealthPercent, target.DistanceCalc());
            }

            if (spell.Spell.IsAreaSpell())
            {
                // Area spell
                WoWPoint loc;

                if (spell.Spell.IsSelfOnlySpell)
                    loc = StyxWoW.Me.Location;
                else
                    loc = target.Location;

                DateTime stoptime = DateTime.Now.AddMilliseconds(500);
                while (DateTime.Now < stoptime)
                {
                    if (StyxWoW.Me.CurrentPendingCursorSpell != null)
                        break;
                    Thread.Sleep(10);
                }
                SpellManager.ClickRemoteLocation(loc);
//.........这里部分代码省略.........
开发者ID:psmyth1,项目名称:code-samples,代码行数:101,代码来源:FTWCoreActions.cs

示例15: CastPetAction

        public static void CastPetAction(string action, WoWUnit on)
        {
            WoWPetSpell spell = PetSpells.FirstOrDefault(p => p.ToString() == action);
            if (spell == null)
                return;

            Logger.Write(Color.DeepSkyBlue, "*Pet:{0} on {1} @ {2:F1} yds", action, on.SafeName(), on.SpellDistance());
            if (on.Guid == StyxWoW.Me.CurrentTargetGuid)
            {
                Logger.WriteDebug("CastPetAction: cast [{0}] specifying CurrentTarget", action);
                Lua.DoString("CastPetAction({0}, 'target')", spell.ActionBarIndex + 1);
            }
            else
            {
                WoWUnit save = StyxWoW.Me.FocusedUnit;
                StyxWoW.Me.SetFocus(on);
                Logger.WriteDebug("CastPetAction: cast [{0}] specifying FocusTarget {1}", action, on.SafeName());
                Lua.DoString("CastPetAction({0}, 'focus')", spell.ActionBarIndex + 1);
                StyxWoW.Me.SetFocus(save == null ? WoWGuid.Empty : save.Guid);
            }
        }
开发者ID:aash,项目名称:Singular,代码行数:21,代码来源:PetManager.cs


注:本文中的WoWUnit.SafeName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。