#==============================================================================
# ** Skill_Equip
#==============================================================================
module Skill_Equip
#--------------------------------------------------------------------------
# * Equip Buttons
#
# ~ Use nil for no button
# ~ Keyboard_Equip_Button requires Near Fantastica's Keyboard Module
#--------------------------------------------------------------------------
Input_Equip_Button = Input::CTRL
Keyboard_Equip_Button = nil
#--------------------------------------------------------------------------
# * Equip Points
#
# ~ Start_Equip_Points = { actor_id => points, ... }
# ~ Equip_Points_Level = { actor_id => { level => point, ... }, ... }
#
# Note : Use 0 as actor_id for default for all non-defined actors
#--------------------------------------------------------------------------
Start_Equip_Points = {
0 => 5
}
Equip_Points_Level = {}
#--------------------------------------------------------------------------
# * Skill Equip Cost
#
# ~ Skill_Equip_Cost = { skill_id => points, ... }
# ~ No_Equip_Cost = [ skill_id, ... ] Require No Skill Points
#
# Note : Use 0 as skill_id for default for all non-defined skills
#--------------------------------------------------------------------------
Skill_Equip_Cost = {
# Set Default For All At 1
0 => 1
}
No_Equip_Cost = []
#--------------------------------------------------------------------------
# * Equip Slots
#
# ~ Start_Equip_Slots = { actor_id => slots, ... }
# ~ Equip_Slots_Level = { actor_id => { level => slots, ... }, ... }
#
# Note : Use 0 as actor_id for default for all non-defined actors
#--------------------------------------------------------------------------
Start_Equip_Slots = {
0 => 5
}
Equip_Slots_Level = {}
#--------------------------------------------------------------------------
# * Skill Equip Slot Cost
#
# ~ Skill_Equip_Slot_Cost = { skill_id => points, ... }
#
# Note : Use 0 as skill_id for default for all non-defined skills
#--------------------------------------------------------------------------
Skill_Equip_Slot_Cost = {
# Set Default For All At 1
0 => 1
}
#--------------------------------------------------------------------------
# * Collect Actor Starting Equip Points
#--------------------------------------------------------------------------
def self.start_equip_points(actor)
# Starting Counter
n = 0
# Starting Actor Equip Points
if Start_Equip_Points.has_key?(actor.id)
n += Start_Equip_Points[actor.id]
elsif Start_Equip_Points.has_key?(0)
n += Start_Equip_Points[0]
end
# Level Points
if Equip_Points_Level.has_key?(actor.id)
Equip_Points_Level[actor.id].each do |level, points|
if actor.level >= level
n += points
end
end
elsif Equip_Points_Level.has_key?(0)
Equip_Points_Level[0].each do |level, points|
if actor.level >= level
n += points
end
end
end
# Return Value
return n
end
#--------------------------------------------------------------------------
# * Collect Actor Starting Equip Slots
#--------------------------------------------------------------------------
def self.start_equip_slots(actor)
# Starting Counter
n = 0
# Starting Actor Equip Points
if Start_Equip_Slots.has_key?(actor.id)
n += Start_Equip_Slots[actor.id]
elsif Start_Equip_Slots.has_key?(0)
n += Start_Equip_Slots[0]
end
# Level Slots
if Equip_Slots_Level.has_key?(actor.id)
Equip_Slots_Level[actor.id].each do |level, slots|
if actor.level >= level
n += slots
end
end
elsif Equip_Slots_Level.has_key?(0)
Equip_Slots_Level[0].each do |level, slots|
if actor.level >= level
n += slots
end
end
end
# Return Value
return n
end
#--------------------------------------------------------------------------
# * Skill Cost
#--------------------------------------------------------------------------
def self.skill_cost(skill_id)
# Return 0 If No Equip Cost
return 0 if No_Equip_Cost.include?(skill_id)
# Return Skill Defined Cost
if Skill_Equip_Cost.has_key?(skill_id)
return Skill_Equip_Cost[skill_id]
# Return Default Cost
elsif Skill_Equip_Cost.has_key?(0)
return Skill_Equip_Cost[0]
end
# Return 0
return 0
end
#--------------------------------------------------------------------------
# * Skill Slot Cost
#--------------------------------------------------------------------------
def self.skill_slot_cost(skill_id)
# Return Skill Defined Cost
if Skill_Equip_Slot_Cost.has_key?(skill_id)
return Skill_Equip_Slot_Cost[skill_id]
# Return Default Cost
elsif Skill_Equip_Slot_Cost.has_key?(0)
return Skill_Equip_Slot_Cost[0]
end
# Return 0
return 0
end
end
#==============================================================================
# ** Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :skill_equip_points
attr_accessor :skill_equip_slots
attr_accessor :equipped_skills
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias seph_skillequip_gmactr_setup setup
alias seph_skillequip_gmactr_scu? skill_can_use?
#--------------------------------------------------------------------------
# * Setup
#--------------------------------------------------------------------------
def setup(actor_id)
# Original Setup
seph_skillequip_gmactr_setup(actor_id)
# Sets Up Skill Equip Points
@skill_equip_points = Skill_Equip.start_equip_points(self)
# Sets Up Skill Equip Slots
@skill_equip_slots = Skill_Equip.start_equip_slots(self)
# Sets Up Equipped Skills
@equipped_skills = []
end
#--------------------------------------------------------------------------
# * Skill Equipped Test
#--------------------------------------------------------------------------
def skill_equipped?(skill_id)
return Skill_Equip::No_Equip_Cost.include?(skill_id) ||
@equipped_skills.include?(skill_id)
end
#--------------------------------------------------------------------------
# * Can Equip Skill Test
#--------------------------------------------------------------------------
def can_equip_skill?(skill_id)
return skill_equip_points_left? >= Skill_Equip.skill_cost(skill_id) &&
skill_equip_slots_left? >= Skill_Equip.skill_slot_cost(skill_id)
end
#--------------------------------------------------------------------------
# * Skill Points Used?
#--------------------------------------------------------------------------
def skill_equip_points_used?
n = 0
@equipped_skills.each {|skill_id| n += Skill_Equip.skill_cost(skill_id) }
return n
end
#--------------------------------------------------------------------------
# * Skill Points Left?
#--------------------------------------------------------------------------
def skill_equip_points_left?
return @skill_equip_points - self.skill_equip_points_used?
end
#--------------------------------------------------------------------------
# * Skill Slots Used?
#--------------------------------------------------------------------------
def skill_equip_slots_used?
n = 0
@equipped_skills.each do |skill_id|
n += Skill_Equip.skill_slotcost(skill_id)
end
return n
end
#--------------------------------------------------------------------------
# * Skill Slots Left?
#--------------------------------------------------------------------------
def skill_equip_slots_left?
return @skill_equip_slots - self.skill_equip_slots_used?
end
#--------------------------------------------------------------------------
# * Skill Can Use Test
#--------------------------------------------------------------------------
def skill_can_use?(skill_id)
# If Skill Equipped
if skill_equipped?(skill_id)
# Return Original Test
return seph_skillequip_gmactr_scu?(skill_id)
end
# Return False
return false
end
#--------------------------------------------------------------------------
# * Equip Skill
#--------------------------------------------------------------------------
def equip_skill(skill_id)
# Return If Cannot Equip Skill
return unless can_equip_skill?(skill_id)
# Equip Skill
@equipped_skills << skill_id
end
#--------------------------------------------------------------------------
# * Unequip Skill
#--------------------------------------------------------------------------
def unequip_skill(skill_id)
@equipped_skills.delete(skill_id)
end
end
#==============================================================================
# ** Window_SkillEquipPoints
#==============================================================================
class Window_SkillEquipPoints < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(actor)
super(320, 400, 320, 80)
self.contents = Bitmap.new(width - 32, height - 32)
self.z = 105
@actor = actor
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh(skill_id)
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(0, 0, 288, 24, 'Skill Equip Slots :')
self.contents.draw_text(0, 24, 288, 24, 'Skill Equip Points :')
self.contents.font.color = normal_color
u = @actor.skill_equip_slots_used?
m = @actor.skill_equip_slots
s = Skill_Equip.skill_slot_cost(skill_id)
p1 = "#{u} / #{m} -> #{u + s} / #{m}"
u = @actor.skill_equip_points_used?
m = @actor.skill_equip_points
s = Skill_Equip.skill_cost(skill_id)
p2 = "#{u} / #{m} -> #{u + s} / #{m}"
self.contents.draw_text(0, 0, 288, 24, p1, 2)
self.contents.draw_text(0, 24, 288, 24, p2, 2)
end
end
#==============================================================================
# ** Window_Skill
#==============================================================================
class Window_Skill < Window_Selectable
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
alias seph_skillequip_wndskl_di draw_item
#--------------------------------------------------------------------------
# * Draw Item
#--------------------------------------------------------------------------
def draw_item(index)
# Changes Font Boldness If Skill Equipped
self.contents.font.bold = @actor.skill_equipped?(@data[index].id)
# Original Draw Item
seph_skillequip_wndskl_di(index)
end
end
#==============================================================================
# ** Scene_Skill
#==============================================================================
class Scene_Skill
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
alias seph_skillequip_scnskl_main main
alias seph_skillequip_scnskl_update update
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Creates Skill Equip Points Window
a = $game_party.actors[@actor_index]
@sep_window = Window_SkillEquipPoints.new(a)
# Original Main Processing
seph_skillequip_scnskl_main
# Dispose Skill Equip Points Window
@sep_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Skill Equip Update
skill_equip_update
# Original Update
seph_skillequip_scnskl_update
end
#--------------------------------------------------------------------------
# * Frame Update : Skill Equip
#--------------------------------------------------------------------------
def skill_equip_update
# If Last Index Changed
if @last_index != @skill_window.index
@sep_window.refresh(@skill_window.skill.id)
@last_index = @skill_window.index
end
# If Non-nil Input Button
unless (button = Skill_Equip::Input_Equip_Button).nil?
# If Button is Pressed
if Input.trigger?(button)
# Equip Skill
equip_skill
end
end
# If Keyboard Enabled
if SDK.state('Keyboard Input')
# Update Keyboard Module
Keyboard.update
# If Non-nil Keyboard Button
unless (button = Skill_Equip::Keyboard_Equip_Button).nil?
# If Button is Pressed
if Keyboard.trigger?(button)
# Equip Skill
equip_skill
end
end
end
end
#--------------------------------------------------------------------------
# * Equip Skill
#--------------------------------------------------------------------------
def equip_skill
# Gets Skill Data
skill = @skill_window.skill
# If Free Skill
if Skill_Equip::No_Equip_Cost.include?(skill.id)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Gets Equipped State
equipped = @actor.skill_equipped?(skill.id)
# If Equipped
if equipped
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Unequip skill
@actor.unequip_skill(skill.id)
# Redraw Skill Item
@skill_window.draw_item(@skill_window.index)
# Refresh Skill Equip Points Window
@sep_window.refresh(@skill_window.skill.id)
return
end
# If Cannot Equip
unless @actor.can_equip_skill?(skill.id)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
# Set Help Text
@help_window.set_text('Not Enough Skill Equip Points')
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Equip skill
@actor.equip_skill(skill.id)
# Redraw Skill Item
@skill_window.draw_item(@skill_window.index)
# Refresh Skill Equip Points Window
@sep_window.refresh(@skill_window.skill.id)
end
end