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