Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

On Map Regeneration

On Map Regeneration
Version: 1.07

Introduction

This script lets ur actors recover HP/SP while moving on Game_Map

Features

  • Recover HP/SP or percentage of MAXHP/MAXSP
  • Individual Regeneration Rate for Actors
  • Choose Maps enabling/disabling the Regeneration
  • Choose states to stop the HP/SP Regeneration
  • [highlight]NEW[/highlight]: The higher the MAXHP/MAXSP the faster the Regeneration
  • [highlight]NEW[/highlight]: Regeneration Speed can be edited in Game Progress (e.g. as reward)

Demo

there will be a test bed with all my scripts, but don't ask when i will do this ;)

Script

Code:
#==============================================================================
# On Map Regeneration Script v. 1.07
# by Caldaron (11.09.2006)
#==============================================================================
#                               DESCRIPTIONS                                   
#==============================================================================
  #--------------------------------------------------------------------------
  #  USE_MAPS:      when true: Regeneration is enabled, except for REG_MAPS
  #                 when false: Regeneration is only for REG_MAPS enabled
  #  REG_MAPS:      insert the Map_IDs where Regeneration is enabled/disabled
  #  HP/SP_WAIT:    time to Wait until HP/SP recovers, will be divided by MAXHP/SP
  #                 should be Limit of MAXHP/MAXSP
  #  HP/SP_REG:     the Value of HP/SP Regeneration
  #  HP/SP_PERCENT: when true: the Value of HP/SP_REG changes to its meant Percentage
  #  HP/SP_MOD:     the Percentage of HP/SP Recovery (1. Value contains 1. Actor's Percentage)
  #                 0 means no Regeneration
  #                 !!NUMBER OF VALUES MUST BE EQUAL THE NUMBER OF ACTORS!!
  #  HP/SP_STOP:    insert the State IDs which prevent the Actor to recover HP/SP
  #                 insert all State IDs which marked 'Regard as HP 0'
  #                 to prevent the Actor to Raise from Dead
  #
  #                 to change the actor's regenerate speed, use:
  #                 $game_system.hp_mod[actor.id-1] = value
  #--------------------------------------------------------------------------
#==============================================================================
module Regenerate
  USE_MAPS      = true
  REG_MAPS      = []
  HP_WAIT       = 9999
  SP_WAIT       = 9999
  HP_REG        = 1
  SP_REG        = 1
  HP_PERCENT    = false
  SP_PERCENT    = false
  HP_STOP       = [1]
  SP_STOP       = [1]
end
#==============================================================================
class Game_System
  #--------------------------------------------------------------------------
  attr_accessor :hp_mod
  attr_accessor :sp_mod
  #--------------------------------------------------------------------------
  alias system_reg_init initialize
  def initialize
    @hp_mod     = [100, 100, 100, 100, 100, 100, 100, 100]
    @sp_mod     = [100, 100, 100, 100, 100, 100, 100, 100]
    system_reg_init
  end
  #--------------------------------------------------------------------------
end
#==============================================================================
class Game_Map
  #--------------------------------------------------------------------------
  alias map_reg_init initialize
  def initialize
    @hp_wait    = [0,0,0,0,0,0,0,0]  # !!NUMBER OF VALUES MUST BE EQUAL THE NUMBER OF ACTORS!!
    @sp_wait    = [0,0,0,0,0,0,0,0]  # !!NUMBER OF VALUES MUST BE EQUAL THE NUMBER OF ACTORS!!
    map_reg_init
  end
  #--------------------------------------------------------------------------
  alias map_reg_update update
  def update
    for actor in $game_party.actors
      i = actor.id
      i -= 1
      @actor = actor
      @hp_wait[i] -= 1
      @sp_wait[i] -= 1
      if Regenerate::USE_MAPS and not Regenerate::REG_MAPS.include?(@map_id) or
        (Regenerate::USE_MAPS == false and Regenerate::REG_MAPS.include?(@map_id))
        if @hp_wait[i] < 1
          @actor.hp_reg
          if Regenerate::HP_PERCENT
            @hp_wait[i] = Regenerate::HP_WAIT/(@actor.maxhp * (@actor.maxhp/(Regenerate::HP_REG*100)) * ($game_system.hp_mod[i]/100.00))
          else
            @hp_wait[i] = Regenerate::HP_WAIT/(@actor.maxhp * Regenerate::HP_REG * ($game_system.hp_mod[i]/100.00))
          end
        end
        if @sp_wait[i] < 1
          @actor.sp_reg
          if @actor.maxsp != 0
            if Regenerate::HP_PERCENT
              @sp_wait[i] = Regenerate::SP_WAIT/(@actor.maxsp * (@actor.maxsp/(Regenerate::SP_REG*100)) * ($game_system.sp_mod[i]/100.00))
            else
              @sp_wait[i] = Regenerate::SP_WAIT/(@actor.maxsp * Regenerate::SP_REG * ($game_system.sp_mod[i]/100.00))
            end
          end
        end
      end
    end
    map_reg_update
  end
  #--------------------------------------------------------------------------
end
#==============================================================================
class Game_Actor
  #--------------------------------------------------------------------------
  def stop_reg(type)
    case type
    when 0
      for i in Regenerate::HP_STOP
        if self.state?(i)
          return true
        end
      end
    when 1
      for i in Regenerate::SP_STOP
        if self.state?(i)
          return true
        end
      end
    end
    return false
  end 
  #--------------------------------------------------------------------------
  def hp_reg
    i = -1 + id
    @mod = $game_system.hp_mod[i]
    if not self.stop_reg(0) and not (@mod == 0 or @mod == nil)
      self.hp += 1
    end
    self.hp = Integer([self.hp, self.maxhp].min)
  end
  #--------------------------------------------------------------------------
  def sp_reg
    i = -1 + id
    @mod = $game_system.sp_mod[i]
    if not self.stop_reg(1) and not (@mod == 0 or @mod == nil)
      self.sp += 1
    end
    self.sp = Integer([self.sp, self.maxsp].min)
  end
  #--------------------------------------------------------------------------
end
Instructions

Put the Script above main

The descriptions should be sufficient

Incompatibility

not known...

Credits and Thanks

Credits to me
Still a thanks to Trickster ;)
 
You should also let the people choose if it runs on certain maps or all maps.

I would do this;

MAPS = [0]

if MAPS.include?(0) #Works for all

Maps = [1,3,5,6]

if MAPS.include?($game_map.map_id)

other then that good job.
 
ahh, ok i know what u mean...
just for a town or a place, that is save in a dungeon, ok, going to implement this, thx
but right now, i'm going to see Fear My Thoughts! so i'll do this tomorrow
 
This is a nice script. I always wondered why no game had natural recover while walking around since real people have natural recover rates. You should include an option that sets the recovery rate for individual actors (such as Werewolves health regenerate faster than humans, etc.)
 
Great Job, not much I can say here

1) I would suggest you move method stop_reg from Game_Map to Game_Actor, I don't feel It really fits in Game_Map, you could then call the method by <Game_Actor>.stop_reg(second_argument) you can remove the first argument from the method since you already know the Game_Actor object

2) This and the other code block
Code:
      for i in 0...$game_party.actors.size
        @actor = $game_party.actors[i]
        if not stop_reg(@actor, 0)
          if Regenerate::HP_PERCENT
            @actor.hp += (@actor.maxhp * Regenerate::HP_REG)/100.00
          else
            @actor.hp += Regenerate::HP_REG
          end
        end
        @actor.hp = Integer([@actor.hp, @actor.maxhp].min)
        @hp_wait = Regenerate::HP_WAIT
      end

Could be moved to Game_Party (with more innermost parts being moved to Game_Actor) for the same reason as 1)
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top