Archeia

Yanfly Engine Ace - Class System v1.10

Mar 30th, 2014
530
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Class System v1.10
  4. # -- Last Updated: 2012.01.29
  5. # -- Level: Normal, Hard
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-ClassSystem"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2012.08.06 - Leveling issue if class level exceeds actor level.
  17. # 2012.01.29 - Visual Bug: Disabled classes now have faded icons.
  18. # 2012.01.08 - Compatibility Update: Learn Skill Engine
  19. # 2012.01.05 - Bug Fixed: Equipment no longer gets duplicated.
  20. # 2012.01.04 - Update: Autobattle will no longer use skills not available to
  21. #              that class for specific actors.
  22. # 2012.01.02 - Efficiency Update.
  23. # 2011.12.26 - Added custom command functionality.
  24. # 2011.12.23 - Compatibility Update: Class Specifics.
  25. # 2011.12.22 - Compatibility Update: Ace Menu Engine.
  26. # 2011.12.20 - Compatibility Update: Class Unlock Level.
  27. # 2011.12.19 - Started Script and Finished.
  28. #
  29. #==============================================================================
  30. # ▼ Introduction
  31. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  32. # This script adds the ability for your player to freely change the classes of
  33. # actors outside of battle from a menu. When changing classes, this script
  34. # gives the option for the developer to choose whether or not classes have
  35. # their own levels (causing the actor's level to reset back to the class's
  36. # level) or to maintain the current level. In addition to providing the ability
  37. # to change classes, equipping a subclass is also doable, and the mechanics of
  38. # having a subclass can also be defined within this script.
  39. #
  40. #==============================================================================
  41. # ▼ Instructions
  42. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  43. # To install this script, open up your script editor and copy/paste this script
  44. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  45. #
  46. # -----------------------------------------------------------------------------
  47. # Actor Notetags - These notetags go in the actors notebox in the database.
  48. # -----------------------------------------------------------------------------
  49. # <unlocked classes: x>
  50. # <unlocked classes: x, x>
  51. # This will set the default classes as unlocked for the actor. This does not
  52. # override the default classes unlocked in the module, but instead, adds on
  53. # to the number of unlocked classes.
  54. #
  55. # -----------------------------------------------------------------------------
  56. # Class Notetags - These notetags go in the class notebox in the database.
  57. # -----------------------------------------------------------------------------
  58. # <icon: x>
  59. # Sets the icon representing the class to x.
  60. #
  61. # <help description>
  62. #  string
  63. #  string
  64. # </help description>
  65. # Sets the text used for the help window in the class scene. Multiple lines in
  66. # the notebox will be strung together. Use | for a line break.
  67. #
  68. # -----------------------------------------------------------------------------
  69. # Script Calls - These commands are used with script calls.
  70. # -----------------------------------------------------------------------------
  71. # $game_actors[x].unlock_class(y)
  72. # This allows actor x to unlock class y, making it available for switching in
  73. # and out in the Class scene.
  74. #
  75. # $game_actors[x].remove_class(y)
  76. # This causes actor x to remove class y from being able to switch to and from.
  77. # If the actor is currently class y, the class will not be removed. If the
  78. # actor's current subclass is y, the subclass will be unequipped.
  79. #
  80. #==============================================================================
  81. # ▼ Compatibility
  82. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  83. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  84. # it will run with RPG Maker VX without adjusting.
  85. #
  86. #==============================================================================
  87.  
  88. module YEA
  89.   module CLASS_SYSTEM
  90.    
  91.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  92.     # - General Class Settings -
  93.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  94.     # These are the general settings regarding the whole script. They control
  95.     # various rules and regulations that this script undergoes. These settings
  96.     # will also determine what a subclass can do for a player.
  97.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  98.     CLASS_MENU_TEXT = "Class"  # Text that appears in the Main Menu.
  99.     MAINTAIN_LEVELS = false    # Maintain through all classes. Default: false.
  100.     DEFAULT_UNLOCKS = [ 1, 11, 21, 31]   # Classes unlocked by default.
  101.    
  102.     # The display between a primary class and a subclass when written in a
  103.     # window will appear as such.
  104.     SUBCLASS_TEXT = "%s/%s"
  105.    
  106.     # This adjusts the stat rate inheritance for an actor if an actor has a
  107.     # subclass equipped. If you want to disable this, set the rate to 0.0.
  108.     SUBCLASS_STAT_RATE = 0.20
  109.    
  110.     # This adds subclass skill types to the available skill types usable.
  111.     SUBCLASS_SKILL_TYPES = true
  112.    
  113.     # This adds subclass weapons to equippable weapon types.
  114.     SUBCLASS_WEAPON_TYPES = true
  115.    
  116.     # This adds subclass weapons to equippable armour types.
  117.     SUBCLASS_ARMOUR_TYPES = true
  118.    
  119.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  120.     # - Class Scene Commands -
  121.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  122.     # These settings adjust how the class scene appears. Here, you can adjust
  123.     # the command list and the order at which items appear. These are mostly
  124.     # visual settings. Adjust them as you see fit.
  125.     #
  126.     # -------------------------------------------------------------------------
  127.     # :command         Description
  128.     # -------------------------------------------------------------------------
  129.     # :primary         Allows the player to change the primary class.
  130.     # :subclass        Allows the player to change the subclass.
  131.     #
  132.     # :learn_skill     Requires YEA - Learn Skill Engine
  133.     #
  134.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  135.     COMMANDS =[ # The order at which the menu items are shown.
  136.     # [ :command,   "Display"],
  137.       [ :primary,   "Primary"],
  138.       [:subclass,  "Subclass"],
  139.       [:learn_skill, "Custom"],
  140.     # [ :custom1,   "Custom1"],
  141.     # [ :custom2,   "Custom2"],
  142.     ] # Do not remove this.
  143.    
  144.     #--------------------------------------------------------------------------
  145.     # - Status Class Commands -
  146.     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  147.     # For those who use scripts to that may produce unique effects for the
  148.     # class menu, use this hash to manage the custom commands for the Class
  149.     # Command Window. You can disable certain commands or prevent them from
  150.     # appearing by using switches. If you don't wish to bind them to a switch,
  151.     # set the proper switch to 0 for it to have no impact.
  152.     #--------------------------------------------------------------------------
  153.     CUSTOM_CLASS_COMMANDS ={
  154.     # :command => [EnableSwitch, ShowSwitch, Handler Method,
  155.       :custom1 => [           0,          0, :command_name1],
  156.       :custom2 => [           0,          0, :command_name2],
  157.     } # Do not remove this.
  158.    
  159.     # These settings adjust the colour displays for classes.
  160.     CURRENT_CLASS_COLOUR = 17     # "Window" colour used for current class.
  161.     SUBCLASS_COLOUR      = 4      # "Window" colour used for subclass.
  162.    
  163.     # This adjusts the display for class levels if MAINTAIN_LEVELS is false.
  164.     CLASS_LEVEL     = "LV%s"      # Text display for level.
  165.     LEVEL_FONT_SIZE = 16          # Font size used for level.
  166.    
  167.     # This array sets the order of how classes are ordered in the class listing
  168.     # window. Any class ID's unlisted will not be shown.
  169.     CLASS_ORDER = [41..999, 1..40]
  170.    
  171.     # This adjusts the font size for the Parameters window.
  172.     PARAM_FONT_SIZE = 20
  173.    
  174.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  175.     # - Switch Settings -
  176.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  177.     # These are the switches that govern whether or not certain menu items will
  178.     # appear and/or will be enabled. By binding them to a Switch, you can just
  179.     # set the Switch ON/OFF to show/hide or enable/disable a menu command. If
  180.     # you do not wish to use this feature, set these commands to 0.
  181.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  182.     SWITCH_SHOW_CLASS      = 0    # Switch that shows Class in Main Menu.
  183.     SWITCH_ENABLE_CLASS    = 0    # Switch that enables Class in Main Menu.
  184.     SWITCH_SHOW_PRIMARY    = 0    # Switch that shows Subclass in Class Menu.
  185.     SWITCH_ENABLE_PRIMARY  = 0    # Switch that enables Subclass in Class Menu.
  186.     SWITCH_SHOW_SUBCLASS   = 0    # Switch that shows Subclass in Class Menu.
  187.     SWITCH_ENABLE_SUBCLASS = 0    # Switch that enables Subclass in Class Menu.
  188.    
  189.   end # CLASS_SYSTEM
  190. end # YEA
  191.  
  192. #==============================================================================
  193. # ▼ Editting anything past this point may potentially result in causing
  194. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  195. # halitosis so edit at your own risk.
  196. #==============================================================================
  197.  
  198. module YEA
  199.   module CLASS_SYSTEM
  200.     module_function
  201.     #--------------------------------------------------------------------------
  202.     # convert_integer_array
  203.     #--------------------------------------------------------------------------
  204.     def convert_integer_array(array)
  205.       result = []
  206.       array.each { |i|
  207.         case i
  208.         when Range; result |= i.to_a
  209.         when Integer; result |= [i]
  210.         end }
  211.       return result
  212.     end
  213.     #--------------------------------------------------------------------------
  214.     # converted_contants
  215.     #--------------------------------------------------------------------------
  216.     DEFAULT_UNLOCKS = convert_integer_array(DEFAULT_UNLOCKS)
  217.     CLASS_ORDER = convert_integer_array(CLASS_ORDER)
  218.   end # CLASS_SYSTEM
  219.   module REGEXP
  220.   module ACTOR
  221.    
  222.     UNLOCKED_CLASSES =
  223.       /<(?:UNLOCKED_CLASSES|unlocked classes):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  224.    
  225.   end # ACTOR
  226.   module CLASS
  227.    
  228.     ICON_INDEX = /<(?:ICON_INDEX|icon index|icon):[ ](\d+)>/i
  229.     HELP_DESCRIPTION_ON  = /<(?:HELP_DESCRIPTION|help description)>/i
  230.     HELP_DESCRIPTION_OFF = /<\/(?:HELP_DESCRIPTION|help description)>/i
  231.    
  232.   end # CLASS
  233.   end # REGEXP
  234. end # YEA
  235.  
  236. #==============================================================================
  237. # ■ Switch
  238. #==============================================================================
  239.  
  240. module Switch
  241.  
  242.   #--------------------------------------------------------------------------
  243.   # self.class_show
  244.   #--------------------------------------------------------------------------
  245.   def self.class_show
  246.     return true if YEA::CLASS_SYSTEM::SWITCH_SHOW_CLASS <= 0
  247.     return $game_switches[YEA::CLASS_SYSTEM::SWITCH_SHOW_CLASS]
  248.   end
  249.  
  250.   #--------------------------------------------------------------------------
  251.   # self.class_enable
  252.   #--------------------------------------------------------------------------
  253.   def self.class_enable
  254.     return true if YEA::CLASS_SYSTEM::SWITCH_ENABLE_CLASS <= 0
  255.     return $game_switches[YEA::CLASS_SYSTEM::SWITCH_ENABLE_CLASS]
  256.   end
  257.  
  258.   #--------------------------------------------------------------------------
  259.   # self.primary_show
  260.   #--------------------------------------------------------------------------
  261.   def self.primary_show
  262.     return true if YEA::CLASS_SYSTEM::SWITCH_SHOW_PRIMARY <= 0
  263.     return $game_switches[YEA::CLASS_SYSTEM::SWITCH_SHOW_PRIMARY]
  264.   end
  265.  
  266.   #--------------------------------------------------------------------------
  267.   # self.primary_enable
  268.   #--------------------------------------------------------------------------
  269.   def self.primary_enable
  270.     return true if YEA::CLASS_SYSTEM::SWITCH_ENABLE_PRIMARY <= 0
  271.     return $game_switches[YEA::CLASS_SYSTEM::SWITCH_ENABLE_PRIMARY]
  272.   end
  273.  
  274.   #--------------------------------------------------------------------------
  275.   # self.subclass_show
  276.   #--------------------------------------------------------------------------
  277.   def self.subclass_show
  278.     return true if YEA::CLASS_SYSTEM::SWITCH_SHOW_SUBCLASS <= 0
  279.     return $game_switches[YEA::CLASS_SYSTEM::SWITCH_SHOW_SUBCLASS]
  280.   end
  281.  
  282.   #--------------------------------------------------------------------------
  283.   # self.subclass_enable
  284.   #--------------------------------------------------------------------------
  285.   def self.subclass_enable
  286.     return true if YEA::CLASS_SYSTEM::SWITCH_ENABLE_SUBCLASS <= 0
  287.     return $game_switches[YEA::CLASS_SYSTEM::SWITCH_ENABLE_SUBCLASS]
  288.   end
  289.    
  290. end # Switch
  291.  
  292. #==============================================================================
  293. # ■ Numeric
  294. #==============================================================================
  295.  
  296. class Numeric
  297.  
  298.   #--------------------------------------------------------------------------
  299.   # new method: group_digits
  300.   #--------------------------------------------------------------------------
  301.   unless $imported["YEA-CoreEngine"]
  302.   def group; return self.to_s; end
  303.   end # $imported["YEA-CoreEngine"]
  304.    
  305. end # Numeric
  306.  
  307. #==============================================================================
  308. # ■ DataManager
  309. #==============================================================================
  310.  
  311. module DataManager
  312.  
  313.   #--------------------------------------------------------------------------
  314.   # alias method: load_database
  315.   #--------------------------------------------------------------------------
  316.   class <<self; alias load_database_cs load_database; end
  317.   def self.load_database
  318.     load_database_cs
  319.     load_notetags_cs
  320.   end
  321.  
  322.   #--------------------------------------------------------------------------
  323.   # new method: load_notetags_cs
  324.   #--------------------------------------------------------------------------
  325.   def self.load_notetags_cs
  326.     groups = [$data_actors, $data_classes]
  327.     for group in groups
  328.       for obj in group
  329.         next if obj.nil?
  330.         obj.load_notetags_cs
  331.       end
  332.     end
  333.   end
  334.  
  335. end # DataManager
  336.  
  337. #==============================================================================
  338. # ■ RPG::Actor
  339. #==============================================================================
  340.  
  341. class RPG::Actor < RPG::BaseItem
  342.  
  343.   #--------------------------------------------------------------------------
  344.   # public instance variables
  345.   #--------------------------------------------------------------------------
  346.   attr_accessor :unlocked_classes
  347.  
  348.   #--------------------------------------------------------------------------
  349.   # common cache: load_notetags_cs
  350.   #--------------------------------------------------------------------------
  351.   def load_notetags_cs
  352.     @unlocked_classes = []
  353.     #---
  354.     self.note.split(/[\r\n]+/).each { |line|
  355.       case line
  356.       #---
  357.       when YEA::REGEXP::ACTOR::UNLOCKED_CLASSES
  358.         $1.scan(/\d+/).each { |num|
  359.         @unlocked_classes.push(num.to_i) if num.to_i > 0 }
  360.       #---
  361.       end
  362.     } # self.note.split
  363.     #---
  364.   end
  365.  
  366. end # RPG::Actor
  367.  
  368. #==============================================================================
  369. # ■ RPG::Class
  370. #==============================================================================
  371.  
  372. class RPG::Class < RPG::BaseItem
  373.  
  374.   #--------------------------------------------------------------------------
  375.   # public instance variables
  376.   #--------------------------------------------------------------------------
  377.   attr_accessor :icon_index
  378.  
  379.   #--------------------------------------------------------------------------
  380.   # common cache: load_notetags_cs
  381.   #--------------------------------------------------------------------------
  382.   def load_notetags_cs
  383.     @icon_index = 0
  384.     @help_description_on = false
  385.     #---
  386.     self.note.split(/[\r\n]+/).each { |line|
  387.       case line
  388.       #---
  389.       when YEA::REGEXP::CLASS::ICON_INDEX
  390.         @icon_index = $1.to_i
  391.       #---
  392.       when YEA::REGEXP::CLASS::HELP_DESCRIPTION_ON
  393.         @help_description_on = true
  394.       when YEA::REGEXP::CLASS::HELP_DESCRIPTION_OFF
  395.         @help_description_on = false
  396.       #---
  397.       else
  398.         @description += line.to_s if @help_description_on
  399.       end
  400.     } # self.note.split
  401.     #---
  402.     @description.gsub!(/[|]/i) { "\n" }
  403.   end
  404.  
  405. end # RPG::Class
  406.  
  407. #==============================================================================
  408. # ■ Game_Temp
  409. #==============================================================================
  410.  
  411. class Game_Temp
  412.  
  413.   #--------------------------------------------------------------------------
  414.   # public instance variables
  415.   #--------------------------------------------------------------------------
  416.   attr_accessor :scene_class_index
  417.   attr_accessor :scene_class_oy
  418.  
  419. end # Game_Temp
  420.  
  421. #==============================================================================
  422. # ■ Game_Action
  423. #==============================================================================
  424.  
  425. class Game_Action
  426.  
  427.   #--------------------------------------------------------------------------
  428.   # alias method: valid?
  429.   #--------------------------------------------------------------------------
  430.   alias game_action_valid_cs valid?
  431.   def valid?
  432.     return false if check_auto_battle_class
  433.     return game_action_valid_cs
  434.   end
  435.  
  436.   #--------------------------------------------------------------------------
  437.   # new method: check_auto_battle_class
  438.   #--------------------------------------------------------------------------
  439.   def check_auto_battle_class
  440.     return false unless subject.actor?
  441.     return false unless subject.auto_battle?
  442.     return false if item.nil?
  443.     return false if subject.added_skill_types.include?(item.stype_id)
  444.     return false if item.id == subject.attack_skill_id
  445.     return true
  446.   end
  447.  
  448. end # Game_Action
  449.  
  450. #==============================================================================
  451. # ■ Game_BattlerBase
  452. #==============================================================================
  453.  
  454. class Game_BattlerBase
  455.  
  456.   #--------------------------------------------------------------------------
  457.   # public instance variables
  458.   #--------------------------------------------------------------------------
  459.   attr_accessor :temp_flag
  460.  
  461.   #--------------------------------------------------------------------------
  462.   # alias method: added_skill_types
  463.   #--------------------------------------------------------------------------
  464.   alias game_battlerbase_added_skill_types_cs added_skill_types
  465.   def added_skill_types
  466.     result = game_battlerbase_added_skill_types_cs
  467.     result |= subclass_skill_types
  468.     return result
  469.   end
  470.  
  471.   #--------------------------------------------------------------------------
  472.   # new method: subclass_skill_types
  473.   #--------------------------------------------------------------------------
  474.   def subclass_skill_types; return []; end
  475.  
  476.   #--------------------------------------------------------------------------
  477.   # alias method: equip_wtype_ok?
  478.   #--------------------------------------------------------------------------
  479.   alias game_battlerbase_equip_wtype_ok_cs equip_wtype_ok?
  480.   def equip_wtype_ok?(wtype_id)
  481.     return true if subclass_equip_wtype?(wtype_id)
  482.     return game_battlerbase_equip_wtype_ok_cs(wtype_id)
  483.   end
  484.  
  485.   #--------------------------------------------------------------------------
  486.   # new method: subclass_equip_wtype?
  487.   #--------------------------------------------------------------------------
  488.   def subclass_equip_wtype?(wtype_id); return false; end
  489.  
  490.   #--------------------------------------------------------------------------
  491.   # alias method: equip_atype_ok?
  492.   #--------------------------------------------------------------------------
  493.   alias game_battlerbase_equip_atype_ok_cs equip_atype_ok?
  494.   def equip_atype_ok?(atype_id)
  495.     return true if subclass_equip_atype?(atype_id)
  496.     return game_battlerbase_equip_atype_ok_cs(atype_id)
  497.   end
  498.  
  499.   #--------------------------------------------------------------------------
  500.   # new method: subclass_equip_atype?
  501.   #--------------------------------------------------------------------------
  502.   def subclass_equip_atype?(atype_id); return false; end
  503.  
  504. end # Game_BattlerBase
  505.  
  506. #==============================================================================
  507. # ■ Game_Actor
  508. #==============================================================================
  509.  
  510. class Game_Actor < Game_Battler
  511.  
  512.   #--------------------------------------------------------------------------
  513.   # alias method: setup
  514.   #--------------------------------------------------------------------------
  515.   alias game_actor_setup_cs setup
  516.   def setup(actor_id)
  517.     game_actor_setup_cs(actor_id)
  518.     init_unlocked_classes
  519.     init_subclass
  520.   end
  521.  
  522.   #--------------------------------------------------------------------------
  523.   # new method: init_unlocked_classes
  524.   #--------------------------------------------------------------------------
  525.   def init_unlocked_classes
  526.     @unlocked_classes = actor.unlocked_classes.clone
  527.     @unlocked_classes.push(@class_id) if !@unlocked_classes.include?(@class_id)
  528.     @unlocked_classes.sort!
  529.   end
  530.  
  531.   #--------------------------------------------------------------------------
  532.   # new method: init_subclass
  533.   #--------------------------------------------------------------------------
  534.   def init_subclass
  535.     @subclass_id = 0
  536.   end
  537.  
  538.   #--------------------------------------------------------------------------
  539.   # new method: unlocked_classes
  540.   #--------------------------------------------------------------------------
  541.   def unlocked_classes
  542.     init_unlocked_classes if @unlocked_classes.nil?
  543.     return @unlocked_classes
  544.   end
  545.  
  546.   #--------------------------------------------------------------------------
  547.   # new method: unlock_class
  548.   #--------------------------------------------------------------------------
  549.   def unlock_class(class_id)
  550.     init_unlocked_classes if @unlocked_classes.nil?
  551.     return if @unlocked_classes.include?(class_id)
  552.     @unlocked_classes.push(class_id)
  553.     learn_class_skills(class_id)
  554.   end
  555.  
  556.   #--------------------------------------------------------------------------
  557.   # new method: remove_class
  558.   #--------------------------------------------------------------------------
  559.   def remove_class(class_id)
  560.     init_unlocked_classes if @unlocked_classes.nil?
  561.     return if class_id == @class_id
  562.     @unlocked_classes.delete(class_id)
  563.     @subclass_id = 0 if class_id == @subclass_id
  564.     refresh
  565.   end
  566.  
  567.   #--------------------------------------------------------------------------
  568.   # new method: subclass
  569.   #--------------------------------------------------------------------------
  570.   def subclass
  571.     init_subclass if @subclass_id.nil?
  572.     return $data_classes[@subclass_id]
  573.   end
  574.  
  575.   #--------------------------------------------------------------------------
  576.   # alias method: change_class
  577.   #--------------------------------------------------------------------------
  578.   alias game_actor_change_class_cs change_class
  579.   def change_class(class_id, keep_exp = false)
  580.     @subclass_id = 0 if @subclass_id == class_id
  581.     game_actor_change_class_cs(class_id, keep_exp)
  582.     learn_class_skills(class_id)
  583.     unlock_class(class_id)
  584.   end
  585.  
  586.   #--------------------------------------------------------------------------
  587.   # new method: learn_class_skills
  588.   #--------------------------------------------------------------------------
  589.   def learn_class_skills(class_id)
  590.     return if class_id <= 0
  591.     return if $data_classes[class_id].nil?
  592.     $data_classes[class_id].learnings.each do |learning|
  593.       learn_skill(learning.skill_id) if learning.level == class_level(class_id)
  594.     end
  595.   end
  596.  
  597.   #--------------------------------------------------------------------------
  598.   # new method: change_subclass
  599.   #--------------------------------------------------------------------------
  600.   def change_subclass(class_id)
  601.     return if class_id == @class_id
  602.     unlock_class(class_id)
  603.     @subclass_id = @subclass_id == class_id ? 0 : class_id
  604.     learn_class_skills(@subclass_id)
  605.     refresh
  606.   end
  607.     #————————————————————————–
  608.     # new method: class_level Edited by DisturbedInside
  609.     #————————————————————————–
  610.     def class_level(class_id)
  611.         return @level if YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
  612.             temp_class = $data_classes[class_id]
  613.             @exp[class_id] = 0 if @exp[class_id].nil?
  614.             #declare a max level (using EXP)
  615.             #If you can’t find it, go to the class database and select exp curve
  616.             #then switch view to total at the top
  617.             @exp[max_level] = 2547133 #This is the value to change. It declares a max level
  618.             #You need to calculate how much exp for max level
  619.             #Do it manually if using Yanfly-Adjusting Limits
  620.             #To calculate max level exp if using Yanfly-adjusting limits is all math!!
  621.  
  622.             # Level 99 = 2547133
  623.             # to calculate past there…. have to add on multiples of 50744
  624.             # Level 110 = 3156061
  625.             # To go from 99 -> 110 have to add on 12 multiples of 50744.
  626.             n = 1          
  627.             loop do
  628.                 break if temp_class.exp_for_level(n+1) > @exp[class_id]
  629.                 n += 1
  630.                 #add a restriction to “kick out” of loop if exp exceeds max level exp
  631.                 break if temp_class.exp_for_level(n+1) > @exp[max_level]
  632.             end
  633.         return n
  634.     end
  635.  
  636.   #--------------------------------------------------------------------------
  637.   # new method: subclass_level
  638.   #--------------------------------------------------------------------------
  639.   def subclass_level
  640.     return 0 if @subclass_id == 0
  641.     return @level if YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
  642.     return class_level(@subclass_id)
  643.   end
  644.  
  645.   #--------------------------------------------------------------------------
  646.   # alias method: param_base
  647.   #--------------------------------------------------------------------------
  648.   alias game_actor_param_base_cs param_base
  649.   def param_base(param_id)
  650.     result = game_actor_param_base_cs(param_id)
  651.     unless subclass.nil?
  652.       subclass_rate = YEA::CLASS_SYSTEM::SUBCLASS_STAT_RATE
  653.       slevel = subclass_level
  654.       result += subclass.params[param_id, slevel] * subclass_rate
  655.     end
  656.     return result.to_i
  657.   end
  658.  
  659.   #--------------------------------------------------------------------------
  660.   # new method: subclass_skill_types
  661.   #--------------------------------------------------------------------------
  662.   def subclass_skill_types
  663.     return [] unless YEA::CLASS_SYSTEM::SUBCLASS_SKILL_TYPES
  664.     return [] if subclass.nil?
  665.     array = []
  666.     for feature in subclass.features
  667.       next unless feature.code == FEATURE_STYPE_ADD
  668.       next if features_set(FEATURE_STYPE_ADD).include?(feature.data_id)
  669.       array.push(feature.data_id)
  670.     end
  671.     return array
  672.   end
  673.  
  674.   #--------------------------------------------------------------------------
  675.   # new method: subclass_equip_wtype?
  676.   #--------------------------------------------------------------------------
  677.   def subclass_equip_wtype?(wtype_id)
  678.     return false unless YEA::CLASS_SYSTEM::SUBCLASS_WEAPON_TYPES
  679.     return false if subclass.nil?
  680.     for feature in subclass.features
  681.       next unless feature.code == FEATURE_EQUIP_WTYPE
  682.       return true if wtype_id == feature.data_id
  683.     end
  684.     return super
  685.   end
  686.  
  687.   #--------------------------------------------------------------------------
  688.   # new method: subclass_equip_atype?
  689.   #--------------------------------------------------------------------------
  690.   def subclass_equip_atype?(atype_id)
  691.     return false unless YEA::CLASS_SYSTEM::SUBCLASS_ARMOUR_TYPES
  692.     return false if subclass.nil?
  693.     for feature in subclass.features
  694.       next unless feature.code == FEATURE_EQUIP_ATYPE
  695.       return true if atype_id == feature.data_id
  696.     end
  697.     return super
  698.   end
  699.  
  700.   #--------------------------------------------------------------------------
  701.   # alias method: release_unequippable_items
  702.   #--------------------------------------------------------------------------
  703.   alias game_actor_release_unequippable_items_cs release_unequippable_items
  704.   def release_unequippable_items(item_gain = true)
  705.     item_gain = false if @temp_flag
  706.     game_actor_release_unequippable_items_cs(item_gain)
  707.   end
  708.  
  709. end # Game_Actor
  710.  
  711. #==============================================================================
  712. # ■ Game_Interpreter
  713. #==============================================================================
  714.  
  715. class Game_Interpreter
  716.  
  717.   #--------------------------------------------------------------------------
  718.   # overwrite method: command_321
  719.   #--------------------------------------------------------------------------
  720.   def command_321
  721.     actor = $game_actors[@params[0]]
  722.     if actor && $data_classes[@params[1]]
  723.       maintain = YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
  724.       actor.change_class(@params[1], maintain)
  725.     end
  726.   end
  727.  
  728. end # Game_Interpreter
  729.  
  730. #==============================================================================
  731. # ■ Window_Base
  732. #==============================================================================
  733.  
  734. class Window_Base < Window
  735.  
  736.   #--------------------------------------------------------------------------
  737.   # overwrite method: draw_actor_class
  738.   #--------------------------------------------------------------------------
  739.   def draw_actor_class(actor, x, y, width = 112)
  740.     change_color(normal_color)
  741.     if actor.subclass.nil?
  742.       text = actor.class.name
  743.     else
  744.       fmt = YEA::CLASS_SYSTEM::SUBCLASS_TEXT
  745.       text = sprintf(fmt, actor.class.name, actor.subclass.name)
  746.     end
  747.     draw_text(x, y, width, line_height, text)
  748.   end
  749.  
  750. end # Window_Base
  751.  
  752. #==============================================================================
  753. # ■ Window_MenuCommand
  754. #==============================================================================
  755.  
  756. class Window_MenuCommand < Window_Command
  757.  
  758.   #--------------------------------------------------------------------------
  759.   # alias method: add_formation_command
  760.   #--------------------------------------------------------------------------
  761.   alias window_menucommand_add_formation_command_cs add_formation_command
  762.   def add_formation_command
  763.     add_class_command unless $imported["YEA-AceMenuEngine"]
  764.     window_menucommand_add_formation_command_cs
  765.   end
  766.  
  767.   #--------------------------------------------------------------------------
  768.   # new method: add_class_command
  769.   #--------------------------------------------------------------------------
  770.   def add_class_command
  771.     return unless Switch.class_show
  772.     text = YEA::CLASS_SYSTEM::CLASS_MENU_TEXT
  773.     add_command(text, :class, Switch.class_enable)
  774.   end
  775.  
  776. end # Window_MenuCommand
  777.  
  778. #==============================================================================
  779. # ■ Window_ClassCommand
  780. #==============================================================================
  781.  
  782. class Window_ClassCommand < Window_Command
  783.  
  784.   #--------------------------------------------------------------------------
  785.   # initialize
  786.   #--------------------------------------------------------------------------
  787.   def initialize(x, y)
  788.     super(x, y)
  789.     @actor = nil
  790.   end
  791.  
  792.   #--------------------------------------------------------------------------
  793.   # ● ウィンドウ幅の取得
  794.   #--------------------------------------------------------------------------
  795.   def window_width; return 160; end
  796.  
  797.   #--------------------------------------------------------------------------
  798.   # actor=
  799.   #--------------------------------------------------------------------------
  800.   def actor=(actor)
  801.     return if @actor == actor
  802.     @actor = actor
  803.     refresh
  804.   end
  805.  
  806.   #--------------------------------------------------------------------------
  807.   # item_window=
  808.   #--------------------------------------------------------------------------
  809.   def item_window=(window)
  810.     @item_window = window
  811.   end
  812.  
  813.   #--------------------------------------------------------------------------
  814.   # visible_line_number
  815.   #--------------------------------------------------------------------------
  816.   def visible_line_number; return 4; end
  817.  
  818.   #--------------------------------------------------------------------------
  819.   # make_command_list
  820.   #--------------------------------------------------------------------------
  821.   def make_command_list
  822.     return if @actor.nil?
  823.     for command in YEA::CLASS_SYSTEM::COMMANDS
  824.       case command[0]
  825.       when :primary
  826.         next unless Switch.primary_show
  827.         add_command(command[1], command[0], Switch.primary_enable)
  828.       when :subclass
  829.         next unless Switch.subclass_show
  830.         add_command(command[1], command[0], Switch.subclass_enable)
  831.       when :learn_skill
  832.         next unless $imported["YEA-LearnSkillEngine"]
  833.         add_learn_skill_command
  834.       else
  835.         process_custom_command(command)
  836.       end
  837.     end
  838.     if !$game_temp.scene_class_index.nil?
  839.       select($game_temp.scene_class_index)
  840.       self.oy = $game_temp.scene_class_oy
  841.     end
  842.     $game_temp.scene_class_index = nil
  843.     $game_temp.scene_class_oy = nil
  844.   end
  845.  
  846.   #--------------------------------------------------------------------------
  847.   # process_ok
  848.   #--------------------------------------------------------------------------
  849.   def process_ok
  850.     $game_temp.scene_class_index = index
  851.     $game_temp.scene_class_oy = self.oy
  852.     super
  853.   end
  854.  
  855.   #--------------------------------------------------------------------------
  856.   # process_custom_command
  857.   #--------------------------------------------------------------------------
  858.   def process_custom_command(command)
  859.     return unless YEA::CLASS_SYSTEM::CUSTOM_CLASS_COMMANDS.include?(command[0])
  860.     show = YEA::CLASS_SYSTEM::CUSTOM_CLASS_COMMANDS[command[0]][1]
  861.     continue = show <= 0 ? true : $game_switches[show]
  862.     return unless continue
  863.     text = command[1]
  864.     switch = YEA::CLASS_SYSTEM::CUSTOM_CLASS_COMMANDS[command[0]][0]
  865.     enabled = switch <= 0 ? true : $game_switches[switch]
  866.     add_command(text, command[0], enabled)
  867.   end
  868.  
  869.   #--------------------------------------------------------------------------
  870.   # update
  871.   #--------------------------------------------------------------------------
  872.   def update
  873.     super
  874.     update_visible_windows
  875.   end
  876.  
  877.   #--------------------------------------------------------------------------
  878.   # update_visible_windows
  879.   #--------------------------------------------------------------------------
  880.   def update_visible_windows
  881.     return if @current_index == current_symbol
  882.     @current_index = current_symbol
  883.     @item_window.refresh unless @item_window.nil?
  884.   end
  885.  
  886.   #--------------------------------------------------------------------------
  887.   # add_learn_skill_command
  888.   #--------------------------------------------------------------------------
  889.   def add_learn_skill_command
  890.     return unless Switch.show_learn_skill
  891.     name = YEA::LEARN_SKILL::COMMAND_NAME
  892.     add_command(name, :learn_skill, true)
  893.   end
  894.  
  895. end # Window_ClassCommand
  896.  
  897. #==============================================================================
  898. # ■ Window_ClassStatus
  899. #==============================================================================
  900.  
  901. class Window_ClassStatus < Window_Base
  902.  
  903.   #--------------------------------------------------------------------------
  904.   # initialize
  905.   #--------------------------------------------------------------------------
  906.   def initialize(dx, dy)
  907.     super(dx, dy, window_width, fitting_height(4))
  908.     @actor = nil
  909.   end
  910.  
  911.   #--------------------------------------------------------------------------
  912.   # window_width
  913.   #--------------------------------------------------------------------------
  914.   def window_width; Graphics.width - 160; end
  915.  
  916.   #--------------------------------------------------------------------------
  917.   # actor=
  918.   #--------------------------------------------------------------------------
  919.   def actor=(actor)
  920.     return if @actor == actor
  921.     @actor = actor
  922.     refresh
  923.   end
  924.  
  925.   #--------------------------------------------------------------------------
  926.   # refresh
  927.   #--------------------------------------------------------------------------
  928.   def refresh
  929.     contents.clear
  930.     return if @actor.nil?
  931.     draw_actor_face(@actor, 0, 0)
  932.     draw_actor_simple_status(@actor, 108, line_height / 2)
  933.   end
  934.  
  935. end # Window_ClassStatus
  936.  
  937. #==============================================================================
  938. # ■ Window_ClassParam
  939. #==============================================================================
  940.  
  941. class Window_ClassParam < Window_Base
  942.  
  943.   #--------------------------------------------------------------------------
  944.   # initialize
  945.   #--------------------------------------------------------------------------
  946.   def initialize(dx, dy)
  947.     super(dx, dy, window_width, Graphics.height - dy)
  948.     @actor = nil
  949.     @temp_actor = nil
  950.     refresh
  951.   end
  952.  
  953.   #--------------------------------------------------------------------------
  954.   # window_width
  955.   #--------------------------------------------------------------------------
  956.   def window_width; return Graphics.width * 2 / 5; end
  957.  
  958.   #--------------------------------------------------------------------------
  959.   # actor=
  960.   #--------------------------------------------------------------------------
  961.   def actor=(actor)
  962.     return if @actor == actor
  963.     @actor = actor
  964.     refresh
  965.   end
  966.  
  967.   #--------------------------------------------------------------------------
  968.   # refresh
  969.   #--------------------------------------------------------------------------
  970.   def refresh
  971.     contents.clear
  972.     8.times {|i| draw_item(0, line_height * i, i) }
  973.   end
  974.  
  975.   #--------------------------------------------------------------------------
  976.   # set_temp_actor
  977.   #--------------------------------------------------------------------------
  978.   def set_temp_actor(temp_actor)
  979.     return if @temp_actor == temp_actor
  980.     @temp_actor = temp_actor
  981.     refresh
  982.   end
  983.  
  984.   #--------------------------------------------------------------------------
  985.   # draw_item
  986.   #--------------------------------------------------------------------------
  987.   def draw_item(dx, dy, param_id)
  988.     draw_background_colour(dx, dy)
  989.     draw_param_name(dx + 4, dy, param_id)
  990.     draw_current_param(dx + 4, dy, param_id) if @actor
  991.     drx = (contents.width + 22) / 2
  992.     draw_right_arrow(drx, dy)
  993.     draw_new_param(drx + 22, dy, param_id) if @temp_actor
  994.     reset_font_settings
  995.   end
  996.  
  997.   #--------------------------------------------------------------------------
  998.   # draw_background_colour
  999.   #--------------------------------------------------------------------------
  1000.   def draw_background_colour(dx, dy)
  1001.     colour = Color.new(0, 0, 0, translucent_alpha/2)
  1002.     rect = Rect.new(dx+1, dy+1, contents.width - 2, line_height - 2)
  1003.     contents.fill_rect(rect, colour)
  1004.   end
  1005.  
  1006.   #--------------------------------------------------------------------------
  1007.   # overwrite method: draw_param_name
  1008.   #--------------------------------------------------------------------------
  1009.   def draw_param_name(dx, dy, param_id)
  1010.     contents.font.size = YEA::CLASS_SYSTEM::PARAM_FONT_SIZE
  1011.     change_color(system_color)
  1012.     draw_text(dx, dy, contents.width, line_height, Vocab::param(param_id))
  1013.   end
  1014.  
  1015.   #--------------------------------------------------------------------------
  1016.   # overwrite method: draw_current_param
  1017.   #--------------------------------------------------------------------------
  1018.   def draw_current_param(dx, dy, param_id)
  1019.     change_color(normal_color)
  1020.     dw = (contents.width + 22) / 2
  1021.     draw_text(0, dy, dw, line_height, @actor.param(param_id).group, 2)
  1022.     reset_font_settings
  1023.   end
  1024.  
  1025.   #--------------------------------------------------------------------------
  1026.   # draw_right_arrow
  1027.   #--------------------------------------------------------------------------
  1028.   def draw_right_arrow(x, y)
  1029.     change_color(system_color)
  1030.     draw_text(x, y, 22, line_height, "→", 1)
  1031.   end
  1032.  
  1033.   #--------------------------------------------------------------------------
  1034.   # draw_new_param
  1035.   #--------------------------------------------------------------------------
  1036.   def draw_new_param(dx, dy, param_id)
  1037.     contents.font.size = YEA::CLASS_SYSTEM::PARAM_FONT_SIZE
  1038.     new_value = @temp_actor.param(param_id)
  1039.     change_color(param_change_color(new_value - @actor.param(param_id)))
  1040.     draw_text(0, dy, contents.width-4, line_height, new_value.group, 2)
  1041.     reset_font_settings
  1042.   end
  1043.  
  1044. end # Window_ClassParam
  1045.  
  1046. #==============================================================================
  1047. # ■ Window_ClassList
  1048. #==============================================================================
  1049.  
  1050. class Window_ClassList < Window_Selectable
  1051.  
  1052.   #--------------------------------------------------------------------------
  1053.   # initialize
  1054.   #--------------------------------------------------------------------------
  1055.   def initialize(dx, dy)
  1056.     dw = Graphics.width - (Graphics.width * 2 / 5)
  1057.     dh = Graphics.height - dy
  1058.     super(dx, dy, dw, dh)
  1059.     @actor = nil
  1060.     @command_window = nil
  1061.     @status_window
  1062.     @data = []
  1063.   end
  1064.  
  1065.   #--------------------------------------------------------------------------
  1066.   # actor=
  1067.   #--------------------------------------------------------------------------
  1068.   def actor=(actor)
  1069.     return if @actor == actor
  1070.     @actor = actor
  1071.     @last_item = nil
  1072.     refresh
  1073.     self.oy = 0
  1074.   end
  1075.  
  1076.   #--------------------------------------------------------------------------
  1077.   # command_window=
  1078.   #--------------------------------------------------------------------------
  1079.   def command_window=(command_window)
  1080.     @command_window = command_window
  1081.   end
  1082.  
  1083.   #--------------------------------------------------------------------------
  1084.   # status_window=
  1085.   #--------------------------------------------------------------------------
  1086.   def status_window=(status_window)
  1087.     @status_window = status_window
  1088.   end
  1089.  
  1090.   #--------------------------------------------------------------------------
  1091.   # item_max
  1092.   #--------------------------------------------------------------------------
  1093.   def item_max; return @data ? @data.size : 1; end
  1094.  
  1095.   #--------------------------------------------------------------------------
  1096.   # item
  1097.   #--------------------------------------------------------------------------
  1098.   def item; return @data && index >= 0 ? @data[index] : nil; end
  1099.  
  1100.   #--------------------------------------------------------------------------
  1101.   # current_item_enabled?
  1102.   #--------------------------------------------------------------------------
  1103.   def current_item_enabled?; return enable?(@data[index]); end
  1104.  
  1105.   #--------------------------------------------------------------------------
  1106.   # include?
  1107.   #--------------------------------------------------------------------------
  1108.   def include?(item)
  1109.     return true if YEA::CLASS_SYSTEM::DEFAULT_UNLOCKS.include?(item.id)
  1110.     return @actor.unlocked_classes.include?(item.id)
  1111.   end
  1112.  
  1113.   #--------------------------------------------------------------------------
  1114.   # enable?
  1115.   #--------------------------------------------------------------------------
  1116.   def enable?(item)
  1117.     return false if item == @actor.class
  1118.     return true
  1119.   end
  1120.  
  1121.   #--------------------------------------------------------------------------
  1122.   # make_item_list
  1123.   #--------------------------------------------------------------------------
  1124.   def make_item_list
  1125.     @data = []
  1126.     for class_id in YEA::CLASS_SYSTEM::CLASS_ORDER
  1127.       next if $data_classes[class_id].nil?
  1128.       item = $data_classes[class_id]
  1129.       @data.push(item) if include?(item)
  1130.     end
  1131.   end
  1132.  
  1133.   #--------------------------------------------------------------------------
  1134.   # select_last
  1135.   #--------------------------------------------------------------------------
  1136.   def select_last
  1137.     case @command_window.current_symbol
  1138.     when :primary
  1139.       select(@data.index(@actor.class))
  1140.     when :subclass
  1141.       select(0) if @actor.subclass.nil?
  1142.       select(@data.index(@actor.subclass)) unless @actor.subclass.nil?
  1143.     else
  1144.       select(0)
  1145.     end
  1146.   end
  1147.  
  1148.   #--------------------------------------------------------------------------
  1149.   # draw_item
  1150.   #--------------------------------------------------------------------------
  1151.   def draw_item(index)
  1152.     item = @data[index]
  1153.     return if item.nil?
  1154.     rect = item_rect(index)
  1155.     rect.width -= 4
  1156.     reset_font_settings
  1157.     set_item_colour(item)
  1158.     draw_class_icon(item, rect)
  1159.     draw_class_name(item, rect)
  1160.     draw_class_level(item, rect)
  1161.   end
  1162.  
  1163.   #--------------------------------------------------------------------------
  1164.   # set_item_colour
  1165.   #--------------------------------------------------------------------------
  1166.   def set_item_colour(item)
  1167.     if item == @actor.class
  1168.       change_color(text_color(YEA::CLASS_SYSTEM::CURRENT_CLASS_COLOUR))
  1169.     elsif item == @actor.subclass
  1170.       change_color(text_color(YEA::CLASS_SYSTEM::SUBCLASS_COLOUR))
  1171.     else
  1172.       change_color(normal_color, enable?(item))
  1173.     end
  1174.   end
  1175.  
  1176.   #--------------------------------------------------------------------------
  1177.   # draw_class_icon
  1178.   #--------------------------------------------------------------------------
  1179.   def draw_class_icon(item, rect)
  1180.     icon = item.icon_index
  1181.     draw_icon(icon, rect.x, rect.y, enable?(item))
  1182.   end
  1183.  
  1184.   #--------------------------------------------------------------------------
  1185.   # draw_class_name
  1186.   #--------------------------------------------------------------------------
  1187.   def draw_class_name(item, rect)
  1188.     text = item.name
  1189.     draw_text(24, rect.y, rect.width-24, line_height, text)
  1190.   end
  1191.  
  1192.   #--------------------------------------------------------------------------
  1193.   # draw_class_level
  1194.   #--------------------------------------------------------------------------
  1195.   def draw_class_level(item, rect)
  1196.     return if YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
  1197.     return if @actor.nil?
  1198.     level = @actor.class_level(item.id)
  1199.     contents.font.size = YEA::CLASS_SYSTEM::LEVEL_FONT_SIZE
  1200.     text = sprintf(YEA::CLASS_SYSTEM::CLASS_LEVEL, level.group)
  1201.     draw_text(rect, text, 2)
  1202.   end
  1203.  
  1204.   #--------------------------------------------------------------------------
  1205.   # update_help
  1206.   #--------------------------------------------------------------------------
  1207.   def update_help
  1208.     @help_window.set_item(item)
  1209.     return if @actor.nil?
  1210.     return if @status_window.nil?
  1211.     update_param_window
  1212.   end
  1213.  
  1214.   #--------------------------------------------------------------------------
  1215.   # update_param_window
  1216.   #--------------------------------------------------------------------------
  1217.   def update_param_window
  1218.     return if @last_item == item
  1219.     @last_item = item
  1220.     class_id = item.nil? ? @actor.class_id : item.id
  1221.     temp_actor = Marshal.load(Marshal.dump(@actor))
  1222.     temp_actor.temp_flag = true
  1223.     case @command_window.current_symbol
  1224.     when :primary
  1225.       temp_actor.change_class(class_id, YEA::CLASS_SYSTEM::MAINTAIN_LEVELS)
  1226.     when :subclass
  1227.       temp_actor.change_subclass(class_id)
  1228.     end
  1229.     @status_window.set_temp_actor(temp_actor)
  1230.   end
  1231.  
  1232.   #--------------------------------------------------------------------------
  1233.   # update_class
  1234.   #--------------------------------------------------------------------------
  1235.   def update_class
  1236.     @last_item = nil
  1237.     update_help
  1238.     refresh
  1239.     activate
  1240.   end
  1241.  
  1242.   #--------------------------------------------------------------------------
  1243.   # refresh
  1244.   #--------------------------------------------------------------------------
  1245.   def refresh
  1246.     make_item_list
  1247.     create_contents
  1248.     draw_all_items
  1249.   end
  1250.  
  1251. end # Window_ClassList
  1252.  
  1253. #==============================================================================
  1254. # ■ Scene_Menu
  1255. #==============================================================================
  1256.  
  1257. class Scene_Menu < Scene_MenuBase
  1258.  
  1259.   #--------------------------------------------------------------------------
  1260.   # alias method: create_command_window
  1261.   #--------------------------------------------------------------------------
  1262.   alias scene_menu_create_command_window_cs create_command_window
  1263.   def create_command_window
  1264.     scene_menu_create_command_window_cs
  1265.     @command_window.set_handler(:class, method(:command_personal))
  1266.   end
  1267.  
  1268.   #--------------------------------------------------------------------------
  1269.   # alias method: on_personal_ok
  1270.   #--------------------------------------------------------------------------
  1271.   alias scene_menu_on_personal_ok_cs on_personal_ok
  1272.   def on_personal_ok
  1273.     case @command_window.current_symbol
  1274.     when :class
  1275.       SceneManager.call(Scene_Class)
  1276.     else
  1277.       scene_menu_on_personal_ok_cs
  1278.     end
  1279.   end
  1280.  
  1281. end # Scene_Menu
  1282.  
  1283. #==============================================================================
  1284. # ■ Scene_Class
  1285. #==============================================================================
  1286.  
  1287. class Scene_Class < Scene_MenuBase
  1288.  
  1289.   #--------------------------------------------------------------------------
  1290.   # start
  1291.   #--------------------------------------------------------------------------
  1292.   def start
  1293.     super
  1294.     create_help_window
  1295.     create_command_window
  1296.     create_status_window
  1297.     create_param_window
  1298.     create_item_window
  1299.     relocate_windows
  1300.   end
  1301.  
  1302.   #--------------------------------------------------------------------------
  1303.   # create_command_window
  1304.   #--------------------------------------------------------------------------
  1305.   def create_command_window
  1306.     wy = @help_window.height
  1307.     @command_window = Window_ClassCommand.new(0, wy)
  1308.     @command_window.viewport = @viewport
  1309.     @command_window.help_window = @help_window
  1310.     @command_window.actor = @actor
  1311.     @command_window.set_handler(:cancel,   method(:return_scene))
  1312.     @command_window.set_handler(:primary,  method(:command_class_change))
  1313.     @command_window.set_handler(:subclass, method(:command_class_change))
  1314.     process_custom_class_commands
  1315.     return if $game_party.in_battle
  1316.     @command_window.set_handler(:pagedown, method(:next_actor))
  1317.     @command_window.set_handler(:pageup,   method(:prev_actor))
  1318.     @command_window.set_handler(:learn_skill, method(:command_learn_skill))
  1319.   end
  1320.  
  1321.   #--------------------------------------------------------------------------
  1322.   # process_custom_class_commands
  1323.   #--------------------------------------------------------------------------
  1324.   def process_custom_class_commands
  1325.     for command in YEA::CLASS_SYSTEM::COMMANDS
  1326.       next unless YEA::CLASS_SYSTEM::CUSTOM_CLASS_COMMANDS.include?(command[0])
  1327.       called_method = YEA::CLASS_SYSTEM::CUSTOM_CLASS_COMMANDS[command[0]][2]
  1328.       @command_window.set_handler(command[0], method(called_method))
  1329.     end
  1330.   end
  1331.  
  1332.   #--------------------------------------------------------------------------
  1333.   # create_status_window
  1334.   #--------------------------------------------------------------------------
  1335.   def create_status_window
  1336.     wy = @help_window.height
  1337.     @status_window = Window_ClassStatus.new(@command_window.width, wy)
  1338.     @status_window.viewport = @viewport
  1339.     @status_window.actor = @actor
  1340.   end
  1341.  
  1342.   #--------------------------------------------------------------------------
  1343.   # create_param_window
  1344.   #--------------------------------------------------------------------------
  1345.   def create_param_window
  1346.     dx = Graphics.width - (Graphics.width * 2 / 5)
  1347.     dy = @status_window.y + @status_window.height
  1348.     @param_window = Window_ClassParam.new(dx, dy)
  1349.     @param_window.viewport = @viewport
  1350.     @param_window.actor = @actor
  1351.   end
  1352.  
  1353.   #--------------------------------------------------------------------------
  1354.   # create_item_window
  1355.   #--------------------------------------------------------------------------
  1356.   def create_item_window
  1357.     dy = @status_window.y + @status_window.height
  1358.     @item_window = Window_ClassList.new(0, dy)
  1359.     @item_window.help_window = @help_window
  1360.     @item_window.command_window = @command_window
  1361.     @item_window.status_window = @param_window
  1362.     @item_window.viewport = @viewport
  1363.     @item_window.actor = @actor
  1364.     @command_window.item_window = @item_window
  1365.     @item_window.set_handler(:ok,     method(:on_class_ok))
  1366.     @item_window.set_handler(:cancel, method(:on_class_cancel))
  1367.   end
  1368.  
  1369.   #--------------------------------------------------------------------------
  1370.   # relocate_windows
  1371.   #--------------------------------------------------------------------------
  1372.   def relocate_windows
  1373.     return unless $imported["YEA-AceMenuEngine"]
  1374.     case Menu.help_window_location
  1375.     when 0 # Top
  1376.       @help_window.y = 0
  1377.       @command_window.y = @help_window.height
  1378.       @param_window.y = @command_window.y + @command_window.height
  1379.     when 1 # Middle
  1380.       @command_window.y = 0
  1381.       @help_window.y = @command_window.height
  1382.       @param_window.y = @help_window.y + @help_window.height
  1383.     else # Bottom
  1384.       @command_window.y = 0
  1385.       @param_window.y = @command_window.height
  1386.       @help_window.y = @param_window.y + @param_window.height
  1387.     end
  1388.     @status_window.y = @command_window.y
  1389.     @item_window.y = @param_window.y
  1390.   end
  1391.  
  1392.   #--------------------------------------------------------------------------
  1393.   # on_actor_change
  1394.   #--------------------------------------------------------------------------
  1395.   def on_actor_change
  1396.     @command_window.actor = @actor
  1397.     @status_window.actor = @actor
  1398.     @param_window.actor = @actor
  1399.     @item_window.actor = @actor
  1400.     @command_window.activate
  1401.   end
  1402.  
  1403.   #--------------------------------------------------------------------------
  1404.   # command_class_change
  1405.   #--------------------------------------------------------------------------
  1406.   def command_class_change
  1407.     @item_window.activate
  1408.     @item_window.select_last
  1409.   end
  1410.  
  1411.   #--------------------------------------------------------------------------
  1412.   # on_class_cancel
  1413.   #--------------------------------------------------------------------------
  1414.   def on_class_cancel
  1415.     @item_window.unselect
  1416.     @command_window.activate
  1417.     @param_window.set_temp_actor(nil)
  1418.   end
  1419.  
  1420.   #--------------------------------------------------------------------------
  1421.   # on_class_ok
  1422.   #--------------------------------------------------------------------------
  1423.   def on_class_ok
  1424.     Sound.play_equip
  1425.     class_id = @item_window.item.id
  1426.     maintain = YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
  1427.     hp = @actor.hp * 1.0 / @actor.mhp
  1428.     mp = @actor.mp * 1.0 / [@actor.mmp, 1].max
  1429.     case @command_window.current_symbol
  1430.     when :primary
  1431.       @actor.change_class(class_id, maintain)
  1432.     when :subclass
  1433.       @actor.change_subclass(class_id)
  1434.     else
  1435.       @item_window.activate
  1436.       return
  1437.     end
  1438.     @actor.hp = (@actor.mhp * hp).to_i
  1439.     @actor.mp = (@actor.mmp * mp).to_i
  1440.     @status_window.refresh
  1441.     @item_window.update_class
  1442.   end
  1443.  
  1444.   #--------------------------------------------------------------------------
  1445.   # new method: command_learn_skill
  1446.   #--------------------------------------------------------------------------
  1447.   def command_learn_skill
  1448.     return unless $imported["YEA-LearnSkillEngine"]
  1449.     SceneManager.call(Scene_LearnSkill)
  1450.   end
  1451.  
  1452.   #--------------------------------------------------------------------------
  1453.   # command_name1
  1454.   #--------------------------------------------------------------------------
  1455.   def command_name1
  1456.     # Do nothing.
  1457.   end
  1458.  
  1459.   #--------------------------------------------------------------------------
  1460.   # command_name2
  1461.   #--------------------------------------------------------------------------
  1462.   def command_name2
  1463.     # Do nothing.
  1464.   end
  1465.  
  1466. end # Scene_Class
  1467.  
  1468. #==============================================================================
  1469. #
  1470. # ▼ End of File
  1471. #
  1472. #==============================================================================
RAW Paste Data