本帖最后由 木许许 于 2014-9-22 11:27 编辑 前几天版主帮忙把人物仓库修改成武器仓库的脚本希望可以再次修改成可以同时存取武器和防具的仓库,改了一半,发现的当存进一件武器,连相同编号的防具也一起存进去了 ...
class Game_Party alias rb_initialize initialize def initialize @weapon_storage = {} @armor_storage = {} rb_initialize end def storage_import(item_id, number, type) case type when 1 @weapon_storage[item_id] = 0 if @weapon_storage[item_id].nil? current = @weapon_storage[item_id] @weapon_storage[item_id] = [number + current, 99].min when 2 @armor_storage[item_id] = 0 if @armor_storage[item_id].nil? current = @armor_storage[item_id] @armor_storage[item_id] = [number + current, 99].min end end def storage_export(item_id, number, type) case type when 1 @weapon_storage[item_id] = 0 if @weapon_storage[item_id].nil? current = @weapon_storage[item_id] @weapon_storage[item_id] = [current - number, 0].max when 2 @armor_storage[item_id] = 0 if @armor_storage[item_id].nil? current = @armor_storage[item_id] @armor_storage[item_id] = [current - number, 0].max end end def storage_number(item_id, type) case type when 1 @weapon_storage[item_id].nil? ? 0 : @weapon_storage[item_id] when 2 @armor_storage[item_id].nil? ? 0 : @armor_storage[item_id] end end def storage_full?(item_id, type) case type when 1 @weapon_storage[item_id] == 99 when 2 @armor_storage[item_id] == 99 end endend class Commitem_Window_PartyLeft < Window_Selectable def initialize super(0, 64, 320, 324) self.index = 0 refresh end def item return @data[self.index] end def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] for i in 1..$data_weapons.size #武器 if $game_party.weapon_number(i) > 0 @data.push($data_weapons[i]) end end for i in 1..$data_armors.size # 防具 if $game_party.armor_number(i) > 0 @data.push($data_armors[i]) end end @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, @item_max * 32) for i in 0...@item_max draw_item(i) end end end def draw_item(index) item = @data[index] case item when RPG::Weapon number = $game_party.weapon_number(item.id) when RPG::Armor number = $game_party.armor_number(item.id) end self.contents.font.color = normal_color x = 4 y = index * 32 rect = Rect.new(x,y,self.width - 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) self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2) end def item_type case self.item when RPG::Weapon return 1 when RPG::Armor return 2 end endend class Commitem_Window_PartyRight < Window_Selectable def initialize super(320, 64, 320, 324) self.index = -1 refresh end def item return @data[self.index] end def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] $data_weapons.each do |weapon| next if weapon.nil? @data.push(weapon) if $game_party.storage_number(weapon.id, 1) > 0 end $data_armors.each do |armor| next if armor.nil? @data.push(armor) if $game_party.storage_number(armor.id, 2) > 0 end @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, @item_max * 32) for i in 0...@item_max draw_item(i) end end end def draw_item(index) item = @data[index] case item when RPG::Weapon number = $game_party.storage_number(item.id, 1) when RPG::Armor number = $game_party.storage_number(item.id, 2) end self.contents.font.color = normal_color x = 4 y = index * 32 rect = Rect.new(x,y,self.width - 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) self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2) end def item_type case self.item when RPG::Weapon return 1 when RPG::Armor return 2 end endend class Commitem_Scene_Party def main @left_temp_command = 0 @right_temp_command = 0 [url=home.php?mod=space&uid=263426]@temp[/url] = 0 @left_window = Commitem_Window_PartyLeft.new @left_window.active = true @right_window = Commitem_Window_PartyRight.new @right_window.active = false @base = Window_Base.new(0, 0, 640, 64) @base.contents = Bitmap.new(@base.width - 32, @base.height - 32) @base.contents.draw_text(4, 0, @base.width - 40, 32, "装备仓库", 1) Graphics.transition loop do Graphics.update Input.update update if $scene != self break end end Graphics.freeze @left_window.dispose @right_window.dispose @base.dispose end def update @left_window.update @right_window.update update_command end def update_command if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) $scene = Scene_Map.new return end if @left_window.active update_left return end if @right_window.active update_right return end end def update_left if Input.trigger?(Input::RIGHT) @left_temp_command = @left_window.index @left_window.index = -1 $game_system.se_play($data_system.cursor_se) @left_window.active = false @right_window.active = true @right_window.index = @right_temp_command return end if Input.trigger?(Input::C) if @left_window.item == nil $game_system.se_play($data_system.buzzer_se) return end id = @left_window.item.id case @left_window.item_type when 1 if $game_party.weapon_number(id) > 0 && !$game_party.storage_full?(id, 1) $game_system.se_play($data_system.decision_se) $game_party.lose_weapon(id, 1) $game_party.storage_import(id, 1, 1) @left_window.refresh @right_window.refresh else $game_system.se_play($data_system.buzzer_se) end when 2 if $game_party.armor_number(id) > 0 && !$game_party.storage_full?(id, 2) $game_system.se_play($data_system.decision_se) $game_party.lose_armor(id, 1) $game_party.storage_import(id, 1, 2) @left_window.refresh @right_window.refresh else $game_system.se_play($data_system.buzzer_se) end end return end end def update_right if Input.trigger?(Input::LEFT) @right_temp_command = @right_window.index @right_window.index = -1 $game_system.se_play($data_system.cursor_se) @left_window.active = true @right_window.active = false @left_window.index = @left_temp_command return end if Input.trigger?(Input::C) if @right_window.item == nil $game_system.se_play($data_system.buzzer_se) return end id = @right_window.item.id case @right_window.item_type when 1 if $game_party.weapon_number(id) < 99 && $game_party.storage_number(id, 1) > 0 $game_system.se_play($data_system.decision_se) $game_party.gain_weapon(id, 1) $game_party.storage_export(id, 1, 1) @left_window.refresh @right_window.refresh else $game_system.se_play($data_system.buzzer_se) end when 2 if $game_party.armor_number(id) < 99 && $game_party.storage_number(id, 2) > 0 $game_system.se_play($data_system.decision_se) $game_party.gain_armor(id, 1) $game_party.storage_export(id, 1, 2) @left_window.refresh @right_window.refresh else $game_system.se_play($data_system.buzzer_se) end end return end endend
class Game_Party alias rb_initialize initialize def initialize @weapon_storage = {} @armor_storage = {} rb_initialize end def storage_import(item_id, number, type) case type when 1 @weapon_storage[item_id] = 0 if @weapon_storage[item_id].nil? current = @weapon_storage[item_id] @weapon_storage[item_id] = [number + current, 99].min when 2 @armor_storage[item_id] = 0 if @armor_storage[item_id].nil? current = @armor_storage[item_id] @armor_storage[item_id] = [number + current, 99].min end end def storage_export(item_id, number, type) case type when 1 @weapon_storage[item_id] = 0 if @weapon_storage[item_id].nil? current = @weapon_storage[item_id] @weapon_storage[item_id] = [current - number, 0].max when 2 @armor_storage[item_id] = 0 if @armor_storage[item_id].nil? current = @armor_storage[item_id] @armor_storage[item_id] = [current - number, 0].max end end def storage_number(item_id, type) case type when 1 @weapon_storage[item_id].nil? ? 0 : @weapon_storage[item_id] when 2 @armor_storage[item_id].nil? ? 0 : @armor_storage[item_id] end end def storage_full?(item_id, type) case type when 1 @weapon_storage[item_id] == 99 when 2 @armor_storage[item_id] == 99 end end end class Commitem_Window_PartyLeft < Window_Selectable def initialize super(0, 64, 320, 324) self.index = 0 refresh end def item return @data[self.index] end def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] for i in 1..$data_weapons.size #武器 if $game_party.weapon_number(i) > 0 @data.push($data_weapons[i]) end end for i in 1..$data_armors.size # 防具 if $game_party.armor_number(i) > 0 @data.push($data_armors[i]) end end @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, @item_max * 32) for i in 0...@item_max draw_item(i) end end end def draw_item(index) item = @data[index] case item when RPG::Weapon number = $game_party.weapon_number(item.id) when RPG::Armor number = $game_party.armor_number(item.id) end self.contents.font.color = normal_color x = 4 y = index * 32 rect = Rect.new(x,y,self.width - 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) self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2) end def item_type case self.item when RPG::Weapon return 1 when RPG::Armor return 2 end end end class Commitem_Window_PartyRight < Window_Selectable def initialize super(320, 64, 320, 324) self.index = -1 refresh end def item return @data[self.index] end def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] $data_weapons.each do |weapon| next if weapon.nil? @data.push(weapon) if $game_party.storage_number(weapon.id, 1) > 0 end $data_armors.each do |armor| next if armor.nil? @data.push(armor) if $game_party.storage_number(armor.id, 2) > 0 end @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, @item_max * 32) for i in 0...@item_max draw_item(i) end end end def draw_item(index) item = @data[index] case item when RPG::Weapon number = $game_party.storage_number(item.id, 1) when RPG::Armor number = $game_party.storage_number(item.id, 2) end self.contents.font.color = normal_color x = 4 y = index * 32 rect = Rect.new(x,y,self.width - 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) self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2) end def item_type case self.item when RPG::Weapon return 1 when RPG::Armor return 2 end end end class Commitem_Scene_Party def main @left_temp_command = 0 @right_temp_command = 0 [url=home.php?mod=space&uid=263426]@temp[/url] = 0 @left_window = Commitem_Window_PartyLeft.new @left_window.active = true @right_window = Commitem_Window_PartyRight.new @right_window.active = false @base = Window_Base.new(0, 0, 640, 64) @base.contents = Bitmap.new(@base.width - 32, @base.height - 32) @base.contents.draw_text(4, 0, @base.width - 40, 32, "装备仓库", 1) Graphics.transition loop do Graphics.update Input.update update if $scene != self break end end Graphics.freeze @left_window.dispose @right_window.dispose @base.dispose end def update @left_window.update @right_window.update update_command end def update_command if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) $scene = Scene_Map.new return end if @left_window.active update_left return end if @right_window.active update_right return end end def update_left if Input.trigger?(Input::RIGHT) @left_temp_command = @left_window.index @left_window.index = -1 $game_system.se_play($data_system.cursor_se) @left_window.active = false @right_window.active = true @right_window.index = @right_temp_command return end if Input.trigger?(Input::C) if @left_window.item == nil $game_system.se_play($data_system.buzzer_se) return end id = @left_window.item.id case @left_window.item_type when 1 if $game_party.weapon_number(id) > 0 && !$game_party.storage_full?(id, 1) $game_system.se_play($data_system.decision_se) $game_party.lose_weapon(id, 1) $game_party.storage_import(id, 1, 1) @left_window.refresh @right_window.refresh else $game_system.se_play($data_system.buzzer_se) end when 2 if $game_party.armor_number(id) > 0 && !$game_party.storage_full?(id, 2) $game_system.se_play($data_system.decision_se) $game_party.lose_armor(id, 1) $game_party.storage_import(id, 1, 2) @left_window.refresh @right_window.refresh else $game_system.se_play($data_system.buzzer_se) end end return end end def update_right if Input.trigger?(Input::LEFT) @right_temp_command = @right_window.index @right_window.index = -1 $game_system.se_play($data_system.cursor_se) @left_window.active = true @right_window.active = false @left_window.index = @left_temp_command return end if Input.trigger?(Input::C) if @right_window.item == nil $game_system.se_play($data_system.buzzer_se) return end id = @right_window.item.id case @right_window.item_type when 1 if $game_party.weapon_number(id) < 99 && $game_party.storage_number(id, 1) > 0 $game_system.se_play($data_system.decision_se) $game_party.gain_weapon(id, 1) $game_party.storage_export(id, 1, 1) @left_window.refresh @right_window.refresh else $game_system.se_play($data_system.buzzer_se) end when 2 if $game_party.armor_number(id) < 99 && $game_party.storage_number(id, 2) > 0 $game_system.se_play($data_system.decision_se) $game_party.gain_armor(id, 1) $game_party.storage_export(id, 1, 2) @left_window.refresh @right_window.refresh else $game_system.se_play($data_system.buzzer_se) end end return end end end
查看全部评分
折叠内容标题(非必须)
折叠内容
站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作
GMT+8, 2024-11-27 11:45
Powered by Discuz! X3.1
© 2001-2013 Comsenz Inc.