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

Project1

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

[已经解决] 想要个简单的物品分类脚本

[复制链接]

Lv2.观梦者

梦石
0
星屑
548
在线时间
254 小时
注册时间
2010-8-25
帖子
371
跳转到指定楼层
1
发表于 2012-1-25 22:03:44 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
本来想要个早期前辈做的简单物品分类脚本,可是去看了新旧的资源帖,连接都失效了。

不知道还有那位同学还有那个工程,希望能发上来,以帮助更多需要同类脚本的人

Lv1.梦旅人

梦石
0
星屑
50
在线时间
470 小时
注册时间
2010-6-25
帖子
316
2
发表于 2012-1-25 22:35:08 | 只看该作者
本帖最后由 腐琴琴 于 2012-1-25 22:37 编辑

Project16.rar (188.99 KB, 下载次数: 56)

其实真心不需要范例啦……

脚本在下面

在物品说明后面“@类型”就好啦

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

  4. #==============================================================================
  5. # ■ Harts_Window_ItemTitle
  6. #==============================================================================
  7. class Harts_Window_ItemTitle < Window_Base
  8.   def initialize
  9.     super(0, 0, 160, 64)
  10.     self.contents = Bitmap.new(width - 32, height - 32)
  11.     self.contents.clear
  12.     self.contents.font.color = normal_color
  13.     self.contents.draw_text(4, 0, 120, 32, $data_system.words.item, 1)
  14.   end
  15. end
  16. #==============================================================================
  17. # ■ Harts_Window_ItemCommand
  18. #==============================================================================
  19. class Harts_Window_ItemCommand < Window_Selectable
  20.   attr_accessor :commands
  21.   #--------------------------------------------------------------------------
  22.   # ● 初始化,生成commands窗口
  23.   #--------------------------------------------------------------------------
  24.   def initialize
  25.     super(0, 64, 160, 352)
  26.     @commands = []
  27.     #————————生成commands窗口
  28.     for i in 1...$data_items.size
  29.       if $game_party.item_number(i) > 0  
  30.         push = true
  31.         for com in @commands
  32.           if com == $data_items[i].desc
  33.             push = false
  34.           end
  35.         end
  36.         if push == true
  37.           @commands.push($data_items[i].desc)
  38.         end
  39.       end
  40.     end
  41.     for i in 1...$data_weapons.size
  42.       if $game_party.weapon_number(i) > 0  
  43.         push = true
  44.         for com in @commands
  45.           if com == $data_weapons[i].desc
  46.             push = false
  47.           end
  48.         end
  49.         if push == true
  50.           @commands.push($data_weapons[i].desc)
  51.         end
  52.       end
  53.     end
  54.     for i in 1...$data_armors.size
  55.       if $game_party.armor_number(i) > 0  
  56.         push = true
  57.         for com in @commands
  58.           if com == $data_armors[i].desc
  59.             push = false
  60.           end
  61.         end
  62.         if push == true
  63.           @commands.push($data_armors[i].desc)
  64.         end
  65.       end
  66.     end
  67.     if @commands == []
  68.       @commands.push("普通物品")
  69.     end      
  70.     @item_max = @commands.size
  71.     self.contents = Bitmap.new(width - 32, @item_max * 32)
  72.     refresh
  73.     self.index = 0
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   #--------------------------------------------------------------------------
  77.   def refresh
  78.     self.contents.clear
  79.     for i in 0...@item_max
  80.       draw_item(i, normal_color)
  81.     end
  82.   end
  83.   #--------------------------------------------------------------------------
  84.   #--------------------------------------------------------------------------
  85.   def draw_item(index, color)
  86.     self.contents.font.color = color
  87.     y = index * 32
  88.     self.contents.draw_text(4, y, 128, 32, @commands[index])
  89.   end
  90.   #--------------------------------------------------------------------------
  91.   # 只描绘原文字
  92.   #--------------------------------------------------------------------------
  93.   def update_help
  94.     @help_window.set_text(@commands[self.index])
  95.   end
  96. end
  97. #==============================================================================
  98. # ■ Window_Item
  99. #==============================================================================
  100. class Harts_Window_ItemList < Window_Selectable
  101.   #--------------------------------------------------------------------------
  102.   #--------------------------------------------------------------------------
  103.   def initialize
  104.     super(160, 0, 480, 416)
  105.     refresh
  106.     self.index = 0
  107.   end
  108.   #--------------------------------------------------------------------------
  109.   #--------------------------------------------------------------------------
  110.   def item
  111.     return @data[self.index]
  112.   end
  113.   #--------------------------------------------------------------------------
  114.   #--------------------------------------------------------------------------
  115.   def refresh
  116.     if self.contents != nil
  117.       self.contents.dispose
  118.       self.contents = nil
  119.     end
  120.     @data = []
  121.   end
  122.   #--------------------------------------------------------------------------
  123.   #--------------------------------------------------------------------------
  124.   def set_item(command)
  125.     refresh
  126.     for i in 1...$data_items.size
  127.       if $game_party.item_number(i) > 0 and $data_items[i].desc == command
  128.         @data.push($data_items[i])
  129.       end
  130.     end
  131.     for i in 1...$data_weapons.size
  132.       if $game_party.weapon_number(i) > 0 and $data_weapons[i].desc == command
  133.         @data.push($data_weapons[i])
  134.       end
  135.     end
  136.     for i in 1...$data_armors.size
  137.       if $game_party.armor_number(i) > 0 and $data_armors[i].desc == command
  138.         @data.push($data_armors[i])
  139.       end
  140.     end
  141.     @item_max = @data.size
  142.     if @item_max > 0
  143.       self.contents = Bitmap.new(width - 32, row_max * 32)
  144.       self.contents.clear
  145.       for i in 0...@item_max
  146.         draw_item(i)
  147.       end
  148.     end
  149.   end
  150.   #--------------------------------------------------------------------------
  151.   #--------------------------------------------------------------------------
  152.   def item_number
  153.     return @item_max
  154.   end
  155.   #--------------------------------------------------------------------------
  156.   #--------------------------------------------------------------------------
  157.   def draw_item(index)
  158.     item = @data[index]
  159.     case item
  160.     when RPG::Item
  161.       number = $game_party.item_number(item.id)
  162.     when RPG::Weapon
  163.       number = $game_party.weapon_number(item.id)
  164.     when RPG::Armor
  165.       number = $game_party.armor_number(item.id)
  166.     end
  167.     if item.is_a?(RPG::Item) and
  168.       $game_party.item_can_use?(item.id)
  169.       self.contents.font.color = normal_color
  170.     else
  171.       self.contents.font.color = disabled_color
  172.     end
  173.     x = 4
  174.     y = index * 32
  175.     bitmap = RPG::Cache.icon(item.icon_name)
  176.     opacity = self.contents.font.color == normal_color ? 255 : 128
  177.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  178.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  179.     self.contents.draw_text(x + 400, y, 16, 32, ":", 1)
  180.     self.contents.draw_text(x + 416, y, 24, 32, number.to_s, 2)
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   #--------------------------------------------------------------------------
  184.   def update_help
  185.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  186.   end
  187. end
  188. #==============================================================================
  189. # ■ Harts_Scene_Item
  190. #==============================================================================
  191. class Scene_Item
  192.   #--------------------------------------------------------------------------
  193.   #--------------------------------------------------------------------------
  194.   def main
  195.     @itemtitle_window = Harts_Window_ItemTitle.new
  196.     @itemcommand_window = Harts_Window_ItemCommand.new
  197.     @command_index = @itemcommand_window.index
  198.     @itemlist_window = Harts_Window_ItemList.new
  199.     @itemlist_window.active = false
  200.     @help_window = Window_Help.new
  201.     @help_window.x = 0
  202.     @help_window.y = 416
  203.     @itemcommand_window.help_window = @help_window
  204.     @itemlist_window.help_window = @help_window
  205.     @target_window = Window_Target.new
  206.     @target_window.visible = false
  207.     @target_window.active = false
  208.     @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  209.     Graphics.transition
  210.     loop do
  211.       Graphics.update
  212.       Input.update
  213.       update
  214.       if $scene != self
  215.         break
  216.       end
  217.     end
  218.     Graphics.freeze
  219.     @itemtitle_window.dispose
  220.     @itemcommand_window.dispose
  221.     @itemlist_window.dispose
  222.     @help_window.dispose
  223.     @target_window.dispose
  224.   end
  225.   #--------------------------------------------------------------------------
  226.   #--------------------------------------------------------------------------
  227.   def update
  228.     @itemtitle_window.update
  229.     @itemcommand_window.update
  230.     @itemlist_window.update
  231.     @help_window.update
  232.     @target_window.update
  233.     if @command_index != @itemcommand_window.index
  234.       @command_index = @itemcommand_window.index
  235.       @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  236.     end
  237.     if @itemcommand_window.active
  238.       update_itemcommand
  239.       return
  240.     end
  241.     if @itemlist_window.active
  242.       update_itemlist
  243.       return
  244.     end
  245.     if @target_window.active
  246.       update_target
  247.       return
  248.     end
  249.   end
  250.   #--------------------------------------------------------------------------
  251.   #--------------------------------------------------------------------------
  252.   def update_itemcommand
  253.     if Input.trigger?(Input::B)
  254.       $game_system.se_play($data_system.cancel_se)
  255.       $scene = Scene_Menu.new(0)
  256.       return
  257.     end
  258.     if Input.trigger?(Input::C)
  259.       if @itemlist_window.item_number == 0
  260.         $game_system.se_play($data_system.buzzer_se)
  261.         return
  262.       end
  263.       $game_system.se_play($data_system.decision_se)
  264.       @itemcommand_window.active = false
  265.       @itemlist_window.active = true
  266.       @itemlist_window.index = 0
  267.       return
  268.     end
  269.   end
  270.   #--------------------------------------------------------------------------
  271.   #--------------------------------------------------------------------------
  272.   def update_itemlist
  273.     if Input.trigger?(Input::B)
  274.       $game_system.se_play($data_system.cancel_se)
  275.       @itemcommand_window.active = true
  276.       @itemlist_window.active = false
  277.       @itemlist_window.index = 0
  278.       @itemcommand_window.index = @command_index
  279.       return
  280.     end
  281.     if Input.trigger?(Input::C)
  282.       @item = @itemlist_window.item
  283.       unless @item.is_a?(RPG::Item)
  284.         $game_system.se_play($data_system.buzzer_se)
  285.         return
  286.       end
  287.       unless $game_party.item_can_use?(@item.id)
  288.         $game_system.se_play($data_system.buzzer_se)
  289.         return
  290.       end
  291.       $game_system.se_play($data_system.decision_se)
  292.       if @item.scope >= 3
  293.         @itemlist_window.active = false
  294.         @target_window.x = 304
  295.         @target_window.visible = true
  296.         @target_window.active = true
  297.         if @item.scope == 4 || @item.scope == 6
  298.           @target_window.index = -1
  299.         else
  300.           @target_window.index = 0
  301.         end
  302.       else
  303.         if @item.common_event_id > 0
  304.           $game_temp.common_event_id = @item.common_event_id
  305.           $game_system.se_play(@item.menu_se)
  306.             if @item.consumable
  307.               $game_party.lose_item(@item.id, 1)
  308.               @itemlist_window.draw_item(@itemlist_window.index)
  309.             end
  310.           $scene = Scene_Map.new
  311.           return
  312.         end
  313.       end
  314.       return
  315.     end
  316.   end
  317.   #--------------------------------------------------------------------------
  318.   #--------------------------------------------------------------------------
  319.   def update_target
  320.     if Input.trigger?(Input::B)
  321.       $game_system.se_play($data_system.cancel_se)
  322.       unless $game_party.item_can_use?(@item.id)
  323.         @itemlist_window.refresh
  324.       end
  325.       @itemlist_window.active = true
  326.       @target_window.visible = false
  327.       @target_window.active = false
  328.       @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  329.       return
  330.     end
  331.     if Input.trigger?(Input::C)
  332.       if $game_party.item_number(@item.id) == 0
  333.         $game_system.se_play($data_system.buzzer_se)
  334.         return
  335.       end
  336.       if @target_window.index == -1
  337.         used = false
  338.         for i in $game_party.actors
  339.           used |= i.item_effect(@item)
  340.         end
  341.       end
  342.       if @target_window.index >= 0
  343.         target = $game_party.actors[@target_window.index]
  344.         used = target.item_effect(@item)
  345.       end
  346.       if used
  347.         $game_system.se_play(@item.menu_se)
  348.         if @item.consumable
  349.           $game_party.lose_item(@item.id, 1)
  350.           @itemlist_window.draw_item(@itemlist_window.index)
  351.           @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  352.         end
  353.         @target_window.refresh
  354.         if $game_party.all_dead?
  355.           $scene = Scene_Gameover.new
  356.           return
  357.         end
  358.         if @item.common_event_id > 0
  359.           $game_temp.common_event_id = @item.common_event_id
  360.           $scene = Scene_Map.new
  361.           return
  362.         end
  363.       end
  364.       unless used
  365.         $game_system.se_play($data_system.buzzer_se)
  366.       end
  367.     return
  368.     end
  369.   end
  370. end
  371. #==============================================================================
  372. # ■ RPG追加定义,使用@符号分类
  373. #==============================================================================
  374. module RPG
  375.   class Weapon
  376.     def description
  377.       description = @description.split(/@/)[0]
  378.       return description != nil ? description : ''
  379.     end
  380.     def desc
  381.       desc = @description.split(/@/)[1]
  382.       return desc != nil ? desc : "普通物品"
  383.     end
  384.   end
  385.   class Item
  386.     def description
  387.       description = @description.split(/@/)[0]
  388.       return description != nil ? description : ''
  389.     end
  390.     def desc
  391.       desc = @description.split(/@/)[1]
  392.       return desc != nil ? desc : "普通物品"
  393.     end
  394.   end
  395.   class Armor
  396.     def description
  397.       description = @description.split(/@/)[0]
  398.       return description != nil ? description : ''
  399.     end
  400.     def desc
  401.       desc = @description.split(/@/)[1]
  402.       return desc != nil ? desc : "普通物品"
  403.     end
  404.   end
  405. end
  406. #==============================================================================
  407. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  408. #==============================================================================
复制代码
���

回复

使用道具 举报

Lv4.逐梦者

梦石
3
星屑
6420
在线时间
1131 小时
注册时间
2007-12-26
帖子
2402
3
发表于 2012-1-26 17:11:19 | 只看该作者
这个?
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================

  4. module RPG
  5.   # 物品分类
  6.   class Item
  7.     def name
  8.       name = @name.split(/,/)[0]
  9.       return name != nil ? name : ""
  10.     end
  11.     def occasion
  12.       occasion = @name.split(/,/)[1]
  13.       return occasion != nil ? 4 : @occasion
  14.     end
  15.   end
  16. end
  17. #==============================================================================
  18. # ■ Harts_Window_ItemTitle
  19. #------------------------------------------------------------------------------
  20. #  アイテム画面で、タイトルを表示するウィンドウ。
  21. #==============================================================================

  22. class Harts_Window_ItemTitle < Window_Base
  23.   #--------------------------------------------------------------------------
  24.   # ● オブジェクト初期化
  25.   #--------------------------------------------------------------------------
  26.   def initialize
  27.     super(10, 10, 150, 59)
  28.     self.contents = Bitmap.new(width - 32, height - 32)
  29.     self.contents.clear
  30.     self.contents.font.color = normal_color
  31.     self.contents.draw_text(0, 0, 100, 32, $data_system.words.item, 1)
  32.   end
  33. end

  34. #==============================================================================
  35. # ■ Harts_Window_ItemCommand
  36. #------------------------------------------------------------------------------
  37. #  アイテムの種別選択を行うウィンドウです。
  38. #==============================================================================

  39. class Harts_Window_ItemCommand < Window_Selectable
  40.   #--------------------------------------------------------------------------
  41.   # ● オブジェクト初期化
  42.   #--------------------------------------------------------------------------
  43.   def initialize
  44.     super(10, 79, 150, 321)
  45.     self.contents = Bitmap.new(width - 32, height - 32)
  46.     @item_max = 9
  47.     @commands = ["药用道具", "投掷道具", "右手道具", "左手道具", "头部防具", "身体防具", "装饰物品", "特殊道具", "闲者之石"]
  48.     refresh
  49.     self.index = 0
  50.   end
  51.   #--------------------------------------------------------------------------
  52.   # ● リフレッシュ
  53.   #--------------------------------------------------------------------------
  54.   def refresh
  55.     self.contents.clear
  56.     for i in 0...@item_max
  57.     draw_item(i, normal_color)
  58.     end
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # ● 項目の描画
  62.   # index : 項目番号
  63.   # color : 文字色
  64.   #--------------------------------------------------------------------------
  65.   def draw_item(index, color)
  66.     self.contents.font.color = color
  67.     y = index * 32
  68.     self.contents.draw_text(4, y, 128, 32, @commands[index])
  69.   end
  70.   #--------------------------------------------------------------------------
  71.   # ● ヘルプテキスト更新
  72.   #--------------------------------------------------------------------------
  73.   def update_help
  74.     case self.index
  75.     when 0
  76.       @text = "居家旅行必备药品。"
  77.     when 1
  78.       @text = "杀人灭口常备道具。"
  79.     when 2
  80.       @text = "右手武器,刀枪剑戟斧钺钩叉……"
  81.     when 3
  82.       @text = "左手防具,包括盾与手套。"
  83.     when 4
  84.       @text = "头部防具,上可防风霜雨雪下可防鸡蛋番茄。"
  85.     when 5
  86.       @text = "身体防具,包括铠甲,长袍与羽衣……不是雨衣啊。"
  87.     when 6
  88.       @text = "装饰物品,目前只有指环,以后……还是只有指环。"
  89.     when 7
  90.       @text = "特殊物品,有些是通关道具,还有一些只是纪念品。"
  91.     when 8
  92.       @text = "闲者之石,顾名思义,是闲着没事做的人发明的晶石。"
  93.     end
  94.     @help_window.set_text(@text)
  95.   end
  96. end

  97. #==============================================================================
  98. # ■ Window_Item
  99. #------------------------------------------------------------------------------
  100. #  アイテム画面で、所持アイテムの一覧を表示するウィンドウです。
  101. #==============================================================================

  102. class Harts_Window_ItemList < Window_Selectable
  103.   #--------------------------------------------------------------------------
  104.   # ● オブジェクト初期化
  105.   #--------------------------------------------------------------------------
  106.   def initialize
  107.     super(170, 10, 460, 390)
  108.     refresh
  109.     self.index = 0
  110.   end
  111.   #--------------------------------------------------------------------------
  112.   # ● アイテムの取得
  113.   #--------------------------------------------------------------------------
  114.   def item
  115.     return @data[self.index]
  116.   end
  117.   #--------------------------------------------------------------------------
  118.   # ● リフレッシュ
  119.   #--------------------------------------------------------------------------
  120.   def refresh
  121.     if self.contents != nil
  122.       self.contents.dispose
  123.       self.contents = nil
  124.     end
  125.     @data = []
  126.   end
  127.   #--------------------------------------------------------------------------
  128.   # ● アイテム一覧設定
  129.   # command : 選択中のコマンド
  130.   #--------------------------------------------------------------------------
  131.   def set_item(command)
  132.     refresh
  133.     case command
  134.     when 0
  135.       for i in 1...$data_items.size
  136.         if ($data_items[i].occasion == 0 or $data_items[i].occasion == 2) and $game_party.item_number(i) > 0
  137.           @data.push($data_items[i])
  138.         end
  139.       end
  140.     when 1
  141.       for i in 1...$data_items.size
  142.         if ($data_items[i].occasion == 1 and $game_party.item_number(i) > 0)
  143.           @data.push($data_items[i])
  144.         end
  145.       end
  146.     when 2
  147.       for i in 1...$data_weapons.size
  148.         if $game_party.weapon_number(i) > 0
  149.           @data.push($data_weapons[i])
  150.         end
  151.       end
  152.     when 3
  153.       for i in 1...$data_armors.size
  154.         if $data_armors[i].kind == 0 and $game_party.armor_number(i) > 0
  155.           @data.push($data_armors[i])
  156.         end
  157.       end
  158.     when 4
  159.       for i in 1...$data_armors.size
  160.         if $data_armors[i].kind == 1 and $game_party.armor_number(i) > 0
  161.           @data.push($data_armors[i])
  162.         end
  163.       end
  164.     when 5
  165.       for i in 1...$data_armors.size
  166.         if $data_armors[i].kind == 2 and $game_party.armor_number(i) > 0
  167.           @data.push($data_armors[i])
  168.         end
  169.       end
  170.     when 6
  171.       for i in 1...$data_armors.size
  172.         if $data_armors[i].kind == 3 and $game_party.armor_number(i) > 0
  173.           @data.push($data_armors[i])
  174.         end
  175.       end
  176.     when 7
  177.       for i in 1...$data_items.size
  178.         if $data_items[i].occasion == 3 and $game_party.item_number(i) > 0
  179.           @data.push($data_items[i])
  180.         end
  181.       end
  182.     when 8
  183.       for i in 1...$data_items.size
  184.         if $data_items[i].occasion == 4 and $game_party.item_number(i) > 0
  185.           @data.push($data_items[i])
  186.         end
  187.       end
  188.     end
  189.     # 項目数が 0 でなければビットマップを作成し、全項目を描画
  190.     @item_max = @data.size
  191.     if @item_max > 0
  192.       self.contents = Bitmap.new(width - 32, row_max * 32)
  193.       self.contents.clear
  194.       for i in 0...@item_max
  195.         draw_item(i)
  196.       end
  197.     end
  198.   end
  199.   #--------------------------------------------------------------------------
  200.   # ● 種類別アイテム数の取得
  201.   #--------------------------------------------------------------------------
  202.   def item_number
  203.     return @item_max
  204.   end
  205.   #--------------------------------------------------------------------------
  206.   # ● 項目の描画
  207.   # index : 項目番号
  208.   #--------------------------------------------------------------------------
  209.   def draw_item(index)
  210.     item = @data[index]
  211.     case item
  212.     when RPG::Item
  213.       number = $game_party.item_number(item.id)
  214.     when RPG::Weapon
  215.       number = $game_party.weapon_number(item.id)
  216.     when RPG::Armor
  217.       number = $game_party.armor_number(item.id)
  218.     end
  219.     if item.is_a?(RPG::Item) and
  220.       $game_party.item_can_use?(item.id)
  221.       self.contents.font.color = normal_color
  222.     else
  223.       self.contents.font.color = disabled_color
  224.     end
  225.     x = 4
  226.     y = index * 32
  227.     bitmap = RPG::Cache.icon(item.icon_name)
  228.     opacity = self.contents.font.color == normal_color ? 255 : 128
  229.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  230.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  231.     self.contents.draw_text(x + 350, y, 16, 32, ":", 1)
  232.     self.contents.draw_text(x + 366, y, 24, 32, number.to_s, 2)
  233.   end
  234.   #--------------------------------------------------------------------------
  235.   # ● ヘルプテキスト更新
  236.   #--------------------------------------------------------------------------
  237.   def update_help
  238.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  239.   end
  240. end

  241. #==============================================================================
  242. # ■ Harts_Scene_Item
  243. #------------------------------------------------------------------------------
  244. #  アイテム画面の処理を行うクラスです。再定義
  245. #==============================================================================

  246. class Scene_Item
  247.   #--------------------------------------------------------------------------
  248.   # ● メイン処理
  249.   #--------------------------------------------------------------------------
  250.   def main
  251.     # タイトルウィンドウを作成
  252.     @itemtitle_window = Harts_Window_ItemTitle.new
  253.     #コマンドウィンドウを作成
  254.     @itemcommand_window = Harts_Window_ItemCommand.new
  255.     @command_index = @itemcommand_window.index
  256.     #アイテムウィンドウを作成
  257.     @itemlist_window = Harts_Window_ItemList.new
  258.     @itemlist_window.active = false
  259.     #ヘルプウィンドウを作成
  260.     @help_window = Window_Help.new
  261.     @help_window.x = 10
  262.     @help_window.y = 410
  263.     # ヘルプウィンドウを関連付け
  264.     @itemcommand_window.help_window = @help_window
  265.     @itemlist_window.help_window = @help_window
  266.     # ターゲットウィンドウを作成 (不可視?非アクティブに設定)
  267.     @target_window = Window_Target.new
  268.     @target_window.visible = false
  269.     @target_window.active = false
  270.     # アイテムウィンドウ内容表示
  271.     @itemlist_window.set_item(@command_index)
  272.     # トランジション実行
  273.     Graphics.transition
  274.     # メインループ
  275.     loop do
  276.       # ゲーム画面を更新
  277.       Graphics.update
  278.       # 入力情報を更新
  279.       Input.update
  280.       # フレーム更新
  281.       update
  282.       # 画面が切り替わったらループを中断
  283.       if $scene != self
  284.         break
  285.       end
  286.     end
  287.     # トランジション準備
  288.     Graphics.freeze
  289.     # ウィンドウを解放
  290.     @itemtitle_window.dispose
  291.     @itemcommand_window.dispose
  292.     @itemlist_window.dispose
  293.     @help_window.dispose
  294.     @target_window.dispose
  295.   end
  296.   #--------------------------------------------------------------------------
  297.   # ● フレーム更新
  298.   #--------------------------------------------------------------------------
  299.   def update
  300.     # ウィンドウを更新
  301.     @itemtitle_window.update
  302.     @itemcommand_window.update
  303.     @itemlist_window.update
  304.     @help_window.update
  305.     @target_window.update
  306.     if @command_index != @itemcommand_window.index
  307.       @command_index = @itemcommand_window.index
  308.       @itemlist_window.set_item(@command_index)
  309.     end
  310.     # コマンドウィンドウがアクティブの場合: update_itemcommand を呼ぶ
  311.     if @itemcommand_window.active
  312.       update_itemcommand
  313.       return
  314.     end
  315.     # アイテムウィンドウがアクティブの場合: update_itemlist を呼ぶ
  316.     if @itemlist_window.active
  317.       update_itemlist
  318.       return
  319.     end
  320.     # ターゲットウィンドウがアクティブの場合: update_target を呼ぶ
  321.     if @target_window.active
  322.       update_target
  323.       return
  324.     end
  325.   end
  326.   #--------------------------------------------------------------------------
  327.   # ● フレーム更新 (コマンドウィンドウがアクティブの場合)
  328.   #--------------------------------------------------------------------------
  329.   def update_itemcommand
  330.   # B ボタンが押された場合
  331.   if Input.trigger?(Input::B)
  332.   # キャンセル SE を演奏
  333.   $game_system.se_play($data_system.cancel_se)
  334.   # メニュー画面に切り替え
  335.   $scene = Scene_Menu.new(0)
  336.   return
  337.   end
  338.   # C ボタンが押された場合
  339.   if Input.trigger?(Input::C)
  340.   # 選択中のコマンドのアイテムがない場合
  341.   if @itemlist_window.item_number == 0
  342.   # ブザー SE を演奏
  343.   $game_system.se_play($data_system.buzzer_se)
  344.   return
  345.   end
  346.   # 決定 SE を演奏
  347.   $game_system.se_play($data_system.decision_se)
  348.   # アイテムウィンドウをアクティブにする
  349.   @itemcommand_window.active = false
  350.   @itemlist_window.active = true
  351.   @itemlist_window.index = 0
  352.   return
  353.   end
  354.   end
  355.   #--------------------------------------------------------------------------
  356.   # ● フレーム更新 (アイテムウィンドウがアクティブの場合)
  357.   #--------------------------------------------------------------------------
  358.   def update_itemlist
  359.     # B ボタンが押された場合
  360.     if Input.trigger?(Input::B)
  361.       # キャンセル SE を演奏
  362.       $game_system.se_play($data_system.cancel_se)
  363.       # アイテムウィンドウをアクティブにする
  364.       @itemcommand_window.active = true
  365.       @itemlist_window.active = false
  366.       @itemlist_window.index = 0
  367.       @itemcommand_window.index = @command_index
  368.       return
  369.     end
  370.     # C ボタンが押された場合
  371.     if Input.trigger?(Input::C)
  372.       # アイテムウィンドウで現在選択されているデータを取得
  373.       @item = @itemlist_window.item
  374.       # 使用アイテムではない場合
  375.       unless @item.is_a?(RPG::Item)
  376.         # ブザー SE を演奏
  377.         $game_system.se_play($data_system.buzzer_se)
  378.         return
  379.       end
  380.       # 使用できない場合
  381.       unless $game_party.item_can_use?(@item.id)
  382.         # ブザー SE を演奏
  383.         $game_system.se_play($data_system.buzzer_se)
  384.         return
  385.       end
  386.       # 決定 SE を演奏
  387.       $game_system.se_play($data_system.decision_se)
  388.       # 効果範囲が味方の場合
  389.       if @item.scope >= 3
  390.         # ターゲットウィンドウをアクティブ化
  391.         @itemlist_window.active = false
  392.         @target_window.x = 304
  393.         @target_window.visible = true
  394.         @target_window.active = true
  395.         # 効果範囲 (単体/全体) に応じてカーソル位置を設定
  396.         if @item.scope == 4 || @item.scope == 6
  397.           @target_window.index = -1
  398.         else
  399.           @target_window.index = 0
  400.         end
  401.         # 効果範囲が味方以外の場合
  402.       else
  403.         # コモンイベント ID が有効の場合
  404.         if @item.common_event_id > 0
  405.           # コモンイベント呼び出し予約
  406.           $game_temp.common_event_id = @item.common_event_id
  407.           # アイテムの使用時 SE を演奏
  408.           $game_system.se_play(@item.menu_se)
  409.           # 消耗品の場合
  410.             if @item.consumable
  411.               # 使用したアイテムを 1 減らす
  412.               $game_party.lose_item(@item.id, 1)
  413.               # アイテムウィンドウの項目を再描画
  414.               @itemlist_window.draw_item(@itemlist_window.index)
  415.             end
  416.           # マップ画面に切り替え
  417.           $scene = Scene_Map.new
  418.           return
  419.         end
  420.       end
  421.       return
  422.     end
  423.   end
  424.   #--------------------------------------------------------------------------
  425.   # ● フレーム更新 (ターゲットウィンドウがアクティブの場合)
  426.   #--------------------------------------------------------------------------
  427.   def update_target
  428.     # B ボタンが押された場合
  429.     if Input.trigger?(Input::B)
  430.       # キャンセル SE を演奏
  431.       $game_system.se_play($data_system.cancel_se)
  432.       # アイテム切れなどで使用できなくなった場合
  433.       unless $game_party.item_can_use?(@item.id)
  434.         # アイテムウィンドウの内容を再作成
  435.         @itemlist_window.refresh
  436.       end
  437.       # ターゲットウィンドウを消去
  438.       @itemlist_window.active = true
  439.       @target_window.visible = false
  440.       @target_window.active = false
  441.       @itemlist_window.set_item(@command_index)
  442.       return
  443.     end
  444.     # C ボタンが押された場合
  445.     if Input.trigger?(Input::C)
  446.       # アイテムを使い切った場合
  447.       if $game_party.item_number(@item.id) == 0
  448.         # ブザー SE を演奏
  449.         $game_system.se_play($data_system.buzzer_se)
  450.         return
  451.       end
  452.       # ターゲットが全体の場合
  453.       if @target_window.index == -1
  454.         # パーティ全体にアイテムの使用効果を適用
  455.         used = false
  456.         for i in $game_party.actors
  457.           used |= i.item_effect(@item)
  458.         end
  459.       end
  460.       # ターゲットが単体の場合
  461.       if @target_window.index >= 0
  462.         # ターゲットのアクターにアイテムの使用効果を適用
  463.         target = $game_party.actors[@target_window.index]
  464.         used = target.item_effect(@item)
  465.       end
  466.       # アイテムを使った場合
  467.       if used
  468.         # アイテムの使用時 SE を演奏
  469.         $game_system.se_play(@item.menu_se)
  470.         # 消耗品の場合
  471.         if @item.consumable
  472.           # 使用したアイテムを 1 減らす
  473.           $game_party.lose_item(@item.id, 1)
  474.           # アイテムウィンドウの項目を再描画
  475.           @itemlist_window.draw_item(@itemlist_window.index)
  476.           @itemlist_window.set_item(@command_index)
  477.         end
  478.         # ターゲットウィンドウの内容を再作成
  479.         @target_window.refresh
  480.         # 全滅の場合
  481.         if $game_party.all_dead?
  482.           # ゲームオーバー画面に切り替え
  483.           $scene = Scene_Gameover.new
  484.           return
  485.         end
  486.         # コモンイベント ID が有効の場合
  487.         if @item.common_event_id > 0
  488.           # コモンイベント呼び出し予約
  489.           $game_temp.common_event_id = @item.common_event_id
  490.           # マップ画面に切り替え
  491.           $scene = Scene_Map.new
  492.           return
  493.         end
  494.       end
  495.       # アイテムを使わなかった場合
  496.       unless used
  497.         # ブザー SE を演奏
  498.         $game_system.se_play($data_system.buzzer_se)
  499.       end
  500.     return
  501.     end
  502.   end
  503. end


  504. #==============================================================================
  505. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  506. #==============================================================================
复制代码
囡囚囨囚囨図囨囧
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
54 小时
注册时间
2012-1-24
帖子
73
4
发表于 2012-1-27 12:47:47 | 只看该作者
↑————不是对的吗,?

评分

参与人数 1星屑 -40 收起 理由
「旅」 -40 提问区是禁止灌水的……0 0b

查看全部评分

!加油吧!諾丶爱❤~!
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-2-20 16:52

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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