Enelvon

SES - Instance Items Anti-Bloat

Feb 16th, 2013
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.22 KB | None | 0 0
  1. #═╦═════════════════════════════════════════════════════════════════════════════
  2. # ║ § Instance Items Anti-Bloat (v1.1) by Enelvon       [License: CC BY-SA 3.0]
  3. # ║                                                            <RMVX Ace>
  4. #═╬═════════════════════════════════════════════════════════════════════════════
  5. # ║ § Change Log
  6. #─╫─────────────────────────────────────────────────────────────────────────────
  7. # ║ v1.0 (February 16th, 2013) - Script Written
  8. # ║ v1.1 (February 17th, 2013) - Fixed bug that caused changing equipment to be
  9. # ║                              impossible
  10. # ║
  11. #═╬═════════════════════════════════════════════════════════════════════════════
  12. # ║ § Summary
  13. #─╫─────────────────────────────────────────────────────────────────────────────
  14. # ║ This is an add-on for my Instance Items script that will prevent old
  15. # ║ instances from being stored after being sold. I had allowed them to remain
  16. # ║ due to a couple of planned add-ons, but decided to write this for those
  17. # ║ who would like it.
  18. #═╬═════════════════════════════════════════════════════════════════════════════
  19. # ║ § Required Scripts
  20. #─╫─────────────────────────────────────────────────────────────────────────────
  21. # ║ SES Core
  22. # ║ SES - Instance Items
  23. # ║
  24. #═╬═════════════════════════════════════════════════════════════════════════════
  25. # ║ § Known Incompatibilities
  26. #─╫─────────────────────────────────────────────────────────────────────────────
  27. # ║ None so far
  28. # ║
  29. #═╬═════════════════════════════════════════════════════════════════════════════
  30. # ║ § Installation
  31. #─╫─────────────────────────────────────────────────────────────────────────────
  32. # ║ Place this below Materials, the SES Script Core, and Instance Items and
  33. # ║ above all other non-SES custom scripts (though make sure it's above any
  34. # ║ other Instance Item extensions, just to be safe).
  35. # ║
  36. #═╬═════════════════════════════════════════════════════════════════════════════
  37. # ║ § Configuration
  38. #─╫─────────────────────────────────────────────────────────────────────────────
  39. # ║ None
  40. # ║
  41. #═╬═════════════════════════════════════════════════════════════════════════════
  42. # ║ § Aliased Methods
  43. #─╫─────────────────────────────────────────────────────────────────────────────
  44. # ║ ● module DataManager
  45. # ║     self.create_game_objects
  46. # ║
  47. #═╬═════════════════════════════════════════════════════════════════════════════
  48. # ║ § Redefined Methods
  49. #─╫─────────────────────────────────────────────────────────────────────────────
  50. # ║ ● class Game_Party
  51. # ║     new_item(item, type)
  52. # ║     lose_item(item, amount, include_equip = false)
  53. # ║
  54. #═╬═════════════════════════════════════════════════════════════════════════════
  55. # ║ ▼ module DataManager
  56. #═╩═════════════════════════════════════════════════════════════════════════════
  57.  
  58. module DataManager
  59.  
  60.   class << self
  61.     alias en_iiab_dm_cgo create_game_objects
  62.   end
  63.  
  64.   def self.create_game_objects
  65.     en_fs_dm_cgo
  66.     $game_armors, $game_weapons, $game_items =
  67.     {},           {},            {}
  68.     $data_armors.each_with_index do |v,k|
  69.       $game_armors[k] = v
  70.     end
  71.     $data_weapons.each_with_index do |v,k|
  72.       $game_weapons[k] = v
  73.     end
  74.     $data_items.each_with_index do |v,k|
  75.       $game_items[k] = v
  76.     end
  77.   end
  78. end
  79. #═╦═════════════════════════════════════════════════════════════════════════════
  80. # ║ ▲ module DataManager
  81. #─╫─────────────────────────────────────────────────────────────────────────────
  82. # ║ ▼ class Game_Party
  83. #═╩═════════════════════════════════════════════════════════════════════════════
  84. class Game_Party < Game_Unit
  85.  
  86.   def new_item(item, type)
  87.     newi = Marshal.load(Marshal.dump(item))
  88.     newi.old_id = item.id
  89. #~     newi.instanced = true
  90.     newi.id = eval("$game_#{type}s.keys.max + 1")
  91.     newi = process_new_item(newi)
  92.     eval("$game_#{type}s[newi.id] = newi
  93.    return $game_#{type}s[newi.id]")
  94.   end
  95.  
  96.   def lose_item(*args)
  97.     args[1] *= -1
  98.     trade_item(*args)
  99.     item = args[0]
  100.     if item && item.unique && !SceneManager.scene == Scene_Equip
  101.       if item.is_a?(RPG::Item) then $game_items.delete(item.id)
  102.       elsif item.is_a?(RPG::Weapon) then $game_weapons.delete(item.id)
  103.       elsif item.is_a?(RPG::Armor) then $game_armors.delete(item.id) end
  104.     end
  105.   end
  106. end
  107. #═╦═════════════════════════════════════════════════════════════════════════════
  108. # ║ ▲ class Game_Party
  109. #═╩═════════════════════════════════════════════════════════════════════════════
Advertisement
Add Comment
Please, Sign In to add comment