The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: wiiman on May 26, 2007, 05:59:29 PM

Title: [RESOLVED] Regain 5-10% SP whenever you defend script?
Post by: wiiman on May 26, 2007, 05:59:29 PM
I was just wondering if anybody has a script that whenever a character defends it would regenerate a certain amount of SP. Thanks in advance.
Title: Re: [Request] Regain 5-10% SP whenever you defend script?
Post by: Shinami on May 26, 2007, 11:19:41 PM
Give me about 10-15 minutes and I should have something that works.
Title: Re: [Request] Regain 5-10% SP whenever you defend script?
Post by: Shinami on May 27, 2007, 12:06:32 AM
Put this above main and below Scene_Battle. Change 0.1 to whatever decimal you want to be restored. The default is 10% aka 0.1

class Scene_Battle
  alias shinami_make_basic_action_result make_basic_action_result
  def make_basic_action_result
    if @active_battler.current_action.basic == 1
      sp_regain = $game_actors[@active_battler.id].maxsp * 0.1
      $game_actors[@active_battler.id].sp += sp_regain.to_i
    end#of "if @active_battler.current_action.basic == 1"
    shinami_make_basic_action_result
  end#of aliased "def make_basic_action_result"
end
Title: Re: [Request] Regain 5-10% SP whenever you defend script?
Post by: Kokowam on May 27, 2007, 12:19:15 AM
If you were make the code:

class Scene_Battle
  alias shinami_make_basic_action_result make_basic_action_result
  def make_basic_action_result
    if @active_battler.current_action.basic == 1
      sp_regain = $game_actors[@active_battler.id].maxsp * $game_variables[id#]
      $game_actors[@active_battler.id].sp += sp_regain.to_i
    end#of "if @active_battler.current_action.basic == 1"
    shinami_make_basic_action_result
  end#of aliased "def make_basic_action_result"
end

Where you change "id#" with the ID number of a variable, would it take that and use it as a multiplier? If so, you can use it so you change the variable and the amount of SP recovered increases when you raise the variable so quests = more SP regen. ;D
Title: Re: [RESOLVED] Regain 5-10% SP whenever you defend script?
Post by: wiiman on May 27, 2007, 07:13:33 PM
Thanks.
Title: Re: [Request] Regain 5-10% SP whenever you defend script?
Post by: Shinami on May 27, 2007, 10:13:01 PM
Quote from: Jae Young on May 27, 2007, 12:19:15 AM
Where you change "id#" with the ID number of a variable, would it take that and use it as a multiplier? If so, you can use it so you change the variable and the amount of SP recovered increases when you raise the variable so quests = more SP regen. ;D
You would probably have to use a call script command to make that work because I don't think RMXP allows decimals to be stored in $game_variables with the variable event command.
Title: Re: [RESOLVED] Regain 5-10% SP whenever you defend script?
Post by: Zeriab on May 27, 2007, 10:45:30 PM
That can be fixed
Just use this code instead ^_^

class Scene_Battle
  alias shinami_make_basic_action_result make_basic_action_result
  def make_basic_action_result
    if @active_battler.current_action.basic == 1
      sp_regain = $game_actors[@active_battler.id].maxsp * ($game_variables[id#] / 100.0)
      $game_actors[@active_battler.id].sp += sp_regain.to_i
    end#of "if @active_battler.current_action.basic == 1"
    shinami_make_basic_action_result
  end#of aliased "def make_basic_action_result"
end


The number in $game_variables[id#] is now the percentage ^_^
You still need to change the "id#"
Lower the 100.0 if you want finer distinction. You can also raise it. Just remember to make it a float. (100 wrong, 100.0 correct)
Title: Re: [RESOLVED] Regain 5-10% SP whenever you defend script?
Post by: Shinami on May 27, 2007, 10:47:42 PM
*slaps forehead* It seems the most simple solutions escape me sometimes.  ;9
Title: Re: [RESOLVED] Regain 5-10% SP whenever you defend script?
Post by: Zeriab on May 28, 2007, 09:00:02 AM
Quote from: Shinami on May 27, 2007, 10:47:42 PM
*slaps forehead* It seems the most simple solutions escape me sometimes.  ;9

The problem with the simplest solutions is that they often can be the most difficult to come up with.
All you can do is learn and remember till next time ^_^