Per 2016, RMID pindah ke RMID Discord (Invite link dihapus untuk mencegah spambot -Theo @ 2019). Posting sudah tidak bisa dilakukan lagi.
Mohon maaf atas ketidaknyamanannya dan mohon kerjasamanya.
|
|
| 2010-07-26, 01:15 | LIMITED INVENTORY SYSTEM |
---|
rusted_71 Scripter Karatan
Posts : 392 Thanked : 11 Engine : RMVX Skill : Beginner Type : Scripter
| LIMITED INVENTORY Versi: 1.0 Tipe: Item Management Pengenalansebenernya seh tadinya nih cuma untuk project pribadi, tapi ternyata sang admin kodok meminta untuk mempublish, jadi karena ga tega melihat air matanya akhirnya saya mempublish juga script ini (lebay mode = on) Fitur
- Item yang di bawa2 oleh party terbatas oleh besarnya slot inventory
- item dapat di stack pada jumlah tertentu per slot (jadi bisa bawa 99 potion)
- sedangkan weapon dan armor hanya di bawa 1 per slot (klo bawa lebih dari 1 bakal ngabisin slot)
- inventory penuh pas mau dapet item penting? tenang aja ada loot management nya kok
Screenshotsparty inventory scene - Spoiler:
loot management scene - Spoiler:
DemoDemonya bang Scripts- Spoiler:
- Code:
-
#============================================================================== # Limited Inventory # Version: 1.0 # Author: rusted_71 # Date: July 26, 2010 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # Description: # Script ini berguna untuk membatasi inventory / item yang di bawah oleh # party # party dapat membawa satu jenis barang sampai batas maksimal (default = 99) # namun untuk weapon dan armor party hanya dapat membawa satu (jika mendapat # weapon atau armor yang sama akan memerlukan slot baru pada inventory) #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # Instructions: # Untuk awal penggunaan copi paste script ini di atas main dan di bawah # semua custom script... # # Setelah itu untuk kenyamanan penggunaan harap lakukan beberapa perubahan # pada default script, sebagai berikut # # pada Scene_Item baris 141 (# Erase target window) # ubahlah baris di bawahnya, dari # # @target_window.visible = false # # menjadi # # @target_window.index = -2 # # untuk pengaturan selanjutnya dapat diliat petunjuk pada module RUSTED_ITEM # # di dalam game kamu dapat mengubah besarnya slot inventory party dengan cara # ketikan code dibawah ini pada script di event # # resize_inventory(new_size) # # new_size dapat diisi angka yang lebih besar atau lebih kecil dari besarnya # inventory sebelum di ubah. Jika lebih kecil ada beberapa item yang akan # dihapus, namun item yang akan di hapus dapat di pilih setelahnya. # #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # # Credit: # Untuk buat ini memang ga sampai membuat saya berkeringat dingin atau masuk # rumah sakit dan di opname. Tapi kalau memang kerjaan saya ini dipakai untuk # projek kamu, tolong cantumkan nama saya (rusted_71) di bagian credit projek # kamu. # # Thank to: # modern_algebra # #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # # Bug report or anything else: # hubungi saya di rusted_71@yahoo.co.id atau # PM rusted_71 di rmid.forumotion.net atau # #============================================================================== module RUSTED_ITEM #============================================================================== # *** EDITABLE SECTION #============================================================================== NONDISCARD = {0 => [31,25], #masukan id dari item2 yg nondiscardable 1 => [5,2], #masukan id dari weapon2 yg nondiscardable 2 => [1,2]} #masukan id dari armor2 yg nondiscardable
DEFAULT_MAX_SIZE = 10 #masukan besarnya inventory awal party
DEFAULT_ITEM_STACK = 99 #masukan jumlah batas max dari item # STRING SECTION PARTY_INV = "Party Inventory" LOOT_INV = "Items to Discard" USE_COM = "Use" DIS_COM = "Discard" #============================================================================== # *** END of EDITABLE SECTION #============================================================================== end
#============================================================================== # ** Game Actor #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # Summary of Changes: # aliased method - equip #============================================================================== class Game_Actor < Game_Battler alias new_equip equip def equip(*args) new_equip(*args) if !$game_temp.slots_to_discard.slots.empty? $game_temp.slots_to_discard.slots.reverse.each { |slot| break unless $game_party.limit_inventory.enough_space? (slot) item, type, id, n = slot.item, slot.item_type, slot.item_id, slot.amount $game_party.gain_item(item, n) $game_temp.slots_to_discard.remove_item (type, id, n) } end end end
#============================================================================== # ** Game Actor #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # Summary of Changes: # new public instance variables - slots_to_discard #==============================================================================
class Game_Temp alias new_initialize initialize attr_accessor :slots_to_discard def initialize new_initialize @slots_to_discard = Game_LimitedInventory.new(-1) end end
#============================================================================== # ** Game Actor #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # Summary of Changes: # new public instance variables - limit_inventory # aliased method # initialize # gain_item # gain_armor # new method # reduce_item # gain_proses #============================================================================== class Game_Party #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Public Instance Variables #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ attr_reader :limit_inventory #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Aliased Method #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias new_initialize initialize alias new_gain_item gain_item alias new_gain_weapon gain_weapon alias new_gain_armor gain_armor #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Object Initialization #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def initialize new_initialize @limit_inventory = Game_LimitedInventory.new (RUSTED_ITEM::DEFAULT_MAX_SIZE) end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Gain Item (or Lose) # item >> item / item_id # n >> number #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def gain_item(item, n) if item.is_a?(RPG::Item) gain_proses(item, n) id = item.id elsif item.is_a?(RPG::Weapon) gain_weapon(item.id, n) elsif item.is_a?(RPG::Armor) gain_armor(item.id, n) else gain_proses($data_items[item],n) id = item end new_gain_item (id, n) if id != nil end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Gain Weapon And Armor (or Lose) # item_id >> weapon / armor id # n >> number #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def gain_weapon(item_id, n) new_gain_weapon (item_id, n) gain_proses($data_weapons[item_id],n) end def gain_armor(item_id, n) new_gain_armor (item_id, n) gain_proses($data_armors[item_id],n) end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Reduce_Item (for synchronize default item number and limited item number) # item >> item # n >> number #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def reduce_item(item, n) if item.is_a?(RPG::Item) new_gain_item (item.id, -1*n) elsif item.is_a?(RPG::Weapon) new_gain_weapon (item.id, -1*n) else new_gain_armor (item.id, -1*n) end end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Gain Proses # item >> item # n >> number #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def gain_proses(item,n) if item != nil type = item.is_a? (RPG::Item) ? 0 : item.is_a? (RPG::Weapon) ? 1 : 2 if n > 0 n2 = @limit_inventory.add_item (type, item.id, n) n -= n2 if RUSTED_ITEM::NONDISCARD[type].include?(item.id) while n2 > 0 for i in 0...@limit_inventory.slots.size x = @limit_inventory.slots.size - 1 - i slot = @limit_inventory.slots[x] if !RUSTED_ITEM::NONDISCARD[slot.item_type].include?(slot.item_id) l_type, id = slot.item_type, slot.item_id while l_type == slot.item_type && id == slot.item_id x -= 1 slot = @limit_inventory.slots[x] end l_item, l_n = @limit_inventory.slots[x + 1].item, @limit_inventory.slots[x + 1].amount break end end gain_proses(l_item, -1*l_n) $game_temp.slots_to_discard.add_item (l_type, id, l_n) n3 = @limit_inventory.add_item (type, item.id, n2) n -= n3 n2 = n3 end end else n2 = @limit_inventory.remove_item (type, item.id, -1*n) n += n2 n2 *= -1 end end return if item == nil if n2 > 0 $game_temp.slots_to_discard.add_item (type, item.id, n2) elsif n2 < 0 $game_temp.slots_to_discard.remove_item (type, item.id, -1*n2) end end end
#============================================================================== # ** Interpreter #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # Summary of Changes: # aliased method - command end # new method - resize_inventory #============================================================================== class Interpreter #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Resize Inventory (change inventory size) # new_size >> Number #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def resize_inventory (new_size) $game_party.limit_inventory.resize (new_size) end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Command End # If there are items in $game_temp, open up the loot management #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias new_command_end command_end def command_end new_command_end unless $game_temp.slots_to_discard.slots.empty? $scene = Scene_Loot.new end end end
#============================================================================== # ** Scene Equip #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # Summary of Changes: # aliased method - main #============================================================================== class Scene_Equip #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Main #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias new_main main def main new_main $scene = Scene_Loot.new if !$game_temp.slots_to_discard.slots.empty? end end
#============================================================================== # ** Scene Battle #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # Summary of Changes: # aliased method - battle_end #============================================================================== class Scene_Battle #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * battle_end # open up loot management if inventory is full in the end of battle #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias new_battle_end battle_end def battle_end(result) new_battle_end (result) if !$game_temp.slots_to_discard.slots.empty? && !$scene.is_a? (Scene_Gameover) $scene = Scene_Loot.new end end end
#============================================================================== # ** Game LimInvSlot #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # This class holds the data on a single slot of the inventory #============================================================================== class Game_LimInvSlot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Public Instance Variables #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ attr_reader :item_type attr_reader :item_id attr_reader :amount #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Object Initialization #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def initialize @item_type = -1 @item_id = 0 @amount = 0 end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Add Item # n >> the amount to add # item_type >> the type of item being added # item_id >> the ID of item being added #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def add_item (n, item_type = -1, item_id = 0) if item_type != -1 @item_type = item_type @item_id = item_id end x = space_left if n > x @amount += x return n - x else @amount += n return 0 end end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Remove Item # n >> the amount to remove #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def remove_item (n) @amount -= n if @amount <= 0 n = -1*@amount @item_type = -1 @item_id = 0 @amount = 0 return n end return 0 end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Item #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def item return case @item_type when -1 then nil when 0 then $data_items[@item_id] when 1 then $data_weapons[@item_id] when 2 then $data_armors[@item_id] end end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Space Left #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def space_left return 1 if item == nil return RUSTED_ITEM::DEFAULT_ITEM_STACK - @amount if item.is_a?(RPG::Item) return 1 - @amount end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Equal? # other : another Game_LimInvSlot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def == (other) return false if !other.is_a? (Game_LimInvSlot) return false if other.item_type != @item_type return false if other.item_id != @item_id return false if other.amount != @amount return super (other) end end
#============================================================================== # ** Game_LimitedInventory #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # This is an array to store the party's inventory #============================================================================== class Game_LimitedInventory #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Public Instance Variable #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ attr_reader :max_size #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Object Initialization # size : the number of slots available #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def initialize (size) @max_size = size clear end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Clear #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def clear @items = [] @weapons = [] @armors = [] end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Resize # size : the number of slots available #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def resize (size) old_size = slots.size if size < old_size index = slots.size - 1 while slots.size > size slot = slots[index] if !RUSTED_ITEM::NONDISCARD[slot.item_type].include?(slot.item_id) type, id, n = slot.item_type, slot.item_id, slot.amount remove_item (type, id, n) $game_temp.slots_to_discard.add_item (type, id, n) index -= 1 else index -= 1 end break if index < 0 end end @max_size = size end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Add Item # type : the type of item being added # id : the ID of item being added # n : the amount to add #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def add_item (type, id, n = 1) array = case type when 0 then @items when 1 then @weapons when 2 then @armors end sort_index = 0 array.each { |slot| if slot.item_id == id n = slot.add_item (n, type, id) break if n == 0 sort_index += 1 elsif slot.item_id < id sort_index += 1 else break end } if n > 0 while @max_size == -1 || ((@items.size + @weapons.size + @armors.size) < @max_size) slot = Game_LimInvSlot.new n = slot.add_item (n, type, id) array.insert (sort_index, slot) sort_index += 1 break if n == 0 end end return n end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Remove Item # type : the type of item being removed # id : the ID of item being removed # n : the amount to remove #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def remove_item (type, id, n = 1) array = case type when 0 then @items when 1 then @weapons when 2 then @armors end array.reverse.each { |slot| if slot.item_type == type && slot.item_id == id n = slot.remove_item (n) array.delete (slot) if slot.amount == 0 break if n == 0 end } return n end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Slots # get all slot in the inventory #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def slots return @items + @weapons + @armors end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * slot # get slot for the certain item #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def slot(item) array = @items array = @weapons if item.is_a?(RPG::Weapon) array = @armors if item.is_a?(RPG::Armor) for i in 0... array.size slot = array[i] break if slot.item_id == item.id end return slot end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Check Space # slot : an Game_InvSlot object #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def enough_space? (slot) return true if @max_size == -1 || slots.size < @max_size array = [@items, @weapons, @armors][slot.item_type] array.each { |i| if i.item_id > slot.item_id break elsif i.item_id == slot.item_id x = slot.item.is_a?(RPG::Item) ? RUSTED_ITEM::DEFAULT_ITEM_STACK : 1 break if i.space_left == 0 return true if i.space_left < x end } return false end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Equals? #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def == (other) return false unless other.is_a? (Game_LimitedInventory) return false if @max_size != other.max_size return false if slots != other.slots return super (other) end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Cek Amount # cek amount of an item in the inventory #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def cek_amount(type, id) array = case type when 0 then @items when 1 then @weapons when 2 then @armors end n = 0 array.each { |slot| if slot.item_id == id n += slot.amount end } return n end end
#============================================================================== # ** Window Item #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # Summary of Changes: # overwritten methods - initialize, item, refresh, draw_text # new method - inventory #============================================================================== class Window_Item < Window_Selectable #-------------------------------------------------------------------------- # * Object Initialization # inventory >> an Game_LimitedInventory object #-------------------------------------------------------------------------- def initialize(inventory = $game_party.limit_inventory) super(0, 128, 320, 352) @column_max = 1 @inventory = inventory refresh self.index = 0 if $game_temp.in_battle self.y = 64 self.height = 256 self.back_opacity = 160 end end #-------------------------------------------------------------------------- # * Get Inventory #-------------------------------------------------------------------------- def inventory return @inventory end #-------------------------------------------------------------------------- # * Get Item #-------------------------------------------------------------------------- def item return nil if @data[self.index] == nil return @data[self.index].item end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] # Add item for slot in @inventory.slots next if slot.item == nil @data.push(slot) end # If item count is not 0, make a bit map and draw all items @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) for i in 0...@item_max draw_item(i) end end end #-------------------------------------------------------------------------- # * Draw Item # index : item number #-------------------------------------------------------------------------- def draw_item(index) return if @data[index] == nil item = @data[index].item number = @data[index].amount if item.is_a?(RPG::Item) and $game_party.item_can_use?(item.id) self.contents.font.color = normal_color else self.contents.font.color = disabled_color end self.contents.font.color = normal_color if @inventory == $game_temp.slots_to_discard x = 4 y = index * 32 rect = Rect.new(x, y, self.width / @column_max - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(item.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) self.contents.draw_text(x + 240, y, 16, 32, ":", 1) if item.is_a?(RPG::Item) self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2) if item.is_a?(RPG::Item) end end
#============================================================================== # ** Window Item Count #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # Class for title of the inventory #============================================================================== class Window_Item_Count < Window_Base #-------------------------------------------------------------------------- # * Object Initialization # inventory >> an Game_LimitedInventory object #-------------------------------------------------------------------------- def initialize(inventory) super(0, 64, 320, 64) @inventory = inventory self.x = 320 if inventory == $game_temp.slots_to_discard self.contents = Bitmap.new(width - 32, height - 32) refresh end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear width = self.contents.width if @inventory == $game_party.limit_inventory self.contents.draw_text(0,0,width,32,RUSTED_ITEM::PARTY_INV) self.contents.draw_text(0,0,width,32,@inventory.slots.size.to_s + " / " + @inventory.max_size.to_s,2) else self.contents.draw_text(0,0,width,32,RUSTED_ITEM::LOOT_INV) end end end
#============================================================================== # ** Window Item Target #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # Class for target window in the Scene_Item #============================================================================== class Window_Item_Target < Window_Selectable #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(320, 64, 320, 416) self.contents = Bitmap.new(width - 32, height - 32) self.z += 10 @item_max = $game_party.actors.size refresh self.index = -2 end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear for i in 0...$game_party.actors.size x = 4 y = i * 96 actor = $game_party.actors[i] draw_actor_name(actor, x, y) draw_actor_class(actor, x + 144, y) draw_actor_level(actor, x + 8, y + 32) draw_actor_state(actor, x + 8, y + 64) draw_actor_hp(actor, x + 144, y + 32) draw_actor_sp(actor, x + 144, y + 64) end end #-------------------------------------------------------------------------- # * Update Cursor Rect #-------------------------------------------------------------------------- def update_cursor_rect if @index <= -2 self.cursor_rect.set(0, (@index + 10) * 116, self.width - 28, 96) elsif @index == -1 self.cursor_rect.set(0, 0, self.width - 28, @item_max * 96) else self.cursor_rect.set(0, @index * 96, self.width - 28, 96) end end end
#============================================================================== # ** Scene_Item #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # A new Scene_Item #============================================================================== class Scene_Item #-------------------------------------------------------------------------- # * Main Processing #-------------------------------------------------------------------------- def main @help_window = Window_Help.new @item_window = Window_Item.new @item_window.help_window = @help_window @target_window = Window_Item_Target.new @target_window.visible = true @target_window.active = false @mount_window = Window_Item_Count.new($game_party.limit_inventory) @inv_com_window = Window_Command.new(96,[RUSTED_ITEM::USE_COM,RUSTED_ITEM::DIS_COM]) @inv_com_window.x = 200 @inv_com_window.active = false @inv_com_window.visible = false Graphics.transition loop do Graphics.update Input.update update if $scene != self break end end Graphics.freeze @help_window.dispose @inv_com_window.dispose @item_window.dispose @target_window.dispose @mount_window.dispose end #-------------------------------------------------------------------------- # * Update Frame #-------------------------------------------------------------------------- def update @mount_window.update @inv_com_window.update @help_window.update @item_window.update @target_window.update if @item_window.active update_item return end if @inv_com_window.active update_command return end if @target_window.active update_target return end end #-------------------------------------------------------------------------- # * Update Item Window #-------------------------------------------------------------------------- def update_item if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) $scene = Scene_Menu.new(0) return end if Input.trigger?(Input::C) @item = @item_window.item if @item != nil @item_window.active = false @inv_com_window.active = true @inv_com_window.visible = true @inv_com_window.y = 160 + @item_window.index * 32 else $game_system.se_play($data_system.buzzer_se) end return end end #-------------------------------------------------------------------------- # * Update Command Window #-------------------------------------------------------------------------- def update_command if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @item_window.active = true @inv_com_window.active = false @inv_com_window.visible = false return end if Input.trigger?(Input::C) case @inv_com_window.index when 0 then use_item when 1 then discard_item end @inv_com_window.index = 0 return end end #-------------------------------------------------------------------------- # * Discard Item Processing #-------------------------------------------------------------------------- def discard_item $game_system.se_play($data_system.decision_se) slot = @item_window.inventory.slot(@item) type, id, n = slot.item_type, slot.item_id, slot.amount $game_party.reduce_item(@item, n) $game_party.limit_inventory.remove_item (type, id, n) @item_window.refresh @mount_window.refresh @item_window.active = true @item_window.index -= 1 if @item_window.index != 0 @inv_com_window.active = false @inv_com_window.visible = false end #-------------------------------------------------------------------------- # * Use Item Processing #-------------------------------------------------------------------------- def use_item unless @item.is_a?(RPG::Item) $game_system.se_play($data_system.buzzer_se) return end unless $game_party.item_can_use?(@item.id) $game_system.se_play($data_system.buzzer_se) return end $game_system.se_play($data_system.decision_se) if @item.scope >= 3 @inv_com_window.active = false @inv_com_window.visible = false @target_window.visible = true @target_window.active = true if @item.scope == 4 || @item.scope == 6 @target_window.index = -1 else @target_window.index = 0 end else if @item.common_event_id > 0 $game_temp.common_event_id = @item.common_event_id $game_system.se_play(@item.menu_se) if @item.consumable $game_party.lose_item(@item.id, 1) @item_window.draw_item(@item_window.index) end $scene = Scene_Map.new return end end end end #============================================================================== # ** Scene_Loot #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # Loot management scene #============================================================================== class Scene_Loot #-------------------------------------------------------------------------- # * MainProcessing #-------------------------------------------------------------------------- def main @help_window = Window_Help.new @item_window = Window_Item.new @item_window.help_window = @help_window @loot_window = Window_Item.new($game_temp.slots_to_discard) @loot_window.active = false @loot_window.x = 320 @loot_window.help_window = @help_window @party_item_window = Window_Item_Count.new($game_party.limit_inventory) @loot_item_window = Window_Item_Count.new($game_temp.slots_to_discard) @loot_item_window.x = 320 Graphics.transition loop do Graphics.update Input.update update if $scene != self break end end Graphics.freeze @help_window.dispose @item_window.dispose @loot_window.dispose @party_item_window.dispose @loot_item_window.dispose end #-------------------------------------------------------------------------- # * update Frame #-------------------------------------------------------------------------- def update @help_window.update @item_window.update @loot_window.update @party_item_window.update @loot_item_window.update if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) if !$game_temp.slots_to_discard.slots.empty? $game_temp.slots_to_discard.slots.each { |slot| $game_party.reduce_item(slot.item, slot.amount) } $game_temp.slots_to_discard.clear end $scene = Scene_Map.new return end if @item_window.active update_item return end if @loot_window.active update_loot return end end #-------------------------------------------------------------------------- # * Update Item Window #-------------------------------------------------------------------------- def update_item if Input.trigger?(Input::C) item = @item_window.item slot = @item_window.inventory.slot(item) type, id, n = slot.item_type, slot.item_id, slot.amount if !RUSTED_ITEM::NONDISCARD[type].include?(item.id) $game_system.se_play($data_system.decision_se) $game_party.limit_inventory.remove_item (type, id, n) $game_temp.slots_to_discard.add_item(type, id, n) else $game_system.se_play($data_system.buzzer_se) end refresh return end if Input.repeat?(Input::RIGHT) @item_window.active = false @loot_window.active = true @loot_window.index = 0 @item_window.index = -1 return end end #-------------------------------------------------------------------------- # * Update Loot Window #-------------------------------------------------------------------------- def update_loot if Input.trigger?(Input::C) item = @loot_window.item slot = @loot_window.inventory.slot(item) type, id, n = slot.item_type, slot.item_id, slot.amount if @item_window.inventory.enough_space? (slot) $game_system.se_play($data_system.decision_se) $game_party.gain_item (item, n) $game_party.reduce_item(item, n) $game_temp.slots_to_discard.remove_item(type, id, n) else $game_system.se_play($data_system.buzzer_se) end refresh return end if Input.repeat?(Input::LEFT) @item_window.active = true @loot_window.active = false @loot_window.index = -1 @item_window.index = 0 return end end #-------------------------------------------------------------------------- # * Refresh Window #-------------------------------------------------------------------------- def refresh @item_window.refresh @loot_window.refresh @party_item_window.refresh end end
Credits
- rusted_71
- modern algebra for limited inventory VX
- Jangan lupa comment ya, klo ada bug atau saran langsung post aja di sini
Terakhir diubah oleh rusted_71 tanggal 2010-07-26, 01:42, total 1 kali diubah (Reason for editing : tambahin link nya kk) |
| | | 2010-07-26, 10:48 | Re: LIMITED INVENTORY SYSTEM |
---|
Chapoenk Newbie
Posts : 34 Thanked : 0 Engine : RMVX Skill : Very Beginner Type : Event Designer
| Ijin DL yah kk Rusted.. Nih script pasangannya inventory system nih. Jadi kan bank inventory kepake deh~ Buat project saya gpp kan kk? Nanti saya credit. Thanks |
| | | 2010-07-26, 11:40 | Re: LIMITED INVENTORY SYSTEM |
---|
AbDoel_Ok Newbie
Posts : 17 Thanked : 0 Engine : RMVX Skill : Intermediate Type : Event Designer
| hm.... bagus juga , ini untuk VX ya...??, btw, ini skript gampang gk di modifikasi, saya masih belajar bahasa ruby... hehehe... |
| | | 2010-07-26, 13:12 | Re: LIMITED INVENTORY SYSTEM |
---|
rusted_71 Scripter Karatan
Posts : 392 Thanked : 11 Engine : RMVX Skill : Beginner Type : Scripter
| @Chapoenk: mang gw bikin ini system biar item bank system bisa ke pake, ga seru kan ada item bank tapi party bisa bawa item ga terbatas... @Abdoel: sayangnya neh buat XP... kan gw post di subforum RMXP Script |
| | | 2011-01-29, 12:03 | Re: LIMITED INVENTORY SYSTEM |
---|
junogan Newbie
Posts : 37 Thanked : 0 Engine : RMVX Skill : Beginner Type : Scripter
| | | | | Re: LIMITED INVENTORY SYSTEM |
---|
Sponsored content
| | | | Similar topics | |
|
Similar topics | |
| |
Halaman 1 dari 1 | |
| Permissions in this forum: | Anda tidak dapat menjawab topik
| |
| |
Latest 10 Topics | [Web Novel] Gloria Infidelis 2016-11-17, 21:27 by LightNightKnight
[Announcement] Forum baru untuk RMID 2016-08-25, 16:39 by TheoAllen
Where I'm Wrong ? 2016-07-24, 16:10 by ReydVires
flakeheartnet's Resources part III 2016-07-08, 14:30 by flakeheartnet
Keira's Art Warehouse 2016-06-28, 19:27 by KeiraBlaze
Theo Core Time System + Bingung 2016-06-27, 16:24 by Lockin
Error Script, Maybe ? 2016-06-27, 16:20 by Lockin
Nusaimoe @ RMID Lounge 2016-06-21, 05:02 by Jihad Bagas
Call Random Battle 2016-06-15, 17:04 by Lockin
Flakeheartnet Resources Part II [come back gift] 2016-06-07, 15:51 by flakeheartnet
|
Statistics
|
Members: [ 4947 ]
Topics: [ 8258 ]
Posts: [ 112606 ]
Newest member: [ https://rmid.forumotion.net/u4968 ]
|
|
|
|
|
|