Have some states stay after dying (compatibility to a script)

I am using this script provided by HimeWorks to ensure some of the states I am using get removed after death:

# By default, when a battler dies, the game simply clears out the states.

# However, sometimes we might want them to be actually "removed" through the

# appropriate remove_state method

class Game_Battler < Game_BattlerBase

  alias :th_remove_states_on_death_die :die

  def die

    @states.each {|id| remove_state(id)}

    th_remove_states_on_death_die

  end

end

I definitely need this script to remove some transformation states on my actors, however, it removes all transformation states and doesn't allow for any exceptions.  Is it possible to have a script that can have some states circumvent this script?  I really need some transformation states to work after death during boss battles.  Thanks!
So this script doesn't allow you to write in which states stay and which don't? 😳

It looks like you can specify which state you can exempt by the State ID.
whoa really?  When I put it in, it seems to just remove all states.
where would I specify which IDs to be removed?
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.


Detectivegame, please avoid double posting, as it is against the forum rules. You can review our forum rules here. Thank you.


Please post a link to the script so we can see the whole thing (this does not mean copying and pasting the whole script into your post - please don't do that)
I tried putting ID numbers where it says id, but theres an error window saying there is an unexpected integer or something...
To say that the error message had "an unexpected integer or something." is not helpful.  Recreate the problem and provide the exact error message.

And Shaz asked you to provide a link to the script.  People have to be able to see what the script says if they are to make suggestions.
I think this may solve the problem.

module TH_States  NON_REMOVABLE = [] # <== Here, you add iD's of the states that should not be removedendalias :th_remove_states_on_death_die :die  def die    @states.each {|id| remove_state(id) unless TH_States::NON_REMOVABLE.include?(id)}    th_remove_states_on_death_die  endendReplace the lines provided above with those lines.
Hi,

By default when a battler dies all other states are deleted anyway, regardless whether you use that script or not. Preventing certain states from being removed by the script you posted might not be enough.

However, you should be able to change

@states.each {|id| remove_state(id)}

into

(@states - [2, 5, 6]).each {|id| remove_state(id)}

in order to exclude certain states (state 2, 5 and 6 for example).

Edit: Too slow 🙂

Original thread: https://forums.rpgmakerweb.com/threads/have-some-states-stay-after-dying-compatibility-to-a-script.44704/