Land Vehicles and Fuel

Hello everybody !

I've been reading a lot of helpful tips from this forum but i've been looking around for a solution and couldn't find one so i'm asking here for my first thread.

I'm trying to make land vehicles (let's say cars) that are powered by a certain item (fuel), and every 20 steps it consumes of these items.

How can i do something like this with events ?

Thanks !
If you want to do it purely with events, make a parallel process on the map with the following contents:

Control Variables: [varid] = Steps
Control Variables: [varid] %= 20
Conditional Branch: Variable [varid] == 0
Change Items: [Fuel] - 1
: Branch End

Obviously you would want to have a switch activated to make sure the event only runs when in a car, and a check for whether the player has no fuel left and do something with that, but this is your basic event for it.

Essentially you're getting the number of steps, dividing it by 20 and checking the result. If it's 0, we know that the number of steps the player has taken is a multiple of 20, so we need to remove a fuel.

(edited with RPG Maker VX Ace event command syntax)
My idea basically is the same with Trihan. I also made a demo for you in case you don't understand.
Dropbox
Ok thank you guys, the fuel system is pretty much functionnal, now i'm still confused how to check if the character is in a vehicle (Considering i'm using Victor Engine Custom Vehicles)
You can use a switch for that.
Is there a script command for it? I can't check the script because my work network blocks Google Drive.
I've read multiple times the script header to make my vehicles but there is no script command and since the vehicles are not controlled by events on the map, i have no idea where to control my switch.
Should i ask the scripter who made it ?
I'm not sure how forthcoming Victor would be in helping with something like this but you could try. Can you paste the script code here so I can read it?
Spoiler: code
Script removed by admin
@strbxl
Moderator note: Please do not post entire scripts but link to the website where you got the scripts from.
This has a lot of reasons, iuncluding that most scripters do not like reposts of their scripts and that those websites usually contain more information and possible bugfixes/latest versions of those scripts.
Maybe you could you this in Conditional Branches script to check it: !$game_player.normal_walk? I haven't tested it. But I think it should work.

Edit: I think the step counter doesn't count when Player is in a vehicle. Use the code below, turn on switch 10 to fix that :3
Code:
#-------------------------------------------------------------------------------
# Turn on switch 10 if you want Step Counter still count when in a vehicle.
#-------------------------------------------------------------------------------
class Game_Player
  #--------------------------------------------------------------------------
  # * overwrite method: increase_steps
  #--------------------------------------------------------------------------
  def increase_steps
    super
    $game_party.increase_steps if normal_walk? || $game_switches[10]
  end
end
True ! Even with a functionnal step counter, it doesn't count the steps when the player is in a vehicle (normal vehicles or victor custom vehicles)


EDIT: Ok with your script i can count the steps even in a vehicle or custom vehicle but i still have no idea how to check if the player is in a custom vehicle.
Sorry Andar, that's my bad for asking, should have asked for it in a PM. I couldn't use the link because it just goes to Google Drive, which I can't access. I'll keep that in mind next time though.
True ! Even with a functionnal step counter, it doesn't count the steps when the player is in a vehicle (normal vehicles or victor custom vehicles)


EDIT: Ok with your script i can count the steps even in a vehicle or custom vehicle but i still have no idea how to check if the player is in a custom vehicle.

So !$game_player.normal_walk? doesn't work? I think if player is in a custom vehicle, he couldn't "walk normal" as well lol.
I tried this condition and it doesn't work with normal or custom vehicles.
I updated the demo. You should check it.
Demo: Dropbox
Ok it's working now, i did not try using !$game_player.normal_walk? after i installed your script, my bad.

Thanks alot for your help !


EDIT: One last question, how can i block the access to the vehicle if the player doesn't have fuel ?


EDIT 2 : I added a new condition check for the FUEL item and the !$game_player.normal_walk? in the parallel process that makes the player exit the vehicle.
Yeah, no problem. Good luck with your project! 👋

Original thread: https://forums.rpgmakerweb.com/threads/land-vehicles-and-fuel.75451/