#-----------------Begin Defense Script Insertion-------------------------
#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?
#-------------------------------------------------------------------------
#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 = 2 #Percentage of Max HP to restore.
b = 25 #Variance in HP restoration.
c = 1 #Percentage of Max SP to restore.
d = 25 #Variance in SP restoration.
e = battler.maxhp * a / 100 #Converting to percentage.
f = 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 battler.hp == battler.maxhp and battler.sp == battler.maxsp
@help_window.set_text("#{battler.name} is defending...", 1)
startup
elsif battler.sp == battler.maxsp
@help_window.set_text("#{battler.name} is defending. #{e.to_s} HP recovered!", 1)
battler.hp += e
elsif battler.hp == battler.maxhp and f < 1
@help_window.set_text("#{battler.name} is defending...", 1)
elsif battler.hp == battler.maxhp and f >= 1
@help_window.set_text("#{battler.name} is defending. #{f.to_s} MP recovered!", 1)
battler.sp += f
elsif battler.hp != battler.maxhp and battler.sp != battler.maxsp and e >= 1
@help_window.set_text("#{battler.name} is defending. #{e.to_s} HP recovered!", 1)
battler.hp += e
else
@help_window.set_text("#{battler.name} is defending. #{e.to_s} HP and #{f.to_s} MP recovered!", 1)
battler.hp += e
battler.sp += f
end
#-------------------End Defense Script Insertion-------------------------