Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> [RMVX] Regenerate HP/MP on Defense
Ty
post Jan 19 2008, 01:05 AM
Post #1


Level 38
Group Icon

Group: +Gold Member
Posts: 1,007
Type: Scripter
RM Skill: Undisclosed




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
#===============================================================================
# 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.

This post has been edited by Synthesize: Jan 19 2008, 03:40 PM


__________________________
My Script Demo link broken? Looking for old scripts? Go here:
http://synthesize.4shared.com
Go to the top of the page
 
+Quote Post
   
Rory
post Jan 19 2008, 05:33 AM
Post #2


GFX Pro
Group Icon

Group: +Gold Member
Posts: 409
Type: Artist
RM Skill: Skilled




ohmy.gif This is a good idea, since the old Defense feature had no point.


__________________________

THE SAVAGE NYMPH
Note: this is Magdreamer, I'm using my real name for my forum name now.
Go to the top of the page
 
+Quote Post
   
SeeYouAlways
post Jan 19 2008, 05:38 AM
Post #3


Demented Moogle
Group Icon

Group: Banned
Posts: 1,130
Type: None
RM Skill: Undisclosed




Like I suggested before, you should document the configuration part of the script for people that don't know scripting.

Also, maybe you can expand on this as an "Improved Defense" script so you can do things like decrease the damage recieved even more if you use defend, or increase the threat on the enemy so they tend to attack you more, kind of like a "cover" ability.

Well, those are my hopeful suggestions but you're probably not up to it. tongue.gif


__________________________
Go to the top of the page
 
+Quote Post
   
Ty
post Jan 19 2008, 03:39 PM
Post #4


Level 38
Group Icon

Group: +Gold Member
Posts: 1,007
Type: Scripter
RM Skill: Undisclosed




V.1.2.0 has been released and can be found in the first post.

QUOTE
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


Also, does a mod mind moving this to the RGSS-2 forum? Thanks ^^

This post has been edited by Synthesize: Jan 19 2008, 03:51 PM


__________________________
My Script Demo link broken? Looking for old scripts? Go here:
http://synthesize.4shared.com
Go to the top of the page
 
+Quote Post
   
ImmortalDreamer
post Jan 24 2008, 09:18 AM
Post #5


Emissary of Chaos
Group Icon

Group: Revolutionary
Posts: 162
Type: Mapper
RM Skill: Skilled




As an Rm2k3 user, I'm new to the whole scripts thing. Where do I put this to make it work?


__________________________
.::Current Projects::.
Loremaster VX
Go to the top of the page
 
+Quote Post
   
SeeYouAlways
post Jan 24 2008, 04:15 PM
Post #6


Demented Moogle
Group Icon

Group: Banned
Posts: 1,130
Type: None
RM Skill: Undisclosed




Insert a new script anywhere above the "Main" script in the script editor and paste the code in there. It should work after that. smile.gif


__________________________
Go to the top of the page
 
+Quote Post
   
Jon_jon_elpresid...
post Jan 31 2008, 01:36 AM
Post #7


Level 1
Group Icon

Group: Member
Posts: 5
Type: Event Designer
RM Skill: Beginner




I can't seem to get it to work i posted it in it's own page above the mainand all it does is say something in japanese(the command i assume.) randomly they glow and nothing! help plz!
Go to the top of the page
 
+Quote Post
   
NiniaDrain
post Feb 26 2008, 09:02 AM
Post #8



Group Icon

Group: Member
Posts: 1
Type: Event Designer
RM Skill: Skilled




Works fine for me, thanks!
Go to the top of the page
 
+Quote Post
   
Diedrupo
post Feb 27 2008, 11:03 AM
Post #9


Level 10
Group Icon

Group: Revolutionary
Posts: 150
Type: Event Designer
RM Skill: Undisclosed




QUOTE (Magdreamer @ Jan 19 2008, 06:40 AM) *
ohmy.gif This is a good idea, since the old Defense feature had no point.


Actually, defending by default does have a point if you add some intelligent enemy actions in battle. For instance, if you have an enemy that charges his attack for 1 round and unleashes it the next round, and you know that the charged attack would kill you in 1 hit, but defending would mitigate that, it would be better to defend...

That's just one example, there are plenty of other scenarios you can think of.
Go to the top of the page
 
+Quote Post
   
CrimsonPride
post Mar 6 2008, 10:47 PM
Post #10


Level 3
Group Icon

Group: Member
Posts: 30
Type: Event Designer
RM Skill: Skilled




For some reason I'm getting a syntax error at line 18 (HP_regen.default = 5 # %).

I copied the script exactly so I'm not sure why this is..
Go to the top of the page
 
+Quote Post
   
Jemik
post Mar 14 2008, 02:54 PM
Post #11


Level 7
Group Icon

Group: Revolutionary
Posts: 106
Type: Event Designer
RM Skill: Skilled




Great in theory and would love to use it, and have already tried it.

but it would be better if it only restored LOST hp and mp.
Its just giving you random hp and mp almost every time you guard. even at full hp/mp.
Go to the top of the page
 
+Quote Post
   
Mune
post Mar 15 2008, 10:45 AM
Post #12


Level 1
Group Icon

Group: Member
Posts: 9
Type: Event Designer
RM Skill: Beginner




nevermind, I fixed it myself...

This post has been edited by Mune: Mar 15 2008, 11:03 AM


__________________________
Go to the top of the page
 
+Quote Post
   
epfrndz
post Mar 26 2008, 04:00 AM
Post #13


Level 1
Group Icon

Group: Member
Posts: 5
Type: Developer
RM Skill: Skilled




where do i add this script?
Go to the top of the page
 
+Quote Post
   
Xirdneh
post Apr 12 2008, 05:18 PM
Post #14


Level 5
Group Icon

Group: Member
Posts: 69
Type: None
RM Skill: Skilled




QUOTE (epfrndz @ Mar 26 2008, 04:14 AM) *
where do i add this script?



Scroll up and read!


__________________________
Current project, Transition of Ages I. 1-10% completed.
Go to the top of the page
 
+Quote Post
   
oblivionator
post Apr 30 2008, 01:54 AM
Post #15


Level 8
Group Icon

Group: Revolutionary
Posts: 124
Type: Event Designer
RM Skill: Advanced




just a quick note, i tried this awesome script and found out that when i put false for increasing HP while defending and true enough it stopped adding HP but the message still appears something like this:
"Ylva's HP increased by and MP increased by 11"
meaning whether or not the character's HP is regenerated, it will still says so, which is weird... =/

another thing is, i want to be able to enable the HP regeneration thing at some point later, perhaps for a Regen skill, how should i go about in re-enabling that script?

help appreciated! biggrin.gif


__________________________

Join the Team NOW! =D


Current Projects:
-Khaos Spiral




Go to the top of the page
 
+Quote Post
   
Création
post Jun 1 2008, 08:37 PM
Post #16


Level 7
Group Icon

Group: Revolutionary
Posts: 102
Type: None
RM Skill: Undisclosed




The script works! Thanks!

Unfortunately, I can't get text to show up whenver the regeneration actually takes place.

I'm using "taikensen" battle script.

Would it be possible to have numbers pop up just like when you're attacking?

Not sure if I'm clear.
Go to the top of the page
 
+Quote Post
   
The Frontera
post Jan 11 2010, 09:23 AM
Post #17


Level 2
Group Icon

Group: Member
Posts: 22
Type: Developer
RM Skill: Advanced




Great script ! Now someone would use the GUARD option ! laugh.gif
Thanks !


__________________________
Visit my official website for resources, games, and informations.
Download for free my (great) videogames and resources.
Link:
http://thefrontera.knossus.net

Watch also my great videos on YouTube !
Link:
http://www.youtube.com/user/AdamCorporation

The VX Project I'm working on: (Click to see the Description)


My Completed VX Games: (Click to Download)


My Completed XP Games: (Click to Download)




Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 19th June 2013 - 06:10 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker