Breath of Fire III Style Masters System
Version 1.0
Version 1.0
Introduction
This script emulates the masters system from breath of fire III. You can create as many masters as you like, and each master can teach
a number of skills to a character apprenticed to him. A master can apprentice as many characters as you like, though he will only teach
each of his skills once!
While apprenticed, each character will enjoy a boost or a penalty to his str, dex, agi, int, hp and sp.
Screenshots
See the demo!
Demo
http://www.rmxp.org/forums/downloads.php?do=file&id=1645
Script
Content Hidden
Spoiler
#==============================================================================
# ** Breath of Fire III Style Masters System
#------------------------------------------------------------------------------
# TywinLannister
# Version 1
# 2007-16-11
#------------------------------------------------------------------------------
# * Description
#
# This system was designed to emulate the Breath of Fire III Masters system.
# That is, you can apprentice a character to a master in order to learn
# additonal skills.
#------------------------------------------------------------------------------
# * Instructions
#
# Place The Script Below the SDK & above Main.
# Read the readme file for more information.
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Masters Script', 'TywinLannister', 1, '2007-16-11')
#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state('Masters Script')
#==============================================================================
# ** Masters_Script
#==============================================================================
class Masters_Script
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make a game_masters object
$game_masters = Game_Masters.new
# Set up masters
$game_masters.set_up_masters
end
end
#==============================================================================
# ** Game_Masters
#------------------------------------------------------------------------------
# This class handles the masters array. Refer to "$game_masters" for each
# instance of this class.
#==============================================================================
class Game_Masters
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :masters # array of masters
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@data = []
end
#--------------------------------------------------------------------------
# * Get Master
# master_id : master ID
#--------------------------------------------------------------------------
def [](master_id)
if @data[master_id] == nil
@data[master_id] = Game_Master.new(master_id)
end
return @data[master_id]
end
#--------------------------------------------------------------------------
# * set_up_masters
#--------------------------------------------------------------------------
def set_up_masters
@masters = []
#This is the only change YOU need to make to the script!
#create masters (ID, name, , skills taught at,
#str adjust, dex adjust, agi adjust, int adjust, hp adjust, sp adjust)
#-----------------------------------------------------------------------
# ID => so we can find the master in the array.
# name => The name of your master.
# simply put the id of each skill the master can teach.
# skills taught at => If this is set to 3, then come back when you have gained
# 3 levels to learn the next skill!
# str adjust => At each level the character will add this to his stat!
# The same applies for the other adjusts!
#-------------------------------------------------------------------------
$game_master = Game_Master.new(0, "Bunyan", [1,2,3], 3, 8, -2, -2, -2, 5, -5)
@masters.push($game_master)
$game_master = Game_Master.new(1, "Lyssa", [10,11,12], 1, -2, -2, -2, 8, -5, 5)
@masters.push($game_master)
$game_master = Game_Master.new(2, "Dokan", [7,8,9], 2, -2, 4, 4, -2, 0, 0)
@masters.push($game_master)
end
#--------------------------------------------------------------------------
# * determine_progress
#--------------------------------------------------------------------------
def determine_progress(master_index)
@master = @masters[master_index]
progress = false
for i in [email hidden]
@actor = @master.pupils[i]
level_needed = @master.pupils_current_level[i] + @master.skills_taught_at
if @actor.level >= level_needed
@master.pupil_can_learn.push(@actor)
progress = true
end
end
if progress == true
@actor = @master.pupil_can_learn[rand(@master.pupil_can_learn.length)]
@actor.learn_skill(@master.skills[@master.next_skill_id])
@master.pupils_current_level[i] = level_needed
@master.next_skill_id += 1
@master.pupil_can_learn.clear
end
return progress
end
end
#==============================================================================
# ** Game_Master
#------------------------------------------------------------------------------
class Game_Master
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor : name # master name
attr_accessor : master_name # master file name
attr_accessor : skills # skills taught by this master
attr_accessor : skills_taught_at # levels you must gain to learn the skill.
attr_accessor : str_boost # boost to STR per level
attr_accessor : dex_boost # boost to DEX per level
attr_accessor : agi_boost # boost to AGI per level
attr_accessor : int_boost # boost to INT per level
attr_accessor : hp_boost # boost to HP per level
attr_accessor : sp_boost # boost to SP per level
attr_accessor : pupils # pupils taught by this master
attr_accessor : pupils_current_level # the current level of the student
attr_accessor : next_skill_id # position of next skill to teach in skills array.
attr_accessor : pupil_can_learn # the pupils that can learn skills at this time.
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize (master_id, name, skills, skills_taught, str, dex, agi, int, hp, sp)
@master_id = master_id
@name = name
@master_name = name
@skills = skills
@skills_taught_at = skills_taught
@str_boost = str
@dex_boost = dex
@agi_boost = agi
@int_boost = int
@hp_boost = hp
@sp_boost = sp
@pupils = []
@pupils_current_level = []
@next_skill_id = 0
@pupil_can_learn = []
end
end
#==============================================================================
# ** Scene_Pupil_Select
#------------------------------------------------------------------------------
class Scene_Pupil_Select
#--------------------------------------------------------------------------
# * Object Initialization
# actor_index : actor index
#--------------------------------------------------------------------------
def initialize(master_index, menu_index = 0)
@master_index = master_index
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Get master
@master = $game_masters.masters[@master_index]
#Commands
@commands = []
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
@commands.push(actor.name)
end
# Make pupil select window
@pupil_select_window = Window_Pupil_Select.new(@master, @commands)
@pupil_select_window.index = @menu_index
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@pupil_select_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@pupil_select_window.update
# If window is active: call update_command
if @pupil_select_window.active
update_pupil_select
return
end
end
#--------------------------------------------------------------------------
# * Update_Pupil_Select
#--------------------------------------------------------------------------
def update_pupil_select
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @pupil_select_window.index
when 0
assign_pupil_to_master
when 1
assign_pupil_to_master
when 2
assign_pupil_to_master
when 3
assign_pupil_to_master
end
return
end
end
#--------------------------------------------------------------------------
# * Assign Pupil To Master
#--------------------------------------------------------------------------
def assign_pupil_to_master
@actor = $game_party.actors[@pupil_select_window.index]
for i in 0...$game_masters.masters.size
@this_master = $game_masters.masters[i]
for i in 0...@this_master.pupils.size
if @actor.name == @this_master.pupils[i].name
$game_system.se_play($data_system.buzzer_se)
return
end
end
end
$game_system.se_play($data_system.decision_se)
@master.pupils.push(@actor)
@master.pupils_current_level.push(@actor.level)
$scene = Scene_Map.new
end
end
#==============================================================================
# ** Window_Status
#------------------------------------------------------------------------------
# This window displays full status specs on the status screen.
#==============================================================================
class Window_Pupil_Select < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(master, commands)
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
@master = master
@item_max = commands.size
@commands = commands
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
draw_master_details(normal_color)
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
x = 300
y = i * 116
actor = $game_party.actors[i]
draw_actor_graphic(actor, x, y + 80)
draw_item(i, normal_color, x + 50, y + 40)
end
draw_pupils_individual_masters(normal_color)
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
# color : text color
#--------------------------------------------------------------------------
def draw_item(index, color, x, y)
self.contents.font.color = color
rect = Rect.new(x, y, self.contents.width, 24)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index])
end
#--------------------------------------------------------------------------
# * Draw Master Details
#--------------------------------------------------------------------------
def draw_master_details(color)
self.contents.font.color = color
#Master's name
rect = Rect.new(0, 0, self.contents.width, 24)
self.contents.draw_text(rect, @master.name)
#Parameter names
rect = Rect.new(0, 24, self.contents.width, 24)
self.contents.draw_text(rect, $data_system.words.str)
rect = Rect.new(0, 48, self.contents.width, 24)
self.contents.draw_text(rect, $data_system.words.dex)
rect = Rect.new(0, 72, self.contents.width, 24)
self.contents.draw_text(rect, $data_system.words.agi)
rect = Rect.new(0, 96, self.contents.width, 24)
self.contents.draw_text(rect, $data_system.words.int)
rect = Rect.new(0, 120, self.contents.width, 24)
self.contents.draw_text(rect, $data_system.words.hp)
rect = Rect.new(0, 144, self.contents.width, 24)
self.contents.draw_text(rect, $data_system.words.sp)
#Parameter boosts
bonus = @master.str_boost
draw_master_bonus(80, 24, @master.str_boost)
draw_master_bonus(80, 48, @master.dex_boost)
draw_master_bonus(80, 72, @master.agi_boost)
draw_master_bonus(80, 96, @master.int_boost)
draw_master_bonus(80, 120, @master.hp_boost)
draw_master_bonus(80, 144, @master.sp_boost)
#Show who master is teaching
self.contents.font.color = color
rect = Rect.new(0,244, self.contents.width, 24)
self.contents.draw_text(rect, "Teaching:")
if @master.pupils != nil
for i in [email hidden]
rect = Rect.new(0, 268 + (i * 24), self.contents.width, 24)
@actor = @master.pupils[i]
self.contents.draw_text(rect, @actor.name)
end
else
rect = Rect.new(0, 268, self.contents.width, 24)
self.contents.draw_text(rect, "None")
end
end
#--------------------------------------------------------------------------
# * Draw Master Bonus
#--------------------------------------------------------------------------
def draw_master_bonus(x, y, bonus)
self.contents.font.color = Color.yellow
if bonus >= 0
rect = Rect.new(x - 15, y, self.contents.width, 24)
self.contents.draw_text(rect, "+")
else
self.contents.font.color = Color.red
x = x - 10
end
rect = Rect.new(x, y, self.contents.width, 24)
self.contents.draw_text(rect, bonus.to_s)
end
#--------------------------------------------------------------------------
# * Draw Student's Individual Masters
#--------------------------------------------------------------------------
def draw_pupils_individual_masters(color)
self.contents.font.color = color
rect = Rect.new(480, 12, self.contents.width, 24)
self.contents.draw_text(rect, "MASTER")
for i in 0...$game_party.actors.size
self.contents.font.color = Color.red
x = 480
y = i * 116
actor = $game_party.actors[i]
this_text = "NONE"
for i in 0...$game_masters.masters.size
@this_master = $game_masters.masters[i]
for i in 0...@this_master.pupils.size
if actor.name == @this_master.pupils[i].name
self.contents.font.color = Color.yellow
this_text = @this_master.name
end
end
end
rect = Rect.new(x, y + 40, self.contents.width, 24)
self.contents.draw_text(rect, this_text)
end
end
#--------------------------------------------------------------------------
# * Update Cursor Rect
#--------------------------------------------------------------------------
alias twyin_update_cursor_rect update_cursor_rect
def update_cursor_rect
# Update cursor rectangle
if @index == 0
newY = 38
elsif @index == 1
newY = 153
elsif @index == 2
newY = 270
elsif @index == 3
newY = 385
end
self.cursor_rect.set(x+340, newY, 120, 32)
end
end
#==============================================================================
# ** Scene_Title
#==============================================================================
class Scene_Title
#--------------------------------------------------------------------------
# * Command New Game
#--------------------------------------------------------------------------
alias tywin_masters_cng command_new_game
def command_new_game
tywin_masters_cng
$masters_system = Masters_Script.new
$masters_system.main
end
end
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :tywin_hp_bonus
attr_accessor :tywin_sp_bonus
attr_accessor :tywin_str_bonus
attr_accessor :tywin_dex_bonus
attr_accessor :tywin_agi_bonus
attr_accessor :tywin_int_bonus
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias tywin_base_maxhp base_maxhp
alias tywin_base_maxsp base_maxsp
alias tywin_base_str base_str
alias tywin_base_dex base_dex
alias tywin_base_agi base_agi
alias tywin_base_int base_int
alias tywin_exp= exp=
#--------------------------------------------------------------------------
# * Setup
#--------------------------------------------------------------------------
alias tywin_setup setup
def setup(actor_id)
@tywin_hp_bonus = 0
@tywin_sp_bonus = 0
@tywin_str_bonus = 0
@tywin_dex_bonus = 0
@tywin_agi_bonus = 0
@tywin_int_bonus = 0
tywin_setup(actor_id)
end
#--------------------------------------------------------------------------
# * Get Basic Maximum HP
#--------------------------------------------------------------------------
def base_maxhp
n = tywin_base_maxhp
n += Integer(tywin_hp_bonus)
return n
end
#--------------------------------------------------------------------------
# * Get Basic Maximum SP
#--------------------------------------------------------------------------
def base_maxsp
n = tywin_base_maxsp
n += Integer(tywin_sp_bonus)
return n
end
#--------------------------------------------------------------------------
# * Get Basic Strength
#--------------------------------------------------------------------------
def base_str
n = tywin_base_str
n += tywin_str_bonus
return n
end
#--------------------------------------------------------------------------
# * Get Basic Dexterity
#--------------------------------------------------------------------------
def base_dex
n = tywin_base_dex
n += tywin_dex_bonus
return n
end
#--------------------------------------------------------------------------
# * Get Basic Agility
#--------------------------------------------------------------------------
def base_agi
n = tywin_base_agi
n += tywin_agi_bonus
return n
end
#--------------------------------------------------------------------------
# * Get Basic Intelligence
#--------------------------------------------------------------------------
def base_int
n = tywin_base_int
n += tywin_int_bonus
return n
end
#--------------------------------------------------------------------------
# * Change EXP
#--------------------------------------------------------------------------
def exp=(exp)
@exp = [[exp, 9999999].min, 0].max
# Level up
while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
@level += 1
add_master_attributes
# 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
#--------------------------------------------------------------------------
# * Add Master Attributes
#--------------------------------------------------------------------------
def add_master_attributes
for i in 0...$game_masters.masters.size
@master = $game_masters.masters[i]
if @master.pupils != nil
for i in [email hidden]
if name == @master.pupils[i].name
@tywin_hp_bonus += @master.hp_boost
@tywin_sp_bonus += @master.sp_boost
@tywin_str_bonus += @master.str_boost
@tywin_dex_bonus += @master.dex_boost
@tywin_agi_bonus += @master.agi_boost
@tywin_int_bonus += @master.int_boost
end
end
end
end
end
end
#==============================================================================
# ** Scene_Save
#==============================================================================
class Scene_Save
#--------------------------------------------------------------------------
# * Write Save Data
#--------------------------------------------------------------------------
alias tywin_masters_wsd write_save_data
def write_save_data(file)
tywin_masters_wsd(file)
Marshal.dump($game_masters, file)
end
end
#==============================================================================
# ** Scene_Load
#==============================================================================
class Scene_Load
#--------------------------------------------------------------------------
# * Read Save Data
#--------------------------------------------------------------------------
alias tywin_masters_rsd read_save_data
def read_save_data(file)
tywin_masters_rsd(file)
$game_masters = Marshal.load(file)
end
end
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end
# ** Breath of Fire III Style Masters System
#------------------------------------------------------------------------------
# TywinLannister
# Version 1
# 2007-16-11
#------------------------------------------------------------------------------
# * Description
#
# This system was designed to emulate the Breath of Fire III Masters system.
# That is, you can apprentice a character to a master in order to learn
# additonal skills.
#------------------------------------------------------------------------------
# * Instructions
#
# Place The Script Below the SDK & above Main.
# Read the readme file for more information.
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Masters Script', 'TywinLannister', 1, '2007-16-11')
#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state('Masters Script')
#==============================================================================
# ** Masters_Script
#==============================================================================
class Masters_Script
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make a game_masters object
$game_masters = Game_Masters.new
# Set up masters
$game_masters.set_up_masters
end
end
#==============================================================================
# ** Game_Masters
#------------------------------------------------------------------------------
# This class handles the masters array. Refer to "$game_masters" for each
# instance of this class.
#==============================================================================
class Game_Masters
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :masters # array of masters
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@data = []
end
#--------------------------------------------------------------------------
# * Get Master
# master_id : master ID
#--------------------------------------------------------------------------
def [](master_id)
if @data[master_id] == nil
@data[master_id] = Game_Master.new(master_id)
end
return @data[master_id]
end
#--------------------------------------------------------------------------
# * set_up_masters
#--------------------------------------------------------------------------
def set_up_masters
@masters = []
#This is the only change YOU need to make to the script!
#create masters (ID, name, , skills taught at,
#str adjust, dex adjust, agi adjust, int adjust, hp adjust, sp adjust)
#-----------------------------------------------------------------------
# ID => so we can find the master in the array.
# name => The name of your master.
# simply put the id of each skill the master can teach.
# skills taught at => If this is set to 3, then come back when you have gained
# 3 levels to learn the next skill!
# str adjust => At each level the character will add this to his stat!
# The same applies for the other adjusts!
#-------------------------------------------------------------------------
$game_master = Game_Master.new(0, "Bunyan", [1,2,3], 3, 8, -2, -2, -2, 5, -5)
@masters.push($game_master)
$game_master = Game_Master.new(1, "Lyssa", [10,11,12], 1, -2, -2, -2, 8, -5, 5)
@masters.push($game_master)
$game_master = Game_Master.new(2, "Dokan", [7,8,9], 2, -2, 4, 4, -2, 0, 0)
@masters.push($game_master)
end
#--------------------------------------------------------------------------
# * determine_progress
#--------------------------------------------------------------------------
def determine_progress(master_index)
@master = @masters[master_index]
progress = false
for i in [email hidden]
@actor = @master.pupils[i]
level_needed = @master.pupils_current_level[i] + @master.skills_taught_at
if @actor.level >= level_needed
@master.pupil_can_learn.push(@actor)
progress = true
end
end
if progress == true
@actor = @master.pupil_can_learn[rand(@master.pupil_can_learn.length)]
@actor.learn_skill(@master.skills[@master.next_skill_id])
@master.pupils_current_level[i] = level_needed
@master.next_skill_id += 1
@master.pupil_can_learn.clear
end
return progress
end
end
#==============================================================================
# ** Game_Master
#------------------------------------------------------------------------------
class Game_Master
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor : name # master name
attr_accessor : master_name # master file name
attr_accessor : skills # skills taught by this master
attr_accessor : skills_taught_at # levels you must gain to learn the skill.
attr_accessor : str_boost # boost to STR per level
attr_accessor : dex_boost # boost to DEX per level
attr_accessor : agi_boost # boost to AGI per level
attr_accessor : int_boost # boost to INT per level
attr_accessor : hp_boost # boost to HP per level
attr_accessor : sp_boost # boost to SP per level
attr_accessor : pupils # pupils taught by this master
attr_accessor : pupils_current_level # the current level of the student
attr_accessor : next_skill_id # position of next skill to teach in skills array.
attr_accessor : pupil_can_learn # the pupils that can learn skills at this time.
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize (master_id, name, skills, skills_taught, str, dex, agi, int, hp, sp)
@master_id = master_id
@name = name
@master_name = name
@skills = skills
@skills_taught_at = skills_taught
@str_boost = str
@dex_boost = dex
@agi_boost = agi
@int_boost = int
@hp_boost = hp
@sp_boost = sp
@pupils = []
@pupils_current_level = []
@next_skill_id = 0
@pupil_can_learn = []
end
end
#==============================================================================
# ** Scene_Pupil_Select
#------------------------------------------------------------------------------
class Scene_Pupil_Select
#--------------------------------------------------------------------------
# * Object Initialization
# actor_index : actor index
#--------------------------------------------------------------------------
def initialize(master_index, menu_index = 0)
@master_index = master_index
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Get master
@master = $game_masters.masters[@master_index]
#Commands
@commands = []
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
@commands.push(actor.name)
end
# Make pupil select window
@pupil_select_window = Window_Pupil_Select.new(@master, @commands)
@pupil_select_window.index = @menu_index
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@pupil_select_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@pupil_select_window.update
# If window is active: call update_command
if @pupil_select_window.active
update_pupil_select
return
end
end
#--------------------------------------------------------------------------
# * Update_Pupil_Select
#--------------------------------------------------------------------------
def update_pupil_select
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @pupil_select_window.index
when 0
assign_pupil_to_master
when 1
assign_pupil_to_master
when 2
assign_pupil_to_master
when 3
assign_pupil_to_master
end
return
end
end
#--------------------------------------------------------------------------
# * Assign Pupil To Master
#--------------------------------------------------------------------------
def assign_pupil_to_master
@actor = $game_party.actors[@pupil_select_window.index]
for i in 0...$game_masters.masters.size
@this_master = $game_masters.masters[i]
for i in 0...@this_master.pupils.size
if @actor.name == @this_master.pupils[i].name
$game_system.se_play($data_system.buzzer_se)
return
end
end
end
$game_system.se_play($data_system.decision_se)
@master.pupils.push(@actor)
@master.pupils_current_level.push(@actor.level)
$scene = Scene_Map.new
end
end
#==============================================================================
# ** Window_Status
#------------------------------------------------------------------------------
# This window displays full status specs on the status screen.
#==============================================================================
class Window_Pupil_Select < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(master, commands)
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
@master = master
@item_max = commands.size
@commands = commands
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
draw_master_details(normal_color)
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
x = 300
y = i * 116
actor = $game_party.actors[i]
draw_actor_graphic(actor, x, y + 80)
draw_item(i, normal_color, x + 50, y + 40)
end
draw_pupils_individual_masters(normal_color)
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
# color : text color
#--------------------------------------------------------------------------
def draw_item(index, color, x, y)
self.contents.font.color = color
rect = Rect.new(x, y, self.contents.width, 24)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index])
end
#--------------------------------------------------------------------------
# * Draw Master Details
#--------------------------------------------------------------------------
def draw_master_details(color)
self.contents.font.color = color
#Master's name
rect = Rect.new(0, 0, self.contents.width, 24)
self.contents.draw_text(rect, @master.name)
#Parameter names
rect = Rect.new(0, 24, self.contents.width, 24)
self.contents.draw_text(rect, $data_system.words.str)
rect = Rect.new(0, 48, self.contents.width, 24)
self.contents.draw_text(rect, $data_system.words.dex)
rect = Rect.new(0, 72, self.contents.width, 24)
self.contents.draw_text(rect, $data_system.words.agi)
rect = Rect.new(0, 96, self.contents.width, 24)
self.contents.draw_text(rect, $data_system.words.int)
rect = Rect.new(0, 120, self.contents.width, 24)
self.contents.draw_text(rect, $data_system.words.hp)
rect = Rect.new(0, 144, self.contents.width, 24)
self.contents.draw_text(rect, $data_system.words.sp)
#Parameter boosts
bonus = @master.str_boost
draw_master_bonus(80, 24, @master.str_boost)
draw_master_bonus(80, 48, @master.dex_boost)
draw_master_bonus(80, 72, @master.agi_boost)
draw_master_bonus(80, 96, @master.int_boost)
draw_master_bonus(80, 120, @master.hp_boost)
draw_master_bonus(80, 144, @master.sp_boost)
#Show who master is teaching
self.contents.font.color = color
rect = Rect.new(0,244, self.contents.width, 24)
self.contents.draw_text(rect, "Teaching:")
if @master.pupils != nil
for i in [email hidden]
rect = Rect.new(0, 268 + (i * 24), self.contents.width, 24)
@actor = @master.pupils[i]
self.contents.draw_text(rect, @actor.name)
end
else
rect = Rect.new(0, 268, self.contents.width, 24)
self.contents.draw_text(rect, "None")
end
end
#--------------------------------------------------------------------------
# * Draw Master Bonus
#--------------------------------------------------------------------------
def draw_master_bonus(x, y, bonus)
self.contents.font.color = Color.yellow
if bonus >= 0
rect = Rect.new(x - 15, y, self.contents.width, 24)
self.contents.draw_text(rect, "+")
else
self.contents.font.color = Color.red
x = x - 10
end
rect = Rect.new(x, y, self.contents.width, 24)
self.contents.draw_text(rect, bonus.to_s)
end
#--------------------------------------------------------------------------
# * Draw Student's Individual Masters
#--------------------------------------------------------------------------
def draw_pupils_individual_masters(color)
self.contents.font.color = color
rect = Rect.new(480, 12, self.contents.width, 24)
self.contents.draw_text(rect, "MASTER")
for i in 0...$game_party.actors.size
self.contents.font.color = Color.red
x = 480
y = i * 116
actor = $game_party.actors[i]
this_text = "NONE"
for i in 0...$game_masters.masters.size
@this_master = $game_masters.masters[i]
for i in 0...@this_master.pupils.size
if actor.name == @this_master.pupils[i].name
self.contents.font.color = Color.yellow
this_text = @this_master.name
end
end
end
rect = Rect.new(x, y + 40, self.contents.width, 24)
self.contents.draw_text(rect, this_text)
end
end
#--------------------------------------------------------------------------
# * Update Cursor Rect
#--------------------------------------------------------------------------
alias twyin_update_cursor_rect update_cursor_rect
def update_cursor_rect
# Update cursor rectangle
if @index == 0
newY = 38
elsif @index == 1
newY = 153
elsif @index == 2
newY = 270
elsif @index == 3
newY = 385
end
self.cursor_rect.set(x+340, newY, 120, 32)
end
end
#==============================================================================
# ** Scene_Title
#==============================================================================
class Scene_Title
#--------------------------------------------------------------------------
# * Command New Game
#--------------------------------------------------------------------------
alias tywin_masters_cng command_new_game
def command_new_game
tywin_masters_cng
$masters_system = Masters_Script.new
$masters_system.main
end
end
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :tywin_hp_bonus
attr_accessor :tywin_sp_bonus
attr_accessor :tywin_str_bonus
attr_accessor :tywin_dex_bonus
attr_accessor :tywin_agi_bonus
attr_accessor :tywin_int_bonus
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias tywin_base_maxhp base_maxhp
alias tywin_base_maxsp base_maxsp
alias tywin_base_str base_str
alias tywin_base_dex base_dex
alias tywin_base_agi base_agi
alias tywin_base_int base_int
alias tywin_exp= exp=
#--------------------------------------------------------------------------
# * Setup
#--------------------------------------------------------------------------
alias tywin_setup setup
def setup(actor_id)
@tywin_hp_bonus = 0
@tywin_sp_bonus = 0
@tywin_str_bonus = 0
@tywin_dex_bonus = 0
@tywin_agi_bonus = 0
@tywin_int_bonus = 0
tywin_setup(actor_id)
end
#--------------------------------------------------------------------------
# * Get Basic Maximum HP
#--------------------------------------------------------------------------
def base_maxhp
n = tywin_base_maxhp
n += Integer(tywin_hp_bonus)
return n
end
#--------------------------------------------------------------------------
# * Get Basic Maximum SP
#--------------------------------------------------------------------------
def base_maxsp
n = tywin_base_maxsp
n += Integer(tywin_sp_bonus)
return n
end
#--------------------------------------------------------------------------
# * Get Basic Strength
#--------------------------------------------------------------------------
def base_str
n = tywin_base_str
n += tywin_str_bonus
return n
end
#--------------------------------------------------------------------------
# * Get Basic Dexterity
#--------------------------------------------------------------------------
def base_dex
n = tywin_base_dex
n += tywin_dex_bonus
return n
end
#--------------------------------------------------------------------------
# * Get Basic Agility
#--------------------------------------------------------------------------
def base_agi
n = tywin_base_agi
n += tywin_agi_bonus
return n
end
#--------------------------------------------------------------------------
# * Get Basic Intelligence
#--------------------------------------------------------------------------
def base_int
n = tywin_base_int
n += tywin_int_bonus
return n
end
#--------------------------------------------------------------------------
# * Change EXP
#--------------------------------------------------------------------------
def exp=(exp)
@exp = [[exp, 9999999].min, 0].max
# Level up
while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
@level += 1
add_master_attributes
# 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
#--------------------------------------------------------------------------
# * Add Master Attributes
#--------------------------------------------------------------------------
def add_master_attributes
for i in 0...$game_masters.masters.size
@master = $game_masters.masters[i]
if @master.pupils != nil
for i in [email hidden]
if name == @master.pupils[i].name
@tywin_hp_bonus += @master.hp_boost
@tywin_sp_bonus += @master.sp_boost
@tywin_str_bonus += @master.str_boost
@tywin_dex_bonus += @master.dex_boost
@tywin_agi_bonus += @master.agi_boost
@tywin_int_bonus += @master.int_boost
end
end
end
end
end
end
#==============================================================================
# ** Scene_Save
#==============================================================================
class Scene_Save
#--------------------------------------------------------------------------
# * Write Save Data
#--------------------------------------------------------------------------
alias tywin_masters_wsd write_save_data
def write_save_data(file)
tywin_masters_wsd(file)
Marshal.dump($game_masters, file)
end
end
#==============================================================================
# ** Scene_Load
#==============================================================================
class Scene_Load
#--------------------------------------------------------------------------
# * Read Save Data
#--------------------------------------------------------------------------
alias tywin_masters_rsd read_save_data
def read_save_data(file)
tywin_masters_rsd(file)
$game_masters = Marshal.load(file)
end
end
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end
Instructions
Paste the script below the SDK and above main.
On line 97 of the script, you will find:
Quote:
$game_master = Game_Master.new(0, "Bunyan", [1,2,3], 3, 8, -2, -2, -2, 5, -5)
masters.push($game_master)
masters.push($game_master)
simply copy and paste these two lines to create a new master. The master is in the format:
Quote:
$game_master = Game_Master.new (ID, name, , skills taught at intervels, str adjust, dex adjust, agi adjust, int adjust, hp adjust, sp adjust)
Now to call the masters, look at the events I have set up. For a simple masters interface, use the following:
Content Hidden
Spoiler
Conditional Branch: Script: $game_masters.masters[0].pupils[0] == nil
Text: Who will I teach? I teach HEALING/ICE or whatever
Script: $scene = Scene_Pupil_Select.new()
Else
Text: Let's see how we've been doing.....
Conditional Branch: Script: $game_masters.masters[].next_skill_id == $game_masters.masters[].skills.length
Text: I've taught you all I can!
Else
Conditonal Branch: script: $game_masters.determine_progress() == true
Text: Good!
Text: You've learned a new skill!
Else
Text: Come back later!
Branch End
Branch End
Text: Do you continue to study under me?
Show Choices: Yes/No
When [yes]
Text: Who else needs my wisdom
Script: $scene = Scene_Pupil_Select.new()
When [no]
Text: I release you all from my teachings!
Script: $game_masters.masters[].pupils.clear
Branch End
Branch End
Text: Who will I teach? I teach HEALING/ICE or whatever
Script: $scene = Scene_Pupil_Select.new()
Else
Text: Let's see how we've been doing.....
Conditional Branch: Script: $game_masters.masters[].next_skill_id == $game_masters.masters[].skills.length
Text: I've taught you all I can!
Else
Conditonal Branch: script: $game_masters.determine_progress() == true
Text: Good!
Text: You've learned a new skill!
Else
Text: Come back later!
Branch End
Branch End
Text: Do you continue to study under me?
Show Choices: Yes/No
When [yes]
Text: Who else needs my wisdom
Script: $scene = Scene_Pupil_Select.new()
When [no]
Text: I release you all from my teachings!
Script: $game_masters.masters[].pupils.clear
Branch End
Branch End
All you've got to do is replace with the ID of the master you want to interact with. Just look at the demo for details.
Compatibility
Requires the SDK (I am using 2.3). Other than that there shouldn't be any major compatibility issues!
Credits and Thanks
Trickster and Sephirothspawn for being awesome scripters! reading through their stuff really cleared up alot of things!
Authors Notes
Three days, a couple of hours at a time got me through my first script! More to come!!!