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

Project1

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

简单物品分类的使用方法

 关闭 [复制链接]
头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-5-22
帖子
78
跳转到指定楼层
1
发表于 2008-6-19 18:24:29 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-5-22
帖子
78
2
 楼主| 发表于 2008-6-19 22:05:20 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv3.寻梦者

永久的旅行者

梦石
1
星屑
110
在线时间
404 小时
注册时间
2006-12-13
帖子
3091

开拓者贵宾第3届短篇游戏大赛主流游戏组季军第5届短篇游戏比赛季军

3
发表于 2008-6-19 22:19:36 | 只看该作者
这个脚本的物品分类都是在数据库里面定义的,
在游戏里面,当得到那样物品时,就会根据在数据库分类好的种类分配好。

如果是要游戏中让玩家自行分配的话...我想是需要别的种类脚本...等待高手来搭救吧...
回复 支持 反对

使用道具 举报

Lv1.梦旅人

蚂蚁卡卡

梦石
0
星屑
116
在线时间
66 小时
注册时间
2007-12-16
帖子
3081
4
发表于 2008-6-20 01:19:14 | 只看该作者
  1. # ————————————————————————————————————
  2. # 本脚本来自www.66rpg.com,转载请保留此信息
  3. # ————————————————————————————————————

  4. #==============================================================================
  5. # ■ Harts_Window_ItemTitle
  6. #------------------------------------------------------------------------------
  7. #  アイテム画面で、タイトルを表示するウィンドウ。
  8. #==============================================================================

  9. class Harts_Window_ItemTitle < Window_Base
  10.   #--------------------------------------------------------------------------
  11.   # ● オブジェクト初期化
  12.   #--------------------------------------------------------------------------
  13.   def initialize
  14.   # picture = "Graphics/Battlebacks/北惧.jpg"
  15.   # @sprite = sprite.new
  16.   # @sprite.bitmap = Bitmap.new(picture)

  17.    # @bitmap1=Bitmap.new("Graphics/Battlebacks/北惧.jpg")
  18.    # @src_rect1=Rect.new(0,0,@bitmap1.width,@bitmap1.height)
  19.     super(0, 0, 160, 64)
  20.     self.contents = Bitmap.new(width - 32, height - 32)
  21.     self.contents.clear
  22.     #self.contents.blt(x,y,@bitmap1,@src_rect1)
  23.     self.contents.font.color = normal_color
  24.     self.contents.draw_text(4, 0, 120, 32, $data_system.words.item, 1)
  25.   end
  26. end

  27. #==============================================================================
  28. # ■ Harts_Window_ItemCommand
  29. #------------------------------------------------------------------------------
  30. #  アイテムの種別選択を行うウィンドウです。
  31. #==============================================================================

  32. class Harts_Window_ItemCommand < Window_Selectable
  33.   #--------------------------------------------------------------------------
  34.   # ● オブジェクト初期化
  35.   #--------------------------------------------------------------------------
  36.   def initialize
  37.    super(0, 64, 160, 160+32)
  38.     self.contents = Bitmap.new(width - 32, height - 32)
  39.     @item_max = 5
  40.     @commands = ["药物", "食物", "特殊道具","装备","剧情道具"]
  41.     refresh
  42.     self.index = 0
  43.   end
  44.   #--------------------------------------------------------------------------
  45.   # ● リフレッシュ
  46.   #--------------------------------------------------------------------------
  47.   def refresh
  48.     self.contents.clear
  49.     for i in 0...@item_max
  50.     draw_item(i, normal_color)
  51.     end
  52.   end
  53.   #--------------------------------------------------------------------------
  54.   # ● 項目の描画
  55.   # index : 項目番号
  56.   # color : 文字色
  57.   #--------------------------------------------------------------------------
  58.   def draw_item(index, color)
  59.     self.contents.font.color = color
  60.     y = index * 32
  61.     self.contents.draw_text(4, y, 128, 32, @commands[index])
  62.   end
  63.   #--------------------------------------------------------------------------
  64.   # ● ヘルプテキスト更新
  65.   #--------------------------------------------------------------------------
  66.   def update_help
  67.     case self.index
  68.     when 0
  69.       @text = @commands[0]
  70.     when 1
  71.       @text = @commands[1]
  72.     when 2
  73.       @text = @commands[2]
  74.     when 3
  75.       @text = @commands[3]
  76.     when 4
  77.       @text = @commands[4]
  78.     when 5
  79.       @text = @commands[5]
  80.     when 6
  81.       @text = @commands[6]
  82.     when 7
  83.       @text = @commands[7]
  84.     when 8
  85.       @text = @commands[8]
  86.     end
  87.     @help_window.set_text(@text)
  88.   end
  89. end

  90. #==============================================================================
  91. # ■ Window_Item
  92. #------------------------------------------------------------------------------
  93. #  アイテム画面で、所持アイテムの一覧を表示するウィンドウです。
  94. #==============================================================================

  95. class Harts_Window_ItemList < Window_Selectable
  96.   #--------------------------------------------------------------------------
  97.   # ● オブジェクト初期化
  98.   #--------------------------------------------------------------------------
  99.   def initialize
  100.     super(160, 0, 480, 416)
  101.    
  102.     refresh
  103.     self.index = 0
  104.   end
  105.   #--------------------------------------------------------------------------
  106.   # ● アイテムの取得
  107.   #--------------------------------------------------------------------------
  108.   def item
  109.     return @data[self.index]
  110.   end
  111.   #--------------------------------------------------------------------------
  112.   # ● リフレッシュ
  113.   #--------------------------------------------------------------------------
  114.   def refresh
  115.     if self.contents != nil
  116.       self.contents.dispose
  117.       self.contents = nil
  118.     end
  119.     @data = []
  120.   end
  121.   #--------------------------------------------------------------------------
  122.   # ● アイテム一覧設定
  123.   # command : 選択中のコマンド
  124.   #--------------------------------------------------------------------------
  125.   def set_item(command)
  126.     refresh
  127.     case command  
  128.     when 0            #药品,特点是分散度为0
  129.       for i in 1...$data_items.size
  130.         if ($data_items[i].variance == 0 and $game_party.item_number(i) > 0)
  131.           @data.push($data_items[i])
  132.         end
  133.       end
  134.     when 1            #食物类,特点是分散度为1  
  135.       for i in 1...$data_items.size
  136.         if ($data_items[i].variance == 1 and $game_party.item_number(i) > 0)
  137.           @data.push($data_items[i])
  138.         end
  139.       end
  140.     when 2            #杂货类,特点是分散度为2
  141.       for i in 1...$data_items.size
  142.         if ($data_items[i].variance == 2 and $game_party.item_number(i) > 0)
  143.           @data.push($data_items[i])
  144.         end
  145.       end
  146.     when 3            #各种装备:根据原本类push
  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.       for i in 1...$data_armors.size
  153.         if $game_party.armor_number(i) > 0
  154.           @data.push($data_armors[i])
  155.         end
  156.       end
  157.     when 4            #剧情:特点是分散度为3
  158.       for i in 1...$data_items.size
  159.         if ($data_items[i].variance == 3 and $game_party.item_number(i) > 0)
  160.           @data.push($data_items[i])
  161.         end
  162.       end
  163.    
  164.     end
  165.     # 項目数が 0 でなければビットマップを作成し、全項目を描画
  166.     @item_max = @data.size
  167.     if @item_max > 0
  168.       self.contents = Bitmap.new(width - 32, row_max * 32)
  169.       self.contents.clear
  170.       for i in 0...@item_max
  171.         draw_item(i)
  172.       end
  173.     end
  174.   end
  175.   #--------------------------------------------------------------------------
  176.   # ● 種類別アイテム数の取得
  177.   #--------------------------------------------------------------------------
  178.   def item_number
  179.     return @item_max
  180.   end
  181.   #--------------------------------------------------------------------------
  182.   # ● 項目の描画
  183.   # index : 項目番号
  184.   #--------------------------------------------------------------------------
  185.   def draw_item(index)
  186.     item = @data[index]
  187.     case item
  188.     when RPG::Item
  189.       number = $game_party.item_number(item.id)
  190.     when RPG::Weapon
  191.       number = $game_party.weapon_number(item.id)
  192.     when RPG::Armor
  193.       number = $game_party.armor_number(item.id)
  194.     end
  195.     if item.is_a?(RPG::Item) and
  196.       $game_party.item_can_use?(item.id)
  197.       self.contents.font.color = normal_color
  198.     else
  199.       self.contents.font.color = disabled_color
  200.     end
  201.     x = 4
  202.     y = index * 32
  203.     bitmap = RPG::Cache.icon(item.icon_name)
  204.     opacity = self.contents.font.color == normal_color ? 255 : 128
  205.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  206.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  207.     self.contents.draw_text(x + 400, y, 16, 32, ":", 1)
  208.     self.contents.draw_text(x + 416, y, 24, 32, number.to_s, 2)
  209.   end
  210.   #--------------------------------------------------------------------------
  211.   # ● ヘルプテキスト更新
  212.   #--------------------------------------------------------------------------
  213.   def update_help
  214.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  215.   end
  216. end

  217. #==============================================================================
  218. # ■ Harts_Scene_Item
  219. #------------------------------------------------------------------------------
  220. #  アイテム画面の処理を行うクラスです。再定義
  221. #==============================================================================

  222. class Scene_Item
  223.   #--------------------------------------------------------------------------
  224.   # ● メイン処理
  225.   #--------------------------------------------------------------------------
  226.   def main
  227.    picture = "Graphics/Battlebacks/北惧.jpg"
  228.    @sprite = Sprite.new
  229.    @sprite.bitmap = Bitmap.new(picture)

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

复制代码

这个是 我结合几个分类脚本改的
在Graphics/Battlebacks里加一张 名字 北惧.jpg的640*480的图 (为了好看些)
分类是自己手动设定 数据库里 物品 分散度(右下角)
0是食物 1是药物 2是杂货类 3是剧情物品
在注释里写了 你看看
《隋唐乱》完整解密版点击进入
米兰,让我怎么说离开……

曾经我也是一个有志青年,直到我膝盖中了一箭……

《隋唐乱》博客地址
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-5-22
帖子
78
5
 楼主| 发表于 2008-6-20 03:36:49 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-5-22
帖子
78
6
 楼主| 发表于 2008-6-20 03:38:35 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv3.寻梦者

永久的旅行者

梦石
1
星屑
110
在线时间
404 小时
注册时间
2006-12-13
帖子
3091

开拓者贵宾第3届短篇游戏大赛主流游戏组季军第5届短篇游戏比赛季军

7
发表于 2008-6-20 03:42:09 | 只看该作者
以下引用取个名字好难于2008-6-19 19:36:49的发言:
就是说在数据库里怎么设定啊,而不是在游戏里面设定,呵呵,是不是在物品描述里加什么
符号啊?能不能举个实际例子?

打开范例的数据库,看看那些物品有什么不同...
(我忘了是名字,还是属性那里了...)
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-5-22
帖子
78
8
 楼主| 发表于 2008-6-20 03:49:17 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv3.寻梦者

永久的旅行者

梦石
1
星屑
110
在线时间
404 小时
注册时间
2006-12-13
帖子
3091

开拓者贵宾第3届短篇游戏大赛主流游戏组季军第5届短篇游戏比赛季军

9
发表于 2008-6-20 04:03:22 | 只看该作者
你可以把那个帖子的连接放出来吗?
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-5-22
帖子
78
10
 楼主| 发表于 2008-6-20 04:08:07 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-14 16:01

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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