Read more about advertising your project here
[RMVX] Regenerate HP/MP on Defense

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 86
Script Name: Regenerate HP/MP on Defense
Written by: Synthesize
Current Version: 1.2.0A
Release Date: January 20, 2008

What is this script?
With this script, the developer has the ability to allow players to regenerate HP and/or SP (Now MP) when they defend. The customization is at the top of the script. This script was made by analyzing the Scene_Battle script in the Trial version and then remaking it in XP, so there may/may not be bugs.

Features:
 - Regenerate HP/MP when you use defend
 - Customize how much HP/MP is regenerated per every actor
 - Enemies also Regenerate HP/MP when they defend
 - Displays how much HP/MP the battler regenerated
 - Customize the defend rates
 - Hopefully easy to use

Version history:
Version 1.2.0A
- Customize the defence rates
- Documentation has been added
- Draw Text option has been added
- Works with Enemies along with party members
- Displays how much HP/MP battlers regenerated

version 1.0.0A:
 - First release

The Script:
Code: [Select]
#===============================================================================
# Regenerate HP/MP - RMVX Version
#===============================================================================
# Written by Synthesize
# Version 1.2.0
# January 19, 2008
#===============================================================================
# *This script is not compatible with RPG Maker XP*
#===============================================================================
module SynRegen
  # Format = { Actor_ID => Percent to restore, Actor_ID2 => Percent to restore}
  HP_regen = {1 => 5, 2 =>7} # %
  # You can define how much HP each individual actor regenerates when they
  # Defend. Add new actors by seperating each returning value with a comma (,)
  #-----------------------------------------------------------------------------
  # This value determines the Default Percent growth if the Actor_ID is not
  # in the above hash
  HP_regen.default = 5 # %
  #-----------------------------------------------------------------------------
  # Set to true to enable HP regen in battle, false to disable.
  Use_hp_regen = true
  #----------------------------------------------------------------------------
  # Format = {Actor_ID => SP to restore
  SP_regen = {1 => 5, 2 => 7} # %
  # You can define how much SP each individual actor regenerates when they
  # defend. Add new actors by seperating each returning value with a comma (,)
  #-----------------------------------------------------------------------------
  # This is the default percentage to regenerate if the Actor_ID is not in the
  # hash.
  SP_regen.default = 5 # %
  #-----------------------------------------------------------------------------
  # Set to true to enable, false to disable
  Use_mp_regen = true
  #-----------------------------------------------------------------------------
  # Draw how much HP/MP the actor regenerated?
  Draw_text = true
  #-----------------------------------------------------------------------------
  # The defense rate if the actor has 'Super Defense'
  Super_guard_rate = 4
  #-----------------------------------------------------------------------------
  # The defense rate if the actor has 'Normal Defense'
  Normal_guard_rate = 2
end
#-------------------------------------------------------------------------------
# Scene_Battle
#   This aliases the execute_action_guard method in Scene_Battle
#-------------------------------------------------------------------------------
class Scene_Battle
  # Alias execute_action_guard
  alias syn_regen_execute_guard execute_action_guard
  #-----------------------------------------------------------------------------
  # Execute Action_Guard
  #-----------------------------------------------------------------------------
  def execute_action_guard
# Calculate the amount of HP and MP gained
hp_restore = ((@active_battler.maxhp * SynRegen::HP_regen[@active_battler.id]) / 100) if SynRegen::Use_hp_regen == true
sp_restore = ((@active_battler.maxmp * SynRegen::SP_regen[@active_battler.id]) / 100) if SynRegen::Use_mp_regen == true
# Calculate the different between MaxHP, HP, MaxMP and MP
temp_value_hp = (@active_battler.maxhp - @active_battler.hp)
temp_value_mp = (@active_battler.maxmp - @active_battler.mp)
# Add HP and MP
@active_battler.hp += hp_restore if SynRegen::Use_hp_regen == true
@active_battler.mp += sp_restore if SynRegen::Use_mp_regen == true
# Draw how much HP/MP the actor regenerated
if temp_value_hp != 0 and temp_value_mp != 0
  @message_window.add_instant_text("#{@active_battler.name} HP increased by #{hp_restore} and MP increased by #{sp_restore}")
elsif temp_value_hp != 0 and temp_value_mp == 0
  @message_window.add_instant_text("#{@active_battler.name} HP increased by #{hp_restore}")
elsif temp_value_hp == 0 and temp_value_mp != 0
  @message_window.add_instant_text("#{@active_battler.name} MP increased by #{sp_restore}")
end
# Call the original code
syn_regen_execute_guard
  end
end
#-------------------------------------------------------------------------------
# Game_Battler
#   This rewrites the defense method found in Game_Battler
#-------------------------------------------------------------------------------
class Game_Battler
  #-----------------------------------------------------------------------------
  # Apply_Guard_Damage
  #-----------------------------------------------------------------------------
  def apply_guard(damage)
if damage > 0 and guarding?
  # Divide the total damage from the effectivness of the defense rate.
  damage /= super_guard ? SynRegen::Super_guard_rate : SynRegen::Normal_guard_rate
end
return damage
  end
end
#===============================================================================
# This script is not compatible with Rpg Maker XP. However, I have also made a
# RPG Maker Xp version which can be found on RPGRPG Revolution.
#===============================================================================
#    * This script is untested but should work in theory *
#===============================================================================
# Written by Synthesize
# January 19, 2008
#===============================================================================
# Regenerate HP/MP - RMVX Version
#===============================================================================
over time, I will gradually re-create my XP scripts into RMVX.

Questions? Concerns? Feel free to post them.
« Last Edit: January 19, 2008, 10:51:29 PM by Synthesize »

******
Revolution is not a bed of roses.
Rep:
Level 89
Project of the Month winner for July 2009
Nice, these are always useful, they provide a real reason for using defense.

I'd move this to the database, but I'm going to look into making two databases, one for VX and one for XP.

**
Rep:
Level 86
version 1.2.0A has been released and is available on the first post.

[quote[
- Customize the defence rates
- Documentation has been added
- Draw Text option has been added
- Works with Enemies along with party members
- Displays how much HP/MP battlers regenerated
[/quote]

***
Rep:
Level 87
I AM THAT IS.
cool, but were exactly to I paste this in?
« Last Edit: March 08, 2008, 08:42:28 PM by oneray »

******
Rep:
Level 87
Let's attack agressively.
When you open your Project, click on the Paper and Pencil icon next to the Music one. In there scroll down where it says Material. Below it, press the Ins key on your keyboard and paste it on the blank spot on the right.

**
Rep: +0/-0Level 79
Let the battle begin.
The script works, but its not showing an actual number next to the sprites. I'm using a sideview battle system. Is there something I could add to it to make it so that numbers would appear?

**
Rep: +0/-0Level 73
RMRK Junior
Very cool script :D

*
Rep: +0/-0Level 71
RMRK Junior
You have our very well huh ...
I would like to ask you something ...
Permission to provide your scrips
forum in Brazilian ...
You will have all Credit brother ...

later add me on msn:
ykky-0.o @ hotmail.com

Thank you and hug