查看: 2063|回复: 4

[已经解决] 想把人物仓库改成武器仓库,改到一半不会改了,求助!

[复制链接]
梦石
0
星屑
50
在线时间
200 小时
注册时间
2008-3-1
回帖
258
发表于 2014-9-12 12:51:37 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
chaochao的人物仓库,想自己改成武器仓库,现在做到左半窗口显示武器,选中按下确定武器失去,但是右半边窗口不知道怎么做,怎么让确认存放的武器转到右半窗口??

这是工程:
Project2.rar (187.95 KB, 下载次数: 38)


211.JPG

评分

参与人数 1星屑 +35 收起 理由
︶ㄣ牛排ぶ + 35 手动认可奖励

查看全部评分

炎

梦石
0
星屑
98
在线时间
1617 小时
注册时间
2013-8-15
回帖
4322
发表于 2014-9-12 14:05:42 | 显示全部楼层
神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦神烦
回复

使用道具 举报

梦石
0
星屑
50
在线时间
200 小时
注册时间
2008-3-1
回帖
258
 楼主| 发表于 2014-9-12 15:06:34 | 显示全部楼层
永燃的狂炎 发表于 2014-9-12 14:05
物品仓库不行吗?https://rpg.blue/forum.php?mod=viewthread&tid=365060&highlight=仓库

不需要物品仓库,我只希望左窗口失去的武器能出现在右窗口上
回复

使用道具 举报

梦石
0
星屑
9557
在线时间
5074 小时
注册时间
2013-6-21
回帖
3459

开拓者贵宾剧作品鉴家

发表于 2014-9-12 16:51:24 | 显示全部楼层
本帖最后由 RyanBern 于 2014-9-12 16:52 编辑

简单地弄了下,一定要设置“武器仓库”的存储结构。
对于武器仓库来说,也有单个武器上限99的限制。这个要注意。
有什么BUG通知我,URL什么的别忘了去掉。
[pre lang="Ruby"]class Game_Party
  alias rb_initialize initialize
  def initialize
    @weapon_storage = {}
    rb_initialize
  end
  def storage_import(item_id, number)
    @weapon_storage[item_id] = 0 if @weapon_storage[item_id].nil?
    current = @weapon_storage[item_id]
    @weapon_storage[item_id] = [number + current, 99].min
  end
  def storage_export(item_id, number)
    @weapon_storage[item_id] = 0 if @weapon_storage[item_id].nil?
    current = @weapon_storage[item_id]
    @weapon_storage[item_id] = [current - number, 0].max
  end
  def storage_number(item_id)
    @weapon_storage[item_id].nil? ? 0 : @weapon_storage[item_id]
  end
  def storage_full?(item_id)
    @weapon_storage[item_id] == 99
  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)
      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]
    number = $game_party.weapon_number(item.id)
    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
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) > 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]
    number = $game_party.storage_number(item.id)
    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
end

class Commitem_Scene_Party
  def main
    @left_temp_command = 0
    @right_temp_command = 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)
      id = @left_window.item.id
      if $game_party.weapon_number(id) > 0 && !$game_party.storage_full?(id)
        $game_system.se_play($data_system.decision_se)
        $game_party.lose_weapon(id, 1)
        $game_party.storage_import(id, 1)
        @left_window.refresh
        @right_window.refresh
      else
        $game_system.se_play($data_system.buzzer_se)
      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)
      id = @right_window.item.id
      if $game_party.weapon_number(id) < 99 && $game_party.storage_number(id) > 0
        $game_system.se_play($data_system.decision_se)
        $game_party.gain_weapon(id, 1)
        $game_party.storage_export(id, 1)
        @left_window.refresh
        @right_window.refresh
      else
        $game_system.se_play($data_system.buzzer_se)
      end
      return
    end
  end  
end[/pre]

评分

参与人数 1梦石 +1 收起 理由
︶ㄣ牛排ぶ + 1 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
50
在线时间
200 小时
注册时间
2008-3-1
回帖
258
 楼主| 发表于 2014-9-12 20:42:48 | 显示全部楼层
本帖最后由 木许许 于 2014-9-12 20:50 编辑
RyanBern 发表于 2014-9-12 16:51
简单地弄了下,一定要设置“武器仓库”的存储结构。
对于武器仓库来说,也有单个武器上限99的限制。这个要 ...


太感谢了,如果我想仓库的空间最大只能放三种武器,并且这三件的数据库编号分别代入$w1,$w2,$w3,应该怎么改?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部