roninator2

Fomar0153 Equipment Skills System mod

Dec 15th, 2024
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.96 KB | None | 0 0
  1. =begin
  2. Equipment Skills System Script
  3. by Fomar0153
  4. Mod by Roninator2
  5. Version 1.1.1
  6. ----------------------
  7. Notes
  8. ----------------------
  9. If using my Custom Equipment Slots script then
  10. make sure this script is above the Equipment Slots Script
  11. and make sure you have the compatability patch.
  12. Allows learning of skills by equipment with the
  13. option to learn skills pernamently.
  14. ----------------------
  15. Instructions
  16. ----------------------
  17. Then follow the instructions below about how to add skills
  18. to weapons and armor.
  19. ----------------------
  20. Change Log
  21. ----------------------
  22. 1.0 -> 1.1 Fixed a bug which caused skills learnt from
  23.            armour to not display they were learnt.
  24. ----------------------
  25. Known bugs
  26. ----------------------
  27. None
  28. =end
  29.  
  30. module Equipment_Skills
  31.  
  32.   Weapons = []
  33.   # Add weapon skills in this format
  34.   # Weapons[weapon_id] = [skillid1, skillid2]
  35.   Weapons[1] = [8]
  36.  
  37.   Armors = []
  38.   # Add weapon skills in this format
  39.   # Armors[armor_id] = [skillid1, skillid2]
  40.   Armors[3] = [9]
  41.  
  42. end
  43.  
  44. class Game_Actor < Game_Battler
  45.   #--------------------------------------------------------------------------
  46.   # ● Rewrites change_equip
  47.   #--------------------------------------------------------------------------
  48.   def change_equip(slot_id, item)
  49.     return unless trade_item_with_party(item, equips[slot_id])
  50.     return if item && equip_slots[slot_id] != item.etype_id
  51.     @equips[slot_id].object = item
  52.     refresh
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # ● Aliases refresh
  56.   #--------------------------------------------------------------------------
  57.   alias eqskills_refresh refresh
  58.   def refresh
  59.     eqskills_refresh
  60.     for item in self.equips
  61.       if item.is_a?(RPG::Weapon)
  62.         unless Equipment_Skills::Weapons[item.id] == nil
  63.           for skill in Equipment_Skills::Weapons[item.id]
  64.             learn_skill(skill)
  65.           end
  66.         end
  67.       end
  68.       if item.is_a?(RPG::Armor)
  69.         unless Equipment_Skills::Armors[item.id] == nil
  70.           for skill in Equipment_Skills::Armors[item.id]
  71.             learn_skill(skill)
  72.           end
  73.         end
  74.       end
  75.     end
  76.     # relearn any class skills you may have forgotten
  77.     self.class.learnings.each do |learning|
  78.       learn_skill(learning.skill_id) if learning.level <= @level
  79.     end
  80.   end
  81. end
  82.  
  83. class Window_EquipItem < Window_ItemList
  84.   #--------------------------------------------------------------------------
  85.   # ● Rewrites col_max
  86.   #--------------------------------------------------------------------------
  87.   def col_max
  88.     return 1
  89.   end
  90.   #--------------------------------------------------------------------------
  91.   # ● Aliases update_help
  92.   #--------------------------------------------------------------------------
  93.   alias eqskills_update_help update_help
  94.   def update_help
  95.     eqskills_update_help
  96.     if @actor && @status_window
  97.       @status_window.refresh(item)
  98.     end
  99.   end
  100. end
  101.  
  102. class Scene_Equip < Scene_MenuBase
  103.   #--------------------------------------------------------------------------
  104.   # ● Rewrites create_item_window
  105.   #--------------------------------------------------------------------------
  106.   alias eqskills_create_item_window create_item_window
  107.   def create_item_window
  108.     wx = @status_window.width # Edited line if you need to merge
  109.     wy = @slot_window.y + @slot_window.height
  110.     ww = @slot_window.width  # Edited line if you need to merge
  111.     wh = Graphics.height - wy
  112.     @item_window = Window_EquipItem.new(wx, wy, ww, wh)
  113.     @item_window.viewport = @viewport
  114.     @item_window.help_window = @help_window
  115.     @item_window.status_window = @status_window
  116.     @item_window.actor = @actor
  117.     @item_window.set_handler(:ok,    method(:on_item_ok))
  118.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  119.     @slot_window.item_window = @item_window
  120.   end
  121. end
  122.  
  123. class Window_EquipStatus < Window_Base
  124.   #--------------------------------------------------------------------------
  125.   # ● Rewrites window_height
  126.   #--------------------------------------------------------------------------
  127.   def window_height
  128.     Graphics.height - (2 * line_height + standard_padding * 2)#fitting_height(visible_line_number)
  129.   end
  130.   #--------------------------------------------------------------------------
  131.   # ● Aliases refresh
  132.   #--------------------------------------------------------------------------
  133.   alias eqskills_refresh refresh
  134.   def refresh(item = nil)
  135.     eqskills_refresh
  136.     contents.clear
  137.     draw_actor_name(@actor, 4, 0) if @actor
  138.     6.times {|i| draw_item(0, line_height * (1 + i), 2 + i) }
  139.       unless item == nil
  140.       if item.is_a?(RPG::Weapon)
  141.         unless Equipment_Skills::Weapons[item.id] == nil
  142.           skills = Equipment_Skills::Weapons[item.id]
  143.         end
  144.       end
  145.       if item.is_a?(RPG::Armor)
  146.         unless Equipment_Skills::Armors[item.id] == nil
  147.           skills = Equipment_Skills::Armors[item.id]
  148.         end
  149.       end
  150.       unless skills == nil
  151.         change_color(normal_color)
  152.         draw_text(4, 168, width, line_height, "Equipment Skills")
  153.         change_color(system_color)
  154.         i = 1
  155.         for skill in skills
  156.           draw_text(4, 168 + 24 * i, width, line_height, $data_skills[skill].name)
  157.           i = i + 1
  158.         end
  159.       end
  160.     end
  161.   end
  162. end
  163.  
  164. class Window_EquipSlot < Window_Selectable
  165.   #--------------------------------------------------------------------------
  166.   # ● Aliases update
  167.   #--------------------------------------------------------------------------
  168.   alias eqskills_update update
  169.   def update
  170.     eqskills_update
  171.     @status_window.refresh(self.item) if self.active == true
  172.   end
  173. end
  174.  
  175. class Scene_Battle < Scene_Base
  176.   #--------------------------------------------------------------------------
  177.   # ● New method add_text
  178.   #--------------------------------------------------------------------------
  179.   def add_message(text)
  180.     $game_message.add('\.' + text)
  181.   end
  182. end
Add Comment
Please, Sign In to add comment