McPaul

Villager
Member
Joined
Sep 24, 2018
Messages
8
Reaction score
5
First Language
English
Primarily Uses
RMMV
Any way to count steps when a player is in a vehicle?
I have a day/night cycle based on Player steps that works when Player is walking around.
But when the Player gets in a vehicle, turns out, the game doesn't count its movements as steps.
Any plugins or something for this?
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,512
Reaction score
11,997
First Language
English
Primarily Uses
RMVXA
I'll leave this here for now, in case this can be evented using variables etc. If it turns out that it does need a plugin please Report your opening post and ask for it to be moved.
Thanks
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
2,761
Reaction score
2,110
First Language
EN
Primarily Uses
RMMZ
In theory you could use a parallel event with some variables, e.g.
  • Store player's X & Y coordinates
    (Control Variables > Set > Game Data > Character > Player > Map X|Y)
  • Wait 6 frames (10 checks/second, probably overkill)
  • Calculate difference between stored and current values
    (Control Variables > Sub > Game Data > Character > Player > Map X|Y)
  • Check if either coordinate difference is non-zero...
    • If position has changed, do your "on step" stuff as required.
Parallel events repeat automatically in the background, so this should suffice. :kaophew: It won't adjust the internal step counter, though.

Alternatively you could try saving this as a .js file and importing as a plugin (works for me!):
Code:
Game_Player.prototype.isNormal = function() {
  return !this._isMoveRouteForcing;  // removed vehicle type check
};
Turns out the default code has a special check for "not in vehicle" and that's why the step counter isn't increasing; this snippet simply removes that extra check. I guess it's not a "step" counter if you're not "stepping"? :kaoswt:

Alternative no. 2: I have a plugin that lets you turn on a switch every step, and works regardless of whether or not you're in a vehicle. You can then make a common event with Parallel trigger (so it doesn't interrupt anything or vice versa) to update your day/night system as appropriate then turn off the switch (so that the event runs only once per step). Plugin link in case you're interested: Cae_StepSwitch. :kaopride:
 

McPaul

Villager
Member
Joined
Sep 24, 2018
Messages
8
Reaction score
5
First Language
English
Primarily Uses
RMMV
Wow, very much big thanks.
The parallel event option works as far as I tested it. I tried to figure out a similar event option for hours, but my math illiterate brain couldn't do it.
Your code also works great, I think I'll use it for now.
No doubt if I mess up down the line, I'll have to fall back on your plugin.
But either way, thank you very very much. You did me a huge favor with this.
 

Escanor

Mightiest of all Men
Member
Joined
Aug 5, 2018
Messages
14
Reaction score
1
First Language
German
Primarily Uses
RMMV
  • Check if either coordinate difference is non-zero...
    • If position has changed, do your "on step" stuff as required.
Hey, I'm sorry, but could you specify what you mean by that last part, like how do i check if either coordinate difference is non-zero and how do i do my "on step" stuff?

I've got the same Problem, but with a weather system based on steps, instead of a day/night cycle.
When i enter a vehicle the weather won't change anymore, since it doesn't count it's movements as steps.
I could figure out everything else you explained about the parallel event except that last part.
I'm not a native english speaker, so maybe that's why i don't understand.

Also i tried typing out your "plugin text" in a notepad and i saved it as a .js file, but when i basically put it in my plugin folder and activate it, nothing happens/ it doesn't work. I have no clue how to write plugins by the way, i just typed in the text you wrote out and saved it as a .js file.
 

McPaul

Villager
Member
Joined
Sep 24, 2018
Messages
8
Reaction score
5
First Language
English
Primarily Uses
RMMV
Here’s what I did with what caethyril figured out. This doesn’t use Steps checks at all, but the Player coordinates and so works with vehicles.

1. Created 2 Variables, name them ‘Player Coordinate X’ and Player Coordinate Y’ or something.

2. Created a Common Event and call it ‘Step Counter’ or something. I also created a special 'Step Counter ON' Switch that turns it on, but in my World Map only, and I put that Switch on and off in between the Events that take me in and out of the World Map.

3. Anyway, now in that ‘Step Counter’ Common Event, first use Control Variable for ‘Player Coordinate X’ and set it equal to Operand Game Data, selecting Character, Player, Map X. Also create the same thing, but using the Map Y option.

4. Having those in your Common Event, make it Wait for like 2 frames.

5. Now you have to create two more Variables and name them like ‘Player X Different and ‘Player Y Different or whatever.

6. And again make them be equal to Operand Game Data, selecting Character, Player, Map X/Y respectively, making exactly like you did for the first 2 Variable.

7. Now the gist is that your first 2 Variables may or may not have different coordinates after waiting those 2 frames while the Player mad a step, so what you need to do now in your Common Event is to use Control Variables and Subtract ‘Player X Different from ‘Player Coordinate X’ and create the same with Y.

8. NOW you need to create 2 Conditional Branches in your Common Event. One that IF your ‘Player X Different is NOT EQUAL to 0, same with Y.

9. Next thing you need to do is to create ANOTHER Variable, name it something like ‘Weather Step Counter' or something.

10. Now I your Common Event you just put that Variable in your IF Conditions and add 1 to them. This way every time the IF does a check, it adds 1 as if you took a step either in the X or Y directions.

11. Also, I myself need a interval of numbers that go up to a certain number then go back to 0 and start over. So to have my interval I put at the end of the Common Event a Control Variable and set my, in our case it would be the ‘Weather Step Counter’, to the Mod Operation and put in a number Constant as high a number as I need.

Now this system is kinda wonky and the X and Y coordinates don’t always register as changed. For me it works good enough though and I don’t mind the occasional miss. But if you figure something out to make it more reliable, let me know just in case.
 

Escanor

Mightiest of all Men
Member
Joined
Aug 5, 2018
Messages
14
Reaction score
1
First Language
German
Primarily Uses
RMMV
Thank you very much for the quick answer.

The problem is, my weather system works with a state.
Basically if it's raining, storming or snowing the player receives one of the states "raining", "snowing" or "storming" which wear out after an x amount of steps using the step-counter from the state.

So i think i understood how this parallel event you explained is supposed to work, though i don't think it works with the step-counter from a state does it?

The easiest way i think for me to do it, would be with this plugin which changes the vehicle movement to stepping but i don't know how to do that.
 
Last edited:

McPaul

Villager
Member
Joined
Sep 24, 2018
Messages
8
Reaction score
5
First Language
English
Primarily Uses
RMMV
I'm guessing you could create a bunch of switched for a specific number period in the interval, but that could be tricky.
So to use caethyril script, you need to copy her code into a text file and save it as a .js file. Name it caethyrlvehiclestepplugin.js or something like that. You can do that with basic Notepad.
Then you put that file into your game folder/js/plugins.
Then you open RPG MV and go to Tools/Plugin Manager and select the plugin and set it to on or off.
This should work. Maybe you missed something?
I'm pretty sure I tested it before and it worked fine.

EDIT 1
I just checked the plugin.
It definitely works with vehicles being counted with the steps.
 
Last edited:

Escanor

Mightiest of all Men
Member
Joined
Aug 5, 2018
Messages
14
Reaction score
1
First Language
German
Primarily Uses
RMMV
I tried that with the .js file but it didn't work for me.

Could you send me a direct-upload link or smth maybe so i could download your js file?
 

McPaul

Villager
Member
Joined
Sep 24, 2018
Messages
8
Reaction score
5
First Language
English
Primarily Uses
RMMV
Sure.
Try this. It definitely makes it so vehicle movement adds to the step counter.
Maybe your events are missing something?
 

Attachments

  • caethyril vehicle step plugin.js
    117 bytes · Views: 5

Escanor

Mightiest of all Men
Member
Joined
Aug 5, 2018
Messages
14
Reaction score
1
First Language
German
Primarily Uses
RMMV
Thank you.

Though i tried it with this now but it still doesn't work.

Maybe it doesn't work because the steps are counted for the ship now and not for the character?

Also i use a lot of Yanfly and other Plugins so maybe they don't get along with this plugin change?

For better understanding i'm gonna explain the situation:
There is a parallel event running which switches through variables 1-100 to determine the weather. Once the variable gets a certain amount the player receives the state of the weather (for example "Rain"). Now when i enter the ship, the actor gets removed and a new actor, which is a ship captain gets added. I've already made events so that once the actor switches, the previous state effect goes to the next actor and this also works fine.
When i enter the ship with the previous actor (who has the raining state) then the new actor (the captain) gets this state applied to him and also the other way around.
But when i walk/sail around with the captain/ship the state never runs out and the weather doesn't change.
 
Last edited:

McPaul

Villager
Member
Joined
Sep 24, 2018
Messages
8
Reaction score
5
First Language
English
Primarily Uses
RMMV
Interesting.
The plugin shouldn't be a problem since it doesn't really add much, just removes the vehicle check. It literally makes the ship act as if you're walking normally not on the ship.
What if you just walk around normally, but with the captain as your main, not the normal actor? Does the weather still stay the same with the captain, but without the ship? Maybe even try sailing without the captain too, see if the weather changes without him or not.
 

Escanor

Mightiest of all Men
Member
Joined
Aug 5, 2018
Messages
14
Reaction score
1
First Language
German
Primarily Uses
RMMV
It's just so weird.

So the captain normally isn't walkable on land, he is only on the ship.
I walked around with the captain actor (via startposition) and the weather works just fine if he walks on land.
The weird thing though is i tried sailing without the captain (without the change of characters) but with my normal actor and there the weather system also works just fine when sailing.

So something must go wrong when the characters are switched... but i don't know what it is to be honest. Everything in the switch works as intended and the Captain also gets the weather state on the ship which should wear off after a few steps but it doesn't...

I'm truly at a loss here. Also thank you really much for your time and help. I really appreciate it :)
 

Escanor

Mightiest of all Men
Member
Joined
Aug 5, 2018
Messages
14
Reaction score
1
First Language
German
Primarily Uses
RMMV
I figured it out.
When you add a new actor to the group and remove an old one, the state of the old one will still be active in the system even so you can't see it and the actor isn't even in the group. At least that's what i think is happening.
Because i removed the previous actors' state in the same parallel process and now it works fine.
 

Latest Threads

Latest Profile Posts

so... I decided since a park was an area in my game... here's an enemy that's slide with a hand behind it. cause why not.
Hot chocolate and music make studying and note-taking much easier :kaoluv:
Until my hand cramps up from writing too much!
Doing RPG Maker News for 21st September 2021


Malak is still waiting for Dark Deception Chapter 4... This was him yesterday after another sugar crash.
Again, he's fine. He's just bored at this point, considering he's exhausted his entire vacation bucket list.
Am I the only one who files custom resources under specific folders to remember who to credit? :kaoswt2:
1632263519730.png

Forum statistics

Threads
115,271
Messages
1,088,503
Members
149,876
Latest member
SeraphofFlame
Top