Beispiel #1
0
        public static bool UnderTurretMode()
        {
            var nearestTurret = TurretAttackManager.GetNearestTurretData(Player, TurretAttackManager.TurretTeam.Ally);

            if (nearestTurret != null && nearestTurret.Turret.IsValid && nearestTurret.Turret.Distance(Player) + Player.AttackRange * 1.1 <= 950)
            {
                return(true);
            }

            return(false);
        }
Beispiel #2
0
        public static Vector3 DashKite(Obj_AI_Base target, float range, int enemyRange = 400)
        {
            var pos = Vector3.Zero;

            for (var i = 140; i < 360; i += 20)
            {
                var dir      = Global.Player.Orientation.To2D();
                var angleRad = Maths.DegreeToRadian(i);
                var rot      = (Global.Player.ServerPosition.To2D() + range * dir.Rotated((float)angleRad)).To3D();

                var turret = TurretAttackManager.GetNearestTurretData(Global.Player, TurretAttackManager.TurretTeam.Enemy);
                if (rot.CountEnemyHeroesInRange(enemyRange) != 0) //|| turret != null && turret.TurretActive && !turret.LastTarget.IsHero && turret.Turret.ServerPosition.Distance(target.ServerPosition) <= 1500)
                {
                    continue;
                }

                pos = rot;
            }
            return(pos);
        }
Beispiel #3
0
        public AttackableUnit GetUnderTurret()
        {
            var attackable = ObjectManager.Get <AttackableUnit>().Where(this.IsValidAttackableObject);

            var nearestTurret = TurretAttackManager.GetNearestTurretData(Player, TurretAttackManager.TurretTeam.Ally);

            if (nearestTurret != null)
            {
                var attackableUnits = attackable as AttackableUnit[] ?? attackable.ToArray();
                var underTurret     = attackableUnits.Where(x => x.ServerPosition.Distance(nearestTurret.Turret.ServerPosition) < 900 && x.IsValidAutoRange());

                if (underTurret.Any())
                {
                    var tData = TurretAttackManager.GetTurretData(nearestTurret.Turret.NetworkId);
                    if (tData != null && tData.TurretActive)
                    {
                        var tTarget = tData.LastTarget;
                        if (tTarget.IsValidAutoRange())
                        {
                            var attacks = tData.Attacks.Where(x => !x.Inactive);

                            foreach (var attack in attacks)
                            {
                                //turret related
                                var arrival = attack.PredictedLandTime;
                                var eta     = arrival - Game.TickCount;
                                var tDmg    = tData.Turret.GetAutoAttackDamage(tTarget);

                                //var tWillKill = tDmg > tTarget.Health;
                                var numTurretAutosToKill = (int)Math.Ceiling(tTarget.Health / tDmg);
                                var turretDistance       = tData.Turret.Distance(tTarget) - Player.BoundingRadius - tTarget.BoundingRadius;
                                var tCastDelay           = tData.Turret.AttackCastDelay * 1000;
                                var tTravTime            = turretDistance / tData.Turret.BasicAttack.MissileSpeed * 1000;
                                var tTotalTime           = tCastDelay + tTravTime + Game.Ping / 2f;

                                //myattack related
                                var castDelay = Player.AttackCastDelay * 1000;
                                //var minDelay = castDelay;
                                var dist      = Player.Distance(tTarget) - Player.BoundingRadius - tTarget.BoundingRadius;
                                var travTime  = dist / Player.BasicAttack.MissileSpeed * 1000;
                                var totalTime = (int)(castDelay + travTime + Game.Ping / 2f);

                                //minion hpred
                                var tMinionDmgPredHealth = HealthPrediction.Instance.GetPrediction(tTarget, totalTime);

                                //myattack
                                const int ExtraBuffer = 50;
                                //if total time > turret attack arrival time by buffer (can be early/late)
                                var canReachSooner = totalTime - eta > ExtraBuffer;

                                var myAutoDmg = this.GetRealAutoAttackDamage(tTarget);

                                //if my attk reach sooner than turret & my auto can kill it
                                if (canReachSooner && myAutoDmg >= tMinionDmgPredHealth)
                                {
                                    return(tTarget);
                                }

                                var remHealth = tMinionDmgPredHealth - tDmg;
                                //var tNextAttackReachTime = tData.LastFireTime + tData.Turret.AttackDelay * 1000 + tCastDelay - Game.Ping / 2f;
                                //var myAttackReachTime = Game.TickCount + totalTime;
                                //var iReachSooner = myAttackReachTime - tNextAttackReachTime > 50;

                                //Minion wont die
                                if (remHealth > 0)
                                {
                                    if (remHealth <= myAutoDmg)
                                    {
                                        return(null);
                                    }

                                    if (totalTime - tTotalTime < 50)
                                    {
                                        return(null);
                                    }

                                    for (var i = 1; i <= numTurretAutosToKill; i++)
                                    {
                                        var dmg    = i * tDmg;
                                        var health = tTarget.Health - dmg;
                                        if (health > 0 && health < myAutoDmg)
                                        {
                                            break;
                                        }

                                        if (i == numTurretAutosToKill)
                                        {
                                            return(tTarget);
                                        }
                                    }
                                }

                                //Turret will kill min and nothing i can do about it
                                else
                                {
                                    foreach (var min in attackableUnits)
                                    {
                                        if (min.NetworkId == tTarget.NetworkId)
                                        {
                                            continue;
                                        }

                                        var minBase = min as Obj_AI_Base;
                                        if (minBase == null)
                                        {
                                            continue;
                                        }

                                        //myattack related
                                        var castDelay1 = Player.AttackCastDelay * 1000;
                                        var dist1      = Player.Distance(min) - Player.BoundingRadius - min.BoundingRadius;
                                        var travTime1  = dist1 / Player.BasicAttack.MissileSpeed * 1000;
                                        var totalTime1 = (int)(castDelay1 + travTime1 + Game.Ping / 2f);

                                        var dmg1  = this.GetRealAutoAttackDamage(minBase);
                                        var pred1 = HealthPrediction.Instance.GetPrediction(minBase, totalTime1);
                                        if (dmg1 > pred1)
                                        {
                                            return(min);
                                        }
                                    }
                                }
                            }

                            /*
                             * if (!attacks.Any())
                             * {
                             *  var target = tData.LastTarget;
                             *  if (tData.LastTarget != null)
                             *  {
                             *      var castDelay1 = Player.AttackCastDelay * 1000;
                             *      var dist1 = Player.Distance(target) - Player.BoundingRadius - target.BoundingRadius;
                             *      var travTime1 = (dist1 / Player.BasicAttack.MissileSpeed) * 1000;
                             *      int totalTime1 = (int)(castDelay1 + travTime1 + Game.Ping / 2);
                             *      var dmg1 = this.GetRealAutoAttackDamage(target);
                             *      var pred = HealthPrediction.Instance.GetPrediction(target, totalTime1);
                             *
                             *      if (pred <= dmg1)
                             *      {
                             *          return target;
                             *      }
                             *  }
                             * }
                             */
                        }
                    }
                }
            }

            return(null);
        }