#==============================================================================
# ** Equipment Skills
#------------------------------------------------------------------------------
# © Yeyinde, 2008
# 03/01/08
#------------------------------------------------------------------------------
# INSTRUCTIONS:
# 1) Insert this script into a new section.
# 2) Edit the constants in the EquipmentSkills module
# 3) ???
# 4) Profit
#==============================================================================
#==============================================================================
# ** EquipmentSkills Configuration
#==============================================================================
module EquipmentSkills
# AP - The number of times a skill must be used in order to be mastered
# If set to 0, the skill cannot be mastered. (Default value = 0)
AP = { 1 => 10, 2 => 20, 3 => 30, 4 => 12, 5 => 20, 6 => 15,
7 => 10, 8 => 20, 9 => 30, 10 => 10, 11 => 20, 12 => 30,
25 => 30}
AP.default = 0
# WEAPON - Contains weapon ID followed by a hash of skills with their
# level requirement
# SYNTAX: weapon_id => {skill_id => level, skill_id => level}
WEAPON = {
1 => {4 => 1},
2 => {1 => 1, 2 => 3, 3 => 5},
3 => {5 => 3},
4 => {6 => 10},
}
WEAPON.default = {}
# ARMOR - Contains armor ID followed by a hash of skills with their
# level requirement
# SYNTAX: armor_id => {skill_id => level, skill_id => level}
ARMOR = {
1 => {7 => 1, 8 => 3, 9 => 5},
2 => {10 => 1, 11 => 3, 12 => 5},
10 => {25 => 30}
}
ARMOR.default = {}
# PERCENT_VIEW - Show the mastery completion as a percentage in battle only
PERCENT_VIEW = true
end
# Set this to what text will be shown when a skill is mastered
Vocab::MasterSkill = "%s was mastered!"
#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
# This class deals with battlers. It's used as a superclass of the Game_Actor
# and Game_Enemy classes.
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# * Object aliasing
#--------------------------------------------------------------------------
alias equipment_skill skill_effect
#--------------------------------------------------------------------------
# * Apply Skill Effects
# user : Skill user
# skill : skill
#--------------------------------------------------------------------------
def skill_effect(user, skill)
return unless equipment_skill(user, skill) && user.is_a?(Game_Actor)
user.add_ap(skill.id)
end
end
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles actors. It's used within the Game_Actors class
# ($game_actors) and referenced by the Game_Party class ($game_party).
#==============================================================================
class Game_Actor
#--------------------------------------------------------------------------
# * Object aliasing
#--------------------------------------------------------------------------
alias equipment_init initialize
alias learned_skills skills
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :equipment_skills
attr_writer :ap_gained
#--------------------------------------------------------------------------
# * Object Initialization
# actor_id : actor ID
#--------------------------------------------------------------------------
def initialize(actor_id)
equipment_init(actor_id)
@equipment_skills = {}
@equipment_skills.default = 0
@ap_gained = false
end
#--------------------------------------------------------------------------
# * Get Skill Object Array
#--------------------------------------------------------------------------
def skills
array = learned_skills
EquipmentSkills::WEAPON[@weapon_id].each do |skill_id, req_level|
array << $data_skills[skill_id] if @level >= req_level
end
if two_swords_style
EquipmentSkills::WEAPON[@armor1_id].each do |skill_id, req_level|
array << $data_skills[skill_id] if @level >= req_level
end
else
EquipmentSkills::ARMOR[@armor1_id].each do |skill_id, req_level|
array << $data_skills[skill_id] if @level >= req_level
end
end
EquipmentSkills::ARMOR[@armor2_id].each do |skill_id, req_level|
array << $data_skills[skill_id] if @level >= req_level
end
EquipmentSkills::ARMOR[@armor3_id].each do |skill_id, req_level|
array << $data_skills[skill_id] if @level >= req_level
end
EquipmentSkills::ARMOR[@armor4_id].each do |skill_id, req_level|
array << $data_skills[skill_id] if @level >= req_level
end
return array.uniq
end
#--------------------------------------------------------------------------
# * Determine Usable Skills
# skill : skill
#--------------------------------------------------------------------------
def skill_can_use?(skill)
return false unless skills.include?(skill)
return super
end
#--------------------------------------------------------------------------
# * Increase Skill AP
# skill_id : skill id
#--------------------------------------------------------------------------
def add_ap(skill_id)
return if EquipmentSkills::AP[skill_id] == 0 || @ap_gained
@ap_gained = true
equipment_skills[skill_id] = [equipment_skills[skill_id] + 1,
EquipmentSkills::AP[skill_id]].min
if equipment_skills[skill_id] >= EquipmentSkills::AP[skill_id]
learn_skill(skill_id)
end
end
end
#==============================================================================
# ** Window_Skill
#------------------------------------------------------------------------------
# This window displays a list of usable skills on the skill screen, etc.
#==============================================================================
class Window_Skill
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
skill = @data[index]
if skill != nil
rect.width -= 4
enabled = @actor.skill_can_use?(skill)
draw_item_name(skill, rect.x, rect.y, enabled)
mp = @actor.calc_mp_cost(skill)
cap = @actor.equipment_skills[skill.id]
map = EquipmentSkills::AP[skill.id]
string = ''
if @actor.learned_skills.include?(skill) || map == 0
string = mp
else
if EquipmentSkills::PERCENT_VIEW && $game_temp.in_battle
string = sprintf("%d (%d%%)", mp, cap * 100 / map)
else
string = sprintf("%d (%d/%d)", mp, cap, map)
end
end
self.contents.draw_text(rect, string, 2)
end
end
end
class Scene_Skill
#--------------------------------------------------------------------------
# * Object aliasing
#--------------------------------------------------------------------------
alias equipment_target determine_target
alias equipment_nontarget use_skill_nontarget
#--------------------------------------------------------------------------
# * Confirm Target
# If there is no effect (such as using a potion on an incapacitated
# character), play a buzzer SE.
#--------------------------------------------------------------------------
def determine_target
equipment_target
@actor.ap_gained = false
end
#--------------------------------------------------------------------------
# * Use Skill (apply effects to non-ally targets)
#--------------------------------------------------------------------------
def use_skill_nontarget
equipment_nontarget
if @skill.common_event_id > 0
@actor.add_ap(@skill.id)
end
end
end
class Scene_Battle
#--------------------------------------------------------------------------
# * Object aliasing
#--------------------------------------------------------------------------
alias equip_skill_execute execute_action_skill
#--------------------------------------------------------------------------
# * Execute Battle Action: Skill
#--------------------------------------------------------------------------
def execute_action_skill
old_skills = []
if @active_battler.is_a?(Game_Actor)
old_skills = @active_battler.learned_skills
end
equip_skill_execute
if @active_battler.is_a?(Game_Actor)
@active_battler.ap_gained = false
if old_skills != @active_battler.learned_skills
(@active_battler.learned_skills - old_skills).each do |new_skill|
text = sprintf(Vocab::MasterSkill, new_skill.name)
$game_message.texts.push(text)
end
end
end
end
end