扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 126|回复: 0

[转载发布] 复杂物品分类轩辕菜单整合版

[复制链接]
累计送礼:
0 个
累计收礼:
0 个
  • TA的每日心情
    开心
    5 小时前
  • 签到天数: 114 天

    连续签到: 4 天

    [LV.6]常住居民II

    2338

    主题

    403

    回帖

    1万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    6
    卡币
    10607
    OK点
    16
    推广点
    0
    同能卷
    0
    积分
    13376

    灌水之王

    发表于 2024-4-19 16:35:23 | 显示全部楼层 |阅读模式
    本帖最后由 后知后觉 于 2009-8-20 12:41 编辑

    复制下面全部脚本内容,在Main脚本之前按insert,插入这个脚本全部内容。

    还有一个附件

    #==============================================================================
    #复杂物品分类轩辕菜单整合版。脚本来自66RPG。物品分类原作者:柳柳
    #轩辕剑菜单原作者:亿万星辰      整合:hktk
    #==============================================================================
    #==============================================================================
    # ■ Window_ItemCommand
    #==============================================================================

    class Window_ItemCommand < Window_Selectable
      attr_accessor :commands
      #--------------------------------------------------------------------------
      # ● 初始化,生成commands窗口
      #--------------------------------------------------------------------------
      def initialize
        super(160, 64, 161, 352)
        @commands = []
        #————————生成commands窗口
        for i in 1...$data_items.size
          if $game_party.item_number(i) > 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.weapon_number(i) > 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.armor_number(i) > 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
        self.contents = Bitmap.new(width - 32, @item_max * 32)
        refresh
        self.index = 0
      end
      #--------------------------------------------------------------------------
      #--------------------------------------------------------------------------
      def refresh
        self.contents.clear
        for i in 0...@item_max
          draw_item(i, normal_color)
        end
      end
      #--------------------------------------------------------------------------
      #--------------------------------------------------------------------------
      def draw_item(index, color)
        self.contents.font.color = color
        y = index * 32
        self.contents.draw_text(4, y, 128, 32, @commands[index])
      end
      #--------------------------------------------------------------------------
      # 只描绘原文字
      #--------------------------------------------------------------------------
      def update_help
        @help_window.set_text(@commands[self.index])
      end
    end
    #==============================================================================
    # ■ Window_ItemList
    #==============================================================================

    class Window_ItemList < Window_Selectable
      #--------------------------------------------------------------------------
      #--------------------------------------------------------------------------
      def initialize
        super(321, 64, 319, 352)
        refresh
        self.index = 0
      end
      #--------------------------------------------------------------------------
      #--------------------------------------------------------------------------
      def item
        return @data[self.index]
      end
      #--------------------------------------------------------------------------
      #--------------------------------------------------------------------------
      def refresh
        if self.contents != nil
          self.contents.dispose
          self.contents = nil
        end
        @data = []
      end
      #--------------------------------------------------------------------------
      #--------------------------------------------------------------------------
      def set_item(command)
        refresh
        for i in 1...$data_items.size
          if $game_party.item_number(i) > 0 and $data_items.desc == command
            @data.push($data_items)
          end
        end
        for i in 1...$data_weapons.size
          if $game_party.weapon_number(i) > 0 and $data_weapons.desc == command
            @data.push($data_weapons)
          end
        end
        for i in 1...$data_armors.size
          if $game_party.armor_number(i) > 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)
        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
        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 + 250, y, 16, 32, ":", 1)
        self.contents.draw_text(x + 258, y, 24, 32, number.to_s, 2)
      end
      #--------------------------------------------------------------------------
      #--------------------------------------------------------------------------
      def update_help
        @help_window.set_text(self.item == nil ? "" : self.item.description)
      end
    end
    #==============================================================================
    #复杂物品分类轩辕菜单整合版。脚本来自66RPG。物品分类原作者:柳柳
    #轩辕剑菜单原作者:亿万星辰      整合:hktk
    #==============================================================================
    #==============================================================================
    # ■ Scene_Item
    #==============================================================================
    class Scene_Item
      def main
    #==============================================================================
    #这段脚本是为了风格与 轩辕剑菜单 吻合加的。(基本上直接拷过来的)
    #==============================================================================
        @command_window = Window_MenuCommand.new(0)
        @gold_window = Window_Gold.new
        @gold_window.x = 0
        @gold_window.y = 416
        @status_window = Window_MenuStatus.new
        @status_window.x = 0
        @status_window.y = 64
        @dummy_window = Window_Base.new(160, 64, 480, 416)
        @dummy_window.back_opacity = 0
        @dummy_sprite = Sprite.new(Viewport.new(160, 64, 480, 416))
        @old_index = @menu_index
    #  item  是轩辕剑菜单的物品默认背景图,如果你修改了,也要将这里修改。
        @dummy_sprite.bitmap = Bitmap.new("Graphics/Pictures/item")
    #==============================================================================
    #这里开始时正式脚本
    #==============================================================================
        @itemcommand_window = Window_ItemCommand.new
        @itemcommand_window.opacity = 180
        @command_index = @itemcommand_window.index
        @itemlist_window = Window_ItemList.new
        @itemlist_window.active = false
        @itemlist_window.opacity = 180
        @help_window = Window_Help_New.new
        @help_window.x = 160
        @help_window.y = 416
        @itemcommand_window.help_window = @help_window
        @itemlist_window.help_window = @help_window
        @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
        Graphics.transition
        loop do
          Graphics.update
          Input.update
          update
          if $scene != self
            break
          end
        end
        Graphics.freeze
        @itemcommand_window.dispose
        @itemlist_window.dispose
        @help_window.dispose
    #这里是关闭前面那些轩辕剑菜单的各种东西。
        @command_window.dispose
        @gold_window.dispose
        @status_window.dispose
        @dummy_window.dispose
        @dummy_sprite.dispose
      end
    #==============================================================================
    #刷新内容总算法
    #==============================================================================
      def update
        @itemcommand_window.update
        @itemlist_window.update
        @help_window.update
        if @command_index != @itemcommand_window.index
          @command_index = @itemcommand_window.index
          @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
        end
        if @itemcommand_window.active
          update_itemcommand
          return
        end
        if @itemlist_window.active
          update_itemlist
          return
        end
        if @status_window.active
          update_target
          return
        end
      end
    #------------------------------------------------------------------------------
    #刷新种类菜单
    #------------------------------------------------------------------------------
      def update_itemcommand
        if Input.trigger?(Input::B)
          $game_system.se_play($data_system.cancel_se)
          $scene = Scene_Menu.new(0)
          return
        end
        if Input.trigger?(Input::C)
          if @itemlist_window.item_number == 0
            $game_system.se_play($data_system.buzzer_se)
            return
          end
          $game_system.se_play($data_system.decision_se)
          @itemcommand_window.active = false
          @itemlist_window.active = true
          @itemlist_window.index = 0
          return
        end
      end
    #------------------------------------------------------------------------------
    #刷新物品菜单
    #------------------------------------------------------------------------------
      def update_itemlist
        if Input.trigger?(Input::B)
          $game_system.se_play($data_system.cancel_se)
          @itemlist_update = false
          @itemcommand_update = true
          @command_window.active = true
          @itemcommand_window.active = true
          @itemlist_window.active = false
          @itemlist_window.index = 0
          @itemcommand_window.index = @command_index
          return
        end
        if Input.trigger?(Input::C)
          @item = @itemlist_window.item
          unless @item.is_a?(RPG::Item)
            $game_system.se_play($data_system.buzzer_se)
            return
          end
          unless $game_party.item_can_use?(@item.id)
            $game_system.se_play($data_system.buzzer_se)
            return
          end
          $game_system.se_play($data_system.decision_se)
          if @item.scope >= 3
            @itemlist_window.active = false
            @status_window.x = 0
            @status_window.visible = true
            @status_window.active = true
            if @item.scope == 4 || @item.scope == 6
              @status_window.index = -1
            else
              @status_window.index = 0
            end
                if Input.trigger?(Input::C)
          @item = @itemlist_window.item
          unless @item.is_a?(RPG::Item)
            $game_system.se_play($data_system.buzzer_se)
            return
          end
          else
            if @item.common_event_id > 0
              $game_temp.common_event_id = @item.common_event_id
              $game_system.se_play(@item.menu_se)
              if @item.consumable
                $game_party.lose_item(@item.id, 1)
                @item_window.draw_item(@item_window.index)
              end
              @item_help_window.dispose
              @itemlist_window.dispose
              @equip_window.dispose
              $scene = Scene_Map.new
              return
            end
          end
          return
        end
      end
    #==============================================================================
    #刷新光标
    #==============================================================================
      def update_target
        if Input.trigger?(Input::B)
          $game_system.se_play($data_system.cancel_se)
          unless $game_party.item_can_use?(@item.id)
            @itemlist_window.refresh
          end
          @itemlist_window.active = true
          @status_window.index = -2
          @status_window.active = false
          @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
          return
        end
        if Input.trigger?(Input::C)
          if $game_party.item_number(@item.id) == 0
            $game_system.se_play($data_system.buzzer_se)
            return
          end
          if @status_window.index == -1
            used = false
            for i in $game_party.actors
              used |= i.item_effect(@item)
            end
          end
          if @status_window.index >= 0
            target = $game_party.actors[@status_window.index]
            used = target.item_effect(@item)
          end
          if used
            $game_system.se_play(@item.menu_se)
            if @item.consumable
              $game_party.lose_item(@item.id, 1)
              @itemlist_window.draw_item(@itemlist_window.index)
              @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
            end
            @status_window.refresh
            if $game_party.all_dead?
              $scene = Scene_Gameover.new
              return
            end
            if @item.common_event_id > 0
              $game_temp.common_event_id = @item.common_event_id
              $scene = Scene_Map.new
              return
            end
          end
          unless used
            $game_system.se_play($data_system.buzzer_se)
          end
          return
        end
      end
    end
    end
    #==============================================================================
    # ■ RPG物品分类追加定义
    #==============================================================================
    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

    轩辕剑菜单Scene_Menu New!中也要改一下
    把275行左右有下面一段脚本
          when 0  # 物品
            # 演奏确定 SE
            $game_system.se_play($data_system.decision_se)
            # 生成帮助窗口、物品窗口
            @item_help_window = Window_Help_New.new
            @item_help_window.x = 160
            @item_help_window.y = 480 - 64
            @item_window = Window_Item_New.new
            # 关联帮助窗口
            @item_window.help_window = @item_help_window
            # 生成目标窗口 (设置为不可见?不活动)
            # 切换到物品画面
            @item_update = true
            @command_window.active = false
    将其改为
          when 0  # 物品
            # 演奏确定 SE
            $game_system.se_play($data_system.decision_se)
            # 切换到物品画面
            $scene = Scene_Item.new
    就可以了。

                 本帖来自P1论坛作者hktk,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=131782  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。

    本帖子中包含更多资源

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

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2025-3-14 23:09 , Processed in 0.152219 second(s), 55 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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