コード例 #1
0
ファイル: Common.cs プロジェクト: aash/Singular
        /// <summary>
        /// Crowd Control all targets within 25 yds that are attacking (if possible.)
        /// if not, attempt to Kite
        /// </summary>
        /// <returns></returns>
        public static Composite CreateDruidCrowdControl()
        {
            return new PrioritySelector(

            #region Crowd Control to Self-Heal

            // Incapacitating Roar - 10 yds, all 3 secs
            // Mighty Bash - Melee, 5 secs
            // Cyclone - 20 yds, 6 secds

                new Action(r =>
                {
                    _CrowdControlTarget = null;
                    if (_CrowdControlGuid != WoWGuid.Empty)
                    {
                        _CrowdControlTarget = ObjectManager.GetObjectByGuid<WoWUnit>(_CrowdControlGuid);
                        if (_CrowdControlTarget != null)
                        {
                            if (Spell.DoubleCastContainsAny(_CrowdControlTarget, "Incapacitating Roar", "Mighty Bash", "Cyclone"))
                            {
                            }
                            else if (_CrowdControlTarget.IsCrowdControlled())
                            {
                            }
                            else if (_CrowdControlTarget.IsMelee() && _CrowdControlTarget.SpellDistance() > 25)
                            {
                                _CrowdControlGuid = WoWGuid.Empty;
                                _CrowdControlTarget = null;
                            }
                        }
                    }

                    _CrowdControlTarget = Unit.UnitsInCombatWithUsOrOurStuff(25)
                        .Where(u => u.CurrentTargetGuid == Me.Guid
                            && u.Guid != _CrowdControlGuid
                            && u.Combat && !u.IsCrowdControlled())
                        .OrderByDescending(k => k.IsPlayer)
                        .ThenBy(k => k.Guid == Me.CurrentTargetGuid)
                        .ThenBy(k => k.DistanceSqr)
                        .FirstOrDefault();

                    _CrowdControlGuid = _CrowdControlTarget == null ? WoWGuid.Empty : _CrowdControlTarget.Guid;
                    return RunStatus.Failure;
                }),

                new Decorator(
                    ret => _CrowdControlTarget != null,
                    new PrioritySelector(
                        Spell.Buff("Incapacitating Roar", on => _CrowdControlTarget, req => Unit.UnfriendlyUnits(10).Count(u => u.CurrentTargetGuid == Me.Guid) > 1),
                        Spell.Buff("Mighty Bash", on => _CrowdControlTarget, req => Me.IsSafelyFacing(_CrowdControlTarget)),
                        new Sequence(
                            Spell.Cast("Cyclone", on => _CrowdControlTarget, req => !Unit.NearbyUnfriendlyUnits.Any(u => u.HasMyAura("Cyclone")), cancel => false),
                            new Action(r => Spell.UpdateDoubleCast("Cyclone", _CrowdControlTarget))
                            ),
                        Spell.Buff("Disorienting Roar", on => _CrowdControlTarget, req => Unit.UnfriendlyUnits(10).Count(u => u.CurrentTargetGuid == Me.Guid) > 0)
                        )
                    ),

            #endregion

            #region Avoidance

            // attackers within 8 yds and we need heal? try to knock them away
                Spell.Cast(
                    "Typhoon",
                    req =>
                    {
                        if (!Spell.CanCastHack("Typhoon"))
                            return false;
                        int attackers = Unit.UnfriendlyUnits(15)
                            .Where(u => u.CurrentTargetGuid == Me.Guid
                                && u.Combat
                                && !u.IsCrowdControlled()
                                && (u.IsMelee() || u.CastingSpellId == 1949 /*Hellfire*/ || u.HasAura("Immolation Aura"))
                                && Me.IsSafelyFacing(u, 90f))
                            .Count();
                        if (attackers < 1)
                            return false;
                        Logger.Write(LogColor.Hilite, "^Typhoon: knock-back and daze {0} attackers", attackers);
                        return true;
                    }),

                // no knock back? lets root and move away if settings allow
                new Decorator(
                    ret => Unit.NearbyUnitsInCombatWithMeOrMyStuff.Any(u => u.SpellDistance() < 8),
                    CreateDruidAvoidanceBehavior(CreateDruidSlowMeleeBehavior(), null, null)
                    )

            #endregion

                );
        }