=begin
==============================================================================
** Skill Select System
Author: Tsukihime
Date: Aug 7, 2012
------------------------------------------------------------------------------
** Change log
Aug 7
-changed skill sets to store skill ID's rather than skill objects,
because the objects themselves are not the same when the game reloads
Jul 22
-fixed bug where drawing skill cost crashed
-fixed bug where skill slots were not updated upon level
May 29
-fixed bug where $import variables were not initialized
May 27
-fixed a bug where passive skill effects weren't working
May 24
-refactored code, removed unnecessary window definitions
-Initialized all RPG classes
May 18, 2012
-Added compatibility for Monster Hunter script so recruited enemies
have skillpoints and skill slots
-added skill icons
May 17, 2012
-added more "skill_conditions_met?" requirements
-added extra refresh calls when skills are assigned/unassigned
-fixed major bug where checking for free slots on the actor
was not performed correctly
May 14, 2012
-added support for skillpoint growth formulas
-separated passive effects code to another script
-fixed bug where added/removed skills were not
updated on access to battle setup sceene
-added passive support for all parameters
-added passive support for party features
-added passive support for special features
-added passive support for adding/sealing skill types
-added passive support for adding/sealing skills
-added passive support for adding weapon/armor types
May 8
-added simple passive effects for base parameters
-fixed a small bug where test battle crashes
-added option to turn off skillpoint system
-added skillpoint system
-added skillpoint cost for skills
-switched to notetags for "active" or "passive" skills
-"normal" skills do not need to be assigned by default
May 7, 2012
-initialize release
------------------------------------------------------------------------------
This script changes the default skill system by
allowing players to only select a certain number
of skills that they can bring into battle.
In this system, there are three "selection types"
for skills
1 - "normal" skills
2 - "active" skills
3 - "passive" skills
To specify a select type, tag the skill with
<select: type>
Normal skills are the default select type for skills.
They can be used in battle as long as you have learned it
Active skills are skills that require you to equip
in order to use in battle.
Passive skills are skills whose effects will be activated
as long as the skill is equipped.
The battle setup menu is accessed through the menu.
The skills are grouped by skill type, and the equipped
skills are displayed on the left. The top window shows the
active skills, while the bottom window shows the passive
skills.
If you have skill slots available, you can select a skill
by selecting it from the main skill list. To remove it
from the list, just select it again. Equipping a skill
requires a certain amount of skill points, and you can
only equip a skill if you have enough skill points.
You can use the left-key or right-key move
between the battle skill lists and your main skill list.
Selecting any of the skills in your battle skill list will
remove them from the list. While you're at the active
skill list, you can press pageup or pagedown to scroll
between the passive skill list.
The max number of skills from either category is limited
by the max number of skills for your particular actor.
The max number of skills may grow depending on your
actor's level, specified by the amounts you write in
each actor's noteboxes.
The syntax for this is
<max active>
1:1, 5:2, 10:3
16:4
23:5
</max active>
The same applies for passive skills; simply replace "active"
with "passive".
You define the skillpoint cost for each skill and the skill select type
through the Skills tab in the database.
<select: active> - specifies the selection type
<sp: 2> - specifies the skillpoint cost
To define the actor's skillpoint growth, you add the following
tag to the actor
<SP: level*3>
To indicate that the amount of skillpoints received at each level
is three times the current level. You will need to use the exact
word "level" if you want to refer to the actor's level.
In order to set up passive skills, you must tag your skills with the
appropriate passive effects defined in FP: Passive Effects script,
and then make sure that your skill is tagged as a passive select type.
==============================================================================
=end
$imported = {} if $imported.nil?
$imported["Tsuki_SkillSelect"] = true
#==============================================================================
# ** Configuration
#==============================================================================
module Tsuki
module Battle_Skill
Command_Name = "Battle Skills"
Handler = :battle_skill
Enabled = true
Access = true
#toggle whether skill points should be used
Use_SkillPoint_System = true
Use_SkillLimit_System = true
# Number of skill sets you can have. Currently only one supported
Num_Skillsets = 5
# Select type names #
# normal does not require assignment to use in battle
Normal_Name = "Normal"
# these require assignment to use in battle
Active_Name = "Active"
Passive_Name = "Passive"
# Number of skillpoints you can have at most
Skillpoint_Limit = 9999
Skillpoint_Growth = "level + 30"
# The color that is used to highlight selected skills
Selected_Color = Color.new(255, 215, 0, 255)
Skillpoint_Color = Color.new(255, 128, 0, 255)
# skill regex
Select_Type = /<select\s*:\s*([^,]*)>/i
Skillpoint_Cost = /<sp\s*:\s*([^,]*)>/i
# actor regex
Max_Active_On = /<(?:MAX_ACTIVE|max active)>/i
Max_Active_Off = /<\/(?:MAX_ACTIVE|max active)>/i
Max_Passive_On = /<(?:MAX_PASSIVE|max passive)>/i
Max_Passive_Off = /<\/(?:MAX_PASSIVE|max passive)>/i
Level_Value = /(\d+):\s*(\d+),*/
Skillpoint_Growth = /<SP:?\s*(.+)>/
end
end
#==============================================================================
# ** Rest of the script
#==============================================================================
#==============================================================================
# ** RPG::Skill
#------------------------------------------------------------------------------
# Add skillpoint cost and selection type to Skill objects
#==============================================================================
module RPG
class Skill < UsableItem
include Tsuki::Battle_Skill
attr_accessor :select_type
attr_accessor :skillpoint_cost
alias :th_skill_select_init_rpg_skill :initialize
def initialize
th_skill_select_init_rpg_skill
load_notetags_skill_select
end
def skillpoint_cost
return @skillpoint_cost unless @skillpoint_cost.nil?
load_notetags_skill_select
return @skillpoint_cost
end
def select_type
return @select_type unless @select_type.nil?
load_notetags_skill_select
return @select_type
end
def load_notetags_skill_select
@skillpoint_cost = 0
@select_type = Normal_Name
self.note.split(/[\r\n]+/).each do |line|
case line
when Select_Type
case $1.upcase
when Active_Name.upcase
@select_type = Active_Name
when Passive_Name.upcase
@select_type = Passive_Name
end
when Skillpoint_Cost
@skillpoint_cost = $1.to_i
end
end
end
end
class Actor < BaseItem
include Tsuki::Battle_Skill
attr_accessor :active_skill_levels
attr_accessor :passive_skill_levels
attr_accessor :skillpoint_growth
alias :th_skill_select_init_rpg_actor :initialize
def initialize
th_skill_select_init_rpg_actor
load_notetags_skill_select
end
def load_notetags_skill_select
@active_skill_levels = {}
@passive_skill_levels = {}
@skillpoint_growth = ""
self.note.split(/[\r\n]+/).each do |line|
case line
when Skillpoint_Growth
@skillpoint_growth = $1
when Max_Active_On
@max_active_on = true
when Max_Active_Off
@max_active_on = false
when Max_Passive_On
@max_passive_on = true
when Max_Active_Off
@max_passive_on = false
when Level_Value
next unless @max_active_on || @max_passive_on
line.scan(Level_Value).each do |match|
level = match[0].to_i
value = match[1].to_i
if @max_active_on
@active_skill_levels[level] = value
elsif @max_passive_on
@passive_skill_levels[level] = value
end
end
end
end
end
end
class Enemy < BaseItem
include Tsuki::Battle_Skill
attr_accessor :active_skill_levels
attr_accessor :passive_skill_levels
attr_accessor :skillpoint_growth
alias :th_skill_select_init_rpg_enemy :initialize
def initialize
th_skill_select_init_rpg_enemy
load_notetags_skill_select
end
def load_notetags_skill_select
@active_skill_levels = {}
@passive_skill_levels = {}
@skillpoint_growth = ""
self.note.split(/[\r\n]+/).each do |line|
case line
when Skillpoint_Growth
@skillpoint_growth = $1
when Max_Active_On
@max_active_on = true
when Max_Active_Off
@max_active_on = false
when Max_Passive_On
@max_passive_on = true
when Max_Active_Off
@max_passive_on = false
when Level_Value
next unless @max_active_on || @max_passive_on
line.scan(Level_Value).each do |match|
level = match[0].to_i
value = match[1].to_i
if @max_active_on
@active_skill_levels[level] = value
elsif @max_passive_on
@passive_skill_levels[level] = value
end
end
end
end
end
end
end
#==============================================================================
# ** DataManager
#------------------------------------------------------------------------------
# Initialize custom notetags
#==============================================================================
module DataManager
class << self
alias tsuki_skill_select_load_database load_database
alias tsuki_skill_select_init init
end
def self.init
tsuki_skill_select_init
load_notetags_skill_select
end
def self.load_database
tsuki_skill_select_load_database
if $BTEST
load_notetags_skill_select
end
end
def self.load_notetags_skill_select
groups = [$data_actors, $data_enemies]
for group in groups
for obj in group
next if obj.nil?
obj.load_notetags_skill_select
end
end
end
end
#==============================================================================
# ** Game_Skillset
#------------------------------------------------------------------------------
# A Skill Set object. This stores a set of skills that the actor
# is currently using
#==============================================================================
class Game_Skillset
attr_reader :id
def initialize(index)
@id = index + 1
@skills = {}
setup
update_cost
end
def setup
@skills[Tsuki::Battle_Skill::Passive_Name] = []
@skills[Tsuki::Battle_Skill::Active_Name] = []
end
def [](type)
@skills[type] ||= []
end
def include?(skill)
@skills[skill.select_type].include?(skill.id)
end
def add_skill(skill)
@skills[skill.select_type] = [] if @skills[skill.select_type].nil?
@skills[skill.select_type] << skill.id
update_cost
end
def remove_skill(skill)
index = @skills[skill.select_type].index(skill.id)
if index
@skills[skill.select_type].delete_at(index)
update_cost
end
end
def update_skills(learned_skills)
@skills[Tsuki::Battle_Skill::Passive_Name] = @skills[Tsuki::Battle_Skill::Passive_Name].select{|skill| learned_skills.include?(skill.id)}
update_cost
end
def passive_skills
@skills[Tsuki::Battle_Skill::Passive_Name]
end
def active_skills
@skills[Tsuki::Battle_Skill::Active_Name]
end
def update_cost
@total_cost = 0
skills.each do |skill|
@total_cost += skill.skillpoint_cost
end
end
def skills
@skills.values.flatten.collect {|id| $data_skills[id]}
end
def cost
@total_cost
end
def size
@skills.size
end
end
#==============================================================================
# ** Game_Skillsets
#------------------------------------------------------------------------------
# This class holds a set of skills that the actor has. It manages skill sets
# such as returning the current set and switching the current set
#==============================================================================
class Game_Skillsets
attr_accessor :current
def initialize
@data = []
[url=home.php?mod=space&uid=94117]@current[/url] = 0
setup_skillsets
end
def num_skillsets
Tsuki::Battle_Skill::Num_Skillsets
end
def setup_skillsets
num_skillsets.times do |i|
@data << Game_Skillset.new(i)
end
end
def next_skillset
@current = [@current + 1, num_skillsets - 1].min
end
def prev_skillset
@current = [0, @current - 1].max
end
def [](index)
@data[index]
end
def current_skillset
@data[@current]
end
end
#==============================================================================
# ** Game_BattlerBase
#------------------------------------------------------------------------------
# Initialize skill parameter effects
#==============================================================================
class Game_BattlerBase
include Tsuki::Battle_Skill
alias tsuki_skill_select_bbase_initialize initialize
def initialize
tsuki_skill_select_bbase_initialize
@skillsets = Game_Skillsets.new
end
end
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#
#==============================================================================
class Game_Actor < Game_Battler
include Tsuki::Battle_Skill
attr_accessor :battle_skills #list of skills for use in battle
attr_accessor :max_active_skills #number of active skills actor can have
attr_accessor :max_passive_skills #number of passive skills actor can have
attr_accessor :max_skillpoints
attr_accessor :current_skillpoints
attr_accessor :current_skillset
alias tsuki_battleSkill_actor_setup setup
def setup(actor_id)
tsuki_battleSkill_actor_setup(actor_id)
@skillsets = Game_Skillsets.new
@max_active_skills = 1
@max_passive_skills = 1
@active_skill_levels = actor.active_skill_levels ? actor.active_skill_levels : {}
@passive_skill_levels = actor.passive_skill_levels ? actor.passive_skill_levels : {}
@sp_formula = actor.skillpoint_growth
@max_skillpoints = calculate_skillpoints
@current_skillpoints = @max_skillpoints
set_max_active
set_max_passive
end
alias tsuki_skill_select_actor_features feature_objects
def feature_objects
current_skillset.passive_skills + tsuki_skill_select_actor_features
end
def skill_conditions_met?(skill)
(skill.select_type == Normal_Name || current_skillset.active_skills.include?(skill.id)) && super
end
def current_skillset
return unless @skillsets
@skillsets.current_skillset
end
def set_max_active
active = 1
@active_skill_levels.each do |level, value|
active = value if [url=home.php?mod=space&uid=22147]@level[/url] >= level
end
@max_active_skills = active
end
def set_max_passive
passive = 1
@passive_skill_levels.each do |level, value|
passive = value if @level >= level
end
@max_passive_skills = passive
end
def gain_passive_slot
@max_passive_skills
end
def gain_active_slot
end
#already maxed out
def skillset_exceeded?(select_type)
case select_type
when Tsuki::Battle_Skill::Active_Name
current_skillset[select_type].size >= @max_active_skills
when Tsuki::Battle_Skill::Passive_Name
current_skillset[select_type].size >= @max_passive_skills
end
end
def enough_skillpoints?(skill)
skill.skillpoint_cost <= @current_skillpoints
end
#check if we can assign the skill
def can_assign?(skill)
return true unless Tsuki::Battle_Skill::Use_SkillLimit_System
return false unless skill
return false if current_skillset.skills.include?(skill)
return false if skillset_exceeded?(skill.select_type)
return false unless enough_skillpoints?(skill)
return true
end
def assign_skill(skill)
current_skillset.add_skill(skill) if can_assign?(skill)
update_skillset
update_skillpoints
refresh
end
def unassign_skill(skill)
current_skillset.remove_skill(skill)
update_skillset
update_skillpoints
refresh
end
def update_skillset
current_skillset.update_skills(@skills | added_skills)
end
def skillpoint_limit
Tsuki::Battle_Skill::Skillpoint_Limit
end
def calculate_skillpoints(level=self.level)
[Kernel.eval(@sp_formula), 0].max rescue 0
end
def gain_skillpoints(val)
@max_skillpoints = [[@max_skillpoints + val, skillpoint_limit].min, 0].max
update_skillpoints
end
def lose_skillpoints(val)
gain_skillpoints(-val)
end
def update_skillpoints
@current_skillpoints = [@max_skillpoints - current_skillset.cost, 0].max
end
def next_skillset
@skillsets.next_skillset
update_skillpoints
end
def prev_skillset
@skillsets.prev_skillset
update_skillpoints
end
def update_skill_slots
set_max_active
set_max_passive
end
#add skillpoints when actor levels up
alias tsuki_skill_select_level_up level_up
def level_up
tsuki_skill_select_level_up
gain_skillpoints(calculate_skillpoints)
update_skill_slots
end
#lose skillpoints when actor levels down
alias tsuki_skill_select_level_down level_down
def level_down
tsuki_skill_select_level_down
lose_skillpoints(calculate_skillpoints(self.level + 1))
update_skill_slots
end
end
#==============================================================================
# ** Update menu scene to add option and add some flags to game system
#==============================================================================
class Game_System
attr_accessor :battleskill_disabled
attr_accessor :battleskill_noshow
alias tsuki_skill_select_system_initialize initialize
def initialize
tsuki_skill_select_system_initialize
@battleskill_disabled = false
@battleskill_noshow = false
end
end
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
# Convenience methods for the interpreter
#==============================================================================
class Game_Interpreter
def enable_skill_select
$game_system.battleskill_disabled = false
end
def disable_skill_select
$game_system.battleskill_disabled = true
end
def show_skill_select
$game_system.battleskill_noshow = false
end
def hide_skill_select
$game_system.battleskill_noshow = true
end
def gain_sp(index, val)
$game_party.all_members[index].gain_skillpoints(val)
end
def lose_sp(index, val)
$game_party.all_members[index].lose_skillpoints(val)
end
end
class Window_MenuCommand < Window_Command
#--------------------------------------------------------------------------
# * Add menu command to List
#--------------------------------------------------------------------------
alias tsuki_skill_select_commands add_main_commands
def add_main_commands
tsuki_skill_select_commands
if !$game_system.battleskill_noshow
add_command(Tsuki::Battle_Skill::Command_Name, Tsuki::Battle_Skill::Handler, !$game_system.battleskill_disabled)
end
end
end
class Scene_Menu < Scene_MenuBase
#--------------------------------------------------------------------------
# * Add menu handler
#--------------------------------------------------------------------------
alias tsuki_skill_select_command_window create_command_window
def create_command_window
tsuki_skill_select_command_window
if !$game_system.battleskill_disabled
@command_window.set_handler(Tsuki::Battle_Skill::Handler, method(:command_personal))
end
end
alias tsuki_skill_select_personal_ok on_personal_ok
def on_personal_ok
case @command_window.current_symbol
when Tsuki::Battle_Skill::Handler
SceneManager.call(Scene_Skill_Select)
end
tsuki_skill_select_personal_ok
end
end
class Window_battleSkillHelp < Window_Base
def initialize(x, y, width, height)
super(x, y, width, height)
end
#--------------------------------------------------------------------------
# * Set Text
#--------------------------------------------------------------------------
def set_text(text)
if text != @text
@text = text
refresh
end
end
#--------------------------------------------------------------------------
# * Clear
#--------------------------------------------------------------------------
def clear
set_text("")
end
#--------------------------------------------------------------------------
# * Set Item
# item : Skills and items etc.
#--------------------------------------------------------------------------
def set_item(item)
set_text(item ? item.description : "")
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_text_ex(4, 0, @text)
end
end
#Displays actor info
class Window_battleSkillStatus < Window_Base
def initialize(x, y, width, height)
super(x, y, width, height)
[url=home.php?mod=space&uid=95897]@actor[/url] = nil
end
def skillpoints_enabled?
Tsuki::Battle_Skill::Use_SkillPoint_System
end
#--------------------------------------------------------------------------
# * Set Actor
#--------------------------------------------------------------------------
def actor=(actor)
return if @actor == actor
@actor = actor
@actor.update_skillset
@actor.update_skillpoints
refresh
self.oy = 0
end
def draw_skillset_number
return unless @actor
set_id = @actor.current_skillset.id
set_name = "Set %d" %set_id
text_width = text_size(set_name).width
change_color(normal_color)
draw_text(130 - text_width, 10, width, line_height, set_name)
end
def draw_skillpoints
return unless @actor
text_width = text_size(@actor.current_skillpoints).width
change_color(Tsuki::Battle_Skill::Skillpoint_Color)
draw_text(130 - text_width, 50, width, line_height, @actor.current_skillpoints)
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
return unless @actor
draw_actor_face(@actor, 0, 0)
draw_skillpoints if skillpoints_enabled?
draw_skillset_number
end
end
#==============================================================================
# ** Update Window_BattleSkill to filter the skills
#==============================================================================
class Window_BattleSkill < Window_SkillList
def include?(item)
item && item.stype_id == @stype_id && (item.select_type == Tsuki::Battle_Skill::Normal_Name || equipped?(item))
end
def equipped?(item)
@actor.current_skillset.skills.include?(item) && item.select_type != Tsuki::Battle_Skill::Passive_Name
end
def make_item_list
@data = @actor ? @actor.skills.select {|id| include?(id) } : []
end
end
class Window_battleSkillCommand < Window_HorzCommand
attr_accessor :window_width
def initialize(x, y)
@window_width = Graphics.width - x
super(x, y)
@actor = nil
update
end
def window_width
@window_width
end
def window_height
50
end
def actor=(actor)
return if @actor == actor
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Get Digit Count
#--------------------------------------------------------------------------
def col_max
return 2
end
#--------------------------------------------------------------------------
# * Get Number of Lines to Show
#--------------------------------------------------------------------------
def visible_line_number
return 4
end
#--------------------------------------------------------------------------
# * Create Command List
#--------------------------------------------------------------------------
def make_command_list
return unless @actor
@actor.added_skill_types.sort.each do |stype_id|
name = $data_system.skill_types[stype_id]
add_command(name, :skill, true, stype_id)
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
@skill_window.stype_id = current_ext if @skill_window
end
#--------------------------------------------------------------------------
# * Set Skill Window
#--------------------------------------------------------------------------
def skill_window=(skill_window)
@skill_window = skill_window
update
end
end
#==============================================================================
# ** Window_battleSkillBattleList
#------------------------------------------------------------------------------
# This class shows the skills that you have selected for battle. It is
# the superclass for any selected skills list
#==============================================================================
class Window_battleSkillSelectedList < Window_SkillList#Window_Selectable
def filler_text
"---"
end
def skill_limits_enabled?
Tsuki::Battle_Skill::Use_SkillLimit_System
end
def draw_filler(rect)
draw_text(rect, filler_text)
end
def add_fillers
(max_items - @data.size).times do |i|
@data << nil
end
end
def col_max
1
end
def window_width
120
end
def include?(skill)
true
end
def make_item_list
add_fillers if skill_limits_enabled?
end
def draw_item(index)
id = @data[index]
rect = item_rect(index)
if id
item = $data_skills[id]
draw_icon(item.icon_index, rect.x, rect.y)
draw_skill_name(rect.x+24, rect.y, rect.width - 16, item.name)
else
draw_filler(rect)
end
end
def draw_skill_name(x, y, width, name)
draw_text(x, y, width, line_height, name)
end
def remove_item(item)
return unless item
@actor.unassign_skill(item)
refresh
end
def refresh
make_item_list
create_contents
draw_all_items
end
def select_last
if @last_index && @data.size > 0 && @data[@last_index]
select(@last_index)
else
select(0)
end
end
#--------------------------------------------------------------------------
# * Add additional handles to be more useful
#--------------------------------------------------------------------------
def process_handling
return unless open? && active
return process_dir4 if Input.trigger?(:LEFT) && handle?(:dir4)
return process_dir6 if Input.trigger?(:RIGHT) && handle?(:dir6)
return super
end
def process_dir4
Sound.play_cursor
Input.update
deactivate
call_handler(:dir4)
end
def process_dir6
Sound.play_cursor
Input.update
deactivate
call_handler(:dir6)
end
end
class Window_battleSkillPassiveList < Window_battleSkillSelectedList
#--------------------------------------------------------------------------
# * Max number of passive skills the actor can choose
#--------------------------------------------------------------------------
def max_items
@actor ? @actor.max_passive_skills : 0
end
def make_item_list
@data = @actor ? @actor.current_skillset.passive_skills.clone : nil
super
end
end
class Window_battleSkillActiveList < Window_battleSkillSelectedList
#--------------------------------------------------------------------------
# * Max number of items you can select
#--------------------------------------------------------------------------
def max_items
@actor ? @actor.max_active_skills : 0
end
def make_item_list
@data = @actor ? @actor.current_skillset.active_skills.clone : nil
super
end
end
#==============================================================================
# ** Window_SkillList
#------------------------------------------------------------------------------
# This window is for displaying a list of available skills on the skill window.
#==============================================================================
class Window_battleSkillList < Window_SkillList
#--------------------------------------------------------------------------
# * Get Skill Type ID
#--------------------------------------------------------------------------
def stype_id
return @stype_id
end
#--------------------------------------------------------------------------
# * Get Digit Count
#--------------------------------------------------------------------------
def col_max
return 1
end
#--------------------------------------------------------------------------
# * Include in Skill List?
#--------------------------------------------------------------------------
def include?(item)
item && item.stype_id == @stype_id && item.select_type != normal_name
end
def normal_name
Tsuki::Battle_Skill::Normal_Name
end
def skillpoint_cost_color
Tsuki::Battle_Skill::Skillpoint_Color
end
def current_item_enabled?
true
end
#--------------------------------------------------------------------------
# * In actor's current skill?
#--------------------------------------------------------------------------
def selected?(item)
@actor.current_skillset.include?(item)
end
def selected_color
Tsuki::Battle_Skill::Selected_Color
end
#--------------------------------------------------------------------------
# * Create Skill List
#--------------------------------------------------------------------------
def make_item_list
@data = @actor ? @actor.skills.select {|skill| include?(skill) } : []
end
def skillpoints_enabled?
Tsuki::Battle_Skill::Use_SkillPoint_System
end
#--------------------------------------------------------------------------
# * Draw Item
#--------------------------------------------------------------------------
def draw_item(index)
skill = @data[index]
if skill
rect = item_rect(index)
rect.width -= 4
if selected?(skill)
can_assign = true
change_color(selected_color)
else
can_assign = @actor.can_assign?(skill)
change_color(normal_color, can_assign)
end
draw_icon(skill.icon_index, rect.x, rect.y)
draw_text(rect.x + 32, rect.y, width, line_height, skill.name)
if skillpoints_enabled?
draw_skillpoint_cost(rect, skill, can_assign)
else
draw_skill_cost(rect, skill)
end
end
end
#--------------------------------------------------------------------------
# * Draw Skillpoint Use Cost
#--------------------------------------------------------------------------
def draw_skillpoint_cost(rect, skill, can_assign)
change_color(skillpoint_cost_color, can_assign)
draw_text(rect, skill.skillpoint_cost, 2)
end
#--------------------------------------------------------------------------
# * Restore Previous Selection Position
#--------------------------------------------------------------------------
def select_last
if @last_index && @data.size > 0 && @data[@last_index]
select(@last_index)
else
select(0)
end
end
def can_add?(item)
@actor.can_assign?(item)
end
#--------------------------------------------------------------------------
# * Rather than give an error when adding a duplicate item, we remove
# if from the list instead
#--------------------------------------------------------------------------
def add_item(item)
if can_add?(item)
@actor.assign_skill(item)
elsif selected?(item)
remove_item(item)
return
else
Sound.play_buzzer
end
refresh
end
def remove_item(item)
return unless item
@actor.unassign_skill(item)
refresh
end
def process_handling
return unless open? && active
return process_dir4 if Input.trigger?(:LEFT) && handle?(:dir4)
return process_dir6 if Input.trigger?(:RIGHT) && handle?(:dir6)
return super
end
def process_dir4
Sound.play_cursor
Input.update
deactivate
call_handler(:dir4)
end
def process_dir6
Sound.play_cursor
Input.update
deactivate
call_handler(:dir6)
end
end
#==============================================================================
# ** Battle Skill scene
#==============================================================================
class Scene_Skill_Select < Scene_MenuBase
def start
super
create_all_windows
@category_window.activate
end
def create_all_windows
create_actor_window
create_help_window
create_category_window
create_active_skills_window
create_passive_skills_window
create_skills_window
end
#draw actor in the top-left corner
def create_actor_window
@actor_window = Window_battleSkillStatus.new(0,0, 160, 100)
@actor_window.actor = @actor
end
#draw help window to the right of actor window
def create_help_window
wx = @actor_window.width
@help_window = Window_battleSkillHelp.new(wx, 0, Graphics.width - wx, 100)
@help_window.viewport = @viewport
end
#draw category window under the help window
def create_category_window
wx = @help_window.x
wy = @help_window.height
@category_window = Window_battleSkillCommand.new(wx, wy)
@category_window.viewport = @viewport
@category_window.help_window = @help_window
@category_window.actor = @actor
@category_window.set_handler(:skill, method(:command_skill))
@category_window.set_handler(:cancel, method(:return_scene))
@category_window.set_handler(:pagedown, method(:next_actor))
@category_window.set_handler(:pageup, method(:prev_actor))
end
#draw passive skills window under actor window
def create_active_skills_window
wx = @actor_window.x
wy = @actor_window.height
width = @actor_window.width
@askill_window = Window_battleSkillActiveList.new(wx, wy, width, 200)
@askill_window.viewport = @viewport
@askill_window.help_window = @help_window
@askill_window.actor = @actor
@askill_window.set_handler(:ok, method(:on_askill_ok))
@askill_window.set_handler(:cancel, method(:on_askill_cancel))
@askill_window.set_handler(:pagedown, method(:activate_pskill_window))
@askill_window.set_handler(:pageup, method(:activate_pskill_window))
@askill_window.set_handler(:dir4, method(:activate_skills_window))
@askill_window.set_handler(:dir6, method(:activate_skills_window))
end
#draw active skills window under passive skills
def create_passive_skills_window
wx = @askill_window.x
wy = @askill_window.y + @askill_window.height
width = @askill_window.width
height = Graphics.height - wy
@pskill_window = Window_battleSkillPassiveList.new(wx, wy, width, height)
@pskill_window.viewport = @viewport
@pskill_window.help_window = @help_window
@pskill_window.actor = @actor
@pskill_window.set_handler(:ok, method(:on_pskill_ok))
@pskill_window.set_handler(:cancel, method(:on_pskill_cancel))
@pskill_window.set_handler(:pagedown, method(:activate_askill_window))
@pskill_window.set_handler(:pageup, method(:activate_askill_window))
@pskill_window.set_handler(:dir4, method(:activate_skills_window))
@pskill_window.set_handler(:dir6, method(:activate_skills_window))
end
#--------------------------------------------------------------------------
# * Displays all the items available to choose from
#--------------------------------------------------------------------------
def create_skills_window
wx = @category_window.x
wy = @category_window.y + @category_window.height
width = @category_window.width
height = Graphics.height - wy
@skills_window = Window_battleSkillList.new(wx, wy, width, height)
@skills_window.help_window = @help_window
@skills_window.actor = @actor
@skills_window.set_handler(:ok, method(:on_skills_ok))
@skills_window.set_handler(:cancel, method(:on_skills_cancel))
@skills_window.set_handler(:pageup, method(:next_skillset))
@skills_window.set_handler(:pagedown, method(:prev_skillset))
@skills_window.set_handler(:dir4, method(:activate_askill_window))
@skills_window.set_handler(:dir6, method(:activate_askill_window))
@category_window.skill_window = @skills_window
update_selected_skills
end
def skill
@skills_window.item
end
def next_skillset
@actor.next_skillset
update_selected_skills
activate_skills_window
end
def prev_skillset
@actor.prev_skillset
update_selected_skills
activate_skills_window
end
def activate_askill_window
@skills_window.unselect
@pskill_window.unselect
@askill_window.activate
@askill_window.select(0)
#~ @askill_window.select_last
end
def activate_pskill_window
@skills_window.unselect
@askill_window.unselect
@pskill_window.activate
@pskill_window.select(0)
#~ @pskill_window.select_last
end
def activate_skills_window
@pskill_window.unselect
@askill_window.unselect
#@skills_window.select_last
@skills_window.activate
end
def activate_category_window
@askill_window.unselect
@pskill_window.unselect
@skills_window.unselect
@category_window.activate
end
def command_skill
@skills_window.activate
@skills_window.select_last
end
def on_skills_ok
determine_skill
update_selected_skills
activate_skills_window
end
def on_skills_cancel
activate_category_window
end
def on_askill_ok
@askill_window.remove_item(@askill_window.item)
update_selected_skills
activate_askill_window
end
def on_askill_cancel
activate_category_window
end
def on_pskill_ok
@pskill_window.remove_item(@pskill_window.item)
update_selected_skills
activate_pskill_window
end
def on_pskill_cancel
activate_category_window
end
def determine_skill
@skills_window.add_item(skill)
update_selected_skills
activate_skills_window
end
def on_actor_change
@actor_window.actor = @actor
@category_window.actor = @actor
@skills_window.actor = @actor
@askill_window.actor = @actor
@pskill_window.actor = @actor
@category_window.activate
end
def update_selected_skills
@askill_window.refresh
@pskill_window.refresh
@actor_window.refresh
@skills_window.refresh
end
end
if $imported["Tsuki_MonsterHunter"]
module Monster_Hunter
class << self
alias skill_select_setup_extra setup_extra
end
def self.setup_extra(actor, enemy)
skill_select_setup_extra(actor, enemy)
actor.skillpoint_growth = enemy.skillpoint_growth
actor.passive_skill_levels = enemy.passive_skill_levels
actor.active_skill_levels = enemy.active_skill_levels
end
end
end