Skip to content

Instantly share code, notes, and snippets.

@AlyxRen
Created June 10, 2014 06:07
Show Gist options
  • Save AlyxRen/269e2413eb5b2f75c0d4 to your computer and use it in GitHub Desktop.
Save AlyxRen/269e2413eb5b2f75c0d4 to your computer and use it in GitHub Desktop.
Yanfly Scripts
#==============================================================================
#
# ▼ Yanfly Engine Ace - Class Specifics v1.00
# -- Last Updated: 2011.12.23
# -- Level: Normal
# -- Requires: YEA - Class System v1.03+
#
#==============================================================================
$imported = {} if $imported.nil?
$imported["YEA-ClassSpecifics"] = true
#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2011.12.23 - Started Script and Finished.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script allows for certain classes to be primary-only or sublcass-only.
# In addition to that, subclasses can require certain classes to be primary
# classes in order to be applied.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Class Notetags - These notetags go in the class notebox in the database.
# -----------------------------------------------------------------------------
# <primary only>
# Makes this class equippable only if it's the primary class.
#
# <subclass only>
# Makes this class equippable only if it's the subclass class.
#
# <subclass to: x>
# <subclass to: x, x>
# This makes the class subclass only and only equippable if the primary class
# is one of the listed x classes.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
# This script requires Yanfly Engine Ace - Class System v1.03+.
#
#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================
if $imported["YEA-ClassSystem"]
module YEA
module REGEXP
module CLASS
PRIMARY_ONLY = /<(?:PRIMARY_ONLY|primary only)>/i
SUBCLASS_ONLY = /<(?:SUBCLASS_ONLY|subclass only)>/i
SUBCLASS_TO = /<(?:SUBCLASS_TO|subclass to):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
end # CLASS
end # REGEXP
end # YEA
#==============================================================================
# ■ DataManager
#==============================================================================
module DataManager
#--------------------------------------------------------------------------
# alias method: load_database
#--------------------------------------------------------------------------
class <<self; alias load_database_csp load_database; end
def self.load_database
load_database_csp
load_notetags_csp
end
#--------------------------------------------------------------------------
# new method: load_notetags_csp
#--------------------------------------------------------------------------
def self.load_notetags_csp
for obj in $data_classes
next if obj.nil?
obj.load_notetags_csp
end
end
end # DataManager
#==============================================================================
# ■ RPG::Class
#==============================================================================
class RPG::Class < RPG::BaseItem
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :primary_only
attr_accessor :subclass_only
attr_accessor :subclass_to
#--------------------------------------------------------------------------
# common cache: load_notetags_csp
#--------------------------------------------------------------------------
def load_notetags_csp
@primary_only = false
@subclass_only = false
@subclass_to = []
#---
self.note.split(/[\r\n]+/).each { |line|
case line
#---
when YEA::REGEXP::CLASS::PRIMARY_ONLY
@primary_only = true
@subclass_only = false
@subclass_to = []
when YEA::REGEXP::CLASS::SUBCLASS_ONLY
@primary_only = false
@subclass_only = true
when YEA::REGEXP::CLASS::SUBCLASS_TO
@primary_only = false
@subclass_only = true
$1.scan(/\d+/).each { |num|
@subclass_to.push(num.to_i) if num.to_i > 0 }
end
} # self.note.split
#---
end
end # RPG::Class
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# alias method: change_class
#--------------------------------------------------------------------------
alias game_actor_change_class_csp change_class
def change_class(class_id, keep_exp = false)
return if $data_classes[class_id].subclass_only
game_actor_change_class_csp(class_id, keep_exp)
correct_subclass
end
#--------------------------------------------------------------------------
# alias method: change_subclass
#--------------------------------------------------------------------------
alias game_actor_change_subclass_csp change_subclass
def change_subclass(class_id)
return unless subclass_requirements_met?(class_id)
game_actor_change_subclass_csp(class_id)
end
#--------------------------------------------------------------------------
# new method: subclass_requirements_met?
#--------------------------------------------------------------------------
def subclass_requirements_met?(class_id)
subclass = $data_classes[class_id]
return false if subclass.primary_only
return subclass_to?(class_id) if subclass.subclass_to != []
return true
end
#--------------------------------------------------------------------------
# new method: subclass_to?
#--------------------------------------------------------------------------
def subclass_to?(class_id)
return true if class_id == 0
subclass = $data_classes[class_id]
return false if subclass.nil?
for class_id in subclass.subclass_to
return true if class_id == self.class.id
end
return false
end
#--------------------------------------------------------------------------
# new method: correct_subclass
#--------------------------------------------------------------------------
def correct_subclass
return if @subclass_id == 0
subclass = $data_classes[@subclass_id]
return if subclass.nil?
return if subclass.subclass_to == []
@subclass_id = 0 if !subclass_to?(@subclass_id)
end
end # Game_Actor
#==============================================================================
# ■ Window_ClassList
#==============================================================================
class Window_ClassList < Window_Selectable
#--------------------------------------------------------------------------
# alias method: enable?
#--------------------------------------------------------------------------
alias window_classlist_enable_csp enable?
def enable?(item)
case @command_window.current_symbol
when :primary
return false if item.subclass_only
when :subclass
return false if item.primary_only
return @actor.subclass_to?(item.id) if item.subclass_to != []
end
return window_classlist_enable_csp(item)
end
end # Window_ClassList
end # $imported["YEA-ClassSystem"]
#==============================================================================
#
# ▼ End of File
#
#==============================================================================
#==============================================================================
#
# ▼ Yanfly Engine Ace - Class System v1.09
# -- Last Updated: 2012.01.29
# -- Level: Normal, Hard
# -- Requires: n/a
#
#==============================================================================
$imported = {} if $imported.nil?
$imported["YEA-ClassSystem"] = true
#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.01.29 - Visual Bug: Disabled classes now have faded icons.
# 2012.01.08 - Compatibility Update: Learn Skill Engine
# 2012.01.05 - Bug Fixed: Equipment no longer gets duplicated.
# 2012.01.04 - Update: Autobattle will no longer use skills not available to
# that class for specific actors.
# 2012.01.02 - Efficiency Update.
# 2011.12.26 - Added custom command functionality.
# 2011.12.23 - Compatibility Update: Class Specifics.
# 2011.12.22 - Compatibility Update: Ace Menu Engine.
# 2011.12.20 - Compatibility Update: Class Unlock Level.
# 2011.12.19 - Started Script and Finished.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script adds the ability for your player to freely change the classes of
# actors outside of battle from a menu. When changing classes, this script
# gives the option for the developer to choose whether or not classes have
# their own levels (causing the actor's level to reset back to the class's
# level) or to maintain the current level. In addition to providing the ability
# to change classes, equipping a subclass is also doable, and the mechanics of
# having a subclass can also be defined within this script.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Actor Notetags - These notetags go in the actors notebox in the database.
# -----------------------------------------------------------------------------
# <unlocked classes: x>
# <unlocked classes: x, x>
# This will set the default classes as unlocked for the actor. This does not
# override the default classes unlocked in the module, but instead, adds on
# to the number of unlocked classes.
#
# -----------------------------------------------------------------------------
# Class Notetags - These notetags go in the class notebox in the database.
# -----------------------------------------------------------------------------
# <icon: x>
# Sets the icon representing the class to x.
#
# <help description>
# string
# string
# </help description>
# Sets the text used for the help window in the class scene. Multiple lines in
# the notebox will be strung together. Use | for a line break.
#
# -----------------------------------------------------------------------------
# Script Calls - These commands are used with script calls.
# -----------------------------------------------------------------------------
# $game_actors[x].unlock_class(y)
# This allows actor x to unlock class y, making it available for switching in
# and out in the Class scene.
#
# $game_actors[x].remove_class(y)
# This causes actor x to remove class y from being able to switch to and from.
# If the actor is currently class y, the class will not be removed. If the
# actor's current subclass is y, the subclass will be unequipped.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
#==============================================================================
module YEA
module CLASS_SYSTEM
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - General Class Settings -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# These are the general settings regarding the whole script. They control
# various rules and regulations that this script undergoes. These settings
# will also determine what a subclass can do for a player.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
CLASS_MENU_TEXT = "Gene" # Text that appears in the Main Menu.
MAINTAIN_LEVELS = false # Maintain through all classes. Default: false.
DEFAULT_UNLOCKS = [1] # Classes unlocked by default.
# The display between a primary class and a subclass when written in a
# window will appear as such.
SUBCLASS_TEXT = "%s | %s"
# This adjusts the stat rate inheritance for an actor if an actor has a
# subclass equipped. If you want to disable this, set the rate to 0.0.
SUBCLASS_STAT_RATE = 0.20
# This adds subclass skill types to the available skill types usable.
SUBCLASS_SKILL_TYPES = true
# This adds subclass weapons to equippable weapon types.
SUBCLASS_WEAPON_TYPES = true
# This adds subclass weapons to equippable armour types.
SUBCLASS_ARMOUR_TYPES = true
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Class Scene Commands -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# These settings adjust how the class scene appears. Here, you can adjust
# the command list and the order at which items appear. These are mostly
# visual settings. Adjust them as you see fit.
#
# -------------------------------------------------------------------------
# :command Description
# -------------------------------------------------------------------------
# :primary Allows the player to change the primary class.
# :subclass Allows the player to change the subclass.
#
# :learn_skill Requires YEA - Learn Skill Engine
#
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
COMMANDS =[ # The order at which the menu items are shown.
# [ :command, "Display"],
[ :primary, "Primary Gene"],
[:subclass, "Sub Gene"],
[:learn_skill, "Custom"],
# [ :custom1, "Custom1"],
# [ :custom2, "Custom2"],
] # Do not remove this.
#--------------------------------------------------------------------------
# - Status Class Commands -
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# For those who use scripts to that may produce unique effects for the
# class menu, use this hash to manage the custom commands for the Class
# Command Window. You can disable certain commands or prevent them from
# appearing by using switches. If you don't wish to bind them to a switch,
# set the proper switch to 0 for it to have no impact.
#--------------------------------------------------------------------------
CUSTOM_CLASS_COMMANDS ={
# :command => [EnableSwitch, ShowSwitch, Handler Method,
:custom1 => [ 0, 0, :command_name1],
:custom2 => [ 0, 0, :command_name2],
} # Do not remove this.
# These settings adjust the colour displays for classes.
CURRENT_CLASS_COLOUR = 17 # "Window" colour used for current class.
SUBCLASS_COLOUR = 4 # "Window" colour used for subclass.
# This adjusts the display for class levels if MAINTAIN_LEVELS is false.
CLASS_LEVEL = "LV%s" # Text display for level.
LEVEL_FONT_SIZE = 16 # Font size used for level.
# This array sets the order of how classes are ordered in the class listing
# window. Any class ID's unlisted will not be shown.
CLASS_ORDER = [41..999, 1..40]
# This adjusts the font size for the Parameters window.
PARAM_FONT_SIZE = 20
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Switch Settings -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# These are the switches that govern whether or not certain menu items will
# appear and/or will be enabled. By binding them to a Switch, you can just
# set the Switch ON/OFF to show/hide or enable/disable a menu command. If
# you do not wish to use this feature, set these commands to 0.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
SWITCH_SHOW_CLASS = 0 # Switch that shows Class in Main Menu.
SWITCH_ENABLE_CLASS = 0 # Switch that enables Class in Main Menu.
SWITCH_SHOW_PRIMARY = 0 # Switch that shows Subclass in Class Menu.
SWITCH_ENABLE_PRIMARY = 0 # Switch that enables Subclass in Class Menu.
SWITCH_SHOW_SUBCLASS = 0 # Switch that shows Subclass in Class Menu.
SWITCH_ENABLE_SUBCLASS = 0 # Switch that enables Subclass in Class Menu.
end # CLASS_SYSTEM
end # YEA
#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================
module YEA
module CLASS_SYSTEM
module_function
#--------------------------------------------------------------------------
# convert_integer_array
#--------------------------------------------------------------------------
def convert_integer_array(array)
result = []
array.each { |i|
case i
when Range; result |= i.to_a
when Integer; result |= [i]
end }
return result
end
#--------------------------------------------------------------------------
# converted_contants
#--------------------------------------------------------------------------
DEFAULT_UNLOCKS = convert_integer_array(DEFAULT_UNLOCKS)
CLASS_ORDER = convert_integer_array(CLASS_ORDER)
end # CLASS_SYSTEM
module REGEXP
module ACTOR
UNLOCKED_CLASSES =
/<(?:UNLOCKED_CLASSES|unlocked classes):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
end # ACTOR
module CLASS
ICON_INDEX = /<(?:ICON_INDEX|icon index|icon):[ ](\d+)>/i
HELP_DESCRIPTION_ON = /<(?:HELP_DESCRIPTION|help description)>/i
HELP_DESCRIPTION_OFF = /<\/(?:HELP_DESCRIPTION|help description)>/i
end # CLASS
end # REGEXP
end # YEA
#==============================================================================
# ■ Switch
#==============================================================================
module Switch
#--------------------------------------------------------------------------
# self.class_show
#--------------------------------------------------------------------------
def self.class_show
return true if YEA::CLASS_SYSTEM::SWITCH_SHOW_CLASS <= 0
return $game_switches[YEA::CLASS_SYSTEM::SWITCH_SHOW_CLASS]
end
#--------------------------------------------------------------------------
# self.class_enable
#--------------------------------------------------------------------------
def self.class_enable
return true if YEA::CLASS_SYSTEM::SWITCH_ENABLE_CLASS <= 0
return $game_switches[YEA::CLASS_SYSTEM::SWITCH_ENABLE_CLASS]
end
#--------------------------------------------------------------------------
# self.primary_show
#--------------------------------------------------------------------------
def self.primary_show
return true if YEA::CLASS_SYSTEM::SWITCH_SHOW_PRIMARY <= 0
return $game_switches[YEA::CLASS_SYSTEM::SWITCH_SHOW_PRIMARY]
end
#--------------------------------------------------------------------------
# self.primary_enable
#--------------------------------------------------------------------------
def self.primary_enable
return true if YEA::CLASS_SYSTEM::SWITCH_ENABLE_PRIMARY <= 0
return $game_switches[YEA::CLASS_SYSTEM::SWITCH_ENABLE_PRIMARY]
end
#--------------------------------------------------------------------------
# self.subclass_show
#--------------------------------------------------------------------------
def self.subclass_show
return true if YEA::CLASS_SYSTEM::SWITCH_SHOW_SUBCLASS <= 0
return $game_switches[YEA::CLASS_SYSTEM::SWITCH_SHOW_SUBCLASS]
end
#--------------------------------------------------------------------------
# self.subclass_enable
#--------------------------------------------------------------------------
def self.subclass_enable
return true if YEA::CLASS_SYSTEM::SWITCH_ENABLE_SUBCLASS <= 0
return $game_switches[YEA::CLASS_SYSTEM::SWITCH_ENABLE_SUBCLASS]
end
end # Switch
#==============================================================================
# ■ Numeric
#==============================================================================
class Numeric
#--------------------------------------------------------------------------
# new method: group_digits
#--------------------------------------------------------------------------
unless $imported["YEA-CoreEngine"]
def group; return self.to_s; end
end # $imported["YEA-CoreEngine"]
end # Numeric
#==============================================================================
# ■ DataManager
#==============================================================================
module DataManager
#--------------------------------------------------------------------------
# alias method: load_database
#--------------------------------------------------------------------------
class <<self; alias load_database_cs load_database; end
def self.load_database
load_database_cs
load_notetags_cs
end
#--------------------------------------------------------------------------
# new method: load_notetags_cs
#--------------------------------------------------------------------------
def self.load_notetags_cs
groups = [$data_actors, $data_classes]
for group in groups
for obj in group
next if obj.nil?
obj.load_notetags_cs
end
end
end
end # DataManager
#==============================================================================
# ■ RPG::Actor
#==============================================================================
class RPG::Actor < RPG::BaseItem
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :unlocked_classes
#--------------------------------------------------------------------------
# common cache: load_notetags_cs
#--------------------------------------------------------------------------
def load_notetags_cs
@unlocked_classes = []
#---
self.note.split(/[\r\n]+/).each { |line|
case line
#---
when YEA::REGEXP::ACTOR::UNLOCKED_CLASSES
$1.scan(/\d+/).each { |num|
@unlocked_classes.push(num.to_i) if num.to_i > 0 }
#---
end
} # self.note.split
#---
end
end # RPG::Actor
#==============================================================================
# ■ RPG::Class
#==============================================================================
class RPG::Class < RPG::BaseItem
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :icon_index
#--------------------------------------------------------------------------
# common cache: load_notetags_cs
#--------------------------------------------------------------------------
def load_notetags_cs
@icon_index = 0
@help_description_on = false
#---
self.note.split(/[\r\n]+/).each { |line|
case line
#---
when YEA::REGEXP::CLASS::ICON_INDEX
@icon_index = $1.to_i
#---
when YEA::REGEXP::CLASS::HELP_DESCRIPTION_ON
@help_description_on = true
when YEA::REGEXP::CLASS::HELP_DESCRIPTION_OFF
@help_description_on = false
#---
else
@description += line.to_s if @help_description_on
end
} # self.note.split
#---
@description.gsub!(/[|]/i) { "\n" }
end
end # RPG::Class
#==============================================================================
# ■ Game_Temp
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :scene_class_index
attr_accessor :scene_class_oy
end # Game_Temp
#==============================================================================
# ■ Game_Action
#==============================================================================
class Game_Action
#--------------------------------------------------------------------------
# alias method: valid?
#--------------------------------------------------------------------------
alias game_action_valid_cs valid?
def valid?
return false if check_auto_battle_class
return game_action_valid_cs
end
#--------------------------------------------------------------------------
# new method: check_auto_battle_class
#--------------------------------------------------------------------------
def check_auto_battle_class
return false unless subject.actor?
return false unless subject.auto_battle?
return false if item.nil?
return false if subject.added_skill_types.include?(item.stype_id)
return false if item.id == subject.attack_skill_id
return true
end
end # Game_Action
#==============================================================================
# ■ Game_BattlerBase
#==============================================================================
class Game_BattlerBase
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :temp_flag
#--------------------------------------------------------------------------
# alias method: added_skill_types
#--------------------------------------------------------------------------
alias game_battlerbase_added_skill_types_cs added_skill_types
def added_skill_types
result = game_battlerbase_added_skill_types_cs
result |= subclass_skill_types
return result
end
#--------------------------------------------------------------------------
# new method: subclass_skill_types
#--------------------------------------------------------------------------
def subclass_skill_types; return []; end
#--------------------------------------------------------------------------
# alias method: equip_wtype_ok?
#--------------------------------------------------------------------------
alias game_battlerbase_equip_wtype_ok_cs equip_wtype_ok?
def equip_wtype_ok?(wtype_id)
return true if subclass_equip_wtype?(wtype_id)
return game_battlerbase_equip_wtype_ok_cs(wtype_id)
end
#--------------------------------------------------------------------------
# new method: subclass_equip_wtype?
#--------------------------------------------------------------------------
def subclass_equip_wtype?(wtype_id); return false; end
#--------------------------------------------------------------------------
# alias method: equip_atype_ok?
#--------------------------------------------------------------------------
alias game_battlerbase_equip_atype_ok_cs equip_atype_ok?
def equip_atype_ok?(atype_id)
return true if subclass_equip_atype?(atype_id)
return game_battlerbase_equip_atype_ok_cs(atype_id)
end
#--------------------------------------------------------------------------
# new method: subclass_equip_atype?
#--------------------------------------------------------------------------
def subclass_equip_atype?(atype_id); return false; end
end # Game_BattlerBase
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
attr_accessor :subclass_id
#--------------------------------------------------------------------------
# alias method: setup
#--------------------------------------------------------------------------
alias game_actor_setup_cs setup
def setup(actor_id)
game_actor_setup_cs(actor_id)
init_unlocked_classes
init_subclass
end
#--------------------------------------------------------------------------
# new method: init_unlocked_classes
#--------------------------------------------------------------------------
def init_unlocked_classes
@unlocked_classes = actor.unlocked_classes.clone
@unlocked_classes.push(@class_id) if !@unlocked_classes.include?(@class_id)
@unlocked_classes.sort!
end
#--------------------------------------------------------------------------
# new method: init_subclass
#--------------------------------------------------------------------------
def init_subclass
@subclass_id = 0
end
#--------------------------------------------------------------------------
# new method: unlocked_classes
#--------------------------------------------------------------------------
def unlocked_classes
init_unlocked_classes if @unlocked_classes.nil?
return @unlocked_classes
end
#--------------------------------------------------------------------------
# new method: unlock_class
#--------------------------------------------------------------------------
def unlock_class(class_id)
init_unlocked_classes if @unlocked_classes.nil?
return if @unlocked_classes.include?(class_id)
@unlocked_classes.push(class_id)
learn_class_skills(class_id)
end
#--------------------------------------------------------------------------
# new method: remove_class
#--------------------------------------------------------------------------
def remove_class(class_id)
init_unlocked_classes if @unlocked_classes.nil?
return if class_id == @class_id
@unlocked_classes.delete(class_id)
@subclass_id = 0 if class_id == @subclass_id
refresh
end
#--------------------------------------------------------------------------
# new method: subclass
#--------------------------------------------------------------------------
def subclass
init_subclass if @subclass_id.nil?
return $data_classes[@subclass_id]
end
#--------------------------------------------------------------------------
# alias method: change_class
#--------------------------------------------------------------------------
alias game_actor_change_class_cs change_class
def change_class(class_id, keep_exp = false)
@subclass_id = 0 if @subclass_id == class_id
game_actor_change_class_cs(class_id, keep_exp)
learn_class_skills(class_id)
unlock_class(class_id)
end
#--------------------------------------------------------------------------
# new method: learn_class_skills
#--------------------------------------------------------------------------
def learn_class_skills(class_id)
return if class_id <= 0
return if $data_classes[class_id].nil?
$data_classes[class_id].learnings.each do |learning|
learn_skill(learning.skill_id) if learning.level == class_level(class_id)
end
end
#--------------------------------------------------------------------------
# new method: change_subclass
#--------------------------------------------------------------------------
def change_subclass(class_id)
return if class_id == @class_id
unlock_class(class_id)
@subclass_id = @subclass_id == class_id ? 0 : class_id
learn_class_skills(@subclass_id)
refresh
end
#————————————————————————–
# new method: class_level Edited by DisturbedInside
# Please don’t sue me Mr. Yanfly!!
#————————————————————————–
def class_level(class_id)
return @level if YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
temp_class = $data_classes[class_id]
@exp[class_id] = 0 if @exp[class_id].nil?
#declare a max level (using EXP)
#If you can’t find it, go to the class database and select exp curve
#then switch view to total at the top
maxlv_exp = temp_class.exp_for_level(99)
@exp[max_level] = maxlv_exp #2547133 #This is the value to change. It declares a max level
#You need to calculate how much exp for max level
#Do it manually if using Yanfly-Adjusting Limits
#To calculate max level exp if using Yanfly-adjusting limits is all math!!
# Level 99 = 2547133
# to calculate past there…. have to add on multiples of 50744
# Level 110 = 3156061
# To go from 99 -> 110 have to add on 12 multiples of 50744.
n = 1
loop do
break if temp_class.exp_for_level(n+1) > @exp[class_id]
n += 1
#add a restriction to “kick out” of loop if exp exceeds max level exp
break if temp_class.exp_for_level(n+1) > @exp[max_level]
end
return n
end
#--------------------------------------------------------------------------
# new method: subclass_level
#--------------------------------------------------------------------------
def subclass_level
return 0 if @subclass_id == 0
return @level if YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
return class_level(@subclass_id)
end
#--------------------------------------------------------------------------
# alias method: param_base
#--------------------------------------------------------------------------
alias game_actor_param_base_cs param_base
def param_base(param_id)
result = game_actor_param_base_cs(param_id)
unless subclass.nil?
subclass_rate = YEA::CLASS_SYSTEM::SUBCLASS_STAT_RATE
slevel = subclass_level
result += subclass.params[param_id, slevel] * subclass_rate
end
return result.to_i
end
#--------------------------------------------------------------------------
# new method: subclass_skill_types
#--------------------------------------------------------------------------
def subclass_skill_types
return [] unless YEA::CLASS_SYSTEM::SUBCLASS_SKILL_TYPES
return [] if subclass.nil?
array = []
for feature in subclass.features
next unless feature.code == FEATURE_STYPE_ADD
next if features_set(FEATURE_STYPE_ADD).include?(feature.data_id)
array.push(feature.data_id)
end
return array
end
#--------------------------------------------------------------------------
# new method: subclass_equip_wtype?
#--------------------------------------------------------------------------
def subclass_equip_wtype?(wtype_id)
return false unless YEA::CLASS_SYSTEM::SUBCLASS_WEAPON_TYPES
return false if subclass.nil?
for feature in subclass.features
next unless feature.code == FEATURE_EQUIP_WTYPE
return true if wtype_id == feature.data_id
end
return super
end
#--------------------------------------------------------------------------
# new method: subclass_equip_atype?
#--------------------------------------------------------------------------
def subclass_equip_atype?(atype_id)
return false unless YEA::CLASS_SYSTEM::SUBCLASS_ARMOUR_TYPES
return false if subclass.nil?
for feature in subclass.features
next unless feature.code == FEATURE_EQUIP_ATYPE
return true if atype_id == feature.data_id
end
return super
end
#--------------------------------------------------------------------------
# alias method: release_unequippable_items
#--------------------------------------------------------------------------
alias game_actor_release_unequippable_items_cs release_unequippable_items
def release_unequippable_items(item_gain = true)
item_gain = false if @temp_flag
game_actor_release_unequippable_items_cs(item_gain)
end
end # Game_Actor
#==============================================================================
# ■ Game_Interpreter
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# overwrite method: command_321
#--------------------------------------------------------------------------
def command_321
actor = $game_actors[@params[0]]
if actor && $data_classes[@params[1]]
maintain = YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
actor.change_class(@params[1], maintain)
end
end
end # Game_Interpreter
#==============================================================================
# ■ Window_Base
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# overwrite method: draw_actor_class
#--------------------------------------------------------------------------
def draw_actor_class(actor, x, y, width = 112)
change_color(normal_color)
if actor.subclass.nil?
text = actor.class.name
else
fmt = YEA::CLASS_SYSTEM::SUBCLASS_TEXT
text = sprintf(fmt, actor.class.name, actor.subclass.name)
end
draw_text(x, y, width, line_height, text)
end
end # Window_Base
#==============================================================================
# ■ Window_MenuCommand
#==============================================================================
class Window_MenuCommand < Window_Command
#--------------------------------------------------------------------------
# alias method: add_formation_command
#--------------------------------------------------------------------------
alias window_menucommand_add_formation_command_cs add_formation_command
def add_formation_command
add_class_command unless $imported["YEA-AceMenuEngine"]
window_menucommand_add_formation_command_cs
end
#--------------------------------------------------------------------------
# new method: add_class_command
#--------------------------------------------------------------------------
def add_class_command
return unless Switch.class_show
text = YEA::CLASS_SYSTEM::CLASS_MENU_TEXT
add_command(text, :class, Switch.class_enable)
end
end # Window_MenuCommand
#==============================================================================
# ■ Window_ClassCommand
#==============================================================================
class Window_ClassCommand < Window_Command
#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y)
@actor = nil
end
#--------------------------------------------------------------------------
# ● ウィンドウ幅の取得
#--------------------------------------------------------------------------
def window_width; return 160; end
#--------------------------------------------------------------------------
# actor=
#--------------------------------------------------------------------------
def actor=(actor)
return if @actor == actor
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# item_window=
#--------------------------------------------------------------------------
def item_window=(window)
@item_window = window
end
#--------------------------------------------------------------------------
# visible_line_number
#--------------------------------------------------------------------------
def visible_line_number; return 4; end
#--------------------------------------------------------------------------
# make_command_list
#--------------------------------------------------------------------------
def make_command_list
return if @actor.nil?
for command in YEA::CLASS_SYSTEM::COMMANDS
case command[0]
when :primary
next unless Switch.primary_show
add_command(command[1], command[0], Switch.primary_enable)
when :subclass
next unless Switch.subclass_show
add_command(command[1], command[0], Switch.subclass_enable)
when :learn_skill
next unless $imported["YEA-LearnSkillEngine"]
add_learn_skill_command
else
process_custom_command(command)
end
end
if !$game_temp.scene_class_index.nil?
select($game_temp.scene_class_index)
self.oy = $game_temp.scene_class_oy
end
$game_temp.scene_class_index = nil
$game_temp.scene_class_oy = nil
end
#--------------------------------------------------------------------------
# process_ok
#--------------------------------------------------------------------------
def process_ok
$game_temp.scene_class_index = index
$game_temp.scene_class_oy = self.oy
super
end
#--------------------------------------------------------------------------
# process_custom_command
#--------------------------------------------------------------------------
def process_custom_command(command)
return unless YEA::CLASS_SYSTEM::CUSTOM_CLASS_COMMANDS.include?(command[0])
show = YEA::CLASS_SYSTEM::CUSTOM_CLASS_COMMANDS[command[0]][1]
continue = show <= 0 ? true : $game_switches[show]
return unless continue
text = command[1]
switch = YEA::CLASS_SYSTEM::CUSTOM_CLASS_COMMANDS[command[0]][0]
enabled = switch <= 0 ? true : $game_switches[switch]
add_command(text, command[0], enabled)
end
#--------------------------------------------------------------------------
# update
#--------------------------------------------------------------------------
def update
super
update_visible_windows
end
#--------------------------------------------------------------------------
# update_visible_windows
#--------------------------------------------------------------------------
def update_visible_windows
return if @current_index == current_symbol
@current_index = current_symbol
@item_window.refresh unless @item_window.nil?
end
#--------------------------------------------------------------------------
# add_learn_skill_command
#--------------------------------------------------------------------------
def add_learn_skill_command
return unless Switch.show_learn_skill
name = YEA::LEARN_SKILL::COMMAND_NAME
add_command(name, :learn_skill, true)
end
end # Window_ClassCommand
#==============================================================================
# ■ Window_ClassStatus
#==============================================================================
class Window_ClassStatus < Window_Base
#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize(dx, dy)
super(dx, dy, window_width, fitting_height(4))
@actor = nil
end
#--------------------------------------------------------------------------
# window_width
#--------------------------------------------------------------------------
def window_width; Graphics.width - 160; end
#--------------------------------------------------------------------------
# actor=
#--------------------------------------------------------------------------
def actor=(actor)
return if @actor == actor
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
return if @actor.nil?
draw_actor_face(@actor, 0, 0)
draw_actor_simple_status(@actor, 108, line_height / 2)
end
end # Window_ClassStatus
#==============================================================================
# ■ Window_ClassParam
#==============================================================================
class Window_ClassParam < Window_Base
#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize(dx, dy)
super(dx, dy, window_width, Graphics.height - dy)
@actor = nil
@temp_actor = nil
refresh
end
#--------------------------------------------------------------------------
# window_width
#--------------------------------------------------------------------------
def window_width; return Graphics.width * 2 / 5; end
#--------------------------------------------------------------------------
# actor=
#--------------------------------------------------------------------------
def actor=(actor)
return if @actor == actor
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
8.times {|i| draw_item(0, line_height * i, i) }
end
#--------------------------------------------------------------------------
# set_temp_actor
#--------------------------------------------------------------------------
def set_temp_actor(temp_actor)
return if @temp_actor == temp_actor
@temp_actor = temp_actor
refresh
end
#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(dx, dy, param_id)
draw_background_colour(dx, dy)
draw_param_name(dx + 4, dy, param_id)
draw_current_param(dx + 4, dy, param_id) if @actor
drx = (contents.width + 22) / 2
draw_right_arrow(drx, dy)
draw_new_param(drx + 22, dy, param_id) if @temp_actor
reset_font_settings
end
#--------------------------------------------------------------------------
# draw_background_colour
#--------------------------------------------------------------------------
def draw_background_colour(dx, dy)
colour = Color.new(0, 0, 0, translucent_alpha/2)
rect = Rect.new(dx+1, dy+1, contents.width - 2, line_height - 2)
contents.fill_rect(rect, colour)
end
#--------------------------------------------------------------------------
# overwrite method: draw_param_name
#--------------------------------------------------------------------------
def draw_param_name(dx, dy, param_id)
contents.font.size = YEA::CLASS_SYSTEM::PARAM_FONT_SIZE
change_color(system_color)
draw_text(dx, dy, contents.width, line_height, Vocab::param(param_id))
end
#--------------------------------------------------------------------------
# overwrite method: draw_current_param
#--------------------------------------------------------------------------
def draw_current_param(dx, dy, param_id)
change_color(normal_color)
dw = (contents.width + 22) / 2
draw_text(0, dy, dw, line_height, @actor.param(param_id).group, 2)
reset_font_settings
end
#--------------------------------------------------------------------------
# draw_right_arrow
#--------------------------------------------------------------------------
def draw_right_arrow(x, y)
change_color(system_color)
draw_text(x, y, 22, line_height, "→", 1)
end
#--------------------------------------------------------------------------
# draw_new_param
#--------------------------------------------------------------------------
def draw_new_param(dx, dy, param_id)
contents.font.size = YEA::CLASS_SYSTEM::PARAM_FONT_SIZE
new_value = @temp_actor.param(param_id)
change_color(param_change_color(new_value - @actor.param(param_id)))
draw_text(0, dy, contents.width-4, line_height, new_value.group, 2)
reset_font_settings
end
end # Window_ClassParam
#==============================================================================
# ■ Window_ClassList
#==============================================================================
class Window_ClassList < Window_Selectable
#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize(dx, dy)
dw = Graphics.width - (Graphics.width * 2 / 5)
dh = Graphics.height - dy
super(dx, dy, dw, dh)
@actor = nil
@command_window = nil
@status_window
@data = []
end
#--------------------------------------------------------------------------
# actor=
#--------------------------------------------------------------------------
def actor=(actor)
return if @actor == actor
@actor = actor
@last_item = nil
refresh
self.oy = 0
end
#--------------------------------------------------------------------------
# command_window=
#--------------------------------------------------------------------------
def command_window=(command_window)
@command_window = command_window
end
#--------------------------------------------------------------------------
# status_window=
#--------------------------------------------------------------------------
def status_window=(status_window)
@status_window = status_window
end
#--------------------------------------------------------------------------
# item_max
#--------------------------------------------------------------------------
def item_max; return @data ? @data.size : 1; end
#--------------------------------------------------------------------------
# item
#--------------------------------------------------------------------------
def item; return @data && index >= 0 ? @data[index] : nil; end
#--------------------------------------------------------------------------
# current_item_enabled?
#--------------------------------------------------------------------------
def current_item_enabled?; return enable?(@data[index]); end
#--------------------------------------------------------------------------
# include?
#--------------------------------------------------------------------------
def include?(item)
return true if YEA::CLASS_SYSTEM::DEFAULT_UNLOCKS.include?(item.id)
return @actor.unlocked_classes.include?(item.id)
end
#--------------------------------------------------------------------------
# enable?
#--------------------------------------------------------------------------
def enable?(item)
return false if item == @actor.class
return true
end
#--------------------------------------------------------------------------
# make_item_list
#--------------------------------------------------------------------------
def make_item_list
@data = []
for class_id in YEA::CLASS_SYSTEM::CLASS_ORDER
next if $data_classes[class_id].nil?
item = $data_classes[class_id]
@data.push(item) if include?(item)
end
end
#--------------------------------------------------------------------------
# select_last
#--------------------------------------------------------------------------
def select_last
case @command_window.current_symbol
when :primary
select(@data.index(@actor.class))
when :subclass
select(0) if @actor.subclass.nil?
select(@data.index(@actor.subclass)) unless @actor.subclass.nil?
else
select(0)
end
end
#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
return if item.nil?
rect = item_rect(index)
rect.width -= 4
reset_font_settings
set_item_colour(item)
draw_class_icon(item, rect)
draw_class_name(item, rect)
draw_class_level(item, rect)
end
#--------------------------------------------------------------------------
# set_item_colour
#--------------------------------------------------------------------------
def set_item_colour(item)
if item == @actor.class
change_color(text_color(YEA::CLASS_SYSTEM::CURRENT_CLASS_COLOUR))
elsif item == @actor.subclass
change_color(text_color(YEA::CLASS_SYSTEM::SUBCLASS_COLOUR))
else
change_color(normal_color, enable?(item))
end
end
#--------------------------------------------------------------------------
# draw_class_icon
#--------------------------------------------------------------------------
def draw_class_icon(item, rect)
icon = item.icon_index
draw_icon(icon, rect.x, rect.y, enable?(item))
end
#--------------------------------------------------------------------------
# draw_class_name
#--------------------------------------------------------------------------
def draw_class_name(item, rect)
text = item.name
draw_text(24, rect.y, rect.width-24, line_height, text)
end
#--------------------------------------------------------------------------
# draw_class_level
#--------------------------------------------------------------------------
def draw_class_level(item, rect)
return if YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
return if @actor.nil?
level = @actor.class_level(item.id)
contents.font.size = YEA::CLASS_SYSTEM::LEVEL_FONT_SIZE
text = sprintf(YEA::CLASS_SYSTEM::CLASS_LEVEL, level.group)
draw_text(rect, text, 2)
end
#--------------------------------------------------------------------------
# update_help
#--------------------------------------------------------------------------
def update_help
@help_window.set_item(item)
return if @actor.nil?
return if @status_window.nil?
update_param_window
end
#--------------------------------------------------------------------------
# update_param_window
#--------------------------------------------------------------------------
def update_param_window
return if @last_item == item
@last_item = item
class_id = item.nil? ? @actor.class_id : item.id
temp_actor = Marshal.load(Marshal.dump(@actor))
temp_actor.temp_flag = true
case @command_window.current_symbol
when :primary
temp_actor.change_class(class_id, YEA::CLASS_SYSTEM::MAINTAIN_LEVELS)
when :subclass
temp_actor.change_subclass(class_id)
end
@status_window.set_temp_actor(temp_actor)
end
#--------------------------------------------------------------------------
# update_class
#--------------------------------------------------------------------------
def update_class
@last_item = nil
update_help
refresh
activate
end
#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh
make_item_list
create_contents
draw_all_items
end
end # Window_ClassList
#==============================================================================
# ■ Scene_Menu
#==============================================================================
class Scene_Menu < Scene_MenuBase
#--------------------------------------------------------------------------
# alias method: create_command_window
#--------------------------------------------------------------------------
alias scene_menu_create_command_window_cs create_command_window
def create_command_window
scene_menu_create_command_window_cs
@command_window.set_handler(:class, method(:command_personal))
end
#--------------------------------------------------------------------------
# alias method: on_personal_ok
#--------------------------------------------------------------------------
alias scene_menu_on_personal_ok_cs on_personal_ok
def on_personal_ok
case @command_window.current_symbol
when :class
SceneManager.call(Scene_Class)
else
scene_menu_on_personal_ok_cs
end
end
end # Scene_Menu
#==============================================================================
# ■ Scene_Class
#==============================================================================
class Scene_Class < Scene_MenuBase
#--------------------------------------------------------------------------
# start
#--------------------------------------------------------------------------
def start
super
create_help_window
create_command_window
create_status_window
create_param_window
create_item_window
relocate_windows
end
#--------------------------------------------------------------------------
# create_command_window
#--------------------------------------------------------------------------
def create_command_window
wy = @help_window.height
@command_window = Window_ClassCommand.new(0, wy)
@command_window.viewport = @viewport
@command_window.help_window = @help_window
@command_window.actor = @actor
@command_window.set_handler(:cancel, method(:return_scene))
@command_window.set_handler(:primary, method(:command_class_change))
@command_window.set_handler(:subclass, method(:command_class_change))
process_custom_class_commands
return if $game_party.in_battle
@command_window.set_handler(:pagedown, method(:next_actor))
@command_window.set_handler(:pageup, method(:prev_actor))
@command_window.set_handler(:learn_skill, method(:command_learn_skill))
end
#--------------------------------------------------------------------------
# process_custom_class_commands
#--------------------------------------------------------------------------
def process_custom_class_commands
for command in YEA::CLASS_SYSTEM::COMMANDS
next unless YEA::CLASS_SYSTEM::CUSTOM_CLASS_COMMANDS.include?(command[0])
called_method = YEA::CLASS_SYSTEM::CUSTOM_CLASS_COMMANDS[command[0]][2]
@command_window.set_handler(command[0], method(called_method))
end
end
#--------------------------------------------------------------------------
# create_status_window
#--------------------------------------------------------------------------
def create_status_window
wy = @help_window.height
@status_window = Window_ClassStatus.new(@command_window.width, wy)
@status_window.viewport = @viewport
@status_window.actor = @actor
end
#--------------------------------------------------------------------------
# create_param_window
#--------------------------------------------------------------------------
def create_param_window
dx = Graphics.width - (Graphics.width * 2 / 5)
dy = @status_window.y + @status_window.height
@param_window = Window_ClassParam.new(dx, dy)
@param_window.viewport = @viewport
@param_window.actor = @actor
end
#--------------------------------------------------------------------------
# create_item_window
#--------------------------------------------------------------------------
def create_item_window
dy = @status_window.y + @status_window.height
@item_window = Window_ClassList.new(0, dy)
@item_window.help_window = @help_window
@item_window.command_window = @command_window
@item_window.status_window = @param_window
@item_window.viewport = @viewport
@item_window.actor = @actor
@command_window.item_window = @item_window
@item_window.set_handler(:ok, method(:on_class_ok))
@item_window.set_handler(:cancel, method(:on_class_cancel))
end
#--------------------------------------------------------------------------
# relocate_windows
#--------------------------------------------------------------------------
def relocate_windows
return unless $imported["YEA-AceMenuEngine"]
case Menu.help_window_location
when 0 # Top
@help_window.y = 0
@command_window.y = @help_window.height
@param_window.y = @command_window.y + @command_window.height
when 1 # Middle
@command_window.y = 0
@help_window.y = @command_window.height
@param_window.y = @help_window.y + @help_window.height
else # Bottom
@command_window.y = 0
@param_window.y = @command_window.height
@help_window.y = @param_window.y + @param_window.height
end
@status_window.y = @command_window.y
@item_window.y = @param_window.y
end
#--------------------------------------------------------------------------
# on_actor_change
#--------------------------------------------------------------------------
def on_actor_change
@command_window.actor = @actor
@status_window.actor = @actor
@param_window.actor = @actor
@item_window.actor = @actor
@command_window.activate
end
#--------------------------------------------------------------------------
# command_class_change
#--------------------------------------------------------------------------
def command_class_change
@item_window.activate
@item_window.select_last
end
#--------------------------------------------------------------------------
# on_class_cancel
#--------------------------------------------------------------------------
def on_class_cancel
@item_window.unselect
@command_window.activate
@param_window.set_temp_actor(nil)
end
#--------------------------------------------------------------------------
# on_class_ok
#--------------------------------------------------------------------------
def on_class_ok
Sound.play_equip
class_id = @item_window.item.id
maintain = YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
hp = @actor.hp * 1.0 / @actor.mhp
mp = @actor.mp * 1.0 / [@actor.mmp, 1].max
case @command_window.current_symbol
when :primary
@actor.change_class(class_id, maintain)
when :subclass
@actor.change_subclass(class_id)
else
@item_window.activate
return
end
@actor.hp = (@actor.mhp * hp).to_i
@actor.mp = (@actor.mmp * mp).to_i
@status_window.refresh
@item_window.update_class
end
#--------------------------------------------------------------------------
# new method: command_learn_skill
#--------------------------------------------------------------------------
def command_learn_skill
return unless $imported["YEA-LearnSkillEngine"]
SceneManager.call(Scene_LearnSkill)
end
#--------------------------------------------------------------------------
# command_name1
#--------------------------------------------------------------------------
def command_name1
# Do nothing.
end
#--------------------------------------------------------------------------
# command_name2
#--------------------------------------------------------------------------
def command_name2
# Do nothing.
end
end # Scene_Class
#==============================================================================
#
# ▼ End of File
#
#==============================================================================
#==============================================================================
#
# ▼ Yanfly Engine Ace - Class System Add-On: Class Unlock Level v1.00
# -- Last Updated: 2011.12.20
# -- Level: Normal
# -- Requires: YEA - Class System v1.01+
#
#==============================================================================
$imported = {} if $imported.nil?
$imported["YEA-ClassUnlockLevel"] = true
#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2011.12.20 - Started Script and Finished.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script allows for classes to be unlocked after a class reaches a certain
# level. Note that this script is made for the Class System script and not
# using the MAINTAIN_LEVELS feature. Requirements for unlocking a class can be
# multiple level requirements as well.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Class Notetags - These notetags go in the class notebox in the database.
# -----------------------------------------------------------------------------
# <level unlock requirements>
# class x: level y
# class x: level y
# </level unlock requirements>
# Sets the requirements for unlocking that particular class. The unlocking of
# the class will require classes x to be at level y. Insert multiple of the
# strings in between the two opening and closing notetags to require all of the
# class levels to be met.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
# This script requires Yanfly Engine Ace - Class System v1.01+.
#
#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================
if $imported["YEA-ClassSystem"] && !YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
module YEA
module REGEXP
module CLASS
LV_UNLOCK_ON =
/<(?:LEVEL_UNLOCK_REQUIREMENTS|level unlock requirements)>/i
LV_UNLOCK_OFF =
/<\/(?:LEVEL_UNLOCK_REQUIREMENTS|level unlock requirements)>/i
LV_UNLOCK_STR = /CLASS[ ](\d+): LEVEL[ ](\d+)/i
end # CLASS
end # REGEXP
end # YEA
#==============================================================================
# ■ DataManager
#==============================================================================
module DataManager
#--------------------------------------------------------------------------
# alias method: load_database
#--------------------------------------------------------------------------
class <<self; alias load_database_cul load_database; end
def self.load_database
load_database_cul
load_notetags_cul
end
#--------------------------------------------------------------------------
# new method: load_notetags_cul
#--------------------------------------------------------------------------
def self.load_notetags_cul
for obj in $data_classes
next if obj.nil?
obj.load_notetags_cul
end
end
end # DataManager
#==============================================================================
# ■ RPG::Class
#==============================================================================
class RPG::Class < RPG::BaseItem
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :level_unlock
#--------------------------------------------------------------------------
# common cache: load_notetags_cul
#--------------------------------------------------------------------------
def load_notetags_cul
@level_unlock = {}
@level_unlock_on = false
#---
self.note.split(/[\r\n]+/).each { |line|
case line
#---
when YEA::REGEXP::CLASS::LV_UNLOCK_ON
@level_unlock_on = true
when YEA::REGEXP::CLASS::LV_UNLOCK_OFF
@level_unlock_on = false
when YEA::REGEXP::CLASS::LV_UNLOCK_STR
next unless @level_unlock_on
@level_unlock[$1.to_i] = $2.to_i
end
} # self.note.split
#---
end
end # RPG::Class
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# check_level_unlocked_classes
#--------------------------------------------------------------------------
def check_level_unlocked_classes
for item in $data_classes
next if item.nil?
next if unlocked_classes.include?(item.id)
next if item.level_unlock == {}
next unless class_unlock_level_requirements_met?(item)
unlock_class(item.id)
end
end
#--------------------------------------------------------------------------
# class_unlock_level_requirements_met?
#--------------------------------------------------------------------------
def class_unlock_level_requirements_met?(item)
for key in item.level_unlock
class_id = key[0]
level_req = key[1]
return false if class_level(class_id) < level_req
end
return true
end
end # Game_Actor
#==============================================================================
# ■ Window_ClassList
#==============================================================================
class Window_ClassList < Window_Selectable
#--------------------------------------------------------------------------
# alias method: actor=
#--------------------------------------------------------------------------
alias window_classlist_actor_equals_cul actor=
def actor=(actor)
return if @actor == actor
actor.check_level_unlocked_classes
window_classlist_actor_equals_cul(actor)
end
end # Window_ClassList
end # $imported["YEA-ClassSystem"] && !YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
#==============================================================================
#
# ▼ End of File
#
#==============================================================================
#==============================================================================
#
# ▼ Yanfly Engine Ace - JP Manager v1.00
# -- Last Updated: 2012.01.07
# -- Level: Normal, Hard
# -- Requires: n/a
#
#==============================================================================
$imported = {} if $imported.nil?
$imported["YEA-JPManager"] = true
#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.01.07 - Started Script and Finished.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script provides a base for JP implementation. JP is a currency similar
# to EXP that's gained through performing actions and leveling up in addition
# to killing enemies. This script provides modifiers that adjust the gains for
# JP through rates, individual gains per skill or item, and per enemy. Though
# this script provides no usage of JP by itself, future Yanfly Engine Ace
# scripts may make use of it.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Actor Notetags - These notetags go in the actors notebox in the database.
# -----------------------------------------------------------------------------
# <jp rate: x%>
# Changes the JP earned rate to x%. This affects JP earned and not JP directly
# gained. If this notetag isn't used, the object will default to 100%.
#
# -----------------------------------------------------------------------------
# Class Notetags - These notetags go in the class notebox in the database.
# -----------------------------------------------------------------------------
# <jp rate: x%>
# Changes the JP earned rate to x%. This affects JP earned and not JP directly
# gained. If this notetag isn't used, the object will default to 100%.
#
# -----------------------------------------------------------------------------
# Skill Notetags - These notetags go in the skills notebox in the database.
# -----------------------------------------------------------------------------
# <jp gain: x>
# When the actor successfully hits an target with this action, the actor will
# earn x JP. If this notetag isn't used, the amount of JP earned will equal to
# the ACTION_JP constant in the module.
#
# -----------------------------------------------------------------------------
# Item Notetags - These notetags go in the items notebox in the database.
# -----------------------------------------------------------------------------
# <jp gain: x>
# When the actor successfully hits an target with this action, the actor will
# earn x JP. If this notetag isn't used, the amount of JP earned will equal to
# the ACTION_JP constant in the module.
#
# -----------------------------------------------------------------------------
# Weapon Notetags - These notetags go in the weapon notebox in the database.
# -----------------------------------------------------------------------------
# <jp rate: x%>
# Changes the JP earned rate to x%. This affects JP earned and not JP directly
# gained. If this notetag isn't used, the object will default to 100%.
#
# -----------------------------------------------------------------------------
# Armour Notetags - These notetags go in the armour notebox in the database.
# -----------------------------------------------------------------------------
# <jp rate: x%>
# Changes the JP earned rate to x%. This affects JP earned and not JP directly
# gained. If this notetag isn't used, the object will default to 100%.
#
# -----------------------------------------------------------------------------
# Enemy Notetags - These notetags go in the enemy notebox in the database.
# -----------------------------------------------------------------------------
# <jp gain: x>
# Changes the amount of JP gained for killing the enemy to x. If this notetag
# isn't used, then the default JP gain will be equal to the amount set in the
# module through the constant ENEMY_KILL.
#
# -----------------------------------------------------------------------------
# State Notetags - These notetags go in the states notebox in the database.
# -----------------------------------------------------------------------------
# <jp rate: x%>
# Changes the JP earned rate to x%. This affects JP earned and not JP directly
# gained. If this notetag isn't used, the object will default to 100%.
#
# -----------------------------------------------------------------------------
# Script Calls - These commands are used with script calls.
# -----------------------------------------------------------------------------
# $game_actors[x].earn_jp(y)
# $game_actors[x].earn_jp(y, z)
# This will cause actor x to earn y amount of JP. JP earned will be modified by
# any JP Rate traits provided through notetags. If z is used, z will be the
# class the JP is earned for.
#
# $game_actors[x].gain_jp(y)
# $game_actors[x].gain_jp(y, z)
# This will cause actor x to gain y amount of JP. JP gained this way will not
# be modified by any JP Rate traits provided through notetags. If z is used,
# z will be the class the JP is gained for.
#
# $game_actors[x].lose_jp(y)
# $game_actors[x].lose_jp(y, z)
# This will cause actor x to lose y amount of JP. JP lost this way will not be
# modified by any JP Rate traits provided through notetags. If z is used, z
# will be the class the JP is lost from.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
# This script is compatible with Yanfly Engine Ace - Victory Aftermath v1.03+.
# If you wish to have Victory Aftermath display JP gains, make sure the version
# is 1.03+. Script placement of these two scripts don't matter.
#
#==============================================================================
module YEA
module JP
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - General JP Settings -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# This adjusts the way JP appears visually in your game. Change the icon
# used and the vocabulary used here. Furthermore, adjust the maximum amount
# of JP that an actor can have at a time.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
ICON = 0 # Icon index used to represent JP.
VOCAB = "JP" # What JP will be called in your game.
MAX_JP = 99999999 # Maximum JP an actor can have.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Default JP Gain Settings -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# The following constants adjust how much JP is earned by default through
# enemy kills, leveling up, and performing actions.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
ENEMY_KILL = 20 # JP earned for the whole party.
LEVEL_UP = 100 # JP earned when leveling up!
ACTION_JP = 5 # JP earned per successful hit.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Victory Message -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# This adjusts the victory message shown for the default battle system and
# the Yanfly Engine Ace - Victory Aftermath script (if used together).
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
VICTORY_MESSAGE = "%s has earned %s %s!"
VICTORY_AFTERMATH = "+%s%s"
end # JP
end # YEA
#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================
module YEA
module REGEXP
module BASEITEM
JP_RATE = /<(?:JP_RATE|jp rate):[ ](\d+)([%%])>/i
end # BASEITEM
module USABLEITEM
JP_GAIN = /<(?:JP_GAIN|jp gain):[ ](\d+)>/i
end # USABLEITEM
module ENEMY
JP_GAIN = /<(?:JP_GAIN|jp gain):[ ](\d+)>/i
end # ENEMY
end # REGEXP
end # YEA
#==============================================================================
# ■ Vocab
#==============================================================================
module Vocab
#--------------------------------------------------------------------------
# new method: self.jp
#--------------------------------------------------------------------------
def self.jp
return YEA::JP::VOCAB
end
end # Vocab
#==============================================================================
# ■ Icon
#==============================================================================
module Icon
#--------------------------------------------------------------------------
# self.jp
#--------------------------------------------------------------------------
def self.jp; return YEA::JP::ICON; end
end # Icon
#==============================================================================
# ■ Numeric
#==============================================================================
class Numeric
#--------------------------------------------------------------------------
# new method: group_digits
#--------------------------------------------------------------------------
unless $imported["YEA-CoreEngine"]
def group; return self.to_s; end
end # $imported["YEA-CoreEngine"]
end # Numeric
#==============================================================================
# ■ DataManager
#==============================================================================
module DataManager
#--------------------------------------------------------------------------
# alias method: load_database
#--------------------------------------------------------------------------
class <<self; alias load_database_jp load_database; end
def self.load_database
load_database_jp
load_notetags_jp
end
#--------------------------------------------------------------------------
# new method: load_notetags_jp
#--------------------------------------------------------------------------
def self.load_notetags_jp
groups = [$data_actors, $data_classes, $data_weapons, $data_armors,
$data_states, $data_enemies, $data_items, $data_skills]
for group in groups
for obj in group
next if obj.nil?
obj.load_notetags_jp
end
end
end
end # DataManager
#==============================================================================
# ■ RPG::BaseItem
#==============================================================================
class RPG::BaseItem
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :jp_rate
#--------------------------------------------------------------------------
# common cache: load_notetags_jp
#--------------------------------------------------------------------------
def load_notetags_jp
@jp_rate = 1.0
#---
self.note.split(/[\r\n]+/).each { |line|
case line
#---
when YEA::REGEXP::BASEITEM::JP_RATE
@jp_rate = $1.to_i * 0.01
#---
end
} # self.note.split
#---
end
end # RPG::BaseItem
#==============================================================================
# ■ RPG::UsableItem
#==============================================================================
class RPG::UsableItem < RPG::BaseItem
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :jp_gain
#--------------------------------------------------------------------------
# common cache: load_notetags_jp
#--------------------------------------------------------------------------
def load_notetags_jp
@jp_gain = YEA::JP::ACTION_JP
#---
self.note.split(/[\r\n]+/).each { |line|
case line
#---
when YEA::REGEXP::USABLEITEM::JP_GAIN
@jp_gain = $1.to_i
#---
end
} # self.note.split
#---
end
end # RPG::UsableItem
#==============================================================================
# ■ RPG::Enemy
#==============================================================================
class RPG::Enemy < RPG::BaseItem
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :jp_gain
#--------------------------------------------------------------------------
# common cache: load_notetags_jp
#--------------------------------------------------------------------------
def load_notetags_jp
@jp_gain = YEA::JP::ENEMY_KILL
#---
self.note.split(/[\r\n]+/).each { |line|
case line
#---
when YEA::REGEXP::ENEMY::JP_GAIN
@jp_gain = $1.to_i
#---
end
} # self.note.split
#---
end
end # RPG::Enemy
#==============================================================================
# ■ BattleManager
#==============================================================================
module BattleManager
#--------------------------------------------------------------------------
# alias method: display_exp
#--------------------------------------------------------------------------
unless $imported["YEA-VictoryAftermath"]
class <<self; alias battlemanager_display_exp_jp display_exp; end
def self.display_exp
battlemanager_display_exp_jp
gain_jp
end
end # $imported["YEA-VictoryAftermath"]
#--------------------------------------------------------------------------
# new method: gain_jp
#--------------------------------------------------------------------------
def self.gain_jp
amount = $game_troop.jp_total
fmt = YEA::JP::VICTORY_MESSAGE
for member in $game_party.members
member.earn_jp(amount)
next if $imported["YEA-VictoryAftermath"]
value = member.battle_jp_earned.group
$game_message.add('\.' + sprintf(fmt, member.name, value, Vocab::jp))
end
wait_for_message unless $imported["YEA-VictoryAftermath"]
end
end # BattleManager
#==============================================================================
# ■ Game_BattlerBase
#==============================================================================
class Game_BattlerBase
#--------------------------------------------------------------------------
# new method: jpr
#--------------------------------------------------------------------------
def jpr
n = 1.0
if actor?
n *= self.actor.jp_rate
n *= self.class.jp_rate
for equip in equips
next if equip.nil?
n *= equip.jp_rate
end
end
for state in states
next if state.nil?
n *= state.jp_rate
end
return n
end
end # Game_BattlerBase
#==============================================================================
# ■ Game_Battler
#==============================================================================
class Game_Battler < Game_BattlerBase
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :battle_jp_earned
#--------------------------------------------------------------------------
# alias method: on_battle_start
#--------------------------------------------------------------------------
alias game_battler_on_battle_start_jp on_battle_start
def on_battle_start
game_battler_on_battle_start_jp
@battle_jp_earned = 0
end
#--------------------------------------------------------------------------
# alias method: on_battle_end
#--------------------------------------------------------------------------
alias game_battler_on_battle_end_jp on_battle_end
def on_battle_end
game_battler_on_battle_end_jp
@battle_jp_earned = 0
end
#--------------------------------------------------------------------------
# alias method: item_user_effect
#--------------------------------------------------------------------------
alias game_battler_item_user_effect_jp item_user_effect
def item_user_effect(user, item)
game_battler_item_user_effect_jp(user, item)
user.earn_jp(item.jp_gain) if user.actor?
end
end # Game_Battler
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# alias method: setup
#--------------------------------------------------------------------------
alias game_actor_setup_jp setup
def setup(actor_id)
game_actor_setup_jp(actor_id)
init_jp
end
#--------------------------------------------------------------------------
# new method: init_jp
#--------------------------------------------------------------------------
def init_jp
@jp = {}
@jp[@class_id] = 0
end
#--------------------------------------------------------------------------
# new method: earn_jp
#--------------------------------------------------------------------------
def earn_jp(jp, class_id = nil)
gain_jp(jp * jpr, class_id)
end
#--------------------------------------------------------------------------
# new method: gain_jp
#--------------------------------------------------------------------------
def gain_jp(jp, class_id = nil)
init_jp if @jp.nil?
class_id = @class_id if class_id.nil?
@jp[class_id] = 0 if @jp[class_id].nil?
@jp[class_id] += jp.to_i
@jp[class_id] = [[@jp[class_id], YEA::JP::MAX_JP].min, 0].max
@battle_jp_earned = 0 if @battle_jp_earned.nil? && $game_party.in_battle
@battle_jp_earned += jp.to_i if $game_party.in_battle
end
#--------------------------------------------------------------------------
# new method: lose_jp
#--------------------------------------------------------------------------
def lose_jp(jp, class_id = nil)
gain_jp(-jp, class_id)
end
#--------------------------------------------------------------------------
# new method: jp
#--------------------------------------------------------------------------
def jp(class_id = nil)
class_id = @class_id if class_id.nil?
@jp[class_id] = 0 if @jp[class_id].nil?
return @jp[class_id]
end
#--------------------------------------------------------------------------
# alias method: level_up
#--------------------------------------------------------------------------
alias game_actor_level_up_jp level_up
def level_up
game_actor_level_up_jp
earn_jp(YEA::JP::LEVEL_UP)
end
end # Game_Actor
#==============================================================================
# ■ Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# new method: jp
#--------------------------------------------------------------------------
def jp
return enemy.jp_gain
end
end # Game_Enemy
#==============================================================================
# ■ Game_Troop
#==============================================================================
class Game_Troop < Game_Unit
#--------------------------------------------------------------------------
# new method: jp_total
#--------------------------------------------------------------------------
def jp_total
dead_members.inject(0) {|r, enemy| r += enemy.jp }
end
end # Game_Troop
#==============================================================================
# ■ Window_Base
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# new method: draw_actor_jp
#--------------------------------------------------------------------------
def draw_actor_jp(actor, dx, dy, dw = 112)
draw_icon(Icon.jp, dx + dw - 24, dy) if Icon.jp > 0
dw -= 24 if Icon.jp > 0
change_color(system_color)
draw_text(dx, dy, dw, line_height, Vocab::jp, 2)
dw -= text_size(Vocab::jp).width
change_color(normal_color)
draw_text(dx, dy, dw, line_height, actor.jp.group, 2)
end
#--------------------------------------------------------------------------
# new method: draw_actor_jp_class
#--------------------------------------------------------------------------
def draw_actor_jp_class(actor, class_id, dx, dy, dw = 112)
draw_icon(Icon.jp, dx + dw - 24, dy) if Icon.jp > 0
dw -= 24 if Icon.jp > 0
change_color(system_color)
draw_text(dx, dy, dw, line_height, Vocab::jp, 2)
dw -= text_size(Vocab::jp).width
change_color(normal_color)
draw_text(dx, dy, dw, line_height, actor.jp(class_id).group, 2)
end
end # Window_Base
#==============================================================================
#
# ▼ End of File
#
#==============================================================================
#==============================================================================
#
# ▼ Yanfly Engine Ace - Learn Skill Engine v1.00
# -- Last Updated: 2012.01.08
# -- Level: Normal, Hard
# -- Requires: n/a
#
#==============================================================================
$imported = {} if $imported.nil?
$imported["YEA-LearnSkillEngine"] = true
#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.01.08 - Started Script and Finished.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# For those who want an alternative for actors to learn skills outside of
# leveling, this script allows actors to learn skills through a learn skill
# menu. The actor can use acquired JP, EXP, or Gold to learn skills. Skills can
# also be hidden until certain requirements are met.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Class Notetags - These notetags go in the class notebox in the database.
# -----------------------------------------------------------------------------
# <learn skills: x>
# <learn skills: x, x>
# Sets the class to be able to learn skills x through the Learn Skills menu.
# Insert multiple of these tags to increase the number of skills learned.
#
# -----------------------------------------------------------------------------
# Skill Notetags - These notetags go in the skill notebox in the database.
# -----------------------------------------------------------------------------
# <learn cost: x jp>
# <learn cost: x exp>
# <learn cost: x gold>
# Sets the learn for cost the skill to require x amounts of JP, x amounts of
# exp, or x amounts of gold. Only one type of cost can be used at a time. For
# JP costs, the Yanfly Engine Ace - JP Manager script must be installed.
#
# <learn require level: x>
# Sets the skill to require the actor's current level to be x before the skill
# will show up in the skill learning window.
#
# <learn require skill: x>
# <learn require skill: x, x>
# Sets the skill to require learning skill x (through any means) before the
# skill becomes visible in the skill learning window. Insert multiples of these
# tags to require more skills to be learned in order for the skill to show.
#
# <learn require switch: x>
# <learn require switch: x, x>
# Sets the skill to require switch x to be ON in order for it to show in the
# skill learning window. Insert multiple switches to to increase the number of
# switches needed to be ON before the skill is shown.
#
# <learn require eval>
# string
# string
# </learn require eval>
# For the more advanced users, replace string with lines of code to check for
# whether or not the skill will be shown in skill learning window. If multiple
# lines are used, they are all considered part of the same line.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
# This script is compatible with Yanfly Engine Ace - JP Manager v1.00+. The
# placement of this script relative to the JP Manager script doesn't matter.
#
#==============================================================================
module YEA
module LEARN_SKILL
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - General Settings -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# Adjust the general settings here for your game. These adjust how the
# command name appears, a switch to show the Learn Command
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
COMMAND_NAME = "Learn Skills" # Name used for Learn Skill command.
# This switch will hide the "Learn" command from view if the switch is OFF.
# The "Learn" command will be shown if the switch is ON. Set this switch to
# 0 to not use this effect and to always have the Learn command be shown.
SHOW_SWITCH = 0
# This adjusts the order the Skill Types appear in for the command window.
# Any Skill Types unlisted will not be shown.
STYPE_ORDER = [41..999, 1..40]
# For those who installed Yanfly Engine - Skill Restrictions, you can
# choose to display warmups or cooldowns inside of the menu here.
DRAW_WARMUP = true # Draw warmups for skills?
DRAW_COOLDOWN = true # Draw cooldowns for skills?
#-------------------------------------------------------------------------
# - Default Cost -
#-------------------------------------------------------------------------
# This sets the default costs for all skills. If the JP script isn't
# installed, the type will become :exp instead.
#
# Cost Type Description
# :jp - Requires YEA - JP Manager.
# :exp - Makes skill cost EXP.
# :gold - Makes skill cost gold.
#-------------------------------------------------------------------------
DEFAULT_COST = 100 # Sets the default cost of a skill.
DEFAULT_TYPE = :jp # Sets the default cost type.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Learn Window Settings -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# These settings adjust the Learn Window's visual appearance. Adjust the
# way empty text appears, EXP cost suffixes appear, Learned text appears,
# font sizes, and cost colours here.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
EMPTY_TEXT = "-" # Text if no restricts used for the skill.
EXP_TEXT = "EXP" # Text used for EXP costs.
LEARNED_TEXT = "Learned" # Text to indicate skill has been learned.
LEARNED_SIZE = 20 # Font size used for learned skill text.
COLOUR_JP = 24 # Text colour used for JP Cost.
COLOUR_EXP = 5 # Text colour used for EXP Cost.
COLOUR_GOLD = 21 # Text colour used for Gold Cost.
COST_SIZE = 20 # Font size used for skill costs.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Cost Window Settings -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# When a skill is selected to be learned, the cost window appears. Adjust
# the settings here to choose how your game's cost window looks. Change the
# maximum number of rows, the gold icon used for gold costs, the gold text,
# the learn skill text, the cancel text, and the cancel icon here.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
MAXIMUM_ROWS = 8 # Maximum number of rows displayed.
GOLD_ICON = 361 # Icon used for gold costs.
GOLD_TEXT = "Gold Cost" # Text used for gold costs.
LEARN_SKILL_TEXT = "Learn %s?" # Text used to learn skill.
LEARN_CANCEL_TEXT = "Cancel" # Text used for do not learn.
CANCEL_ICON = 187 # Icon used for cancel.
end # LEARN_SKILL
end # YEA
#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================
module YEA
module LEARN_SKILL
module_function
#--------------------------------------------------------------------------
# convert_integer_array
#--------------------------------------------------------------------------
def convert_integer_array(array)
result = []
array.each { |i|
case i
when Range; result |= i.to_a
when Integer; result |= [i]
end }
return result
end
#--------------------------------------------------------------------------
# converted_contants
#--------------------------------------------------------------------------
STYPE_ORDER = convert_integer_array(STYPE_ORDER)
end # LEARN_SKILL
module REGEXP
module CLASS
LEARN_SKILLS = /<(?:LEARN_SKILLS|learn skills):[ ](\d+(?:\s*,\s*\d+)*)>/i
end # CLASS
module SKILL
LEARN_COST = /<(?:LEARN_COST|learn cost):[ ](.*)>/i
LEARN_REQUIRE_LEVEL =
/<(?:LEARN_REQUIRE_LEVEL|learn require level):[ ](\d+)>/i
LEARN_REQUIRE_SKILL =
/<(?:LEARN_REQUIRE_SKILL|learn require skill):[ ](\d+(?:\s*,\s*\d+)*)>/i
LEARN_REQUIRE_SWITCH =
/<(?:LEARN_REQUIRE_SWITCH|learn require switch):[ ](\d+(?:\s*,\s*\d+)*)>/i
LEARN_REQUIRE_EVAL_ON = /<(?:LEARN_REQUIRE_EVAL|learn require eval)>/i
LEARN_REQUIRE_EVAL_OFF = /<\/(?:LEARN_REQUIRE_EVAL|learn require eval)>/i
end # SKILL
end # REGEXP
end # YEA
#==============================================================================
# ■ Numeric
#==============================================================================
class Numeric
#--------------------------------------------------------------------------
# new method: group_digits
#--------------------------------------------------------------------------
unless $imported["YEA-CoreEngine"]
def group; return self.to_s; end
end # $imported["YEA-CoreEngine"]
end # Numeric
#==============================================================================
# ■ Icon
#==============================================================================
module Icon
#--------------------------------------------------------------------------
# self.cancel
#--------------------------------------------------------------------------
def self.cancel
return YEA::LEARN_SKILL::CANCEL_ICON
end
#--------------------------------------------------------------------------
# self.learn_skill_gold
#--------------------------------------------------------------------------
def self.learn_skill_gold
return YEA::LEARN_SKILL::GOLD_ICON
end
end # Icon
#==============================================================================
# ■ Switch
#==============================================================================
module Switch
#--------------------------------------------------------------------------
# self.show_learn_skill
#--------------------------------------------------------------------------
def self.show_learn_skill
return true if YEA::LEARN_SKILL::SHOW_SWITCH <= 0
return $game_switches[YEA::LEARN_SKILL::SHOW_SWITCH]
end
end # Switch
#==============================================================================
# ■ DataManager
#==============================================================================
module DataManager
#--------------------------------------------------------------------------
# alias method: load_database
#--------------------------------------------------------------------------
class <<self; alias load_database_lse load_database; end
def self.load_database
load_database_lse
load_notetags_lse
end
#--------------------------------------------------------------------------
# new method: load_notetags_lse
#--------------------------------------------------------------------------
def self.load_notetags_lse
groups = [$data_classes, $data_skills]
for group in groups
for obj in group
next if obj.nil?
obj.load_notetags_lse
end
end
end
end # DataManager
#==============================================================================
# ■ RPG::Class
#==============================================================================
class RPG::Class < RPG::BaseItem
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :learn_skills
#--------------------------------------------------------------------------
# common cache: load_notetags_lse
#--------------------------------------------------------------------------
def load_notetags_lse
@learn_skills = []
#---
self.note.split(/[\r\n]+/).each { |line|
case line
#---
when YEA::REGEXP::CLASS::LEARN_SKILLS
$1.scan(/\d+/).each { |num|
@learn_skills.push(num.to_i) if num.to_i > 0 }
end
} # self.note.split
#---
end
end # RPG::Class
#==============================================================================
# ■ RPG::Skill
#==============================================================================
class RPG::Skill < RPG::UsableItem
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :learn_cost
attr_accessor :learn_require_level
attr_accessor :learn_require_skill
attr_accessor :learn_require_switch
attr_accessor :learn_require_eval
#--------------------------------------------------------------------------
# common cache: load_notetags_lse
#--------------------------------------------------------------------------
def load_notetags_lse
@learn_cost = [YEA::LEARN_SKILL::DEFAULT_COST]
@learn_cost.push(YEA::LEARN_SKILL::DEFAULT_TYPE)
@learn_require_level = 0
@learn_require_skill = []
@learn_require_switch = []
@learn_require_eval_on = false
#---
self.note.split(/[\r\n]+/).each { |line|
case line
#---
when YEA::REGEXP::SKILL::LEARN_COST
case $1.upcase
when /(\d+)[ ]JP/i
next unless $imported["YEA-JPManager"]
@learn_cost = [$1.to_i, :jp]
when /(\d+)[ ]EXP/i
@learn_cost = [$1.to_i, :exp]
when /(\d+)[ ]GOLD/i
@learn_cost = [$1.to_i, :gold]
end
#---
when YEA::REGEXP::SKILL::LEARN_REQUIRE_LEVEL
@learn_require_level = $1.to_i
when YEA::REGEXP::SKILL::LEARN_REQUIRE_SKILL
$1.scan(/\d+/).each { |num|
@learn_require_skill.push(num.to_i) if num.to_i > 0 }
when YEA::REGEXP::SKILL::LEARN_REQUIRE_SWITCH
$1.scan(/\d+/).each { |num|
@learn_require_switch.push(num.to_i) if num.to_i > 0 }
#---
when YEA::REGEXP::SKILL::LEARN_REQUIRE_EVAL_ON
@learn_require_eval_on = true
when YEA::REGEXP::SKILL::LEARN_REQUIRE_EVAL_OFF
@learn_require_eval_on = false
else
next unless @learn_require_eval_on
@learn_require_eval = "" if @learn_require_eval.nil?
@learn_require_eval += line.to_s
#---
end
} # self.note.split
#---
if !$imported["YEA-JPManager"] && @learn_cost[1] == :jp
@learn_cost[1] = :exp
end
end
end # RPG::Skill
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# alias method: skills
#--------------------------------------------------------------------------
alias game_actor_skills_lse skills
def skills
btest_add_learn_skills
game_actor_skills_lse
end
#--------------------------------------------------------------------------
# new method: btest_add_learn_skills
#--------------------------------------------------------------------------
def btest_add_learn_skills
return unless $BTEST
for skill_id in self.class.learn_skills; learn_skill(skill_id); end
end
#--------------------------------------------------------------------------
# new method: exp_class
#--------------------------------------------------------------------------
def exp_class(class_id)
@exp[class_id] = 0 if @exp[class_id].nil?
return @exp[class_id]
end
#--------------------------------------------------------------------------
# lose_exp_class
#--------------------------------------------------------------------------
def lose_exp_class(value, class_id)
exp = exp_class(class_id) - value
change_exp_class(exp, class_id)
end
#--------------------------------------------------------------------------
# change_exp_class
#--------------------------------------------------------------------------
def change_exp_class(exp, class_id)
return change_exp(exp, false) if class_id == @class_id
@exp[class_id] = [exp, 0].max
end
end # Game_Actor
#==============================================================================
# ■ Window_SkillCommand
#==============================================================================
class Window_SkillCommand < Window_Command
#--------------------------------------------------------------------------
# alias method: make_command_list
#--------------------------------------------------------------------------
alias window_skillcommand_make_command_list_lse make_command_list
def make_command_list
window_skillcommand_make_command_list_lse
return if @actor.nil?
add_learn_skill_command unless $imported["YEA-SkillMenu"]
end
#--------------------------------------------------------------------------
# new method: add_learn_skill_command
#--------------------------------------------------------------------------
def add_learn_skill_command
return unless Switch.show_learn_skill
name = YEA::LEARN_SKILL::COMMAND_NAME
add_command(name, :learn_skill, true, @actor.added_skill_types[0])
end
end # Window_SkillCommand
#==============================================================================
# ■ Window_LearnSkillCommand
#==============================================================================
class Window_LearnSkillCommand < Window_Command
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_reader :skill_window
#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize(dx, dy)
super(dx, dy)
@actor = nil
end
#--------------------------------------------------------------------------
# window_width
#--------------------------------------------------------------------------
def window_width; return 160; end
#--------------------------------------------------------------------------
# visible_line_number
#--------------------------------------------------------------------------
def visible_line_number; return 4; end
#--------------------------------------------------------------------------
# actor=
#--------------------------------------------------------------------------
def actor=(actor)
return if @actor == actor
@actor = actor
refresh
select(item_max - 1) if index >= item_max
end
#--------------------------------------------------------------------------
# make_command_list
#--------------------------------------------------------------------------
def make_command_list
return if @actor.nil?
make_unlocked_class_skill_types
correct_unlocked_class_learned_skills
for stype_id in YEA::LEARN_SKILL::STYPE_ORDER
next unless include?(stype_id)
name = $data_system.skill_types[stype_id]
add_command(name, :skill, true, stype_id)
end
end
#--------------------------------------------------------------------------
# make_unlocked_class_skill_types
#--------------------------------------------------------------------------
def make_unlocked_class_skill_types
return unless $imported["YEA-ClassSystem"]
@unlocked_types = []
unlocked_classes = @actor.unlocked_classes.clone
unlocked_classes |= YEA::CLASS_SYSTEM::DEFAULT_UNLOCKS
for class_id in unlocked_classes
next if $data_classes[class_id].nil?
for feature in $data_classes[class_id].features
next unless feature.code == 41
@unlocked_types.push(feature.data_id)
end
end
end
#--------------------------------------------------------------------------
# correct_unlocked_class_learned_skills
#--------------------------------------------------------------------------
def correct_unlocked_class_learned_skills
return unless $imported["YEA-ClassSystem"]
unlocked_classes = @actor.unlocked_classes.clone
unlocked_classes |= YEA::CLASS_SYSTEM::DEFAULT_UNLOCKS
for class_id in unlocked_classes
@actor.learn_class_skills(class_id)
end
end
#--------------------------------------------------------------------------
# include?
#--------------------------------------------------------------------------
def include?(stype_id)
return true if @actor.added_skill_types.include?(stype_id)
if $imported["YEA-ClassSystem"]
return true if @unlocked_types.include?(stype_id)
end
return false
end
#--------------------------------------------------------------------------
# update
#--------------------------------------------------------------------------
def update
super
@skill_window.stype_id = current_ext if @skill_window
end
#--------------------------------------------------------------------------
# skill_window=
#--------------------------------------------------------------------------
def skill_window=(skill_window)
@skill_window = skill_window
update
end
end # Window_LearnSkillCommand
#==============================================================================
# ■ Window_LearnSkillList
#==============================================================================
class Window_LearnSkillList < Window_SkillList
#--------------------------------------------------------------------------
# col_max
#--------------------------------------------------------------------------
def col_max; return 1; end
#--------------------------------------------------------------------------
# select_last
#--------------------------------------------------------------------------
def select_last; select(0); end
#--------------------------------------------------------------------------
# actor=
#--------------------------------------------------------------------------
def actor=(actor)
return if @actor == actor
super(actor)
make_learn_skills_list
end
#--------------------------------------------------------------------------
# make_learn_skills_list
#--------------------------------------------------------------------------
def make_learn_skills_list
@learn_skills = []
@skill_classes = {}
return if @actor.nil?
for skill_id in @actor.class.learn_skills
next if $data_skills[skill_id].nil?
next if @learn_skills.include?($data_skills[skill_id])
skill = $data_skills[skill_id]
@learn_skills.push(skill)
@skill_classes[skill] = [] if @skill_classes[skill].nil?
@skill_classes[skill].push(@actor.class.id)
end
make_unlocked_class_skills
end
#--------------------------------------------------------------------------
# make_unlocked_class_skills
#--------------------------------------------------------------------------
def make_unlocked_class_skills
return unless $imported["YEA-ClassSystem"]
@unlocked_types = []
unlocked_classes = @actor.unlocked_classes.clone
unlocked_classes |= YEA::CLASS_SYSTEM::DEFAULT_UNLOCKS
for class_id in unlocked_classes
next if $data_classes[class_id].nil?
for skill_id in $data_classes[class_id].learn_skills
next if $data_skills[skill_id].nil?
skill = $data_skills[skill_id]
@learn_skills.push(skill) unless @learn_skills.include?(skill)
@skill_classes[skill] = [] if @skill_classes[skill].nil?
@skill_classes[skill] |= [class_id]
end
end
end
#--------------------------------------------------------------------------
# skill_classes
#--------------------------------------------------------------------------
def skill_classes(skill)
return @skill_classes[skill]
end
#--------------------------------------------------------------------------
# make_item_list
#--------------------------------------------------------------------------
def make_item_list
return if @learn_skills.nil?
@data = @learn_skills.select {|skill| include?(skill) }
end
#--------------------------------------------------------------------------
# include?
#--------------------------------------------------------------------------
def include?(item)
return false if item.nil?
return false unless meet_requirements?(item)
return item.stype_id == @stype_id
end
#--------------------------------------------------------------------------
# meet_requirements?
#--------------------------------------------------------------------------
def meet_requirements?(item)
return false if @actor.nil?
return false unless meet_level_requirements?(item)
return false unless meet_skill_requirements?(item)
return false unless meet_switch_requirements?(item)
return false unless meet_eval_requirements?(item)
return true
end
#--------------------------------------------------------------------------
# meet_level_requirements?
#--------------------------------------------------------------------------
def meet_level_requirements?(item)
return @actor.level >= item.learn_require_level
end
#--------------------------------------------------------------------------
# meet_skill_requirements?
#--------------------------------------------------------------------------
def meet_skill_requirements?(item)
for skill_id in item.learn_require_skill
next if $data_skills[skill_id].nil?
return false unless @actor.skill_learn?($data_skills[skill_id])
end
return true
end
#--------------------------------------------------------------------------
# meet_switch_requirements?
#--------------------------------------------------------------------------
def meet_switch_requirements?(item)
for switch_id in item.learn_require_switch
return false unless $game_switches[switch_id]
end
return true
end
#--------------------------------------------------------------------------
# meet_eval_requirements?
#--------------------------------------------------------------------------
def meet_eval_requirements?(item)
return true if item.learn_require_eval.nil?
return eval(item.learn_require_eval)
end
#--------------------------------------------------------------------------
# enable?
#--------------------------------------------------------------------------
def enable?(skill)
return false if skill.nil?
return false unless enabled_jp?(skill)
return false unless enabled_exp?(skill)
return false unless enabled_gold?(skill)
return !@actor.skill_learn?(skill)
end
#--------------------------------------------------------------------------
# enabled_jp?
#--------------------------------------------------------------------------
def enabled_jp?(skill)
return true if skill.learn_cost[1] != :jp
cost = skill.learn_cost[0]
for class_id in @skill_classes[skill]
return true if @actor.jp(class_id) >= cost
end
return false
end
#--------------------------------------------------------------------------
# enabled_exp?
#--------------------------------------------------------------------------
def enabled_exp?(skill)
return true if skill.learn_cost[1] != :exp
cost = skill.learn_cost[0]
for class_id in @skill_classes[skill]
return true if @actor.exp_class(class_id) >= cost
end
return false
end
#--------------------------------------------------------------------------
# enabled_gold?
#--------------------------------------------------------------------------
def enabled_gold?(skill)
return true if skill.learn_cost[1] != :gold
cost = skill.learn_cost[0]
return $game_party.gold >= cost
end
#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(index)
skill = @data[index]
return if skill.nil?
rect = item_rect(index)
rect.width = (contents.width - spacing) / 2 - 4
draw_item_name(skill, rect.x, rect.y, enable?(skill), rect.width - 24)
draw_skill_cost(rect, skill)
draw_restriction_info(skill, index)
draw_learn_cost(skill, index)
end
#--------------------------------------------------------------------------
# skill_restriction?
#--------------------------------------------------------------------------
def skill_restriction?(index)
return false
end
#--------------------------------------------------------------------------
# draw_restriction_info
#--------------------------------------------------------------------------
def draw_restriction_info(skill, index)
return unless $imported["YEA-SkillRestrictions"]
rect = item_rect(index)
rect.x = contents.width / 2
rect.width /= 2
rect.width /= 3
rect.width -= 8
draw_skill_warmup(skill, rect)
rect.x += rect.width + 4
draw_skill_cooldown(skill, rect)
end
#--------------------------------------------------------------------------
# draw_skill_warmup
#--------------------------------------------------------------------------
def draw_skill_warmup(skill, rect)
return unless YEA::LEARN_SKILL::DRAW_WARMUP
enabled = enable?(skill)
enabled = false if skill.warmup <= 0
change_color(warmup_colour, enabled)
icon = Icon.warmup
if icon > 0
draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
rect.width -= 24
end
contents.font.size = YEA::SKILL_RESTRICT::WARMUP_SIZE
value = skill.warmup > 0 ? skill.warmup.group : empty_text
text = sprintf(YEA::SKILL_RESTRICT::WARMUP_SUFFIX, value)
draw_text(rect, text, 2)
reset_font_settings
end
#--------------------------------------------------------------------------
# draw_skill_cooldown
#--------------------------------------------------------------------------
def draw_skill_cooldown(skill, rect)
return unless YEA::LEARN_SKILL::DRAW_COOLDOWN
enabled = enable?(skill)
enabled = false if skill.cooldown <= 0
change_color(cooldown_colour, enabled)
icon = Icon.cooldown
if icon > 0
draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
rect.width -= 24
end
contents.font.size = YEA::SKILL_RESTRICT::COOLDOWN_SIZE
value = skill.cooldown > 0 ? skill.cooldown.group : empty_text
text = sprintf(YEA::SKILL_RESTRICT::COOLDOWN_SUFFIX, value)
draw_text(rect, text, 2)
reset_font_settings
end
#--------------------------------------------------------------------------
# empty_text
#--------------------------------------------------------------------------
def empty_text
return YEA::LEARN_SKILL::EMPTY_TEXT
end
#--------------------------------------------------------------------------
# draw_learn_cost
#--------------------------------------------------------------------------
def draw_learn_cost(skill, index)
rect = item_rect(index)
rect.width -= 4
if @actor.skill_learn?(skill)
draw_learned_skill(rect)
else
draw_learn_skill_cost(skill, rect)
end
reset_font_settings
end
#--------------------------------------------------------------------------
# draw_learned_skill
#--------------------------------------------------------------------------
def draw_learned_skill(rect)
contents.font.size = YEA::LEARN_SKILL::LEARNED_SIZE
change_color(normal_color)
draw_text(rect, YEA::LEARN_SKILL::LEARNED_TEXT, 2)
end
#--------------------------------------------------------------------------
# draw_learn_skill_cost
#--------------------------------------------------------------------------
def draw_learn_skill_cost(skill, rect)
case skill.learn_cost[1]
when :jp
return unless $imported["YEA-JPManager"]
draw_jp_cost(skill, rect)
when :exp
draw_exp_cost(skill, rect)
when :gold
draw_gold_cost(skill, rect)
else; return
end
end
#--------------------------------------------------------------------------
# draw_jp_cost
#--------------------------------------------------------------------------
def draw_jp_cost(skill, rect)
enabled = enabled_jp?(skill)
if Icon.jp > 0
draw_icon(Icon.jp, rect.x + rect.width - 24, rect.y, enabled)
rect.width -= 24
end
contents.font.size = YEA::LEARN_SKILL::COST_SIZE
change_color(system_color, enabled)
draw_text(rect, Vocab::jp, 2)
rect.width -= text_size(Vocab::jp).width
cost = skill.learn_cost[0]
text = cost.group
change_color(text_color(YEA::LEARN_SKILL::COLOUR_JP), enabled)
draw_text(rect, text, 2)
end
#--------------------------------------------------------------------------
# draw_exp_cost
#--------------------------------------------------------------------------
def draw_exp_cost(skill, rect)
enabled = enabled_exp?(skill)
contents.font.size = YEA::LEARN_SKILL::COST_SIZE
change_color(system_color, enabled)
draw_text(rect, YEA::LEARN_SKILL::EXP_TEXT, 2)
rect.width -= text_size(YEA::LEARN_SKILL::EXP_TEXT).width
cost = skill.learn_cost[0]
text = cost.group
change_color(text_color(YEA::LEARN_SKILL::COLOUR_EXP), enabled)
draw_text(rect, text, 2)
end
#--------------------------------------------------------------------------
# draw_gold_cost
#--------------------------------------------------------------------------
def draw_gold_cost(skill, rect)
enabled = enabled_jp?(skill)
contents.font.size = YEA::LEARN_SKILL::COST_SIZE
change_color(system_color, enabled)
draw_text(rect, Vocab::currency_unit, 2)
rect.width -= text_size(Vocab::currency_unit).width
cost = skill.learn_cost[0]
text = cost.group
change_color(text_color(YEA::LEARN_SKILL::COLOUR_GOLD), enabled)
draw_text(rect, text, 2)
end
end # Window_LearnSkillList
#==============================================================================
# ■ Window_LearnSkillCostBack
#==============================================================================
class Window_LearnSkillCostBack < Window_Base
#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize(item_window)
dw = Graphics.width * 3 / 4
dx = (Graphics.width - dw) / 2
super(dx, 0, dw, fitting_height(2))
self.openness = 0
self.back_opacity = 255
@front_window = nil
@item_window = item_window
@skill = nil
end
#--------------------------------------------------------------------------
# reveal
#--------------------------------------------------------------------------
def reveal(skill, skill_classes)
@skill = skill
return if @skill.nil?
case @skill.learn_cost[1]
when :gold
self.height = fitting_height(3)
else
maximum = [skill_classes.size, YEA::LEARN_SKILL::MAXIMUM_ROWS].min
self.height = fitting_height(maximum + 2)
end
create_contents
self.y = (Graphics.height - self.height) / 2
refresh
open
end
#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
reset_font_settings
draw_learn_skill_text
rect = Rect.new(0, 0, contents.width - 4, line_height)
draw_learn_skill_cost(@skill, rect)
end
#--------------------------------------------------------------------------
# draw_learn_skill_text
#--------------------------------------------------------------------------
def draw_learn_skill_text
name = sprintf("\eI[%d]%s", @skill.icon_index, @skill.name)
fmt = YEA::LEARN_SKILL::LEARN_SKILL_TEXT
text = sprintf(fmt, name)
draw_text_ex(4, 0, text)
end
#--------------------------------------------------------------------------
# draw_learn_skill_cost
#--------------------------------------------------------------------------
def draw_learn_skill_cost(skill, rect)
case skill.learn_cost[1]
when :jp
return unless $imported["YEA-JPManager"]
draw_jp_cost(skill, rect)
when :exp
draw_exp_cost(skill, rect)
when :gold
draw_gold_cost(skill, rect)
else; return
end
end
#--------------------------------------------------------------------------
# draw_jp_cost
#--------------------------------------------------------------------------
def draw_jp_cost(skill, rect)
enabled = true
if Icon.jp > 0
draw_icon(Icon.jp, rect.x + rect.width - 24, rect.y, enabled)
rect.width -= 24
end
contents.font.size = YEA::LEARN_SKILL::COST_SIZE
change_color(system_color, enabled)
draw_text(rect, Vocab::jp, 2)
rect.width -= text_size(Vocab::jp).width
cost = skill.learn_cost[0]
text = cost.group
change_color(text_color(YEA::LEARN_SKILL::COLOUR_JP), enabled)
draw_text(rect, text, 2)
end
#--------------------------------------------------------------------------
# draw_exp_cost
#--------------------------------------------------------------------------
def draw_exp_cost(skill, rect)
enabled = true
contents.font.size = YEA::LEARN_SKILL::COST_SIZE
change_color(system_color, enabled)
draw_text(rect, YEA::LEARN_SKILL::EXP_TEXT, 2)
rect.width -= text_size(YEA::LEARN_SKILL::EXP_TEXT).width
cost = skill.learn_cost[0]
text = cost.group
change_color(text_color(YEA::LEARN_SKILL::COLOUR_EXP), enabled)
draw_text(rect, text, 2)
end
#--------------------------------------------------------------------------
# draw_gold_cost
#--------------------------------------------------------------------------
def draw_gold_cost(skill, rect)
enabled = true
contents.font.size = YEA::LEARN_SKILL::COST_SIZE
change_color(system_color, enabled)
draw_text(rect, Vocab::currency_unit, 2)
rect.width -= text_size(Vocab::currency_unit).width
cost = skill.learn_cost[0]
text = cost.group
change_color(text_color(YEA::LEARN_SKILL::COLOUR_GOLD), enabled)
draw_text(rect, text, 2)
end
end # Window_LearnSkillCostBack
#==============================================================================
# ■ Window_LearnSkillCostFront
#==============================================================================
class Window_LearnSkillCostFront < Window_Command
#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize(item_window, cost_window)
super((Graphics.width - window_width) / 2, 0)
self.openness = 0
self.opacity = 0
@item_window = item_window
@cost_window = cost_window
@skill = nil
@actor = nil
deactivate
end
#--------------------------------------------------------------------------
# window_width
#--------------------------------------------------------------------------
def window_width; return Graphics.width * 3 / 4; end
#--------------------------------------------------------------------------
# skill_class
#--------------------------------------------------------------------------
def skill_class
return @skill_classes.nil? ? nil : @skill_classes[index]
end
#--------------------------------------------------------------------------
# reveal
#--------------------------------------------------------------------------
def reveal(skill, skill_classes, actor)
@skill = skill
@skill_classes = skill_classes.clone
@actor = actor
return if @skill.nil?
case @skill.learn_cost[1]
when :gold
self.height = fitting_height(2)
else
maximum = [skill_classes.size, YEA::LEARN_SKILL::MAXIMUM_ROWS].min
self.height = fitting_height(maximum + 1)
end
create_contents
self.y = @cost_window.y + line_height
refresh
select(0)
open
activate
end
#--------------------------------------------------------------------------
# make_command_list
#--------------------------------------------------------------------------
def make_command_list
return if @skill_classes.nil?
if @skill.learn_cost[1] == :gold
add_command("GOLD", :gold, true)
add_command(YEA::LEARN_SKILL::LEARN_CANCEL_TEXT, :cancel, true)
return
end
for class_id in @skill_classes
name = $data_classes[class_id].name
add_command(name, :class, enabled?(class_id), class_id)
end
add_command(YEA::LEARN_SKILL::LEARN_CANCEL_TEXT, :cancel, true)
end
#--------------------------------------------------------------------------
# enabled?
#--------------------------------------------------------------------------
def enabled?(class_id)
cost = @skill.learn_cost[0]
case @skill.learn_cost[1]
when :jp
return @actor.jp(class_id) >= cost
when :exp
return @actor.exp_class(class_id) >= cost
end
return true
end
#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(index)
reset_font_settings
rect = item_rect(index)
rect.x += 24
rect.width -= 28
return draw_cancel_text(index, rect) if @list[index][:symbol] == :cancel
draw_class_name(index, rect) if @skill.learn_cost[1] != :gold
draw_party_gold(rect) if @skill.learn_cost[1] == :gold
draw_learn_skill_cost(@skill, rect, index)
end
#--------------------------------------------------------------------------
# draw_cancel_text
#--------------------------------------------------------------------------
def draw_cancel_text(index, rect)
draw_icon(Icon.cancel, rect.x, rect.y)
text = command_name(index)
draw_text(rect.x+24, rect.y, rect.width-24, line_height, text)
end
#--------------------------------------------------------------------------
# draw_class_name
#--------------------------------------------------------------------------
def draw_class_name(index, rect)
class_id = @list[index][:ext]
return if $data_classes[class_id].nil?
enabled = enabled?(class_id)
if $imported["YEA-ClassSystem"]
draw_icon($data_classes[class_id].icon_index, rect.x, rect.y, enabled)
end
rect.x += 24
rect.width -= 24
change_color(normal_color, enabled)
draw_text(rect, $data_classes[class_id].name)
end
#--------------------------------------------------------------------------
# draw_class_name
#--------------------------------------------------------------------------
def draw_party_gold(rect)
enabled = true
draw_icon(Icon.learn_skill_gold, rect.x, rect.y)
rect.x += 24
rect.width -= 24
change_color(normal_color, enabled)
draw_text(rect, YEA::LEARN_SKILL::GOLD_TEXT)
end
#--------------------------------------------------------------------------
# draw_learn_skill_cost
#--------------------------------------------------------------------------
def draw_learn_skill_cost(skill, rect, index)
case skill.learn_cost[1]
when :jp
return unless $imported["YEA-JPManager"]
draw_jp_cost(skill, rect, index)
when :exp
draw_exp_cost(skill, rect, index)
when :gold
draw_gold_cost(skill, rect)
else; return
end
end
#--------------------------------------------------------------------------
# draw_jp_cost
#--------------------------------------------------------------------------
def draw_jp_cost(skill, rect, index)
enabled = enabled?(@list[index][:ext])
if Icon.jp > 0
draw_icon(Icon.jp, rect.x + rect.width - 24, rect.y, enabled)
rect.width -= 24
end
contents.font.size = YEA::LEARN_SKILL::COST_SIZE
change_color(system_color, enabled)
draw_text(rect, Vocab::jp, 2)
rect.width -= text_size(Vocab::jp).width
cost = @actor.jp(@list[index][:ext])
text = cost.group
change_color(text_color(YEA::LEARN_SKILL::COLOUR_JP), enabled)
draw_text(rect, text, 2)
end
#--------------------------------------------------------------------------
# draw_exp_cost
#--------------------------------------------------------------------------
def draw_exp_cost(skill, rect, index)
enabled = enabled?(@list[index][:ext])
contents.font.size = YEA::LEARN_SKILL::COST_SIZE
change_color(system_color, enabled)
draw_text(rect, YEA::LEARN_SKILL::EXP_TEXT, 2)
rect.width -= text_size(YEA::LEARN_SKILL::EXP_TEXT).width
cost = @actor.exp_class(@list[index][:ext])
text = cost.group
change_color(text_color(YEA::LEARN_SKILL::COLOUR_EXP), enabled)
draw_text(rect, text, 2)
end
#--------------------------------------------------------------------------
# draw_gold_cost
#--------------------------------------------------------------------------
def draw_gold_cost(skill, rect)
enabled = $game_party.gold >= skill.learn_cost[0]
contents.font.size = YEA::LEARN_SKILL::COST_SIZE
change_color(system_color, enabled)
draw_text(rect, Vocab::currency_unit, 2)
rect.width -= text_size(Vocab::currency_unit).width
cost = $game_party.gold
text = cost.group
change_color(text_color(YEA::LEARN_SKILL::COLOUR_GOLD), enabled)
draw_text(rect, text, 2)
end
end # Window_LearnSkillCostFront
#==============================================================================
# ■ Scene_Skill
#==============================================================================
class Scene_Skill < Scene_ItemBase
#--------------------------------------------------------------------------
# alias method: create_command_window
#--------------------------------------------------------------------------
alias scene_skill_create_command_window_lse create_command_window
def create_command_window
scene_skill_create_command_window_lse
@command_window.set_handler(:learn_skill, method(:command_learn_skill))
end
#--------------------------------------------------------------------------
# new method: command_learn_skill
#--------------------------------------------------------------------------
def command_learn_skill
SceneManager.call(Scene_LearnSkill)
end
end # Scene_Skill
#==============================================================================
# ■ Scene_LearnSkill
#==============================================================================
class Scene_LearnSkill < Scene_Skill
#--------------------------------------------------------------------------
# start
#--------------------------------------------------------------------------
def start
super
create_cost_windows
end
#--------------------------------------------------------------------------
# create_command_window
#--------------------------------------------------------------------------
def create_command_window
wy = @help_window.height
@command_window = Window_LearnSkillCommand.new(0, wy)
@command_window.viewport = @viewport
@command_window.help_window = @help_window
@command_window.actor = @actor
@command_window.set_handler(:skill, method(:command_skill))
@command_window.set_handler(:cancel, method(:return_scene))
@command_window.set_handler(:pagedown, method(:next_actor))
@command_window.set_handler(:pageup, method(:prev_actor))
end
#--------------------------------------------------------------------------
# create_item_window
#--------------------------------------------------------------------------
def create_item_window
wx = 0
wy = @status_window.y + @status_window.height
ww = Graphics.width
wh = Graphics.height - wy
@item_window = Window_LearnSkillList.new(wx, wy, ww, wh)
@item_window.actor = @actor
@item_window.viewport = @viewport
@item_window.help_window = @help_window
@item_window.set_handler(:ok, method(:on_item_ok))
@item_window.set_handler(:cancel, method(:on_item_cancel))
@command_window.skill_window = @item_window
end
#--------------------------------------------------------------------------
# create_cost_windows
#--------------------------------------------------------------------------
def create_cost_windows
@cost_window = Window_LearnSkillCostBack.new(@item_window)
@cost_front = Window_LearnSkillCostFront.new(@item_window, @cost_window)
@cost_window.viewport = @viewport
@cost_front.viewport = @viewport
@cost_front.set_handler(:ok, method(:on_cost_ok))
@cost_front.set_handler(:cancel, method(:on_cost_cancel))
end
#--------------------------------------------------------------------------
# on_item_ok
#--------------------------------------------------------------------------
def on_item_ok
skill = @item_window.item
@cost_window.reveal(skill, @item_window.skill_classes(skill))
@cost_front.reveal(skill, @item_window.skill_classes(skill), @actor)
end
#--------------------------------------------------------------------------
# on_cost_ok
#--------------------------------------------------------------------------
def on_cost_ok
Sound.play_use_skill
skill = @item_window.item
@actor.learn_skill(skill.id)
cost = skill.learn_cost[0]
case skill.learn_cost[1]
when :jp
@actor.lose_jp(cost, @cost_front.skill_class)
when :exp
@actor.lose_exp_class(cost, @cost_front.skill_class)
when :gold
$game_party.lose_gold(cost)
end
on_cost_cancel
refresh_windows
end
#--------------------------------------------------------------------------
# on_cost_cancel
#--------------------------------------------------------------------------
def on_cost_cancel
@cost_front.close
@cost_window.close
@item_window.activate
end
#--------------------------------------------------------------------------
# refresh_windows
#--------------------------------------------------------------------------
def refresh_windows
@item_window.refresh
@status_window.refresh
end
end # Scene_LearnSkill
#==============================================================================
#
# ▼ End of File
#
#==============================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment