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.

Battle script

Not to be offending, but this may look better:

Code:
    #-----------------Begin Defense Script Insertion-------------------------
     #by Khatharr (Creation Asylum)
     #This script is intended to be inserted in "Scene_Battle 4", replacing the line that reads:
     #"@help_window.set_text($data_system.words.guard, 1)"
     #If you cannot find this line, it may have been changed to:
     #"@help_window.set_text("Defend", 1)"
     #------------------------------------------------------------------------
     #In the first four lines of code there are question marks that must be replaced by values.
     #
     #"a" is the _Percentage of Max HP_ to restore when defending.  In other words, if your character
     #has 34/200 HP and defends, if this number is 50, then they will gain 100 HP, because 100 is 50%
     #of 200.
     #"b" is the _HP Variance Percentage_.  This randomizes the HP recovered by the
     #percentage entered.  In other words, if the Max HP is 100 and "a" is 50, then a "b" of 10 would
     #mean that anywhere from 45 to 55 HP would be restored.  That is 10% variance on 50% of 100.
     #If you don't understand that, then just set it to 15.
     #"c" is _Percentage of Max SP_ to restore, and works the same as "a".
     #"d" is _SP Variance Percentage_, and works the same as "b".  Again, if you don't understand
     #variance, just set it to 15.
     #
     #When entering values, use integers (whole numbers) only and do not put the "%" sign.  In other
     # words, if you want your character to regain 10% of his Max HP when he defends, change
     #"a = ?" to "a = 10".  0 is and acceptable value for "b" and "d".  I have not experimented with
     #values over 100 or under 0, but that would be silly anyways, wouldn't it?  :o
     #-------------------------------------------------------------------------
     #If you need help with this, message me in the forum and I'll make fun of you....
     #Okay, okay, I'll help you out!
     #Don't look at me like that!
     #Oh, and in case YOU DIDN'T KNOW, this idea came from DragoonDart and was coded by Khatharr, both
     #from DubeAlex's "Creation Asylum" forums.  Recognoiiiiize!  -*splutter*-
     #-------------------------------------------------------------------------
     a = ?        #Percentage of Max HP to restore.
     b = ?        #Variance in HP restoration.
     c = ?        #Percentage of Max SP to restore.
     d = ?        #Variance in SP restoration.
    
     e = @active_battler.maxhp * a / 100        #Converting to percentage.
     f = @active_battler.maxsp * c / 100
    
     if b > 0        #Randomizing HP.
       e += rand((e * b / 100) + 1) + rand((e * b / 100) + 1) - (e * b / 100)
     end
    
     if d > 0        #Randomizing SP.
       f += rand((f * d / 100) + 1) + rand((f * d / 100) + 1) - (f * d / 100)
     end
    
     #This chunk determines whether HP or SP is being restored and does so.
     #It also generates a help window message explaining what was restored, if anything.
     #I added the battler's name to the defense message.  Ya' like that?;)
     if @active_battler.hp == @active_battler.maxhp and @active_battler.sp == @active_battler.maxsp
       @help_window.set_text("#{@active_battler.name} is defending...", 1)
     elsif @active_battler.sp == @active_battler.maxsp
       @help_window.set_text("#{@active_battler.name} is defending. #{e.to_s}HP regained!", 1)
       @active_battler.damage = (e * -1)
       @active_battler.damage_pop = true
       @active_battler.hp += e
     elsif @active_battler.hp == @active_battler.maxhp
       @help_window.set_text("#{@active_battler.name} is defending. #{f.to_s}SP regained!", 1)
       @active_battler.sp += f
     else
       @help_window.set_text("#{@active_battler.name} is defending. #{e.to_s}HP and #{f.to_s}SP regained!", 1)
       @active_battler.damage = (e * -1)
       @active_battler.damage_pop = true
       @active_battler.hp += e
       @active_battler.sp += f
     end
     #-------------------End Defense Script Insertion-------------------------

Credits are within the script.
 

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