MP Regen System

FenixFyreX

Fire Deity
Veteran
Joined
Mar 1, 2012
Messages
434
Reaction score
310
First Language
English
Primarily Uses
Mp Regeneration System

v 1.4

FenixFyreX


Introduction

This script sets everyone's MP to 0 (one actually, cause of the first turn) at the beginning of the battle and gives each actor and enemy a defined amount of MP each turn.

Features

  • -=- Make MP start at 0 and work it's way up, making battles much more strategic.
    -=- Turn the whole system off entirely, just for actors, or just for enemies via script calls.
    -=- Manipulate the amount of MP Regen via a script call.

Version Changes

  • -=- v1.0 -- Added in switches and such, allowing for more customization.
    -=- v1.1 -- Fixed a bug
    -=- v1.2 -- Added support for and intelligence boost
    -=- v1.3 -- Fixed a bug and changed one method
    -=- v1.4 -- Changed the system to regen mp per actor, not to whole party / troop

How To

To turn the whole system off, call this in an event:



Code:
mpreg_sys(true / false)
To disable the whole system for actors, call this in an event:



Code:
mpreg_act(true / false)
To disable the whole system for enemies, call this in an event:



Code:
mpreg_eny(true / false)
To change the amount of mp regeneration per turn, call this in an event:



Code:
mpreg_amt(type, number)
Where type is 0 (actors) or 1 (enemies) and number is the amount you wish to change to.

Script

Code:
=begin
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-=					   MP Regenerator System v1.4						   -=
-=							  FenixFyreX									-=
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


There are a couple commands to be aware of.

To turn the whole system off, use this script call:

   mpreg_sys(true / false)


To turn the system off only for actors, use this:

   mpreg_act(true / false)


To turn the system off only for enemies, use this:

   mpreg_eny(true / false)


To change how much mp each turn regenerates, use this:

   mpreg_amt(type, number)

  Where type is 0(actors) or 1(enemies) and number is the amount to regen each
  turn.

  Other setup is below.

=end

module Mp_Reg_Setup

  # If the below is 0, mp will be returned to 0 after battle. if 1, mp will
  # be fully restored. any other number will result in mp staying the same.

  Mp_Return_Action = 0

  #--------------------------
  # What each actor's mp will be set as at the beginning of battle.

  Mp_Start_Value   = 0

  #--------------------------
  # How much mp each actor and enemy gains per turn.

  Regen_Amount_A   = 1  # Actors
  Regen_Amount_E   = 1  # Enemies

  #--------------------------
  # Which options to start with

  Start_System	 = true
  Start_Actors	 = true
  Start_Enemys	 = true

  #--------------------------
  # do you want the system to NOT effect those who are dead?
  Stop_When_Dead   = true

  #--------------------------
  # If true, intelligence will affect the mp gained.

  Use_Int_Effect   = true

  #---------------------------
  # You can use your own formula for the above switch via the global variable:
  # To specify the active battler be it actor or enemy, use i. So, i is the
  # active battler.

  $mp_reg_form = "((i.spi / 100) * 4)"

end

class Scene_Battle < Scene_Base

  alias mpregen_prog start unless $@
  def start
	mpregen_prog
	start_mp_regen
  end

  def start_mp_regen
	if $game_system.mp_regen_switch[0]
	  if $game_system.mp_regen_switch[1]
		$game_party.members.each {|i| i.mp = Mp_Reg_Setup::Mp_Start_Value}
	  end
	  if $game_system.mp_regen_switch[2]
		$game_troop.members.each {|i| i.mp = Mp_Reg_Setup::Mp_Start_Value}
	  end
	  $game_party.members.each {|i| do_add_mp_regen(i)}
	end
  end

  alias mpreg_s_main process_action unless $@
  def process_action
	if !Mp_Reg_Setup::Stop_When_Dead
	  do_add_mp_regen(@active_battler) if $game_system.mp_regen_switch[0]
	else
	  if !@active_battler.nil?
		if !@active_battler.state?(1)
		  do_add_mp_regen(@active_battler) if $game_system.mp_regen_switch[0]
		end
	  end
	end
	mpreg_s_main
  end

  def do_add_mp_regen(i)
	if $game_system.mp_regen_switch[1] and @active_battler.is_a?(Game_Actor)
	  if Mp_Reg_Setup::Use_Int_Effect
		number = ((i.spi / 100) * 4).to_i if $mp_reg_form == nil
		number = eval($mp_reg_form) if $mp_reg_form != nil
		i.mp += $game_system.mp_regen_amt[0] + number
		if i.mp > i.maxmp
		  i.mp = i.maxmp
		end
	  else
		i.mp += $game_system.mp_regen_amt[0]
		if i.mp > i.maxmp
		  i.mp = i.maxmp
		end
	  end
	end
	if $game_system.mp_regen_switch[2] and @active_battler.is_a?(Game_Enemy)
	  if Mp_Reg_Setup::Use_Int_Effect
		number = ((i.spi / 100) * 4).to_i if $mp_reg_form == nil
		number = eval($mp_reg_form) if $mp_reg_form != nil
		i.mp += $game_system.mp_regen_amt[0] + number
		if i.mp > i.maxmp
		  i.mp = i.maxmp
		end
	  else
		i.mp += $game_system.mp_regen_amt[1]
		if i.mp > i.maxmp
		  i.mp = i.maxmp
		end
	  end
	end
  end

  def do_regen_end
	regener = Mp_Reg_Setup::Mp_Return_Action
	if regener == 0
	  $game_party.members.each {|i| i.mp = 0}
	elsif regener == 1
	  $game_party.members.each {|i| i.mp = i.maxmp}
	end
  end

  alias mp_regen_batend battle_end unless $@
  def battle_end(*args)
	switch = $game_system.mp_regen_switch
	do_regen_end if switch[0] and switch[1]
	mp_regen_batend(*args)
  end
end

class Game_System

  include Mp_Reg_Setup

  attr_accessor :mp_regen_switch
  attr_accessor :mp_regen_amt

  alias mp_regen_init initialize unless $@
  def initialize
	mp_regen_init
	@mp_regen_switch = [Start_System, Start_Actors, Start_Enemys]
	@mp_regen_amt	= [Regen_Amount_A,Regen_Amount_E]
  end
end

class Game_Interpreter

  def mpreg_amt(item, number)
	$game_system.mp_regen_amt[item] = number
  end

  def mpreg_sys(sys)
	$game_system.mp_regen_switch[0] = sys
  end

  def mpreg_act(actr)
	$game_system.mp_regen_switch[1] = actr
  end

  def mpreg_eny(eny)
	$game_system.mp_regen_switch[2] = eny
  end
end
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
# END
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
Notes / Credit

Give credit to me for creating this and Rezna for requesting it, please ;)

Also, this should work with any battle system out there. If not, just yell and I'll patch it.

EDIT: It should work with any battle system now o.0 But as most battle systems are different, I can't guarantee that XD
 

RenderIce2000

Villager
Member
Joined
Mar 30, 2017
Messages
7
Reaction score
7
First Language
English
Primarily Uses
RMMV
When I get into battle it says "undefined method `[]' for nil:NilClass" Think you know whats wrong? Is it not RMVX compatible? :rsad:
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,863
Messages
1,017,053
Members
137,571
Latest member
grr
Top