public static int CalculatePayment(MissionLocation fromLocation, MissionLocation toLocation,
                                           MissionCargo missionCargo)
        {
            var distance = GetDistance(fromLocation, toLocation);

            return((int)Math.Floor(distance * missionCargo.PayPerUnit));
        }
Exemple #2
0
        private static bool SetRandomMissionData(Player player, MissionCargoVehicleType missionCargoVehicleType)
        {
            player.MissionCargo = MissionCargo.GetRandomCargo(missionCargoVehicleType);
            player.FromLocation = MissionCargo.GetRandomStartLocation(player.MissionCargo);
            player.ToLocation   = MissionCargo.GetRandomEndLocation(player.MissionCargo);

            player.MissionVehicle = (Vehicle)player.Vehicle;
            player.MissionTrailer = (Vehicle)player.Vehicle.Trailer;

            return(true);
        }
        public static void StartRandomMission(Player player)
        {
            if (player.IsDoingMission)
            {
                return;
            }

            player.IsDoingMission = true;

            player.MissionCargo = MissionCargo.GetRandomCargo(MissionCargoVehicleType.MafiaVan);
            player.FromLocation = MissionCargo.GetRandomStartLocation(player.MissionCargo);
            player.ToLocation   = MissionCargo.GetRandomEndLocation(player.MissionCargo);

            player.MissionStep          = 1;
            player.MissionTextDraw.Text = $"~w~Hauling ~b~{player.MissionCargo.Name}~w~ from ~r~{player.FromLocation.Name}~w~ to {player.ToLocation.Name}.";

            player.SetCheckpoint(player.FromLocation.Position, 7.0f);
            player.MissionVehicle     = (Vehicle)player.Vehicle;
            player.MissionVehicleTime = Configuration.Instance.FailMissionSeconds;
            player.SendClientMessage(Color.GreenYellow, $"Pickup the {player.MissionCargo.Name} at {player.FromLocation.Name}.");
        }
Exemple #4
0
        private static bool SetRandomMission(Player player)
        {
            if (!player.IsDriving())
            {
                return(false);
            }

            switch (player.Vehicle.Model)
            {
            case VehicleModelType.Nevada:
            case VehicleModelType.Shamal:
                player.MissionCargo   = MissionCargo.GetRandomCargo(MissionCargoVehicleType.Plane);
                player.FromLocation   = MissionCargo.GetRandomStartLocation(player.MissionCargo);
                player.ToLocation     = MissionCargo.GetRandomEndLocation(player.MissionCargo);
                player.MissionVehicle = (Vehicle)player.Vehicle;

                while (!MissionsController.CheckDistanceBetweenLocations(player.ToLocation, player.FromLocation, 1000.0f))
                {
                    player.ToLocation = MissionCargo.GetRandomEndLocation(player.MissionCargo);
                }

                return(true);

            case VehicleModelType.Maverick:
            case VehicleModelType.Cargobob:
                player.MissionCargo   = MissionCargo.GetRandomCargo(MissionCargoVehicleType.Helicopter);
                player.FromLocation   = MissionCargo.GetRandomStartLocation(player.MissionCargo);
                player.ToLocation     = MissionCargo.GetRandomEndLocation(player.MissionCargo);
                player.MissionVehicle = (Vehicle)player.Vehicle;

                while (!MissionsController.CheckDistanceBetweenLocations(player.ToLocation, player.FromLocation, 1000.0f))
                {
                    player.ToLocation = MissionCargo.GetRandomEndLocation(player.MissionCargo);
                }

                return(true);
            }

            return(false);
        }
Exemple #5
0
        private static List <MissionCargo> GetMissionCargoes(VehicleModelType?playerVehicleModel,
                                                             VehicleModelType?playerVehicleTrailerModel)
        {
            var numberOfCargoes = 0;

            switch (playerVehicleModel)
            {
            case VehicleModelType.Flatbed:
            case VehicleModelType.DFT30:
                return(MissionCargo.GetCargoList(MissionCargoVehicleType.NoTrailer, ref numberOfCargoes));

            case VehicleModelType.CementTruck:
                return(MissionCargo.GetCargoList(MissionCargoVehicleType.CementTruck, ref numberOfCargoes));

            case VehicleModelType.Linerunner:
            case VehicleModelType.Tanker:
            case VehicleModelType.Roadtrain:
                switch (playerVehicleTrailerModel)
                {
                case VehicleModelType.ArticleTrailer:
                case VehicleModelType.ArticleTrailer3:
                    return(MissionCargo.GetCargoList(MissionCargoVehicleType.CargoTrailer, ref numberOfCargoes));

                case VehicleModelType.ArticleTrailer2:
                    return(MissionCargo.GetCargoList(MissionCargoVehicleType.OreTrailer, ref numberOfCargoes));

                case VehicleModelType.PetrolTrailer:
                    return(MissionCargo.GetCargoList(MissionCargoVehicleType.FluidsTrailer,
                                                     ref numberOfCargoes));
                }

                break;
            }

            return(null);
        }
        private static void Timer_Tick(object sender, EventArgs e)
        {
            var isMissionSet = false;
            var random       = new Random();

            if (BonusMission.RandomCargo == null || BonusMission.IsMissionFinished)
            {
                while (!isMissionSet)
                {
                    var index = random.Next(1, MissionCargo.MissionCargoes.Count);
                    BonusMission.RandomCargo = MissionCargo.MissionCargoes[index];

                    switch (BonusMission.RandomCargo.JobCargoVehicleType)
                    {
                    case MissionCargoVehicleType.CargoTrailer:
                    case MissionCargoVehicleType.FluidsTrailer:
                    case MissionCargoVehicleType.OreTrailer:
                    case MissionCargoVehicleType.CementTruck:
                    case MissionCargoVehicleType.NoTrailer:
                        isMissionSet = true;
                        break;
                    }
                }

                BonusMission.RandomFromLocation = MissionCargo.GetRandomStartLocation(BonusMission.RandomCargo);
                BonusMission.RandomToLocation   = MissionCargo.GetRandomEndLocation(BonusMission.RandomCargo);
                BonusMission.IsMissionFinished  = false;
            }

            var truckName = string.Empty;

            switch (BonusMission.RandomCargo.JobCargoVehicleType)
            {
            case MissionCargoVehicleType.CargoTrailer:
                truckName = "truck with cargo trailer";
                break;

            case MissionCargoVehicleType.FluidsTrailer:
                truckName = "truck with fluids trailer";
                break;

            case MissionCargoVehicleType.OreTrailer:
                truckName = "truck with ore trailer";
                break;

            case MissionCargoVehicleType.CementTruck:
                truckName = "cement truck";
                break;

            case MissionCargoVehicleType.NoTrailer:
                truckName = "Flatbed or DFT-30";
                break;
            }

            foreach (var basePlayer in Player.All)
            {
                var player = (Player)basePlayer;

                if (player.PlayerClass != PlayerClassType.TruckDriver)
                {
                    continue;
                }

                player.SendClientMessage(Color.White,
                                         $"{{00BBFF}}Bonus mission: transport {{FFBB00}}{BonusMission.RandomCargo.Name}");
                player.SendClientMessage(Color.White,
                                         $"{{00BBFF}}from {{FFBB00}}{BonusMission.RandomFromLocation.Name}{{00BBFF}} to {{FFBB00}}{BonusMission.RandomToLocation.Name}");
                player.SendClientMessage(Color.White,
                                         $"{{00BBFF}}You'll need a {{FFBB00}}{truckName}{{00BBFF}} to complete this mission");
            }
        }