#==============================================================================
# ** Stat points distribution system 1.2
# By Lettuce.
#------------------------------------------------------------------------------
# This script lets you distribute points onto your actor's stats
# You can give points to your actors by using this code
#
# $points[actor_id] += amount_of_points
#
# If you want your actor to get points after leveling:
# Under Game_Actor, in def change_exp, under the line level_up; paste this
#
# difference = @level - last_level
# $points[actor.id-1] += <amount_of_points>*difference
#
# OR (if you want RO mode; explained below)
#
# difference = @level - last_level
# $points[actor.id-1] += ((@level/5).floor+2).floor*difference
#
# # It seems the game returns non 0 based array if we use game_party >.<;
#
# **Note**
# This script does not stop your actors from gaining stats points defined in
# the database. It will just add to it.
# Set the stats to 1 all the way in the database to disable growth :0
#
# **Modes**
# 1 : Add one point to the attribute per point
# 2 : Use RO system, attribute with value needs more points to increase.
# Explanation: In RO, if you got high stats, you need more points to
# increase it. So if you have 90 ATK and 5 INT...You can
# choose to use 10 points for 1 more ATK OR use that 10 points
# to get 6 INT
#============================ Configuration ====================================
#this var is for storing points.If you got 10 chars in database,
#you need 10 zero's here.
$points = [0,0,0,0,0,0,0,0]
#Maximum attribute point you allow in your game
MaxStat = 99
#1 for normal mode, 2 or RO mode
Mode = 2
#You can chage font family and size here
Fontname = "Calibri"
Fontsize = 20
#How many stats will increase per point?
IncreaseBy = 1;
OFFSET = -10
#========================== End Configuration ==================================
#==============================================================================
# ** Lettuce_Window_Top
#------------------------------------------------------------------------------
# This window displays Title message
#==============================================================================
class Lettuce_Window_Top < Window_Base
def initialize
super(0,0,544,70)
self.contents = Bitmap.new(width-32,height-32)
self.contents.font.name = Fontname
self.contents.font.size = Fontsize
refresh
end
def refresh
self.contents.clear
self.contents.draw_text(0,-10,544-32,32,"Stats distribution",1)
self.contents.font.size = Fontsize-4
self.contents.draw_text(0,10,544-32,32,"Press left or right to change actor",1)
end
end
#==============================================================================
# ** Lettuce_Window_Points
#------------------------------------------------------------------------------
# This window displays the attributes of a party member
#==============================================================================
class Lettuce_Window_Points < Window_Base
def initialize(member_index)
super(351,200,194,52)
self.contents = Bitmap.new(width-32,height-32)
self.contents.font.name = Fontname
self.contents.font.size = Fontsize
refresh(member_index)
end
def refresh(member_index)
actor = $game_party.members[member_index]
points = $points[actor.id-1]
self.contents.draw_text(0,0,162,20,"Points: "+points.to_s)
end
end
#==============================================================================
# ** Lettuce_Window_Info
#------------------------------------------------------------------------------
# This window displays the attributes of a party member
#==============================================================================
class Lettuce_Window_Info < Window_Base
def initialize(member_index)
super(0,71,350,346)
self.contents = Bitmap.new(width-32,height-32)
self.contents.font.name = Fontname
self.contents.font.size = Fontsize
refresh(member_index)
end
def refresh(member_index)
actor = $game_party.members[member_index]
self.contents.clear
draw_actor_face(actor,10,10,92)
draw_actor_name(actor,120,10)
self.contents.font.size = Fontsize
self.contents.draw_text(190,30,200,20,"Class: "+actor.class.name)
self.contents.draw_text(120,30,200,20,"Lv. "+actor.level.to_s)
#s1 = actor.exp_s #total exp
#s2 = actor.next_rest_exp_s #exp left to nex lvl
#self.contents.draw_text(120,50,200,20,s1.to_s+" / "+s2.to_s)
#Preparing bar colours
back_color = Color.new(39, 58, 83, 255)
str_color1 = Color.new(229, 153, 73, 255)
str_color2 = Color.new(255, 72, 0, 255)
def_color1 = Color.new(210, 255, 0, 255)
def_color2 = Color.new(85, 129, 9, 255)
spi_color1 = Color.new(99, 133, 161, 255)
spi_color2 = Color.new(10, 60,107, 255)
agi_color1 = Color.new(167, 125, 180, 255)
agi_color2 = Color.new(90, 11, 107, 255)
hp_color1 = Color.new(66, 114, 164, 255)
hp_color2 = Color.new(122, 175, 229, 255)
mp_color1 = Color.new(93, 50, 158, 255)
mp_color2 = Color.new(145, 122, 229, 255)
self.contents.fill_rect(120,67,104,7,back_color)
self.contents.gradient_fill_rect(122,69,(actor.hp/actor.maxhp)*100,3,hp_color1,hp_color2)
self.contents.draw_text(120,44,100,30,"HP",0)
self.contents.draw_text(120,44,100,30,actor.hp.to_s + "/" + actor.maxhp.to_s,2)
self.contents.fill_rect(120,90,104,7,back_color)
self.contents.gradient_fill_rect(122,92,(actor.mp/actor.maxmp)*100,3,mp_color1,mp_color2)
self.contents.draw_text(120,67,100,30,"MP",0)
self.contents.draw_text(120,67,100,30,actor.mp.to_s + "/" + actor.maxmp.to_s,2)
##weapons
weapon = $data_weapons[actor.weapon_id]
shield = $data_armors[actor.armor1_id]
helm =$data_armors[actor.armor2_id]
body =$data_armors[actor.armor3_id]
accessory =$data_armors[actor.armor4_id]
bonus_atk = 0
bonus_def = 0
bonus_spi = 0
bonus_agi = 0
evasion = 0
crit = 4
if $data_actors[actor.id].critical_bonus
crit +=4
end
if weapon
bonus_atk += weapon.atk
bonus_def += weapon.def
bonus_spi += weapon.spi
bonus_agi += weapon.agi
if weapon.critical_bonus
crit += 4
end
end
if shield
bonus_atk += shield.atk
bonus_def += shield.def
bonus_spi += shield.spi
bonus_agi += shield.agi
evasion += shield.eva
end
if helm
bonus_atk += helm.atk
bonus_def += helm.def
bonus_spi += helm.spi
bonus_agi += helm.agi
evasion += helm.eva
end
if body
bonus_atk += body.atk
bonus_def += body.def
bonus_spi += body.spi
bonus_agi += body.agi
evasion += body.eva
end
if accessory
bonus_atk += accessory.atk
bonus_def += accessory.def
bonus_spi += accessory.spi
bonus_agi += accessory.agi
evasion += accessory.eva
end
draw_item_name(weapon,160,125+OFFSET,true)
draw_item_name(shield,160,165+OFFSET,true)
draw_item_name(helm,160,205+OFFSET,true)
draw_item_name(body,160,245+OFFSET,true)
draw_item_name(accessory,160,285+OFFSET,true)
self.contents.font.size = Fontsize - 5
self.contents.draw_text(10,120,100,20,Vocab::atk+": ")
self.contents.draw_text(10,120,100,20,(actor.atk-bonus_atk).to_s+" + "+bonus_atk.to_s,2)
self.contents.fill_rect(10,140,104,7,back_color)
self.contents.gradient_fill_rect(12,142,((actor.atk-bonus_atk)*MaxStat)/100,3,str_color1,str_color2)
self.contents.draw_text(10,150,100,20,Vocab::def+": ")
self.contents.draw_text(10,150,100,20,(actor.def-bonus_def).to_s+" + "+bonus_def.to_s,2)
self.contents.fill_rect(10,170,104,7,back_color)
self.contents.gradient_fill_rect(12,172,((actor.def-bonus_def)*MaxStat)/100,3,def_color1,def_color2)
self.contents.draw_text(10,180,100,20,Vocab::spi+": ")
self.contents.draw_text(10,180,100,20,(actor.spi-bonus_spi).to_s+" + "+bonus_spi.to_s,2)
self.contents.fill_rect(10,200,104,7,back_color)
self.contents.gradient_fill_rect(12,202,((actor.spi-bonus_spi)*MaxStat)/100,3,spi_color1,spi_color2)
self.contents.draw_text(10,210,100,20,Vocab::agi+": ")
self.contents.draw_text(10,210,100,20,(actor.agi-bonus_agi).to_s+" + "+bonus_agi.to_s,2)
self.contents.fill_rect(10,230,104,7,back_color)
self.contents.gradient_fill_rect(12,232,((actor.agi-bonus_agi)*MaxStat)/100,3,agi_color1,agi_color2)
if weapon
hit_rate = weapon.hit
else
hit_rate = 95
end
self.contents.font.size = Fontsize - 5
self.contents.font.color = Color.new(162,212,98,255)
self.contents.draw_text(10,245,100,20,"Maximum ATK :",2)
self.contents.draw_text(10,260,100,20,"Hit rate (%) :",2)
self.contents.draw_text(10,275,100,20,"Evasion rate (%) :",2)
self.contents.draw_text(10,290,100,20,"Critical Rate (%) :",2)
self.contents.draw_text(120,245,60,20,actor.atk.to_s,0)
self.contents.draw_text(120,260,60,20,hit_rate.to_s,0)
self.contents.draw_text(120,275,60,20,(evasion+5).to_s,0)
self.contents.draw_text(120,290,60,20,crit.to_s,0)
if Mode == 2
self.contents.font.size = Fontsize - 8
self.contents.font.color = Color.new(155,199,206,255)
self.contents.draw_text(23,100,125,20,"POINTS",2)
self.contents.draw_text(29,110,125,20,"REQUIRED",2)
self.contents.font.size = Fontsize - 4
self.contents.draw_text(20,125,115,20,required(actor.atk-bonus_atk).to_s,2)
self.contents.draw_text(20,155,115,20,required(actor.def-bonus_def).to_s,2)
self.contents.draw_text(20,185,115,20,required(actor.spi-bonus_spi).to_s,2)
self.contents.draw_text(20,215,115,20,required(actor.agi-bonus_agi).to_s,2)
end
self.contents.font.color = Color.new(155,199,206,255)
self.contents.font.size = Fontsize - 8
if weapon
self.contents.draw_text(185,140+OFFSET,100,20,Vocab::atk+"+"+weapon.atk.to_s)
self.contents.draw_text(185,150+OFFSET,100,20,Vocab::def+"+"+weapon.def.to_s)
self.contents.draw_text(253,140+OFFSET,100,20,Vocab::spi+"+"+weapon.spi.to_s)
self.contents.draw_text(253,150+OFFSET,100,20,Vocab::agi+"+"+weapon.agi.to_s)
end
if shield
self.contents.draw_text(185,180+OFFSET,100,20,Vocab::atk+"+"+shield.atk.to_s)
self.contents.draw_text(185,190+OFFSET,100,20,Vocab::def+"+"+shield.def.to_s)
self.contents.draw_text(253,180+OFFSET,100,20,Vocab::spi+"+"+shield.spi.to_s)
self.contents.draw_text(253,190+OFFSET,100,20,Vocab::agi+"+"+shield.agi.to_s)
end
if helm
self.contents.draw_text(185,220+OFFSET,100,20,Vocab::atk+"+"+helm.atk.to_s)
self.contents.draw_text(185,230+OFFSET,100,20,Vocab::def+"+"+helm.def.to_s)
self.contents.draw_text(253,220+OFFSET,100,20,Vocab::spi+"+"+helm.spi.to_s)
self.contents.draw_text(253,230+OFFSET,100,20,Vocab::agi+"+"+helm.agi.to_s)
end
if body
self.contents.draw_text(185,260+OFFSET,100,20,Vocab::atk+"+"+body.atk.to_s)
self.contents.draw_text(185,270+OFFSET,100,20,Vocab::def+"+"+body.def.to_s)
self.contents.draw_text(253,260+OFFSET,100,20,Vocab::spi+"+"+body.spi.to_s)
self.contents.draw_text(253,270+OFFSET,100,20,Vocab::agi+"+"+body.agi.to_s)
end
if accessory
self.contents.draw_text(185,300+OFFSET,100,20,Vocab::atk+"+"+accessory.atk.to_s)
self.contents.draw_text(185,310+OFFSET,100,20,Vocab::def+"+"+accessory.def.to_s)
self.contents.draw_text(253,300+OFFSET,100,20,Vocab::spi+"+"+accessory.spi.to_s)
self.contents.draw_text(253,310+OFFSET,100,20,Vocab::agi+"+"+accessory.agi.to_s)
end
end
def required(base)
return (((base-1)/10)+2).floor
end
end
#==============================================================================
# ** Lettuce_Window_Help
#------------------------------------------------------------------------------
# This window displays property of each attribute
#==============================================================================
class Lettuce_Window_Help < Window_Base
def initialize(index)
super(351,253,194,160)
self.contents = Bitmap.new(width-32,height-32)
self.contents.font.size = Fontsize - 6
refresh(index)
end
def refresh(index)
self.contents.clear
case index
when 0
help_text = "Increase "+Vocab::atk+" by 1 point"
when 1
help_text = "Increase "+Vocab::def+" by 1 point"
when 2
help_text = "Increase "+Vocab::spi+" by 1 point"
when 3
help_text = "Increase "+Vocab::agi+" by 1 point"
end
self.contents.draw_text(0,0,180,20,help_text)
end
end
#==============================================================================
# ** Scene_Stat_Dist
#------------------------------------------------------------------------------
# Performs stat distribution process :)
#==============================================================================
class Scene_Stat_Dist < Scene_Base
def initialize(menu_index=0)
@menu_index = menu_index
end
def start
super
create_menu_background
i1 = Vocab::atk
i2 = Vocab::def
i3 = Vocab::spi
i4 = Vocab::agi
@window_select = Window_Command.new(194,[i1,i2,i3,i4])
if $position
@window_select.index = $position - 1
else
@window_select.index = 0
end
@window_select.active = true
@window_select.x = 351
@window_select.y = 71
@window_top = Lettuce_Window_Top.new
@window_points = Lettuce_Window_Points.new(@menu_index)
@window_info = Lettuce_Window_Info.new(@menu_index)
@window_help = Lettuce_Window_Help.new(0)
end
def terminate
super
dispose_menu_background
@window_top.dispose
@window_points.dispose
@window_info.dispose
@window_help.dispose
@window_select.dispose
end
def update
update_menu_background
@window_points.update
@window_select.update
@window_help.refresh(@window_select.index)
@changes = 0
if Input.trigger?(Input::B)
Sound.play_cancel
$scene = Scene_Map.new
elsif Input.trigger?(Input::R)
@menu_index += 1
@menu_index %= $game_party.members.size
$scene = Scene_Stat_Dist.new(@menu_index)
elsif Input.trigger?(Input::L)
@menu_index += $game_party.members.size - 1
@menu_index %= $game_party.members.size
$scene = Scene_Stat_Dist.new(@menu_index)
elsif Input.trigger?(Input::C)
#Points addition begins
#which attribute
if Mode == 1
do_point_reg
elsif Mode == 2
do_point_rag
end
end
end
def do_point_reg
@att = @window_select.index
actor = $game_party.members[@menu_index]
##weapons
weapon = $data_weapons[actor.weapon_id]
shield = $data_armors[actor.armor1_id]
helm =$data_armors[actor.armor2_id]
body =$data_armors[actor.armor3_id]
accessory =$data_armors[actor.armor4_id]
bonus_atk = 0
bonus_def = 0
bonus_spi = 0
bonus_agi = 0
if weapon
bonus_atk += weapon.atk
bonus_def += weapon.def
bonus_spi += weapon.spi
bonus_agi += weapon.agi
end
if shield
bonus_atk += shield.atk
bonus_def += shield.def
bonus_spi += shield.spi
bonus_agi += shield.agi
end
if helm
bonus_atk += helm.atk
bonus_def += helm.def
bonus_spi += helm.spi
bonus_agi += helm.agi
end
if body
bonus_atk += body.atk
bonus_def += body.def
bonus_spi += body.spi
bonus_agi += body.agi
end
if accessory
bonus_atk += accessory.atk
bonus_def += accessory.def
bonus_spi += accessory.spi
bonus_agi += accessory.agi
end
case @att
when 0 #ATK
if $points[actor.id-1] < 1
Sound.play_cancel
elsif (actor.atk-bonus_atk) == MaxStat
Sound.play_cancel
else
$game_party.members[@menu_index].atk += IncreaseBy
$points[$game_party.members[@menu_index].id-1] -= 1
@changes += 1
end
when 1 #DEF
if $points[actor.id-1] < 1
Sound.play_cancel
elsif (actor.def-bonus_def) == MaxStat
Sound.play_cancel
else
$game_party.members[@menu_index].def += IncreaseBy
$points[$game_party.members[@menu_index].id-1] -= 1
@changes += 1
end
when 2 #SPI
if $points[actor.id-1] < 1
Sound.play_cancel
elsif (actor.spi-bonus_spi) == MaxStat
Sound.play_cancel
else
$game_party.members[@menu_index].spi += IncreaseBy
$points[$game_party.members[@menu_index].id-1] -= 1
@changes += 1
end
when 3 #AGI
if $points[actor.id-1] < 1
Sound.play_cancel
elsif (actor.agi-bonus_agi) == MaxStat
Sound.play_cancel
else
$game_party.members[@menu_index].agi += IncreaseBy
$points[$game_party.members[@menu_index].id-1] -= 1
@changes += 1
end
end
if @changes > 0
$scene = Scene_Stat_Dist.new(@menu_index)
end
end
def do_point_rag
@att = @window_select.index
actor = $game_party.members[@menu_index]
##weapons
weapon = $data_weapons[actor.weapon_id]
shield = $data_armors[actor.armor1_id]
helm =$data_armors[actor.armor2_id]
body =$data_armors[actor.armor3_id]
accessory =$data_armors[actor.armor4_id]
bonus_atk = 0
bonus_def = 0
bonus_spi = 0
bonus_agi = 0
if weapon
bonus_atk += weapon.atk
bonus_def += weapon.def
bonus_spi += weapon.spi
bonus_agi += weapon.agi
end
if shield
bonus_atk += shield.atk
bonus_def += shield.def
bonus_spi += shield.spi
bonus_agi += shield.agi
end
if helm
bonus_atk += helm.atk
bonus_def += helm.def
bonus_spi += helm.spi
bonus_agi += helm.agi
end
if body
bonus_atk += body.atk
bonus_def += body.def
bonus_spi += body.spi
bonus_agi += body.agi
end
if accessory
bonus_atk += accessory.atk
bonus_def += accessory.def
bonus_spi += accessory.spi
bonus_agi += accessory.agi
end
case @att
when 0 #ATK
base_value = actor.atk-bonus_atk
points = $points[actor.id-1]
if enough_point(base_value,points)
Sound.play_cancel
elsif (actor.atk-bonus_atk) == MaxStat
Sound.play_cancel
else
$game_party.members[@menu_index].atk += IncreaseBy
$points[$game_party.members[@menu_index].id-1] -= required(base_value)
@changes += 1
$position = 1
end
when 1 #DEF
base_value = actor.def-bonus_def
points = $points[actor.id-1]
if enough_point(base_value,points)
Sound.play_cancel
elsif (actor.def-bonus_def) == MaxStat
Sound.play_cancel
else
$game_party.members[@menu_index].def += IncreaseBy
$points[$game_party.members[@menu_index].id-1] -= required(base_value)
@changes += 1
$position = 2
end
when 2 #SPI
base_value = actor.spi-bonus_spi
points = $points[actor.id-1]
if enough_point(base_value,points)
Sound.play_cancel
elsif (actor.spi-bonus_spi) == MaxStat
Sound.play_cancel
else
$game_party.members[@menu_index].spi += IncreaseBy
$points[$game_party.members[@menu_index].id-1] -= required(base_value)
@changes += 1
$position = 3
end
when 3 #AGI
base_value = actor.agi-bonus_agi
points = $points[actor.id-1]
if enough_point(base_value,points)
Sound.play_cancel
elsif (actor.agi-bonus_agi) == MaxStat
Sound.play_cancel
else
$game_party.members[@menu_index].agi += IncreaseBy
$points[$game_party.members[@menu_index].id-1] -= required(base_value)
@changes += 1
$position = 4
end
end
if @changes > 0
$scene = Scene_Stat_Dist.new(@menu_index)
end
end
def enough_point(base,points)
required = (((base-1)/10)+2).floor
if required > points
return true
elsif required <= points
return false
end
end
def required(base)
return (((base-1)/10)+2).floor
end
end
#==============================================================================
# ** Save, Load and Level up aliases
#------------------------------------------------------------------------------
class Scene_File < Scene_Base
#-------------------------------Alias List
alias lettuce_write_save_data write_save_data
alias lettuce_read_save_data read_save_data
def write_save_data(file)
lettuce_write_save_data(file)
Marshal.dump($points, file)
end
def read_save_data(file)
lettuce_read_save_data(file)
$points = Marshal.load(file)
end
end
#==============================================================================