# Life Barrier System By SephirothSpawn
module LifeBarrier
Initial_Actor_StartValue = Hash.new(0)
Initial_Actor_MaxValue = Hash.new(0)
Initial_Enemy_StartValue = Hash.new(0)
Initial_Enemy_MaxValue = Hash.new(0)
class LifeBarrier
attr_accessor :value
attr_accessor :max
def init_actor(id)
@value = Initial_Actor_StartValue[id]
@max = Initial_Actor_MaxValue[id]
end
def init_enemy(id)
@value = Initial_Enemy_StartValue[id]
@max = Initial_Enemy_MaxValue[id]
end
end
end
class Game_Battler
attr_reader :lifebarrier
alias_method :seph_lifebarrier_init, :initialize
def initialize
@lifebarrier = LifeBarrier::LifeBarrier.new
seph_lifebarrier_init
end
alias_method :seph_lifebarrier_hp=, :hp=
def hp=(n)
if @lifebarrier.value > 0
if n > @lifebarrier.value
n -= @lifebarrier.value
@lifebarrier.value = 0
else
@lifebarrier.value -= n
n = 0
end
end
self.seph_lifebarrier_hp=(n)
end
alias_method :seph_lifebarrier_ra, :recover_all
def recover_all
seph_lifebarrier_ra
@lifebarrier.value = @lifebarrier.max
end
end
class Game_Actor
alias_method :seph_lifebarrier_setup, :setup
def setup(actor_id)
@lifebarrier.init_actor(actor_id)
seph_lifebarrier_setup(actor_id)
end
end
class Game_Enemy
alias_method :seph_lifebarrier_enmy_init, :initialize
def initialize(*args)
seph_lifebarrier_enmy_init
@lifebarrier.init_enemy(@enemy_id)
end
end
I haven't tested this (just did it in fast reply), but it should work.
Setup:
* Setting up actors start life barrier
- Below this line
Initial_Actor_StartValue = Hash.new(0)
Add
Initial_Actor_StartValue[actor_id] = n
* Setting up actors max life barrier
- Below this line
Initial_Actor_MaxValue = Hash.new(0)
Add
Initial_Actor_MaxValue[actor_id] = n
* Same for enemies for setup
Syntax
* Changing current life barrier value
$game_actors[actor_id].lifebarrier.value <operator> n
* Changing max life barrier value
$game_actors[actor_id].lifebarrier.max <operator> n
As is in the script, life barrier recovers to max value when the recover_all method is called.
Let me know if it doesn't work.