Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

SP Regen

I was going to put this in RGSS/RGSS2 Help, but I figured it's more of a request so I put it here.  I would like a script that will regenerate 5 SP every 60 frames unless the player is in battle.  I want this script to work for the first actor in the party, not the others.  I also would like to be able to turn this script on and off based on a switch (I don't care which ID).  This seems like a fairly simple request, but I'm not great at scripting yet so I froze the game trying to do this.  Please, if you could explain how each line works, that would really help me!  Thanks in advance!

By the way, if I was not clear about something, please let me know.
 
@AbyssalLord: I took a quick look at it and it looks good! Although i don't have time to really "Look" at it right now, but later when i have time, i'll see if i can find out what's wrong with it. :thumb:

@omegazion: Hmm.. i don't really know VX scripting that well, i barley know what they've changed in VX..
But when i have time, i guess i could see if i can make it work for VX, that is, if noone beats me to the punch.^^


EDIT: It's done, i barley had to change anything, but it works for VX now. Here is it:
Code:
#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
#  First, i've aliased the initialize and update method in Game_System.
#  If you don't know what aliasing does i suggest that you read Me(tm)'s
#  tutorial Aliasing with ease. You can find the tutorial here:
#  
#  http://www.rmxp.org/forums/index.php?topic=5698
#
#
#==============================================================================
class Game_System
  alias gando_timer_init initialize
  alias gando_timer_update update
  #--------------------------------------------------------------------------
  # * Initialize the "Gando_timer".
  #--------------------------------------------------------------------------
  #  gando_timer_init - This will add the old code from def initialize in
  #                     Game_System.
  #
  #  @gando_timer - this is and instance variable holding the amount of 
  #                 frames(60). You could say that this is the timer.
  #
  #
  #  So what i have done is that i have added the @gando_timer in the 
  #  initialize method in Game_System.
  #
  #--------------------------------------------------------------------------
  def initialize
    gando_timer_init
    @gando_timer = 60
  end
  #--------------------------------------------------------------------------
  # * Reset_timer
  #--------------------------------------------------------------------------
  #   Here, you can add whatever you want to happen
  #   when x number of frames has passed.
  #
  #   The line : "unless $game_temp.in_battle" means, as long as your not
  #               in battle. With other words, it checks so that your not 
  #               in any battle, and if your not, it increases the sp.
  #
  #   The line : $game_party.actors[0].sp += 5, gives the first actor in 
  #              the party 5 sp. if you want to give another member sp you
  #              can just change the 0 to either 1,2 or 3 depending on which
  #              party member you want to increase the sp of.
  #
  #              You could also change the  .sp  to  .hp   to give the
  #              party member 5 hp instead of 5 sp.
  #
  #   @gando_timer = 60 - This will reset the timer to 60 again, so that
  #                       the lead actor can keep regenerate sp every 60 
  #                       frame.
  #
  #--------------------------------------------------------------------------
  def reset_timer
  unless $game_temp.in_battle
  if $game_switches[2] == true
    $game_party.members[0].mp += 10
  else if $game_switches[3] == true
    $game_party.members[0].mp += 1    
  else
    $game_party.members[0].mp += 5
  end
  end
  end
   @gando_timer = 60
  end
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  #  gando_timer_update -This will add the old code from def update in
  #                      Game_System.
  #
  #  reset_timer - This line will call the reset_timer method, 
  #                abd it will execute everything inside it.
  #
  #   I am not 100% sure about this, but i think the update method updates
  #   every frame. That means, that it will reduce the @gando_timer by 1
  #   every frame.  If i'm wrong, the i hope an experienced scripter can tell
  #   me if they see this.
  #--------------------------------------------------------------------------
  def update
    gando_timer_update
    # reduce timer by 1 if timer is above 0.
    if @gando_timer > 0
      @gando_timer -= 1
    end
    # Checks if swith 1 is on
   if $game_switches[1] == true
     #Checks if @gando_timer has reached 0, (if 60 frames has passed)
    if @gando_timer == 0
      reset_timer
    end
   end
 end
end
 
Because that's what AbyssalLord asked for.
If you want to have the other party members to also regenerate sp, put these lines under "$game_party.actors[0].sp += 5":

Code:
$game_party.actors[1].sp += 5
$game_party.actors[2].sp += 5
$game_party.actors[3].sp += 5
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top