Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Defense = HP/SP gain Script
#1
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.


This is the "restorative defense" script I came up with that's been bouncing around the help forum for a month or two. It's done. Be glad.

This script makes it so that when you "Defend" in battle you regain some percentage of your Max HP and/or SP. It also has customizable variability.

I added some minor features to it since my last post. HP regained now pops up on the characters, and the defending chracter's name has been added to the help window message. You have to enter values to get it to work, so read the comment to get it set up right. Unless, of course, you want a "crash my game" script.

Code:
#-----------------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?  :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-------------------------

I know the window isn't wide enough and some of the lines are split, but if you copy and paste the whole thing it should go into your script editor properly.
}


Possibly Related Threads…
Thread Author Replies Views Last Post
  Change character script jaigai 0 2,797 11-19-2006, 01:00 PM
Last Post: jaigai
  Just a modification of Abyssos' facs script lumina... 0 2,633 11-01-2006, 01:00 PM
Last Post: lumina...
  Credit Script 1.1 acoole 0 2,473 10-24-2006, 01:00 PM
Last Post: acoole
  Script Dev Kit Nick 0 2,845 10-15-2006, 01:00 PM
Last Post: Nick
  Opening Image script sasuke89 0 2,060 07-24-2006, 01:00 PM
Last Post: sasuke89
  Change Color of The diferent Status Script MASTERLOKI 0 2,311 07-18-2006, 01:00 PM
Last Post: MASTERLOKI
  Event Name and ID Search Script Hadriel 0 2,077 06-21-2006, 01:00 PM
Last Post: Hadriel
  Currency Script Split 0 2,312 05-18-2006, 01:00 PM
Last Post: Split
  Book Script and Utility Bruth 0 2,262 05-07-2006, 01:00 PM
Last Post: Bruth
  Individuality Script DrakoShade 0 2,223 03-12-2006, 01:00 PM
Last Post: DrakoShade



Users browsing this thread: