Beispiel #1
0
 /// <summary>
 ///     Casts spell with selected hitchancepercent.
 /// </summary>
 public static void Cast(this Spell.SpellBase spell, Obj_AI_Base target, float hitchancepercent)
 {
     if (target != null && spell.IsReady() && target.IsKillable(spell.Range))
     {
         var pred = spell.GetPrediction(target);
         if (pred.HitChancePercent >= hitchancepercent || target.IsCC())
         {
             spell.Cast(pred.CastPosition);
         }
     }
 }
Beispiel #2
0
        /// <summary>
        ///     Casts AoE spell with selected hitchance.
        /// </summary>
        public static void CastLineAoE(this Spell.SpellBase spell, Obj_AI_Base target, HitChance hitChance, int hits = 2)
        {
            var skillshot = spell as Spell.Skillshot;

            if (target != null && skillshot != null && skillshot.IsReady() && target.IsKillable(skillshot.Range))
            {
                var pred = spell.GetPrediction(target);
                var rect = new Geometry.Polygon.Rectangle(Player.Instance.ServerPosition, Player.Instance.ServerPosition.Extend(pred.CastPosition, skillshot.Range).To3D(), skillshot.Width);
                if (EntityManager.Heroes.Enemies.Count(e => e != null && e.IsKillable(skillshot.Range) && skillshot.GetPrediction(e).HitChance >= hitChance && rect.IsInside(skillshot.GetPrediction(e).CastPosition)) >= hits)
                {
                    skillshot.Cast(pred.CastPosition);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        ///     Casts <paramref name="spell" /> with selected hitchance.
        /// </summary>
        public static void Cast(this Spell.SpellBase spell, Obj_AI_Base target, HitChance hitChance)
        {
            if (target == null || !spell.IsReady() || !target.IsKillable(spell.Range))
            {
                return;
            }

            var pred = spell.GetPrediction(target);

            if (pred.HitChance >= hitChance || target.IsCc())
            {
                spell.Cast(pred.CastPosition);
            }
        }
Beispiel #4
0
        /// <summary>
        ///     Attemtps To Cast the spell AoE.
        /// </summary>
        public static bool CastAOE(this Spell.SpellBase spell, int hitcount, float CustomRange = -1, AIHeroClient target = null)
        {
            var skillshot = spell.SetSkillshot();
            var range     = CustomRange.Equals(-1) ? spell.Range : CustomRange;

            if (skillshot.Type == SkillShotType.Circular)
            {
                foreach (var enemy in EntityManager.Heroes.Enemies.Where(e => e.IsKillable(range)))
                {
                    var pred   = spell.GetPrediction(enemy);
                    var circle = new Geometry.Polygon.Circle(pred.CastPosition, skillshot.Width);
                    foreach (var point in circle.Points)
                    {
                        circle = new Geometry.Polygon.Circle(point, skillshot.Width);
                        foreach (var p in circle.Points.OrderBy(a => a.Distance(pred.CastPosition)))
                        {
                            if (p.CountEnemyHeros(skillshot.Width) >= hitcount)
                            {
                                if (target == null)
                                {
                                    Player.CastSpell(spell.Slot, p.To3D());
                                    return(true);
                                }
                                if (target.ServerPosition.IsInRange(p.To3D(), skillshot.Width))
                                {
                                    Player.CastSpell(spell.Slot, p.To3D());
                                    return(true);
                                }
                            }
                        }
                    }
                }
            }

            if (skillshot.Type == SkillShotType.Linear)
            {
                return(target != null?spell.CastLineAoE(target, HitChance.Low, hitcount)
                           : EntityManager.Heroes.Enemies.Where(e => e.IsKillable(spell.Range)).Select(e => spell.CastLineAoE(e, HitChance.Low, hitcount)).FirstOrDefault());
            }

            return(skillshot.CastIfItWillHit(hitcount));
        }