[RMVX ACE] [SCRIPTING] REMOVING A STATE BEFORE APPYING DEATH

Posts

Pages: 1
Greetings fellow rpg makers! I'm having a bit of a unique problem I'm hoping someone can assist me with. I was wondering if it would be possible to remove a specific state from an actor when their HP hits 0 before the death state is applied. I would assume it would involve modifying in the Game_BattlerBase, which frankly terrifies me. Any help would be greatly appreciated!
Any reason why it has to be before?
Yeah, it'll be in battler base. Look at:
class Game_BattlerBase
  def refresh
    state_resist_set.each {|state_id| erase_state(state_id) }
    @hp = [[@hp, mhp].min, 0].max
    @mp = [[@mp, mmp].min, 0].max
    @hp == 0 ? add_state(death_state_id) : remove_state(death_state_id)
  end
You can replace it with something like: (via a script below the Materials page and above any other script)
class Game_BattlerBase
  def refresh
    state_resist_set.each {|state_id| erase_state(state_id) }
    @hp = [[@hp, mhp].min, 0].max
    @mp = [[@mp, mmp].min, 0].max
    if @hp == 0
      remove_state(MYSTERY_STATE_ID_HERE)
      add_state(death_state_id)
    else
      remove_state(death_state_id)
    end
  end
Change MYSTERY_STATE_ID_HERE with the ID# of the state you want to remove. Let me know if you have an issue, I'm just winging this but it should be fine!
author=karins_soulkeeper
Any reason why it has to be before?


Yeah, kind of wondering this myself I mean, why before? I cannot see any reason to honestly. Seems like it just makes things complex for no reason.
I asked because dying already clears states afterwards anyway.

Edit: Unless something really complex absolutely requires some state to be removed for... some reason, it seems unnecessary. But GRS already has provided an answer to it.
Bless you GreatRedSpirit! Bless your kind soul! I had been struggling with this issue for months but your modification cleared things right up.

See, I'm using Hime's shapeshifting script, which transforms an actor into a different actor when a certain state is applied. Problem was, an actor would stay transformed even after dying, so I needed a way to change them back to normal the instant before they died. The issue must've had something to do with how the default system removes states upon death.

Whoops, there was one more thing. There are actually 3 transformation states in my game. Is there a way to remove all 3 of those states at once before death?
Just repeat the "remove_state(MYSTERY_STATE_ID_HERE)" line.

Or just use "clear_states", to remove everything.
Glad to hear it worked out! Good luck with your game e: (yeah just do what karins said, remove each state as needed, the remove_state should do the rest)
Works absolutely perfectly, I can't thank you all enough. *sniffle* You guys are good people. Anyway, this issue is now officially solved.
Pages: 1