TheoAllen

Theo - Item slots

Feb 25th, 2013
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 33.72 KB | None | 0 0
  1. # =============================================================================
  2. # ♫ ~ Item slots by TheoAllen ~ ♫
  3. # Version  : 1.2c
  4. # Requires : N/A
  5. # Contact  : www.rpgmakerid.com
  6. # =============================================================================
  7. # ♫ UPDATES :
  8. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  9. # 2013.03.07 - Compatibility patch for YEA - Core Engine
  10. #            - Compatibility patch for YEA - Item menu
  11. #            - Compatibility patch for YEA - Shop Option
  12. # 2013.03.06 - Add force gain item method
  13. #            - Refix slot info window
  14. #        - Slot info window now can be seen in Scene equip
  15. # 2013.03.02 - Fixed bug when access equip menu
  16. # 2013.03.01 - Add slot_plus notetag for states, item, equip, and actor
  17. #            - Add slot_minus notetag for states
  18. # 2013.02.28 - Add weight notetag for each inventory item
  19. #            - Add slot info window at item menu
  20. #            - Add slot info and weight info at shop processing
  21. #            - Refixed gain item bug
  22. # 2013.02.27 - Fixed gain item bug
  23. # 2013.02.26 - Started and finished script
  24. #
  25. # =============================================================================
  26. # ♫ DESCRIPTION :
  27. # This script allow you to make maximum item by overall item possesed instead
  28. # of each item possesed
  29. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  30. # ♫ INSTRUCTION :
  31. # Put this script below material but above main in script editor. If u use YEA
  32. # shop options, put this script below YEA Shop Options. Don't forget to save.
  33. # =============================================================================
  34. # ♫ HOW TO USE :
  35. # ---------------------------------------
  36. # ♫ ACTOR NOTETAG
  37. # ---------------------------------------
  38. # <slot plus: x>
  39. # To specify additional slots each actor. Default value is based on "slots
  40. # number" in configurations below.
  41. # ---------------------------------------
  42. # ♫ ITEM NOTETAGS
  43. # ---------------------------------------
  44. # <weight: x>
  45. # To specify weight each item, (default = 1). Floating number such as 0.5 will
  46. # be counted as 1
  47. #
  48. # <slot plus: x>
  49. # To specify additional slots each item possesed. Default value 0
  50. # ---------------------------------------
  51. # ♫ WEAPON AND ARMOR NOTETAG
  52. # ---------------------------------------
  53. # <weight: x>
  54. # To specify weight each item. (default = 1). Floating number such as 0.5 will
  55. # be counted as 1
  56. #
  57. # <slot plus: x>
  58. # To specify additional slots if the weapon/armor is equiped. default value is 0
  59. # ---------------------------------------
  60. # ♫ STATE NOTETAGS
  61. # ---------------------------------------
  62. # <slot plus: x>
  63. # To specify additional slots each status. Default value is 0
  64. #
  65. # <slot minus: x>
  66. # To decrease maximum slots each status if status inflicted. Default value is 0
  67. # ---------------------------------------
  68. # You can type force_gain_item(x,y) in script call if you want to add item even
  69. # though the slot has reached it's max.
  70. #
  71. # Other configurations can be seen below
  72. # =============================================================================
  73. # ♫ TERMS OF USE :
  74. # - Credit me, TheoAllen.
  75. # - You may use and edit this script both for commercial and non-commercial or
  76. #   even adult game as long as u don't claim it yours.
  77. # - I'll be glad if you give me a free copy of your game if you use this script
  78. #   in your commercial project.
  79. # =============================================================================
  80. $imported = {} if $imported.nil?
  81. $imported["Theo-ItemSlots"] = true
  82. # =============================================================================
  83. # ♫ CONFIGURATIONS ~ ♫
  84. # =============================================================================
  85. module THEOLIZED
  86.   module ITEMSLOTS
  87.  
  88.   # ---------- General Setting ---------------
  89.     SLOTS_CURRENCY = "S"      # Currency of slot
  90.     DEFAULT_SLOTS  = 400      # Default Maximum slots
  91.     DYNAMIC_SLOTS  = true     # Maximum slots depens on notetags
  92.     DISPLAY_WEIGHT = true     # Display weight at shop processing and item menu
  93.                            
  94.   # ---------- Shop Processing ---------------                        
  95.     WEIGHT_VOCAB   = "Weight"  # Weight info for each item
  96.     SLOTS_VOCAB    = "Slots: " # Current slot info
  97.  
  98.   # ---------- Item Slots info ---------------
  99.     MAXSLOT_VOCAB     = "Max: "   # Vocab for maximum slot
  100.     USED_VOCAB        = "Used: "  # Vocab for used slot
  101.     WEIGHT_INFO_VOCAB = "Wght: "  # Vocab for item weight
  102.  
  103.   end
  104. end
  105. # =============================================================================
  106. # ♫ Do not edit unless you know what to do ~ ♫
  107. # =============================================================================
  108. # SCRIPT INFOS :
  109. # -------------------------------------
  110. # Rewriten method :
  111. # - Game_Party        
  112. #    def gain_item
  113. #    def item_max?
  114. # - Scene_Shop        
  115. #    def max_buy
  116. # - Scene_Item        
  117. #    def create_item_window
  118. # - Scene_Equip        
  119. #    def create_item_window
  120. # -------------------------------------
  121. # Aliased method :
  122. # - DataManager      
  123. #    def load_database
  124. # - Window_ItemList
  125. #    def refresh
  126. #    def update_help
  127. # - Window_ShopNumber
  128. #    def initialize
  129. #    def set
  130. #    def refresh
  131. # - Window_ShopStatus
  132. #    def refresh
  133. #    def draw_equip_info (YEA-ShopOptions compatibility patch)
  134. # - Scene_Menu        
  135. #    def start
  136. # - Scene_Item
  137. #    def use_item
  138. # - Scene_Equip
  139. #    def start
  140. # - Scene_Shop
  141. #    def on_buy_ok
  142. #    def on_sell_ok
  143. # -------------------------------------
  144. # New Classes :
  145. # - Window_ItemSlot
  146. # - Window_SlotInfo
  147. # =============================================================================
  148. # ♫ NOTETAG ~ ♫
  149. # =============================================================================
  150.  
  151. module THEOLIZED
  152.   module NOTETAGS_IS
  153.    
  154.     ITEM_WEIGHT   = /<(?:WEIGHT|weight):[ ]*(\d+)>/i
  155.     SLOT_PLUS     = /<(?:SLOT PLUS|slot plus):[ ]*(\d+)>/i
  156.     SLOT_MINUS    = /<(?:SLOT MINUS|slot minus):[ ]*(\d+)>/i
  157.    
  158.   end # notetags
  159. end # theolized
  160.  
  161. # =============================================================================
  162. # ♫ Module DataManager ~ ♫
  163. # =============================================================================
  164. module DataManager
  165.   #--------------------------------------------------------------------------
  166.   # ♫ Aliased load database
  167.   #--------------------------------------------------------------------------
  168.   class <<self;  alias load_database_itemslots load_database; end #self
  169.   def self.load_database
  170.     load_database_itemslots
  171.     load_theolized_is_notetags
  172.   end
  173.   #--------------------------------------------------------------------------
  174.   # ♫ New method : load item slot notetag
  175.   #--------------------------------------------------------------------------
  176.   def self.load_theolized_is_notetags
  177.     groups = [$data_items, $data_weapons, $data_armors, $data_actors, $data_states]
  178.     for group in groups
  179.       for obj in group
  180.         next if obj.nil?
  181.         obj.load_theolized_is_notetags
  182.       end # obj
  183.     end # group
  184.   end # load db
  185.  
  186. end # datamanager
  187. # =============================================================================
  188. # ♫ RPG::Item ~ ♫
  189. # =============================================================================
  190. class RPG::Actor < RPG::BaseItem
  191.  
  192.   attr_accessor :slot_plus
  193.   #--------------------------------------------------------------------------
  194.   # ♫ New method : load item slot notetag
  195.   #--------------------------------------------------------------------------
  196.   def load_theolized_is_notetags
  197.     @slot_plus = THEOLIZED::ITEMSLOTS::DEFAULT_SLOTS
  198.     self.note.split(/[\r\n]+/).each { |line|
  199.       case line
  200.       when THEOLIZED::NOTETAGS_IS::SLOT_PLUS
  201.         @slot_plus = $1.to_i
  202.       end
  203.       } # -- note split --
  204.   end
  205.  
  206. end #RPG::Actor
  207. # =============================================================================
  208. # ♫ RPG::Item ~ ♫
  209. # =============================================================================
  210. class RPG::Item < RPG::UsableItem
  211.  
  212.   attr_accessor :weight
  213.   attr_accessor :slot_plus
  214.   #--------------------------------------------------------------------------
  215.   # ♫ New method : load item slot notetag
  216.   #--------------------------------------------------------------------------
  217.   def load_theolized_is_notetags
  218.     @weight = 1
  219.     @slot_plus = 0
  220.     self.note.split(/[\r\n]+/).each { |line|
  221.       case line
  222.       when THEOLIZED::NOTETAGS_IS::ITEM_WEIGHT
  223.         @weight = $1.to_i
  224.       when THEOLIZED::NOTETAGS_IS::SLOT_PLUS
  225.         @weight = 0
  226.         @slot_plus = $1.to_i
  227.       end
  228.     } # -- note split -- #
  229.    end
  230. end
  231. # =============================================================================
  232. # ♫ RPG::EquipItem ~ ♫
  233. # =============================================================================
  234. class RPG::EquipItem < RPG::BaseItem
  235.  
  236.   attr_accessor :weight
  237.   attr_accessor :slot_plus
  238.   #--------------------------------------------------------------------------
  239.   # ♫ New method : load equip slot notetags
  240.   #--------------------------------------------------------------------------
  241.   def load_theolized_is_notetags
  242.     @weight = 1
  243.     @slot_plus = 0
  244.     self.note.split(/[\r\n]+/).each { |line|
  245.       case line
  246.       when THEOLIZED::NOTETAGS_IS::ITEM_WEIGHT
  247.         @weight = $1.to_i
  248.       when THEOLIZED::NOTETAGS_IS::SLOT_PLUS
  249.         @slot_plus = $1.to_i
  250.       end      
  251.     } # -- note split -- #
  252.   end
  253.  
  254. end
  255. # =============================================================================
  256. # ♫ RPG::States ~ ♫
  257. # =============================================================================
  258. class RPG::State < RPG::BaseItem
  259.  
  260.   attr_accessor :slot_plus
  261.   attr_accessor :slot_minus
  262.   #--------------------------------------------------------------------------
  263.   # ♫ New method : load states slot notetags
  264.   #--------------------------------------------------------------------------
  265.   def load_theolized_is_notetags
  266.   @slot_plus = 0
  267.   @slot_minus  = 0
  268.   self.note.split(/[\r\n]+/).each { |line|
  269.     case line
  270.     when THEOLIZED::NOTETAGS_IS::SLOT_PLUS
  271.       @slot_plus = $1.to_i
  272.     when THEOLIZED::NOTETAGS_IS::SLOT_MINUS
  273.       @slot_minus = $1.to_i
  274.     end
  275.     }
  276.   end
  277.  
  278. end  
  279. # =============================================================================
  280. # ♫ Game_Party ~ ♫
  281. # =============================================================================
  282. class Game_Party < Game_Unit
  283.   #--------------------------------------------------------------------------
  284.   # ♫ New method : Get maximum slots
  285.   #--------------------------------------------------------------------------
  286.   def max_slots_number
  287.     if THEOLIZED::ITEMSLOTS::DYNAMIC_SLOTS
  288.       total_slots = 0
  289.   # ------- calculate additional slots for item each and party member ----- #  
  290.       all_members.each {|actor|
  291.         total_slots += $data_actors[actor.id].slot_plus
  292.         actor.equips.each {|equip|
  293.           total_slots += equip.slot_plus unless equip.nil?
  294.         }
  295.       }
  296.   # -------- calculate slots change in actor's states ---------------- #    
  297.       party_member = all_members.collect{|actor| actor.id}
  298.       party_member.each {|id|
  299.         $game_actors[id].states.each {|state|
  300.           total_slots += state.slot_plus
  301.           total_slots -= state.slot_minus
  302.         }
  303.       }
  304.       return total_slots
  305.     else
  306.       return THEOLIZED::ITEMSLOTS::DEFAULT_SLOTS
  307.     end
  308.   end
  309.   #--------------------------------------------------------------------------
  310.   # ♫ New method : Get avalaible slots
  311.   #--------------------------------------------------------------------------
  312.   def avalaible_slots
  313.     max_slots_number - all_inventory_slots
  314.   end
  315.   #--------------------------------------------------------------------------
  316.   # ♫ New method : Get all used slots
  317.   #--------------------------------------------------------------------------
  318.   def all_inventory_slots
  319.     value = inventory_slots(@items, $data_items)
  320.     value += inventory_slots(@weapons, $data_weapons)
  321.     value += inventory_slots(@armors, $data_armors)
  322.     value += equip_slots
  323.     return value
  324.   end
  325.   #--------------------------------------------------------------------------
  326.   # ♫ New method : Get used equips slots
  327.   #--------------------------------------------------------------------------  
  328.   def equip_slots
  329.     total_amount = 0
  330.     all_members.each {|actor|
  331.       actor.equips.each {|equip|
  332.         total_amount += equip.weight unless equip.nil?
  333.       }
  334.     }
  335.     return total_amount
  336.   end
  337.   #--------------------------------------------------------------------------
  338.   # ♫ New method : Get used slots
  339.   #--------------------------------------------------------------------------
  340.   def inventory_slots(inventory, type)
  341.     total_amount = 0
  342.     inventory.each do |id,amount|
  343.       total_amount += amount * type[id].weight
  344.     end
  345.     return total_amount
  346.   end
  347.   #--------------------------------------------------------------------------
  348.   # ♫ New method : force_gain_item
  349.   #--------------------------------------------------------------------------
  350.   def force_gain_item(item, amount)
  351.     container = item_container(item.class)
  352.     return unless container || amount == 0
  353.     container[item.id] = 0 if container[item.id].nil?
  354.     container[item.id] += amount
  355.     container.delete(item.id) if container[item.id] <= 0
  356.     $game_map.need_refresh = true
  357.   end
  358.  
  359.   #--------------------------------------------------------------------------
  360.   # ♫ Overwrite : Gain item
  361.   #--------------------------------------------------------------------------
  362.   def gain_item(item, amount, include_equip = false)
  363.     container = item_container(item.class)
  364.     return unless container || amount == 0
  365.     container[item.id] = 0 if container[item.id].nil?
  366.     container[item.id] += [amount, avalaible_slots/item.weight].min unless item_max?(item)
  367.     container.delete(item.id) if container[item.id] <= 0
  368.     if include_equip
  369.       discard_members_equip(item, amount)
  370.     end
  371.     $game_map.need_refresh = true
  372.   end
  373.   #--------------------------------------------------------------------------
  374.   # ♫ Overwrite : Item max
  375.   #--------------------------------------------------------------------------
  376.   def item_max?(item)
  377.     avalaible_slots < item.weight
  378.   end
  379.   #--------------------------------------------------------------------------
  380.   # ♫ New Method : Get used slots
  381.   #--------------------------------------------------------------------------
  382.   def used_slots
  383.     max_slots_number - avalaible_slots
  384.   end
  385.  
  386. end
  387. # =============================================================================
  388. # ♫ Window_Base ~ ♫
  389. # =============================================================================
  390. class Window_Base
  391.   #--------------------------------------------------------------------------
  392.   # ♫ Exclusive method for slot value
  393.   #--------------------------------------------------------------------------
  394.   def draw_slot_value(value, unit, x, y, width)
  395.     cx = text_size(unit).width
  396.     change_color(normal_color)
  397.     draw_text(x, y, width - cx - 2, line_height, value, 2)
  398.     change_color(system_color)
  399.     draw_text(x, y, width, line_height, unit, 2)
  400.   end
  401. end
  402.  
  403. # =============================================================================
  404. # ♫ New class : Window_ItemSlots ~ ♫
  405. # =============================================================================
  406. class Window_ItemSlots < Window_Base
  407.   #--------------------------------------------------------------------------
  408.   # ♫ Object initialization
  409.   #--------------------------------------------------------------------------
  410.   def initialize
  411.     super(0, 0, window_width, fitting_height(1))
  412.     refresh
  413.   end
  414.   #--------------------------------------------------------------------------
  415.   # ♫ Get window width
  416.   #--------------------------------------------------------------------------
  417.   def window_width
  418.     return 160
  419.   end
  420.   #--------------------------------------------------------------------------
  421.   # ♫ Refresh
  422.   #--------------------------------------------------------------------------
  423.   def refresh
  424.     contents.clear
  425.     draw_slot_value(value, slots_currency, 4, 0, contents.width - 8)
  426.   end
  427.   #--------------------------------------------------------------------------
  428.   # ♫ Get party avalaible slots
  429.   #--------------------------------------------------------------------------
  430.   def value
  431.     return $game_party.used_slots.to_s + '/' + $game_party.max_slots_number.to_s
  432.   end
  433.   #--------------------------------------------------------------------------
  434.   # ♫ Get slots currency
  435.   #--------------------------------------------------------------------------
  436.   def slots_currency
  437.     THEOLIZED::ITEMSLOTS::SLOTS_CURRENCY
  438.   end
  439.   #--------------------------------------------------------------------------
  440.   # ♫ Open window
  441.   #--------------------------------------------------------------------------
  442.   def open
  443.     refresh
  444.     super
  445.   end
  446.  
  447. end
  448. # =============================================================================
  449. # ♫ New class : Window_SlotInfo ~ ♫
  450. # =============================================================================
  451. class Window_SlotInfo < Window_Base
  452.   #--------------------------------------------------------------------------
  453.   # ♫ Object initialization
  454.   #--------------------------------------------------------------------------
  455.   def initialize
  456.     super(0,0,width,fitting_height(1))
  457.     @item = nil
  458.     refresh
  459.   end
  460.   #--------------------------------------------------------------------------
  461.   # ♫ Get window width
  462.   #--------------------------------------------------------------------------
  463.   def width
  464.     Graphics.width
  465.   end
  466.   #--------------------------------------------------------------------------
  467.   # ♫ Refresh
  468.   #--------------------------------------------------------------------------
  469.   def refresh
  470.     contents.clear
  471.     draw_all_info_slot
  472.   end
  473.   #--------------------------------------------------------------------------
  474.   # ♫ Draw all slots info
  475.   #--------------------------------------------------------------------------
  476.   def draw_all_info_slot
  477.     if THEOLIZED::ITEMSLOTS::DISPLAY_WEIGHT
  478.       w = width / 3
  479.       draw_max_slot(0,w)
  480.       draw_used_slot(w,w)
  481.       draw_weight_info(w+w,w)
  482.     else
  483.       w = width / 2
  484.       draw_max_slot(0,w)
  485.       draw_used_slot(w,w)
  486.     end
  487.   end
  488.   #--------------------------------------------------------------------------
  489.   # ♫ Draw maximum slots
  490.   #--------------------------------------------------------------------------
  491.   def draw_max_slot(x,width)
  492.     draw_info(maxslots,THEOLIZED::ITEMSLOTS::MAXSLOT_VOCAB,4+x,0,width)
  493.   end
  494.   #--------------------------------------------------------------------------
  495.   # ♫ Draw used slots
  496.   #--------------------------------------------------------------------------
  497.   def draw_used_slot(x,width)
  498.     draw_info(used_slots,THEOLIZED::ITEMSLOTS::USED_VOCAB,4+x,0,width)
  499.   end
  500.   #--------------------------------------------------------------------------
  501.   # ♫ Draw item weight
  502.   #--------------------------------------------------------------------------
  503.   def draw_weight_info(x,width)
  504.     draw_info(@item.nil? ? 0 : @item,THEOLIZED::ITEMSLOTS::WEIGHT_INFO_VOCAB,4+x,0,width)
  505.   end
  506.   #--------------------------------------------------------------------------
  507.   # ♫ Draw slot info
  508.   #--------------------------------------------------------------------------
  509.   def draw_info(value, unit, x, y, width)
  510.     cx = text_size(unit).width
  511.     change_color(normal_color)
  512.     draw_text(x, y, width - cx - 2, line_height, value, 2)
  513.     change_color(system_color)
  514.     draw_text(x, y, width, line_height, unit, 0)
  515.   end
  516.   #--------------------------------------------------------------------------
  517.   # ♫ Get maximum slots
  518.   #--------------------------------------------------------------------------
  519.   def maxslots
  520.     $game_party.max_slots_number
  521.   end
  522.   #--------------------------------------------------------------------------
  523.   # ♫ Get used slots
  524.   #--------------------------------------------------------------------------
  525.   def used_slots
  526.     $game_party.used_slots
  527.   end
  528.   #--------------------------------------------------------------------------
  529.   # ♫ Set weight info
  530.   #--------------------------------------------------------------------------
  531.   def set_item(item)
  532.     item ? @item = item.weight : @item = 0
  533.     refresh
  534.   end
  535.  
  536. end  
  537. # =============================================================================
  538. # ♫ Window_ItemList ~ ♫
  539. # =============================================================================
  540. class Window_ItemList < Window_Selectable
  541.   attr_accessor :slots_info
  542.   #--------------------------------------------------------------------------
  543.   # ♫ Aliased method : Update help
  544.   #--------------------------------------------------------------------------
  545.   alias theo_update_help update_help
  546.   def update_help
  547.     theo_update_help
  548.     @slots_info.set_item(item)
  549.   end
  550.  
  551. end
  552. # =============================================================================
  553. # ♫ Window_EquipSlot ~ ♫
  554. # =============================================================================
  555. class Window_EquipSlot < Window_Selectable
  556.   attr_accessor :slots_info
  557.   #--------------------------------------------------------------------------
  558.   # ♫ Aliased method : Update help
  559.   #--------------------------------------------------------------------------
  560.   alias theo_update_help update_help
  561.   def update_help
  562.     theo_update_help
  563.     @slots_info.set_item(item) if @slots_info
  564.   end
  565.  
  566. end
  567. # =============================================================================
  568. # ♫ Window_EquipItem ~ ♫
  569. # =============================================================================
  570. class Window_EquipItem < Window_ItemList
  571.   attr_accessor :slots_info
  572.   #--------------------------------------------------------------------------
  573.   # ♫ Normalized method : Update help
  574.   #--------------------------------------------------------------------------
  575.   def update_help
  576.     theo_update_help
  577.     @slots_info.set_item(item)
  578.   end  
  579. end
  580. # =============================================================================
  581. # ♫ Window_ShopSell ~ ♫
  582. # =============================================================================
  583. class Window_ShopSell < Window_ItemList
  584.   #--------------------------------------------------------------------------
  585.   # ♫ Normalized method : Update help
  586.   #--------------------------------------------------------------------------
  587.   def update_help
  588.     theo_update_help
  589.   end  
  590. end
  591. # =============================================================================
  592. # ♫ Window_ShopStatus ~ ♫
  593. # =============================================================================
  594. class Window_ShopStatus < Window_Base
  595.   #--------------------------------------------------------------------------
  596.   # ♫ Manually aliased method : Refresh
  597.   #--------------------------------------------------------------------------
  598.   def theo_refresh
  599.     contents.clear
  600.     draw_possession(4, 0)
  601.     draw_equip_info(4, line_height * 2) if @item.is_a?(RPG::EquipItem)
  602.   end
  603.   #--------------------------------------------------------------------------
  604.   # ♫ Aliased method : Refresh
  605.   #--------------------------------------------------------------------------
  606.   def refresh
  607.     theo_refresh
  608.     draw_item_weight(4,line_height) if THEOLIZED::ITEMSLOTS::DISPLAY_WEIGHT
  609.   end
  610.   #--------------------------------------------------------------------------
  611.   # ♫ New method : Draw item weight
  612.   #--------------------------------------------------------------------------
  613.   def draw_item_weight(x,y)
  614.     rect = Rect.new(x,y,contents.width - 4 - x, line_height)
  615.     change_color(system_color)
  616.     draw_text(rect,THEOLIZED::ITEMSLOTS::WEIGHT_VOCAB)
  617.     change_color(normal_color)        
  618.     draw_text(rect,!@item.nil? ? @item.weight : 0,2)
  619.   end
  620.   #--------------------------------------------------------------------------
  621.   # ♫ Aliased method : Draw equip info
  622.   #--------------------------------------------------------------------------
  623.   alias theolized_equip_info draw_equip_info
  624.   def draw_equip_info(dx, dy)
  625.     if $imported["YEA-ShopOptions"]
  626.       status_members.each_with_index do |actor, i|
  627.         draw_actor_equip_info(dx, dy + line_height * i, actor)
  628.       end
  629.     else
  630.       theolized_equip_info
  631.     end
  632.   end
  633.    
  634. end
  635. # =============================================================================
  636. # ♫ Window_ShopNumber ~ ♫
  637. # =============================================================================
  638. class Window_ShopNumber < Window_Selectable
  639.   #--------------------------------------------------------------------------
  640.   # ♫ Aliased method : Initialize
  641.   #--------------------------------------------------------------------------
  642.   alias theo_is_init initialize
  643.   def initialize(x, y, height)
  644.     theo_is_init(x, y, height)
  645.     @slots = "0/0"
  646.     @slots_temp = 0
  647.   end
  648.   #--------------------------------------------------------------------------
  649.   # ♫ Aliased method : Set item
  650.   #--------------------------------------------------------------------------
  651.   alias theolized_set set
  652.   def set(item, max, price, currency_unit = nil)
  653.     theolized_set(item, max, price, currency_unit)
  654.     slot_refresh
  655.   end
  656.   #--------------------------------------------------------------------------
  657.   # ♫ New method : Get slot currency
  658.   #--------------------------------------------------------------------------
  659.   def slots_currency
  660.     THEOLIZED::ITEMSLOTS::SLOTS_CURRENCY
  661.   end
  662.   #--------------------------------------------------------------------------
  663.   # ♫ New method : Get slot vocab
  664.   #--------------------------------------------------------------------------
  665.   def slots_vocab
  666.     THEOLIZED::ITEMSLOTS::SLOTS_VOCAB
  667.   end
  668.   #--------------------------------------------------------------------------
  669.   # ♫ Aliased method : refresh
  670.   #--------------------------------------------------------------------------
  671.   alias theolized_is_refresh refresh
  672.   def refresh
  673.     theolized_is_refresh
  674.     slot_refresh
  675.     draw_slot_info
  676.   end
  677.   #--------------------------------------------------------------------------
  678.   # ♫ New method : Draw slot info
  679.   #--------------------------------------------------------------------------
  680.   def draw_slot_info
  681.     width = contents_width - 8
  682.     if $imported["YEA-ShopOptions"]
  683.       draw_slot_value(@slots,slots_currency,4,price_y+(line_height*4),width)
  684.       draw_text(4,price_y+(line_height*4), width, line_height, slots_vocab)
  685.     else
  686.       draw_slot_value(@slots,slots_currency,4,price_y+(line_height*2),width)
  687.       draw_text(4,price_y+(line_height*2), width, line_height, slots_vocab)
  688.     end
  689.   end
  690.   #--------------------------------------------------------------------------
  691.   # ♫ New method : Set weight slot
  692.   #--------------------------------------------------------------------------
  693.   def set_slot(number)    
  694.     @slots_temp = number
  695.     refresh
  696.   end
  697.   #--------------------------------------------------------------------------
  698.   # ♫ New method : Refresh slot
  699.   #--------------------------------------------------------------------------
  700.   def slot_refresh
  701.     temp = $game_party.max_slots_number
  702.     temp2 = $game_party.used_slots+(@slots_temp * @number)
  703.     @slots = temp2.to_s + '/' + temp.to_s
  704.   end
  705.  
  706. end
  707. # =============================================================================
  708. # ♫ Scene_Menu ~ ♫
  709. # =============================================================================
  710. class Scene_Menu < Scene_MenuBase
  711.   #--------------------------------------------------------------------------
  712.   # ♫ Aliased start
  713.   #--------------------------------------------------------------------------
  714.   alias theo_itemslot_start start
  715.   def start
  716.     theo_itemslot_start
  717.     create_itemslot_window
  718.   end
  719.   #--------------------------------------------------------------------------
  720.   # ♫ New method : Create item slots window
  721.   #--------------------------------------------------------------------------
  722.   def create_itemslot_window
  723.     @slot_window = Window_ItemSlots.new
  724.     @slot_window.x = 0
  725.     @slot_window.y = Graphics.height - (@gold_window.height + @slot_window.height)
  726.   end
  727. end
  728. # =============================================================================
  729. # ♫ Scene_Item ~ ♫
  730. # =============================================================================
  731. class Scene_Item < Scene_ItemBase
  732.   #--------------------------------------------------------------------------
  733.   # ♫ Aliased method : Start
  734.   #--------------------------------------------------------------------------
  735.   alias theo_itemslots_start start
  736.   def start
  737.     theo_itemslots_start
  738.     create_slotinfo_window
  739.   end
  740.   #--------------------------------------------------------------------------
  741.   # ♫ New method : Create slot info window
  742.   #--------------------------------------------------------------------------
  743.   def create_slotinfo_window
  744.     wy = @help_window.height + @category_window.height + @item_window.height
  745.     @window_slotsinfo = Window_SlotInfo.new
  746.     @window_slotsinfo.y = wy
  747.     @window_slotsinfo.viewport = @viewport
  748.     @item_window.slots_info = @window_slotsinfo
  749.   end
  750.   #--------------------------------------------------------------------------
  751.   # ♫ Overwrite : Create item window
  752.   #--------------------------------------------------------------------------
  753.   def create_item_window
  754.     wy = @category_window.y + @category_window.height
  755.     wh = Graphics.height - wy - (24*2)
  756.     @item_window = Window_ItemList.new(0, wy, Graphics.width, wh)
  757.     @item_window.viewport = @viewport
  758.     @item_window.help_window = @help_window
  759.     @item_window.set_handler(:ok,     method(:on_item_ok))
  760.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  761.     @category_window.item_window = @item_window
  762.   end
  763.   #--------------------------------------------------------------------------
  764.   # ♫ Aliased method : Use item
  765.   #--------------------------------------------------------------------------
  766.   alias theolized_use_item use_item
  767.   def use_item
  768.     theolized_use_item
  769.     @window_slotsinfo.refresh
  770.   end
  771.  
  772. end
  773. # =============================================================================
  774. # ♫ Scene_Equip ~ ♫
  775. # =============================================================================
  776. class Scene_Equip < Scene_MenuBase
  777.   #--------------------------------------------------------------------------
  778.   # ♫ Aliased method : start
  779.   #--------------------------------------------------------------------------
  780.   alias theolized_is_start start
  781.   def start
  782.     theolized_is_start
  783.     create_slotinfo_window
  784.   end
  785.   #--------------------------------------------------------------------------
  786.   # ♫ New method : create slot info window
  787.   #--------------------------------------------------------------------------  
  788.   def create_slotinfo_window
  789.     wy = @help_window.height + @status_window.height + @item_window.height
  790.     @window_slotsinfo = Window_SlotInfo.new
  791.     @window_slotsinfo.y = wy
  792.     @window_slotsinfo.viewport = @viewport
  793.     @item_window.slots_info = @window_slotsinfo
  794.     @slot_window.slots_info = @window_slotsinfo
  795.   end
  796.   #--------------------------------------------------------------------------
  797.   # ♫ Overwrite : Create item window
  798.   #--------------------------------------------------------------------------  
  799.   def create_item_window
  800.     wx = 0
  801.     wy = @slot_window.y + @slot_window.height
  802.     ww = Graphics.width
  803.     wh = Graphics.height - wy - (24*2)
  804.     @item_window = Window_EquipItem.new(wx, wy, ww, wh)
  805.     @item_window.viewport = @viewport
  806.     @item_window.help_window = @help_window
  807.     @item_window.status_window = @status_window
  808.     @item_window.actor = @actor
  809.     @item_window.set_handler(:ok,     method(:on_item_ok))
  810.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  811.     @slot_window.item_window = @item_window
  812.   end
  813. end
  814. # =============================================================================
  815. # ♫ Scene_Shop ~ ♫
  816. # =============================================================================
  817. class Scene_Shop < Scene_MenuBase
  818.   #--------------------------------------------------------------------------
  819.   # ♫ Aliased method : Sell OK
  820.   #--------------------------------------------------------------------------
  821.   alias theolized_sell_ok on_sell_ok
  822.   def on_sell_ok
  823.     theolized_sell_ok
  824.     @number_window.set_slot(-@item.weight)
  825.   end
  826.   #--------------------------------------------------------------------------
  827.   # ♫ Aliased method : Buy OK
  828.   #--------------------------------------------------------------------------
  829.   alias theolized_buy_ok on_buy_ok
  830.   def on_buy_ok
  831.     theolized_buy_ok
  832.     @number_window.set_slot(@item.weight)
  833.   end
  834.   #--------------------------------------------------------------------------
  835.   # ♫ Overwrite : max buying item
  836.   #--------------------------------------------------------------------------
  837.   def max_buy
  838.     check_slot = $game_party.avalaible_slots > @item.weight
  839.     check_slot ? max = $game_party.avalaible_slots / @item.weight : max = 0
  840.     buying_price == 0 ? max : [max, money / buying_price].min
  841.   end
  842.  
  843. end
  844. # =============================================================================
  845. # ♫ Outside of class ~ ♫
  846. # =============================================================================
  847. def force_gain_item(item, amount)
  848.   $game_party.force_gain_item(item, amount)
  849. end
  850. # =============================================================================
  851. # ♫ End of script ~ ♫
  852. # =============================================================================
Add Comment
Please, Sign In to add comment