コード例 #1
0
ファイル: TreeFactory.cs プロジェクト: IdcNoob/Ensage
        public Tree GetChaseTree(
            Hero hero,
            Target target,
            TimberChain timberChain,
            float maxDistanceToEnemy,
            float minDistanceToHero)
        {
            var castRange = timberChain.GetCastRange();
            var targetPosition = target.GetPosition();

            var targetDistance = target.GetDistance(hero.Position);
            var ignoreMaxDistance = targetDistance > castRange + 200;

            var delay = Game.RawGameTime + timberChain.CastPoint + Game.Ping / 1000;
            var trees = GetAvailableTrees(hero, targetPosition, castRange, delay, timberChain.Speed).ToList();

            return
                trees.Where(
                    x =>
                    (ignoreMaxDistance
                     || x.Distance2D(
                         TimberPrediction.PredictedXYZ(
                             target,
                             timberChain.CastPoint + x.Distance2D(targetPosition) / timberChain.Speed))
                     <= maxDistanceToEnemy
                     || (target.Hero.GetTurnTime(x.Position) <= 0 && x.Distance2D(targetPosition) < 600))
                    && x.Distance2D(hero) >= minDistanceToHero)
                    .FirstOrDefault(
                        z =>
                        trees.Where(x => !x.Equals(z))
                            .All(
                                x =>
                                x.Distance2D(hero) > 150 && !IsPointOnLine(x.Position, hero.Position, z.Position, 25)));
        }
コード例 #2
0
ファイル: TimberPrediction.cs プロジェクト: IdcNoob/Ensage
        public static Vector3 PredictedXYZ(Target target, float delay)
        {
            if (IsIdle(target.Hero))
            {
                return target.Position;
            }

            var targetSpeed = new Vector3();
            if (!LastRotRDictionary.ContainsKey(target.Handle))
            {
                LastRotRDictionary.Add(target.Handle, target.RotationRad);
            }

            var straightTime = StraightTime(target.Hero);
            if (straightTime > 180)
            {
                LastRotRDictionary[target.Handle] = target.RotationRad;
            }

            LastRotRDictionary[target.Handle] = target.RotationRad;
            if ((target.ClassID == ClassID.CDOTA_Unit_Hero_StormSpirit
                 || target.ClassID == ClassID.CDOTA_Unit_Hero_Rubick)
                && target.HasModifier("modifier_storm_spirit_ball_lightning"))
            {
                var ballLightning = target.FindSpell("storm_spirit_ball_lightning", true);
                var firstOrDefault =
                    ballLightning.AbilitySpecialData.FirstOrDefault(x => x.Name == "ball_lightning_move_speed");
                if (firstOrDefault != null)
                {
                    var ballSpeed = firstOrDefault.GetValue(ballLightning.Level - 1);
                    var newpredict = target.Vector3FromPolarAngle() * (ballSpeed / 1000f);
                    targetSpeed = newpredict;
                }
            }
            else
            {
                targetSpeed = target.Vector3FromPolarAngle() * (target.MovementSpeed / 1000f);
            }

            var v = target.GetPosition() + targetSpeed * delay;
            return new Vector3(v.X, v.Y, 0);
        }
コード例 #3
0
ファイル: TreeFactory.cs プロジェクト: IdcNoob/Ensage
        public Vector3 GetBlinkPosition(
            Target target,
            Vector3 hero,
            float distance,
            float radius,
            bool whirlingDeathCanBeCasted)
        {
            var tree =
                allTrees.OrderBy(x => x.Distance2D(target.Position))
                    .FirstOrDefault(
                        x =>
                        x.Distance2D(target.Position) <= radius * 1.9 && x.Distance2D(hero) <= distance
                        && NavMesh.GetCellFlags(x.Position).HasFlag(NavMeshCellFlags.Tree));

            return tree != null && whirlingDeathCanBeCasted
                       ? new Vector3(
                             (target.Position.X + tree.Position.X) / 2,
                             (target.Position.Y + tree.Position.Y) / 2,
                             target.Position.Z)
                       : target.GetPosition();
        }