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

Project1

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

[已经解决] 怎么样使一些物品,在物品栏里面不会出现?

[复制链接]

Lv1.梦旅人

梦石
0
星屑
168
在线时间
189 小时
注册时间
2012-8-25
帖子
139
跳转到指定楼层
1
发表于 2012-9-25 23:02:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
3星屑
本帖最后由 delv25 于 2012-9-27 13:49 编辑

有一些物品是用来触发剧情的……,在物品栏里堆起来很难看,所以问一下有没有什么办法让那些物品在物品栏里也不显示。

我现在用的一个物品分类的脚本,不知道能不能修改使用。


#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================

module RPG
  class Weapon
    def description
      description = @description.split(/@/)[0]
      return description != nil ? description : ''
    end
    def desc
      desc = @description.split(/@/)[1]
      return desc != nil ? desc : "普通物品"
    end
  end
  class Item
    def description
      description = @description.split(/@/)[0]
      return description != nil ? description : ''
    end
    def desc
      desc = @description.split(/@/)[1]
      return desc != nil ? desc : "普通物品"
    end
  end
  class Armor
    def description
      description = @description.split(/@/)[0]
      return description != nil ? description : ''
    end
    def desc
      desc = @description.split(/@/)[1]
      return desc != nil ? desc : "普通物品"
    end
  end
end

class Harts_Window_ItemTitle < Window_Base
  def initialize
    super(0, 0, 160, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 0, 120, 32, Vocab::item, 1)
  end
end

class Harts_Window_ItemCommand < Window_Selectable
  attr_accessor :commands
  def initialize
    super(0, 64, 160, 296)
    self.index = 0
    refresh
  end
  
def addcommand
   @commands = []
   for i in 1...$data_items.size
     if $game_party.item_number($data_items) > 0
       push = true
       for com in @commands
         if com == $data_items.desc
           push = false
         end
       end
       if push == true
         @commands.push($data_items.desc)
       end
     end
   end
   for i in 1...$data_weapons.size
     if $game_party.item_number($data_weapons) > 0
       push = true
       for com in @commands
         if com == $data_weapons.desc
           push = false
           end
         end
         if push == true
           @commands.push($data_weapons.desc)
         end
       end
     end
     for i in 1...$data_armors.size
       if $game_party.item_number($data_armors) > 0
         push = true
         for com in @commands
           if com == $data_armors.desc
             push = false
           end
         end
         if push == true
           @commands.push($data_armors.desc)
         end
       end
     end
     if @commands == []
       @commands.push("普通物品")
     end      
     @item_max = @commands.size
  end
  
def refresh
    addcommand
    create_contents
    for i in 0...@item_max
      draw_item(i, normal_color)
    end
  end
  
  def draw_item(index, color)
    y = index * WLH
    self.contents.font.color = color
    if @commands[index] != nil
      self.contents.draw_text(4,y, 172, WLH, @commands[index])
    end
  end

  def update_help
    @help_window.set_text(@commands[self.index])
  end
end

class Harts_Window_ItemList < Window_Selectable
  
  def initialize
    super(160, 0, 384, 360)
    self.index = 0
    refresh
  end
  
  def item
    return @data[self.index]
  end
  
  def refresh
    @data = []
  end
  
  def set_item(command)
    refresh
    for i in 1...$data_items.size
      if $game_party.item_number($data_items) > 0  and $data_items.desc == command
        @data.push($data_items)
      end
    end
    for i in 1...$data_weapons.size
      if $game_party.item_number($data_weapons) > 0  and $data_weapons.desc == command
        @data.push($data_weapons)
      end
    end
    for i in 1...$data_armors.size
      if $game_party.item_number($data_armors) > 0  and $data_armors.desc == command
        @data.push($data_armors)
      end
    end
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      self.contents.clear
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  
  def item_number
    return @item_max
  end
  
  def draw_item(index)
    rect = item_rect(index)
    self.contents.clear_rect(rect)
    item = @data[index]
    if item != nil
      number = $game_party.item_number(item)
      enabled = $game_party.item_can_use?(item)
      rect.width -= 4
      draw_item_name(item, rect.x, rect.y, enabled)
      self.contents.draw_text(rect, sprintf(":%2d", number), 2)
    end
  end
  
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end
class Harts_Window_Help < Window_Base
  
  def initialize
    super(0, 360, 544, WLH + 32)
  end

  def set_text(text, align = 0)
    if text != @text or align != @align
      self.contents.clear
      self.contents.font.color = normal_color
      self.contents.draw_text(4, 0, self.width - 40, WLH , text, align)
      @text = text
      @align = align
    end
  end
end

class Harts_Window_MenuStatus < Window_Selectable

  def initialize(x, y)
    super(x, y, 288, 416)
    refresh
    self.active = false
    self.index = -1
  end

  def refresh
    self.contents.clear
    @item_max = $game_party.members.size
    for actor in $game_party.members
      x = 8
      y = actor.index * 96 + WLH / 2
      draw_actor_name(actor, x, y)
      draw_actor_class(actor, x + 120, y)
      draw_actor_level(actor, x, y + WLH * 1)
      draw_actor_state(actor, x, y + WLH * 2)
      draw_actor_hp(actor, x + 120, y + WLH * 1)
      draw_actor_mp(actor, x + 120, y + WLH * 2)
    end
  end

  def update_cursor
    if @index < 0               
      self.cursor_rect.empty
    elsif @index < @item_max  
      self.cursor_rect.set(0, @index * 96, contents.width, 96)
    elsif @index >= 100        
      self.cursor_rect.set(0, (@index - 100) * 96, contents.width, 96)
    else                       
      self.cursor_rect.set(0, 0, contents.width, @item_max * 96)
    end
  end
end

class Scene_Item < Scene_Base
  def start
    super
    create_menu_background
    @viewport = Viewport.new(0, 0, 544, 416)
    @itemtitle_window = Harts_Window_ItemTitle.new
    @itemcommand_window = Harts_Window_ItemCommand.new
    @command_index = @itemcommand_window.index
    @itemcommand_window.refresh
    @itemlist_window = Harts_Window_ItemList.new
    @itemlist_window.active = false
    @help_window = Harts_Window_Help.new
    @help_window.viewport = @viewport
    @target_window = Harts_Window_MenuStatus.new(96, 0)
    @itemcommand_window.help_window = @help_window
    @itemlist_window.help_window = @help_window
    @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
    hide_target_window
  end

  def terminate
    super
    dispose_menu_background
    @viewport.dispose
    @itemtitle_window.dispose
    @itemcommand_window.dispose
    @itemlist_window.dispose
    @help_window.dispose
    @target_window.dispose
  end

  def return_scene
    $scene = Scene_Menu.new(0)
  end

  def update
    super
    update_menu_background
    @help_window.update
    @itemlist_window.update
    @itemcommand_window.update
    @target_window.update
    @itemcommand_window.refresh
    if @command_index != @itemcommand_window.index
      @itemlist_window.index = 0
      @command_index = @itemcommand_window.index
      @itemcommand_window.update_help
      @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
    end
    if @itemcommand_window.active
      @itemcommand_window.update_help
      update_itemcommand
    elsif @itemlist_window.active
      update_itemlist
    elsif @target_window.active
      update_target_selection
    end
  end

  def update_itemcommand
    if Input.trigger?(Input::B)
      Sound.play_cancel
      return_scene
      return
    end
    if Input.trigger?(Input::C)
      if @itemlist_window.item_number == 0
        Sound.play_buzzer
        return
      end
      Sound.play_decision
      @itemcommand_window.active = false
      @itemlist_window.index = 0
      @itemlist_window.active = true
      return
    end
  end

  def update_itemlist
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @itemcommand_window.active = true
      @itemlist_window.active = false
      @itemcommand_window.index = @command_index
    elsif Input.trigger?(Input::C)
      @item = @itemlist_window.item
      if @item != nil
        $game_party.last_item_id = @item.id
      end
      if $game_party.item_can_use?(@item)
        Sound.play_decision
        determine_item
      else
        Sound.play_buzzer
      end
    end
  end

  def determine_item
    if @item.for_friend?
      show_target_window(@itemlist_window.index % 2 == 0)
      if @item.for_all?
        @target_window.index = 99
      else
        if $game_party.last_target_index < @target_window.item_max
          @target_window.index = $game_party.last_target_index
        else
          @target_window.index = 0
        end
      end
    else
      use_item_nontarget
    end
  end

  def update_target_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      if $game_party.item_number(@item) == 0
        @itemlist_window.refresh                 
      end
      @itemlist_window.active = true
      @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
      hide_target_window
      @itemlist_window.active = true
    elsif Input.trigger?(Input::C)
      if not $game_party.item_can_use?(@item)
        Sound.play_buzzer
      else
        determine_target
      end
    end
  end

  def determine_target
    used = false
    if @item.for_all?
      for target in $game_party.members
        target.item_effect(target, @item)
        used = true unless target.skipped
      end
    else
      $game_party.last_target_index = @target_window.index
      target = $game_party.members[@target_window.index]
      target.item_effect(target, @item)
      used = true unless target.skipped
    end
    if used
      use_item_nontarget
    else
      Sound.play_buzzer
    end
  end

  def show_target_window(right)
    @itemlist_window.active = false
    width_remain = 544 - @target_window.width
    @target_window.x = right ? width_remain : 0
    @target_window.visible = true
    @target_window.active = true
    if right
      @viewport.rect.set(0, 0, width_remain, 416)
      @viewport.ox = 0
    else
      @viewport.rect.set(@target_window.width, 0, width_remain, 416)
      @viewport.ox = @target_window.width
    end
  end

  def hide_target_window
    @target_window.visible = false
    @target_window.active = false
    @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
    @viewport.rect.set(0, 0, 544, 416)
    @viewport.ox = 0
  end

  def use_item_nontarget
    Sound.play_use_item
    $game_party.consume_item(@item)
    @itemlist_window.draw_item(@itemlist_window.index)
    @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
    @target_window.refresh
    if $game_party.all_dead?
      $scene = Scene_Gameover.new
    elsif @item.common_event_id > 0
      $game_temp.common_event_id = @item.common_event_id
      $scene = Scene_Map.new
    end
  end
end

#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================

最佳答案

查看完整内容

请使用把脚本包上。不然都被转换成论坛代码了囧 [hr]覆盖掉原来的脚本的相同部分(def set_item(command)) 然后,在不想让他显示的道具的备注部分输入

点评

问题解决了么囧?  发表于 2012-9-27 17:19
↓↑没有code真不舒服……复制也没法= =  发表于 2012-9-26 18:34
^_^建议使用代码功能,把脚本复制到代码里。  发表于 2012-9-26 17:41
新作《树海夜影》企划中……

Lv1.梦旅人

Mr.Gandum

梦石
0
星屑
226
在线时间
2070 小时
注册时间
2007-1-31
帖子
3039

贵宾

2
发表于 2012-9-25 23:02:41 | 只看该作者
本帖最后由 feizhaodan 于 2012-9-26 18:46 编辑

请使用
  1. [code][\code]
复制代码
把脚本包上。不然都被转换成论坛代码了囧

  1. def set_item(command)
  2.     refresh
  3.     for i in 1...$data_items.size
  4.       if $game_party.item_number($data_items[i]) > 0  and $data_items[i].desc == command
  5.         @data.push($data_items[i]) unless $data_items[i].note.match("<剧情物品>")
  6.       end
  7.     end
  8.     for i in 1...$data_weapons.size
  9.       if $game_party.item_number($data_weapons[i]) > 0  and $data_weapons[i].desc == command
  10.         @data.push($data_weapons[i]) unless $data_weapons[i].note.match("<剧情物品>")
  11.       end
  12.     end
  13.     for i in 1...$data_armors.size
  14.       if $game_party.item_number($data_armors[i]) > 0  and $data_armors[i].desc == command
  15.         @data.push($data_armors[i]) unless $data_armors[i].note.match("<剧情物品>")
  16.       end
  17.     end
  18.     @item_max = @data.size
  19.     if @item_max > 0
  20.       self.contents = Bitmap.new(width - 32, row_max * 32)
  21.       self.contents.clear
  22.       for i in 0...@item_max
  23.         draw_item(i)
  24.       end
  25.     end
  26.   end
复制代码
覆盖掉原来的脚本的相同部分(def set_item(command))
然后,在不想让他显示的道具的备注部分输入
  1. <剧情物品>
复制代码

点评

虽然还没搞懂,不过P叔都这么说了,分就给你了……  发表于 2012-9-27 07:47
FZD君看到VIP于是秀一下触手吗。。。  发表于 2012-9-26 22:10
以前P叔遇到困难都是这位同学帮助解决的。喵~~  发表于 2012-9-26 19:03
此同学比P叔厉害十倍以上,LZ可以直接认可这答案了。  发表于 2012-9-26 19:02
我正纳闷为什么是斜体呢,现在才发现一个[i](第i个元素)导致……斜体  发表于 2012-9-26 18:46

评分

参与人数 2星屑 +6 梦石 +2 收起 理由
咕噜 + 2 认可答案 附赠66RPG提供的好人卡一张^^.
怪蜀黍 + 6 赞同,真正的高手来了。

查看全部评分

回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
48
在线时间
2459 小时
注册时间
2011-12-18
帖子
1484
3
发表于 2012-9-25 23:25:15 | 只看该作者
这简单啊,不设置物品,给一个标记开关就可以了。

点评

我用的方法是打开物品栏时减掉这些物品,关闭时再加上......  发表于 2012-9-27 18:38
↓其实不显示就没有设置该物品的必要了,给一些剧情性的文字提示获得某件东西就行了。 最终还是用一个剧情物品来划分最好。  发表于 2012-9-26 10:42
可以考虑用注释吧,被注释了特定文字比如“剧情”的就不显示。  发表于 2012-9-26 10:32

评分

参与人数 1星屑 +2 收起 理由
怪蜀黍 + 2 同意点评

查看全部评分

这是一个深不见底的坑,这是一个广袤无边的坑,我才刚刚放上了一抔泥土……

《六道·陈国篇》开坑了……↓点我
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
168
在线时间
189 小时
注册时间
2012-8-25
帖子
139
4
 楼主| 发表于 2012-9-26 00:27:00 | 只看该作者
a364774426 发表于 2012-9-25 23:25
这简单啊,不设置物品,给一个标记开关就可以了。

主要是已经设置物品了……大概有两百多个吧。。重新去改太累了。

点评

不可能200个都是任务物品吧~~~  发表于 2012-9-26 09:24
= =主要是麻烦啦。。  发表于 2012-9-26 01:23
那啥。。。我只是觉得。。。“不过两百多=A=”怎么办。。。  发表于 2012-9-26 00:28
新作《树海夜影》企划中……
回复

使用道具 举报

Lv3.寻梦者 (版主)

八宝粥的基叔

梦石
0
星屑
4504
在线时间
5228 小时
注册时间
2009-4-29
帖子
14318

贵宾

5
发表于 2012-9-26 10:35:05 | 只看该作者
不显示也有弊端,比如已经得到了剧情物品,却没有显示,还以为没得到呢。
可以考虑添加一个类,叫做“剧情道具”,把所有剧情道具放到该类即可。
还有,这次的奖励很丰厚,问题又极容易,所以依旧是留给大家解答。
《逝去的回忆3:四叶草之梦》真情发布,欢迎点击图片下载试玩喵。

《逝去的回忆3》的讨论群:
一群:192885514
二群:200460747
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
168
在线时间
189 小时
注册时间
2012-8-25
帖子
139
6
 楼主| 发表于 2012-9-26 10:39:57 | 只看该作者
protosssonny 发表于 2012-9-26 10:35
不显示也有弊端,比如已经得到了剧情物品,却没有显示,还以为没得到呢。
可以考虑添加一个类,叫 ...

说起来我确实是有这样的脚本。。只要加 @剧情道具,就可以了……其实也不是剧情道具,是类似于开关一样启动事件的
新作《树海夜影》企划中……
回复

使用道具 举报

Lv3.寻梦者 (版主)

八宝粥的基叔

梦石
0
星屑
4504
在线时间
5228 小时
注册时间
2009-4-29
帖子
14318

贵宾

7
发表于 2012-9-26 10:47:39 | 只看该作者
煌龙的夜袭 发表于 2012-9-26 10:39
说起来我确实是有这样的脚本。。只要加 @剧情道具,就可以了……其实也不是剧情道具,是类似于开 ...

P叔只是建议,如果你坚持要“让那些物品在物品栏里也不显示”,那改起来也是相当简单的。主要是你悬赏了那么多,P叔就不回答了,毕竟P叔已经有那么多积分了,所以还是留给大家好了
@a364774426是很热心的高手,LZ可以向他请求帮助。
如果3天之后问题依然没解决,LZ可以再让P叔来回答。不过这基本是不可能的

点评

P叔最近很忙就直说嘛  发表于 2012-9-26 12:16
《逝去的回忆3:四叶草之梦》真情发布,欢迎点击图片下载试玩喵。

《逝去的回忆3》的讨论群:
一群:192885514
二群:200460747
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
168
在线时间
189 小时
注册时间
2012-8-25
帖子
139
8
 楼主| 发表于 2012-9-26 10:51:03 | 只看该作者
protosssonny 发表于 2012-9-26 10:47
P叔只是建议,如果你坚持要“让那些物品在物品栏里也不显示”,那改起来也是相当简单的。主要是你悬赏了 ...

那我把悬赏改了你就会回答了是不是= =!

点评

不是。简单的题目我一定是后回答的。把机会先给大家。  发表于 2012-9-26 11:04
新作《树海夜影》企划中……
回复

使用道具 举报

Lv2.观梦者

梦石
0
星屑
728
在线时间
687 小时
注册时间
2011-2-13
帖子
638
9
发表于 2012-9-26 18:13:47 | 只看该作者
触发剧情 不一定值能用物品啊
那只是之一啊
开关啊 变量开关啊 都可以用的
如果是必须用到物品...
不过鄙人也没觉得难看啊
事件道具不是很正常的东西 至于要不要留下来
事件完成后会不会收 不是作者自己说的算
如果只是难看 东西多 又有事件道具收集癖
那道具分类是能用到的 那是老脚本了 而且分类什么的 脚本白痴研究一会都会
直接弄一类事件道具 物品备注里 关键词填上
世界和平了...

点评

好的游戏 多少时间都不够 鄙人在乎做游戏中克服的问题 不在乎游戏做完要多久 而且好游戏容易坑  发表于 2012-9-27 17:39
= =当我学会的时候游戏已经做完了。。。  发表于 2012-9-27 03:00

评分

参与人数 1星屑 +2 收起 理由
怪蜀黍 + 2 我很赞同

查看全部评分

回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
168
在线时间
189 小时
注册时间
2012-8-25
帖子
139
10
 楼主| 发表于 2012-9-27 17:21:08 | 只看该作者
feizhaodan 发表于 2012-9-26 01:02
请使用把脚本包上。不然都被转换成论坛代码了囧

覆盖掉原来的脚本的相同部分(def set_item(command)) ...

替换了,但是还是不行……
新作《树海夜影》企划中……
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-20 15:33

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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