Advertisement
Dragor

YEA - Class System

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