Beispiel #1
0
        /// <summary>
        ///     Returns if the spell will hit the unit when casted.
        /// </summary>
        /// <param name="unit">
        ///     The Target
        /// </param>
        /// <param name="castPosition">
        ///     Cast Position
        /// </param>
        /// <param name="extraWidth">
        ///     Extra Width
        /// </param>
        /// <param name="minHitChance">
        ///     Minimum Hit Chance
        /// </param>
        /// <returns>
        ///     Will Spell Hit
        /// </returns>
        public bool WillHit(
            Obj_AI_Base unit,
            Vector3 castPosition,
            int extraWidth = 0,
            Enumerations.HitChance minHitChance = Enumerations.HitChance.High)
        {
            var unitPosition = this.GetPrediction(unit);

            return(unitPosition.Hitchance >= minHitChance &&
                   this.WillHit(unitPosition.UnitPosition, castPosition, extraWidth));
        }
Beispiel #2
0
        public Spell(SpellSlot slot, bool loadFromGame, Enumerations.HitChance hitChance = Enumerations.HitChance.Medium)
        {
            this.Slot = slot;

            if (!loadFromGame)
            {
                return;
            }

            var spellData = GameObjects.Player.Spellbook.GetSpell(slot).SData;

            this.Range = spellData.CastRange;
            this.Width = spellData.LineWidth.Equals(0) ? spellData.CastRadius : spellData.LineWidth;
            this.Speed = spellData.MissileSpeed;
            this.Delay = spellData.DelayTotalTimePercent;

            this.MinHitChance = hitChance;
        }
Beispiel #3
0
 /// <summary>
 ///     Returns Hit Count
 /// </summary>
 /// <param name="hitChance">
 ///     The HitChance
 /// </param>
 /// <returns>
 ///     Hit Count
 /// </returns>
 public float GetHitCount(Enumerations.HitChance hitChance = Enumerations.HitChance.High)
 {
     return(GameObjects.EnemyHeroes.Select(e => this.GetPrediction(e)).Count(p => p.Hitchance >= hitChance));
 }
Beispiel #4
0
 /// <summary>
 ///     Cast Spell if HitChance is more than the minimum to input HitChance
 /// </summary>
 /// <param name="unit">
 ///     The Target
 /// </param>
 /// <param name="hitChance">
 ///     The HitChance
 /// </param>
 /// <returns>
 ///     Was Spell Casted
 /// </returns>
 public CastStates CastIfHitchanceMinimum(Obj_AI_Base unit, Enumerations.HitChance hitChance)
 {
     return(this.Cast(unit, false, false, -1, hitChance));
 }
Beispiel #5
0
        /// <summary>
        ///     Casts the spell.
        /// </summary>
        /// <param name="unit">Unit to cast on</param>
        /// <param name="exactHitChance">
        ///     Is exact hit chance
        /// </param>
        /// <param name="areaOfEffect">
        ///     Is Area of Effect
        /// </param>
        /// <param name="minTargets">
        ///     Minimum of Targets
        /// </param>
        /// <param name="tempHitChance">
        ///     Temporary HitChance Override
        /// </param>
        /// <returns>
        ///     The <see cref="CastStates" />
        /// </returns>
        public CastStates Cast(
            Obj_AI_Base unit,
            bool exactHitChance = false,
            bool areaOfEffect   = false,
            int minTargets      = -1,
            Enumerations.HitChance tempHitChance = Enumerations.HitChance.None)
        {
            if (!unit.LSIsValid() || !unit.IsVisible || !unit.IsHPBarRendered)
            {
                return(CastStates.InvalidTarget);
            }

            if (!this.IsReady())
            {
                return(CastStates.NotReady);
            }

            if (!this.minManaPercent.Equals(0) && ObjectManager.Player.ManaPercent < this.minManaPercent)
            {
                return(CastStates.LowMana);
            }

            if (this.CastCondition != null && !this.CastCondition())
            {
                return(CastStates.FailedCondition);
            }

            if (!areaOfEffect && minTargets != -1)
            {
                areaOfEffect = true;
            }

            if (!this.IsSkillshot)
            {
                if (this.RangeCheckFrom.LSDistanceSquared(unit.ServerPosition) > this.RangeSqr)
                {
                    return(CastStates.OutOfRange);
                }

                this.LastCastAttemptT = Variables.TickCount;

                return(!GameObjects.Player.Spellbook.CastSpell(this.Slot, unit)
                           ? CastStates.NotCasted
                           : CastStates.SuccessfullyCasted);
            }

            var prediction = this.GetPrediction(unit, areaOfEffect);

            if (minTargets != -1 && prediction.AoeTargetsHitCount <= minTargets)
            {
                return(CastStates.NotEnoughTargets);
            }

            if (prediction.CollisionObjects.Count > 0)
            {
                return(CastStates.Collision);
            }

            if (this.RangeCheckFrom.LSDistanceSquared(prediction.CastPosition) > this.RangeSqr)
            {
                return(CastStates.OutOfRange);
            }

            if (prediction.Hitchance < ((tempHitChance == Enumerations.HitChance.None) ? this.MinHitChance : tempHitChance) ||
                (exactHitChance &&
                 prediction.Hitchance != ((tempHitChance == Enumerations.HitChance.None) ? this.MinHitChance : tempHitChance)))
            {
                return(CastStates.LowHitChance);
            }

            this.LastCastAttemptT = Variables.TickCount;

            if (this.IsChargedSpell)
            {
                if (this.IsCharging)
                {
                    ShootChargedSpell(this.Slot, prediction.CastPosition);
                }
                else
                {
                    this.StartCharging();
                }
            }
            else
            {
                if (!GameObjects.Player.Spellbook.CastSpell(this.Slot, prediction.CastPosition))
                {
                    return(CastStates.NotCasted);
                }
            }

            return(CastStates.SuccessfullyCasted);
        }
Beispiel #6
0
 /// <summary>
 ///     Gets all of the units that this spell can hit that is greater then or equal to the <see cref="HitChance" />
 ///     provided.
 /// </summary>
 /// <param name="minimumHitChance">Minimum HitChance</param>
 /// <returns>
 ///     All of the units that this spell can hit that is greater then or equal to the <see cref="HitChance" />
 ///     provided.
 /// </returns>
 public IEnumerable <Obj_AI_Base> GetUnitsByHitChance(Enumerations.HitChance minimumHitChance = Enumerations.HitChance.High)
 {
     return
         (GameObjects.Enemy.Where(
              unit => this.WillHit(unit, GameObjects.Player.ServerPosition, 0, minimumHitChance)));
 }