State Add/Remove Commands

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,445
Reaction score
12,012
First Language
English
Primarily Uses
RMMV
Yes, that is what I mean :p


edit: in that case, it probably won't make a difference, because it's MV/Javascript that requires this. Ace will work without self.

@Ninjakillzu can you confirm that you have done what I requested in my first response to you, by putting p $1 on that line and checking the output when the command is run? You didn't actually say that's what you did that led you to add_param.
 
Last edited:

Ninjakillzu

Veteran
Veteran
Joined
Aug 19, 2013
Messages
132
Reaction score
41
First Language
English
Primarily Uses
RMVXA
Yes, that is what I mean :p


edit: in that case, it probably won't make a difference, because it's MV/Javascript that requires this. Ace will work without self.

@Ninjakillzu can you confirm that you have done what I requested in my first response to you, by putting p $1 on that line and checking the output when the command is run? You didn't actually say that's what you did that led you to add_param.
Sorry if I didn't say I did that. I did do it though. The reason it led me to add_param is that it would show up a ton in the console when it should only show up once, like it somehow was repeating itself over and over, and that's what lead to the crash. I tried it with self. but that didn't fix it.

 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,445
Reaction score
12,012
First Language
English
Primarily Uses
RMMV
And did you do the other thing I requested, which was to put the commands into a script call in a regular event, and separate them from my script? You would need to have an object for this - so $game_actors[id].add_param(6, 6) or $game_actors[id].add_param(6, -6)?

Do that inside a script call and not through the state add/remove commands script, to see if it's even related to my script.

I also asked a number of other questions in my first reply, which you haven't answered.
 

Ninjakillzu

Veteran
Veteran
Joined
Aug 19, 2013
Messages
132
Reaction score
41
First Language
English
Primarily Uses
RMVXA
And did you do the other thing I requested, which was to put the commands into a script call in a regular event, and separate them from my script? You would need to have an object for this - so $game_actors[id].add_param(6, 6) or $game_actors[id].add_param(6, -6)?

Do that inside a script call and not through the state add/remove commands script, to see if it's even related to my script.

I also asked a number of other questions in my first reply, which you haven't answered.
I just tested the script call in two separate events, one for increasing the parameters, and one for decreasing the parameters. Both worked without issues.

@Ninjakillzu can you please check that you don't have the script installed in multiple slots, or twice in the same slot? Could you please insert a new line before the eval($1), and put the following there:
p $1

Then play with the debug window open and see what it shows there immediately before the crash.

Also, when does it happen? ANY time a state is removed, or only a specific state? If it's only a specific state, please show a screenshot of the state in the database so we can see how it's set up. If it references other states (when removing this state, either add or remove that state, for example), then please show a screenshot of those states as well. Any chance you have some kind of looping going on, where state A adds/removes state B, and state B adds/removes state A (with or without another state or more in between)?

Did you go through this thread looking at the other issues that had been reported previously and the fixes for them?
As for the other questions, I did look through the thread earlier, and found nothing similar. I also did add p $1 before the eval($1) line. I didn't install the script twice or in the same slot. The crash only happens on enemies when any state is removed (with onremove) that has the add_param command part. As for looping, none of my states add or remove each other, so I don't know if it's possible otherwise.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
4,685
Reaction score
5,358
First Language
Indonesian
Primarily Uses
RMVXA
I still feel like this is unfair that the error pointed out to this script while it does exactly nothing.
For a "foolproof", try to change your add_param to literally like this
Code:
onremove: @param_plus[param_id] += value;refresh
Of course, change the param_id and value to what you need. See if it still yields stack error
 

Ninjakillzu

Veteran
Veteran
Joined
Aug 19, 2013
Messages
132
Reaction score
41
First Language
English
Primarily Uses
RMVXA
I still feel like this is unfair that the error pointed out to this script while it does exactly nothing.
For a "foolproof", try to change your add_param to literally like this
Code:
onremove: @param_plus[param_id] += value;refresh
Of course, change the param_id and value to what you need. See if it still yields stack error
It seems like it works sometimes, but other times it crashes. For instance, this seems like it doesn't crash:
Code:
onadd: add_param(6, 6)
onremove: @param_plus[6] += -6;refresh
But this does:
Code:
onadd: add_param(5, -2)
onremove: @param_plus[5] += 2;refresh
Also, what did you mean by "it does exactly nothing"?
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
4,685
Reaction score
5,358
First Language
Indonesian
Primarily Uses
RMVXA
Also, what did you mean by "it does exactly nothing"?
The script does not produce stack level too deep on its own. It is like asking "why my custom damage formula does not work" using support ticket to the official staff instead of asking it in the forum, while the damage formula feature does not actually make your game broken. It's more appropriate if you continue this in your thread you created rather than asking directly to Shaz.

But let's get back to the question. Your two example shouldn't be that different, however, I suspect there's something within the method refresh that does the stack level too deep. Without going into detail, or even knowing what scripts did you install in your game, let's try to "reconstruct" the add_param method. Try to insert this as a new script.
Code:
class Game_Battler
  def add_param_custom(param_id, value)
    @param_plus[param_id] += value
    @hp = [[@hp, mhp].min, 0].max
    @mp = [[@mp, mmp].min, 0].max
  end
end
Then replace your line to
Code:
onremove: add_param_custom(6,6)
See if it works.
 

Ninjakillzu

Veteran
Veteran
Joined
Aug 19, 2013
Messages
132
Reaction score
41
First Language
English
Primarily Uses
RMVXA
The script does not produce stack level too deep on its own. It is like asking "why my custom damage formula does not work" using support ticket to the official staff instead of asking it in the forum, while the damage formula feature does not actually make your game broken. It's more appropriate if you continue this in your thread you created rather than asking directly to Shaz.

But let's get back to the question. Your two example shouldn't be that different, however, I suspect there's something within the method refresh that does the stack level too deep. Without going into detail, or even knowing what scripts did you install in your game, let's try to "reconstruct" the add_param method. Try to insert this as a new script.
Code:
class Game_Battler
  def add_param_custom(param_id, value)
    @param_plus[param_id] += value
    @hp = [[@hp, mhp].min, 0].max
    @mp = [[@mp, mmp].min, 0].max
  end
end
Then replace your line to
Code:
onremove: add_param_custom(6,6)
See if it works.
It seems like it actually works now, both in combat and if I use the commands in an event script call! Thank you so much for your efforts.:smile: Same to @Shaz as well!

Could you explain why this would work instead of the old refresh method? I honestly don't know much about scripting with ruby.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
4,685
Reaction score
5,358
First Language
Indonesian
Primarily Uses
RMVXA
Could you explain why this would work instead of the old refresh method? I honestly don't know much about scripting with ruby.
I'd go straight answering "I don't know". I don't know what script you install, and they may actually change how the internal system works and whatnot because the method refresh is "shared". What I'm doing is just make a completely separate method that no one is going to touch it no matter how many scripts you install (this could be mean a good/bad thing though).
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,445
Reaction score
12,012
First Language
English
Primarily Uses
RMMV
It's very odd, because when you added p $1 to my script, it clearly showed that that part of my script was being run over and over and over. I don't know if you just had many battles before it crashed and most of that output was from the successful ones, or if it was somehow looping, as if the remove_state logic was being called repeatedly.

I hope it continues to work for you. If it starts happening again, it might be necessary for you to just create a dummy map with an enemy that causes it to crash, then load your game up for us to take a look at.
 

Ninjakillzu

Veteran
Veteran
Joined
Aug 19, 2013
Messages
132
Reaction score
41
First Language
English
Primarily Uses
RMVXA
It's very odd, because when you added p $1 to my script, it clearly showed that that part of my script was being run over and over and over. I don't know if you just had many battles before it crashed and most of that output was from the successful ones, or if it was somehow looping, as if the remove_state logic was being called repeatedly.

I hope it continues to work for you. If it starts happening again, it might be necessary for you to just create a dummy map with an enemy that causes it to crash, then load your game up for us to take a look at.
The part being run over and over took place in the span of a couple seconds or so, in a single battle. This also took place shortly after loading a saved game. It must've been looping like you said.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,445
Reaction score
12,012
First Language
English
Primarily Uses
RMMV
You said you looked back through the thread and didn't find anything, but I can see some comments on page 2 about recursion and stack errors, and a suggested fix. Did you see them, and did you try them? The script formatting has been messed up long ago by a forum move, so here it is in a better format:

Code:
  #-------------------------------------------------------------------------- 
  # * Clear State Information 
  #-------------------------------------------------------------------------- 
  alias shaz_state_commands_clear_states clear_states 
  def clear_states
    last_states = @states
    shaz_state_commands_clear_states
    last_states.each {|state_id| state_remove_command(state_id) } if last_states
  end
 
  #--------------------------------------------------------------------------
  # * Erase State
  #--------------------------------------------------------------------------
  def erase_state(state_id)
    remove = state?(state_id)
    super
    state_remove_command(state_id) if remove
  end
If it starts to happen again, you can replace these two methods in the script with the above code to see if it fixes it.
 

Oddball

Veteran
Veteran
Joined
Sep 4, 2014
Messages
1,683
Reaction score
454
First Language
English
Primarily Uses
N/A
My head just exploded with ideas when i found this!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

tfw, after your game being intensively played by many people, after 5 years, patch after patch released, suddenly an innocent person reported another bug.
"Never let a sense of morals/
Prevent me from doing what is right"
- Clutch
OMFG. I had typed \fiPhilosophia Hermetica\fi in a forum post and didn't notice it for AN HOUR.

(Anyone else ever catch themselves doing this?)
Stream will be live shortly with a guest stream! Feel free to drop by and listen to whatever weird stories we're telling~
fighting game fans might really enjoy my game battle wise, and I feel non fighting fans might learn some stuff. thanks row system. pokes, neutral, and zoning time...

Forum statistics

Threads
94,252
Messages
919,413
Members
123,969
Latest member
TsuruharaYuki
Top