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

Project1

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

[已经解决] 【2VIP】物品分类脚本,隐藏某类装备

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1428
在线时间
1705 小时
注册时间
2011-8-17
帖子
818
跳转到指定楼层
1
发表于 2011-11-27 14:12:08 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
本帖最后由 黑舞嗜 于 2011-11-27 15:37 编辑

我想要的效果是物品栏里不显示除了物品类以外的所有装备类(武器和防具)(装备界面还是看得到)
(我记得以前下过一个物品分类就是不填写@XXX的情况下那个物品就不会显示)

【以下是物品分类脚本】
  1. $default_desc = "物品道具"
  2. module RPG
  3.   class Weapon
  4.     def description
  5.       description = @description.split(/@/)[0]
  6.       return description != nil ? description : ''
  7.     end
  8.     def desc
  9.       desc = @description.split(/@/)[1]
  10.       return desc != nil ? desc : $default_desc
  11.     end
  12.   end
  13.   class Item
  14.     def description
  15.       description = @description.split(/@/)[0]
  16.       return description != nil ? description : ''
  17.     end
  18.     def desc
  19.       desc = @description.split(/@/)[1]
  20.       return desc != nil ? desc : $default_desc
  21.     end
  22.   end
  23.   class Armor
  24.     def description
  25.       description = @description.split(/@/)[0]
  26.       return description != nil ? description : ''
  27.     end
  28.     def desc
  29.       desc = @description.split(/@/)[1]
  30.       return desc != nil ? desc : $default_desc
  31.     end
  32.   end
  33. end

  34. class Harts_Window_ItemTitle < Window_Base
  35.   def initialize
  36.     super(0, 0, 160, 64)
  37.     self.contents = Bitmap.new(width - 32, height - 32)
  38.     self.contents.clear
  39.     self.contents.font.color = normal_color
  40.     self.contents.draw_text(4, 0, 120, 32, Vocab::item, 1)
  41.   end
  42. end

  43. class Harts_Window_ItemCommand < Window_Selectable
  44.   attr_accessor :commands
  45.   def initialize
  46.     super(0, 64, 160, 296)
  47.     self.index = 0
  48.     refresh
  49.   end
  50.   
  51.   def addcommand
  52.     @commands = []
  53.     for i in 1...$data_items.size
  54.       if $game_party.item_number($data_items[i]) > 0
  55.         push = true
  56.         for com in @commands
  57.           push = false if com == $data_items[i].desc
  58.         end
  59.         @commands.push($data_items[i].desc) if push == true
  60.       end
  61.     end
  62.     for i in 1...$data_weapons.size
  63.       if $game_party.item_number($data_weapons[i]) > 0
  64.         push = true
  65.         for com in @commands
  66.           push = false if com == $data_weapons[i].desc
  67.         end
  68.         @commands.push($data_weapons[i].desc) if push == true
  69.       end
  70.     end
  71.     for i in 1...$data_armors.size
  72.       if $game_party.item_number($data_armors[i]) > 0
  73.         push = true
  74.         for com in @commands
  75.           push = false if com == $data_armors[i].desc
  76.         end
  77.         @commands.push($data_armors[i].desc) if push == true
  78.       end
  79.     end
  80.     @commands.push($default_desc) if @commands == []  
  81.     @item_max = @commands.size
  82.   end
  83.   
  84.   def refresh
  85.     addcommand
  86.     create_contents
  87.     @item_max.times {|i| draw_item(i, normal_color)}
  88.   end
  89.   
  90.   def draw_item(index, color)
  91.     y = index * WLH
  92.     self.contents.font.color = color
  93.     self.contents.draw_text(4,y, 172, WLH, @commands[index]) if @commands[index] != nil
  94.   end
  95.   
  96.   def update_help
  97.     @help_window.set_text(@commands[self.index])
  98.   end
  99. end

  100. class Harts_Window_ItemList < Window_Selectable
  101.   
  102.   def initialize
  103.     super(160, 0, 384, 360)
  104.     refresh
  105.   end
  106.   
  107.   def item
  108.     return @data[self.index]
  109.   end
  110.   
  111.   def refresh
  112.     @data = []
  113.   end
  114.   
  115.   def set_item(command)
  116.     refresh
  117.     for i in 1...$data_items.size
  118.       if $game_party.item_number($data_items[i]) > 0  and $data_items[i].desc == command
  119.         @data.push($data_items[i])
  120.       end
  121.     end
  122.     for i in 1...$data_weapons.size
  123.       if $game_party.item_number($data_weapons[i]) > 0  and $data_weapons[i].desc == command
  124.         @data.push($data_weapons[i])
  125.       end
  126.     end
  127.     for i in 1...$data_armors.size
  128.       if $game_party.item_number($data_armors[i]) > 0  and $data_armors[i].desc == command
  129.         @data.push($data_armors[i])
  130.       end
  131.     end
  132.     @item_max = @data.size
  133.     if @item_max > 0
  134.       self.contents = Bitmap.new(width - 32, row_max * 32)
  135.       self.contents.clear
  136.       @item_max.times{|i| draw_item(i)}
  137.     end
  138.   end
  139.   
  140.   def item_number
  141.     return @item_max
  142.   end
  143.   
  144.   def draw_item(index)
  145.     rect = item_rect(index)
  146.     self.contents.clear_rect(rect)
  147.     item = @data[index]
  148.     if item != nil
  149.       number = $game_party.item_number(item)
  150.       enabled = $game_party.item_can_use?(item)
  151.       rect.width -= 4
  152.       draw_item_name(item, rect.x, rect.y, enabled)
  153.       self.contents.draw_text(rect, sprintf(":%2d", number), 2)
  154.     end
  155.   end
  156.   
  157.   def update_help
  158.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  159.   end
  160. end

  161. class Harts_Window_Help < Window_Base
  162.   
  163.   def initialize
  164.     super(0, 360, 544, WLH + 32)
  165.   end
  166.   
  167.   def set_text(text, align = 0)
  168.     if text != @text or align != @align
  169.       self.contents.clear
  170.       self.contents.font.color = normal_color
  171.       self.contents.draw_text(4, 0, self.width - 40, WLH , text, align)
  172.       @text = text
  173.       @align = align
  174.     end
  175.   end
  176. end

  177. class Harts_Window_MenuStatus < Window_Selectable
  178.   
  179.   def initialize(x, y)
  180.     super(x, y, 288, 416)
  181.     refresh
  182.     self.active = false
  183.     self.index = -1
  184.   end
  185.   
  186.   def refresh
  187.     self.contents.clear
  188.     @item_max = $game_party.members.size
  189.     for actor in $game_party.members
  190.       x = 8
  191.       y = actor.index * 96 + WLH / 2
  192.       draw_actor_name(actor, x, y)
  193.       draw_actor_class(actor, x + 120, y)
  194.       draw_actor_level(actor, x, y + WLH * 1)
  195.       draw_actor_state(actor, x, y + WLH * 2)
  196.       draw_actor_hp(actor, x + 120, y + WLH * 1)
  197.       draw_actor_mp(actor, x + 120, y + WLH * 2)
  198.     end
  199.   end
  200.   
  201.   def update_cursor
  202.     if @index < 0 : self.cursor_rect.empty
  203.     elsif @index < @item_max : self.cursor_rect.set(0, @index * 96, contents.width, 96)
  204.     elsif @index >= 100 : self.cursor_rect.set(0, (@index - 100) * 96, contents.width, 96)
  205.     else self.cursor_rect.set(0, 0, contents.width, @item_max * 96)
  206.     end
  207.   end
  208. end

  209. class Scene_Item < Scene_Base
  210.   def start
  211.     super
  212.     create_menu_background
  213.     @viewport = Viewport.new(0, 0, 544, 416)
  214.     @itemtitle_window = Harts_Window_ItemTitle.new
  215.     @itemcommand_window = Harts_Window_ItemCommand.new
  216.     @command_index = @itemcommand_window.index
  217.     @itemcommand_window.refresh
  218.     @itemlist_window = Harts_Window_ItemList.new
  219.     @itemlist_window.active = false
  220.     @itemlist_window.index = -1
  221.     @help_window = Harts_Window_Help.new
  222.     @help_window.viewport = @viewport
  223.     @target_window = Harts_Window_MenuStatus.new(96, 0)
  224.     @itemcommand_window.help_window = @help_window
  225.     @itemlist_window.help_window = @help_window
  226.     @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  227.     hide_target_window
  228.   end
  229.   
  230.   def terminate
  231.     super
  232.     dispose_menu_background
  233.     @viewport.dispose
  234.     @itemtitle_window.dispose
  235.     @itemcommand_window.dispose
  236.     @itemlist_window.dispose
  237.     @help_window.dispose
  238.     @target_window.dispose
  239.   end
  240.   
  241.   def return_scene
  242.     $scene = Scene_Menu.new(0)
  243.   end
  244.   
  245.   def update
  246.     super
  247.     update_menu_background
  248.     @help_window.update
  249.     @itemlist_window.update
  250.     @itemcommand_window.update
  251.     @target_window.update
  252.     @itemcommand_window.refresh
  253.     if @command_index != @itemcommand_window.index
  254.       @itemlist_window.index = -1
  255.       @command_index = @itemcommand_window.index
  256.       @itemcommand_window.update_help
  257.       @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  258.     end
  259.     if @itemcommand_window.active
  260.       @itemcommand_window.update_help
  261.       update_itemcommand
  262.     elsif @itemlist_window.active
  263.       update_itemlist
  264.     elsif @target_window.active
  265.       update_target_selection
  266.     end
  267.   end
  268.   
  269.   def update_itemcommand
  270.     if Input.trigger?(Input::B)
  271.       Sound.play_cancel
  272.       return_scene
  273.       return
  274.     end
  275.     if Input.trigger?(Input::C)
  276.       if @itemlist_window.item_number == 0
  277.         Sound.play_buzzer
  278.         return
  279.       end
  280.       Sound.play_decision
  281.       @itemcommand_window.active = false
  282.       @itemlist_window.index = 0
  283.       @itemlist_window.active = true
  284.       return
  285.     end
  286.   end
  287.   
  288.   def update_itemlist
  289.     if Input.trigger?(Input::B)
  290.       Sound.play_cancel
  291.       @itemcommand_window.active = true
  292.       @itemlist_window.active = false
  293.       @itemlist_window.index = -1
  294.       @itemcommand_window.index = @command_index
  295.     elsif Input.trigger?(Input::C)
  296.       @item = @itemlist_window.item
  297.       if @item != nil
  298.         $game_party.last_item_id = @item.id
  299.       end
  300.       if $game_party.item_can_use?(@item)
  301.         Sound.play_decision
  302.         determine_item
  303.       else
  304.         Sound.play_buzzer
  305.       end
  306.     end
  307.   end
  308.   
  309.   def determine_item
  310.     if @item.for_friend?
  311.       show_target_window(@itemlist_window.index % 2 == 0)
  312.       if @item.for_all?
  313.         @target_window.index = 99
  314.       else
  315.         if $game_party.last_target_index < @target_window.item_max
  316.           @target_window.index = $game_party.last_target_index
  317.         else
  318.           @target_window.index = 0
  319.         end
  320.       end
  321.     else
  322.       use_item_nontarget
  323.     end
  324.   end
  325.   
  326.   def update_target_selection
  327.     if Input.trigger?(Input::B)
  328.       Sound.play_cancel
  329.       if $game_party.item_number(@item) == 0
  330.         @itemlist_window.refresh                 
  331.       end
  332.       @itemlist_window.active = true
  333.       @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  334.       hide_target_window
  335.       @itemlist_window.active = true
  336.     elsif Input.trigger?(Input::C)
  337.       if not $game_party.item_can_use?(@item)
  338.         Sound.play_buzzer
  339.       else
  340.         determine_target
  341.       end
  342.     end
  343.   end
  344.   
  345.   def determine_target
  346.     used = false
  347.     if @item.for_all?
  348.       for target in $game_party.members
  349.         target.item_effect(target, @item)
  350.         used = true unless target.skipped
  351.       end
  352.     else
  353.       $game_party.last_target_index = @target_window.index
  354.       target = $game_party.members[@target_window.index]
  355.       target.item_effect(target, @item)
  356.       used = true unless target.skipped
  357.     end
  358.     if used
  359.       use_item_nontarget
  360.     else
  361.       Sound.play_buzzer
  362.     end
  363.   end
  364.   
  365.   def show_target_window(right)
  366.     @itemlist_window.active = false
  367.     width_remain = 544 - @target_window.width
  368.     @target_window.x = right ? width_remain : 0
  369.     @target_window.visible = true
  370.     @target_window.active = true
  371.     if right
  372.       @viewport.rect.set(0, 0, width_remain, 416)
  373.       @viewport.ox = 0
  374.     else
  375.       @viewport.rect.set(@target_window.width, 0, width_remain, 416)
  376.       @viewport.ox = @target_window.width
  377.     end
  378.   end
  379.   
  380.   def hide_target_window
  381.     @target_window.visible = false
  382.     @target_window.active = false
  383.     @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  384.     @viewport.rect.set(0, 0, 544, 416)
  385.     @viewport.ox = 0
  386.   end
  387.   
  388.   def use_item_nontarget
  389.     Sound.play_use_item
  390.     $game_party.consume_item(@item)
  391.     @itemlist_window.draw_item(@itemlist_window.index)
  392.     @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  393.     @target_window.refresh
  394.     if $game_party.all_dead?
  395.       $scene = Scene_Gameover.new
  396.     elsif @item.common_event_id > 0
  397.       $game_temp.common_event_id = @item.common_event_id
  398.       $scene = Scene_Map.new
  399.     end
  400.   end
  401. end
复制代码

点评

找到脚本喽  发表于 2011-11-27 16:14
没有就可以进行操作了么……那我就不知道了……正确的说,都有什么“note.split”……  发表于 2011-11-27 15:46
那么把那个脚本里的注释语句拿过来= =  发表于 2011-11-27 15:25
roguelike求生RPG研发中....

Lv1.梦旅人

梦石
0
星屑
50
在线时间
1071 小时
注册时间
2011-5-12
帖子
2317

贵宾

4
发表于 2011-11-27 17:00:47 | 只看该作者
那啥……我以为这问题很简单所以让给别人= =结果还没结束啊……
127行注释掉就行了= =

点评

拖住!你不会脚本,去学吧~  发表于 2011-11-27 17:46
= = 会脚本的来了,撤退  发表于 2011-11-27 17:19
找我请找芙蕾娅
顺带一提,完全看得懂我头像请捡起你自己的节操哟(自重
回复

使用道具 举报

Lv2.观梦者

梦石
0
星屑
448
在线时间
628 小时
注册时间
2011-9-27
帖子
3996
3
发表于 2011-11-27 16:03:41 | 只看该作者
本帖最后由 小白玩家 于 2011-11-27 16:35 编辑

清除,继续找,不能弄个假的放着

点评

晕,你这和原版不是一样么  发表于 2011-11-27 16:36
囧,好像还是会显示到普通类里!  发表于 2011-11-27 16:33
地址换了  发表于 2011-11-27 16:30
我确定这个脚本不分类就不显示武器的  发表于 2011-11-27 16:30
他应该不是这意思,话说你就这么贪VIP么= = PS:“资源不存在或已删除”下载不了= =  发表于 2011-11-27 16:28
回复

使用道具 举报

Lv1.梦旅人

星君

梦石
0
星屑
83
在线时间
2980 小时
注册时间
2011-10-9
帖子
2317

贵宾短篇七萝莉正太组冠军

2
发表于 2011-11-27 14:59:53 | 只看该作者
把class Weapon之类的地方去掉就行了= =
不过我没怎么懂,就是只显示道具分类么?

点评

没有啊...  发表于 2011-11-27 15:30
不是,我记得以前有个旧版本的物品分类,在物品后面没有加@XXX的情况下那个装备就不会在物品栏里显示,现在这个会显示出来了  发表于 2011-11-27 15:10

回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-25 06:33

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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