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

Project1

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

[已经解决] 品分类脚本和新增装备脚本怎么整合

[复制链接]

Lv2.观梦者

梦石
0
星屑
463
在线时间
193 小时
注册时间
2014-8-25
帖子
30
1
发表于 2015-9-26 11:40:11 | 显示全部楼层
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================
  4. #可以自定义设置物品分类,利用物品描述,每个描述后面添加@物品分类即可。

  5. #==============================================================================
  6. # ■ Harts_Window_ItemTitle
  7. #==============================================================================

  8. class Harts_Window_ItemTitle < Window_Base
  9.   def initialize
  10.     super(0, 0, 160, 64)
  11.     self.contents = Bitmap.new(width - 32, height - 32)
  12.     self.contents.clear
  13.     self.contents.font.color = normal_color
  14.     self.contents.draw_text(4, 0, 120, 32, $data_system.words.item, 1)
  15.   end
  16. end

  17. #==============================================================================
  18. # ■ Harts_Window_ItemCommand
  19. #==============================================================================

  20. class Harts_Window_ItemCommand < Window_Selectable
  21.   attr_accessor :commands
  22.   #--------------------------------------------------------------------------
  23.   # ● 初始化,生成commands窗口
  24.   #--------------------------------------------------------------------------
  25.   def initialize
  26.     super(0, 64, 160, 352)
  27.     @commands = []
  28.     #————————生成commands窗口
  29.     for i in 1...$data_items.size
  30.       if $game_party.item_number(i) > 0
  31.         push = true
  32.         for com in @commands
  33.           if com == $data_items[i].desc
  34.             push = false
  35.           end
  36.         end
  37.         if push == true
  38.           @commands.push($data_items[i].desc)
  39.         end
  40.       end
  41.     end
  42.     for i in 1...$data_weapons.size
  43.       if $game_party.weapon_number(i) > 0
  44.         push = true
  45.         for com in @commands
  46.           if com == $data_weapons[i].desc
  47.             push = false
  48.           end
  49.         end
  50.         if push == true
  51.           @commands.push($data_weapons[i].desc)
  52.         end
  53.       end
  54.     end
  55.     for i in 1...$data_armors.size
  56.       if $game_party.armor_number(i) > 0
  57.         push = true
  58.         for com in @commands
  59.           if com == $data_armors[i].desc
  60.             push = false
  61.           end
  62.         end
  63.         if push == true
  64.           @commands.push($data_armors[i].desc)
  65.         end
  66.       end
  67.     end
  68.     if @commands == []
  69.       @commands.push("天材地宝")
  70.     end      
  71.     @item_max = @commands.size
  72.     self.contents = Bitmap.new(width - 32, @item_max * 32)
  73.     refresh
  74.     self.index = 0
  75.    if $game_temp.in_battle
  76.      self.height = 288
  77.    end
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   #--------------------------------------------------------------------------
  81.   def refresh
  82.     self.contents.clear
  83.     for i in 0...@item_max
  84.       draw_item(i, normal_color)
  85.     end  
  86.   end
  87.   #--------------------------------------------------------------------------
  88.   #--------------------------------------------------------------------------
  89.   def draw_item(index, color)
  90.     self.contents.font.color = color
  91.     y = index * 32
  92.     self.contents.draw_text(4, y, 128, 32, @commands[index])
  93.   end
  94.   #--------------------------------------------------------------------------
  95.   # 只描绘原文字
  96.   #--------------------------------------------------------------------------
  97.   def update_help
  98.     @help_window.set_text(@commands[self.index])
  99.   end
  100. end

  101. #==============================================================================
  102. # ■ Window_Item
  103. #==============================================================================

  104. class Harts_Window_ItemList < Window_Selectable
  105.   #--------------------------------------------------------------------------
  106.   #--------------------------------------------------------------------------
  107.   
  108. def initialize
  109.    super(160, 0, 480, 416)
  110.    self.opacity = 0
  111.    self.z = 999
  112.    refresh
  113.    self.index = 0
  114.    # 战斗中的情况下将窗口移至中央并将其半透明化
  115.    if $game_temp.in_battle
  116.      self.y = 64
  117.      self.height = 256
  118.      self.back_opacity = 160
  119.      self.opacity = 255
  120.    end
  121. end
  122.   #--------------------------------------------------------------------------
  123.   #--------------------------------------------------------------------------
  124.   def item
  125.     return @data[self.index]
  126.   end
  127.   #--------------------------------------------------------------------------
  128.   #--------------------------------------------------------------------------
  129.   def refresh
  130.     if self.contents != nil
  131.       self.contents.dispose
  132.       self.contents = nil
  133.     end
  134.     @data = []
  135.   end
  136.   #--------------------------------------------------------------------------
  137.   #--------------------------------------------------------------------------
  138.   def set_item(command)
  139.     refresh
  140.     for i in 1...$data_items.size
  141.       if $game_party.item_number(i) > 0 and $data_items[i].desc == command
  142.         @data.push($data_items[i])
  143.       end
  144.     end
  145.     for i in 1...$data_weapons.size
  146.       if $game_party.weapon_number(i) > 0 and $data_weapons[i].desc == command
  147.         @data.push($data_weapons[i])
  148.       end
  149.     end
  150.     for i in 1...$data_armors.size
  151.       if $game_party.armor_number(i) > 0 and $data_armors[i].desc == command
  152.         @data.push($data_armors[i])
  153.       end
  154.     end
  155.     @item_max = @data.size
  156.     if @item_max > 0
  157.       self.contents = Bitmap.new(width - 32, row_max * 32)
  158.       self.contents.clear
  159.       for i in 0...@item_max
  160.         draw_item(i)
  161.       end
  162.     end
  163.   end
  164.   #--------------------------------------------------------------------------
  165.   #--------------------------------------------------------------------------
  166.   def item_number
  167.     return @item_max
  168.   end
  169.   #--------------------------------------------------------------------------
  170.   #--------------------------------------------------------------------------
  171.   def draw_item(index)
  172.     item = @data[index]
  173.     case item
  174.     when RPG::Item
  175.       number = $game_party.item_number(item.id)
  176.     when RPG::Weapon
  177.       number = $game_party.weapon_number(item.id)
  178.     when RPG::Armor
  179.       number = $game_party.armor_number(item.id)
  180.     end
  181.     if item.is_a?(RPG::Item) and
  182.       $game_party.item_can_use?(item.id)
  183.       self.contents.font.color = normal_color
  184.     else
  185.       self.contents.font.color = disabled_color
  186.     end
  187.     x = 4
  188.     y = index * 32
  189.     bitmap = RPG::Cache.icon(item.icon_name)
  190.     opacity = self.contents.font.color == normal_color ? 255 : 128
  191.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  192.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  193.     self.contents.draw_text(x + 400, y, 16, 32, ":", 1)
  194.     self.contents.draw_text(x + 416, y, 24, 32, number.to_s, 2)
  195.   end
  196.   #--------------------------------------------------------------------------
  197.   #--------------------------------------------------------------------------
  198.   def update_help
  199.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  200.   end
  201. end

  202. #==============================================================================
  203. # ■ Harts_Scene_Item
  204. #==============================================================================

  205. class Scene_Item
  206.   #--------------------------------------------------------------------------
  207.   #--------------------------------------------------------------------------
  208.   def main
  209.     #添加背景图,不用则删
  210.     @backsp = Sprite.new
  211.     @backsp.bitmap = Bitmap.new("Graphics/Pictures/界面物品")
  212.     #
  213.     @itemtitle_window = Harts_Window_ItemTitle.new
  214.     @itemcommand_window = Harts_Window_ItemCommand.new
  215.     @command_index = @itemcommand_window.index
  216.     @itemlist_window = Harts_Window_ItemList.new
  217.     @itemlist_window.active = false
  218.     @help_window = Window_Help.new
  219.     @help_window.x = 0
  220.     @help_window.y = 416
  221.     @itemcommand_window.help_window = @help_window
  222.     @itemlist_window.help_window = @help_window
  223.     @target_window = Window_Target.new
  224.     @target_window.visible = false
  225.     @target_window.active = false
  226.     @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  227.     Graphics.transition
  228.     loop do
  229.       Graphics.update
  230.       Input.update
  231.       update
  232.       if $scene != self
  233.         break
  234.       end
  235.     end
  236.     Graphics.freeze
  237.      #添加背景图,不用则删
  238.     @backsp.dispose
  239.      #
  240.     @itemtitle_window.dispose
  241.     @itemcommand_window.dispose
  242.     @itemlist_window.dispose
  243.     @help_window.dispose
  244.     @target_window.dispose
  245.   end
  246.   #--------------------------------------------------------------------------
  247.   #--------------------------------------------------------------------------
  248.   def update
  249.     @itemtitle_window.update
  250.     @itemcommand_window.update
  251.     @itemlist_window.update
  252.     @help_window.update
  253.     @target_window.update
  254.     if @command_index != @itemcommand_window.index
  255.       @command_index = @itemcommand_window.index
  256.       @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  257.     end
  258.     if @itemcommand_window.active
  259.       update_itemcommand
  260.       return
  261.     end
  262.     if @itemlist_window.active
  263.       update_itemlist
  264.       return
  265.     end
  266.     if @target_window.active
  267.       update_target
  268.       return
  269.     end
  270.   end
  271.   #--------------------------------------------------------------------------
  272.   #--------------------------------------------------------------------------
  273.   def update_itemcommand
  274.     if Input.trigger?(Input::B)
  275.       $game_system.se_play($data_system.cancel_se)
  276.       $scene = Scene_Menu.new(0)
  277.       return
  278.     end
  279.     if Input.trigger?(Input::C)
  280.       if @itemlist_window.item_number == 0
  281.         $game_system.se_play($data_system.buzzer_se)
  282.         return
  283.       end
  284.       $game_system.se_play($data_system.decision_se)
  285.       @itemcommand_window.active = false
  286.       @itemlist_window.active = true
  287.       @itemlist_window.index = 0
  288.       return
  289.     end
  290.   end
  291.   #--------------------------------------------------------------------------
  292.   #--------------------------------------------------------------------------
  293.   def update_itemlist
  294.     if Input.trigger?(Input::B)
  295.       $game_system.se_play($data_system.cancel_se)
  296.       @itemcommand_window.active = true
  297.       @itemlist_window.active = false
  298.       @itemlist_window.index = 0
  299.       @itemcommand_window.index = @command_index
  300.       return
  301.     end
  302.     if Input.trigger?(Input::C)
  303.       @item = @itemlist_window.item
  304.       unless @item.is_a?(RPG::Item)
  305.         $game_system.se_play($data_system.buzzer_se)
  306.         return
  307.       end
  308.       unless $game_party.item_can_use?(@item.id)
  309.         $game_system.se_play($data_system.buzzer_se)
  310.         return
  311.       end
  312.       $game_system.se_play($data_system.decision_se)
  313.       if @item.scope >= 3
  314.         @itemlist_window.active = false
  315.         @target_window.x = 304
  316.         @target_window.visible = true
  317.         @target_window.active = true
  318.         if @item.scope == 4 || @item.scope == 6
  319.           @target_window.index = -1
  320.         else
  321.           @target_window.index = 0
  322.         end
  323.       else
  324.         if @item.common_event_id > 0
  325.           $game_temp.common_event_id = @item.common_event_id
  326.           $game_system.se_play(@item.menu_se)
  327.             if @item.consumable
  328.               $game_party.lose_item(@item.id, 1)
  329.               @itemlist_window.draw_item(@itemlist_window.index)
  330.             end
  331.           $scene = Scene_Map.new
  332.           return
  333.         end
  334.       end
  335.       return
  336.     end
  337.   end
  338.   #--------------------------------------------------------------------------
  339.   #--------------------------------------------------------------------------
  340.   def update_target
  341.     if Input.trigger?(Input::B)
  342.       $game_system.se_play($data_system.cancel_se)
  343.       unless $game_party.item_can_use?(@item.id)
  344.         @itemlist_window.refresh
  345.       end
  346.       @itemlist_window.active = true
  347.       @target_window.visible = false
  348.       @target_window.active = false
  349.       @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  350.       return
  351.     end
  352.     if Input.trigger?(Input::C)
  353.       if $game_party.item_number(@item.id) == 0
  354.         $game_system.se_play($data_system.buzzer_se)
  355.         return
  356.       end
  357.       if @target_window.index == -1
  358.         used = false
  359.         for i in $game_party.actors
  360.           used |= i.item_effect(@item)
  361.         end
  362.       end
  363.       if @target_window.index >= 0
  364.         target = $game_party.actors[@target_window.index]
  365.         used = target.item_effect(@item)
  366.       end
  367.       if used
  368.         $game_system.se_play(@item.menu_se)
  369.         if @item.consumable
  370.           $game_party.lose_item(@item.id, 1)
  371.           @itemlist_window.draw_item(@itemlist_window.index)
  372.           @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  373.         end
  374.         @target_window.refresh
  375.         if $game_party.all_dead?
  376.           $scene = Scene_Gameover.new
  377.           return
  378.         end
  379.         if @item.common_event_id > 0
  380.           $game_temp.common_event_id = @item.common_event_id
  381.           $scene = Scene_Map.new
  382.           return
  383.         end
  384.       end
  385.       unless used
  386.         $game_system.se_play($data_system.buzzer_se)
  387.       end
  388.     return
  389.     end
  390.   end
  391. end

  392. #==============================================================================
  393. # ■ RPG追加定义,使用@符号分类
  394. #==============================================================================

  395. module RPG
  396.   class Weapon
  397.     def description
  398.       description = @description.split(/@/)[0]
  399.       return description != nil ? description : ''
  400.     end
  401.     def desc
  402.       desc = @description.split(/@/)[1]
  403.       return desc != nil ? desc : "天材地宝"
  404.     end
  405.   end
  406.   class Item
  407.     def description
  408.       description = @description.split(/@/)[0]
  409.       return description != nil ? description : ''
  410.     end
  411.     def desc
  412.       desc = @description.split(/@/)[1]
  413.       return desc != nil ? desc : "天材地宝"
  414.     end
  415.   end
  416.   class Armor
  417.     def description
  418.       description = @description.split(/@/)[0]
  419.       return description != nil ? description : ''
  420.     end
  421.     def desc
  422.       desc = @description.split(/@/)[1]
  423.       return desc != nil ? desc : "天材地宝"
  424.     end
  425.   end
  426. end

  427. #==============================================================================
  428. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  429. #==============================================================================
复制代码
推荐使用这个物品分类脚本
黄海有狂人,欲与日月争,还我三万六千晨
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-15 17:16

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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