Example #1
0
        public static void UpdateStats(int loot, int kills, int death)
        {
            loots  += loot;
            _kills += kills;
            _death += death;
            TimeSpan duration           = DateTime.Now - _startTime;
            string   timeToLevel        = string.Empty;
            double   xpPerHourBySession = 0;

            _xpCurrent = ObjectManager.MyPlayer.Experience;
            if (_xpCurrent < _xpInitial)
            {
                Logging.Write("Ding!");
                _xpInitial = ObjectManager.MyPlayer.Experience;
                _xpCurrent = _xpInitial;
                _startTime = DateTime.Now;
                if (GrindingSettings.ShouldTrain)
                {
                    Navigator.Stop();
                    MoveHelper.ReleaseKeys();
                    ShouldTrain = false;
                    ShouldTrain = GrindingShouldTrain.ShouldTrain();
                }
            }
            else
            {
                double xpGained = (_xpCurrent - _xpInitial);
                double time     = (duration.Milliseconds); // hours
                if (time != 0.0)
                {
                    try
                    {
                        int    toLevelXp   = ObjectManager.MyPlayer.NextLevel - ObjectManager.MyPlayer.Experience;
                        double sessionTime = duration.TotalSeconds;
                        double seconds     = (toLevelXp * sessionTime / xpGained);
                        xpPerHourBySession = Math.Round(xpGained / sessionTime * 3600, 0);
                        TimeSpan t = TimeSpan.FromSeconds(seconds);

                        timeToLevel = string.Format("{0:D2}h:{1:D2}m:{2:D2}s", t.Hours, t.Minutes, t.Seconds);
                    }
                    catch
                    {
                        //Empty
                    }
                }
            }
            LazyForm.Loots       = loots;
            LazyForm.Deaths      = _death;
            LazyForm.Kills       = _kills;
            LazyForm.TimeToLevel = timeToLevel;
            LazyForm.UpdateStatsText(string.Format("Loots:{0} -Kills:{1} -Deaths:{2} -XP/H: {3}-TTL:{4} ", loots, _kills,
                                                   _death, xpPerHourBySession, timeToLevel));
        }
Example #2
0
        public bool EngineStart()
        {
            GrindingSettings.LoadSettings();
            if (!ObjectManager.InGame)
            {
                Logging.Write(LogType.Info, "Enter game before starting the bot");
                return(false);
            }
            if (ObjectManager.MyPlayer.IsDead && ObjectManager.MyPlayer.IsGhost)
            {
                Logging.Write(LogType.Info, "Please ress before starting the bot");
                return(false);
            }
            if (CurrentProfile == null)
            {
                Logging.Write(LogType.Info, "Please load a profile");
                return(false);
            }
            Navigator  = new GrindingNavigator();
            Navigation = new GrindingNavigation(CurrentProfile);
            GrindingSettings.LoadSettings();
            ToTown.SetToTown(false);
            switch (CurrentMode)
            {
            case Mode.TestToTown:
                Logging.Write(LogType.Warning,
                              "Starting Grinding engine in TestToTown mode, next start will be in normal mode THIS IS TODO");
                //TODO
                break;

            default:
                _states = new List <MainState>
                {
                    new StatePull(),
                    new StateLoot(),
                    new StateMoving(),
                    new StateTrainer(),
                    new StateResting(),
                    new StateResurrect(),
                    new StateCombat(),
                    new StateToTown(),
                    new StateVendor(),
                };
                break;
            }
            Stuck.Run();
            CurrentMode = Mode.Normal;
            CombatHandler.CombatStatusChanged += CombatChanged;
            CloseWindows();
            loots      = 0;
            _kills     = 0;
            _death     = 0;
            _xpInitial = ObjectManager.MyPlayer.Experience;
            _startTime = DateTime.Now;
            if (GrindingSettings.ShouldTrain)
            {
                ShouldTrain = GrindingShouldTrain.ShouldTrain();
            }
            PullController.Start();
            return(true);
        }