I want to make it so that if a player goes a certain amount of steps while a player has a certain negative state(It doesn't go away post-combat), without getting it cured, the state will upgrade to a far more punishing version. I don't know how to record when the player takes a step, however.
If it means anything, I am using Yanfly Engine Ace scripts.
Record how many steps a player has taken?
● ARCHIVED · READ-ONLY
-
-
Under "Game Variables", use the "Game Data" selection.
Under "Other", there is a "Steps" selection.
This won't tell you how many steps a State has been in effect, but you at least have the core information. -
When you want to record the current number of steps, you use control variable : game data : other : steps.
At a later time, you use the same command with a different variable, then substract the first variable from it, and the resulting difference is the number of steps since the original step number was stored. -
....Hm. Yes, but what time would I check, however? All the time? That would put a serious strain on the eventing system. At particular forced intervals? That'd be tricky to handle properly.
-
Bang
#==============================================================================# ** Game_Party#------------------------------------------------------------------------------# This class handles parties. Information such as gold and items is included.# Instances of this class are referenced by $game_party.#==============================================================================class Game_Party < Game_Unit def step_check ; @steps = @steps end endjust plug a variable in a event call with this inside the script option
It defiantly works, I'm sure I could write it a better way, but this is the quickest working option, plus It's been a busy day for me =P
So from now on, your variable will always hold the data, you can even use F9 to check it in the Debug Menu.
Code:$game_party.step_check -
So would this go in an if, or.....what, @Zane ?
-
No just make an event > Control Variable > Click Script > Type
$game_party.step_check> Done.
It works even in a state and will always return the number of steps you took. Lag free works 24/7 -
Ah. So this would go in a loop then, if I wanted to check it constantly?
-
Nope Ruby will do it all internally. You just need to set the variable up with the data from an event 1 time.
-
Okay. Suppose the state gets cured, however. How would I go about turning this off? Just terminate the process? Or is there something extra?
-
Okay so I'll try to explain this better:
By default RM has a method for adding steps to the step counter but it doesn't contain a method to check the steps.
I added a step checking def that is already on and running but I didn't plug it in a variable because I left that up to you.
The method is both on/off basically all your doing is providing a variable that is readable easily in game rather then the internal variable.
Here is what I told RM to do. @steps = @steps. In other words I said read the equal amount.
When you plug it into a variable your now giving that more direction to be able to be used somewhere. So now in retrospect your saying
@steps = $game_variable[number] but the only difference is you can take that variable and use it anywhere in your game without needing
to hit the script editor.
Long story short It's not really a process that needs to be turned off to save processing power or FPS. The most you can do is have the variable = 0 to reset it and then have it equal steps again.
It won't update unless you step but by then the interpreter takes care of it and it's almost nothing to even update it.
I know you probably didn't need to hear all that. But I love explaining things haha. -
Okay....I think it's starting to make a bit more sense. But now the question comes as to how to have eventing check to see if that step variable equals a certain number, and then do something once that has happened.
Common Event? -
After you set the variable to equal the step amount, I wouldn't say common event unless it happens a lot often but in a new event of something else or yeah a common event if you feel the need too, just run a conditional branch and say if variable equals x amount then do something
-
Zane already answered it. But you could use this script to get it into a game variable so you can use a normal if-check in a (common)-event:
But if you need to check for just 1 number (like 150th step only) then scripting is the best solution because parallel events drain too much resources (unless you have a small game).Spoiler#sb:nap_party_step_cnt [misc]#================================================================================beginNapoleons Party Step CounterVersion 1.00By NapoleonPurpose: Automatically stores the party-steps into a game variable.License: CC0 or public domain (http://creativecommons.org/publicdomain/zero/1.0/)=end$imported ||= {}$imported[:nap_party_step_cnt] = 1.00module Nap; module Step_Counter#===============================================================================# Settings#=============================================================================== VAR_IDX = 6 # The game_variable index (starts at 1)end; end#===============================================================================# Game Party#===============================================================================class Game_Party < Game_Unit #----------------------------------------------------------------------------- # Increase Steps [ALIAS] #----------------------------------------------------------------------------- alias nap_step_cnt_increase_steps increase_steps def increase_steps nap_step_cnt_increase_steps $game_variables[Nap::Step_Counter::VAR_IDX] = @steps endend
Something like:
class Game_Party < Game_Unit #----------------------------------------------------------------------------- # Increase Steps [ALIAS] #----------------------------------------------------------------------------- alias nap_step_cnt_increase_steps2 increase_steps def increase_steps nap_step_cnt_increase_steps2 $game_temp.reserve_common_event(1) if @steps == 150 endendThis will call common event with id #1 whenever the 150th step is reached.
Alternatively you could use a modules to do it every 150 steps (out of my head w/o testing):
Code:class Game_Party < Game_Unit #----------------------------------------------------------------------------- # Increase Steps [ALIAS] #----------------------------------------------------------------------------- alias nap_step_cnt_increase_steps3 increase_steps def increase_steps nap_step_cnt_increase_steps3 $game_temp.reserve_common_event(1) if @steps % 150 == 0 endend -
Alright. I'll try what Zane's suggesting, and if it falls through, i'll use Napoleon's script. Thanks.
(don't close the thread yet mods, juuust in case stuff happens) -
I see this has not been closed yet so i will ask a question i need answered. Basically the step count starts from the start of the game when i do Var1 = steps then var1 -66 it doesnt take 66 away from the step count is there some little tiny piece of script somone could do for me that stores step count in to a variable and can be reset back to 0? it would be very much appreciated
-
no, you need to restructure your logic.
You need two variables - one to store a certain moment, and one to check the current count.
Instead of resetting the count, you store the current count into the first variable.
And when you want to check the number of steps, you first load the current steps into var2, and then substract the stored value of var1 from var2 - the difference is the number of steps since the last store command. -
Updated the previous script (changed the default value to 0 just in case. But I believe that RPG Maker already does that somehow):
Spoiler#sb:nap_party_step_cnt [misc]#================================================================================beginNapoleons Party Step CounterVersion 1.00By NapoleonPurpose: Automatically stores the party-steps into a game variable.License: CC0 or public domain (http://creativecommons.org/publicdomain/zero/1.0/)=end$imported ||= {}$imported[:nap_party_step_cnt] = 1.00module Nap; module Step_Counter#===============================================================================# Settings#=============================================================================== VAR_IDX = 6 # The game_variable index (starts at 1)end; end#===============================================================================# Game Party#===============================================================================class Game_Party < Game_Unit #----------------------------------------------------------------------------- # Increase Steps [ALIAS] #----------------------------------------------------------------------------- alias nap_step_cnt_increase_steps increase_steps def increase_steps nap_step_cnt_increase_steps $game_variables[Nap::Step_Counter::VAR_IDX] = @steps endend#===============================================================================# DataManager#===============================================================================module DataManager #----------------------------------------------------------------------------- # Create Game Objects [ALIAS] # For: Setting the default value #----------------------------------------------------------------------------- class << self; alias nap_party_step_create_game_objects create_game_objects; end def self.create_game_objects nap_party_step_create_game_objects $game_variables[Nap::Step_Counter::VAR_IDX] = 0 if !$game_variables[Nap::Step_Counter::VAR_IDX] endend
This is the one you need to change the step amount:I see this has not been closed yet so i will ask a question i need answered. Basically the step count starts from the start of the game when i do Var1 = steps then var1 -66 it doesnt take 66 away from the step count is there some little tiny piece of script somone could do for me that stores step count in to a variable and can be reset back to 0? it would be very much appreciated
You can now say:Spoiler#sb:nap_party_step_inc [misc]#================================================================================beginNapoleons Party Step Incremental Counter (Addon)Version 1.00By NapoleonPurpose:- Automatically stores the party-steps into a game variable incrementally. So you can now say game_variables[7] -= 10 and it will work.- Also calls Game_Party.on_step_reached(*args) whenever the value is reached.Note: Compatible with "Nap Step Counter" but it is not required.License: CC0 or public domain (http://creativecommons.org/publicdomain/zero/1.0/)=end$imported ||= {}$imported[:nap_party_step_inc] = 1.00module Nap; module Step_Counter#===============================================================================# Settings#=============================================================================== # The game_variable index (starts at 1) VAR_INCREMENT_IDX = 7 # Set this value to anything above zero to make it automatically reset this # step counter after that value was reached. # Example: AUTO_RESET = 15 will reset the variable to 1 when it should have # been 16. AUTO_RESET = 5end; end#===============================================================================# Game Party#===============================================================================class Game_Party < Game_Unit #----------------------------------------------------------------------------- # Increase Steps [ALIAS] #----------------------------------------------------------------------------- alias nap_step_inc_increase_steps increase_steps def increase_steps nap_step_inc_increase_steps $game_variables[Nap::Step_Counter::VAR_INCREMENT_IDX] += 1 if Nap::Step_Counter::AUTO_RESET > 0 $game_variables[Nap::Step_Counter::VAR_INCREMENT_IDX] = 1 if $game_variables[Nap::Step_Counter::VAR_INCREMENT_IDX] % Nap::Step_Counter::AUTO_RESET == 1 on_step_reached if $game_variables[Nap::Step_Counter::VAR_INCREMENT_IDX] % Nap::Step_Counter::AUTO_RESET == 0 end end #----------------------------------------------------------------------------- # On Step Reached [NEW] #----------------------------------------------------------------------------- def on_step_reached(*args) # Alias/Overwrite this method to your needs. endend#===============================================================================# DataManager#===============================================================================module DataManager #----------------------------------------------------------------------------- # Create Game Objects [ALIAS] # For: Setting the default value #----------------------------------------------------------------------------- class << self; alias nap_party_step_inc_create_game_objects create_game_objects; end def self.create_game_objects nap_party_step_inc_create_game_objects $game_variables[Nap::Step_Counter::VAR_INCREMENT_IDX] = 0 if !$game_variables[Nap::Step_Counter::VAR_INCREMENT_IDX] endend

Or simply reset it back to 0 yourself. I even added an auto-reset feature. Oh and the 2 scripts are compatible with each other but don't require each other.
You can test it in my master demo (just added them) in combination with my "variable display script" so you can easily test it. Or just press [F9] to view the variables. -
Script error. NoMethodError. Undefined Method step_check.No just make an event > Control Variable > Click Script > Type
$game_party.step_check> Done.
It works even in a state and will always return the number of steps you took. Lag free works 24/7 -
The above code doesn't work. For $game_party.step_check to work you need to include the below as a new script in your scripts section below Materials (he forgot a ; character and didn't return anything). I'm surprised it didn't crash.Bang
#==============================================================================# ** Game_Party#------------------------------------------------------------------------------# This class handles parties. Information such as gold and items is included.# Instances of this class are referenced by $game_party.#==============================================================================class Game_Party < Game_Unit def step_check ; @steps = @steps end end
class Game_Party < Game_Unit def step_check ; @steps; endendOr even better:
Code:# Use: $game_party.stepsclass Game_Party < Game_Unit attr_reader :stepsend