コード例 #1
0
        public Waypoint(MPos position, WaypointLocation location, WaypointType type)
        {
            Position = position;
            Location = location;

            Type = type;
        }
コード例 #2
0
ファイル: MapUtils.cs プロジェクト: abc013/WarriorsSnuggery
        public static Waypoint RandomPositionFromEdge(Random random, int distanceFromMapEdge, MPos bounds)
        {
            MPos             pos      = MPos.Zero;
            WaypointLocation location = WaypointLocation.CENTER;

            var side = (byte)random.Next(4);

            switch (side)
            {
            case 0:
                pos      = new MPos(distanceFromMapEdge, distanceFromMapEdge + random.Next(bounds.Y - distanceFromMapEdge * 2));
                location = WaypointLocation.TOP;
                break;

            case 1:
                pos      = new MPos(distanceFromMapEdge + random.Next(bounds.X - distanceFromMapEdge * 2), distanceFromMapEdge);
                location = WaypointLocation.LEFT;
                break;

            case 2:
                pos      = new MPos(bounds.X - distanceFromMapEdge - 1, distanceFromMapEdge + random.Next(bounds.Y - distanceFromMapEdge * 2));
                location = WaypointLocation.BOTTOM;
                break;

            case 3:
                pos      = new MPos(distanceFromMapEdge + random.Next(bounds.X - distanceFromMapEdge * 2), bounds.Y - distanceFromMapEdge - 1);
                location = WaypointLocation.RIGHT;
                break;
            }

            return(new Waypoint(pos, location, WaypointType.END));
        }
コード例 #3
0
        MPos getPosNearBorder(MPos spawnArea, out WaypointLocation location)
        {
            var pos = MPos.Zero;

            location = WaypointLocation.CENTER;
            // Picking a random side, 0 = x, 1 = y, 2 = -x, 3 = -y;
            var side = (byte)Random.Next(4);

            switch (side)
            {
            case 0:
                pos      = new MPos(Random.Next(2), Random.Next(spawnArea.X));
                location = WaypointLocation.TOP;
                break;

            case 1:
                pos      = new MPos(Random.Next(spawnArea.Y), Random.Next(2));
                location = WaypointLocation.LEFT;
                break;

            case 2:
                pos      = new MPos(spawnArea.X - Random.Next(2), Random.Next(spawnArea.X));
                location = WaypointLocation.BOTTOM;
                break;

            case 3:
                pos      = new MPos(Random.Next(spawnArea.X), spawnArea.Y - Random.Next(2));
                location = WaypointLocation.RIGHT;
                break;
            }

            return(pos);
        }
コード例 #4
0
ファイル: Player.cs プロジェクト: serioth/FFXIV_Bot_STABLE
        public string RunToPoint(Waypoint wp, Func <bool> run)
        {
            bool runToEnemy = run.Method.Name.Contains("AttackTarget");
            var  treshold   = runToEnemy ? ExpFarming.AttackingDistance : ExpFarming.WaypointTurnDistance;

            //Reset Camera
            //MemoryHandler.HumanKeyPress(MemoryApi.KeyCode.NUMLOCK);
            //Thread.Sleep(Utils.getRandom(100,300));
            //MemoryHandler.HumanKeyPress(MemoryApi.KeyCode.END);
            //Thread.Sleep(Utils.getRandom(100, 300));
            //MemoryHandler.HumanKeyPress(MemoryApi.KeyCode.NUMLOCK);

            while ((wp.Distance(WaypointLocation) > treshold) && run())
            {
                if (runToEnemy)
                {
                    wp = Target.WaypointLocation;
                }

                if (HP == 0)
                {
                    return("died");
                }

                if (runToEnemy && !ExpFarming.Aggro)
                {
                    Globals.Instance.KeySenderInstance.SendKey(Keys.NumPad8, KeySender.ModifierControl);
                    Thread.Sleep(Utils.getRandom(100, 200));
                    Character aggressor = GetTarget(_targetTwoBaseOffset);
                    if (aggressor != null && Target.ID != aggressor.ID)
                    {
                        Globals.Instance.ExpFamingLogger.Log("Retargeting aggressor...");
                        ExpFarming.Aggro = true;
                        wp     = aggressor.WaypointLocation;
                        Target = aggressor;
                    }
                }

                Face(wp);

                //Code to jump over obstacles if stuck
                double tempDistance = WaypointLocation.Distance(wp);
                Thread.Sleep(500);
                var jumpCount = 0;
                while (!(WaypointLocation.Distance(wp) < tempDistance * 0.99) && run())
                {
                    Globals.Instance.ExpFamingLogger.Log("Jumping...");
                    Thread.Sleep(Utils.getRandom(800, 1200)); //TO avoid hitting jump to rapidly

                    Globals.Instance.KeySenderInstance.SendKey(Keys.Space);

                    jumpCount++;

                    if (jumpCount == 5)
                    {
                        return("stuck");
                    }
                }
            }
            return(ExpFarming.Running ? "point reached" : "running cancelled");
        }
コード例 #5
0
ファイル: Player.cs プロジェクト: serioth/FFXIV_Bot_STABLE
        //Runs to and attacks an enemy
        public string AttackTarget(Character target)
        {
            Target = target;
            Globals.Instance.ExpFamingLogger.Log("Targeting: " + Target.Name);

            //Wait between tab and lock, and provide time to stop RunningHandler
            //PROBLEM: This also makes player wait after one enemy is dead and you search for next
            Thread.Sleep(Utils.getRandom(200, 400));

            //Lock onto enemy
            //Globals.Instance.KeySenderInstance.SendKey(Keys.NumPad5);

            //Thread.Sleep(Utils.getRandom(200, 400)); //After locking onto enemy, wait with running towards it

            if (!ExpFarming.Aggro)
            {
                WaitForRegen();
            }

            if (!ExpFarming.StandStill)
            {
                Globals.Instance.KeySenderInstance.SendDown(Keys.W);
                ExpFarming.Running = true;
                string runResult = RunToPoint(Target.WaypointLocation, () => ExpFarming.Attacking);
                ExpFarming.Running = false;
                Globals.Instance.KeySenderInstance.SendUp(Keys.W);
                switch (runResult)
                {
                case ("stuck"): return("Stuck. Jumping not successful.");

                case ("running cancelled"): return("attack cancelled");
                }
            }

            if (WaypointLocation.Distance(Target.WaypointLocation) > ExpFarming.MaxPullingDistance)
            {
                return("target too far");
            }

            //Summoner battle preparation
            //Here we look up in dictionary each time, that's ok as it is not a heavy operation
            //Thread.Sleep(Utils.getRandom(200, 400));

            Globals.Instance.KeySenderInstance.SendKey(Keys.NumPad0);

            //Keep attacking until target is dead (not targetting anymore)
            while (Target.HP > 0 && ExpFarming.Attacking)
            {
                if (RestoreHP() == "escape")
                {
                    return("escape");
                }

                if (PetInfo.PetHP < 100)
                {
                    UseSkill(Globals.Instance.SkillDictionary["SummonII"]);
                }

                if (Target.HP <= 0)
                {
                    break;
                }

                if (RestoreHP() == "escape")
                {
                    return("escape");
                }
                UseSkill(Globals.Instance.SkillDictionary["Aetherflow"]);
                UseSkill(Globals.Instance.SkillDictionary["EnergyDrain"]);
                UseSkill(Globals.Instance.SkillDictionary["Virus"]);

                if (RestoreHP() == "escape")
                {
                    return("escape");
                }
                UseSkill(Globals.Instance.SkillDictionary["Miasma"]);
                if (Target.HP <= 0)
                {
                    break;
                }

                if (RestoreHP() == "escape")
                {
                    return("escape");
                }
                UseSkill(Globals.Instance.SkillDictionary["Bio"]);
                if (Target.HP <= 0)
                {
                    break;
                }

                if (RestoreHP() == "escape")
                {
                    return("escape");
                }
                UseSkill(Globals.Instance.SkillDictionary["Ruin"]);
            }
            //No longer targetting the enemy, which means it must be dead

            return(ExpFarming.Attacking ? "target defeated" : "attack cancelled");
        }
コード例 #6
0
        void addWaypoint(Piece piece, MPos pos, WaypointLocation location = WaypointLocation.CENTER)
        {
            var position = pos + new MPos(piece.Size.X / 2, piece.Size.Y / 2);

            Loader.Waypoints.Add(new Waypoint(position, location, WaypointType.END));
        }