#============================================================================== # # GaryCXJk - Class Extensions v1.07 # * Last Updated: 2012.01.09 # * Level: Normal # * Requires: YEA - Class System v1.10+ # * Optional: YEA - Class Specifics v1.00+ # YEA - Learn Skill Engine v1.00+ # CXJ - AnimEx v1.01+ # #============================================================================== $imported = {} if $imported.nil? $imported["CXJ-ClassExtensions"] = true #============================================================================== # # Changelog: # #------------------------------------------------------------------------------ # 2013.01.09 - v1.07 # # * Added: Subclass traits # * Added: Option to 'hybridize' classes # #------------------------------------------------------------------------------ # 2013.01.08 - v1.06 # # * Added: Fix for parameter using main level instead of class level # * Fixed: Regular expression mistakes # #------------------------------------------------------------------------------ # 2013.01.06 - v1.05 # # * Added: Learning Skill Engine addon # * Added: Ability to change class experience rate # * Added: Experience distribution to subclasses # * Fixed: Class level not appearing # #------------------------------------------------------------------------------ # 2013.01.05 - v1.04 # # * Added: AnimEx compatibility # * Added: Subclass learning # * Added: Skill learning when all classes defined have certain level # * Fixed: Overlooked mistakes # * Fixed: Errors in graphics picking # #------------------------------------------------------------------------------ # 2013.01.01 - v1.03 # # * Fixed: Wrong calculation of class level # #------------------------------------------------------------------------------ # 2012.12.31 - v1.02 # # * Fixed: Player sprite not changing # #------------------------------------------------------------------------------ # 2012.12.31 - v1.01 # # * Added: Ability to hide classes that are unavailable for primary or subclass # (requires Class Specifics) # * Fixed: Some errors # #------------------------------------------------------------------------------ # 2012.12.31 - v1.00 # # * Initial release # #============================================================================== # # Yanfly's Class System is a very solid script, but it is missing a few small # things. This scripts adds just the little things it is missing. # # Some ideas came from members from the community. haothehare gave me the idea # to start this entire project with the level limiter. Both haothehare and # Titanhex gave me the idea for class-specific graphics. Crossroads gave me # some good ideas for compatibility with the Learn Skill Engine. thedrifter148 # came with the idea of hybridizing classes. # #============================================================================== # # Installation: # # Make sure to put this below Materials, but above Main Process. # # This script overrides several methods. If you are sure no method that is # used by other scripts get overridden, you can place it anywhere, otherwise, # make sure this script is loaded first. Do know that there is a possibility # that this script will stop working due to that. # # This script adds aliases for several methods. If you are sure no method that # is used by other scripts get overridden, you can place it anywhere, # otherwise, make sure this script is loaded after any other script overriding # these methods, otherwise this script stops working. # # This script requires another script to run. Put this script after the # required scripts to make it work properly. # # This script has additional functionality and / or compatibility with other # scripts. In order to benifit the most out of it, it is advised to place this # script after the others. # #------------------------------------------------------------------------------ # Overridden methods: # # * class Game_Actor # - class_level(class_id) (from Class System) # - level_up # * class Window_ClassList (from Class System) # - make_item_list # #------------------------------------------------------------------------------ # Aliased methods: # # * module DataManager # - load_database # * class Game_Actor # - gain_exp(exp) # - change_exp(exp, show) # - feature_objects # * class Window_ClassList (from Class System) # - set_item_colour # * class Window_LearnSkillList (from Learn Skill Engine) # - meet_requirements?(item) # #============================================================================== # # Usage: # # There are various functionalities in this script. You can enable and disable # them by specifying it in the script. I'll go through them one at a time. # #------------------------------------------------------------------------------ # Class Level Limiter: # # This allows you to limit the class level cap. This means that classes will # never go over the level cap you specified. You can also specify a limit # for a specific class using notetags. # # # #------------------------------------------------------------------------------ # Skill Unlock by Class Level: # # Normally when you level up, regardless of the class level you will unlock # skills based on your current actor's level. In order to change that, add # the following to the skill learning notetag: # # # # This will pick the level based on several things: # - If YEA::CLASS_SYSTEM::MAINTAIN_LEVELS is set to true, use the actor's # level; # - If CXJ::CLASS_EXTENSION::SWITCH_MAIN_LEVEL is set to true, use the class # level when not set, otherwise use main level; # - Use main level when not set, otherwise use class level. # # You can also directly set the class levels in the skills, which has the # added bonus that you can assign multiple class level requirements for one # skill. You use the same syntax as that of the Class Unlock Level script. # # # class x: level y # class x: level y # # # When Learn Skill Engine is installed, you can also assign multiple classes # to skills that could be learned using this engine. Skills can only be # learned if all classes have reached a certain level, and will appear in # all classes, unless specified. # # # class x: level y # class x: level y[ exclude] # # # When exclude is added to the end, a skill will not appear in the skill # learning list of that class. # #------------------------------------------------------------------------------ # Experience: # # You can change experience rate and experience distribution. Changing the # experience rate is the same as modifying the experience learning curve, # except you'll earn lower experience instead of having to earn more # experience. This especially can be handy when skills that can be learned # using the Learn Skill Engine use experience. # # # # # As a standard, the experience rate is 1.00, or 100%. You can use operators # to modify the experience accordingly. For example, if the new rate is -10%, # the rate will change to 90%. # # The same can be used for the subclass experience distribution. There are two # modes. Either the main class experience remains unaffected or it will share # its experience with the subclass. You can enable or disable it by using the # following notetag: # # # # # When set to off, subclasses will still earn experience, but it will not # affect main classes. You can also set the default in the script. # # Finally, you can set the subclass experience ratio by using the following: # # # # #------------------------------------------------------------------------------ # Class Graphics: # # If you want classes to have generic appearances, or if you want an actor to # have a specific graphics set when using a certain class. # # You can set a generic class graphics set, which is a set of data which # specifies the default class graphic. You can specify multiple sets here. It # defaults to the "DEFAULT" set, but you can use a notetag on the actor to # specify a specific graphics set. # # # # Where x is the string defining the graphics set. # # By default, you can set all classes to either opt in or opt out. What this # means is that you can specify if actor uses the generic set or not, depending # on the settings. If an actor opts in, it means that it will use the generic # set, otherwise it doesn't. You can set the default settings in the script, # but using notetags you can also specify it per actor. # # # # # You can also set a class specific graphic for the actor itself. # # # # # x: the class id. # y: the character / face image. # z: the index. # # Finally, on the classes themselves you can specify a default graphic. # Depending on the script settings, these will have priority over the default # settings. # # # # # x: the character / face image. # y: the index. # #------------------------------------------------------------------------------ # AnimEx compatibility: # # This script has compatibility modifications for AnimEx, so that both scripts # can be used. You will have to add whether they have diagonal sprites or not # if the sprite doesn't have eight or nine animation rows. # #============================================================================== # # License: # # Creative Commons Attribution 3.0 Unported # # The complete license can be read here: # http://creativecommons.org/licenses/by/3.0/legalcode # # The license as it is described below can be read here: # http://creativecommons.org/licenses/by/3.0/deed # # You are free: # # to Share — to copy, distribute and transmit the work # to Remix — to adapt the work # to make commercial use of the work # # Under the following conditions: # # Attribution — You must attribute the work in the manner specified by the # author or licensor (but not in any way that suggests that they endorse you or # your use of the work). # # With the understanding that: # # Waiver — Any of the above conditions can be waived if you get permission from # the copyright holder. # # Public Domain — Where the work or any of its elements is in the public domain # under applicable law, that status is in no way affected by the license. # # Other Rights — In no way are any of the following rights affected by the # license: # # * Your fair dealing or fair use rights, or other applicable copyright # exceptions and limitations; # * The author's moral rights; # * Rights other persons may have either in the work itself or in how the work # is used, such as publicity or privacy rights. # # Notice — For any reuse or distribution, you must make clear to others the # license terms of this work. The best way to do this is with a link to this # web page. # #------------------------------------------------------------------------------ # Extra notes: # # Despite what the license tells you, I will not hunt down anybody who doesn't # follow the license in regards to giving credits. However, as it is common # courtesy to actually do give credits, it is recommended that you do. # # As I picked this license, you are free to share this script through any # means, which includes hosting it on your own website, selling it on eBay and # hang it in the bathroom as toilet paper. Well, not selling it on eBay, that's # a dick move, but you are still free to redistribute the work. # # Yes, this license means that you can use it for both non-commercial as well # as commercial software. # # You are free to pick the following names when you give credit: # # * GaryCXJk # * Gary A.M. Kertopermono # * G.A.M. Kertopermono # * GARYCXJK # # Personally, when used in commercial games, I prefer you would use the second # option. Not only will it actually give me more name recognition in real # life, which also works well for my portfolio, it will also look more # professional. Also, do note that I actually care about capitalization if you # decide to use my username, meaning, capital C, capital X, capital J, lower # case k. Yes, it might seem stupid, but it's one thing I absolutely care # about. # # Finally, if you want my endorsement for your product, if it's good enough # and I have the game in my posession, I might endorse it. Do note that if you # give me the game for free, it will not affect my opinion of the game. It # would be nice, but if I really did care for the game I'd actually purchase # it. Remember, the best way to get any satisfaction is if you get people to # purchase the game, so in a way, I prefer it if you don't actually give me # a free copy. # # This script was originally hosted on: # http://area91.multiverseworks.com # # Don't forget to include the credits of the original script as well. # #============================================================================== # # The code below defines the settings of this script, and are there to be # modified. # #============================================================================== module CXJ module CLASS_EXTENSIONS #------------------------------------------------------------------------ # Class Level Limiter #------------------------------------------------------------------------ ENABLE_CLASS_LEVEL_LIMITER = true # Defines if you want to limit # class levels DEFAULT_MAX_LEV = 99 # Defines the max level STOP_GAINING_EXP_AFTER_MAX = true # Stops experience gain after # hitting the level cap STOP_LEVELING_AFTER_CLASS_MAX = true # Stops leveling main character # after hitting the experience # cap. #------------------------------------------------------------------------ # Generic Class Graphics #------------------------------------------------------------------------ # When you set these, all characters will use this list as their initial # graphics. You can pick between an opt-in or opt-out. When you pick # opt-in, characters won't use these generic class graphics unless they # chose to, otherwise they will always use these generic class graphics # unless either the character has set their custom graphics or they opt # out. # # Also, notetags specified in the database have priority over this list, # meaning that any class that has a custom class graphic set in the # notetags will have that as the generic class graphic. You can however # change it below to have generic class graphics have priority instead. # # Finally, when the graphics for a certain class isn't set here, it will # always default to the default character graphics. #------------------------------------------------------------------------ ENABLE_CLASS_SPECIFIC_GRAPHICS = true # Defines whether to use class # specific graphics. OPT_IN_CLASS_GRAPHICS = false # Defines if you want to opt in. CLASS_SPECIFIED_HAS_PRIORITY = true # Graphics defined in class # notetags have priority. GENERIC_CLASS_GRAPHICS = {} GENERIC_CLASS_GRAPHICS["DEFAULT"] = { # ClassID => [ CharacterName, CharacterIndex, FaceName, FaceIndex ], 1 => [ "Actor1", 0, "Actor1", 0 ], 3 => [ "Actor4", 2, "Actor4", 2 ], } #------------------------------------------------------------------------ # Miscellaneous #------------------------------------------------------------------------ # Set the class hiding mode for the class list window. Requires the # Class Specifics addon. # 0: Original # 1: Hide unavailable # 2: Grey out selected in other type CLASS_HIDE_MODE = 2 # When false, actor level is the main level, otherwise, class level is # the main level. SWITCH_MAIN_LEVEL = true # When false, main class experience gain remains normal, when true, # experience gain is reduced when shared with subclass. SPLIT_TO_SUB = false # The base amount of experience gain for subclasses in comparison to the # main class gain. EXP_TO_SUBCLASS = 1.00 # Use class level for parameter calculation. CLASS_LEVEL_PARAMS = true # Checks whether subclasses can set traits or not. SUBCLASS_TRAITS = true # Instead of adding subclass stats, average between the two. HYBRIDIZE = false #------------------------------------------------------------------------ # AnimEx compatibility # Define below #------------------------------------------------------------------------ GENERIC_CLASS_HAS_DIAGONAL = {} GENERIC_CLASS_HAS_DIAGONAL["DEFAULT"] = { # ClassID => HasDiagonal?, 1 => false, 3 => false, } end end #============================================================================== # # The code below should not be altered unless you know what you're doing. # #============================================================================== if $imported["YEA-ClassSystem"] module CXJ module REGEXP module CLASS MAX_LEVEL = /<(?:MAX_LEVEL|max level):\s*(\d+)>/i CHARSET = /<(?:CHARACTER_SET|CHARSET|character set|charset):\s*(.+?)\s*,\s*(\d+)>/i FACESET = /<(?:FACE_SET|FACESET|face set|faceset):\s*(.+?)\s*,\s*(\d+)>/i EXP_RATE = /<(?:EXPERIENCE_RATE|experience rate):\s*([\+\-\*]?)(\d+)\%>/i SUB_RATIO = /<(?:SUBCLASS_EXPERIENCE_RATIO|subclass experience ratio):\s*([\+\-\*]?)(\d+)\%>/i EXP_SPLIT = /<(?:SPLIT_EXPERIENCE|split experience) (on|off)>/ # AnimEx compatibility HAS_DIAG = /<(?:SPRITE_HAS_DIAGONAL|sprite has diagonal)>/i end module ACTOR OPT_IN = /<(?:GRAPHICS_OPT_IN|graphics opt) (in|out)>/i GENERICSET = /<(?:GENERIC_SET|generic set):\s*(.+?)>/i CHARSET = /<(?:CHARACTER_SET|CHARSET|character set|charset):\s*(\d+)\s*,\s*(.+?)\s*,\s*(\d+)>/i FACESET = /<(?:FACE_SET|FACESET|face set|faceset):\s*(\d+)\s*,\s*(.+?)\s*,\s*(\d+)>/i # AnimEx compatibility HAS_DIAG = /<(?:SPRITE_HAS_DIAGONAL|sprite has diagonal):\s*(\d+)>/i end module LEARNING USE_OTHER = /<(?:USE_OTHER_LEVEL|use other level)>/i end module SKILL LV_UNLOCK_ON = /<(?:LEVEL_UNLOCK_REQUIREMENTS|level unlock requirements)>/i LV_UNLOCK_OFF = /<\/(?:LEVEL_UNLOCK_REQUIREMENTS|level unlock requirements)>/i LV_LEARN_UNLOCK_ON = /<(?:LEARN_REQUIRE_CLASS_LEVEL|learn require class level)>/i LV_LEARN_UNLOCK_OFF = /<\/(?:LEARN_REQUIRE_CLASS_LEVEL|learn require class level)>/i LV_UNLOCK_STR = /CLASS[ ](\d+): LEVEL[ ](\d+)(?: (EXCLUDE))?/i end end end #============================================================================ # ** DataManager #---------------------------------------------------------------------------- # This module manages the database and game objects. Almost all of the # global variables used by the game are initialized by this module. #============================================================================ module DataManager #------------------------------------------------------------------------ # Alias: load_database #------------------------------------------------------------------------ class < -1 maxExp = self.class.exp_for_level(maxLevel) if !CXJ::CLASS_EXTENSIONS::ENABLE_CLASS_LEVEL_LIMITER || YEA::CLASS_SYSTEM::MAINTAIN_LEVELS game_actor_change_exp_cxj_ce(exp, show) elsif CXJ::CLASS_EXTENSIONS::STOP_GAINING_EXP_AFTER_MAX game_actor_change_exp_cxj_ce([exp, maxExp].min, show) elsif CXJ::CLASS_EXTENSIONS::STOP_LEVELING_AFTER_CLASS_MAX @exp[@class_id] = [exp, 0].max last_level = @level last_skills = skills level_up while !max_level? && self.exp >= next_level_exp && self.exp <= maxExp level_down while self.exp < current_level_exp display_level_up(skills - last_skills) if show && @level > last_level refresh else game_actor_change_exp_cxj_ce(exp, show) end end #-------------------------------------------------------------------------- # * Override: Level Up #-------------------------------------------------------------------------- def level_up @level += 1 maintain = YEA::CLASS_SYSTEM::MAINTAIN_LEVELS self.class.learnings.each do |learning| use_class = (learning.use_other ^ CXJ::CLASS_EXTENSIONS::SWITCH_MAIN_LEVEL) learn_skill(learning.skill_id) if ((maintain || !use_class) && learning.level == @level) || (!maintain && use_class && learning.level == class_level(@class_id)) end $skill_class_unlock.each do |skill| skill_id = $data_skills.index(skill) next if skill_id.nil? || skill_learn?(skill) can_add = true skill.level_unlock.each do |class_id, level| if class_level(class_id) < level can_add = false break end end learn_skill(skill_id) if can_add end return if(self.subclass.nil?) self.subclass.learnings.each do |learning| use_class = (learning.use_other ^ CXJ::CLASS_EXTENSIONS::SWITCH_MAIN_LEVEL) learn_skill(learning.skill_id) if ((maintain || !use_class) && learning.level == @level) || (!maintain && use_class && learning.level == class_level(@subclass_id)) end end #------------------------------------------------------------------------ # Override: New: class_level Edited by DisturbedInside #------------------------------------------------------------------------ def class_level(class_id) return @level if YEA::CLASS_SYSTEM::MAINTAIN_LEVELS current_class = $data_classes[class_id] maxLevel = CXJ::CLASS_EXTENSIONS::DEFAULT_MAX_LEV maxLevel = current_class.max_level if current_class.max_level > -1 maxLevel = max_level if !CXJ::CLASS_EXTENSIONS::ENABLE_CLASS_LEVEL_LIMITER maxExp = current_class.exp_for_level(maxLevel) @exp[class_id] = 0 if @exp[class_id].nil? n = 1 loop do break if maxExp <= current_class.exp_for_level(n) break if @exp[class_id] <= current_class.exp_for_level(n) n+= 1 end return n end #-------------------------------------------------------------------------- # * Alias: Get Array of All Objects Retaining Features #-------------------------------------------------------------------------- alias game_actor_feature_objects_cxj_ce feature_objects def feature_objects obj = game_actor_feature_objects_cxj_ce obj+= [self.subclass] if !self.subclass.nil? && CXJ::CLASS_EXTENSIONS::SUBCLASS_TRAITS obj end end #============================================================================== # ** Game_Player #------------------------------------------------------------------------------ # This class handles the player. It includes event starting determinants and # map scrolling functions. The instance of this class is referenced by # $game_player. #============================================================================== class Game_Player < Game_Character #-------------------------------------------------------------------------- # * New: Refresh #-------------------------------------------------------------------------- def refresh @character_name = actor ? actor.real_character_name : "" @character_index = actor ? actor.real_character_index : 0 @followers.refresh end #------------------------------------------------------------------------ # New: character_name #------------------------------------------------------------------------ def character_name if CXJ::CLASS_EXTENSIONS::ENABLE_CLASS_SPECIFIC_GRAPHICS cname = actor.character_name cind = actor.character_index(@direction) return cname if cname != actor.real_character_name || cind != actor.real_character_index end @character_name end #------------------------------------------------------------------------ # New: character_index #------------------------------------------------------------------------ def character_index if CXJ::CLASS_EXTENSIONS::ENABLE_CLASS_SPECIFIC_GRAPHICS cname = actor.character_name cind = actor.character_index(@direction) return cind if cname != actor.real_character_name || cind != actor.real_character_index end if $imported["CXJ-AnimEx"] super else @character_index end end #------------------------------------------------------------------------ # New: face_name #------------------------------------------------------------------------ def face_name if CXJ::CLASS_EXTENSIONS::ENABLE_CLASS_SPECIFIC_GRAPHICS fname = actor.face_name return fname if fname != actor.real_face_name || actor.face_index != actor.real_face_index end @face_name end #------------------------------------------------------------------------ # New: face_index #------------------------------------------------------------------------ def face_index if CXJ::CLASS_EXTENSIONS::ENABLE_CLASS_SPECIFIC_GRAPHICS fname = actor.face_name return actor.face_index if fname != actor.real_face_name || actor.face_index != actor.real_face_index end @face_index end end if $imported["YEA-ClassSpecifics"] #========================================================================== # ** Window_ClassList #-------------------------------------------------------------------------- # This class handles the class list window #========================================================================== class Window_ClassList < Window_Selectable #---------------------------------------------------------------------- # Override: make_item_list #---------------------------------------------------------------------- def make_item_list @data = [] for class_id in YEA::CLASS_SYSTEM::CLASS_ORDER next if $data_classes[class_id].nil? item = $data_classes[class_id] next if CXJ::CLASS_EXTENSIONS::CLASS_HIDE_MODE == 1 && available?(item) @data.push(item) if include?(item) end end #---------------------------------------------------------------------- # New: Check if available #---------------------------------------------------------------------- def available?(item) case @command_window.current_symbol when :primary return false if item.subclass_only when :subclass return false if item.primary_only return @actor.subclass_to?(item.id) if item.subclass_to != [] end return true end #---------------------------------------------------------------------- # Alias: set_item_colour #---------------------------------------------------------------------- alias window_classlist_set_item_color set_item_colour def set_item_colour(item) if CXJ::CLASS_EXTENSIONS::CLASS_HIDE_MODE == 2 primary_enable = (@command_window.current_symbol == :primary ? item == @actor.class : enable?(item)) subclass_enable = (@command_window.current_symbol == :subclass ? item == @actor.subclass : enable?(item)) if item == @actor.class change_color(text_color(YEA::CLASS_SYSTEM::CURRENT_CLASS_COLOUR), primary_enable) elsif item == @actor.subclass change_color(text_color(YEA::CLASS_SYSTEM::SUBCLASS_COLOUR), subclass_enable) else change_color(normal_color, enable?(item)) end else window_classlist_set_item_color(item) end end end end if $imported["YEA-LearnSkillEngine"] #========================================================================== # ** Window_LearnSkillList #========================================================================== class Window_LearnSkillList < Window_SkillList #---------------------------------------------------------------------- # Alias: meet_requirements? #---------------------------------------------------------------------- alias window_learnskilllist_meet_requirements_cxj_ce? meet_requirements? def meet_requirements?(item) return false unless window_learnskilllist_meet_requirements_cxj_ce? return false unless meet_class_level_requirements?(item) end #-------------------------------------------------------------------------- # New: meet_class_level_requirements? #-------------------------------------------------------------------------- def meet_class_level_requirements?(item) item.level_learn_unlock.each do |class_id, learn_level| return false if @actor.class_level(class_id) < learn_level end return true end end end end