Advertisement
roninator2

Yanfly Class System Addons - subclass skill swap

Dec 9th, 2024
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.76 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Class v1.06 Addon for subclass - skillswap
  4. # -- Last Updated: 2020.09.15
  5. # -- Requires: Yanfly Class System
  6. #              Yanfly Class Specifics <- Optional
  7. #              Estriole Subclass Addon
  8. # -- addon created by: Roninator2
  9. #==============================================================================
  10. # ▼ Updates
  11. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  12. # 2020.09.14 - Started Script
  13. # 2020.09.15 - Added forget skills option
  14. # 2020.09.20 - fixed bug
  15. #==============================================================================
  16. # ▼ Introduction
  17. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  18. # Allow Subclass to gain levels & skills and allows the option to
  19. # have the actor forget skills from the class they were previously
  20. # when changing classes.
  21. #==============================================================================
  22. module R2_yanfly_skills
  23.   Forget_skills = true
  24. end
  25.  
  26. class Game_Interpreter
  27.   def command_316
  28.    value = operate_value(@params[2], @params[3], @params[4])
  29.    iterate_actor_var(@params[0], @params[1]) do |actor|
  30.      actor.sublevelup = true
  31.      actor.sublevelcnt = value
  32.      actor.change_level(actor.level + value, @params[5])
  33.    end
  34.   end
  35. end
  36.  
  37. class Game_Actor < Game_Battler
  38.  
  39.   attr_accessor   :sublevelup
  40.   attr_accessor   :sublevelcnt
  41.   attr_accessor   :subclass_id
  42.  
  43.   alias r2_game_actor_level_up level_up
  44.   def level_up
  45.     r2_game_actor_level_up
  46.     return if @subclass_id == 0
  47.     return if !@subclass_id
  48.     if @sublevelup
  49.       @exp[@subclass_id] = exp_for_level(class_level(@subclass_id).to_i + @sublevelcnt)
  50.     elsif @exp[@subclass_id] == exp_for_level(class_level(@subclass_id).to_i + 1)
  51.       @sublevelup = true
  52.       class_level(@subclass_id).to_i + 1
  53.       @sublevelcnt += 1
  54.     end
  55.     subclass_add_exp(@subclass_id,0)
  56.     if @sublevelup
  57.       @sublevelup = false
  58.       @sublevelcnt = 0
  59.     end
  60.   end
  61.  
  62.   def forget_class_skills(class_id)
  63.     return if class_id <= 0
  64.     return if $data_classes[class_id].nil?
  65.     $data_classes[class_id].learnings.each do |learning|
  66.       forget_skill(learning.skill_id)
  67.     end
  68.   end
  69.  
  70.   def forget_subclass_skills(class_id)
  71.     return if class_id <= 0
  72.     return if $data_classes[class_id].nil?
  73.     $data_classes[class_id].learnings.each do |learning|
  74.       forget_skill(learning.skill_id)
  75.     end
  76.   end
  77.  
  78.   def learn_class_skills(class_id)
  79.     return if class_id <= 0
  80.     return if $data_classes[class_id].nil?
  81.     $data_classes[class_id].learnings.each do |learning|
  82.       learn_skill(learning.skill_id) if learning.level <= class_level(class_id)
  83.     end
  84.   end
  85.  
  86.   def subclass_add_exp(class_id,value)
  87.     return if !@subclass_id
  88.     return if @subclass_id == 0
  89.     last_level = class_level(class_id).to_i
  90.     last_skills = skills
  91.     exprate = sub_exp_rate(class_id)
  92.     expvalue = (value * exprate).to_i
  93.     expvalue = [expvalue,1].max if ESTRIOLE::SUBCLASS_MIN_1_EXP && value != 0
  94.     if !YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
  95.       @exp[class_id] = @exp[class_id] + expvalue
  96.       @exp[class_id] = [@exp[class_id],subclass.exp_for_level(subclass_max_level)].min
  97.     end
  98.     self.subclass.learnings.each do |learning|
  99.       learn_skill(learning.skill_id) if learning.level <= class_level(class_id).to_i
  100.       if @extra_features && class_level(class_id).to_i > last_level && learning.note =~ /<extratrait (.*)>/i
  101.         @extra_features.features += $data_weapons[$1.to_i].features if EXTRA_FEATURES_SOURCE == 0
  102.         @extra_features.features += $data_armors[$1.to_i].features if EXTRA_FEATURES_SOURCE == 1
  103.         @extra_features.features += $data_states[$1.to_i].features if EXTRA_FEATURES_SOURCE == 2
  104.       end
  105.     end
  106.     display_level_up_sub(skills - last_skills) if class_level(class_id).to_i > last_level
  107.   end
  108. end # Game_Actor
  109. class Window_Base < Window
  110.  
  111.   if $imported["YEA-AceMenuEngine"]
  112.     def draw_actor_simple_status(actor, dx, dy)
  113.       dy -= line_height / 2
  114.       draw_actor_name(actor, dx, dy)
  115.       draw_actor_level(actor, dx, dy + line_height * 1)
  116.       draw_actor_icons(actor, dx, dy + line_height * 2)
  117.       dx = dx + 25
  118.       dw = contents.width - dx - 124
  119.       draw_actor_class(actor, dx + 120, dy, dw)
  120.       draw_actor_hp(actor, dx + 120, dy + line_height * 1, dw)
  121.       if YEA::MENU::DRAW_TP_GAUGE && actor.draw_tp? && !actor.draw_mp?
  122.         draw_actor_tp(actor, dx + 120, dy + line_height * 2, dw)
  123.       elsif YEA::MENU::DRAW_TP_GAUGE && actor.draw_tp? && actor.draw_mp?
  124.         if $imported["YEA-BattleEngine"]
  125.           draw_actor_tp(actor, dx + 120, dy + line_height * 2, dw/2 - 1)
  126.           draw_actor_mp(actor, dx + 120 + dw/2, dy + (line_height * 2), dw/2 + 1)
  127.         else
  128.           draw_actor_mp(actor, dx + 120, dy + line_height * 2, dw/2 - 1)
  129.           draw_actor_tp(actor, dx + 120 + dw/2, dy + line_height * 2, dw/2 + 1)
  130.         end
  131.       elsif YEA::MENU::DRAW_TP_GAUGE && actor.draw_mp?
  132.         draw_actor_mp(actor, dx + 120, dy + line_height * 2, dw)
  133.       end
  134.     end
  135.   end
  136.  
  137.   alias r2_draw_actor_class_924v  draw_actor_simple_status
  138.   def draw_actor_simple_status(actor, dx, dy)
  139.     r2_draw_actor_class_924v(actor, dx, dy)
  140.     @class_id = actor.class_id
  141.     @sublass_id = actor.subclass.nil? ? nil : actor.subclass.id
  142.   end
  143.  
  144. end # Window_Base
  145.  
  146. class Scene_LearnSkill < Scene_Skill
  147.   def on_cost_ok
  148.     Sound.play_use_skill
  149.     skill = @item_window.item
  150.     @actor.learn_skill(skill.id)
  151.     cost = skill.learn_cost[0]
  152.     case skill.learn_cost[1]
  153.     when :exp
  154.       @actor.lose_exp_class(cost, @cost_front.skill_class)
  155.     when :gold
  156.       $game_party.lose_gold(cost)
  157.     end
  158.     on_cost_cancel
  159.     refresh_windows
  160.   end
  161. end
  162.  
  163. class Scene_Class < Scene_MenuBase
  164.   def on_class_ok
  165.     Sound.play_equip
  166.     class_old = @actor.class_id
  167.     subclass_old = @actor.subclass_id
  168.     class_id = @item_window.item.id
  169.     maintain = YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
  170.     hp = @actor.hp * 1.0 / @actor.mhp
  171.     mp = @actor.mp * 1.0 / [@actor.mmp, 1].max
  172.     case @command_window.current_symbol
  173.     when :primary
  174.       @actor.forget_class_skills(class_old) if R2_yanfly_skills::Forget_skills
  175.       @actor.change_class(class_id, maintain)
  176.       if @actor.subclass_id == 0
  177.         @actor.forget_subclass_skills(subclass_old) if R2_yanfly_skills::Forget_skills
  178.       end
  179.     when :subclass
  180.       @actor.forget_subclass_skills(subclass_old) if R2_yanfly_skills::Forget_skills
  181.       @actor.change_subclass(class_id)
  182.     else
  183.       @item_window.activate
  184.       return
  185.     end
  186.     @actor.hp = (@actor.mhp * hp).to_i
  187.     @actor.mp = (@actor.mmp * mp).to_i
  188.     @status_window.refresh
  189.     @item_window.update_class
  190.   end  
  191. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement