Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # Class Switch System
- # Version 1.10
- # By Szyu
- #
- # About:
- # Classify and divide your classes into several levels (tier).
- # Actors can switch their class when they match the requirements for "higher
- # classes". You can also disable classes for actors.
- #
- # Instructions:
- # - Place below "▼ Materials" but above "▼ Main Process".
- # - Classes without the NoteTag ">Tier x" won't be shown in any list
- #
- # How to Use:
- # - ">Tier x" tags a class as "switchable class" that can be accessed through
- # the Class Switch System
- # - ">Pre: x, y, z" tags a class with the required Class IDs, that must have
- # reached a certain level
- # - ">Disabled Actors: x, y, z" tags a class with Actor IDs that are not
- # allowed to switch to the class
- #
- # Requires:
- # - RPG Maker VX Ace
- #
- # Terms of Use:
- # - Free for commercal and non-commercial use. Please list me
- # in the credits to support my work.
- #
- # Pastebin:
- # http://adf.ly/UMYEB
- #
- #==============================================================
- # * Configuration
- #==============================================================
- # Term shown as entry in Menu
- CLASS_SWITCH_TERM = "Class Switch"
- # Access menu in GameMenu
- SCENE_MENU_CSS_ACCESS = true
- # Categories
- CLASS_TIERS = {
- "Warrior" => [1,5,6], # Path 1
- "Cleric" => [2,7,8], # Path 2
- "Archer" => [3,9,10], # Path 3
- "Novice" => [4,11,12], # Path 4
- }
- # Levels at which you can access new Tier
- TIER_SWITCH_LEVEL = [9, 15, 30, 50]
- # At Tier Switch the actors Level will be reset to 1
- SWITCH_LEVEL_RESET = true
- # Keeps all skill when switching class
- KEEP_SKILLS = false
- # Different colors for tier levels
- COLORED_TIER_LEVELS = true
- #=====================================================================
- # Don't edit below this line
- #=====================================================================
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- #==============================================================
- # * Scene_ClassSwitch
- #==============================================================
- class Scene_ClassSwitch < Scene_MenuBase
- def start
- super
- create_actor_status
- create_tier_selection
- create_class_window
- end
- def create_actor_status
- @cstatus_window = Window_ClassStatus.new(@actor)
- end
- def create_tier_selection
- @command_window = Window_ClassTier.new(0,@cstatus_window.height)#,Graphics.width/2,Graphics.height-@cstatus_window.height)
- @command_window.actor = @actor
- @command_window.set_handler(:class, method(:command_class))
- @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
- def create_class_window
- wx = @command_window.width
- wy = @cstatus_window.height
- ww = Graphics.width - @command_window.width
- wh = Graphics.height - wy
- @item_window = Window_ClassSwitch.new(wx, wy, ww, wh)
- @item_window.actor = @actor
- @item_window.viewport = @viewport
- @item_window.set_handler(:ok, method(:on_class_ok))
- @item_window.set_handler(:cancel, method(:on_class_cancel))
- @command_window.class_window = @item_window
- end
- def command_class
- if @item_window.item_max > 0
- @item_window.activate
- @item_window.select(0)
- else
- @command_window.activate
- end
- end
- def on_class_ok
- #switch class
- @actor.change_class(@item_window.item)
- @cstatus_window.refresh
- @item_window.refresh
- @item_window.unselect
- @command_window.activate
- end
- def on_class_cancel
- @item_window.unselect
- @command_window.activate
- end
- def on_actor_change
- @cstatus_window.actor = @actor
- @item_window.actor = @actor
- @cstatus_window.activate
- end
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- #==============================================================
- # * Window_ClassTier
- #==============================================================
- class Window_ClassTier < Window_Command
- attr_reader :skill_window
- def initialize(x, y)
- super(x, y)
- @actor = nil
- end
- def window_width
- return 160
- end
- def actor=(actor)
- return if @actor == actor
- @actor = actor
- refresh
- end
- def visible_line_number
- return 6
- end
- def make_command_list
- return unless @actor
- CLASS_TIERS.each_key do |key|
- add_command(key, :class, true, key)
- end
- end
- def update
- super
- @class_window.tclass_id = current_ext if @class_window
- end
- def class_window=(class_window)
- @class_window = class_window
- update
- end
- end
- #==============================================================
- # * Window_ClassSwitch
- #==============================================================
- class Window_ClassSwitch < Window_Selectable
- def initialize(x, y, width, height)
- super
- @actor = nil
- @tclass_id = nil
- @data = []
- end
- def actor=(actor)
- return if @actor == actor
- @actor = actor
- refresh
- self.oy = 0
- end
- def tclass_id=(tclass_id)
- return if @tclass_id == tclass_id
- @tclass_id = tclass_id
- refresh
- self.oy = 0
- end
- def col_max
- return 1
- end
- def item_max
- @data ? @data.size : 1
- end
- def item
- @data && index >= 0 ? @data[index] : nil
- end
- def current_item_enabled?
- return @data[index] > 0 && @actor.class_id != @data[index]
- end
- def make_item_list
- @data = @tclass_id ? CLASS_TIERS[@tclass_id].select {|cl|
- cl != 0 && $data_classes[cl].tier && !actor_disabled_for_class(cl) && class_matches_requirements?(cl)
- } : []
- end
- def actor_disabled_for_class(id)
- return false if !$data_classes[id].disabled_actors
- return true if $data_classes[id].disabled_actors.include?(@actor.id.to_s)
- end
- def class_matches_requirements?(id)
- return true if @actor.class_exp(id) && @actor.class_exp(id) > 0
- return true if not $data_classes[id].predecessors
- $data_classes[id].predecessors.each do |cl|
- tier = $data_classes[id].tier
- return false if !@actor.class_exp(cl.to_i) ||
- @actor.class_exp(cl.to_i) < $data_classes[cl.to_i].exp_for_level(TIER_SWITCH_LEVEL[(tier <= TIER_SWITCH_LEVEL.size ? tier : TIER_SWITCH_LEVEL.size) - 1])
- end
- return true
- end
- def draw_item(index)
- cl = @data[index]
- if cl
- rect = item_rect(index)
- rect.width -= 4
- if COLORED_TIER_LEVELS && $data_classes[@actor.class_id].tier
- change_color(normal_color) if $data_classes[cl].tier == $data_classes[@actor.class_id].tier
- change_color(hp_gauge_color2) if $data_classes[cl].tier < $data_classes[@actor.class_id].tier
- change_color(tp_gauge_color2) if $data_classes[cl].tier == $data_classes[@actor.class_id].tier+1
- change_color(crisis_color) if $data_classes[cl].tier > $data_classes[@actor.class_id].tier+1
- end
- draw_text(rect,$data_classes[cl].name)
- end
- end
- def refresh
- make_item_list
- create_contents
- draw_all_items
- end
- end
- #==============================================================
- # * Window_ClassStatus
- #==============================================================
- class Window_ClassStatus < Window_Selectable
- def initialize(actor)
- super(0, 0, Graphics.width, line_height * 10+8)
- @actor = actor
- refresh
- activate
- end
- def actor=(actor)
- return if @actor == actor
- @actor = actor
- refresh
- end
- def refresh
- contents.clear
- draw_block1 (line_height * 0)
- draw_horz_line(line_height * 1)
- draw_block2 (line_height * 2)
- draw_horz_line(line_height * 6)
- draw_block3 (line_height * 7)
- end
- def draw_block1(y)
- draw_actor_name(@actor, 4, y)
- draw_actor_class(@actor, 128, y)
- draw_actor_nickname(@actor, 288, y)
- end
- def draw_block2(y)
- draw_actor_face(@actor, 8, y)
- draw_basic_info(136, y)
- draw_exp_info(304, y)
- end
- def draw_block3(y)
- draw_description(4, y)
- end
- def draw_horz_line(y)
- line_y = y + line_height / 2 - 1
- contents.fill_rect(0, line_y, contents_width, 2, line_color)
- end
- def line_color
- color = normal_color
- color.alpha = 48
- color
- end
- def draw_basic_info(x, y)
- draw_actor_level(@actor, x, y + line_height * 0)
- draw_actor_icons(@actor, x, y + line_height * 1)
- draw_actor_hp(@actor, x, y + line_height * 2)
- draw_actor_mp(@actor, x, y + line_height * 3)
- end
- def draw_exp_info(x, y)
- s1 = @actor.max_level? ? "-------" : @actor.exp
- s2 = @actor.max_level? ? "-------" : @actor.next_level_exp - @actor.exp
- s_next = sprintf(Vocab::ExpNext, Vocab::level)
- change_color(system_color)
- draw_text(x, y + line_height * 0, 180, line_height, Vocab::ExpTotal)
- draw_text(x, y + line_height * 2, 180, line_height, s_next)
- change_color(normal_color)
- draw_text(x, y + line_height * 1, 180, line_height, s1, 2)
- draw_text(x, y + line_height * 3, 180, line_height, s2, 2)
- end
- def draw_description(x, y)
- draw_text_ex(x, y, @actor.description)
- end
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- #==============================================================
- # * Actor's Class Levels
- #==============================================================
- class Game_Actor < Game_Battler
- alias :store_class_level :change_class
- def change_class(class_id, keep_exp = false)
- if !KEEP_SKILLS
- self.skills.each do|sk|
- forget_skill(sk.id)
- end
- end
- store_class_level(class_id, !SWITCH_LEVEL_RESET)
- self.class.learnings.each do |learning|
- learn_skill(learning.skill_id) if learning.level == @level
- end
- end
- def class_exp(class_id)
- return @exp[class_id]
- end
- end
- #==============================================================
- # * Add Entry to Menu
- #==============================================================
- class Scene_Menu < Scene_MenuBase
- alias :command_class_switch :create_command_window
- alias :on_personal_ok_class_switch :on_personal_ok
- def create_command_window
- command_class_switch
- @command_window.set_handler(:swclass, method(:command_personal)) if SCENE_MENU_CSS_ACCESS
- end
- def on_personal_ok
- on_personal_ok_class_switch
- if SCENE_MENU_CSS_ACCESS
- case @command_window.current_symbol
- when :swclass
- SceneManager.call(Scene_ClassSwitch)
- end
- end
- end
- end
- #==============================================================
- # * Add Entry to Menu
- #==============================================================
- class Window_MenuCommand < Window_Command
- alias :command_class_switch :add_main_commands
- def add_main_commands
- command_class_switch
- add_command(CLASS_SWITCH_TERM, :swclass, main_commands_enabled) if SCENE_MENU_CSS_ACCESS
- end
- end
- #==============================================================
- # * RPG Class Availability Extension
- #==============================================================
- module RPG
- class Class < BaseItem
- def tier
- self.note.each_line do |line|
- return line.downcase.gsub(/\d+/).to_a[0].to_i if line.downcase.include?(">tier")
- end
- return nil
- end
- def predecessors
- self.note.each_line do |line|
- return line.downcase.gsub(/\d+/).to_a if line.downcase.include?(">pre:")
- end
- return nil
- end
- def disabled_actors
- self.note.each_line do |line|
- return line.downcase.gsub(/\d+/).to_a if line.downcase.include?(">disabled actors:")
- end
- return nil
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement