module Limits
#--------------------------------------------------------------------------
# * Max Hp Limit (nil for no limit)
#--------------------------------------------------------------------------
Max_Hp_Limit_Actors = 999
Max_Hp_Limit_Enemies = 99999
#--------------------------------------------------------------------------
# * Max Sp Limit (nil for no limit)
#--------------------------------------------------------------------------
Max_Sp_Limit_Actors = 99
Max_Sp_Limit_Enemies = 9999
#--------------------------------------------------------------------------
# * Exp Limit
#--------------------------------------------------------------------------
Exp_Limit = 9999999
#--------------------------------------------------------------------------
# * Strength Limit
#--------------------------------------------------------------------------
Strength_Limit = 100
#--------------------------------------------------------------------------
# * Dexerity Limit
#--------------------------------------------------------------------------
Dexerity_Limit = 100
#--------------------------------------------------------------------------
# * Agility Limit
#--------------------------------------------------------------------------
Agility_Limit = 100
#--------------------------------------------------------------------------
# * Intelligence Limit
#--------------------------------------------------------------------------
Intelligence_Limit = 100
#--------------------------------------------------------------------------
# * Hp Plus Limit
#--------------------------------------------------------------------------
Hp_Plus_Limit = nil
#--------------------------------------------------------------------------
# * Sp Plus Limit
#--------------------------------------------------------------------------
Sp_Plus_Limit = nil
#--------------------------------------------------------------------------
# * Strength Plus Limit
#--------------------------------------------------------------------------
Str_Plus_Limit = nil
#--------------------------------------------------------------------------
# * Dex Plus Limit
#--------------------------------------------------------------------------
Dex_Plus_Limit = nil
#--------------------------------------------------------------------------
# * Agi Plus Limit
#--------------------------------------------------------------------------
Agi_Plus_Limit = nil
#--------------------------------------------------------------------------
# * Int Plus Limit
#--------------------------------------------------------------------------
Int_Plus_Limit = nil
#--------------------------------------------------------------------------
# * Damage Limit
#--------------------------------------------------------------------------
Damage_Limit = nil
end
class Game_Enemy
#--------------------------------------------------------------------------
# * Get Maximum HP
#--------------------------------------------------------------------------
def maxhp
if Max_Hp_Limit_Enemies != nil
n = [[base_maxhp + @maxhp_plus, 1].max, Max_Hp_Limit_Enemies].min
else
n = [base_maxhp + @maxhp_plus, 1].max
end
for i in @states
n *= $data_states[i].maxhp_rate / 100.0
end
if Max_Hp_Limit_Enemies != nil
n = [[n, 1].max, Max_Hp_Limit_Enemies].min
else
n = [n, 1].max
end
return Integer(n)
end
#--------------------------------------------------------------------------
# * Get Maximum SP
#--------------------------------------------------------------------------
def maxsp
if Max_Sp_Limit_Enemies != nil
n = [[base_maxsp + @maxsp_plus, 0].max, Max_Sp_Limit_Enemies].min
else
n = [base_maxsp + @maxsp_plus, 0].max
end
for i in @states
n *= $data_states[i].maxsp_rate / 100.0
end
if Max_Sp_Limit_Enemies != nil
n = [[n, 0].max, Max_Sp_Limit_Enemies].min
else
n = [n, 0].max
end
return Integer(n)
end
end
class Game_Actor
#--------------------------------------------------------------------------
# * Get Maximum HP
#--------------------------------------------------------------------------
def maxhp
if Max_Hp_Limit_Actors != nil
n = [[base_maxhp + @maxhp_plus, 1].max, Max_Hp_Limit_Actors].min
else
n = [base_maxhp + @maxhp_plus, 1].max
end
for i in @states
n *= $data_states[i].maxhp_rate / 100.0
end
if Max_Hp_Limit_Actors != nil
n = [[n, 1].max, Max_Hp_Limit_Actors].min
else
n = [n, 1].max
end
return Integer(n)
end
#--------------------------------------------------------------------------
# * Get Maximum SP
#--------------------------------------------------------------------------
def maxsp
if Max_Sp_Limit_Actors != nil
n = [[base_maxsp + @maxsp_plus, 0].max, Max_Sp_Limit_Actors].min
else
n = [base_maxsp + @maxsp_plus, 0].max
end
for i in @states
n *= $data_states[i].maxsp_rate / 100.0
end
if Max_Sp_Limit_Actors != nil
n = [[n, 0].max, Max_Sp_Limit_Actors].min
else
n = [n, 0].max
end
return Integer(n)
end
#--------------------------------------------------------------------------
# * Get Basic Strength
#--------------------------------------------------------------------------
def base_str
n = $data_actors[@actor_id].parameters[2, @level]
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
n += weapon != nil ? weapon.str_plus : 0
n += armor1 != nil ? armor1.str_plus : 0
n += armor2 != nil ? armor2.str_plus : 0
n += armor3 != nil ? armor3.str_plus : 0
n += armor4 != nil ? armor4.str_plus : 0
n = Strength_Limit != nil ? [[n, 1].max, Strength_Limit].min : [n, 1].max
return n
end
#--------------------------------------------------------------------------
# * Get Basic Dexterity
#--------------------------------------------------------------------------
def base_dex
n = $data_actors[@actor_id].parameters[3, @level]
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
n += weapon != nil ? weapon.dex_plus : 0
n += armor1 != nil ? armor1.dex_plus : 0
n += armor2 != nil ? armor2.dex_plus : 0
n += armor3 != nil ? armor3.dex_plus : 0
n += armor4 != nil ? armor4.dex_plus : 0
n = Dexerity_Limit != nil ? [[n, 1].max, Dexerity_Limit].min : [n, 1].max
return n
end
#--------------------------------------------------------------------------
# * Get Basic Agility
#--------------------------------------------------------------------------
def base_agi
n = $data_actors[@actor_id].parameters[4, @level]
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
n += weapon != nil ? weapon.agi_plus : 0
n += armor1 != nil ? armor1.agi_plus : 0
n += armor2 != nil ? armor2.agi_plus : 0
n += armor3 != nil ? armor3.agi_plus : 0
n += armor4 != nil ? armor4.agi_plus : 0
n = Agility_Limit != nil ? [[n, 1].max, Agility_Limit].min : [n, 1].max
return n
end
#--------------------------------------------------------------------------
# * Get Basic Intelligence
#--------------------------------------------------------------------------
def base_int
n = $data_actors[@actor_id].parameters[5, @level]
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
n += weapon != nil ? weapon.int_plus : 0
n += armor1 != nil ? armor1.int_plus : 0
n += armor2 != nil ? armor2.int_plus : 0
n += armor3 != nil ? armor3.int_plus : 0
n += armor4 != nil ? armor4.int_plus : 0
n = Intelligence_Limit != nil ? [[n, 1].max, Intelligence_Limit].min : [n, 1].max
return n
end
#--------------------------------------------------------------------------
# * Change EXP
# exp : new EXP
#--------------------------------------------------------------------------
def exp=(exp)
if Exp_Limit != nil
@exp = [[exp, Exp_Limit].min, 0].max
else
@exp = [exp, 0].max
end
# Level up
while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
@level += 1
# Learn skill
for j in $data_classes[@class_id].learnings
if j.level == @level
learn_skill(j.skill_id)
end
end
end
# Level down
while @exp < @exp_list[@level]
@level -= 1
end
# Correction if exceeding current max HP and max SP
@hp = [@hp, self.maxhp].min
@sp = [@sp, self.maxsp].min
end
end
class Game_Battler
#--------------------------------------------------------------------------
# * Include Limits - Laziness and to Avoid Typing As Much
#--------------------------------------------------------------------------
include Limits
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :damage_limit_enabled
#--------------------------------------------------------------------------
# * Initialize
#--------------------------------------------------------------------------
alias damage_limit_initialize initialize
def initialize
damage_limit_initialize
@damage_limit_enabled = true
end
#--------------------------------------------------------------------------
# * Get Strength (STR)
#--------------------------------------------------------------------------
def str
if Strength_Limit != nil
n = [[base_str + @str_plus, 1].max, Strength_Limit].min
else
n = [base_str + @str_plus, 1].max
end
for i in @states
n *= $data_states[i].str_rate / 100.0
end
if Strength_Limit != nil
n = [[n, 1].max, Strength_Limit].min
else
n = [n, 1].max
end
return Integer(n)
end
#--------------------------------------------------------------------------
# * Get Dexterity (DEX)
#--------------------------------------------------------------------------
def dex
if Dexerity_Limit != nil
n = [[base_dex + @dex_plus, 1].max, Dexerity_Limit].min
else
n = [base_dex + @dex_plus, 1].max
end
for i in @states
n *= $data_states[i].dex_rate / 100.0
end
if Dexerity_Limit != nil
n = [[n, 1].max, Dexerity_Limit].min
else
n = [n, 1].max
end
return Integer(n)
end
#--------------------------------------------------------------------------
# * Get Agility (AGI)
#--------------------------------------------------------------------------
def agi
if Agility_Limit != nil
n = [[base_agi + @agi_plus, 1].max, Agility_Limit].min
else
n = [base_agi + @agi_plus, 1].max
end
for i in @states
n *= $data_states[i].agi_rate / 100.0
end
if Agility_Limit != nil
n = [[n, 1].max, Agility_Limit].min
else
n = [n,1].max
end
return Integer(n)
end
#--------------------------------------------------------------------------
# * Get Intelligence (INT)
#--------------------------------------------------------------------------
def int
if Intelligence_Limit != nil
n = [[base_int + @int_plus, 1].max, Intelligence_Limit].min
else
n = [base_int + @int_plus, 1].max
end
for i in @states
n *= $data_states[i].int_rate / 100.0
end
if Intelligence_Limit != nil
n = [[n, 1].max, Intelligence_Limit].min
else
n = [n, 1].max
end
return Integer(n)
end
#--------------------------------------------------------------------------
# * Set Maximum HP
# maxhp : new maximum HP
#--------------------------------------------------------------------------
def maxhp=(maxhp)
@maxhp_plus += maxhp - self.maxhp
if Hp_Plus_Limit != nil
@maxhp_plus = [[@maxhp_plus, -Hp_Plus_Limit].max, Hp_Plus_Limit].min
end
@hp = [@hp, self.maxhp].min
end
#--------------------------------------------------------------------------
# * Set Maximum SP
# maxsp : new maximum SP
#--------------------------------------------------------------------------
def maxsp=(maxsp)
@maxsp_plus += maxsp - self.maxsp
if Sp_Plus_Limit != nil
@maxsp_plus = [[@maxsp_plus, -Sp_Plus_Limit].max, Sp_Plus_Limit].min
end
@sp = [@sp, self.maxsp].min
end
#--------------------------------------------------------------------------
# * Set Strength (STR)
# str : new Strength (STR)
#--------------------------------------------------------------------------
def str=(str)
@str_plus += str - self.str
if Str_Plus_Limit != nil
@str_plus = [[@str_plus, -Str_Plus_Limit].max, Str_Plus_Limit].min
end
end
#--------------------------------------------------------------------------
# * Set Dexterity (DEX)
# dex : new Dexterity (DEX)
#--------------------------------------------------------------------------
def dex=(dex)
@dex_plus += dex - self.dex
if Dex_Plus_Limit != nil
@dex_plus = [[@dex_plus, -Dex_Plus_Limit].max, Dex_Plus_Limit].min
end
end
#--------------------------------------------------------------------------
# * Set Agility (AGI)
# agi : new Agility (AGI)
#--------------------------------------------------------------------------
def agi=(agi)
@agi_plus += agi - self.agi
if Agi_Plus_Limit != nil
@agi_plus = [[@agi_plus, -Agi_Plus_Limit].max, Agi_Plus_Limit].min
end
end
#--------------------------------------------------------------------------
# * Set Intelligence (INT)
# int : new Intelligence (INT)
#--------------------------------------------------------------------------
def int=(int)
@int_plus += int - self.int
if Int_Plus_Limit != nil
@int_plus = [[@int_plus, -Int_Plus_Limit].max, Int_Plus_Limit].min
end
end
#--------------------------------------------------------------------------
# * Set Hp (Damage Limit)
#--------------------------------------------------------------------------
alias damage_limit_hp= hp=
def hp=(hp)
# Get old hp and
old_hp, new_hp = self.hp, hp
# If Damage is A Number and Difference is damage
if self.damage.is_a?(Numeric) and old_hp - new_hp == self.damage and self.damage > 9999 and @damage_limit_enabled
# Get Damage
n = self.damage
# Set New Damage
damage_hp = Damage_Limit.nil? ? n : Damage_Limit
# Set Hp
self.damage_limit_hp = old_hp - damage_hp
# Set Damage
self.damage = damage_hp
else
# The usaul
self.damage_limit_hp = hp
end
# Reset Damage Enabled Flag
@damage_limit_enabled = false
end
#--------------------------------------------------------------------------
# * Attack Effect
#--------------------------------------------------------------------------
alias damage_limit_attack_effect attack_effect
def attack_effect(attacker)
self.damage_limit_enabled = true
damage_limit_attack_effect(attacker)
return true
end
#--------------------------------------------------------------------------
# * Skill Effect
#--------------------------------------------------------------------------
alias damage_limit_skill_effect skill_effect
def skill_effect(user, skill)
self.damage_limit_enabled = true
effective = damage_limit_skill_effect(user, skill)
return effective
end
#--------------------------------------------------------------------------
# * Item Effect
#--------------------------------------------------------------------------
alias damage_limit_item_effect item_effect
def item_effect(item)
self.damage_limit_enabled = true
effective = damage_limit_item_effect(item)
return effective
end
end