The RPG Maker Resource Kit

RMRK RPG Maker Creation => XP => XP Scripts Database => Topic started by: Sir Edeon X on July 04, 2005, 01:58:09 PM

Title: Regen, Auto-Life and more!!!
Post by: Sir Edeon X on July 04, 2005, 01:58:09 PM
By: Sir Edeon X

Desperate not, my beloved FF Fans! Here I am leading you to salvation. :)
This tutorial includes easy follow-the-steps guide to making:

--> Regen Status: For those who don't know what this is, it is the opposite of poison. Instead of damaging you,
it heals you.
--> Change MP Cost: Whether Half MP Cost or No MP Cost, learn how to reduce the amount of MP you use
for spells during battle. Remember the Gold Hairpin in FF6? This is useful!
--> Auto-Life Status: This status assures that when you're killed, you'll be automatically revived. This is present
in all FF above the 6th! So, why can't you use it, too? :)
--> 9999 ATK: A status to assure that your next attacks will cause 9999 of damage.
--> Critical ATK:  A status to assure that your next attacks will hit with critical dmg.
--> Overdrive: For those who use anykind of overdrive script, this status accelerates the overdrive bar.
--> Demi and Quarter Spells (or Gravity and Gravija): For those who don't know what these spells does,
they reduce enemy's HP by 1/2 or 1/4.
--> Changing Items and Skills name and description during game: Useful if you want your game to include
more than one language!

Let's begin!!! If you have any doubt through any of these steps, just check the previous topic, where all steps
are explained a lot better. For example, if you begin reading the 9999 ATK, I suggest to read REGEN first, where
I explain everything better.

REGEN:

a) Open up Database, select Status Effects
b) Create a new one called Regen and select the animation you want.
c) Check the first and last box ('Unresistable' and 'Progressive Damage')
d) Check the 'Ends after battle' box
e) Select the amount of turns you want it to last for, and input '100' after it. Personnaly, I like it to last during
5 turns, so, this would be like this: 'After   5    turns, there is a   100   % Chance of Recovery Each
f) Check the id (number before the name) of 'Regen'
g) Close the Database.
h) Open up the Script Editor and search (Ctrl+Shift+F) for 'def update_phase4_step2'
If more than one appears, you'll have to add to both. This will assure that whatever scripts you have, this
will work.
i) Double click on it and add

if @active_battler.hp > 0 and @active_battler.regen?
  @active_battler.regen_effect
  @active_battler.restorative = true
  @active_battler.damage_pop = true
end

below 'def update_phase4_step2'.
j) Go to Game_Battler 2 and replace the last 'end' for

def regen?
  for i in @states
    if $data_states.slip_damage and i == !!!!!!
      return true
    end
  end
  return false
 end
def regen_effect
   self.damage = self.maxhp / 10
   if self.damage.abs > 0
     amp = [self.damage.abs * 15 / 100, 1].max
     self.damage += rand(amp+1) + rand(amp+1) - amp
   end
   self.hp -= -self.damage
   return true
 end
end

k) replace the '!!!!!!' for the id of Regen
l) Go to line 129 (or the one where's 'def slip_damage?' and replace

if $data_states.slip_damage

for

if $data_states.slip_damage and i != !!!!!!

m) replace the '!!!!!!' for the id of Regen

And that's all!!! You just have to create a skill that adds this status! The only problem is that the recovery
will pop up as damage (white colored). This can be easily changed with a script for damage coloring. Here
it is. Put it before Main. This one was put together by me. I don't know who wrote the first class script, but
I've changed it a lil' bit. Thanks to whoever wrote it.

module RPG
 class Sprite < ::Sprite
   def damage(damage, critical, restorative)
     dispose_damage
     if damage.is_a?(Numeric)
       damage_string = damage.abs.to_s
     else
       damage_string = damage.to_s
     end
     bitmap = Bitmap.new(160, 48)
     bitmap.font.name = "High Tower Text"
     bitmap.font.size = 40
     bitmap.font.color.set(0, 0, 0)
     bitmap.draw_text(-1, 12-1, 160, 20, damage_string, 1)
     bitmap.draw_text(+1, 12-1, 160, 20, damage_string, 1)
     bitmap.draw_text(-1, 12+1, 160, 20, damage_string, 1)
     bitmap.draw_text(+1, 12+1, 160, 20, damage_string, 1)
     if damage.is_a?(Numeric) and damage < 0
       bitmap.font.color.set(176, 255, 144)
     elsif restorative
       bitmap.font.color.set(176, 255, 144)
     else
       bitmap.font.color.set(255, 255, 255)
     end
     bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
     if critical
       bitmap.font.size = 20
       bitmap.font.color.set(0, 0, 0)
       bitmap.draw_text(-1, -1, 160, 36, "CRITICAL", 1)
       bitmap.draw_text(+1, -1, 160, 36, "CRITICAL", 1)
       bitmap.font.color.set(255, 255, 255)
       bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
     end
     @_damage_sprite = ::Sprite.new(self.viewport)
     @_damage_sprite.bitmap = bitmap
     @_damage_sprite.ox = 80
     @_damage_sprite.oy = 20
     @_damage_sprite.x = self.x
     @_damage_sprite.y = self.y - self.oy / 2
     @_damage_sprite.z = 3000
     @_damage_duration = 40
   end
 end
end
# --------------------------------
class Game_Battler
 attr_accessor :restorative  
 alias game_battler_initialize initialize
 def initialize
   game_battler_initialize
   @restorative = false
 end
end
# --------------------------------
class Sprite_Battler < RPG::Sprite
 def update
   super
   if @battler == nil
     self.bitmap = nil
     loop_animation(nil)
     return
   end
   if @battler.battler_name != @battler_name or
      @battler.battler_hue != @battler_hue
     @battler_name = @battler.battler_name
     @battler_hue = @battler.battler_hue
     self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
     @width = bitmap.width
     @height = bitmap.height
     self.ox = @width / 2
     self.oy = @height
     if @battler.dead? or @battler.hidden
       self.opacity = 0
     end
   end
   if @battler.damage == nil and
      @battler.state_animation_id != @state_animation_id
     @state_animation_id = @battler.state_animation_id
     loop_animation($data_animations[@state_animation_id])
   end
   if @battler.is_a?(Game_Actor) and @battler_visible
     if $game_temp.battle_main_phase
       self.opacity += 3 if self.opacity < 255
     else
       self.opacity -= 3 if self.opacity > 207
     end
   end
   if @battler.blink
     blink_on
   else
     blink_off
   end
   unless @battler_visible
     if not @battler.hidden and not @battler.dead? and
        (@battler.damage == nil or @battler.damage_pop)
       appear
       @battler_visible = true
     end
   end
   if @battler_visible
     if @battler.hidden
       $game_system.se_play($data_system.escape_se)
       escape
       @battler_visible = false
     end
     if @battler.white_flash
       whiten
       @battler.white_flash = false
     end
     if @battler.animation_id != 0
       animation = $data_animations[@battler.animation_id]
       animation(animation, @battler.animation_hit)
       @battler.animation_id = 0
     end
     if @battler.damage_pop
       damage(@battler.damage, @battler.critical, @battler.restorative)
       @battler.damage = nil
       @battler.critical = false
       @battler.damage_pop = false
       @battler.restorative = false
     end
     if @battler.damage == nil and @battler.dead?
       if @battler.is_a?(Game_Enemy)
         $game_system.se_play($data_system.enemy_collapse_se)
       else
         $game_system.se_play($data_system.actor_collapse_se)
       end
       collapse
       @battler_visible = false
     end
   end
   self.x = @battler.screen_x
   self.y = @battler.screen_y
   self.z = @battler.screen_z
 end
end

------------------------------------------------------------------------------------------------------------------------------------------------
CHANGING MP COST:
These are a lot easier. I'll teach you how to reduce the MP(SP) cost to Half and to 0.

a) Open the database, and in the Status Effects create two new status: 'Half MP Cost' and 'No MP Cost'
b) Check the 'unresistable' box, which is the first one, and put them to end after battle, for both!
c) Put a minus before 'Half MP Cost' IN THE 'No MP Cost'
c) Check the id of the status (no. before the name) and close the database.
d) Script editor!!! Go to Window_Skill and change the  

self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)

for
#----------------------------------
mp_cost = skill.sp_cost
  if @actor.states.include?(!!!!!)
     mp_cost /= 2
  end
  if @actor.states.include?(*****)
     mp_cost *= 0
  end
self.contents.draw_text(x + 226, y, 48, 32, mp_cost.to_s, 2)
#----------------------------------
where '!!!!!' is the 'Half MP Cost' ID and ***** the 'NO MP Cost' ID.
e) Search for '@active_battler.sp -= @skill.sp_cost'. If more than one appears, you'll have to do the following
to both.
f) Replace

@active_battler.sp -= @skill.sp_cost

for
#----------------------------------
if @active_battler.states.include?(*****)
 @active_battler.sp -= 0
elsif @active_battler.states.include?(!!!!!)
 @active_battler.sp -= (@skill.sp_cost / 2)
else
 @active_battler.sp -= @skill.sp_cost
end
#----------------------------------
where '!!!!!' is the 'Half MP Cost' ID and ***** the 'NO MP Cost' ID.
That's all. Create a skill that adds one of them, or even an accessory that auto-inflict one of these.
Title: Continuation
Post by: Sir Edeon X on July 04, 2005, 02:04:13 PM
AUTO_LIFE:
a) Yet again, create a new status called 'Auto-Life'. Put it 'Unresistable' and ending after battle.
b) After selecting the animation, memorize the ID of 'Auto-Life'
c) In the Script Editor, go to Game_Party and search for 'def all_dead?'.
d) Below

for actor in @actors
 if actor.hp > 0
   return false
 end

add
#----------------------------------
if actor.states.include?(Auto-life ID!!!!!)
 return false
end
#----------------------------------
e) In Scene_Battle1, go to 'def Judge', and before everything (if $game_party.all_dead...) add

for i in 0...$game_party.actors.size
 actor = $game_party.actors
 if actor.states.include?(Auto-life ID!!!!!) and actor.hp == 0
   actor.hp += 1
   @battler = $game_actors[actor.id]
   @battler.remove_state(Auto-life ID!!!!!)
   @battler.remove_state(1)
   @dead = false
   @battler.animation_id = 25 #(this is the number of MY ressurection animation. I don't know if it is yours, too)
   @battler.restorative = true
   @battler.damage = "Auto-Life!"
   @battler.damage_pop = true
   #@spriteset.actor_sprites.default_pose (if you have the animated side view battle script, remove the #)
 end
end

f) That's all. Remember adding the damage_coloring script I gave above in REGEN or you'll receive an error
message! Now, create a skill that adds it, or even an accessory that auto-inflicts it!

--------------------------------------------------------------------------------------------------------------------------------------------------------------------
9999 ATK and CRITICAL ATK:

a) You know what to do, right? Create both status in the database.
b) Check the 'unresistable' box and put them to end after battle and after X turns, I like 4 turns. (Check REGEN
to know how this is done, if you don't know)
c) In '9999 ATK' status, put a minus before 'CRITICAL ATK'
d) Remember both numbers and open up the script editor
e) Search for 'attack_effect' in Game_Battler3 and look for:

if rand(100) < 4 * attacker.dex / self.agi
  self.damage *= 2
  self.critical = true
end

f) replace it for:

if attacker.states.include?(CRITICAL ATK ID!!!!)
  self.damage *= 2
  self.critical = true
else
  if rand(100) < 4 * attacker.dex / self.agi
     self.damage *= 2
     self.critical = true
  end
end

g) look also for 'remove_states_shock'. Below it put this:

if attacker.states.include?(9999 ATK ID!!!!)
  self.damage = 9999
end

That's all!!! Create a skill or so. :)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
OVERDRIVE:

If you have an overdrive bar, here it is a little help.

a) Create a status called 'Overdrive x1.5' and another called 'Overdrive x2'.
b) Make it unresistable and ending after a few turns (I like 4 :P)
c) Put a minus before 'Overdrive x1.5' IN 'Overdrive x2' status 'cuz 2 is bigger than 1.5!
d) Search for '.overdrive +=' (Ctrl+Shift+F) and do this in each topic:
e) Replace the XXXX.overdrive += YYYY for (doesn't matter what you have besides XXXX or YYYY':

if XXXX.states.include?(OVERDRIVE X2 ID)
  XXXX.overdrive += YYYY * 2
elsif XXXX.states.include?(OVERDRIVE X1.5 ID)
  XXXX.overdrive += YYYY * 1.5
else
  XXXX.overdrive += YYYY
end
f) And that's all. Create a skill or an item which adds you this status and that's all.
Title: Regen, Auto-Life and more!!!
Post by: Sir Edeon X on July 04, 2005, 02:05:23 PM
DEMI AND QUARTER SPELLS:

a) create two attributes in the database (system). call them like 'Demi' or '1/2 HP' and 'Quarter' or '1/4'. What
you like
b) Memorize the IDs and go to the script editor
c) Go to Game_Battler3 and search for 'last_hp = self.hp' in 'def skill_effect(user, skill)'
d) Replace

last_hp = self.hp
self.hp -= self.damage

for

if skill.element_set.include?(DEMI STATUS ID!!!!)
 @damage_hp = self.hp * 50 / 100
 self.damage = @damage_hp
 last_hp = self.hp
 self.hp -= @damage_hp
 @hp_damaging = true
elsif skill.element_set.include?(QUARTER STATUS ID!!!!)      
 @damage_hp = self.hp * 25 / 100
 self.damage = @damage_hp
 last_hp = self.hp
 self.hp -= @damage_hp
 @hp_damaging = true
else
  last_hp = self.hp
  self.hp -= self.damage
end

e) Now, below 'unless @status_changed' there's a 'self.damage = "Miss" '. Replace it for

if @hp_damaging = true
  self.damage = @damage_hp
  @hp_damaging = false
else
  self.damage = "Miss"
end  

f) And that's all. Create a skill WITH NO effect rating, but WITH the element you want it to do. That's all :)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
CHANGING ITEMS AND SKILL DESCRIPTION:

Want to have more than one language in your game (like me: English and Portuguese)? Don't make twice
as many items and skills, and so, which I previously did. This cause you to assure that the player can't
change language in the middle of the game! If he changes it, he will play in one language with items from
another one! Now, follow me here to see how everything is done:

a) In your language choosing menu, add '$game_variables[XXXX] = 0' for the first language
and increase the number for the next ones. (You can use this variable to change the messages in events)
b) Then, go to Game_System and replace the last 'end' for

 def english? #(or what you want)
   if $game_variables[XXXX] == 0
     return true
   else
     return
   end
 end
 def portuguese?#(or your second language)
   if $game_variables[XXXX] == 1
     return true
   else
     return
   end
 end
end

c) Now search (Ctrl+Shift+F) for 'item.name' and make the game check if the language was changed and
if that's true, add a letter before 'name', like 'p' for portuguese name :)

if $game_system.portuguese?#(for example)
  self.contents.draw_text(x + 28, y, 212, 32, item.pname, 0)
else #(or 'elsif $game_system.chinese?' if you have more than 2 langs)
  self.contentsdraw_text(x + 28, y, 212, 32, item.name, 0)
end

d) Do this for all the topics and do the same thing for 'skill.name'
e) Create a new script above Main called Portuguese(or what you want) Item Name and do this:

module RPG
 class Item
   def pname
     if self.id == 1
       return "Po
Title: Regen, Auto-Life and more!!!
Post by: Leeroy_Jenkins on July 05, 2005, 03:03:18 AM
:shock: you are amazing :shock:
Title: Oh My GOSH, THANK YOU!!!
Post by: Ammom on December 14, 2005, 02:37:06 AM
:shock:  Finally, someone has had the sense to do this!

Oh my you don't know ho mmuch I have been waiting for something like this! Dude, you are FRICKIN AWESOME MAN!!!!

Hey, do you know how to break the Level 99 system by chance?
Title: Regen, Auto-Life and more!!!
Post by: Inaru on December 14, 2005, 02:43:19 AM
Are you sure you can't create a system, without using scripts? I'm preety sure you can create most of them. Like the quarter one, you would make a varible, equal it to the enemy's HP, divide by 4, then subtract the varible from the HP of the enemy. I haven't checked, but I am preety sure there is a way to have a varible equal a monster's HP.
Title: Re: Regen, Auto-Life and more!!!
Post by: Teovak454 on December 16, 2008, 11:17:20 PM
hey i have a problem with the regen script. like everytime it regens health, like right after if regens a thing pops up saying " Script 'Game_Battler 2' line 296: NoMethodError occured.
                                     undefined method `slip_damage' for #<Array:0x141b8d0>
Title: Re: Regen, Auto-Life and more!!!
Post by: Teovak454 on December 17, 2008, 10:08:57 PM
also that regen color script is messing with my CBS. i'm using a side view battle system and with the color script the ally battlers disappear and the enimies show their sprite, i need help
Title: Re: Regen, Auto-Life and more!!!
Post by: thanatos2k1 on June 24, 2011, 05:57:18 AM
This is wonderful.  I'm going to try this one out soon. I love Regen and Autolife. Very very cool.
Title: Re: Regen, Auto-Life and more!!!
Post by: thanatos2k1 on June 24, 2011, 05:58:30 AM
Ooo, I just realized this is for XP,  does anyone know if it works for VX?
Title: Re: Regen, Auto-Life and more!!!
Post by: thanatos2k1 on July 18, 2011, 06:09:31 PM
bump
Title: Re: Regen, Auto-Life and more!!!
Post by: gerkrt on July 18, 2011, 09:52:38 PM
I doubt a lot because the defaults scritps are different.

This is the worse script to install and configure i have ever seen, for sure...