Advertisement
roninator2

Victor Sant Materia Addons - Equip Fix (from my game)

Dec 9th, 2024
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.08 KB | None | 0 0
  1. # ╔═════════════════════════════════════╦════════════════════╗
  2. # ║ Title: Materia Equipment Fix        ║  Version: 1.00     ║
  3. # ║ Author: Roninator2                  ║                    ║
  4. # ╠═════════════════════════════════════╬════════════════════╣
  5. # ║ Function:                           ║   Date Created     ║
  6. # ║                                     ╠════════════════════╣
  7. # ║ Fixes issues with my game           ║    30 Jan 2022     ║
  8. # ╚═════════════════════════════════════╩════════════════════╝
  9. # ╔══════════════════════════════════════════════════════════╗
  10. # ║ Plug and Play                                            ║
  11. # ╚══════════════════════════════════════════════════════════╝
  12. # ╔══════════════════════════════════════════════════════════╗
  13. # ║ Terms of use:                                            ║
  14. # ║ Free for all uses in RPG Maker except nudity             ║
  15. # ╚══════════════════════════════════════════════════════════╝
  16.  
  17. class Game_Actor < Game_Battler
  18.   def equip_materia(equip, slot, id, forced = false)
  19.     old = @materia_slots[equip][slot]
  20.     item = $game_party.materias[id].dup
  21.     list = $game_party.materias
  22.     total = $game_party.materias.size
  23.     # adjust for materia list
  24.     @materia_slots[equip][slot] = item
  25.     $game_party.materias = list
  26.     $game_party.lose_mater(item, id) unless forced
  27.     $game_party.gain_item(old, 1) if old
  28.     make_paired_materia
  29.     update_materia_skills
  30.     refresh
  31.   end
  32.  
  33.   def unequip_materia(equip, slot)
  34.     # gain item when equipment removed - Roninator2
  35.     return if equip.nil?
  36.     if slot == -1
  37.       for i in 0..@materia_slots.size - 1
  38.         next if @materia_slots[equip][i].nil?
  39.         $game_party.gain_item(@materia_slots[equip][i], 1)
  40.         @materia_slots[equip][i] = nil
  41.       end
  42.     else
  43.       item = @materia_slots[equip][slot]
  44.       $game_party.gain_item(@materia_slots[equip][slot], 1)
  45.       @materia_slots[equip][slot] = nil
  46.     end
  47.     make_paired_materia
  48.     update_materia_skills
  49.     refresh
  50.   end
  51. end
  52.  
  53. class Scene_MateriaShop < Scene_MenuBase
  54.   def on_sell_ok
  55.     Sound.play_shop
  56.     @item = @sell_window.materia
  57.     $game_party.gain_gold(selling_price)
  58.     $game_party.lose_materia(@sell_window.index)
  59.     #added line for equipment listed - roninator2
  60.     $game_party.lose_item(@item, 1)
  61.     activate_sell_window
  62.     index = @sell_window.index
  63.     @sell_window.select([[index, @sell_window.item_max - 1].min, 0].max)
  64.     refresh_windows
  65.   end
  66. end
  67.  
  68. class Game_Party < Game_Unit
  69.   attr_writer   :materias
  70.   def lose_mater(item, index)
  71.     @materias.delete_at(index)
  72.     @materias.compact!
  73.     @materias.sort! {|a, b| a.id <=> b.id }
  74.     # added to adjust item inventory
  75.     container = item_container(item.class)
  76.     return unless container
  77.     last_number = item_number(item)
  78.     new_number = last_number - 1
  79.     container[item.id] = [[new_number, 0].max, max_item_number(item)].min
  80.     container.delete(item.id) if container[item.id] == 0
  81.   end
  82.   def gain_item(item, amount, include_equip = false)
  83.     if item && item.materia?
  84.       gain_materia(item, amount)
  85.     end
  86.     # edit to add item to inventory
  87.     gain_item_ve_materia_system(item, amount, include_equip)
  88.   end
  89. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement