Exemplo n.º 1
0
        public static Sequence GetSequence()
        {
            try
            {
                var PreWalk = new BehaviorAction(() => Player.IsDead ? BehaviorState.Failure : BehaviorState.Success);

                var GetTarget = new BehaviorAction(
                    () =>
                {
                    //  Console.WriteLine("GetTarget");
                    //FollowTarget = Program.Allies.FirstOrDefault(x => !Program.IsBadFollowTarget(x));
                    FollowTarget = TargetPriority.GetPriorityHero();
                    return(FollowTarget.IsValidTarget(float.MaxValue, false)
                            ? BehaviorState.Success
                            : BehaviorState.Failure);
                });

                //recall logic
                var FollowRecallLogic = new Inverter(new Sequence(FollowTarget.IsPlayerRecalling(),
                                                                  new Inverter(Utils.IsEnemyNear(500)), Recalling.RecallSequence));

                // don't move to follow when you are already moving to it
                var IsOTW =
                    new Conditional(
                        () =>
                        Player.GetWaypoints().Count > 3 &&
                        Player.GetWaypoints().Last().Distance(FollowTarget.Position) < 200);

                //if follow target is recalling do somethign else

                var SetOrbwalkerMode = new BehaviorAction(
                    () =>
                {
                    //       Console.WriteLine("SETMODE");
                    Orbwalking.OrbwalkingMode.Combo.SetOrbwalkingMode();
                    return(BehaviorState.Success);
                });

                var GetFollowPosition = new BehaviorAction(
                    () =>
                {
                    //     Console.WriteLine("GetFollowPosition");
                    // if follow unit is headed towards (and within x range of ) enemy decrease this range
                    var pos = FollowTarget.ServerPosition.To2D();
                    if (FollowTarget.GetWaypoints().Count > 1)
                    {
                        var rng = new Random(Environment.TickCount);
                        var rnd = rng.Next(100);
                        if (rnd % 3 == 0)
                        {
                            pos = FollowTarget.GetWaypoints().Last();
                        }
                        else if (rnd % 2 == 0)
                        {
                            pos = FollowTarget.GetWaypoints()[2];
                        }
                    }
                    //var pos = FollowTarget.GetWaypoints().Count > 1 ? FollowTarget.GetWaypoints().Last() : FollowTarget.Position.To2D();

                    var c  = new Geometry.Circle(pos, 500);
                    var c2 = new Geometry.Circle(pos, 300);
                    c.ToPolygon().Draw(Color.Red, 2);
                    c2.ToPolygon().Draw(Color.Blue, 2);

                    var poly = Geometry.ClipPolygons(new List <Geometry.Polygon> {
                        c.ToPolygon(), c2.ToPolygon()
                    });
                    var ran        = new Random();
                    FollowPosition = poly.GetRandomPoint(LastMovePosition, ran.Next(50, 70), ran.Next(100, 200));
                    return(FollowPosition == Vector3.Zero ? BehaviorState.Failure : BehaviorState.Success);
                });
                //new Inverter(IsOTW),
                //Utils.IsPlayerFullHealth()),

                var Follow = new BehaviorAction(
                    () =>
                {
                    Console.WriteLine("FOLLOW");
                    FollowPosition.SetOrbwalkingPoint();
                    return(BehaviorState.Success);
                });


                var NeedRandom = new Conditional(() => Orbwalking.GetLastMoveTime() > 300);

                var RandomWalk = new BehaviorAction(
                    () =>
                {
                    ObjectManager.Player.IssueOrder(GameObjectOrder.MoveTo, Player.Position.Randomize(50, 100));
                    return(BehaviorState.Success);
                });

                var RandomSequence = new Selector(NeedRandom, RandomWalk);

                var FollowSequence = new Sequence(GetTarget, SetOrbwalkerMode, GetFollowPosition, Follow);
                return(new Sequence(PreWalk, FollowRecallLogic, FollowSequence)); //, RandomSequence));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            //PreWalk,
            return(new Sequence());
            // IsOTW,
            //Utils.Dead()
            // ShouldFollow,
            //atfountain
            //, RandomLogic));
        }