Beispiel #1
0
 void ShowVehicleSensors() // draws the debug display every frame (no flicker)
 {
     debug_speed.Caption      = "Speed: " + speed;
     debug_wheelSpeed.Caption = "Wheel speed: " + wheelSpeed;
     debug_rpm.Caption        = "RPM: " + rpm;
     debug_gear.Caption       = "Gear: " + gear;
     debug_angle.Caption      = "Steering angle: " + angle;
     debug_throttle.Caption   = "Throttle: " + throttle;
     debug_braking.Caption    = "Braking: " + braking;
     debug_clutch.Caption     = "Clutch: " + clutch;
     debug_engineTemp.Caption = "Engine temp: " + engineTemp;
     debug_fuelLevel.Caption  = "Fuel level: " + fuelLevel;
     debug_worldPos.Caption   = "Pos: " + worldPos;
     debugContainer.Draw();
 }
 void OnTick(object sender, EventArgs e)
 {
     if (enable)
     {
         Player player = Game.Player;
         if (player != null && player.CanControlCharacter && player.IsAlive && player.Character != null)
         {
             pos          = player.Character.Position;
             heading      = player.Character.Heading;
             text.Caption = string.Format("next:{0} ({1}routed) closeby:{2} x:{3} y:{4} z:{5} heading:{6}", next, routed ? "" : "un", closeby,
                                          pos.X.ToString("0"), pos.Y.ToString("0"), pos.Z.ToString("0"), heading.ToString("0"));
             container.Draw();
         }
     }
 }
Beispiel #3
0
        //event runs every tick interval (set as MS)
        void OnTick(object sender, EventArgs e)
        {
            //update current direction
            GetLocationInfo();
            locationInfo.Draw();


            //show details of targeted NPC
            if (Game.Player.TargetedEntity != null && Game.Player.TargetedEntity.EntityType == EntityType.Ped)
            {
                GetTargetInfo();
                targetInfo.Draw();
            }

            //show speed if in vehicle
        }
Beispiel #4
0
        private void OnTick(object sender, EventArgs e)
        {
#if DEBUG
            Container.Draw();
            Text.Draw();
            MainPool.Process();
            if (Game.IsControlPressed(Control.Context) && Game.IsControlPressed(Control.Sprint) && !Menu.Visible)
            {
                Menu.Visible = !Menu.Visible;
            }
#endif

            foreach (Module Mod in Modules)
            {
                Mod.Tick();
            }
        }
Beispiel #5
0
        /// <summary>
        /// Called in the OnTick event
        /// </summary>
        public override void Tick()
        {
            // Create a new FuelVeh for the current vehicle if there isn't already one
            if (Game.Player.Character.IsInVehicle() && FuelVehicles.FirstOrDefault(x => x.Vehicle == Game.Player.Character.CurrentVehicle) == null)
            {
                CurrentVehicle = new FuelVeh()
                {
                    Fuel    = new Random().Next(10, 125),
                    Vehicle = Game.Player.Character.CurrentVehicle
                };
                FuelVehicles.Add(CurrentVehicle);
            }

            if (LastWeightChangeHour != World.CurrentTimeOfDay.Hours)
            {
                LastWeightChangeHour = World.CurrentTimeOfDay.Hours;
                Weight = ((float)new Random().Next(Config.MinimumPriceChange, Config.MaximumPriceChange)) / 100.0f;
            }

            // Set the current vehicle appropriately and runs everything needed when in a vehicle
            // Also yes, spaghetti code.
            if (CurrentVehicle != null && !BlacklistedModels.Contains(CurrentVehicle.Vehicle.Model) && !CurrentVehicle.Vehicle.Model.IsBicycle && !CurrentVehicle.Vehicle.Model.IsPlane && !CurrentVehicle.Vehicle.Model.IsBlimp && !CurrentVehicle.Vehicle.Model.IsHelicopter && !CurrentVehicle.Vehicle.Model.IsBoat)
            {
                FuelBar.Position = new PointF(FuelBar.Position.X, Screen.Height - 137.5f + 125 - CurrentVehicle.Fuel);
                FuelBar.Size     = new SizeF(FuelBar.Size.Width, CurrentVehicle.Fuel);
                FuelBarBackground.Draw();
                FuelBar.Draw();

                if (!Game.Player.Character.IsInVehicle())
                {
                    CurrentVehicle = null;
                    return;
                }

                if (CurrentVehicle.Vehicle.IsEngineRunning)
                {
                    // Fuel depletion
                    switch (CurrentVehicle.Vehicle.Acceleration)
                    {
                    case -1:     // Backwards
                        CurrentVehicle.Fuel -= Config.DecelerateDepletion;
                        break;

                    case 0:     // Idle
                        CurrentVehicle.Fuel -= Config.IdleDepletion;
                        break;

                    case 1:     // Forwards
                        CurrentVehicle.Fuel -= Config.AccelerateDepletion;
                        break;
                    }
                }

                // Engine killing
                if (CurrentVehicle.Fuel <= 0.0f && CurrentVehicle.Vehicle.IsEngineRunning && CurrentVehicle.Vehicle.FuelLevel != 0)
                {
                    Screen.ShowHelpTextThisFrame("You have run out of fuel! Use a jerry can to refuel your vehicle.");
                    CurrentVehicle.Vehicle.FuelLevel = 0;
                }
                else if (CurrentVehicle.Fuel > 0.0f)
                {
                    CurrentVehicle.Vehicle.FuelLevel = 60;
                }
            }
            else if (CurrentVehicle == null && Game.Player.Character.IsInVehicle())
            {
                CurrentVehicle = FuelVehicles.FirstOrDefault(x => x.Vehicle == Game.Player.Character.CurrentVehicle);
            }

            if (Game.Player.Character.Weapons.Current.Hash == WeaponHash.PetrolCan)
            {
                foreach (FuelVeh Vehicle in FuelVehicles)
                {
                    // Even more spaghetti code! lovely!
                    if (Vehicle.Vehicle.Exists() && !BlacklistedModels.Contains(Vehicle.Vehicle.Model) && World.GetDistance(Vehicle.Vehicle.Position, Game.Player.Character.Position) <= 3.0f && Game.Player.Character.Weapons.Current.Ammo > 0 && Vehicle.Fuel <= 125 && !Vehicle.Vehicle.Model.IsBicycle && !Vehicle.Vehicle.Model.IsPlane && !Vehicle.Vehicle.Model.IsBlimp && !Vehicle.Vehicle.Model.IsHelicopter && !Vehicle.Vehicle.Model.IsBoat)
                    {
                        Screen.ShowHelpTextThisFrame("Hold ~INPUT_AIM~ to refuel this vehicle");
                        if (Game.IsControlPressed(Control.Aim))
                        {
                            Vehicle.Fuel++;
                            Game.Player.Character.Weapons.Current.Ammo -= 50;
                            FuelBar.Position = new PointF(FuelBar.Position.X, Screen.Height - 137.5f + 125 - Vehicle.Fuel);
                            FuelBar.Size     = new SizeF(FuelBar.Size.Width, Vehicle.Fuel);
                            FuelBarBackground.Draw();
                            FuelBar.Draw();
                            Screen.ShowSubtitle($"~y~Fuel: ~w~{Vehicle.Fuel}", 1);
                        }
                    }
                }
            }

            // MORE spaghetti code... I really need to stop.
            if (Game.Player.Character.IsInVehicle() && !BlacklistedModels.Contains(CurrentVehicle.Vehicle.Model) && !CurrentVehicle.Vehicle.Model.IsBicycle && !CurrentVehicle.Vehicle.Model.IsPlane && !CurrentVehicle.Vehicle.Model.IsBlimp && !CurrentVehicle.Vehicle.Model.IsHelicopter && !CurrentVehicle.Vehicle.Model.IsBoat)
            {
                // Gas station stuff
                foreach (Prop Pump in World.GetNearbyProps(Game.Player.Character.Position, 15, PumpModels.ToArray())) // CHANGE THIS TO THE NEW PUMP SYSTEM
                {
                    if (World.GetDistance(Pump.Position, Game.Player.Character.Position) <= 3.5f)
                    {
                        float Multiplier = .50f + Weight;
                        int   Cost       = (int)Math.Round((125.0f - CurrentVehicle.Fuel) * Multiplier);
                        if (Cost == 0)
                        {
                            Cost = 1;
                        }
                        if (Game.Player.Money >= Cost)
                        {
                            Screen.ShowHelpTextThisFrame($"Press ~INPUT_CONTEXT~ to refuel (${Cost})");
                            if (Game.IsControlJustPressed(Control.Context))
                            {
                                Screen.FadeOut(1500);
                                Script.Wait(1500);
                                CurrentVehicle.Fuel = 125;
                                Game.Player.Money  -= Cost;
                                Script.Wait(1500);
                                Screen.FadeIn(1500);
                            }
                        }
                        else if (BlacklistedModels.Contains(CurrentVehicle.Vehicle.Model))
                        {
                            Screen.ShowHelpTextThisFrame("This vehicle cannot be refueled!");
                        }
                        else
                        {
                            Screen.ShowHelpTextThisFrame($"You cannot afford to refuel this vehicle. The cost is ${Cost}");
                        }
                    }
                }
            }
        }