· 7 years ago · Mar 04, 2019, 08:06 PM
1#==============================================================================
2# ** JobChanger for VX, by Blackmorning
3# last updated 31/07/10 (Version 2.02)
4# Some features taken from tkblackknight, Prexus & Yanfly Job Changers
5# and from Enelvon
6#==============================================================================
7=begin
8********************************************************************************
9Updates
10********************************************************************************
1131/07/10
12- cleaned up a few points, some bugs fixed (higher class levels)
1312/07/10
14- compatible with YEM Battler Stat: RES and Battler Stat: DEX (requested by Kaimi)
1523/06/10
16- change in how skills are forgotten when changing classes
1716/02/10
18- compatible with YEZ Battler Stat: RES and Battler Stat: DEX (requested by sol003)
1918/11/09
20- fixed jp earned during fight (noticed by Slajmboll)
2123/08/09
22- minor visual improvements when no jp is used
2304/08/09
24- when not gaining jp by any means, skills are learnt by actor level (original way)
2528/07/09
26- can make items to add/remove classes
27- fixed class adding and removing from list (now works when reloading)
28- fixed when class level up bonus based on actor's level
2922/07/09
30- bug fix
31# requests by Andrelvis
32- can modify jp needed to go up a level
33- icons can appear next to class in job changer window
3420/07/09
35- level up bonuses can be by either class level or actor level
36- skills fix when initialized actor is higher level
3716/07/09
38- fixed minor issue with custom menus
3914/07/09
40- added check actor class list size
4113/07/09
42- customizable description of class on help window
4330/06/09
44- level up stat bonuses now based on class level.
45( ie. stats increase as class level increases )
4629/06/09
47- compability fix with special classes (ie. OriginalWij sequence skills)
48- issue fixed when regular level up
4928/06/09
50- minor formatting errors cleared up
51- check any actor class level and assign it to a variable
52( good for creating events to add classes )
53- fixed issue with character change
5426/06/09
55- skill window help opacity 255
56- item (jp gain) fixed
57- can show class level in status & menu status screen
58#===============================================================================
59WHAT IT DOES:
60 * This script basically gives you an interface to allow the player to select
61 which Class to switch to for each character.
62 * Actors Base Stats can be changed based on class
63 * Added BigEd781's Class Dependant Stat Bonuses
64 * Actor options (ie. Super Guard, 2-swords, autobattle, pharmacology) can be
65 based on Class chosen
66 * Actor character graphic can be based on Class chosen
67 *******************************************************************************
68 Added = From Prexus - Job Changer (v1.0) & Yanfly
69 * Experience is totalled for characters and their Classes, individually.
70 * Classes gain levels, Jobs determine what skills you learn.
71 * Class Levels/Exp are remembered when changing jobs.
72 *******************************************************************************
73Script calls (events):
74 To assign an actor's class list size to a variable
75 actor_class_list_size(actor, variable_id)
76 For example:
77 actor_class_list_size(1, 5)
78 assigns actor 1 class list size to variable 5
79
80 To assign an actor's class level to a variable
81 check_class_level(actor, class_id, variable_id)
82 For example:
83 check_class_level(1, 1, 5)
84 assigns actor 1 class 1 level to variable 5
85
86 To increase the level of a specific job for an actor:
87 <#Game_Actor>.class_level_up(ID of Class)
88 For example:
89 $game_party.members[0].class_level_up(2)
90
91 * Allows you to enable or disable the JobChange screen on the main command menu.
92 This also actives or deactivates CLASSES_SWITCH.
93 permit_jobchange(true/false)
94
95 New script commands: Used in script in Event Commands
96
97 Character_Class.new_class(actor,class_id):
98
99 *Adds a class to the selected actor:
100 Character_Class.new_class(1,6)
101 Ralph learns Dark Knight or:
102 Character_Class.new_class($game_party.actors[2].id,6)
103 party actor 2 learns Dark Knight
104
105 *Removes Class from character
106 Character_Class.remove_class(actor_id,class_id)
107 doesn't work if character is currently at that class
108
109********************************************************************************
110 Added from Yanfly
111 ********************
112 *SKILL TAGS - notebox.
113 ********************
114 <jp_boost_set x>
115 If an actor uses this skill, that actor will gain x set amount of JP.
116
117 <jp_boost_ran x>
118 If an actor uses this skill, that actor will gain x random amount of JP.
119 ********************
120 *ITEM TAGS - notebox.
121 ********************
122 <gain_jp x>
123 The item will give the target ally JP of x amount. JP is given to whatever
124 the ally's current class is.
125
126 <unlock class x>
127 The item will unlock class x for the target ally. Use multiple of these tags
128 if you want an item to unlock more than one class.
129
130 <lock class x>
131 The item will lock class x for the target ally. Use multiple of these tags if
132 you want an item to lock more than one class.
133 ********************
134 *ENEMY TAGS - notebox.
135 ********************
136 <enemy_jp x>
137 This determines the amount of JP given by that enemy. If nothing is determined
138 by this set value and you allow your enemies to give JP, then the JP delivered
139 will equal to the ENEMIES_DEFAULT amount.
140
141 ********************
142 *STATE TAGS - notebox
143 ********************
144
145 <bonus_jp_per x>
146 JP gain rate is x%. If x is 200, then the JP gain rate is 200%.
147
148 <bonus_jp_set x>
149 x is added to JP gain. This means if JP gain is 20 and x is 10, total is 30.
150
151********************************************************************************
152 * Not 100% tested, please report any bugs
153********************************************************************************
154=end
155#===============================================================================
156# * Customize *
157#===============================================================================
158module S_B
159module CLASS
160 #-----------------------------------------------------------------------------
161 # Name for the experience gained for Job class
162 #-----------------------------------------------------------------------------
163 CLASS_EXP = "Job EXP"
164 CLASS_EXP_A = "JP"
165 #-----------------------------------------------------------------------------
166 # What appears in the menu to call script
167 #-----------------------------------------------------------------------------
168 MENU_CLASS_CHANGE_TITLE = "Job"
169 #-----------------------------------------------------------------------------
170 # Shows actors' class level in main menu & status screens
171 #-----------------------------------------------------------------------------
172 SHOW_CLASS_LVL_MAIN = true
173 SHOW_CLASS_LVL_STATUS = true
174 #-----------------------------------------------------------------------------
175 # Whether or not class changing is allowed at the begining of the game
176 #-----------------------------------------------------------------------------
177 MENU_CLASS_CHANGE_OPTION = false
178 #-----------------------------------------------------------------------------
179 # Switch ID to enable class changing in the menu
180 #-----------------------------------------------------------------------------
181 DISABLE_CLASS = 101
182 HIDE_CLASS = 102
183 #-----------------------------------------------------------------------------
184 # JP earned through various battle options *Yanfly
185 #-----------------------------------------------------------------------------
186 USE_BONUS_JP = false
187 # This sets whether or not you'd like your actors to display the JP they've
188 # earned in battle (since every action adds JP)
189 DISPLAY_BONUS_JP = false
190 DISPLAY_ACTOR_MSG = "%s earned %d #{S_B::CLASS::CLASS_EXP_A}!"
191 # JP is earned throughout battle from different effects. You can determine
192 # what will earn JP here and by how much. Set amounts are the increases that
193 # will always occur so long as the action is enabled. Random amounts will
194 # increase the JP earned from 0 to that amount.
195
196 EARN_JP_VIA_ATTACK_ENABLE = true # Normal attacks will earn JP.
197 EARN_JP_VIA_ATTACK_AMOUNT = 3 # Earns at least this amount of JP.
198 EARN_JP_VIA_ATTACK_RANDOM = 0 # Earns up to this random amount.
199
200 EARN_JP_VIA_SKILL_ENABLE = true # Skills will earn JP.
201 EARN_JP_VIA_SKILL_AMOUNT = 5 # Earns at least this amount of JP.
202 EARN_JP_VIA_SKILL_RANDOM = 0 # Earns up to this random amount.
203
204 EARN_JP_VIA_GUARD_ENABLE = false # Guarding will earn JP.
205 EARN_JP_VIA_GUARD_AMOUNT = 2 # Earns at least this amount of JP.
206 EARN_JP_VIA_GUARD_RANDOM = 0 # Earns up to this random amount.
207
208 EARN_JP_VIA_ITEMS_ENABLE = true # Using items will earn JP.
209 EARN_JP_VIA_ITEMS_AMOUNT = 1 # Earns at least this amount of JP.
210 EARN_JP_VIA_ITEMS_RANDOM = 0 # Earns up to this random amount.
211 #-----------------------------------------------------------------------------
212 # JP from enemies *Yanfly
213 # This determines whether or not enemies will give JP if killed and the
214 # default amount if not set with <enemy jp x>.
215 #-----------------------------------------------------------------------------
216 ENEMIES_GIVE_JP = true
217 ENEMIES_JP_DEFAULT = 0
218 #-----------------------------------------------------------------------------
219 # Vocab for end of combat *Prexus
220 #-----------------------------------------------------------------------------
221 ObtainClassExp = "%s #{S_B::CLASS::CLASS_EXP_A} was earned!"
222 # first %s is # of JP earned
223 ClassLevelUp = "%s is now %s %s %s!"
224 # first %s is actor, second %s is class, third & fourth %s is level
225 #-----------------------------------------------------------------------------
226 # Maximum level per job *Blackmorning and Mithran
227 # DO NOT go above 99
228 #-----------------------------------------------------------------------------
229 MAX_CLASS_LEVEL_DEFAULT = 99
230 CLASS_MAX_LEVELS = {} # Do not alter this line!
231 # Below here, set up the individiual max levels for each class.
232 # CLASS_MAX_LEVELS[class_id] = maxlevel
233 CLASS_MAX_LEVELS[1] = 99
234 # ie Paladin is capped at level 30
235 CLASS_MAX_LEVELS[2] = 99
236 # ie Warrior is capped at level 99
237 CLASS_MAX_LEVELS[3] = 99
238 # ie Priest is capped at level 99
239 CLASS_MAX_LEVELS[4] = 99
240 # ie Magician is capped at level 50
241 #-----------------------------------------------------------------------------
242 # Icon used to show MAX level *Blackmorning
243 #-----------------------------------------------------------------------------
244 MASTERED_ICON = 102
245 #-----------------------------------------------------------------------------
246 # Icon beside skills in class menu
247 #-----------------------------------------------------------------------------
248 Skills_Icon = 128
249 #-----------------------------------------------------------------------------
250 # Button to show skills window in job change
251 #-----------------------------------------------------------------------------
252 SHOW_SKILLS_WINDOW = Input::A
253 #-----------------------------------------------------------------------------
254 # CLASS SPECIFIC CHARACTER GFX - *Enelvon
255 # file format:
256 # $"actor_ID"_"class_ID"
257 # ie. $1_5 for actor 1, class 5
258 #-----------------------------------------------------------------------------
259 CHANGE_GRAPHIC = true
260 #-----------------------------------------------------------------------------
261 # Available classes are the classes that each actor starts out with.
262 AVAILABLE_CLASSES = { # don't remove
263 # format: actor_id => [class_id, class_id...],
264 #-----------------------------------------------------------------------------
265 1 => [1,2,3,4,5,6,7],
266 2 => [2,5],
267 3 => [3,6],
268 4 => [4,7],
269 5 => [1,2,5,6],
270 6 => [5,6],
271 7 => [7],
272 8 => [7,8],
273 } # don't remove
274 #-----------------------------------------------------------------------------
275 # If set to true, actor keeps skills learned when changing classes
276 # if false, loses ALL skills learnt by previous class (those specific to the class)
277 #-----------------------------------------------------------------------------
278 KEEP_SKILLS = true
279 #-----------------------------------------------------------------------------
280 # Enter the ID's of the characters that always keep their skills
281 # characters that ignore KEEP_SKILLS = false
282 #-----------------------------------------------------------------------------
283 SPECIAL_CLASS_ACTORS = [5]
284 #-----------------------------------------------------------------------------
285 # Define which Class_ID's use these special options. *TBK
286 #-----------------------------------------------------------------------------
287 CHANGE_ACTOR_OPTIONS = false
288 CRITICAL_CLASSES = [0]
289 TWOSWORDS_CLASSES = [0]
290 # Actor will automatically attack.
291 AUTOBATTLE_CLASSES = [0]
292 # Actor will take even less damage when guarding.
293 SUPERGUARD_CLASSES = [0,0,0]
294 # Items will have double effect when used by actor.
295 PHARMACOLOGY_CLASSES = [0]
296 #-----------------------------------------------------------------------------
297 HALP_MP_CLASSES = [9]
298 HP_RECOVER = [9]
299 FAST_ATTACK = [9,8]
300 #-----------------------------------------------------------------------------
301 # Yanfly Engine RD - Battler Stat: Barehand
302 # Last Date Updated: 2009.05.14
303 #-----------------------------------------------------------------------------
304 # For those that would like to give their actors stronger strength when no
305 # weapon is equipped, there is a barehand stat now. You can adjust how strong
306 # an actor's barehanded multiplier will grow each level so that way, you don't
307 # have your actors going over the top strong from the beginning.
308 #-----------------------------------------------------------------------------
309 # This is the array of classes that can fight barehanded.
310 BAREHANDED_CLASSES = [8]
311 # This is the multiplier given to base attack when no weapon is equipped.
312 BAREHAND_BASE_MULTIPLIER = 150
313 BAREHAND_PER_LEVEL_BOOST = 5 # based on class level
314 BAREHAND_MAX_MULTIPLIER = 400
315 #-----------------------------------------------------------------------------
316 # CLASS "BASED STAT MULTIPLIER" - *Enelv-on - specifically for the JobChanger
317 # Redesigned by Blackmorning
318 #-----------------------------------------------------------------------------
319 # Below are the Multipliers for each Class ID/Stat
320 # Class ID => Stat Multipliers
321 # example: if you want Class_ID #1 to have normal MAXHP (ie 100%)
322 # you would set the multiplier to 1.0
323 #-----------------------------------------------------------------------------
324 # This determines whether or not actor stats are affected by their what
325 # class they have equipped.
326 CHANGE_BASE_STATS = true
327 # This affects the display type for new stats.
328 # if true, Shows the increase/decrease in the stat.
329 # if false, Shows the new stat itself.
330 SHOW_DIFFERENCE = true
331 #-----------------------------------------------------------------------------
332 BASE_STAT_CHANGE = { # <--- Do not remove
333 # res and dex only active with YEZ Battler stats res and dex
334 # Class HP MP ATK DEF INT AGI RES DEX
335 0 => [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1, 1], #default
336 1 => [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1, 1], #default
337 2 => [ 0.9, 1.2, 0.8, 0.8, 1.2, 1.0, 0.9, 0.8], #Mage
338 3 => [ 1.2, 0.8, 1.2, 0.8, 0.8, 1.0, 0.5, 0.8], #Warrior
339 4 => [ 0.9, 1.0, 1.0, 0.8, 1.0, 1.2, 1.1, 0.8], #Sneak
340 5 => [ 1.0, 1.1, 0.9, 1.1, 1.1, 0.8, 1.1, 0.8], #Medic
341 6 => [ 1.1, 0.8, 1.1, 1.2, 0.8, 0.8, 1.0, 1.0], #Knight
342 7 => [ 0.8, 1.0, 1.0, 0.9, 1.1, 1.1, 1, 1], #Shadow
343 } # Do not remove this.
344 #==========================================================================
345 # BigEd781's Class Dependant Stat Bonuses
346 #--------------------------------------------------------------------------
347 # The purpose of this is to allow one to set stat
348 # bonuses upon class level up depending on the player's class.
349 #==========================================================================
350 # * When the below value is set to "true", the table of constant values
351 # below it are used to determine class level up bonuses are, depending
352 # on the class.
353 #-----------------------------------------------------------------------------
354 LEVEL_UP_BONUSES = true
355
356 CLASS_LEVEL_UP_BONUS_CLASS_DEP = false
357 # if true, bonuses based on class level
358 # if false, bonuses based on actor level
359 #-----------------------------------------------------------------------------
360 # * Configuration module
361 #-----------------------------------------------------------------------------
362 STAT_BONUS = { # <--- Do not remove
363 # res and dex only active with YEZ Battler stats res and dex
364 # Class HP MP ATK DEF INT AGI RES DEX
365 1 => [ 0, 0, 1, 0, 1, 0, 0, 0], #Paladin
366 2 => [ 0, 2, 0, 0, 1, 0, 0, 0], #Mage
367 3 => [ 4, 0, 1, 0, 0, 0, 0, 0], #Warrior
368 4 => [ 0, 0, 1, 0, 0, 1, 0, 0], #Thief
369 5 => [ 0, 2, 0, 1, 0, 0, 0, 0], #Medic
370 6 => [ 4, 0, 0, 1, 0, 0, 0, 0], #Knight
371 7 => [ 0, 0, 0, 0, 1, 1, 0, 0], #Phantom
372 } # Do not remove this.
373 #-----------------------------------------------------------------------------
374 # if level is decreased, are stat bonuses lost?
375 #=============================================================================
376 LOSE_STAT_BONUS = true
377 #=============================================================================
378 # Description of the class for the help window
379 #-----------------------------------------------------------------------------
380 # format: class_id => ["description"],
381 Class_Descriptions = { # <--- Do not remove
382 1 =>["[Wk: None][Res: None] Well rounded. Uses swords."], #Hero
383 2 =>["[Wk: Earth][Res: Electric] Frail, yet strong. Uses staves."], #Beserker
384 3 =>["[Wk: Water][Res: Fire] Very powerful. Uses axes."], #Priest
385 4 =>["[Wk: Electric][Res: Water] Quick and nimble. Uses knives."], #Magician
386 5 =>["[Wk: Ice][Res: Wind] Heals allies. Uses staves."],#Knight
387 6 =>["[Wk: Wind][Res: Earth] A durable defender. Uses axes."], #Dark Knight
388 7 =>["[Wk: Fire][Res: Ice] Clever and mysterious. Uses knives."], #Grappler
389 8 =>["Professional sneak and highwayman."],#Thief
390 }# <--- Do not remove
391 #=============================================================================
392 # icons appear next to class in job changer window # requested by Andrelvis
393 USE_ICONS_FOR_CLASSES = true
394 # format: class_id => [icon_id],
395 Class_Icons = { # <--- Do not remove
396 0 => 0, #default if no icon assigned
397 1 => 2,
398 2 => 32,
399 3 => 6,
400 4 => 48,
401 5 => 189,
402 6 => 52,
403 7 => 39,
404 8 => 147,
405 } # <--- Do not remove
406 #-----------------------------------------------------------------------------
407 Custom_JP_Needed_For_Level = true
408 # If true, uses exp_list as starting values and similar formula.
409 # If false, solely uses exp_list for jp needed for class level up.
410 CLASS_JP_MOD_BASIS = 20
411 CLASS_JP_MOD_INFLATION = 10
412
413 CLASS_JP_MOD = {# <--- Do not remove
414 #format: class_id => [basis, inflation],
415 9 => [20, 15],
416 10 => [10, 20],
417 11 => [25, 25],
418 }# <--- Do not remove
419
420
421end
422end
423#=============================================================================
424# * End Customization *
425#=============================================================================
426
427# Don't touch, all customizations can be done in the script above.
428#===============================================================================
429module S_B::CLASS
430 module_function
431 def permit_jobchange(enabled = true)
432 if enabled
433 $game_switches[S_B::CLASS::DISABLE_CLASS] = false
434 else
435 $game_switches[S_B::CLASS::DISABLE_CLASS] = true
436 end
437 end
438 #--------------------------------------------------------------------------
439 def check_class_level(actor, class_id, variable_id = 0)
440 level = 2
441 c = $data_classes[class_id]
442 level = $game_actors[actor].class_level[c.id]
443 $game_variables[variable_id] = level if variable_id > 0
444 return level
445 end
446 #--------------------------------------------------------------------------
447 def actor_class_list_size(actor, variable_id = 0)
448 class_list = $game_actors[actor].unlocked_classes
449 $game_variables[variable_id] = class_list.size if variable_id > 0
450 return class_list
451 end
452end
453#===============================================================================
454class Game_Interpreter
455 include S_B::CLASS
456end
457#===============================================================================
458module Vocab
459 ObtainClassExp = S_B::CLASS::ObtainClassExp
460 ClassLevelUp = S_B::CLASS::ClassLevelUp
461 Display_Actor_Msg = S_B::CLASS::DISPLAY_ACTOR_MSG
462 Classes_Vocab = S_B::CLASS::MENU_CLASS_CHANGE_TITLE
463 def self.jp
464 return S_B::CLASS::CLASS_EXP
465 end
466 def self.jp_a
467 return S_B::CLASS::CLASS_EXP_A
468 end
469end
470$imported = {} if $imported == nil
471$imported["JobChange"] = true
472#===============================================================================
473module YE
474 module REGEXP
475 module BASEITEM
476 # These are skill related.
477 JP_BOOST_SET = /<(?:JP_BOOST_SET|jp_boost_set)\s*(\d+)>/i
478 JP_BOOST_RAN = /<(?:JP_BOOST_RAN|jp_boost_ran)\s*(\d+)>/i
479 # These are item related.
480 GAIN_JP = /<(?:GAIN_JP|gain_jp)\s*(\d+)>/i
481 UNLOCK_CLASS = /<(?:UNLOCK_CLASS|unlock class)[ ]*(\d+)>/i
482 LOCK_CLASS = /<(?:LOCK_CLASS|lock class)[ ]*(\d+)>/i
483 end # BASEITEM
484 module ENEMY
485 # These are enemy related
486 ENEMY_JP = /<(?:ENEMY_JP|enemy_jp)\s*(\d+)>/i
487 end # ENEMY
488 module STATE
489 # This affects states.
490 BONUS_JP_PER = /<(?:BONUS_JP_PER|bonus_jp_per)[ ]*(\d+)(?:%|%)?>/i
491 BONUS_JP_SET = /<(?:BONUS_JP_SET|bonus_jp_set)[ ]*(\d+)>/i
492 end # STATE
493 end # REGEXP
494end # YE
495#===============================================================================
496# RPG::State *from yanfly
497#===============================================================================
498class RPG::State
499 #--------------------------------------------------------------------------
500 # Yanfly_Cache_SSS
501 #--------------------------------------------------------------------------
502 def yanfly_cache_state_sss
503 @bonus_jp_per = 100; @bonus_jp_set = 0
504 self.note.split(/[\r\n]+/).each { |line|
505 case line
506 when YE::REGEXP::STATE::BONUS_JP_PER
507 @bonus_jp_per = $1.to_i
508 when YE::REGEXP::STATE::BONUS_JP_SET
509 @bonus_jp_set = $1.to_i
510 end
511 }
512 end # cache
513 #--------------------------------------------------------------------------
514 # definitions
515 #--------------------------------------------------------------------------
516 def bonus_jp_per
517 yanfly_cache_state_sss if @bonus_jp_per == nil
518 return @bonus_jp_per
519 end
520 def bonus_jp_set
521 yanfly_cache_state_sss if @bonus_jp_set == nil
522 return @bonus_jp_set
523 end
524end
525#===============================================================================
526# RPG::BaseItem *from yanfly
527#===============================================================================
528class RPG::BaseItem
529 #--------------------------------------------------------------------------
530 # Yanfly_Cache_SSS
531 #--------------------------------------------------------------------------
532 def yanfly_cache_baseitem_sss
533 @jp_boost_set = 0; @jp_boost_ran = 0
534 @gain_jp = 0; @unlock_class = []; @lock_class = []
535 self.note.split(/[\r\n]+/).each { |line|
536 case line
537 when YE::REGEXP::BASEITEM::JP_BOOST_SET
538 @jp_boost_set = $1.to_i
539 when YE::REGEXP::BASEITEM::JP_BOOST_RAN
540 @jp_boost_ran = $1.to_i
541 when YE::REGEXP::BASEITEM::GAIN_JP
542 @gain_jp = $1.to_i
543 when YE::REGEXP::BASEITEM::UNLOCK_CLASS
544 @unlock_class.push($1.to_i)
545 when YE::REGEXP::BASEITEM::LOCK_CLASS
546 @lock_class.push($1.to_i)
547 end
548 }
549 end # cache
550 #--------------------------------------------------------------------------
551 # JP definitions
552 #--------------------------------------------------------------------------
553 def jp_boost_set
554 yanfly_cache_baseitem_sss if @jp_boost_set == nil
555 return @jp_boost_set
556 end
557 def jp_boost_ran
558 yanfly_cache_baseitem_sss if @jp_boost_ran == nil
559 return @jp_boost_ran
560 end
561 def gain_jp
562 yanfly_cache_baseitem_sss if @gain_jp == nil
563 return @gain_jp
564 end
565 #--------------------------------------------------------------------------
566 # class definitions
567 #--------------------------------------------------------------------------
568 def unlock_class
569 yanfly_cache_baseitem_sss if @unlock_class == nil
570 return @unlock_class
571 end
572 def lock_class
573 yanfly_cache_baseitem_sss if @lock_class == nil
574 return @lock_class
575 end
576end
577#===============================================================================
578# RPG::Enemy *from yanfly
579#===============================================================================
580class RPG::Enemy
581 #--------------------------------------------------------------------------
582 # Yanfly_Cache_SSS
583 #--------------------------------------------------------------------------
584 def yanfly_cache_enemy_sss
585 @enemy_jp = S_B::CLASS::ENEMIES_JP_DEFAULT
586 self.note.split(/[\r\n]+/).each { |line|
587 case line
588 when YE::REGEXP::ENEMY::ENEMY_JP
589 @enemy_jp = $1.to_i
590 end
591 }
592 end # cache
593 #--------------------------------------------------------------------------
594 # definitions
595 #--------------------------------------------------------------------------
596 def enemy_jp
597 yanfly_cache_enemy_sss if @enemy_jp == nil
598 return @enemy_jp
599 end
600end
601#==============================================================================
602# ** Game_Actor *from prexus and TBK and blackmorning
603#==============================================================================
604class Game_Actor < Game_Battler
605 attr_accessor :jp_list
606 attr_accessor :jp_exp
607 attr_accessor :class_level
608 #--------------------------------------------------------------------------
609 alias job_initialize initialize unless $@
610 #--------------------------------------------------------------------------
611 def initialize(actor_id)
612 job_initialize(actor_id)
613 @exist_character_graphics = []
614 end
615 #--------------------------------------------------------------------------
616 alias job_setup setup unless $@
617 #--------------------------------------------------------------------------
618 def setup(actor_id)
619 job_setup(actor_id) #default
620 @jp_list = {}
621
622 for id in 1..$data_classes.size - 1
623 next unless $data_classes[id]
624 @jp_list[id] = Array.new(101)
625 end
626
627 make_jp_exp_list
628
629 @jp_exp = {}
630 @jp_exp.default = 0
631 @class_level = {}
632 @class_level.default = 1
633 @skills = []
634 define_skills
635 @unlocked_classes = S_B::CLASS::AVAILABLE_CLASSES[self.id] # What classes are unlocked.
636 @unlocked_classes = [self.class.id] if S_B::CLASS::AVAILABLE_CLASSES[self.id] == nil
637
638 end
639 #--------------------------------------------------------------------------
640 # * Calculate JP Experience
641 #--------------------------------------------------------------------------
642 def make_jp_exp_list
643 for id in 1..$data_classes.size - 1
644 next unless $data_classes[id]
645 if S_B::CLASS::Custom_JP_Needed_For_Level
646 if S_B::CLASS::CLASS_JP_MOD.include?(id)
647 jp_basis = S_B::CLASS::CLASS_JP_MOD[id][0]
648 jp_inflation = S_B::CLASS::CLASS_JP_MOD[id][1]
649 else
650 jp_basis = S_B::CLASS::CLASS_JP_MOD_BASIS
651 jp_inflation = S_B::CLASS::CLASS_JP_MOD_INFLATION
652 end
653 maxlevel = S_B::CLASS::CLASS_MAX_LEVELS[id]
654 maxlevel = S_B::CLASS::MAX_CLASS_LEVEL_DEFAULT if maxlevel == nil
655 @jp_list[id][1] = @jp_list[id][maxlevel+1] = 0
656 m = jp_basis
657 n = (0.5 + jp_inflation / 200.0);
658 for i in 2..(maxlevel)
659 @jp_list[id][i] = @jp_list[id][i - 1] + Integer(m)
660 m *= 1 + n;
661 n *= 0.895;
662 end
663 else
664 @jp_list[id] = @exp_list
665 end
666 end
667 end
668 #--------------------------------------------------------------------------
669 def forget_class_skills(id = nil)
670 id = @class_id if id == nil
671 for i in $data_classes[id].learnings
672 forget_skill(i.skill_id) unless S_B::CLASS::KEEP_SKILLS or S_B::CLASS::SPECIAL_CLASS_ACTORS.include?(actor.id)
673 end
674 end
675 #--------------------------------------------------------------------------
676 def define_skills(id = nil)
677 id = @class_id if id == nil
678 if !S_B::CLASS::USE_BONUS_JP && !S_B::CLASS::ENEMIES_GIVE_JP
679 for i in $data_classes[id].learnings
680 learn_skill(i.skill_id) if i.level <= @level
681 end
682 else
683 for i in $data_classes[id].learnings
684 learn_skill(i.skill_id) if i.level <= @class_level[id]
685 end
686 end
687 end
688 #--------------------------------------------------------------------------
689 def change_jp(jp, id = nil, show = false)
690 id = @class_id if id == nil
691 last_level = @class_level[id]
692 last_skills = skills
693 @jp_exp[id] = [[jp, 999999].min, 0].max
694 while @jp_exp[id] >= @jp_list[id][@class_level[id] + 1] and @jp_list[id][@class_level[id] + 1] > 0
695 class_level_up(id)
696 end
697 while @jp_exp[id] < @jp_list[id][@class_level[id]]
698 class_level_down(id)
699 end
700 if show and @class_level[id] > last_level
701 display_class_level_up(skills - last_skills, id)
702 end
703 end
704 #--------------------------------------------------------------------------
705 def jp_exp_s(id = nil)
706 id = @class_id if id == nil
707 return @jp_list[id][@class_level[id]+1] > 0 ? @jp_exp[id] : "-------"
708 end
709 #--------------------------------------------------------------------------
710 # * Get jp - numeric for calculations
711 #--------------------------------------------------------------------------
712 def now_jp_exp(id = nil)
713 id = @class_id if id == nil
714 return @jp_exp[id] - @jp_list[id][@class_level[id]]
715 end
716 #--------------------------------------------------------------------------
717 def next_jp_exp_s(id = nil)
718 id = @class_id if id == nil
719 return @jp_list[id][@class_level[id]+1] > 0 ? @jp_list[id][@class_level[id]+1] : "-------"
720 end
721 #--------------------------------------------------------------------------
722 def next_class_rest_exp_s(id = nil)
723 id = @class_id if id == nil
724 return @jp_list[id][@class_level[id]+1] > 0 ? (@jp_list[id][@class_level[id]+1] - @jp_exp[id]) : "-------"
725 end
726 #--------------------------------------------------------------------------
727 def class_level_up(id = nil, adjust = false)
728 id = @class_id if id == nil
729 maxlevel = S_B::CLASS::CLASS_MAX_LEVELS[id]
730 maxlevel = S_B::CLASS::MAX_CLASS_LEVEL_DEFAULT if maxlevel == nil
731 @class_level[id] += 1 unless @class_level[id] == maxlevel
732 @jp_exp[id] = @jp_list[id][@class_level[id]]
733 if S_B::CLASS::LEVEL_UP_BONUSES
734 if S_B::CLASS::CLASS_LEVEL_UP_BONUS_CLASS_DEP && S_B::CLASS::STAT_BONUS.include?(id)
735 self.maxhp += S_B::CLASS::STAT_BONUS[id][0]
736 self.maxmp += S_B::CLASS::STAT_BONUS[id][1]
737 self.atk += S_B::CLASS::STAT_BONUS[id][2]
738 self.def += S_B::CLASS::STAT_BONUS[id][3]
739 self.spi += S_B::CLASS::STAT_BONUS[id][4]
740 self.agi += S_B::CLASS::STAT_BONUS[id][5]
741 self.res += S_B::CLASS::STAT_BONUS[id][6] if $imported["BattlerStatRES"] or $imported["RES Stat"]
742 self.dex += S_B::CLASS::STAT_BONUS[id][7] if $imported["BattlerStatDEX"] or $imported["DEX Stat"]
743 end
744 end
745 define_skills
746 define_skills(id) if S_B::CLASS::KEEP_SKILLS or S_B::CLASS::SPECIAL_CLASS_ACTORS.include?(actor.id)
747 end
748 #--------------------------------------------------------------------------
749 def class_level_down(id = nil, adjust = false)
750 id = @class_id if id == nil
751 @class_level[id] -= 1 unless @class_level[id] == 1
752 @jp_exp[id] = @jp_list[id][@class_level[id]]
753 if S_B::CLASS::LEVEL_UP_BONUSES
754 if S_B::CLASS::CLASS_LEVEL_UP_BONUS_CLASS_DEP && S_B::CLASS::LOSE_STAT_BONUS && S_B::CLASS::STAT_BONUS.include?(id)
755 self.maxhp -= S_B::CLASS::STAT_BONUS[id][0]
756 self.maxmp -= S_B::CLASS::STAT_BONUS[id][1]
757 self.atk -= S_B::CLASS::STAT_BONUS[id][2]
758 self.def -= S_B::CLASS::STAT_BONUS[id][3]
759 self.spi -= S_B::CLASS::STAT_BONUS[id][4]
760 self.agi -= S_B::CLASS::STAT_BONUS[id][5]
761 self.res -= S_B::CLASS::STAT_BONUS[id][6] if $imported["BattlerStatRES"] or $imported["RES Stat"]
762 self.dex -= S_B::CLASS::STAT_BONUS[id][7] if $imported["BattlerStatDEX"] or $imported["DEX Stat"]
763 end
764 end
765 define_skills
766 define_skills(id) if S_B::CLASS::KEEP_SKILLS or S_B::CLASS::SPECIAL_CLASS_ACTORS.include?(actor.id)
767 end
768 #--------------------------------------------------------------------------
769 # level up
770 #--------------------------------------------------------------------------
771 def level_up
772 @level += 1
773 if S_B::CLASS::LEVEL_UP_BONUSES
774 if !S_B::CLASS::CLASS_LEVEL_UP_BONUS_CLASS_DEP && S_B::CLASS::STAT_BONUS.include?(id)
775 self.maxhp += S_B::CLASS::STAT_BONUS[id][0]
776 self.maxmp += S_B::CLASS::STAT_BONUS[id][1]
777 self.atk += S_B::CLASS::STAT_BONUS[id][2]
778 self.def += S_B::CLASS::STAT_BONUS[id][3]
779 self.spi += S_B::CLASS::STAT_BONUS[id][4]
780 self.agi += S_B::CLASS::STAT_BONUS[id][5]
781 self.res += S_B::CLASS::STAT_BONUS[id][6] if $imported["BattlerStatRES"] or $imported["RES Stat"]
782 self.dex += S_B::CLASS::STAT_BONUS[id][7] if $imported["BattlerStatDEX"] or $imported["DEX Stat"]
783 end
784 end
785 end
786 #--------------------------------------------------------------------------
787 alias jp_leveldown level_down unless $@
788 #--------------------------------------------------------------------------
789 def level_down
790 jp_leveldown
791 if S_B::CLASS::LEVEL_UP_BONUSES
792 if !S_B::CLASS::CLASS_LEVEL_UP_BONUS_CLASS_DEP && S_B::CLASS::LOSE_STAT_BONUS && S_B::CLASS::STAT_BONUS.include?(id)
793 self.maxhp -= S_B::CLASS::STAT_BONUS[id][0]
794 self.maxmp -= S_B::CLASS::STAT_BONUS[id][1]
795 self.atk -= S_B::CLASS::STAT_BONUS[id][2]
796 self.def -= S_B::CLASS::STAT_BONUS[id][3]
797 self.spi -= S_B::CLASS::STAT_BONUS[id][4]
798 self.agi -= S_B::CLASS::STAT_BONUS[id][5]
799 self.res -= S_B::CLASS::STAT_BONUS[id][6] if $imported["BattlerStatRES"] or $imported["RES Stat"]
800 self.dex -= S_B::CLASS::STAT_BONUS[id][7] if $imported["BattlerStatDEX"] or $imported["DEX Stat"]
801 end
802 end
803 end
804 #--------------------------------------------------------------------------
805 def jp_received(jp, id = nil, show = false)
806 id = @class_id if id == nil
807 change_jp(@jp_exp[id] + jp, id, show)
808 end
809 #--------------------------------------------------------------------------
810 # forget all skills
811 #--------------------------------------------------------------------------
812 def forget_all_skills
813 @skills = []
814 end
815 #--------------------------------------------------------------------------
816 def class_change_level(level, id = nil, show = false)
817 id = @class_id if id == nil
818 maxlevel = S_B::CLASS::CLASS_MAX_LEVELS[id]
819 maxlevel = S_B::CLASS::MAX_CLASS_LEVEL_DEFAULT if maxlevel == nil
820 level = [[level, maxlevel].min, 1].max
821 change_jp(@jp_list[id][level], id, show)
822 end
823 #--------------------------------------------------------------------------
824 def class_id=(class_id)
825 forget_class_skills
826 @class_id = class_id
827 for i in 0..4 # Remove unequippable items
828 change_equip(i, nil) unless equippable?(equips[i])
829 end
830 if $imported["EquipExtension"]
831 return if extra_armor_number == 0
832 for i in 5..armor_number
833 change_equip(i, nil) unless equippable?(equips[i])
834 end
835 end
836 purge_unequippable if $imported["EquipmentOverhaul"]
837 unless @unlocked_classes.include?(@class_id)
838 @unlocked_classes.push(@class_id)
839 end
840 @unlocked_classes.sort!
841 purge_unequippable_skills if $imported["SkillCPSystem"]
842 define_skills
843 pic_name = "$#{actor.id}_#{$data_classes[class_id].id}"
844 if S_B::CLASS::CHANGE_GRAPHIC && graphic_exist?(pic_name)
845 $game_actors[@actor_id].set_graphic(pic_name, 0, @face_name, @face_index)
846 $game_player.refresh
847 end
848 end
849 #--------------------------------------------------------------------------
850 # return unlocked classes
851 #--------------------------------------------------------------------------
852 def unlocked_classes
853 results = []
854 @unlocked_classes = [self.class.id] if @unlocked_classes == nil
855 @unlocked_classes.sort!
856 results = @unlocked_classes
857 results.push(self.class.id) unless results.include?(self.class.id)
858 return results
859 end
860 #--------------------------------------------------------------------------
861 # perform unlock class
862 #--------------------------------------------------------------------------
863 def unlock_class(newclass_id)
864 @unlocked_classes = [self.class.id] if @unlocked_classes == nil
865 unless @unlocked_classes.include?(newclass_id)
866 @unlocked_classes.push(newclass_id)
867 end
868 @unlocked_classes.sort!
869 end
870 #--------------------------------------------------------------------------
871 # perform lock class
872 #--------------------------------------------------------------------------
873 def lock_class(newclass_id)
874 return if newclass_id == self.class.id
875 @unlocked_classes = [self.class.id] if @unlocked_classes == nil
876 @unlocked_classes.delete(newclass_id)
877 @unlocked_classes.sort!
878 end
879 #--------------------------------------------------------------------------
880 # perform unlock all classes
881 #--------------------------------------------------------------------------
882 def unlock_all_classes
883 for i in 0..$data_classes.size
884 unlock = $data_classes[i + 1]
885 self.unlock_class(unlock.id)
886 end
887 @unlocked_classes.sort!
888 end
889 #--------------------------------------------------------------------------
890 # perform lock all classes
891 #--------------------------------------------------------------------------
892 def lock_all_classes
893 for i in 0..$data_classes.size
894 unlock = $data_classes[i + 1]
895 self.lock_class(unlock.id)
896 end
897 @unlocked_classes.sort!
898 end
899 #--------------------------------------------------------------------------
900 # * Determine if Graphic Filename Exists
901 #--------------------------------------------------------------------------
902 def graphic_exist?(filename)
903 return true if @exist_character_graphics.include?(filename)
904 begin
905 Cache.character(filename)
906 @exist_character_graphics.push(filename)
907 return true
908 rescue
909 return false
910 end
911 end
912 #--------------------------------------------------------------------------
913 def display_class_level_up(new_skills, id)
914 $game_message.new_page
915 i = @class_id
916 c = $data_classes[i]
917 level = @class_level[c.id]
918 text = sprintf(Vocab::ClassLevelUp, @name, $data_classes[id].name, Vocab::level, level.to_s)
919 $game_message.texts.push(text)
920 for skill in new_skills
921 text = sprintf(Vocab::ObtainSkill, skill.name)
922 $game_message.texts.push(text)
923 end
924 end
925 #--------------------------------------------------------------------------
926 # * Show Level Up Message
927 # new_skills : Array of newly learned skills
928 #--------------------------------------------------------------------------
929 def display_level_up(new_skills)
930 text = sprintf(Vocab::LevelUp, @name, Vocab::level, @level)
931 $game_message.texts.push(text)
932 for skills in new_skills
933 text = sprintf(Vocab::ObtainSkill, actor.name)
934 $game_message.texts.push(text)
935 end
936 end
937 #--------------------------------------------------------------------------
938 # * Get Critical Ratio
939 #--------------------------------------------------------------------------
940 alias job_cri cri unless $@
941 def cri
942 n = job_cri
943 n += 4 if self.job_critical_bonus
944 return n
945 end
946 #=============================================================================
947 # * Change Actor Options based on Class *from TBK
948 #=============================================================================
949 if S_B::CLASS::CHANGE_ACTOR_OPTIONS
950 #--------------------------------------------------------------------------
951 # * Get [Critical Bonus] Option
952 #--------------------------------------------------------------------------
953 def job_critical_bonus
954 return true if S_B::CLASS::CRITICAL_CLASSES.include?(@class_id)
955 end
956 #--------------------------------------------------------------------------
957 # * Get [Dual Wield] Option
958 #--------------------------------------------------------------------------
959 alias job_two_sword two_swords_style unless $@
960 def two_swords_style
961 return true if S_B::CLASS::TWOSWORDS_CLASSES.include?(@class_id)
962 job_two_sword
963 end
964 #--------------------------------------------------------------------------
965 # * Get [Automatic Battle] Option
966 #--------------------------------------------------------------------------
967 alias job_auto_battle auto_battle unless $@
968 def auto_battle
969 return true if S_B::CLASS::AUTOBATTLE_CLASSES.include?(@class_id)
970 job_auto_battle
971 end
972 #--------------------------------------------------------------------------
973 # * Get [Super Guard] Option
974 #--------------------------------------------------------------------------
975 alias job_super_guard super_guard unless $@
976 def super_guard
977 return true if S_B::CLASS::SUPERGUARD_CLASSES.include?(@class_id)
978 job_super_guard
979 end
980 #--------------------------------------------------------------------------
981 # * Get [Pharmocology] Option
982 #--------------------------------------------------------------------------
983 alias job_pharmacology pharmacology unless $@
984 def pharmacology
985 return true if S_B::CLASS::PHARMACOLOGY_CLASSES.include?(@class_id)
986 job_pharmacology
987 end
988 #--------------------------------------------------------------------------
989 # * Get [Half MP Cost] Option
990 #--------------------------------------------------------------------------
991 alias job_half_mp_cost half_mp_cost unless $@
992 def half_mp_cost
993 return true if S_B::CLASS::HALP_MP_CLASSES.include?(@class_id)
994 job_half_mp_cost
995 end
996 #--------------------------------------------------------------------------
997 # * Get [HP Recover] Option
998 #--------------------------------------------------------------------------
999 alias job_auto_hp_recover auto_hp_recover unless $@
1000 def auto_hp_recover
1001 return true if S_B::CLASS::HP_RECOVER.include?(@class_id)
1002 job_auto_hp_recover
1003 end
1004 #--------------------------------------------------------------------------
1005 # * Get [Fast Attack] Option
1006 #--------------------------------------------------------------------------
1007 alias job_fast_attack fast_attack unless $@
1008 def fast_attack
1009 return true if S_B::CLASS::FAST_ATTACK.include?(@class_id)
1010 job_fast_attack
1011 end
1012 else
1013 def job_critical_bonus
1014 return false
1015 end
1016 end
1017
1018 def base_stat_class(type, actclass = @class_id)
1019 if S_B::CLASS::CHANGE_BASE_STATS and S_B::CLASS::BASE_STAT_CHANGE.include?(actclass)
1020 multiplier = S_B::CLASS::BASE_STAT_CHANGE[actclass][type] - 1
1021 elsif S_B::CLASS::CHANGE_BASE_STATS
1022 multiplier = S_B::CLASS::BASE_STAT_CHANGE[0][type] - 1
1023 else
1024 multiplier = 0
1025 end
1026 if type == 6 && $imported["BattlerStatRES"]
1027 if YEZ::STAT::ACTOR_BASE_RES.include?(@actor_id)
1028 n = eval(YEZ::STAT::ACTOR_BASE_RES[@actor_id])
1029 else
1030 n = eval(YEZ::STAT::ACTOR_BASE_RES[0])
1031 end
1032 value = multiplier * n
1033 elsif type == 6 && $imported["RES Stat"]
1034 if YEM::STATS::RES::ACTOR_BASE.include?(@actor_id)
1035 n = eval(YEM::STATS::RES::ACTOR_BASE[@actor_id])
1036 else
1037 n = eval(YEM::STATS::RES::ACTOR_BASE[0])
1038 end
1039 value = multiplier * n
1040 elsif type == 7 && $imported["BattlerStatDEX"]
1041 if YEZ::STAT::ACTOR_BASE_DEX.include?(@actor_id)
1042 n = eval(YEZ::STAT::ACTOR_BASE_DEX[@actor_id])
1043 else
1044 n = eval(YEZ::STAT::ACTOR_BASE_DEX[0])
1045 end
1046 value = multiplier * n
1047 elsif type == 7 && $imported["DEX Stat"]
1048 if YEM::STATS::DEX::ACTOR_BASE.include?(@actor_id)
1049 n = eval(YEM::STATS::DEX::ACTOR_BASE[@actor_id])
1050 else
1051 n = eval(YEM::STATS::DEX::ACTOR_BASE[0])
1052 end
1053 value = multiplier * n
1054 elsif $imported["LimitBreak"]
1055 value = multiplier * base_parameter(type)
1056 else
1057 value = multiplier * actor.parameters[type, @level]
1058 end
1059 return Integer(value)
1060 end
1061
1062 def barehand?
1063 if S_B::CLASS::BAREHANDED_CLASSES.include?(@class_id)
1064 if self.weapons[0] == nil and self.weapons[1] == nil
1065 return true
1066 else
1067 return false
1068 end
1069 else
1070 return false
1071 end
1072 end
1073 #--------------------------------------------------------------------------
1074 # bare handed multiplier
1075 #--------------------------------------------------------------------------
1076 def barehanded_multiplier(value)
1077 multiplier = S_B::CLASS::BAREHAND_BASE_MULTIPLIER
1078 id = @class_id
1079 classlevel = @class_level[id]
1080 multiplier += S_B::CLASS::BAREHAND_PER_LEVEL_BOOST * (classlevel - 1)
1081 multiplier = [S_B::CLASS::BAREHAND_MAX_MULTIPLIER, multiplier].min
1082 value *= multiplier
1083 value /= 100
1084 return value
1085 end
1086 #============================================================================#
1087 # * Change Parameters based on Class #
1088 #============================================================================#
1089 #--------------------------------------------------------------------------
1090 # * Get Basic Maximum HP
1091 #--------------------------------------------------------------------------
1092 alias job_base_maxhp base_maxhp unless $@
1093 def base_maxhp
1094 n = job_base_maxhp
1095 n += base_stat_class(0)
1096 return Integer(n)
1097 end
1098 #--------------------------------------------------------------------------
1099 # * Get basic Maximum MP
1100 #--------------------------------------------------------------------------
1101 alias job_base_maxmp base_maxmp unless $@
1102 def base_maxmp
1103 n = job_base_maxmp
1104 n += base_stat_class(1)
1105 return Integer(n)
1106 end
1107 #--------------------------------------------------------------------------
1108 # * Get Basic Attack
1109 #--------------------------------------------------------------------------
1110 alias job_base_atk base_atk unless $@
1111 def base_atk
1112 n = job_base_atk
1113 n += base_stat_class(2)
1114 barehand_trait = self.barehand?
1115 n = barehanded_multiplier(n) if barehand_trait
1116 return Integer(n)
1117 end
1118 #--------------------------------------------------------------------------
1119 # * Get Basic Defense
1120 #--------------------------------------------------------------------------
1121 alias job_base_def base_def unless $@
1122 def base_def
1123 n = job_base_def
1124 n += base_stat_class(3)
1125 return Integer(n)
1126 end
1127 #--------------------------------------------------------------------------
1128 # * Get Basic Spirit
1129 #--------------------------------------------------------------------------
1130 alias job_base_spi base_spi unless $@
1131 def base_spi
1132 n = job_base_spi
1133 n += base_stat_class(4)
1134 return Integer(n)
1135 end
1136 #--------------------------------------------------------------------------
1137 # * Get Basic Agility
1138 #--------------------------------------------------------------------------
1139 alias job_base_agi base_agi unless $@
1140 def base_agi
1141 n = job_base_agi
1142 n += base_stat_class(5)
1143 return Integer(n)
1144 end
1145 #--------------------------------------------------------------------------
1146 # * Get Basic Resistance
1147 #--------------------------------------------------------------------------
1148 if $imported["BattlerStatRES"] or $imported["RES Stat"]
1149 alias job_base_res base_res unless $@
1150 def base_res
1151 n = job_base_res
1152 n += base_stat_class(6)
1153 return Integer(n)
1154 end
1155 end
1156 #--------------------------------------------------------------------------
1157 # * Get Basic Dexterity
1158 #--------------------------------------------------------------------------
1159 if $imported["BattlerStatDEX"] or $imported["DEX Stat"]
1160 alias job_base_dex base_dex unless $@
1161 def base_dex
1162 n = job_base_dex
1163 n += base_stat_class(7)
1164 return Integer(n)
1165 end
1166 end
1167end
1168#===============================================================================
1169# *Window_Base
1170#===============================================================================
1171class Window_Base < Window
1172 #--------------------------------------------------------------------------
1173 # * Draw Class Level
1174 #--------------------------------------------------------------------------
1175 def draw_class_level(actor, x, y)
1176 w = 60
1177 i = actor.class_id
1178 c = $data_classes[i]
1179 level = actor.class_level[c.id]
1180 maxlevel = S_B::CLASS::CLASS_MAX_LEVELS[c.id]
1181 maxlevel = S_B::CLASS::MAX_CLASS_LEVEL_DEFAULT if maxlevel == nil
1182 unless level == maxlevel
1183 self.contents.font.color = system_color
1184 self.contents.draw_text(x, y, w - 30, WLH, "(#{Vocab::level_a}.")
1185 self.contents.draw_text(x, y, w, WLH, "#{level.to_s})", 2)
1186 end
1187 end
1188 #--------------------------------------------------------------------------
1189 alias job_draw_actor_class draw_actor_class unless $@
1190 #--------------------------------------------------------------------------
1191 def draw_actor_class(actor, x, y)
1192 i = actor.class_id
1193 c = $data_classes[i]
1194 level = actor.class_level[c.id]
1195 maxlevel = S_B::CLASS::CLASS_MAX_LEVELS[c.id]
1196 maxlevel = S_B::CLASS::MAX_CLASS_LEVEL_DEFAULT if maxlevel == nil
1197 if level == maxlevel
1198 w = x + 108
1199 draw_icon(S_B::CLASS::MASTERED_ICON, x, y, enabled = true)
1200 job_draw_actor_class(actor, x + 24, y)
1201 else
1202 job_draw_actor_class(actor, x, y)
1203 end
1204 end
1205 #--------------------------------------------------------------------------
1206 # * Draw Class Experience
1207 #--------------------------------------------------------------------------
1208 def draw_jp_exp(actor, x, y)
1209 w = self.contents.width
1210 i = actor.class_id
1211 c = $data_classes[i]
1212 level = actor.class_level[c.id]
1213 maxlevel = S_B::CLASS::CLASS_MAX_LEVELS[c.id]
1214 maxlevel = S_B::CLASS::MAX_CLASS_LEVEL_DEFAULT if maxlevel == nil
1215 unless level == maxlevel
1216 s1 = actor.jp_exp_s(c.id)
1217 s2 = actor.next_class_rest_exp_s(c.id)
1218 s_next = "#{Vocab.jp} needed"
1219 self.contents.font.color = system_color
1220 self.contents.draw_text(x, y, w, WLH, Vocab.jp)
1221 self.contents.draw_text(x, y + WLH, w, WLH, s_next)
1222 self.contents.font.color = normal_color
1223 self.contents.draw_text(x, y, w, WLH, s1, 2)
1224 self.contents.draw_text(x, y + WLH, w, WLH, s2, 2)
1225 end
1226 end
1227end
1228#===============================================================================
1229# ¦ Scene_Title
1230#===============================================================================
1231class Scene_Title < Scene_Base
1232 #--------------------------------------------------------------------------
1233 # ? Create various game objects
1234 #--------------------------------------------------------------------------
1235 alias job_create_game_objects create_game_objects unless $@
1236 def create_game_objects
1237 job_create_game_objects
1238 unless S_B::CLASS::MENU_CLASS_CHANGE_OPTION
1239 $game_switches[S_B::CLASS::DISABLE_CLASS] = true
1240 $game_switches[S_B::CLASS::HIDE_CLASS] = true
1241 end
1242 end
1243end
1244#===============================================================================
1245# ¦ Game_Party
1246#===============================================================================
1247class Game_Party
1248 #--------------------------------------------------------------------------
1249 def jobchange_enable?
1250 if $game_switches[S_B::CLASS::DISABLE_CLASS]
1251 return false
1252 else
1253 return true
1254 end
1255 end
1256end
1257
1258#==============================================================================
1259# ** Game_Troop (addon) *from yanfly
1260#==============================================================================
1261class Game_Troop < Game_Unit
1262 attr_accessor :jp_total
1263 #--------------------------------------------------------------------------
1264 def jp_total
1265 jp = 0
1266 if S_B::CLASS::ENEMIES_GIVE_JP
1267 for enemy in dead_members
1268 jp += enemy.enemy.enemy_jp unless enemy.hidden
1269 end
1270 end
1271 return jp
1272 end
1273end
1274#==============================================================================
1275# Game_Battler *from yanfly
1276#==============================================================================
1277class Game_Battler
1278 attr_accessor :jp_counter
1279 #--------------------------------------------------------------------------
1280 # perform gain_jp
1281 #--------------------------------------------------------------------------
1282 def gain_jp_battle(amount)
1283 return unless self.actor?
1284 jp = amount
1285 for state in states
1286 jp *= state.bonus_jp_per
1287 jp /= 100
1288 end
1289 for state in states
1290 jp += state.bonus_jp_set
1291 end
1292 if double_exp_gain
1293 jp *= 2
1294 end
1295 self.jp_counter += jp if $scene.is_a?(Scene_Battle)
1296 end
1297 #--------------------------------------------------------------------------
1298 # jp counter
1299 #--------------------------------------------------------------------------
1300 def jp_counter
1301 @jp_counter = 0 if @jp_counter == nil
1302 return @jp_counter
1303 end
1304 def jp_counter=(newvalue)
1305 @jp_counter = 0 if @jp_counter == nil
1306 @jp_counter = newvalue
1307 end
1308 #--------------------------------------------------------------------------
1309 # alias attack effect
1310 #--------------------------------------------------------------------------
1311 alias attack_effect_sss attack_effect unless $@
1312 def attack_effect(attacker)
1313 attack_effect_sss(attacker)
1314 return unless attacker.actor?
1315 return unless S_B::CLASS::USE_BONUS_JP
1316 return unless S_B::CLASS::EARN_JP_VIA_ATTACK_ENABLE
1317 amount = S_B::CLASS::EARN_JP_VIA_ATTACK_AMOUNT
1318 unless S_B::CLASS::EARN_JP_VIA_ATTACK_RANDOM == 0
1319 amount += rand(S_B::CLASS::EARN_JP_VIA_ATTACK_RANDOM)
1320 end
1321 attacker.gain_jp_battle(amount)
1322 end
1323 #--------------------------------------------------------------------------
1324 # alias skill effect
1325 #--------------------------------------------------------------------------
1326 alias skill_effect_sss skill_effect unless $@
1327 def skill_effect(user, skill)
1328 skill_effect_sss(user, skill)
1329 return unless user.actor?
1330 return unless S_B::CLASS::USE_BONUS_JP
1331 return unless S_B::CLASS::EARN_JP_VIA_SKILL_ENABLE
1332 return unless $scene.is_a?(Scene_Battle)
1333 amount = S_B::CLASS::EARN_JP_VIA_SKILL_AMOUNT
1334 unless S_B::CLASS::EARN_JP_VIA_SKILL_RANDOM == 0
1335 amount += rand(S_B::CLASS::EARN_JP_VIA_SKILL_RANDOM)
1336 end
1337 amount += skill.jp_boost_set unless skill.jp_boost_set <= 0
1338 jp += rand(skill.jp_boost_ran) unless skill.jp_boost_ran <= 0
1339 user.gain_jp_battle(amount)
1340 end
1341 #--------------------------------------------------------------------------
1342 # alias item effect
1343 #--------------------------------------------------------------------------
1344 alias item_effect_sss item_effect unless $@
1345 def item_effect(user, item)
1346 item_effect_sss(user, item)
1347 return unless user.actor?
1348 user.jp_received(item.gain_jp, nil, true)
1349 #----------------------------------
1350 if item.unlock_class != []
1351 for class_id in item.unlock_class
1352 user.unlock_class(class_id)
1353 end
1354 end
1355 if item.lock_class != []
1356 for class_id in item.lock_class
1357 user.lock_class(class_id)
1358 end
1359 end
1360 #----------------------------------
1361 return unless S_B::CLASS::USE_BONUS_JP
1362 return unless S_B::CLASS::EARN_JP_VIA_ITEMS_ENABLE
1363 return unless $scene.is_a?(Scene_Battle)
1364 amount = S_B::CLASS::EARN_JP_VIA_ITEMS_AMOUNT
1365 unless S_B::CLASS::EARN_JP_VIA_ITEMS_RANDOM == 0
1366 amount += rand(S_B::CLASS::EARN_JP_VIA_ITEMS_RANDOM)
1367 end
1368 user.gain_jp_battle(amount)
1369 end
1370 #--------------------------------------------------------------------------
1371 # alias item test
1372 #--------------------------------------------------------------------------
1373 alias item_test_sss item_test unless $@
1374 def item_test(user, item)
1375 if self.actor?
1376 return true if item.unlock_class != []
1377 return true if item.lock_class != []
1378 return true if item.gain_jp > 0
1379 end
1380 return item_test_sss(user, item)
1381 end
1382end
1383#==============================================================================
1384# ** Scene_Battle (addon) *from yanfly
1385#==============================================================================
1386class Scene_Battle < Scene_Base
1387 #--------------------------------------------------------------------------
1388 # alias process_battle_start
1389 #--------------------------------------------------------------------------
1390 alias process_battle_start_sss process_battle_start unless $@
1391 def process_battle_start
1392 for actor in $game_party.members
1393 actor.jp_counter = 0
1394 end
1395 process_battle_start_sss
1396 end
1397 #--------------------------------------------------------------------------
1398 # alias execute_action_guard
1399 #--------------------------------------------------------------------------
1400 alias execute_action_guard_sss execute_action_guard unless $@
1401 def execute_action_guard
1402 execute_action_guard_sss
1403 return unless @active_battler.actor?
1404 return unless S_B::CLASS::USE_BONUS_JP
1405 return unless S_B::CLASS::EARN_JP_VIA_GUARD_ENABLE
1406 amount = S_B::CLASS::EARN_JP_VIA_GUARD_AMOUNT
1407 unless S_B::CLASS::EARN_JP_VIA_GUARD_RANDOM == 0
1408 amount += rand(S_B::CLASS::EARN_JP_VIA_GUARD_RANDOM)
1409 end
1410 @active_battler.gain_jp_battle(amount)
1411 end
1412
1413 alias job_display_exp_and_gold display_exp_and_gold unless $@
1414 def display_exp_and_gold
1415 @ignore_wait_for_message = true
1416 # call the original code
1417
1418 job_display_exp_and_gold
1419
1420 display_JP
1421 @ignore_wait_for_message = false
1422 wait_for_message
1423 end
1424 #--------------------------------------------------------------------------
1425 def display_JP
1426 jp = 0
1427 jp = $game_troop.jp_total if S_B::CLASS::ENEMIES_GIVE_JP
1428 if jp > 0
1429 text = sprintf(Vocab::ObtainClassExp, jp)
1430 $game_message.texts.push('\.' + text)
1431 end
1432 for actor in $game_party.existing_members
1433 jp = 0
1434 jp = $game_troop.jp_total if S_B::CLASS::ENEMIES_GIVE_JP
1435
1436 unless $imported["battleresults"]
1437 if S_B::CLASS::USE_BONUS_JP && S_B::CLASS::DISPLAY_BONUS_JP
1438 i = actor.class_id
1439 c = $data_classes[i]
1440 maxlevel = S_B::CLASS::CLASS_MAX_LEVELS[c.id]
1441 maxlevel = S_B::CLASS::MAX_CLASS_LEVEL_DEFAULT if maxlevel == nil
1442 if actor.jp_counter > 0 && actor.class_level != maxlevel
1443 text = sprintf(Vocab::Actor_Msg, actor.name, actor.jp_counter)
1444 $game_message.texts.push('\>' + text)
1445 end
1446 end
1447 end
1448 if actor.double_exp_gain
1449 jp *= 2
1450 end
1451 for state in actor.states
1452 jp *= state.bonus_jp_per
1453 jp /= 100
1454 end
1455 for state in actor.states
1456 jp += state.bonus_jp_set
1457 end
1458 jp = jp + actor.jp_counter if S_B::CLASS::USE_BONUS_JP
1459 last_level = actor.class_level
1460 last_skills = actor.skills
1461 actor.jp_received(jp, nil, true)
1462 end
1463 end
1464end
1465#==============================================================================
1466# ** Scene_Job (new) *from prexus
1467#==============================================================================
1468class Scene_Job < Scene_Base
1469 #--------------------------------------------------------------------------
1470 def initialize(actor_index = 0, menu_index = 0)
1471 @menu_index = menu_index
1472 @actor_index = actor_index
1473 end
1474 #--------------------------------------------------------------------------
1475 def start
1476 @actor = $game_party.members[@actor_index]
1477 create_menu_background
1478 create_windows
1479 @classlist_window.refresh
1480 end
1481 #--------------------------------------------------------------------------
1482 def create_windows
1483 @classlist_window = Window_ClassPick.new(@actor)
1484 @classchange_window = Window_Class_Change.new(@actor)
1485 @skills_window = Window_ShowSkills.new(@actor)
1486 @help_window = Window_Help.new
1487 @help_window.visible = false
1488 @help_window.close
1489 @help_window2 = Window_Help.new
1490 @classchange_window.x = 0
1491 @classlist_window.y = @classchange_window.y = @help_window2.height
1492 @classchange_window.width = @classlist_window.width = Graphics.width / 2
1493 @classlist_window.x = @classchange_window.width
1494 @classlist_window.height = @classchange_window.height = Graphics.height - @help_window2.height
1495 @classlist_window.index = 0
1496 @help_window.width = 544
1497 @help_window.height = 64
1498 @help_window.x = 0
1499 @help_window.y = 354
1500 @help_window.back_opacity = 255
1501 @help_window.create_contents
1502 @skills_window.help_window = @help_window
1503 @skills_window.help_window.back_opacity = 255
1504 @confirm_window = Window_Confirm.new
1505 end
1506 #--------------------------------------------------------------------------
1507 def update_windows
1508 @classlist_window.update(@actor)
1509 @classchange_window.update
1510 @skills_window.update
1511 @help_window.update
1512 @help_window2.update
1513 @confirm_window.update
1514 if @classlist_window.active
1515 @classchange_window.set(@actor, @classlist_window.item)
1516 id = @classlist_window.item.id
1517 if S_B::CLASS::Class_Descriptions.include?(id)
1518 @help_window2.set_text(S_B::CLASS::Class_Descriptions[id][0])
1519 else
1520 @help_window2.set_text("")
1521 end
1522 end
1523 end
1524 #--------------------------------------------------------------------------
1525 def terminate
1526 super
1527 dispose_menu_background
1528 @classlist_window.dispose
1529 @classchange_window.dispose
1530 @skills_window.dispose
1531 @help_window.dispose
1532 @help_window2.dispose
1533 @confirm_window.dispose
1534 end
1535 #--------------------------------------------------------------------------
1536 def update
1537 super
1538 update_menu_background
1539 update_windows
1540 if @classlist_window.active
1541 update_class_list
1542 elsif @skills_window.active
1543 update_skills_list
1544 elsif @confirm_window.active
1545 update_confirm_window
1546 end
1547 end
1548 #--------------------------------------------------------------------------
1549 # * Switch to Next Actor Screen
1550 #--------------------------------------------------------------------------
1551 def next_actor
1552 @actor_index += 1
1553 @actor_index %= $game_party.members.size
1554 $scene = Scene_Job.new(@actor_index, @menu_index)
1555 end
1556 #--------------------------------------------------------------------------
1557 # * Switch to Previous Actor Screen
1558 #--------------------------------------------------------------------------
1559 def prev_actor
1560 @actor_index += $game_party.members.size - 1
1561 @actor_index %= $game_party.members.size
1562 $scene = Scene_Job.new(@actor_index, @menu_index)
1563 end
1564 #--------------------------------------------------------------------------
1565 # * Return to previous scene
1566 #--------------------------------------------------------------------------
1567 def return_scene
1568 if $imported["SceneStatusReDux"]
1569 update_menu_background
1570 $scene = Scene_Menu.new(3)
1571 elsif @menu_index == 0
1572 $scene = Scene_Map.new
1573 else
1574 $scene = Scene_Menu.new(@menu_index)
1575 end
1576 end
1577 #--------------------------------------------------------------------------
1578 def update_class_list
1579 if Input.trigger?(Input::B)
1580 Sound.play_cancel
1581 return_scene
1582 elsif Input.trigger?(Input::C)
1583 if @classlist_window.item.id == @classlist_window.actor.class_id
1584 Sound.play_buzzer
1585 return
1586 end
1587 Sound.play_decision
1588 @confirm_window.visible = true
1589 @confirm_window.active = true
1590 @confirm_window.index = 0
1591 @confirm_window.open
1592 @classlist_window.active = false
1593 elsif Input.trigger?(S_B::CLASS::SHOW_SKILLS_WINDOW)
1594 Sound.play_decision
1595 @skills_window.set(@actor, @classlist_window.item.id)
1596 @skills_window.active = true
1597 @skills_window.index = 1
1598 @skills_window.open
1599 @help_window.visible = true
1600 @help_window.open
1601 @classlist_window.active = false
1602 elsif Input.trigger?(Input::R) or Input.trigger?(Input::RIGHT)
1603 Sound.play_cursor
1604 next_actor
1605 elsif Input.trigger?(Input::L) or Input.trigger?(Input::LEFT)
1606 Sound.play_cursor
1607 prev_actor
1608 end
1609 end
1610 def update_skills_list
1611 if Input.trigger?(Input::B)
1612 Sound.play_cancel
1613 @classlist_window.active = true
1614 @skills_window.active = false
1615 @skills_window.index = -1
1616 @skills_window.close
1617 @help_window.close
1618 end
1619 end
1620 def update_confirm_window
1621 if Input.trigger?(Input::B)
1622 Sound.play_cancel
1623 if @confirm_window.index == 1
1624 @confirm_window.active = false
1625 @confirm_window.index = -1
1626 @confirm_window.close
1627 @classlist_window.active = true
1628 return
1629 else
1630 @confirm_window.index = 1
1631 return
1632 end
1633 elsif Input.trigger?(Input::C)
1634 case @confirm_window.index
1635 when 0
1636 Sound.play_decision
1637 actor = @classlist_window.actor
1638 actor.class_id = @classlist_window.item.id
1639 #Check to make sure that
1640 if @actor.hp > @actor.maxhp
1641 @actor.hp = @actor.maxhp
1642 end
1643 if @actor.mp > @actor.maxmp
1644 @actor.mp = @actor.maxmp
1645 end
1646 @confirm_window.active = false
1647 @confirm_window.index = -1
1648 @confirm_window.close
1649 @classlist_window.refresh
1650 @classchange_window.refresh
1651 @classlist_window.active = true
1652 when 1
1653 @confirm_window.active = false
1654 @confirm_window.index = -1
1655 @confirm_window.close
1656 @classlist_window.active = true
1657 return
1658 end
1659 end
1660 end
1661end
1662
1663#==============================================================================
1664# ** Window_ClassPick
1665# window where selectable class list is generated
1666#==============================================================================
1667class Window_ClassPick < Window_Selectable
1668 #--------------------------------------------------------------------------
1669 def initialize(actor)
1670 super(Graphics.width / 2, 48, Graphics.width / 2, Graphics.height - (WLH + 32))
1671 create_contents
1672 @actor = actor
1673 self.index = 0
1674 self.active = true
1675 refresh
1676 end
1677 #--------------------------------------------------------------------------
1678 def update(actor = nil)
1679 super()
1680 return if actor == @actor
1681 @actor = actor
1682 refresh
1683 end
1684 #--------------------------------------------------------------------------
1685 def actor
1686 return @actor
1687 end
1688 #--------------------------------------------------------------------------
1689 def item
1690 return $data_classes[@actor.unlocked_classes[index]]
1691 end
1692 #--------------------------------------------------------------------------
1693 # refresh
1694 #--------------------------------------------------------------------------
1695 def refresh
1696 @data = []
1697 for class_id in @actor.unlocked_classes
1698 @data.push(class_id)
1699 end
1700 @item_max = @data.size
1701 create_contents
1702 for i in 0...@item_max
1703 draw_item(i)
1704 end
1705 end
1706 #--------------------------------------------------------------------------
1707 # draw item
1708 #--------------------------------------------------------------------------
1709 def draw_item(index)
1710 rect = item_rect(index)
1711 self.contents.clear_rect(rect)
1712 iclass = $data_classes[@actor.unlocked_classes[index]]
1713 if iclass.id != 0
1714 rect.width -= 4
1715 enabled = true
1716 enabled = false if iclass == @actor.class
1717 level = @actor.class_level[iclass.id]
1718 maxlevel = S_B::CLASS::CLASS_MAX_LEVELS[iclass.id]
1719 maxlevel = S_B::CLASS::MAX_CLASS_LEVEL_DEFAULT if maxlevel == nil
1720 if level == maxlevel
1721 icon = S_B::CLASS::MASTERED_ICON
1722 elsif S_B::CLASS::USE_ICONS_FOR_CLASSES
1723 if S_B::CLASS::Class_Icons.include?(iclass.id)
1724 icon = S_B::CLASS::Class_Icons[iclass.id]
1725 else
1726 icon = S_B::CLASS::Class_Icons[0]
1727 end
1728 end
1729 draw_icon(icon, rect.x, rect.y, enabled)
1730 dx = rect.x
1731 dy = rect.y
1732 dw = rect.width
1733 dh = rect.height
1734 self.contents.font.color.alpha = enabled ? 255 : 128
1735 self.contents.draw_text(dx+24, dy, dw-48, dh, iclass.name, 0)
1736 unless !S_B::CLASS::USE_BONUS_JP && !S_B::CLASS::ENEMIES_GIVE_JP
1737 self.contents.draw_text(dx, dy, dw, dh, "Lv. " + level.to_s, 2)
1738 end
1739 end
1740 end
1741end
1742#==============================================================================
1743# ** Window_Class_Change
1744#==============================================================================
1745class Window_Class_Change < Window_Base
1746 #--------------------------------------------------------------------------
1747 def initialize(actor = nil, class_obj = nil)
1748 super(0, 48, Graphics.width / 2, Graphics.height - (WLH + 32))
1749 create_contents
1750 @actor = actor
1751 @class_obj = class_obj
1752 refresh
1753 end
1754 #--------------------------------------------------------------------------
1755 def actor
1756 return @actor
1757 end
1758 #--------------------------------------------------------------------------
1759 def item
1760 return @class_obj
1761 end
1762 #--------------------------------------------------------------------------
1763 def set(actor, class_obj)
1764 old_actor = @actor
1765 @actor = actor
1766 old_class_obj = @class_obj
1767 @class_obj = class_obj
1768 refresh if (old_actor != @actor) or (old_class_obj != @class_obj)
1769 end
1770 #--------------------------------------------------------------------------
1771 def refresh
1772 self.contents.clear
1773
1774 return unless @actor
1775 c = (@class_obj != nil ? @class_obj : $data_classes[@actor.class_id])
1776 x, y = 0, 0
1777 w = self.contents.width
1778 hy = self.contents.height - WLH * 4
1779 self.draw_actor_face(@actor, x + 2, y + 2)
1780
1781 draw_basic_info(112, 0)
1782 self.contents.font.color = system_color
1783 self.contents.draw_text(x, hy + WLH * 0, w, WLH, "Class:")
1784 unless !S_B::CLASS::USE_BONUS_JP && !S_B::CLASS::ENEMIES_GIVE_JP
1785 self.contents.draw_text(x, hy + WLH * 1, w, WLH, "Class #{Vocab::level_a}:")
1786 s_next = ("#{Vocab.jp} needed:")
1787 self.contents.draw_text(x, hy + WLH * 2, w, WLH, Vocab.jp)
1788 self.contents.draw_text(x, hy + WLH * 3, w, WLH, s_next)
1789 end
1790 dy = WLH * 4
1791
1792 y1 = (hy - dy - 80)/2
1793 y = y1 + dy
1794
1795 draw_parameters(x, y)
1796
1797 return unless @class_obj
1798 self.contents.font.color = normal_color
1799 self.contents.draw_text(x, hy + WLH * 0, w, WLH, c.name,2)
1800 maxlevel = S_B::CLASS::CLASS_MAX_LEVELS[c.id]
1801 maxlevel = S_B::CLASS::MAX_CLASS_LEVEL_DEFAULT if maxlevel == nil
1802 s1 = @actor.jp_exp_s(c.id)
1803 s2 = @actor.next_class_rest_exp_s(c.id)
1804 if @actor.class_level[c.id] == maxlevel
1805 draw_icon(S_B::CLASS::MASTERED_ICON, w - 24, hy + WLH * 1, enabled = true)
1806 self.contents.font.color = normal_color
1807 self.contents.draw_text(x, hy + WLH * 1, w - 24, WLH, "Mastered",2)
1808 else
1809 unless !S_B::CLASS::USE_BONUS_JP && !S_B::CLASS::ENEMIES_GIVE_JP
1810 self.contents.draw_text(x, hy + WLH * 1, w, WLH, @actor.class_level[c.id], 2)
1811 self.contents.font.color = normal_color
1812 end
1813 end
1814 self.contents.draw_text(x, hy + WLH * 2, w, WLH, s1, 2)
1815 self.contents.draw_text(x, hy + WLH * 3, w, WLH, s2, 2)
1816 end
1817
1818 def draw_basic_info(x, y)
1819 w = self.contents.width
1820 self.contents.font.color = system_color
1821 self.contents.draw_text(x, y + WLH * 0, w, WLH, "Name:")
1822 self.contents.font.color = normal_color
1823 self.contents.draw_text(x, y + WLH * 1, w - 112, WLH, actor.name, 2)
1824 self.contents.font.color = system_color
1825 self.contents.draw_text(x, y + WLH * 2, w, WLH, "Current Class:")
1826 self.contents.font.color = normal_color
1827 self.contents.draw_text(x, y + WLH * 3, w - 112, WLH, actor.class.name, 2)
1828 self.draw_actor_level(@actor, x - 112, y + WLH * 4)
1829 self.draw_icon(S_B::CLASS::Skills_Icon, w - 24, y + WLH * 4)
1830 self.contents.font.color = system_color
1831 self.contents.draw_text(x - 112, y + WLH * 4, w - 24, WLH, 'Skills', 2)
1832 end
1833
1834 def draw_parameters(x, y)
1835 last_font_size = self.contents.font.size
1836 if $imported["BattlerStatRES"] || $imported["BattlerStatDEX"] || $imported["RES Stat"] || $imported["DEX Stat"]
1837 self.contents.font.size = 13
1838 a = 13
1839 else
1840 self.contents.font.size = 15
1841 a = 15
1842 end
1843 draw_parameter(x, y + a * 0, 0)
1844 draw_parameter(x, y + a * 1, 1)
1845 draw_parameter(x, y + a * 2, 2)
1846 draw_parameter(x, y + a * 3, 3)
1847 draw_parameter(x, y + a * 4, 4)
1848 draw_parameter(x, y + a * 5, 5)
1849 b = 0
1850 draw_parameter(x, y + a * 6, 6) if $imported["BattlerStatRES"] or $imported["RES Stat"]
1851 b = 13 if $imported["BattlerStatRES"] or $imported["RES Stat"]
1852 draw_parameter(x, y + a * 6 + b, 7) if $imported["BattlerStatDEX"] or $imported["DEX Stat"]
1853 self.contents.font.size = last_font_size
1854 end
1855 #--------------------------------------------------------------------------
1856 # * Draw Parameters
1857 #--------------------------------------------------------------------------
1858 def draw_parameter(x, y, type)
1859 c = (@class_obj != nil ? @class_obj : $data_classes[@actor.class_id])
1860 case type
1861 when 0
1862 name = Vocab::hp_a
1863 value = @actor.maxhp
1864 when 1
1865 name = Vocab::mp_a
1866 value = @actor.maxmp
1867 when 2
1868 name = Vocab::atk
1869 value = @actor.atk
1870 when 3
1871 name = Vocab::def
1872 value = @actor.def
1873 when 4
1874 name = Vocab::spi
1875 value = @actor.spi
1876 when 5
1877 name = Vocab::agi
1878 value = @actor.agi
1879 when 6
1880 name = "RES"
1881 value = @actor.res
1882 when 7
1883 name = "DEX"
1884 value = @actor.dex
1885 end
1886 old = @actor.base_stat_class(type)
1887 if @class_obj
1888 new = @actor.base_stat_class(type, c.id)
1889 new_value = value - old + new
1890 difference = new - old
1891 if difference > 0
1892 difference = "+ #{new - old}"
1893 end
1894 end
1895 self.contents.font.color = system_color
1896 self.contents.draw_text(x + 26, y, 80, WLH, name)
1897 self.contents.font.color = normal_color
1898 self.contents.draw_text(x + 70, y, 30, WLH, value, 2)
1899 self.contents.font.color = system_color
1900 self.contents.draw_text(x + 122, y, 20, WLH, "-->", 1)
1901 if new_value != nil
1902 self.contents.font.color = new_parameter_color(value, new_value)
1903 if S_B::CLASS::SHOW_DIFFERENCE
1904 if difference == 0
1905 self.contents.draw_text(x + 152, y, 30, WLH, "---", 2)
1906 else
1907 self.contents.draw_text(x + 152, y, 30, WLH, difference, 2)
1908 end
1909 else
1910 self.contents.draw_text(x + 152, y, 30, WLH, new_value, 2)
1911 end
1912 end
1913 end
1914
1915 def new_parameter_color(old_value, new_value)
1916 if new_value > old_value # Get stronger
1917 return power_up_color
1918 elsif new_value == old_value # No change
1919 return normal_color
1920 else # Get weaker
1921 return power_down_color
1922 end
1923 end
1924end
1925#==============================================================================
1926# ** Window_ShowSkills
1927#==============================================================================
1928class Window_ShowSkills < Window_Selectable
1929 #--------------------------------------------------------------------------
1930 def initialize(actor, class_id = nil)
1931 super(0, 56, 272, 360)
1932 @actor = actor
1933 @class_id = (class_id != nil ? class_id : @actor.class_id)
1934 @item_max = $data_classes[@class_id].learnings.size
1935 @column_max = 2
1936 create_contents
1937 self.index = -1
1938 self.active = false
1939 self.openness = 0
1940 self.back_opacity = 255
1941 refresh
1942 end
1943 #--------------------------------------------------------------------------
1944 def set(actor, class_id)
1945 old_actor = @actor
1946 @actor = actor
1947 old_class_id = @class_id
1948 @class_id = class_id
1949 @item_max = $data_classes[@class_id].learnings.size unless @class_id == nil
1950 create_contents
1951 refresh
1952 end
1953 #--------------------------------------------------------------------------
1954 def refresh
1955 return if @class_id == nil
1956 return if $data_classes[@class_id].learnings.empty?
1957 for i in 0...@item_max
1958 rect = item_rect(i)
1959 learning = $data_classes[@class_id].learnings[i]
1960 next unless learning
1961 self.contents.font.color.alpha = (@actor.class_level[@class_id] >= learning.level ? 255 : 128)
1962 self.contents.draw_text(rect, $data_skills[learning.skill_id].name)
1963 end
1964 end
1965 #--------------------------------------------------------------------------
1966 def update_help
1967 if $data_classes[@class_id].learnings.empty?
1968 self.help_window.set_text('')
1969 self.back_opacity = 255
1970 return
1971 end
1972 level = $data_classes[@class_id].learnings[self.index].level
1973 skill = $data_skills[$data_classes[@class_id].learnings[self.index].skill_id]
1974 self.help_window.set_text(skill == nil ? '' : "[Level #{level}] #{skill.description}")
1975 self.back_opacity = 255
1976 end
1977end
1978#==============================================================================
1979# ** Window_Confirm
1980#==============================================================================
1981class Window_Confirm < Window_Selectable
1982 #--------------------------------------------------------------------------
1983 def initialize(index = -1)
1984 dx = (Graphics.width - 160)/2
1985 super(dx, 168, 160, 80)
1986 create_contents
1987 @item_max = 2
1988 @column_max = 2
1989 self.index = index
1990 self.active = false
1991 self.openness = 0
1992 refresh
1993 end
1994 #--------------------------------------------------------------------------
1995 def refresh
1996 for i in 0..@item_max
1997 rect = item_rect(i)
1998 self.contents.clear_rect(rect)
1999 end
2000 self.contents.draw_text(0, 0, self.contents.width, WLH, "Confirm?", 1)
2001 rect = item_rect(0)
2002 self.contents.draw_text(rect, "Yes", 1)
2003 rect = item_rect(1)
2004 self.contents.draw_text(rect, "No", 1)
2005 end
2006 #--------------------------------------------------------------------------
2007 def item_rect(index)
2008 rect = Rect.new(0, 0, 0, 0)
2009 rect.width = (contents.width + @spacing) / @column_max - @spacing
2010 rect.height = WLH
2011 rect.x = index % @column_max * (rect.width + @spacing)
2012 rect.y = (index / @column_max * WLH) + WLH
2013 return rect
2014 end
2015end
2016#==============================================================================
2017# ** Character_Class
2018#==============================================================================
2019class Character_Class
2020 def self.new_class(actor, class_id)
2021 $game_actors[actor].unlock_class(class_id)
2022 end
2023 #--------------------------------------------------------------------------
2024 def self.remove_class(actor, class_id)
2025 $game_actors[actor].lock_class(class_id)
2026 end
2027end
2028
2029#==============================================================================
2030# Window_Command (imported from KGC)
2031#==============================================================================
2032
2033class Window_Command < Window_Selectable
2034unless method_defined?(:add_command)
2035 #--------------------------------------------------------------------------
2036 # add command
2037 #--------------------------------------------------------------------------
2038 def add_command(command)
2039 @commands << command
2040 @item_max = @commands.size
2041 item_index = @item_max - 1
2042 refresh_command
2043 draw_item(item_index)
2044 return item_index
2045 end
2046 #--------------------------------------------------------------------------
2047 # refresh command
2048 #--------------------------------------------------------------------------
2049 def refresh_command
2050 buf = self.contents.clone
2051 self.height = [self.height, row_max * WLH + 32].max
2052 create_contents
2053 self.contents.blt(0, 0, buf, buf.rect)
2054 buf.dispose
2055 end
2056 #--------------------------------------------------------------------------
2057 # insert command
2058 #--------------------------------------------------------------------------
2059 def insert_command(index, command)
2060 @commands.insert(index, command)
2061 @item_max = @commands.size
2062 refresh_command
2063 refresh
2064 end
2065 #--------------------------------------------------------------------------
2066 # remove command
2067 #--------------------------------------------------------------------------
2068 def remove_command(command)
2069 @commands.delete(command)
2070 @item_max = @commands.size
2071 refresh
2072 end
2073end
2074end
2075#===============================================================================
2076# Scene Menu
2077#===============================================================================
2078class Scene_Menu < Scene_Base
2079 #--------------------------------------------------------------------------
2080 # alias create command window
2081 #--------------------------------------------------------------------------
2082 alias create_command_window_sss create_command_window unless $@
2083 def create_command_window
2084 create_command_window_sss
2085 return if $imported["CustomMenuCommand"]
2086 return if $game_switches[S_B::CLASS::HIDE_CLASS]
2087 if S_B::CLASS::MENU_CLASS_CHANGE_OPTION || $game_party.jobchange_enable?
2088 scc_text = Vocab::Classes_Vocab
2089 @command_class_change = @command_window.add_command(scc_text)
2090 @command_window.draw_item(@command_class_change,
2091 $game_party.jobchange_enable?)
2092 if @command_window.oy > 0
2093 @command_window.oy -= Window_Base::WLH
2094 end
2095 end
2096 @command_window.index = @menu_index
2097 end
2098 #--------------------------------------------------------------------------
2099 # alias update command selection
2100 #--------------------------------------------------------------------------
2101 alias update_command_selection_sss update_command_selection unless $@
2102 def update_command_selection
2103 call_job_command = 0
2104 if Input.trigger?(Input::C)
2105 case @command_window.index
2106 when @command_class_change
2107 call_job_command = 1
2108 end
2109 end
2110 if call_job_command == 1
2111 if $game_party.members.size == 0 || !$game_party.jobchange_enable?
2112 Sound.play_buzzer
2113 return
2114 end
2115 Sound.play_decision
2116 start_actor_selection
2117 return
2118 end
2119 update_command_selection_sss
2120 end
2121
2122 #--------------------------------------------------------------------------
2123 # alias update actor selection
2124 #--------------------------------------------------------------------------
2125 alias update_actor_selection_sss update_actor_selection unless $@
2126 def update_actor_selection
2127 if Input.trigger?(Input::C)
2128 $game_party.last_actor_index = @status_window.index
2129 Sound.play_decision
2130 case @command_window.index
2131 when @command_class_change
2132 $scene = Scene_Job.new(@status_window.index,
2133 @command_class_change)
2134 return
2135 end
2136 end
2137 update_actor_selection_sss
2138 end
2139
2140end # Scene Menu
2141if S_B::CLASS::SHOW_CLASS_LVL_STATUS && (S_B::CLASS::USE_BONUS_JP || S_B::CLASS::ENEMIES_GIVE_JP)
2142 #==============================================================================
2143 # ** Window_MenuStatus
2144 #==============================================================================
2145 class Window_Status < Window_Base
2146 def draw_actor_class(actor, x, y)
2147 i = actor.class_id
2148 c = $data_classes[i]
2149 level = actor.class_level[c.id]
2150 maxlevel = S_B::CLASS::CLASS_MAX_LEVELS[c.id]
2151 maxlevel = S_B::CLASS::MAX_CLASS_LEVEL_DEFAULT if maxlevel == nil
2152 if level == maxlevel
2153 w = x + 108
2154 draw_icon(S_B::CLASS::MASTERED_ICON, x, y, true)
2155 job_draw_actor_class(actor, x + 24, y)
2156 else
2157 job_draw_actor_class(actor, x + 60, y)
2158 draw_class_level(actor, x, y)
2159 end
2160 end
2161 end
2162 class Window_Status_Actor < Window_Base
2163 def draw_actor_class(actor, x, y)
2164 i = actor.class_id
2165 c = $data_classes[i]
2166 level = actor.class_level[c.id]
2167 maxlevel = S_B::CLASS::CLASS_MAX_LEVELS[c.id]
2168 maxlevel = S_B::CLASS::MAX_CLASS_LEVEL_DEFAULT if maxlevel == nil
2169 if level == maxlevel
2170 w = x + 108
2171 draw_icon(S_B::CLASS::MASTERED_ICON, x, y, true)
2172 job_draw_actor_class(actor, x + 24, y)
2173 else
2174 job_draw_actor_class(actor, x + 60, y)
2175 draw_class_level(actor, x, y)
2176 end
2177 end
2178 end
2179end
2180if S_B::CLASS::SHOW_CLASS_LVL_MAIN && (S_B::CLASS::USE_BONUS_JP || S_B::CLASS::ENEMIES_GIVE_JP)
2181 class Window_MenuStatus < Window_Selectable
2182 def draw_actor_class(actor, x, y)
2183 i = actor.class_id
2184 c = $data_classes[i]
2185 level = actor.class_level[c.id]
2186 maxlevel = S_B::CLASS::CLASS_MAX_LEVELS[c.id]
2187 maxlevel = S_B::CLASS::MAX_CLASS_LEVEL_DEFAULT if maxlevel == nil
2188 if level == maxlevel
2189 w = x + 108
2190 draw_icon(S_B::CLASS::MASTERED_ICON, x, y, true)
2191 job_draw_actor_class(actor, x + 24, y)
2192 else
2193 self.contents.font.color = normal_color
2194 self.contents.draw_text(x + 40, y, 108 - 20, WLH, actor.class.name)
2195 draw_class_level(actor, x - 20, y)
2196 end
2197 end
2198 end
2199end