Advertisement
estriole

EST - YEA - SUBCLASS ADDON - EXP, TRAIT, ETC

Mar 24th, 2013
1,560
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 30.35 KB | None | 0 0
  1. =begin
  2. #==============================================================================
  3.  ** EST - YEA - SUBCLASS ADD ON : GAIN EXP , LEARN SKILL, WORKING TRAIT, ETC
  4.  REWRITTEN !!!
  5.  v 3.07
  6. #------------------------------------------------------------------------------
  7.  Author : ESTRIOLE
  8.  also credits: Disturbed Inside for class level bugfix which i modified more
  9.  
  10.  Version History:
  11.   v 1.00 - 2012.06.21 > First relase
  12.   v 2.00 - final - 2012.06.25 > updated skill and trait from subclass works
  13.   v 3.00 - 2013.03.24 > - rewritten the script. to make it lots more
  14.                         compatible with another script.
  15.                         - add ability to set class max level by notetags:
  16.                         <class_max_lv: 20>
  17.                         to set the class max lv to 20.
  18.                         - add ability to set subclass exp rate for each class.
  19.                         so when that class is equipped as subclass. how many
  20.                         percent exp it will gained.
  21.                         <sub_exp_rate: 50>
  22.                         to set the class sub exp rate to 50 percent
  23.   v 3.01 - 2013.03.29 > - add configuration to set when exp divided by sub exp
  24.                         rate below 1. it could set exp gain to 1 instead of 0.
  25.                         example1: slimex2 give 8 exp * subrate 10% = 0,8 -> 1 exp
  26.                         example2: slimex2 give 0 exp * subrate 10% = 0 -> 0 exp.
  27.   v 3.02 - 2013.05.26 > - add support for float percentage sub exp rate. ex:
  28.                         <sub_exp_rate: 1.5> means 1.5% rate.
  29.                         even i doubt people will use it... but the function is available in case
  30.                         someone crazy enough to use it :D.
  31.                         - add ability to boost/reduce sub exp rate
  32.                         give notetags to actor/class/weapon/armor/state
  33.                         <sub_exp_mod: 30> means +30%
  34.                         it's direct addition to current rate so if the rate 50% it will become 80%
  35.                         <sub_exp_mod: -30> means -30%
  36.                         it's direct substraction to current rate so if the rate 50% it will become 20%
  37.                         all actor/class/subclass/weapon/armor/state mod stacks
  38.                         usefull to make accessory that make your subclass gain (+30% battle exp)
  39.                         - add ability to grant multiplier to sub_exp_rate. ex:
  40.                         <sub_exp_mult: 150> will multiply current rate to 150%
  41.                         multiplier STACKS
  42.   v 3.03 - 2013.05.28 > - add MAIN EXP RATE function. this function is SEPARATE
  43.                         with SUB EXP RATE. means increasing MAIN EXP RATE didn't
  44.                         raise sub exp gained. ONLY raised exp gained by main class.
  45.                         notetags the class with:
  46.                         <main_exp_rate: 75> -> to set main class exp rate to 75 percent
  47.                         - add ability to boost/reduce main exp rate
  48.                         give notetags to actor/class/weapon/armor/state
  49.                         <main_exp_mod: 30> means +30%
  50.                         it's direct addition to current rate so if the rate 50% it will become 80%
  51.                         <main_exp_mod: -30> means -30%
  52.                         it's direct substraction to current rate so if the rate 50% it will become 20%
  53.                         all actor/class/subclass/weapon/armor/state mod stacks
  54.                         usefull to make accessory that make your mainclass gain (+30% battle exp)
  55.                         - add ability to grant multiplier to main_exp_rate. ex:
  56.                         <main_exp_mult: 150> will multiply current rate to 150%
  57.                         multiplier STACKS
  58.   v 3.04 - 2013.10.22 > - add compatibility patch to yanfly adjust limit script                        
  59.   v 3.05 - 2014.01.09 > - stop exp gain when max level reached. (both subclass and main class works now)
  60.                         in case the exp gained will make the actor exceed max level... it will add to maximum exp
  61.                         you can get to reach next level and ignore the rest.  
  62.   v 3.06 - 2014.01.16 > - compatibility patch with yanfly victory aftermath. to recognize exp rate.
  63.   v 3.07 - 2014.07.16 > - fix the script. IF maintain level set to true. stop the sub exp gain.
  64.                         since the level should be the same with main class.
  65.                        
  66. #------------------------------------------------------------------------------
  67.   This script is addon to YEA class system. Subclass equipped will gain
  68.   full or some exp. gain skill as the subclass level up. actor will have
  69.   all the subclass trait. also if using Tsukihime Effect Manager. subclass
  70.   can be given 'effect' too like normal class.
  71. #------------------------------------------------------------------------------
  72.  Compatibility
  73.    1) REQUIRES the script YEA - Class System. put this script below yanfly class script
  74.  
  75.    -> built in compatibility with Tsukihime Effect Manager script
  76.    -> built in compatibility with Formar extra trait lv up script
  77.    -> built in compatibility with yanfly adjust limit
  78.  
  79.    2) put this script BELOW yanfly victory aftermath
  80.    
  81.  HOW TO USE:
  82.  1) by plugging this script automatically...
  83.     - subclass gain exp (default sub_exp_rate is using what you defined in config)
  84.     - subclass's skill and trait gained by actor
  85.     - subclass's effect is executed (if using tsukihime effect manager)
  86.    
  87.  2) you can set a class max level by notetagging the class with:
  88.  
  89.     <class_max_lv: 20>
  90.     to set the class max lv to 20. change the number as you want.
  91.  
  92.  3) to customize each class to have different sub exp rate. give the class
  93.  
  94.     <sub_exp_rate: 50>
  95.     to set the class sub exp rate to 50%.  change the number as you want.
  96.    
  97.     support float percentage. ex:
  98.    
  99.     <sub_exp_rate: 2.5>
  100.     to set the class sub exp rate to 2.5%    
  101.  
  102.  4) you can give sub_exp_rate modifier by notetagging:
  103.     actor / class / subclass / weapon / armor / state
  104.    
  105.     <sub_exp_mod: 30> means +30% increase to sub exp rate
  106.  
  107.     it's direct addition so if current sub_exp_rate is 50% it will become 80%
  108.     support negative value too
  109.    
  110.     <sub_exp_mod: -30> means -30% decrease to sub exp rate
  111.    
  112.     it's direct substraction so if current sub_exp_rate is 50% it will become 20%
  113.     ALL sub exp rate modifier STACKS
  114.     so example current sub exp rate 50%
  115.     actor +10%, class -5%, subclass -5%, weapon +100%, armor1 -10%, armor2 -5%, state1 10%, state2 - 10%
  116.     final rate = (50%) +10% -5% -5% +100% -10% -5% +10% + 10%
  117.     count it yourself :D.
  118.  
  119.  5) you can give sub_exp_rate multiplier by notetagging:
  120.     actor / class / subclass / weapon / armor / state
  121.    
  122.     <sub_exp_mult: 150> means sub exp rate multiplied by 150%
  123.  
  124.     it's multiplication so if current sub_exp_rate is 50% it will become 75%
  125.     current sub_exp rate is sub exp rate after adding sub_exp_mod
  126.     ALL sub exp rate multiplier STACKS
  127.     so example current sub exp rate 50% (after adding exp_mod)
  128.     actor *150%, class *50%, subclass *500%, weapon *125%, armor1 *250%, armor2 *105%, state1 *410%, state2 *310%
  129.     final rate = (50%) * 150% * 500% * 125% * 250% * 105% * 410% * 310%
  130.     count it yourself :D.
  131.  
  132.  6) to customize each class to have different main exp rate. give the class
  133.  
  134.     <main_exp_rate: 50>
  135.     to set the class main exp rate to 50%.  change the number as you want.
  136.    
  137.     support float percentage. ex:
  138.    
  139.     <main_exp_rate: 2.5>
  140.     to set the class main exp rate to 2.5%    
  141.  
  142.  7) you can give main_exp_rate modifier by notetagging:
  143.     actor / class / subclass / weapon / armor / state
  144.    
  145.     <main_exp_mod: 30> means +30% increase to main exp rate
  146.  
  147.     it's direct addition so if current main_exp_rate is 50% it will become 80%
  148.     support negative value too
  149.    
  150.     <main_exp_mod: -30> means -30% decrease to main exp rate
  151.    
  152.     it's direct substraction so if current main_exp_rate is 50% it will become 20%
  153.     ALL main exp rate modifier STACKS
  154.     so example current main exp rate 50%
  155.     actor +10%, class -5%, subclass -5%, weapon +100%, armor1 -10%, armor2 -5%, state1 10%, state2 - 10%
  156.     final rate = (50%) +10% -5% -5% +100% -10% -5% +10% + 10%
  157.     count it yourself :D.
  158.  
  159.  8) you can give main_exp_rate multiplier by notetagging:
  160.     actor / class / subclass / weapon / armor / state
  161.    
  162.     <main_exp_mult: 150> means main exp rate multiplied by 150%
  163.  
  164.     it's multiplication so if current main_exp_rate is 50% it will become 75%
  165.     current main_exp rate is main exp rate after adding main_exp_mod
  166.     ALL main exp rate multiplier STACKS
  167.     so example current main exp rate 50% (after adding exp_mod)
  168.     actor *150%, class *50%, subclass *500%, weapon *125%, armor1 *250%, armor2 *105%, state1 *410%, state2 *310%
  169.     final rate = (50%) * 150% * 500% * 125% * 250% * 105% * 410% * 310%
  170.     count it yourself :D.
  171.    
  172. interesting play with subexpmod and subexpmult...
  173. create a subclass only which have no growth in subclass. but after equipping
  174. some accessory that increase subexpmod. it will have some growth and raised lv.
  175. could create a weapon/armor which is strong but subexpmult = 0%. so no growth.    
  176.  
  177. #------------------------------------------------------------------------------
  178. =end
  179.  
  180. module ESTRIOLE
  181.   SUB_EXP_RATE = 50   #default sub exp rate (in percentage so 50 means 50% exp,
  182.                       #200 means 200% exp. etc). when no notetags set for that class
  183.   MAIN_EXP_RATE = 100 #default MAIN exp rate (in percentage so 50 means 50% exp,
  184.                       #200 means 200% exp. etc). when no notetags set for that class
  185.                       #better to leave it at 100%
  186.   SUBCLASS_VOCAB = "Subclass"
  187.   SUBCLASS_MIN_1_EXP = true #if true minimum 1 exp gained when the result exp x sub exp rate is between 0 - 1
  188.  
  189.   module VICTORY_AFTERMATH
  190.   VICTORY_SUB_EXP  = "+%sSUBEXP"      # Text used to display SUB EXP. IF USING YANFLY VICTORY AFTERMATH SCRIPT
  191.   end
  192.  
  193. end
  194.  
  195. class RPG::BaseItem
  196.   def sub_exp_mod
  197.     return nil if !@note[/<sub_exp_mod:(.*)>/i]
  198.     a = @note[/<sub_exp_mod:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| ([-\w.\w]+)|([-\w.\w]+),|,([-\w.\w]+))/).flatten.compact
  199.     return noteargs = a[0].to_f
  200.   end    
  201.   def sub_exp_mult
  202.     return nil if !@note[/<sub_exp_mult:(.*)>/i]
  203.     a = @note[/<sub_exp_mult:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| ([-\w.\w]+)|([-\w.\w]+),|,([-\w.\w]+))/).flatten.compact
  204.     return noteargs = a[0].to_f
  205.   end    
  206.   def main_exp_mod
  207.     return nil if !@note[/<main_exp_mod:(.*)>/i]
  208.     a = @note[/<main_exp_mod:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| ([-\w.\w]+)|([-\w.\w]+),|,([-\w.\w]+))/).flatten.compact
  209.     return noteargs = a[0].to_f
  210.   end    
  211.   def main_exp_mult
  212.     return nil if !@note[/<main_exp_mult:(.*)>/i]
  213.     a = @note[/<main_exp_mult:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| ([-\w.\w]+)|([-\w.\w]+),|,([-\w.\w]+))/).flatten.compact
  214.     return noteargs = a[0].to_f
  215.   end    
  216. end
  217. #Notetags ability to set max level for each class instead of using actor max_lv
  218. class RPG::Class < RPG::BaseItem
  219.   def max_level
  220.     return nil if !@note[/<class_max_lv:(.*)>/i]
  221.     a = @note[/<class_max_lv:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| ([-\w.\w]+)|([-\w.\w]+),|,([-\w.\w]+))/).flatten.compact
  222.     return noteargs = a[0].to_i
  223.   end
  224.   def sub_exp_rate
  225.     return nil if !@note[/<sub_exp_rate:(.*)>/i]
  226.     a = @note[/<sub_exp_rate:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| ([-\w.\w]+)|([-\w.\w]+),|,([-\w.\w]+))/).flatten.compact
  227.     return noteargs = a[0].to_f
  228.   end  
  229.   def main_exp_rate
  230.     return nil if !@note[/<main_exp_rate:(.*)>/i]
  231.     a = @note[/<main_exp_rate:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| ([-\w.\w]+)|([-\w.\w]+),|,([-\w.\w]+))/).flatten.compact
  232.     return noteargs = a[0].to_f
  233.   end  
  234. end
  235.  
  236. class Game_Actor < Game_Battler
  237.   def main_exp_rate(class_id)
  238.     exprate = $data_classes[class_id].main_exp_rate ? $data_classes[class_id].main_exp_rate * 0.01 : ESTRIOLE::MAIN_EXP_RATE  * 0.01
  239.     exprate = (exprate + main_exp_mod) * main_exp_mult
  240.     exprate = [exprate,0].max #disallow negative exp rate
  241.   end
  242.   def main_exp_mod
  243.     actormod = (self.actor.main_exp_mod ? self.actor.main_exp_mod : 0) rescue 0
  244.     classmod = (self.class.main_exp_mod ? self.class.main_exp_mod : 0) rescue 0
  245.     subclassmod = (self.subclass.main_exp_mod ? self.subclass.main_exp_mod : 0) rescue 0
  246.     equipsmod = 0
  247.     equips.each do |equip|
  248.       next if !equip
  249.       equipsmod += equip.main_exp_mod if equip.main_exp_mod
  250.     end    
  251.     statesmod = 0
  252.     states.each do |state|
  253.       statesmod += state.main_exp_mod if state.main_exp_mod
  254.     end
  255.     return main_exp_mod = (actormod + classmod + subclassmod + equipsmod + statesmod) * 0.01
  256.   end
  257.   def main_exp_mult
  258.     actor_mult = (self.actor.main_exp_mult ? self.main_exp_mult * 0.01 : 1) rescue 1
  259.     class_mult = (self.class.main_exp_mult ? self.class.main_exp_mult * 0.01 : 1) rescue 1
  260.     subclass_mult = (self.subclass.main_exp_mult ? self.subclass.main_exp_mult * 0.01 : 1) rescue 1
  261.     equips_mult = 1
  262.     equips.each do |equip|
  263.       next if !equip
  264.       equips_mult = equips_mult * equip.main_exp_mult * 0.01 if equip.main_exp_mult
  265.     end    
  266.     states_mult = 1
  267.     states.each do |state|
  268.       states_mult = states_mult * state.main_exp_mult * 0.01 if state.main_exp_mult
  269.     end
  270.     return main_exp_mult = actor_mult * class_mult * subclass_mult * equips_mult * states_mult
  271.   end
  272.  
  273.   def sub_exp_rate(class_id)
  274.     exprate = $data_classes[class_id].sub_exp_rate ? $data_classes[class_id].sub_exp_rate * 0.01 : ESTRIOLE::SUB_EXP_RATE  * 0.01
  275.     exprate = (exprate + sub_exp_mod) * sub_exp_mult
  276.     exprate = [exprate,0].max #disallow negative exp rate
  277.   end
  278.   def sub_exp_mod
  279.     actormod = (self.actor.sub_exp_mod ? self.actor.sub_exp_mod : 0) rescue 0
  280.     classmod = (self.class.sub_exp_mod ? self.class.sub_exp_mod : 0) rescue 0
  281.     subclassmod = (self.subclass.sub_exp_mod ? self.subclass.sub_exp_mod : 0) rescue 0
  282.     equipsmod = 0
  283.     equips.each do |equip|
  284.       next if !equip
  285.       equipsmod += equip.sub_exp_mod if equip.sub_exp_mod
  286.     end    
  287.     statesmod = 0
  288.     states.each do |state|
  289.       statesmod += state.sub_exp_mod if state.sub_exp_mod
  290.     end
  291.     return sub_exp_mod = (actormod + classmod + subclassmod + equipsmod + statesmod) * 0.01
  292.   end
  293.   def sub_exp_mult
  294.     actor_mult = (self.actor.sub_exp_mult ? self.sub_exp_mult * 0.01 : 1) rescue 1
  295.     class_mult = (self.class.sub_exp_mult ? self.class.sub_exp_mult * 0.01 : 1) rescue 1
  296.     subclass_mult = (self.subclass.sub_exp_mult ? self.subclass.sub_exp_mult * 0.01 : 1) rescue 1
  297.     equips_mult = 1
  298.     equips.each do |equip|
  299.       next if !equip
  300.       equips_mult = equips_mult * equip.sub_exp_mult * 0.01 if equip.sub_exp_mult
  301.     end    
  302.     states_mult = 1
  303.     states.each do |state|
  304.       states_mult = states_mult * state.sub_exp_mult * 0.01 if state.sub_exp_mult
  305.     end
  306.     return sub_exp_mult = actor_mult * class_mult * subclass_mult * equips_mult * states_mult
  307.   end
  308.  
  309. # buxfix for yanfly class level method. i make it read the 'max level' from database
  310.   def class_level(class_id)
  311.   return @level if YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
  312.   temp_class = $data_classes[class_id]
  313.   @exp[class_id] = 0 if @exp[class_id].nil?
  314.   max_lv = temp_class.max_level == nil ? actor.max_level : temp_class.max_level
  315.   maxlv_exp = temp_class.exp_for_level(max_lv)
  316.   #below part is taken from bugfix by disturbed inside
  317.     n = 1
  318.     loop do
  319.     break if temp_class.exp_for_level(n+1) > @exp[class_id]
  320.     n += 1
  321.     #add a restriction to “kick out” of loop if exp exceeds max level exp
  322.     break if temp_class.exp_for_level(n+1) > maxlv_exp
  323.     end
  324.   return n
  325.   #end bugfix by disturbed inside here
  326.   end  
  327.  
  328. # patch for max level using class max level instead of using actor (if notetags exist)
  329.   alias est_yan_game_actor_max_level max_level
  330.   def max_level
  331.     return $data_classes[@class_id].max_level if $data_classes[@class_id].max_level != nil
  332.     return est_yan_game_actor_max_level
  333.   end
  334.   def subclass_max_level
  335.     return 0 if @subclass_id == 0
  336.     return $data_classes[@subclass_id].max_level if $data_classes[@subclass_id].max_level != nil
  337.     return actor.max_level
  338.   end
  339.  
  340. # to prevent initial level more than initial class max level
  341.   alias est_yan_game_actor_setup setup
  342.   def setup(actor_id)
  343.     est_yan_game_actor_setup(actor_id)
  344.     if $data_classes[@class_id].max_level
  345.     @level = [actor.initial_level,$data_classes[@class_id].max_level].min
  346.     init_exp
  347.     init_skills
  348.     clear_param_plus
  349.     recover_all
  350.     end
  351.   end
  352.  
  353. # new method to add exp to subclass  
  354.   def subclass_add_exp(class_id,value)
  355.     return if !@subclass_id
  356.     return if @subclass_id == 0
  357.     return if YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
  358.     last_level = class_level(class_id).to_i
  359.     last_skills = skills
  360.     exprate = sub_exp_rate(class_id)
  361.     expvalue = (value * exprate).to_i
  362.     expvalue = [expvalue,1].max if ESTRIOLE::SUBCLASS_MIN_1_EXP && value != 0
  363.     @exp[class_id] = @exp[class_id] + expvalue
  364.     @exp[class_id] = [@exp[class_id],subclass.exp_for_level(subclass_max_level)].min
  365.       #learn skill if sub level can learn it
  366.       self.subclass.learnings.each do |learning|
  367.         learn_skill(learning.skill_id) if learning.level <= class_level(class_id).to_i
  368.            # formar extra traits lv up patch
  369.            if @extra_features && class_level(class_id).to_i > last_level && learning.note =~ /<extratrait (.*)>/i
  370.             @extra_features.features += $data_weapons[$1.to_i].features if EXTRA_FEATURES_SOURCE == 0
  371.             @extra_features.features += $data_armors[$1.to_i].features if EXTRA_FEATURES_SOURCE == 1
  372.             @extra_features.features += $data_states[$1.to_i].features if EXTRA_FEATURES_SOURCE == 2
  373.            end
  374.            #end formar extra traits lv up patch
  375.         end
  376.     # display subclass level up msg
  377.     display_level_up_sub(skills - last_skills) if class_level(class_id).to_i > last_level
  378.   end
  379.  
  380. # new method subclass -> to get data classes of subclass  
  381.   def subclass
  382.     @subclass_id = 0 if @subclass_id.nil?
  383.     $data_classes[@subclass_id]
  384.   end
  385.  
  386. # to make subclass traits works...
  387.   alias est_yan_subclass_feature_objects feature_objects
  388.   def feature_objects
  389.     return est_yan_subclass_feature_objects + [self.subclass] if @subclass_id && @subclass_id != 0
  390.     return est_yan_subclass_feature_objects
  391.   end
  392.  
  393. # compatibility patch with tsukihime effect manager. so you can have subclass
  394. # that can give you 'effects'
  395.   if $imported["Effect_Manager"]
  396.     alias est_yan_hime_effect_objects effect_objects
  397.     def effect_objects
  398.       return est_yan_hime_effect_objects + [self.subclass] if @subclass_id && @subclass_id != 0
  399.       return est_yan_hime_effect_objects
  400.     end
  401.   end
  402.  
  403. # new method to display level up when subclass level  
  404.   def display_level_up_sub(new_skills)
  405.     return if !@subclass_id || @subclass_id == 0
  406.     level_sub = class_level(@subclass_id).to_i
  407.     $game_message.new_page
  408.     temp = ESTRIOLE::SUBCLASS_VOCAB
  409.     text = "%s's %s now reached %s %s!"
  410.     text = "%s's %s now reached\n%s %s!" if SceneManager.scene_is?(Scene_Battle)
  411.     $game_message.add(sprintf(text, @name, temp ,Vocab::level ,level_sub))
  412.     new_skills.each do |skill|
  413.       $game_message.add(sprintf(Vocab::ObtainSkill, skill.name))
  414.     end
  415.   end
  416.  
  417.   #patch compatibility to yanfly adjust limit
  418.   if $imported["YEA-AdjustLimits"] == true
  419.   def param_base(param_id)
  420.     result = game_actor_param_base_cs(param_id)
  421.     unless subclass.nil?
  422.       subclass_rate = YEA::CLASS_SYSTEM::SUBCLASS_STAT_RATE
  423.       slevel = subclass_level
  424.       result += subclass.params[param_id, slevel] * subclass_rate if slevel <= 99
  425.       result += subclass.above_lv99_params(param_id, slevel) * subclass_rate if slevel > 99
  426.     end
  427.     return result.to_i
  428.   end
  429.   end
  430.    
  431. # alias method gain exp to also gain subclass exp.
  432. # before i use change_exp. but then i realize it will break when using change_level method
  433. # so i use gain_exp method instead. but... gain_exp only occur when you get exp
  434. # from enemy/battle. and not working for event command that grant exp. so i also
  435. # alias command_315 to handle that.
  436. # so basically battle use gain_exp method, event use command_315 method.
  437.   alias est_yan_gain_exp gain_exp
  438.   def gain_exp(exp,enabled = false)
  439.     new_exp = (exp * main_exp_rate(@class_id) * final_exp_rate).to_i
  440.     new_exp = [new_exp,1].max if ESTRIOLE::SUBCLASS_MIN_1_EXP && exp != 0
  441.     max_exp = self.class.exp_for_level(max_level) - self.exp
  442.     new_exp = [new_exp,max_exp].min
  443.     est_yan_gain_exp(new_exp)
  444.     subclass_add_exp(@subclass_id,exp) if @subclass_id
  445.   end
  446.  
  447. end
  448.  
  449. class Game_Interpreter
  450.   #Overwrite command_315 to make it also gain subclass exp. read gain_exp comment.:D
  451.   #have to overwrite to implement main exp rate which SEPARATED with sub exp rate
  452.   #so increasing main sub exp rate didn't raise sub exp gained.
  453.   def command_315
  454.     value = operate_value(@params[2], @params[3], @params[4])
  455.     iterate_actor_var(@params[0], @params[1]) do |actor|
  456.       new_value = (value * actor.main_exp_rate(actor.class.id) * actor.final_exp_rate).to_i
  457.       new_value = [new_value,1].max if ESTRIOLE::SUBCLASS_MIN_1_EXP && value != 0
  458.       new_value = actor.exp + new_value
  459.       max_exp =  actor.class.exp_for_level(actor.max_level)
  460.       new_value = [new_value,max_exp].min
  461.       actor.change_exp(new_value, @params[5])
  462.     end
  463.     value = operate_value(@params[2], @params[3], @params[4])
  464.     iterate_actor_var(@params[0], @params[1]) do |actor|
  465.       actor.subclass_add_exp(actor.subclass.id, value * actor.final_exp_rate) if actor.subclass
  466.     end
  467.   end
  468. end
  469.  
  470.  
  471. #yanfly aftermath exp rate patch
  472. class Window_VictoryEXP_Back < Window_Selectable
  473.  
  474.   #--------------------------------------------------------------------------
  475.   # initialize
  476.   #--------------------------------------------------------------------------
  477.   def initialize
  478.     super(0, fitting_height(1), Graphics.width, window_height)
  479.     self.z = 200
  480.     self.openness = 0
  481.   end
  482.  
  483.   #--------------------------------------------------------------------------
  484.   # window_height
  485.   #--------------------------------------------------------------------------
  486.   def window_height
  487.     return Graphics.height - fitting_height(4) - fitting_height(1)
  488.   end
  489.  
  490.   #--------------------------------------------------------------------------
  491.   # col_max
  492.   #--------------------------------------------------------------------------
  493.   def col_max; return item_max; end
  494.  
  495.   #--------------------------------------------------------------------------
  496.   # spacing
  497.   #--------------------------------------------------------------------------
  498.   def spacing; return 8; end
  499.  
  500.   #--------------------------------------------------------------------------
  501.   # item_max
  502.   #--------------------------------------------------------------------------
  503.   def item_max; return $game_party.battle_members.size; end
  504.  
  505.   #--------------------------------------------------------------------------
  506.   # open
  507.   #--------------------------------------------------------------------------
  508.   def open
  509.     @exp_total = $game_troop.exp_total
  510.     super
  511.   end
  512.  
  513.   #--------------------------------------------------------------------------
  514.   # item_rect
  515.   #--------------------------------------------------------------------------
  516.   def item_rect(index)
  517.     rect = Rect.new
  518.     rect.width = item_width
  519.     rect.height = contents.height
  520.     rect.x = index % col_max * (item_width + spacing)
  521.     rect.y = index / col_max * item_height
  522.     return rect
  523.   end
  524.  
  525.   #--------------------------------------------------------------------------
  526.   # draw_item
  527.   #--------------------------------------------------------------------------
  528.   def draw_item(index)
  529.     actor = $game_party.battle_members[index]
  530.     return if actor.nil?
  531.     rect = item_rect(index)
  532.     reset_font_settings
  533.     draw_actor_name(actor, rect)
  534.     draw_exp_gain(actor, rect)
  535.     draw_sub_exp_gain(actor, rect)
  536.     draw_jp_gain(actor, rect)
  537.     draw_actor_face(actor, rect)
  538.   end
  539.  
  540.   #--------------------------------------------------------------------------
  541.   # draw_actor_name
  542.   #--------------------------------------------------------------------------
  543.   def draw_actor_name(actor, rect)
  544.     name = actor.name
  545.     draw_text(rect.x, rect.y+line_height, rect.width, line_height, name, 1)
  546.   end
  547.  
  548.   #--------------------------------------------------------------------------
  549.   # draw_actor_face
  550.   #--------------------------------------------------------------------------
  551.   def draw_actor_face(actor, rect)
  552.     face_name = actor.face_name
  553.     face_index = actor.face_index
  554.     bitmap = Cache.face(face_name)
  555.     rw = [rect.width, 96].min
  556.     face_rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, rw, 96)
  557.     rx = (rect.width - rw) / 2 + rect.x
  558.     contents.blt(rx, rect.y + line_height * 2, bitmap, face_rect, 255)
  559.   end
  560.  
  561.   #--------------------------------------------------------------------------
  562.   # draw_exp_gain
  563.   #--------------------------------------------------------------------------
  564.   def draw_exp_gain(actor, rect)
  565.     dw = rect.width - (rect.width - [rect.width, 96].min) / 2
  566.     dy = rect.y + line_height * 2 + 96
  567.     fmt = YEA::VICTORY_AFTERMATH::VICTORY_EXP
  568.     text = sprintf(fmt, actor_exp_gain(actor).group)
  569.     contents.font.size = YEA::VICTORY_AFTERMATH::FONTSIZE_EXP
  570.     change_color(power_up_color)
  571.     draw_text(rect.x, dy, dw, line_height, text, 2)
  572.   end
  573.  
  574.   #--------------------------------------------------------------------------
  575.   # actor_exp_gain
  576.   #--------------------------------------------------------------------------
  577.   def actor_exp_gain(actor)
  578.     n = @exp_total * actor.main_exp_rate(actor.class.id) * actor.final_exp_rate
  579.     return n.to_i
  580.   end
  581.  
  582.   def actor_sub_exp_gain(actor)
  583.     return nil if !actor.subclass
  584.     n = @exp_total * actor.sub_exp_rate(actor.subclass.id) * actor.final_exp_rate
  585.     return n.to_i
  586.   end
  587.  
  588.   def draw_sub_exp_gain(actor, rect)
  589.     return if !actor_sub_exp_gain(actor)
  590.     return if YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
  591.     dw = rect.width - (rect.width - [rect.width, 96].min) / 2
  592.     dy = rect.y + line_height * 4 + 96
  593.     fmt = ESTRIOLE::VICTORY_AFTERMATH::VICTORY_SUB_EXP
  594.     text = sprintf(fmt, actor_sub_exp_gain(actor).group)
  595.     contents.font.size = YEA::VICTORY_AFTERMATH::FONTSIZE_EXP
  596.     change_color(power_up_color)
  597.     draw_text(rect.x, dy, dw, line_height, text, 2)
  598.   end
  599.  
  600.  
  601.   #--------------------------------------------------------------------------
  602.   # draw_jp_gain
  603.   #--------------------------------------------------------------------------
  604.   def draw_jp_gain(actor, rect)
  605.     return unless $imported["YEA-JPManager"]
  606.     dw = rect.width - (rect.width - [rect.width, 96].min) / 2
  607.     dy = rect.y + line_height * 0
  608.     fmt = YEA::JP::VICTORY_AFTERMATH
  609.     text = sprintf(fmt, actor_jp_gain(actor).group, Vocab::jp)
  610.     contents.font.size = YEA::VICTORY_AFTERMATH::FONTSIZE_EXP
  611.     change_color(power_up_color)
  612.     draw_text(rect.x, dy, dw, line_height, text, 2)
  613.   end
  614.  
  615.   #--------------------------------------------------------------------------
  616.   # actor_jp_gain
  617.   #--------------------------------------------------------------------------
  618.   def actor_jp_gain(actor)
  619.     n = actor.battle_jp_earned
  620.     if actor.exp + actor_exp_gain(actor) > actor.exp_for_level(actor.level + 1)
  621.       n += YEA::JP::LEVEL_UP unless actor.max_level?
  622.     end
  623.     return n
  624.   end
  625.  
  626. end # Window_VictoryEXP_Back
  627.  
  628. class Window_VictoryEXP_Front < Window_VictoryEXP_Back  
  629.   def draw_item(index)
  630.     actor = $game_party.battle_members[index]
  631.     return if actor.nil?
  632.     rect = item_rect(index)
  633.     draw_actor_exp(actor, rect)
  634.     draw_actor_sub_exp(actor, rect)
  635.   end
  636.   def draw_actor_exp(actor, rect)
  637.     if actor.max_level?
  638.       draw_exp_gauge(actor, rect, 1.0)
  639.       return
  640.     end
  641.     total_ticks = YEA::VICTORY_AFTERMATH::EXP_TICKS
  642.     bonus_exp = actor_exp_gain(actor) * @ticks / total_ticks
  643.     now_exp = actor.exp - actor.current_level_exp + bonus_exp
  644.     next_exp = actor.next_level_exp - actor.current_level_exp
  645.     rate = now_exp * 1.0 / next_exp
  646.     draw_exp_gauge(actor, rect, rate)
  647.   end
  648.  
  649.   def draw_actor_sub_exp(actor, rect)
  650.     return if !actor.subclass
  651.     return if YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
  652.     rect.y += line_height * 2
  653.     if actor.subclass_level == actor.subclass_max_level
  654.       draw_sub_exp_gauge(actor, rect, 1.0)
  655.       return
  656.     end
  657.     total_ticks = YEA::VICTORY_AFTERMATH::EXP_TICKS
  658.     bonus_exp = actor_sub_exp_gain(actor) * @ticks / total_ticks
  659.     now_exp = actor.exp[actor.subclass.id] - actor.subclass.exp_for_level(actor.subclass_level) + bonus_exp
  660.     next_exp = actor.subclass.exp_for_level(actor.subclass_level+1) - actor.subclass.exp_for_level(actor.subclass_level)
  661.     rate = now_exp * 1.0 / next_exp
  662.     draw_sub_exp_gauge(actor, rect, rate)
  663.   end
  664.   def draw_exp_gauge(actor, rect, rate)
  665.     rate = [[rate, 1.0].min, 0.0].max
  666.     dx = (rect.width - [rect.width, 96].min) / 2 + rect.x
  667.     dy = rect.y + line_height * 1 + 96
  668.     dw = [rect.width, 96].min
  669.     colour1 = rate >= 1.0 ? lvl_gauge1 : exp_gauge1
  670.     colour2 = rate >= 1.0 ? lvl_gauge2 : exp_gauge2
  671.     draw_gauge(dx, dy, dw, rate, colour1, colour2)
  672.     fmt = YEA::VICTORY_AFTERMATH::EXP_PERCENT
  673.     text = sprintf(fmt, [rate * 100, 100.00].min)
  674.     if [rate * 100, 100.00].min == 100.00
  675.       text = YEA::VICTORY_AFTERMATH::LEVELUP_TEXT
  676.       text = YEA::VICTORY_AFTERMATH::MAX_LVL_TEXT if actor.max_level?
  677.     end
  678.     draw_text(dx, dy, dw, line_height, text, 1)
  679.   end
  680.   def draw_sub_exp_gauge(actor, rect, rate)
  681.     rate = [[rate, 1.0].min, 0.0].max
  682.     dx = (rect.width - [rect.width, 96].min) / 2 + rect.x
  683.     dy = rect.y + line_height * 1 + 96
  684.     dw = [rect.width, 96].min
  685.     colour1 = rate >= 1.0 ? lvl_gauge1 : exp_gauge1
  686.     colour2 = rate >= 1.0 ? lvl_gauge2 : exp_gauge2
  687.     draw_gauge(dx, dy, dw, rate, colour1, colour2)
  688.     fmt = YEA::VICTORY_AFTERMATH::EXP_PERCENT
  689.     text = sprintf(fmt, [rate * 100, 100.00].min)
  690.     if [rate * 100, 100.00].min == 100.00
  691.       text = YEA::VICTORY_AFTERMATH::LEVELUP_TEXT
  692.       text = YEA::VICTORY_AFTERMATH::MAX_LVL_TEXT if actor.subclass_level == actor.subclass_max_level
  693.     end
  694.     draw_text(dx, dy, dw, line_height, text, 1)
  695.   end
  696. end # Window_VictoryEXP_Front
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement