设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 411|回复: 1
打印 上一主题 下一主题

[有事请教] 请问:仓库脚本如何设置才能显示0

[复制链接]

Lv3.寻梦者

梦石
0
星屑
3925
在线时间
254 小时
注册时间
2013-10-13
帖子
790
跳转到指定楼层
1
发表于 2023-11-13 21:31:19 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
class Scene_Ck
  def main
    # 生成帮助窗口、物品窗口
    @help_window = Window_Help.new
    @ck_item_window = Ck_Window_Item.new
    @ch_item_window = Ch_Window_Item.new
    # 关联帮助窗口
    @ck_item_window.help_window = @help_window
    # 生成命令窗口
    s1 = "取出"
    s2 = "存入"
    s3 = "取消"
    @command_window = Window_Command.new(192, [s1,s2,s3])
    @command_window.x = 0
    @command_window.y = 480-128
    # 执行过渡
    Graphics.transition
    # 主循环
    loop do
      # 刷新游戏画面
      Graphics.update
      # 刷新输入信息
      Input.update
      # 刷新画面
      update
      # 如果画面被切换就中断循环
      if $scene != self
        break
      end
    end
    # 装备过渡
    Graphics.freeze
    @ck_item_window.dispose
    @ch_item_window.dispose
    @help_window.dispose
    @command_window.dispose
  end
  def update
    @command_window.update
    @ck_item_window.update
    @ch_item_window.update

    if @command_window.active   #命令窗口界面
      command_update
      return
    end
    if @ck_item_window.active  #仓库界面

      ck_update
      return
    end

    if @ch_item_window.active #角色背包界面
      ch_update
      return
    end
  end
  def command_update
    @ck_item_window.active=false
    @ch_item_window.active=false
    if Input.trigger?(Input::B)
      $scene=Scene_Map.new
    end
    if Input.trigger?(Input::C)
      case @command_window.index
      when 0
        @command_window.active=false
        @ch_item_window.active=false
        @ck_item_window.active=true
        return
      when 1
        @command_window.active=false
        @ch_item_window.active=true
        @ck_item_window.active=false
        return
      when 2
        $scene=Scene_Map.new
        return
      end
    end
  end
  def ck_update
      if Input.trigger?(Input::B)
        @command_window.active=true
        @ch_item_window.active=false
        @ck_item_window.active=false
        return
      end
      if Input.trigger?(Input::C)
        @tmp=@ck_item_window.item.id
        if $game_party.item_number(@ck_item_window.item.id)>0
#p   $game_party
          $game_party.lose_item(@ck_item_window.item.id,1)
#p   $game_party
#p   @ck_item_window.item.id
          @ck_item_window.refresh
#p   @ck_item_window.item.id
        else
          return
        end
        $game_party.gain_item_1(@tmp,1)
        @ch_item_window.refresh
      end
  end
  def ch_update
      if Input.trigger?(Input::B)
        @command_window.active=true
        @ch_item_window.active=false
        @ck_item_window.active=false
        return
      end
      if Input.trigger?(Input::C)
        @tmp_1=@ch_item_window.item.id
        if $game_party.item_number_1(@ch_item_window.item.id)>0
          $game_party.lose_item_1(@ch_item_window.item.id,1)
          @ch_item_window.refresh
        else
          return
        end
          $game_party.gain_item(@tmp_1,1)
          @ck_item_window.refresh
      end
  end
end

class Ch_Window_Item < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #--------------------------------------------------------------------------
  def initialize
    super(320, 64, 320, 416-64)
    @column_max = 1
    refresh
    self.index = 0
    # 战斗中的情况下将窗口移至中央并将其半透明化
    if $game_temp.in_battle
      self.y = 64
      self.height = 256
      self.back_opacity = 160
    end
  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_items.size
      if $game_party.item_number_1(i) > 0
        @data.push($data_items[i])
      end
    end
    # 如果项目数不是 0 就生成位图、重新描绘全部项目
    @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
  #--------------------------------------------------------------------------
  # ● 描绘项目
  #     index : 项目编号
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item
      number = $game_party.item_number_1(item.id)
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    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
    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)
    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  end
  

  #--------------------------------------------------------------------------
  # ● 更新光标矩形
  #--------------------------------------------------------------------------
  def update_cursor_rect
    # 光标位置不满 0 的情况下
    if @index < 0
      self.cursor_rect.empty
      return
    end
    # 获取当前的行
    row = @index / @column_max
    # 当前行被显示开头行前面的情况下
    if row < self.top_row
      # 从当前行向开头行滚动
      self.top_row = row
    end
    # 当前行被显示末尾行之后的情况下
    if row > self.top_row + (self.page_row_max - 1)
      # 从当前行向末尾滚动
      self.top_row = row - (self.page_row_max - 1)
    end
    # 计算光标的宽度
    cursor_width = self.width / (@column_max*2) - 32
    # 计算光标坐标
    x = @index % @column_max * (cursor_width/2 + 32)
    y = @index / @column_max * 32 - self.oy
    # 更新光标矩形
    self.cursor_rect.set(x, y, cursor_width/2, 32)
  end
end
class Ck_Window_Item < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 320, 416-64)
    @column_max = 1
    refresh
    self.index = 0
    # 战斗中的情况下将窗口移至中央并将其半透明化
    if $game_temp.in_battle
      self.y = 64
      self.height = 256
      self.back_opacity = 160
    end
  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_items.size
      if $game_party.item_number(i) > 0
#p    $game_party
        @data.push($data_items[i])
      end
    end

    # 如果项目数不是 0 就生成位图、重新描绘全部项目
    @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
  #--------------------------------------------------------------------------
  # ● 描绘项目
  #     index : 项目编号
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item
      number = $game_party.item_number(item.id)
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    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

    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)
    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  end
  
  #--------------------------------------------------------------------------
  # ● 刷新帮助文本
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
  #--------------------------------------------------------------------------
  # ● 更新光标矩形
  #--------------------------------------------------------------------------
  def update_cursor_rect
    # 光标位置不满 0 的情况下
    if @index < 0
      self.cursor_rect.empty
      return
    end
    # 获取当前的行
    row = @index / @column_max
    # 当前行被显示开头行前面的情况下
    if row < self.top_row
      # 从当前行向开头行滚动
      self.top_row = row
    end
    # 当前行被显示末尾行之后的情况下
    if row > self.top_row + (self.page_row_max - 1)
      # 从当前行向末尾滚动
      self.top_row = row - (self.page_row_max - 1)
    end
    # 计算光标的宽度
    cursor_width = self.width / (@column_max*2) - 32
    # 计算光标坐标
    x = @index % @column_max * (cursor_width/2 + 32)
    y = @index / @column_max * 32 - self.oy
    # 更新光标矩形
    self.cursor_rect.set(x, y, cursor_width/2, 32)
  end
end
class Game_Party
  alias initialize_old initialize
  def initialize
    initialize_old
    @items_1={}
  end
  #--------------------------------------------------------------------------
  # ● 获取物品的所持数
  #     item_id : 物品 ID
  #--------------------------------------------------------------------------
  def item_number_1(item_id)
    # 如果 hash 个数数值不存在就返回 0
    return @items_1.include?(item_id) ? @items_1[item_id] : 0
  end
  #--------------------------------------------------------------------------
  # ● 减少物品
  #     item_id : 物品 ID
  #     n       : 个数
  #--------------------------------------------------------------------------
  def lose_item_1(item_id, n)
    # 调用 gain_item 的数值逆转
    gain_item_1(item_id, -n)
  end

  #--------------------------------------------------------------------------
  # ● 增加物品 (减少)
  #     item_id : 物品 ID
  #     n       : 个数
  #--------------------------------------------------------------------------
  def gain_item_1(item_id, n)
    # 更新 hash 的个数数据
    if item_id > 0
      @items_1[item_id] = [[item_number_1(item_id) + n, 0].max, 99].min
    end
  end
end
描述:
在地图上设置一个事件用脚本:
$game_party.gain_item(1,10)
$game_party.gain_item(4,10)
$scene=Scene_Ck.new

我的仓库脚本只能作到取出物品和存入物品,但是在物品数目0的时候显示不了,请高手帮我改一下脚本,做到能显示0数目的物品数目。

Lv4.逐梦者

梦石
0
星屑
5680
在线时间
782 小时
注册时间
2019-1-20
帖子
191
2
发表于 2023-11-15 22:51:08 | 只看该作者
  1. =begin
  2. 改过或者增加的地方找 #sjr
  3. 只是简单实现而已,细节自己搞定
  4. =end

  5. ### #sjr
  6. class Game_System
  7. attr_accessor :ck_h
  8. def ck_h
  9.    @ck_h ||=[]
  10.   end
  11. end  
  12. ### #sjr
  13. class Game_Party
  14.   def item_can_use_0?(item_id)  
  15.     occasion = $data_items[item_id].occasion
  16.     if $game_temp.in_battle
  17.       return (occasion == 0 or occasion == 1)
  18.     end
  19.     return (occasion == 0 or occasion == 2)
  20.   end
  21. end
  22. ### #sjr



  23. class Scene_Ck
  24.   def main
  25.     $game_system.ck_h=[] #sjr
  26.    
  27.     # 生成帮助窗口、物品窗口
  28.     @help_window = Window_Help.new
  29.     @ck_item_window = Ck_Window_Item.new
  30.     @ch_item_window = Ch_Window_Item.new
  31.     # 关联帮助窗口
  32.     @ck_item_window.help_window = @help_window
  33.     # 生成命令窗口
  34.     s1 = "取出"
  35.     s2 = "存入"
  36.     s3 = "取消"
  37.     @command_window = Window_Command.new(192, [s1,s2,s3])
  38.     @command_window.x = 0
  39.     @command_window.y = 480-128
  40.     # 执行过渡
  41.     Graphics.transition
  42.     # 主循环
  43.     loop do
  44.       # 刷新游戏画面
  45.       Graphics.update
  46.       # 刷新输入信息
  47.       Input.update
  48.       # 刷新画面
  49.       update
  50.       # 如果画面被切换就中断循环
  51.       if $scene != self
  52.         break
  53.       end
  54.     end
  55.     # 装备过渡
  56.     Graphics.freeze
  57.     @ck_item_window.dispose
  58.     @ch_item_window.dispose
  59.     @help_window.dispose
  60.     @command_window.dispose
  61.   end
  62.   
  63.   
  64.   def update
  65.     @command_window.update
  66.     @ck_item_window.update
  67.     @ch_item_window.update

  68.     if @command_window.active   #命令窗口界面
  69.       command_update
  70.       return
  71.     end
  72.     if @ck_item_window.active  #仓库界面
  73.       ck_update
  74.       return
  75.     end
  76.     if @ch_item_window.active #角色背包界面
  77.       ch_update
  78.       return
  79.     end
  80.   end
  81.   
  82.   
  83.   def command_update
  84.     @ck_item_window.active=false
  85.     @ch_item_window.active=false
  86.     if Input.trigger?(Input::B)
  87.       $scene=Scene_Map.new
  88.     end
  89.     if Input.trigger?(Input::C)
  90.       case @command_window.index
  91.       when 0
  92.         @command_window.active=false
  93.         @ch_item_window.active=false
  94.         @ck_item_window.active=true
  95.         return
  96.       when 1
  97.         @command_window.active=false
  98.         @ch_item_window.active=true
  99.         @ck_item_window.active=false
  100.         return
  101.       when 2
  102.         $scene=Scene_Map.new
  103.         return
  104.       end
  105.     end
  106.   end
  107.   
  108.   
  109.   def ck_update
  110.       if Input.trigger?(Input::B)
  111.         @command_window.active=true
  112.         @ch_item_window.active=false
  113.         @ck_item_window.active=false
  114.         return
  115.       end
  116.       if Input.trigger?(Input::C)
  117.         @tmp=@ck_item_window.item.id

  118.         if $game_party.item_number(@ck_item_window.item.id)>0
  119.          
  120. $game_system.ck_h.push(@ck_item_window.item.id) if !$game_system.ck_h.include?(@ck_item_window.item.id) #sjr

  121. #p   $game_party
  122.           $game_party.lose_item(@ck_item_window.item.id,1)
  123. #p   $game_party
  124. #p   @ck_item_window.item.id
  125.          @ck_item_window.refresh  
  126.         else
  127.           return
  128.         end
  129.         $game_party.gain_item_1(@tmp,1)
  130.         @ch_item_window.refresh
  131.       end
  132.   end

  133.   
  134.   def ch_update
  135.       if Input.trigger?(Input::B)
  136.         @command_window.active=true
  137.         @ch_item_window.active=false
  138.         @ck_item_window.active=false
  139.         return
  140.       end
  141.       if Input.trigger?(Input::C)
  142.         @tmp_1=@ch_item_window.item.id
  143.         if $game_party.item_number_1(@ch_item_window.item.id)>0

  144. $game_system.ck_h.push(@ch_item_window.item.id) if !$game_system.ck_h.include?(@ch_item_window.item.id)  #sjr
  145.          
  146.           $game_party.lose_item_1(@ch_item_window.item.id,1)
  147.           @ch_item_window.refresh
  148.         else
  149.           return
  150.         end
  151.         $game_party.gain_item(@tmp_1,1)
  152.         @ck_item_window.refresh
  153.       end
  154.   end
  155. end


  156. class Ch_Window_Item < Window_Selectable
  157.   #--------------------------------------------------------------------------
  158.   # ● 初始化对像
  159.   #--------------------------------------------------------------------------
  160.   def initialize
  161.     super(320, 64, 320, 416-64)
  162.     @column_max = 1
  163.     refresh
  164.     self.index = 0
  165.     # 战斗中的情况下将窗口移至中央并将其半透明化
  166.     if $game_temp.in_battle
  167.       self.y = 64
  168.       self.height = 256
  169.       self.back_opacity = 160
  170.     end
  171.   end
  172.   #--------------------------------------------------------------------------
  173.   # ● 获取物品
  174.   #--------------------------------------------------------------------------
  175.   def item
  176.     return @data[self.index]
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   # ● 刷新
  180.   #--------------------------------------------------------------------------
  181.   def refresh
  182.     if self.contents != nil
  183.       self.contents.dispose
  184.       self.contents = nil
  185.     end
  186.     @data = []
  187.     # 添加物品
  188.     for i in 1...$data_items.size
  189.       
  190.       if $game_system.ck_h.include?(i)  #sjr
  191.       @data.push($data_items[i])
  192.       next
  193.       end
  194.    
  195.       if $game_party.item_number_1(i) > 0
  196.         @data.push($data_items[i])
  197.       end
  198.     end
  199.     # 如果项目数不是 0 就生成位图、重新描绘全部项目
  200.     @item_max = @data.size
  201.     if @item_max > 0
  202.       self.contents = Bitmap.new(width - 32, row_max * 32)
  203.       for i in 0...@item_max
  204.         draw_item(i)
  205.       end
  206.     end
  207.   end
  208.   #--------------------------------------------------------------------------
  209.   # ● 描绘项目
  210.   #     index : 项目编号
  211.   #--------------------------------------------------------------------------
  212.   def draw_item(index)
  213.     item = @data[index]
  214.     case item
  215.     when RPG::Item
  216.       number = $game_party.item_number_1(item.id)
  217.     when RPG::Weapon
  218.       number = $game_party.weapon_number(item.id)
  219.     when RPG::Armor
  220.       number = $game_party.armor_number(item.id)
  221.     end
  222.     if item.is_a?(RPG::Item) and
  223.        $game_party.item_can_use_0?(item.id) #sjr
  224.       self.contents.font.color = normal_color
  225.     else
  226.       self.contents.font.color = disabled_color
  227.     end
  228.     x = 4
  229.     y = index * 32
  230. #    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  231. #    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  232.     bitmap = RPG::Cache.icon(item.icon_name)
  233.     opacity = self.contents.font.color == normal_color ? 255 : 128
  234.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  235.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  236.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  237.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  238.   end
  239.   #--------------------------------------------------------------------------
  240.   # ● 更新光标矩形
  241.   #--------------------------------------------------------------------------
  242.   def update_cursor_rect
  243.     # 光标位置不满 0 的情况下
  244.     if @index < 0
  245.       self.cursor_rect.empty
  246.       return
  247.     end
  248.     # 获取当前的行
  249.     row = @index / @column_max
  250.     # 当前行被显示开头行前面的情况下
  251.     if row < self.top_row
  252.       # 从当前行向开头行滚动
  253.       self.top_row = row
  254.     end
  255.     # 当前行被显示末尾行之后的情况下
  256.     if row > self.top_row + (self.page_row_max - 1)
  257.       # 从当前行向末尾滚动
  258.       self.top_row = row - (self.page_row_max - 1)
  259.     end
  260.     # 计算光标的宽度
  261.     cursor_width = self.width / (@column_max*2) - 32
  262.     # 计算光标坐标
  263.     x = @index % @column_max * (cursor_width/2 + 32)
  264.     y = @index / @column_max * 32 - self.oy
  265.     # 更新光标矩形
  266.     self.cursor_rect.set(x, y, cursor_width/2, 32)
  267.   end
  268. end


  269. class Ck_Window_Item < Window_Selectable
  270.   #--------------------------------------------------------------------------
  271.   # ● 初始化对像
  272.   #--------------------------------------------------------------------------
  273.   def initialize
  274.     super(0, 64, 320, 416-64)
  275.     @column_max = 1
  276.     refresh
  277.     self.index = 0
  278.     # 战斗中的情况下将窗口移至中央并将其半透明化
  279.     if $game_temp.in_battle
  280.       self.y = 64
  281.       self.height = 256
  282.       self.back_opacity = 160
  283.     end
  284.   end
  285.   #--------------------------------------------------------------------------
  286.   # ● 获取物品
  287.   #--------------------------------------------------------------------------
  288.   def item
  289.     return @data[self.index]
  290.   end
  291.   #--------------------------------------------------------------------------
  292.   # ● 刷新
  293.   #--------------------------------------------------------------------------
  294.   def refresh
  295.     if self.contents != nil
  296.       self.contents.dispose
  297.       self.contents = nil
  298.     end
  299.     @data = []
  300.     # 添加物品
  301.     for i in 1...$data_items.size
  302.       
  303.       if $game_system.ck_h.include?(i) #sjr
  304.       @data.push($data_items[i])
  305.       next
  306.       end  
  307.         
  308.       if $game_party.item_number(i) > 0
  309.         @data.push($data_items[i])
  310.       end
  311.     end

  312.     # 如果项目数不是 0 就生成位图、重新描绘全部项目
  313.     @item_max = @data.size
  314.     if @item_max > 0
  315.       self.contents = Bitmap.new(width - 32, row_max * 32)
  316.       for i in 0...@item_max
  317.         draw_item(i)
  318.       end
  319.     end
  320.   end
  321.   #--------------------------------------------------------------------------
  322.   # ● 描绘项目
  323.   #     index : 项目编号
  324.   #--------------------------------------------------------------------------
  325.   def draw_item(index)
  326.     item = @data[index]
  327.     case item
  328.     when RPG::Item
  329.       number = $game_party.item_number(item.id)
  330.     when RPG::Weapon
  331.       number = $game_party.weapon_number(item.id)
  332.     when RPG::Armor
  333.       number = $game_party.armor_number(item.id)
  334.     end
  335.      
  336.     if item.is_a?(RPG::Item) and
  337.        $game_party.item_can_use_0?(item.id) #sjr
  338.       self.contents.font.color = normal_color
  339.     else
  340.       self.contents.font.color = disabled_color
  341.     end

  342.     x = 4
  343.     y = index * 32
  344. #    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  345. #    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  346.     bitmap = RPG::Cache.icon(item.icon_name)
  347.     opacity = self.contents.font.color == normal_color ? 255 : 128
  348.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  349.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  350.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  351.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  352.   end
  353.   #--------------------------------------------------------------------------
  354.   # ● 刷新帮助文本
  355.   #--------------------------------------------------------------------------
  356.   def update_help
  357.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  358.   end
  359.   #--------------------------------------------------------------------------
  360.   # ● 更新光标矩形
  361.   #--------------------------------------------------------------------------
  362.   def update_cursor_rect
  363.     # 光标位置不满 0 的情况下
  364.     if @index < 0
  365.       self.cursor_rect.empty
  366.       return
  367.     end
  368.     # 获取当前的行
  369.     row = @index / @column_max
  370.     # 当前行被显示开头行前面的情况下
  371.     if row < self.top_row
  372.       # 从当前行向开头行滚动
  373.       self.top_row = row
  374.     end
  375.     # 当前行被显示末尾行之后的情况下
  376.     if row > self.top_row + (self.page_row_max - 1)
  377.       # 从当前行向末尾滚动
  378.       self.top_row = row - (self.page_row_max - 1)
  379.     end
  380.     # 计算光标的宽度
  381.     cursor_width = self.width / (@column_max*2) - 32
  382.     # 计算光标坐标
  383.     x = @index % @column_max * (cursor_width/2 + 32)
  384.     y = @index / @column_max * 32 - self.oy
  385.     # 更新光标矩形
  386.     self.cursor_rect.set(x, y, cursor_width/2, 32)
  387.   end
  388. end


  389. class Game_Party
  390.   alias initialize_old initialize
  391.   def initialize
  392.     initialize_old
  393.     @items_1={}
  394.   end
  395.   #--------------------------------------------------------------------------
  396.   # ● 获取物品的所持数
  397.   #     item_id : 物品 ID
  398.   #--------------------------------------------------------------------------
  399.   def item_number_1(item_id)
  400.     # 如果 hash 个数数值不存在就返回 0
  401.     return @items_1.include?(item_id) ? @items_1[item_id] : 0
  402.   end
  403.   #--------------------------------------------------------------------------
  404.   # ● 减少物品
  405.   #     item_id : 物品 ID
  406.   #     n       : 个数
  407.   #--------------------------------------------------------------------------
  408.   def lose_item_1(item_id, n)
  409.     # 调用 gain_item 的数值逆转
  410.     gain_item_1(item_id, -n)
  411.   end
  412.   #--------------------------------------------------------------------------
  413.   # ● 增加物品 (减少)
  414.   #     item_id : 物品 ID
  415.   #     n       : 个数
  416.   #--------------------------------------------------------------------------
  417.   def gain_item_1(item_id, n)
  418.     # 更新 hash 的个数数据
  419.     if item_id > 0
  420.       @items_1[item_id] = [[item_number_1(item_id) + n, 0].max, 99].min
  421.     end
  422.   end
  423. end
  424.   
复制代码



提高解答机会的方法:
看一下对应版本的帮助文件 看天气预报说今天不下雨
改变问题为更有可能的或常见的 如:天气自动变化下雨→天气系统 果然不准呀~
使用论坛的搜索功能查找相关问题 好丧啊... ...想看女装
清楚说明实际上你想解决的问题  想看坛友的女装  
脚本自己有改过的地方要标明  不要遮脸的
脚本有问题但不是默认的要全部贴出来 大胆点,尽情发
三包原则:包有BUG,包甩锅,包咕咕
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-30 10:26

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表