RMRK is retiring.
Server is paid up for the rest of 2026, but the forum may go after that. See here for more information. Please archive or save anything you would like to keep before 2027.
Main Menu

[RESOLVED] Regain 5-10% SP whenever you defend script?

Started by wiiman, May 26, 2007, 05:59:29 PM

0 Members and 1 Guest are viewing this topic.

wiiman

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.

Shinami

Give me about 10-15 minutes and I should have something that works.

Shinami

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

Kokowam

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


Shinami

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.

Zeriab

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)

Shinami

*slaps forehead* It seems the most simple solutions escape me sometimes.  ;9

Zeriab

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 ^_^