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.

Increasing maximum SP in battle

guy

Member

Ok, so you can do that with a state I see, but it's not very useful because it doesn't fill your sp up to the new max.

I saw on the battle scripts something that said change max sp, can't I just add an extra line in there that fills it up whenever max sp is changed. How would I do that?
 

guy

Member

Ok thanks for responding, but I should say that I don't know anything about scripting. I've never done any scripting at all. That being said, I think I can just make an extra line or two that fills up the SP when it's increased in that battle script. If I copy and paste what you wrote in there will that work?
 
I just barely wrote this as a request for somebody else a couple days ago XD

Code:
#===============================================================================

# ** States : Max HP/SP Refill

#===============================================================================

 

#-------------------------------------------------------------------------------

# * SDK Log

#-------------------------------------------------------------------------------

if Object.const_defined?(:SDK)

  SDK.log('States.MaxHP/SPRefill', 'Kain Nobel ©', 3.0, '04.01.2009')

end

 

#===============================================================================

# * RPG::State::FillRate

#===============================================================================

 

module RPG::State::FillRate

  #-----------------------------------------------------------------------------

  # * For states that'll reduce HP when inflicted, can HP be 0?

  #-----------------------------------------------------------------------------

  HP0_CanKill = {}

  #-----------------------------------------------------------------------------

  # * The Direct HP filled when this state is inflicted.

  #-----------------------------------------------------------------------------

  HP_Direct   = {}

  #-----------------------------------------------------------------------------

  # * The Percent HP filled when this state is inflicted.

  #-----------------------------------------------------------------------------

  HP_Percent  = {}

  #-----------------------------------------------------------------------------

  # * The random Variance of HP filled when this state is inflicted.

  #-----------------------------------------------------------------------------

  HP_Variance = {}

  #-----------------------------------------------------------------------------

  # * The Direct SP filled when this state is inflicted.

  #-----------------------------------------------------------------------------

  SP_Direct   = {}

  #-----------------------------------------------------------------------------

  # * The Percent SP filled when this state is inflicted.

  #-----------------------------------------------------------------------------

  SP_Percent  = {}

  #-----------------------------------------------------------------------------

  # * The random Variance of HP filled when this state is inflicted.

  #-----------------------------------------------------------------------------

  SP_Variance = {}

  #-----------------------------------------------------------------------------

  # * Default Settings (DON'T TOUCH : Will affect all states not defined.)

  #-----------------------------------------------------------------------------

  HP0_CanKill.default = true

  HP_Direct.default   = 0

  HP_Percent.default  = 0

  HP_Variance.default = 0

  SP_Direct.default   = 0

  SP_Percent.default  = 0

  SP_Variance.default = 0

end

 

#===============================================================================

# ** RPG::State

#===============================================================================

 

class RPG::State

  #-----------------------------------------------------------------------------

  # * HP Fill Rate

  #-----------------------------------------------------------------------------

  def hp_fill_rate(old, new)

    new -= old

    new *= FillRate::HP_Percent[@id] / 100.0

    new += FillRate::HP_Direct[@id]

    var = rand(FillRate::HP_Variance[@id] + 1)

    new += rand(2) > 0 ? var : -var

    return Integer(new)

  end

  #-----------------------------------------------------------------------------

  # * SP Fill Rate

  #-----------------------------------------------------------------------------

  def sp_fill_rate(old, new)

    new -= old

    new *= FillRate::SP_Percent[@id] / 100.0

    new += FillRate::SP_Direct[@id]

    var = rand(FillRate::HP_Variance[@id] + 1)

    new += rand(2) > 0 ? var : -var

    return Integer(new)

  end

end

 

#===============================================================================

# ** Game_Battler 

#===============================================================================

 

class Game_Battler

  #-----------------------------------------------------------------------------

  # * Alias Listings

  #-----------------------------------------------------------------------------

  alias_method :statesmaxhpsprefill_gmbtlr_addstate, :add_state

  #-----------------------------------------------------------------------------

  # * Add State

  #-----------------------------------------------------------------------------

  def add_state(id)

    if self.states.include?(id)

      statesmaxhpsprefill_gmbtlr_addstate(id)

      return

    end

    old_maxhp, old_maxsp = self.maxhp, self.maxsp

    statesmaxhpsprefill_gmbtlr_addstate(id)

    new_maxhp, new_maxsp = self.maxhp, self.maxsp

    fill_hp = self.hp + $data_states[id].hp_fill_rate(old_maxhp, new_maxhp)

    fill_sp = self.sp + $data_states[id].sp_fill_rate(old_maxsp, new_maxsp)

    unless self.hp.zero?

      self.hp = [fill_hp, 1].max

    end

    self.sp = fill_sp

  end

end

Similiar to setting up items/skills, you can set up the direct ammount, percentage ammount and variance of HP/SP to fill when certain states are inflicted. Lets say state #17 is "Bubble" which doubles MaxHP, and you want to fill HP entirely when inflicted with this state...

HP_Direct = {17 => 9999, ...}

Or if you want state #17 to set the inflicted target to 1 HP...

HP_Direct = {17 => -9999, ...}
HP0_CanKill = {17 => false, ...}


Things like that are what I set the script to do, if you have any problems/questions please PM me because I don't watch topics XD
 

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