Example #1
0
        private static float PredictedHealth(Unit unit, int time)
        {
            var TimeToCheck = Environment.TickCount + time;

            var rangedProjSpeed = 900;

            var allyMeleeCreeps  = ObjectManager.GetEntities <Creep>().Where(creep => creep.IsAlive && creep.IsValid && creep.Team == LocalHero.Team && creep.IsMelee).ToList();
            var enemyMeleeCreeps = ObjectManager.GetEntities <Creep>().Where(creep => creep.IsAlive && creep.IsValid && creep.Team == LocalHero.GetEnemyTeam() && creep.IsMelee).ToList();

            var allyRangedCreeps  = ObjectManager.GetEntities <Creep>().Where(creep => creep.IsAlive && creep.IsValid && creep.Team == LocalHero.Team && creep.IsRanged).ToList();
            var enemyRangedCreeps = ObjectManager.GetEntities <Creep>().Where(creep => creep.IsAlive && creep.IsValid && creep.Team == LocalHero.GetEnemyTeam() && creep.IsRanged).ToList();

            if (unit.Team == LocalHero.GetEnemyTeam()) //Enemy Creep
            {
                var rangedDamage = 0f;
                var meleeDamage  = 0f;

                foreach (var allyCreep in allyRangedCreeps)
                {
                    var projDamage = 0f;

                    Ray FrontPos = new Ray(allyCreep.NetworkPosition, allyCreep.Vector3FromPolarAngle());

                    BoundingSphere unitPos = new BoundingSphere(unit.NetworkPosition, 25);

                    if (FrontPos.Intersects(unitPos) && Math.Max(0, allyCreep.Distance2D(unit)) < (allyCreep.AttackRange + allyCreep.HullRadius / 2) && StartedAttack(allyCreep))
                    {
                        //Game.PrintMessage("INTERSECTION DETECTED", MessageType.LogMessage);

                        var arrivalTime = Environment.TickCount + 1000 * Math.Max(0, allyCreep.Distance2D(unit)) / rangedProjSpeed + 1000 * MinionAAData.GetAttackPoint(allyCreep);

                        if (arrivalTime < TimeToCheck)
                        {
                            projDamage = GetPhysDamage(allyCreep, unit);
                        }
                    }

                    rangedDamage += projDamage;
                }

                foreach (var allyCreep in allyMeleeCreeps)
                {
                    var hitDamage = 0f;

                    Ray FrontPos = new Ray(allyCreep.NetworkPosition, allyCreep.Vector3FromPolarAngle());

                    BoundingSphere unitPos = new BoundingSphere(unit.NetworkPosition, 25);

                    if (FrontPos.Intersects(ref unitPos) && Math.Max(0, allyCreep.Distance2D(unit)) < allyCreep.GetAttackRange() && StartedAttack(allyCreep))
                    {
                        var arrivalTime = Environment.TickCount + MinionAAData.GetAttackPoint(allyCreep) * 1000;

                        if (arrivalTime < TimeToCheck)
                        {
                            hitDamage = GetPhysDamage(allyCreep, unit);
                        }
                    }

                    meleeDamage += hitDamage;
                }

                return(Math.Max(0, unit.Health - (rangedDamage + meleeDamage)));
            }

            if (unit.Team == LocalHero.Team) //Ally Creep
            {
                var rangedDamage = 0f;
                var meleeDamage  = 0f;

                foreach (var enemyCreep in enemyRangedCreeps)
                {
                    var projDamage = 0f;

                    Ray FrontPos = new Ray(enemyCreep.NetworkPosition, enemyCreep.Vector3FromPolarAngle());

                    BoundingSphere unitPos = new BoundingSphere(unit.NetworkPosition, 25);

                    if (FrontPos.Intersects(ref unitPos) && Math.Max(0, enemyCreep.Distance2D(unit)) < (enemyCreep.AttackRange + enemyCreep.HullRadius / 2) && StartedAttack(enemyCreep))
                    {
                        //Game.PrintMessage("INTERSECTION DETECTED", MessageType.LogMessage);

                        var arrivalTime = Environment.TickCount + 1000 * Math.Max(0, enemyCreep.Distance2D(unit)) / rangedProjSpeed + 1000 * MinionAAData.GetAttackPoint(enemyCreep);

                        if (arrivalTime < TimeToCheck)
                        {
                            projDamage = GetPhysDamage(enemyCreep, unit);
                        }
                    }

                    rangedDamage += projDamage;
                }

                foreach (var enemyCreep in enemyMeleeCreeps)
                {
                    var hitDamage = 0f;

                    Ray FrontPos = new Ray(enemyCreep.NetworkPosition, enemyCreep.Vector3FromPolarAngle());

                    BoundingSphere unitPos = new BoundingSphere(unit.NetworkPosition, 25);

                    if (FrontPos.Intersects(ref unitPos) && Math.Max(0, enemyCreep.Distance2D(unit)) < enemyCreep.GetAttackRange() && StartedAttack(enemyCreep))
                    {
                        var arrivalTime = Environment.TickCount + MinionAAData.GetAttackPoint(enemyCreep) * 1000;

                        if (arrivalTime < TimeToCheck)
                        {
                            hitDamage = GetPhysDamage(enemyCreep, unit);
                        }
                    }

                    meleeDamage += hitDamage;
                }

                return(Math.Max(0, unit.Health - (rangedDamage + meleeDamage)));
            }

            return(unit.Health);
        }
Example #2
0
        private static void MinionAAInfoMethod()
        {
            if (PossibleMinion != null)
            {
                NearMeleeCreeps =
                    ObjectManager.GetEntities <Creep>()
                    .Where(
                        creep =>
                        creep.IsAlive && creep.IsMelee && creep.IsValid &&
                        creep.Distance2D(PossibleMinion) <= creep.GetAttackRange() &&
                        creep.Team == PossibleMinion.GetEnemyTeam())
                    .ToList();

                NearRangedCreeps =
                    ObjectManager.GetEntities <Creep>()
                    .Where(
                        creep =>
                        creep.IsAlive && !creep.IsMelee && creep.IsValid &&
                        creep.Distance2D(PossibleMinion) <= (creep.AttackRange + creep.HullRadius / 2) &&
                        creep.Team == PossibleMinion.GetEnemyTeam())
                    .ToList();

                if (NearMeleeCreeps.Any())
                {
                    foreach (Creep creep in NearMeleeCreeps)
                    {
                        if (StartedAttack(creep))
                        {
                            minionAttackPointList.Add(creep.Handle);

                            var creepAttackPoint     = MinionAAData.GetAttackPoint(creep) * 1000;
                            var creepAttackBackswing = MinionAAData.GetAttackBackswing(creep) * 1000;

                            DelayAction.Add(creepAttackPoint, () =>
                            {
                                minionAttackPointList.Remove(creep.Handle);
                                minionAttackBackswingList.Add(creep.Handle);
                            });

                            DelayAction.Add(creepAttackPoint + creepAttackBackswing, () =>
                            {
                                minionAttackBackswingList.Remove(creep.Handle);
                            });
                        }
                    }
                }

                if (NearRangedCreeps.Any())
                {
                    foreach (Creep creep in NearRangedCreeps)
                    {
                        if (StartedAttack(creep))
                        {
                            minionAttackPointList.Add(creep.Handle);

                            var creepAttackPoint     = MinionAAData.GetAttackPoint(creep) * 1000;
                            var creepAttackBackswing = MinionAAData.GetAttackBackswing(creep) * 1000;

                            DelayAction.Add(creepAttackPoint, () =>
                            {
                                minionAttackPointList.Remove(creep.Handle);
                                minionAttackBackswingList.Add(creep.Handle);
                            });

                            DelayAction.Add(creepAttackPoint + creepAttackBackswing, () =>
                            {
                                minionAttackBackswingList.Remove(creep.Handle);
                            });
                        }
                    }
                }
            }
        }