The RPG Maker Resource Kit

RMRK RPG Maker Creation => Requests => Script Request => Topic started by: dragon3025 on August 12, 2012, 03:12:14 PM

Title: [VXA][SOLVED] States Immune to Full Recovery
Post by: dragon3025 on August 12, 2012, 03:12:14 PM
States Immune to Full Recovery
8/12/12



Summary
I hate how full recovery event command removes positive states, (for example you have a state that boost defense, and it get's removed once you use full recovery). Can someone make a script that allows choose which states aren't affected by it.

Features Desired

Games its been in



Did you search?
Yes

Where did you search?

What did you search for?
Title: Re: [VXA] States Immune to Full Recovery
Post by: pacdiggity on August 12, 2012, 09:01:25 PM
Put the tag "\no_recover" in the notebox of states you don't want to remove upon full recovery.

Code: [Select]
class Game_BattlerBase
  def clear_states
    hold_states = []
    states.each { |state|
      hold_states.push if !state.note[/\\no[_ ]recover/i].nil?
    }
    @states = hold_states
    @state_turns = {}
    @state_steps = {}
  end
end
Title: Re: [VXA] States Immune to Full Recovery
Post by: dragon3025 on August 13, 2012, 04:32:35 AM
Put the tag "\no_recover" in the notebox of states you don't want to remove upon full recovery.

Code: [Select]
class Game_BattlerBase
  def clear_states
    hold_states = []
    states.each { |state|
      hold_states.push if !state.note[/\\no[_ ]recover/i].nil?
    }
    @states = hold_states
    @state_turns = {}
    @state_steps = {}
  end
end
Thanks for the reply Pacman. I tried it and it gave me this error though:

Script 'Game_BattlerBase' line 146: NoMethodError occured.

undefined method `collect' for nil:NilClass

I then tried using it in a fresh new project and it removed the "\no_recover" states also.
Title: Re: [VXA] States Immune to Full Recovery
Post by: pacdiggity on August 13, 2012, 10:21:42 AM
This should work.
Code: [Select]
class Game_BattlerBase
  alias no_recover_states_init initialize
  def initialize(*args)
    @states = []
    no_recover_states_init(*args)
  end
  alias no_recover_states_clear clear_states
  def clear_states(*args)
    hold_states = []
    for state in states
      hold_states.push(state.id) if state.note[/\\no[_ ]recover/i] != nil
    end
    no_recover_states_clear(*args)
    @states = hold_states
  end
end
Title: Re: [VXA] States Immune to Full Recovery
Post by: dragon3025 on August 13, 2012, 05:11:02 PM
This should work.
Code: [Select]
class Game_BattlerBase
  alias no_recover_states_init initialize
  def initialize(*args)
    @states = []
    no_recover_states_init(*args)
  end
  alias no_recover_states_clear clear_states
  def clear_states(*args)
    hold_states = []
    for state in states
      hold_states.push(state.id) if state.note[/\\no[_ ]recover/i] != nil
    end
    no_recover_states_clear(*args)
    @states = hold_states
  end
end
It gave me this error:
Script 'Game_Actor' line 52: TypeError occurred

no implicit conversion from nil to integer

and I tried it in a new project again and it removed all of the states again.
Title: Re: [VXA] States Immune to Full Recovery
Post by: pacdiggity on August 13, 2012, 09:11:51 PM
I don't get that error. It works completely fine for me.
Title: Re: [VXA] States Immune to Full Recovery
Post by: dragon3025 on August 14, 2012, 02:46:39 AM
I don't get that error. It works completely fine for me.
I put without quotes "\no_recover" with the backslash included right? I don't understand, you tried this in a fresh new project right?
Title: Re: [VXA] States Immune to Full Recovery
Post by: pacdiggity on August 14, 2012, 11:40:11 AM
Yes, new project, everything. Works fine.
Title: Re: [VXA] States Immune to Full Recovery
Post by: dragon3025 on August 14, 2012, 07:28:29 PM
Yes, new project, everything. Works fine.
Sorry, it is working now. I made the silly mistake of putting the script below "Main". Thanks for the script, this really helps.

I tested it out while placing other script in it, (one at a time), and finally figured it out, Yanfly's 'Yanfly Engine Ace - Passive States v1.02" is causing this compatibility error:

"Script 'Game_Actor' line 52: TypeError occurred

no implicit conversion from nil to integer"

The problem was fixed though: http://rmrk.net/index.php/topic,46683.0.html