Advertisement
roninator2

MBS Learn Equipment Skills mod

Dec 6th, 2024
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.92 KB | None | 0 0
  1. #==============================================================================
  2. # MBS - Learn Equipment Skills
  3. #------------------------------------------------------------------------------
  4. # by Masked # mod by Roninator2
  5. #==============================================================================
  6. # Only the actor stated will learn the skill if that actor has the item equiped
  7. # equipment notetags
  8. # <Actor1 LearnSkills: 21>  # temporary until item is removed
  9. # <Actor5 LearnSkills: 21>  # temporary until item is removed
  10. # <Actor1 LearnPSkills: 21>  # permanent
  11. ($imported ||= {})[:mbs_equipment_skills] = true
  12. #==============================================================================
  13. # ** Game_Actor
  14. #==============================================================================
  15. class Game_Actor < Game_Battler
  16.   attr_accessor :perm_skills
  17.   alias mbs_chngeqp change_equip
  18.   alias mbs_inteqps init_equips
  19.   #--------------------------------------------------------------------------
  20.   # * Equipment initialization
  21.   #   equips: initial equipment
  22.   #--------------------------------------------------------------------------
  23.   def init_equips(equips)
  24.     @perm_skills = []
  25.     mbs_inteqps(equips)
  26.     @equips.each {|i|
  27.       equip_skills(i.object).each {|skill| learn_skill(skill)}
  28.     }
  29.   end
  30.   #--------------------------------------------------------------------------
  31.   # * Equipment change
  32.   #   slot_id: slot ID
  33.   #   item: Weapons / Matures (nil if empty)
  34.   #--------------------------------------------------------------------------
  35.   def change_equip(slot_id, item)
  36.     equip_skills(@equips[slot_id].object).each {|skill| forget_skill(skill) unless @perm_skills.include?(skill)}
  37.     mbs_chngeqp(slot_id,item)
  38.     equip_skills(item).each {|skill| learn_skill(skill)}
  39.   end
  40.   #--------------------------------------------------------------------------
  41.     # * Acquisition of equipment skills
  42.   #   item: the equipment in question  
  43.   #--------------------------------------------------------------------------
  44.   def equip_skills(item)
  45.     return [] if item.nil?
  46.     s = ""
  47.     skills = []
  48.     item.note.split(/[\r\n]+/).each { |line|
  49.       case line
  50.       when /<Actor#{self.id}\s*LearnSkills:\s*(.+>)/im
  51.       unless $1.nil?
  52.         $1.each_char {|char|
  53.           next if char == " "
  54.           if char == "," || char == ">"
  55.             skills << s.to_i
  56.             s = ""
  57.             next
  58.           end
  59.           s += char
  60.         }
  61.       end
  62.     end }
  63.     item.note.split(/[\r\n]+/).each { |line|
  64.       case line
  65.       when /<Actor#{self.id}\s*LearnPSkills:\s*(.+>)/im
  66.       @perm_skills ||= []
  67.       return skills if $1.nil?
  68.       $1.each_char {|char|
  69.         next if char == " "
  70.         if char == "," || char == ">"
  71.           skills << s.to_i
  72.           @perm_skills << s.to_i
  73.           s = ""
  74.           next
  75.         end
  76.         s += char
  77.       }
  78.       end }
  79.     return skills
  80.   end
  81. end
  82.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement