Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Closed TopicStart new topic
> Regeneration Script
ZFMaster
post Dec 23 2008, 03:48 PM
Post #1


ZFMaster; Master at Zelda Freaking.
Group Icon

Group: Revolutionary
Posts: 160
Type: Developer
RM Skill: Masterful




THIS SCRIPT LETS YOU REGENERATE HP/MP ON OCCASION IT IS HIGHLY EDITABLE.

PASTE ABOVE MAIN


[Show/Hide] THE SCRIPT
CODE
#========================================================================
=
=====
# ** Regeneration
#------------------------------------------------------------------------------
#  © Zelda Freak, 2008
#  04/11/08
#  Version 1.0
#------------------------------------------------------------------------------
#  VERSION HISTORY:
#   - 1.0 (01/11/08), Initial release
#------------------------------------------------------------------------------
#  INTRODUCTION:
#     This script will let actors regenerate HP/MP in 3 occasions.
#     Regeneration can occur on map, when defending or at the end of
#     a battle. This system is highly customizable. You can specify any
#     regeneration formula you want, for any actors in any of the 3
#     occasions!
#------------------------------------------------------------------------------
#  INSTRUCTIONS:
#   1) Paste the script above main
#   2) Edit the constants in the Regeneration module
#==============================================================================

#==============================================================================
#  ** Regeneration Configuration Module
#==============================================================================

module Regeneration
  # Regenerate after battles?
  Battle_Regen = true
  # Defense Regen
  Defense_Regen = true
  # Regenerate on map?
  Map_Regen = true
  # On Map Regeneration delay (in frames)
  Map_Regen_Delay = 240
  # End battle results allowed (0: Victory, 1: Escape, 2: Defeated)
  Battle_End = [0]
  # States that prevents from regenerating after battles
  NoRegen_States = [1]
  # Play recovery SE on map?
  Map_Recovery_SE = true
  # Super Guard Regeneration Multiplier
  Super_Guard_Multiplier = 3
  # Battle Regeneration rate formula for HP/MP
  # SYNTAX: {actor_id => "formula"}
  Battle_HP_Formulas = {}
  Battle_MP_Formulas = {}
  # Default formula if none specified
  Battle_HP_Formulas.default = "(self.maxhp / 100) * 6" # 6% of maxhp
  Battle_MP_Formulas.default = "(self.maxmp / 100) * 3" # 3% of maxmp
  # Defense Regeneration rate formula for HP/MP
  # SYNTAX: {actor_id => "formula"}
  Defense_HP_Formulas = {}
  Defense_MP_Formulas = {}
  # Default formula if none specified
  Defense_HP_Formulas.default = "(self.maxhp / 100) * 2" # 2% of maxhp
  Defense_MP_Formulas.default = "(self.maxmp / 100) * 1" # 1% of maxmp
  # Map Regeneration rate formula for HP/MP
  # SYNTAX: {actor_id => "formula"}
  Map_HP_Formulas = {}
  Map_MP_Formulas = {}
  # Default formula if none specified
  Map_HP_Formulas.default = "(self.maxhp / 100) * 2" # 2% of maxhp
  Map_MP_Formulas.default = "(self.maxmp / 100) * 1" # 1% of maxmp
end

#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
#  This class handles system-related data. Also manages vehicles and BGM, etc.
# The instance of this class is referenced by $game_system.
#==============================================================================

class Game_System
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor  :map_regen
  attr_accessor  :battle_regen
  attr_accessor  :defense_regen
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias dargor_vx_battle_regen_system_initialize initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # The usual
    dargor_vx_battle_regen_system_initialize
    # Map/Battle Regeneration flags
    @battle_regen = Regeneration::Battle_Regen
    @defense_regen = Regeneration::Defense_Regen
    @map_regen = Regeneration::Map_Regen
  end
end

#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles actors. It's used within the Game_Actors class
# ($game_actors) and referenced by the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Get Map HP/MP Regeneration Formulas
  #--------------------------------------------------------------------------
  def map_regen_formulas
    hp_formula = nil
    mp_formula = nil
    # Get actor's map hp regen formula
    if Regeneration::Map_HP_Formulas[@actor_id].nil?
      hp_formula = eval(Regeneration::Map_HP_Formulas.default)
    else
      hp_formula = eval(Regeneration::Map_HP_Formulas[@actor_id])
    end
    # Get actor's map mp regen formula
    if Regeneration::Map_MP_Formulas[@actor_id].nil?
      mp_formula = eval(Regeneration::Map_MP_Formulas.default)
    else
      mp_formula = eval(Regeneration::Map_MP_Formulas[@actor_id])
    end
    hp_formula = 1 if hp_formula == 0
    mp_formula = 1 if mp_formula == 0
    return [hp_formula, mp_formula]
  end
  #--------------------------------------------------------------------------
  # * Regenerate on Map
  #--------------------------------------------------------------------------
  def map_regenerate
    # Check if map regeneration is allowed
    if $game_system.map_regen
      # Make sure the actor is not in a NoRegen state
      for state_id in Regeneration::NoRegen_States
        if state?(state_id)
          # Do not regenerate
          return
        end
      end
      # Regenerate
      self.hp += map_regen_formulas[0]
      self.mp += map_regen_formulas[1]
    end
  end
  #--------------------------------------------------------------------------
  # * Get defense HP/MP Regeneration Formulas
  #--------------------------------------------------------------------------
  def defense_regen_formulas
    hp_formula = nil
    mp_formula = nil
    # Get actor's battle hp regen formula
    if Regeneration::Defense_HP_Formulas[@actor_id].nil?
      hp_formula = eval(Regeneration::Defense_HP_Formulas.default)
    else
      hp_formula = eval(Regeneration::Defense_HP_Formulas[@actor_id])
    end
    # Get actor's battle mp regen formula
    if Regeneration::Defense_HP_Formulas[@actor_id].nil?
      mp_formula = eval(Regeneration::Defense_MP_Formulas.default)
    else
      mp_formula = eval(Regeneration::Defense_MP_Formulas[@actor_id])
    end
    hp_formula = 1 if hp_formula == 0
    mp_formula = 1 if mp_formula == 0
    if super_guard
      hp_formula *= Regeneration::Super_Guard_Multiplier
      mp_formula *= Regeneration::Super_Guard_Multiplier
    end
    return [hp_formula, mp_formula]
  end
  #--------------------------------------------------------------------------
  # * Regenerate After Battles
  #--------------------------------------------------------------------------
  def defense_regenerate
    # Check if battle regeneration la allowed
    if $game_system.defense_regen
     # Make sure the actor is not in a NoRegen state
     for state_id in Regeneration::NoRegen_States
       if state?(state_id)
         # Do not regenerate
         return
       end
      end
     end
    @hp_damage = -defense_regen_formulas[0]
    @mp_damage = -defense_regen_formulas[1]
    self.hp -= @hp_damage
    self.mp -= @mp_damage
  end
  #--------------------------------------------------------------------------
  # * Get Battle HP/MP Regeneration Formulas
  #--------------------------------------------------------------------------
  def battle_regen_formulas
    hp_formula = nil
    mp_formula = nil
    # Get actor's battle hp regen formula
    if Regeneration::Battle_HP_Formulas[@actor_id].nil?
      hp_formula = eval(Regeneration::Battle_HP_Formulas.default)
    else
      hp_formula = eval(Regeneration::Battle_HP_Formulas[@actor_id])
    end
    # Get actor's battle mp regen formula
    if Regeneration::Battle_MP_Formulas[@actor_id].nil?
      mp_formula = eval(Regeneration::Battle_MP_Formulas.default)
    else
      mp_formula = eval(Regeneration::Battle_MP_Formulas[@actor_id])
    end
    hp_formula = 1 if hp_formula == 0
    mp_formula = 1 if mp_formula == 0
    return [hp_formula, mp_formula]
  end
  #--------------------------------------------------------------------------
  # * Regenerate After Battles
  #--------------------------------------------------------------------------
  def battle_regenerate
    # Check if battle regeneration is allowed
    if $game_system.battle_regen
      # Make sure the actor is not in a NoRegen state
      for state_id in Regeneration::NoRegen_States
        if state?(state_id)
          # Do not regenerate
          return
        end
      end
    end
    @hp_damage = -battle_regen_formulas[0]
    @mp_damage = -battle_regen_formulas[1]
    self.hp -= @hp_damage
    self.mp -= @mp_damage
  end
end

#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  This class handles the party. It includes information on amount of gold
# and items. The instance of this class is referenced by $game_party.
#==============================================================================

class Game_Party
  #--------------------------------------------------------------------------
  # * Regenerate Party
  #--------------------------------------------------------------------------
  def regenerate
    if Graphics.frame_count % Regeneration::Map_Regen_Delay == 0
      for member in members
        total_hp = member.hp
        total_maxhp = member.maxhp
        member.map_regenerate
      end
      Sound.play_recovery unless total_hp == total_maxhp or !Regeneration::Map_Recovery_SE
    end
  end
end

#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  This class handles maps. It includes event starting determinants and map
# scrolling functions. The instance of this class is referenced by $game_map.
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias dargor_vx_battle_regen_player_update update
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # If player is free to move
    if movable?
      # Regenerate
      $game_party.regenerate
    end
    # The Usual
    dargor_vx_battle_regen_player_update
  end
end
  
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias dargor_vx_battle_regen_battle_end battle_end
  alias dargor_vx_battle_regen_execute_action_guard execute_action_guard
  #-----------------------------------------------------------------------------
  # Execute Action_Guard
  #-----------------------------------------------------------------------------
  def execute_action_guard
    # The Usual
    dargor_vx_battle_regen_execute_action_guard
    if $game_system.defense_regen
      # Regenerate actor
      @active_battler.defense_regenerate
      # Display regeneration text
      display_hp_damage(@active_battler)
      wait(45)
      @message_window.back_one
      display_mp_damage(@active_battler)
      wait(45)
      @message_window.clear
    end
  end
  #--------------------------------------------------------------------------
  # * End Battle
  #     result : Results (0: win, 1: escape, 2:lose)
  #--------------------------------------------------------------------------
  def battle_end(result)
    # If regenerating is allowed with this battle end result
    if Regeneration::Battle_End.include?(result)
      for member in $game_party.members
        # Regenerate actor
        member.battle_regenerate
        # Display regeneration text
        Sound.play_recovery
        display_hp_regeneration(member)
        display_mp_regeneration(member)
        wait_for_message
        @message_window.clear
      end
    end
    # The usual
    dargor_vx_battle_regen_battle_end(result)
  end
  #--------------------------------------------------------------------------
  # * Show HP Regeneration
  #     target : Target
  #     obj    : Skill or item
  #--------------------------------------------------------------------------
  def display_hp_regeneration(target)
    if target.hp_damage == 0                # No damage
      fmt = target.actor? ? Vocab::ActorNoDamage : Vocab::EnemyNoDamage
      text = sprintf(fmt, target.name)
    elsif target.absorbed                   # Absorb
      fmt = target.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
      text = sprintf(fmt, target.name, Vocab::hp, target.hp_damage)
    elsif target.hp_damage > 0              # Damage
      if target.actor?
        text = sprintf(Vocab::ActorDamage, target.name, target.hp_damage)
        Sound.play_actor_damage
        $game_troop.screen.start_shake(5, 5, 10)
      else
        text = sprintf(Vocab::EnemyDamage, target.name, target.hp_damage)
        Sound.play_enemy_damage
        target.blink = true
      end
    else                                    # Recovery
      fmt = target.actor? ? Vocab::ActorRecovery : Vocab::EnemyRecovery
      text = sprintf(fmt, target.name, Vocab::hp, -target.hp_damage)
    end
    $game_message.texts.push(text)
  end
  #--------------------------------------------------------------------------
  # * Show MP Regeneration
  #     target : Target
  #     obj    : Skill or item
  #--------------------------------------------------------------------------
  def display_mp_regeneration(target)
    return if target.dead?
    return if target.mp_damage == 0
    if target.absorbed                      # Absorb
      fmt = target.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
      text = sprintf(fmt, target.name, Vocab::mp, target.mp_damage)
    elsif target.mp_damage > 0              # Damage
      fmt = target.actor? ? Vocab::ActorLoss : Vocab::EnemyLoss
      text = sprintf(fmt, target.name, Vocab::mp, target.mp_damage)
    else                                    # Recovery
      fmt = target.actor? ? Vocab::ActorRecovery : Vocab::EnemyRecovery
      text = sprintf(fmt, target.name, Vocab::mp, -target.mp_damage)
    end
    $game_message.texts.push(text)
  end
end


This post has been edited by Junkexx: Dec 23 2008, 04:39 PM
Reason for edit: Added code tags, which should of been put in regarless.


__________________________
<--- Click.

Want a signature like the one above? PM me and I'll see what I can do.
Go to the top of the page
 
+Quote Post
   
Midnight Assassi...
post Dec 23 2008, 04:17 PM
Post #2



Group Icon

Group: Banned
Posts: 0
Type: None
RM Skill: Undisclosed




Needs more detail.

If you go and read the guidelines, you'll see that this isn't a "good" submission.

Add some details, an intro, and use proper grammar. Typing in caps makes you seem like you're angry.

It's not a neccessity, but to get more people attracted, add a better title that "REGEN" (more caps?). When I read the title, millions of ideas jumped into my head: "Regenerate what?", "How to use the script?", "Why is he typing in caps?"

Also, put the script in code tags. Maybe add a demo, and some screenies?

If the mods pull you up, don't get surprised.

Come on, it's common sense!

This post has been edited by Midnight Assassin: Dec 23 2008, 04:22 PM


__________________________
Banned for attempting to hack the site - The Admin Team
Go to the top of the page
 
+Quote Post
   
Kuma-san
post Dec 23 2008, 04:34 PM
Post #3


「VOIDVOIDVOID」
Group Icon

Group: Revolutionary
Posts: 291
Type: Writer
RM Skill: Skilled




QUOTE
If the mods pull you up, don't get surprised.

Physic much? tongue.gif
Yes, this needs way more detail!
If your going to post a script, please read this: http://www.rpgrevolution.com/forums/index....showtopic=15772.
A demo isn't needed, but some people are new to RMVX and need it to use it as an example.
Also I'm going to change the title to "Regeneration Script". Feel free to change it to something more descriptive later.
Oh yes, I put it in code tags.



__________________________
[Show/Hide] Signature.
[Show/Hide] Best real-life quote. Ever
Teacher- Do you think your cute? Do you think your funny?
Student- I think I'm SEXY.

[Show/Hide] Userbars






[Show/Hide] My Tarot Card.

"Prudence, Caution, Deliberation.

The Hermit points to all things hidden, such as knowledge and inspiration,hidden enemies. The illumination is from within, and retirement from participation in current events.

The Hermit is a card of introspection, analysis and, well, virginity. You do not desire to socialize; the card indicates, instead, a desire for peace and solitude. You prefer to take the time to think, organize, ruminate, take stock. There may be feelings of frustration and discontent but these feelings eventually lead to enlightenment, illumination, clarity.

The Hermit represents a wise, inspirational person, friend, teacher, therapist. This a person who can shine a light on things that were previously mysterious and confusing.
"
Go to the top of the page
 
+Quote Post
   
Midnight Assassi...
post Dec 23 2008, 04:45 PM
Post #4



Group Icon

Group: Banned
Posts: 0
Type: None
RM Skill: Undisclosed




QUOTE
Physic much?

Which means... What?


__________________________
Banned for attempting to hack the site - The Admin Team
Go to the top of the page
 
+Quote Post
   
Twilight
post Dec 23 2008, 07:26 PM
Post #5


Real name, Lily White
Group Icon

Group: Revolutionary
Posts: 227
Type: Developer
RM Skill: Advanced




It's pretty funny how I actually know the guy that wrote this script.
Not sure how you all handle things here but changing the author in the script and passing it off as your own is what made many scripters leave the scene.

Btw link to the real author
http://www.rmxp.org/forums/index.php?topic=58036.0

This post has been edited by Twilight: Dec 23 2008, 07:27 PM
Go to the top of the page
 
+Quote Post
   
jens009
post Dec 23 2008, 08:46 PM
Post #6


L Did you know? Death gods... only eat apples
Group Icon

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled




Thanks for the report twilight.

Zelda Freak, you have committed plagiarism (Claiming other people's work). Although it is not explicitly stated in the board guidelines, it is implied that you act civil in the forums as you do normally.

You will be deprived of posting privileges for 3 days. As of being banned, I will bring this concern towards the staff.

If ever you guys are concerned as to who the real author of the script is, it is dargor
as indicated by this line:
CODE
alias dargor_vx_battle_regen_system_initialize initialize

Thank god for aliasing habits.

This topic will now be closed.


__________________________

My RMXP Project:


Farewell RRR. =]
Go to the top of the page
 
+Quote Post
   

Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 21st May 2013 - 11:57 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker