Hello, I have a problem with the Job Level script. When you gain enough JP to level up a job, it doesn't level up. And trying to force a level up gives the message "undefined method '[]' for nil:NilClass". Does anyone know how to fix this? Thanks!
Here's the script:
Here's the script:
Code:
#==============================================================================# Crystal Engine - Job Levels#------------------------------------------------------------------------------# Current Version: 1.00#==============================================================================$imported = {} if $imported.nil?$imported["CE-JobLevels"] = true=beginin Final Fantasy III, V, and Tactics Jobs had there own levelwith this script I duplicated the systems used in FFT and FFIIIevery job uses jp to level up it although uses the total numberto level up a job use the script call$game_actor[id].level_up_job(levels, class_id)class_id can be left blank and it will use the current class=endif $imported["YEA-JPManager"] # YOU MUST HAVE YEA - JP MANAGER TO USE THIS SCRIPT!module CRYSTAL module JOB_LEVELS FFIII_STYLE = false #In this format you need 100jp to level up every level MAX_LEVEL = 14 #the maximum level a job level can reach MAX_LEVEL_STRING = "Infinite" # Warning! The following causes JP to be given to be given to the subclass # every time jp is given to your primary class, be warry SUBLCASS_GAIN_JP = 0.00 # the rate for JP gain for subclasses 0.00 no JP. # the message used for leveling up a job # Name, Job LEVEL_UP_MESSAGE = "%s gain a Job level for the %s Job" #-------------------------------------------------------------------------- # this is the way job level is diplayed in the menu # 0 = class # 1 = class lv x # 2 = class lv x JP y/z # 3 = class JP x/y #-------------------------------------------------------------------------- DRAW_JOB_LEVEL_STYLE = 2 FFT_STRUCTURE = [] #here you set the jp needed to gain a level FFT_STRUCTURE[1] = 200 FFT_STRUCTURE[2] = 400 FFT_STRUCTURE[3] = 700 FFT_STRUCTURE[4] = 1100 FFT_STRUCTURE[5] = 1600 FFT_STRUCTURE[6] = 2200 FFT_STRUCTURE[7] = 3000 FFT_STRUCTURE[8] = "Infinite" endend#==============================================================================# Editing beyond this point may cause stone, zombie, mist frenzy, and/or toad,# so edit at your own risk.#==============================================================================#==============================================================================# ** Game_Actor#------------------------------------------------------------------------------# This class handles actors. It is used within the Game_Actors class# ($game_actors) and is also referenced from the Game_Party class ($game_party).#==============================================================================class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :jp_total # JP attr_accessor :job_level # Level #-------------------------------------------------------------------------- # * Setup #-------------------------------------------------------------------------- alias job_setup setup def setup(actor_id) job_setup(actor_id) @jp_total = [] @job_level = [] for i in 1..$data_classes.size @job_level[i] = 1 @jp_total[i] = 0 end end #-------------------------------------------------------------------------- # new method: gain_jp #-------------------------------------------------------------------------- def gain_jp(jp, class_id = nil) init_jp if @jp.nil? class_id = @class_id if class_id.nil? @jp[class_id] = 0 if @jp[class_id].nil? @jp_total[class_id] = 0 if @jp[class_id].nil? @jp[class_id] += jp.to_i @jp_total[class_id] += jp.to_i @jp[class_id] = [[@jp[class_id], YEA::JP::MAX_JP].min, 0].max @jp_total[class_id] = [[@jp[class_id], YEA::JP::MAX_JP].min, 0].max @battle_jp_earned = 0 if @battle_jp_earned.nil? && $game_party.in_battle @battle_jp_earned += jp.to_i if $game_party.in_battle if @subclass_id > 0 && class_id = @class_id @jp[@subclass_id] = 0 if @jp[@subclass_id].nil? @jp_total[@subclass_id] = 0 if @jp[@subclass_id].nil? jp = CRYSTAL::JOB_LEVELS::SUBCLASS_GAIN_JP @jp[@subclass_id] += jp.to_i @jp_total[@subclass_id] += jp.to_i @jp[@subclass_id] = [[@jp[@subclass_id], YEA::JP::MAX_JP].min, 0].max @jp_total[@subclass_id] = [[@jp[@subclass_id], YEA::JP::MAX_JP].min, 0].max determine_job_level(@subclass_id) end end #--------------------------------------------------------------------------- # determines if the class can level up #--------------------------------------------------------------------------- def determine_job_level(class_id) if @job_level[class_id] < CRYSTAL::JOB_LEVELS::MAX_LEVEL if CRYSTAL::JOB_LEVELS::FFIII_STYLE if @jp_total[class_id] >= 100 * @job_level[class_id] @job_level[class_id] += 1 end elsif @jp_total[class_id] >= CRYSTAL::JOB_LEVELS::FFT_STRUCTURE[@job_level[class_id]] @job_level[class_id] += 1 end end end #--------------------------------------------------------------------------- # Level_up_a_job #--------------------------------------------------------------------------- def level_up_job(levels, class_id) if @job_level[class_id] < CRYSTAL::JOB_LEVELS::MAX_LEVEL @job_level[class_id] += levels fmt = CRYSTAL::JOB_LEVELS::LEVEL_UP_MESSAGE text = sprintf(fmt, @name, $data_classes[class_id].name) wait_for_message $game_message.add(text) if CRYSTAL::JOB_LEVELS::FFIII_STYLE unless @jp_total[class_id] >= 100 * @job_level[class_id] @jp_total[class_id] = 100 * @job_level[class_id] end else unless @jp_total[class_id] >= CRYSTAL::JOB_LEVELS::FFT_STRUCTURE[@job_level[class_id]] @jp_total[class_id] = CRYSTAL::JOB_LEVELS::FFT_STRUCTURE[@job_level[class_id]] end end end endend#==============================================================================# ** Window_Base#------------------------------------------------------------------------------# This is a super class of all windows within the game.#==============================================================================class Window_Base < Window #-------------------------------------------------------------------------- # * Draw Class #-------------------------------------------------------------------------- def draw_actor_class(actor, x, y, width = 112) change_color(normal_color) case CRYSTAL::JOB_LEVELS::DRAW_JOB_LEVEL_STYLE when 0 string = actor.class.name when 1 string = "#{actor.class.name} Lv #{actor.job_level[actor.class_id]}" when 2 if CRYSTAL::JOB_LEVELS::FFIII_STYLE if actor.job_level[actor.class_id] < CRYSTAL::JOB_LEVELS::MAX_LEVEL jp_needed = 100 * actor.job_level[actor.class_id] else jp_needed = CRYSTAL::JOB_LEVELS::MAX_LEVEL_STRING end else jp_needed = CRYSTAL::JOB_LEVELS::FFT_STRUCTURE[actor.job_level[actor.class_id]] end string = "#{actor.class.name} Lv #{actor.job_level[actor.class_id]} #{YEA::JP::VOCAB} #{actor.jp_total[actor.class_id]}/#{jp_needed}" when 3 string = "#{actor.class.name} #{YEA::JP::VOCAB} #{actor.jp_total[actor.class_id]}/#{jp_needed}" end if $imported["CE-BasicModule"] draw_text(x + CRYSTAL::BASIC::MOVE_CLASS_NAME_OVER, y, width, line_height, string) else draw_text(x, y, width, line_height, string) end endendif $imported["YEA-ClassSystem"]#==============================================================================# ■ Window_ClassList#==============================================================================class Window_ClassList < Window_Selectable #-------------------------------------------------------------------------- # draw_class_level #-------------------------------------------------------------------------- def draw_class_level(item, rect) return if !YEA::CLASS_SYSTEM::MAINTAIN_LEVELS return if @actor.nil? level = @actor.job_level[item.id] contents.font.size = YEA::CLASS_SYSTEM::LEVEL_FONT_SIZE text = sprintf(YEA::CLASS_SYSTEM::CLASS_LEVEL, level.group) draw_text(rect, text, 2) endendendif $imported["YEA-ClassSystem"] && $imported["YEA-ClassUnlockLevel"] && YEA::CLASS_SYSTEM::MAINTAIN_LEVELSclass Game_Actor < Game_Battler #-------------------------------------------------------------------------- # check_level_unlocked_classes #-------------------------------------------------------------------------- def check_level_unlocked_classes for item in $data_classes next if item.nil? next if unlocked_classes.include?(item.id) next if item.level_unlock == {} next unless class_unlock_level_requirements_met?(item) unlock_class(item.id) end end #-------------------------------------------------------------------------- # class_unlock_level_requirements_met? #-------------------------------------------------------------------------- def class_unlock_level_requirements_met?(item) for key in item.level_unlock class_id = key[0] level_req = key[1] return false if class_level(class_id) < level_req end return true endendendelse msgbox("YEA - JP Manager is needed to use this script.") exitend#==============================================================================# # ▼ End of File# #==============================================================================