查看: 5240|回复: 4

[RMVA发布] 任務「佈告欄」系統

[复制链接]
梦石
0
星屑
50
在线时间
78 小时
注册时间
2011-6-29
回帖
11
发表于 2012-11-23 19:23:23 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

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

×
本帖最后由 feizhaodan 于 2012-11-23 22:31 编辑

本系統並非一般的觀看當前任務的系統
而是類似魔物獵人的接取任務的系統
是我接觸RGSS之後第一個作品
保證有BUG
應該用了很多很矬很土法煉鋼的方法
需要改進的部份也很多,麻煩各位前輩多多指教

使用方法請參考系統內註解

P1.png

P2.png

P3.png


  1. #==============================================================================
  2. # ■ Quests
  3. #------------------------------------------------------------------------------
  4. #  用於設定任務內容的模組。
  5. #==============================================================================

  6. =begin
  7. 使用說明:
  8. 在本模組下設定好所有遊戲中的任務的資料,
  9. 將下方兩個#---之間的腳本複製一份就能創造新任務,
  10. @name = 任務名稱
  11. @info = 任務的簡介,可使用一般對話的指令,前面多加一個\。
  12. [url=home.php?mod=space&uid=13302]@exp[/url] = 顯示的經驗值
  13. [url=home.php?mod=space&uid=236945]@gold[/url] = 顯示的報酬金
  14. @loop_b = 任務可否重覆執行(true or false)
  15. @comev_id = 對應的公用事件編號

  16. 本系統只處理任務佈告欄的部份,
  17. 接受任務之後會對應到公用事件,請用公用事件設定接下來的行動。

  18. 腳本功能:
  19. 在事件中使用自訂腳本寫入以下語法:

  20. 設定任務可用 - $game_party.get_quest("任務名稱")
  21. 設定任務禁用 - $game_party.lost_quest("任務名稱")
  22. 設定任務完成 - $game_party.finish_quest("任務名稱")

  23. 本系統任務是以名稱當做標籤,而非常見的編號
  24. 一開始使用可能會覺得不習慣
  25. 不過遊戲內容一但變得龐大之後應該會感到方便。

  26. 另外在任務列表下按shift可以選擇顯示任務的類別。
  27. 在任務數量增加之後應該會變得方便(對玩家而言)。
  28. =end

  29. module Quests
  30.   Quest_list = Array.new
  31.   $game_quest = nil

  32.     def create_quest
  33.       h = {'name' => @name,
  34.               'info' => @info,
  35.               'exp' => @exp,
  36.               'gold' => @gold,
  37.               'loop' => @loop_b,
  38.               'usability' => false,
  39.               'finished' => false,
  40.               'ev_id' => @comev_id}  
  41.       Quest_list.push h
  42.     end  
  43.     module_function :create_quest

  44. #---
  45.   @name = "今晚吃香菇濃湯"
  46.   @info = "委託人:忙碌的村婦
  47. 今天晚上想要煮好喝的香菇濃湯
  48. 給心愛的老公,可是香菇居然用
  49. 完了,請幫我摘一些吧。

  50. PS: 煮好會分你一份"
  51.   @exp = 5
  52.   @gold = 10
  53.   @loop_b = false
  54.   @comev_id = 1

  55. create_quest
  56. #---
  57.   @name = "盜賊出沒"
  58.   @info = "委託人:村長
  59. 村子西邊的山上居然出現了\\c[2]盜賊\\c[0]
  60. !!不管是誰都好,請\\c[2]討伐\\c[0]他們
  61. 吧!"
  62.   @exp = 20
  63.   @gold = 50
  64.   @loop_b = true
  65.   @comev_id = 2

  66.   create_quest
  67.   
  68. #---
  69.   @name = "戀人的遺願"
  70.   @info = "委託人:道具店老闆希莎
  71. 我的未婚夫在一次冒險中喪生了
  72. ,希望你能幫我將他的屍體帶回
  73. 來,讓我能好好安葬他。他曾經
  74. 用過劍就讓你使用,將他的意志
  75. 傳承下去吧。
  76. 特殊獎勵:\\i[387]絕世好劍
  77.   "
  78.   @exp = 40
  79.   @gold = 0
  80.   @loop_b = false
  81.   @comev_id = 3

  82.   create_quest   
  83.    
  84. #---
  85.   @name = "快來抓我!"
  86.   @info = "委託人:小女孩茉莉
  87. 我可是鎮上的捉迷藏高手呢!如
  88. 果你有辦法在時間內抓到我的話
  89. ,就給你糖果!
  90. "
  91.   @exp = 3
  92.   @gold = 10
  93.   @loop_b = true
  94.   @comev_id = 4

  95.   create_quest   
  96.    
  97.    
  98. end
复制代码

  1. #==============================================================================
  2. # ■ Window_QuestType
  3. #------------------------------------------------------------------------------
  4. #  任務列表顯示方式的選擇視窗。
  5. #==============================================================================

  6. class Window_QuestType < Window_Command
  7.   #--------------------------------------------------------------------------
  8.   # ● 物件初始化
  9.   #--------------------------------------------------------------------------
  10.   def initialize
  11.     super(36, 150)
  12.     deactivate
  13.     self.openness = 0
  14.   end
  15.   #--------------------------------------------------------------------------
  16.   # ● 項目的作成
  17.   #--------------------------------------------------------------------------
  18.   def make_command_list
  19.     add_command("全部",  :all_quests)
  20.     add_command("未完成", :unfinished_quests)
  21.     add_command("循環", :loop_quests)
  22.     add_command("取消", :cancel)
  23.   end
  24. end
复制代码

  1. #==============================================================================
  2. # ■ Window_QuestList
  3. #------------------------------------------------------------------------------
  4. #  任務列表選擇視窗。
  5. #==============================================================================


  6. class Window_QuestList < Window_Selectable
  7.   attr_accessor :type
  8.   attr_reader :quest_list
  9.   #--------------------------------------------------------------------------
  10.   # ● 物件初始化
  11.   #--------------------------------------------------------------------------
  12.   def initialize
  13.     super(12,48,160, 300)
  14.     create_contents
  15.     @type = 0
  16.     @index = 0
  17.     activate
  18.   end
  19.   #--------------------------------------------------------------------------
  20.   # ● 顯示類型的設定
  21.   #--------------------------------------------------------------------------
  22.   def set_type(n)
  23.     @type = n
  24.     set_item_max
  25.   end
  26.   #--------------------------------------------------------------------------
  27.   # ● 項目數的取得
  28.   #--------------------------------------------------------------------------
  29.   def item_max
  30.     return @item_max != nil ? @item_max : 0
  31.   end
  32.   #--------------------------------------------------------------------------
  33.   # ● 項目數的計算
  34.   #--------------------------------------------------------------------------
  35.   def set_item_max
  36.     @quest_list = []
  37.     case @type
  38.     when 0  #所有任務
  39.       p = []
  40.       q = []
  41.       Quests::Quest_list.each { |h|
  42.         if h['usability']
  43. #~           @quest_list.unshift h if h['finished'] == false || h['loop']
  44. #~           @quest_list.push h if h['finished'] && h['loop'] == false
  45.           p.push h if h['finished'] == false || h['loop']
  46.           q.push h if h['finished'] && h['loop'] == false
  47.         end
  48.       }
  49.       @quest_list = p + q
  50.     when 1 #未完成任務
  51.       Quests::Quest_list.each { |h|
  52.         if h['usability'] && h['finished'] == false
  53.           @quest_list.push h
  54.         end
  55.       }
  56.     when 2 #循環任務
  57.         Quests::Quest_list.each { |h|
  58.         if h['usability'] && h['loop']
  59.           @quest_list.push h
  60.         end
  61.       }
  62.     end
  63.     @item_max = @quest_list.size
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # ● 刷新
  67.   #--------------------------------------------------------------------------
  68.   def refresh
  69.     set_item_max
  70.     super
  71.   end
  72.   #--------------------------------------------------------------------------
  73.   # ● 項目的描畫
  74.   #--------------------------------------------------------------------------
  75.   def draw_item(index)
  76.     text = ""
  77.     if @quest_list[index] != nil
  78.       text = @quest_list[index]['name']
  79.     end
  80.     if @quest_list[index]['loop']
  81.       change_color(system_color)
  82.     elsif @quest_list[index]['finished']
  83.       change_color(gauge_back_color)
  84.     else
  85.       change_color(normal_color)
  86.     end
  87.     draw_text(item_rect_for_text(index), text)
  88.   end
  89.   #--------------------------------------------------------------------------
  90.   # ● 獲取項目的繪制矩形(內容用)
  91.   #--------------------------------------------------------------------------
  92.   def item_rect_for_text(index)
  93.     rect = item_rect(index)
  94.     rect.x += 4
  95.     rect.width = 160
  96.     rect
  97.   end
  98. end
复制代码

  1. #==============================================================================
  2. # ■ Window_QuestInfo
  3. #------------------------------------------------------------------------------
  4. #  任務列表顯示內容的視窗。
  5. #==============================================================================

  6. class Window_QuestInfo < Window_Base
  7. #~   attr_accessor :list_index
  8.   attr_accessor :list_window
  9.   #--------------------------------------------------------------------------
  10.   # ● 物件初始化
  11.   #--------------------------------------------------------------------------
  12.   def initialize
  13.     super(184,24,Graphics.width - 184,Graphics.height - 48)
  14.     create_contents
  15.     @list_index = 0
  16. #~     refresh
  17.     deactivate
  18.   end
  19.   #--------------------------------------------------------------------------
  20.   # ● 刷新
  21.   #--------------------------------------------------------------------------
  22.   def refresh
  23.     contents.clear
  24.     draw_desc
  25.   end
  26.   #--------------------------------------------------------------------------
  27.   # ● 描畫內容
  28.   #--------------------------------------------------------------------------
  29.   def draw_desc
  30.     quest = @list_window.quest_list[@list_window.index]
  31.      if quest != nil
  32.        draw_text_ex( 0, 0, quest['info'])
  33.        draw_text_ex( 0, 202, "經驗值:" + quest['exp'].to_s)
  34.        draw_text_ex( 0, 226, "報酬金:" + quest['gold'].to_s)
  35.        draw_text_ex( 0, 250, "\\c[20]已完成") if quest['finished']
  36.        draw_text_ex( 0, 274, "\\c[16]可重覆進行") if quest['loop']
  37.        draw_text_ex( 0, self.height - 48, "\\c[18]確定要接受這個任務嗎?") if self.active
  38.      else
  39.        draw_text_ex( 60, 160, "目前沒有可接受任務。")
  40.      end
  41.    end
  42. end
复制代码

  1. #==============================================================================
  2. # ■ Game_Party
  3. #------------------------------------------------------------------------------
  4. #  パーティを扱うクラスです。所持金やアイテムなどの情報が含まれます。このクラ
  5. # スのインスタンスは $game_party で参照されます。
  6. #==============================================================================

  7. class Game_Party < Game_Unit
  8.   #--------------------------------------------------------------------------
  9.   # ● 以自訂腳本啟用任務的方法
  10.   #--------------------------------------------------------------------------
  11.   def get_quest(name)   
  12.     Quests::Quest_list.each do |h|
  13.       if h['name'] == name
  14.         h['usability'] = true
  15.         break
  16.       end
  17.     end
  18.   end
  19.   #--------------------------------------------------------------------------
  20.   # ● 以自訂腳本停用任務的方法
  21.   #--------------------------------------------------------------------------
  22.     def lost_quest(name)
  23.     Quests::Quest_list.each do |h|
  24.       if h['name'] == name
  25.         h['usability'] = false
  26.         break
  27.       end
  28.     end
  29.   end
  30.   #--------------------------------------------------------------------------
  31.   # ● 以自訂腳本完成任務的方法
  32.   #--------------------------------------------------------------------------
  33.     def finish_quest(name)
  34.     Quests::Quest_list.each do |h|
  35.       if h['name'] == name
  36.         h['finished'] = true
  37.         break
  38.       end
  39.     end
  40.   end
  41. end
复制代码

  1. #==============================================================================
  2. # ■ Scene_Quest
  3. #------------------------------------------------------------------------------
  4. #  處理任務場景的類。
  5. #==============================================================================

  6. class Scene_Quest < Scene_Base
  7.   #--------------------------------------------------------------------------
  8.   # ● 開始處理
  9.   #--------------------------------------------------------------------------
  10.   def start
  11.     super
  12.     create_list_window
  13.     create_info_window
  14.     create_type_window
  15.     create_background
  16.     create_check_window if $game_quest != nil
  17.   end
  18.   #--------------------------------------------------------------------------
  19.   # ● 刷新
  20.   #--------------------------------------------------------------------------
  21.   def update
  22.     super
  23.     if @info_window.active
  24.       action = 1
  25.     elsif @list_window.active
  26.       action = 2
  27.     elsif @type_window.active
  28.       action = 3
  29.     elsif @check_window.active
  30.       action = 4
  31.     end
  32.    
  33.     case action
  34.     when 1 #任務確認狀態
  35.       if Input.trigger?(:C) #按下確定的情形
  36.         Sound.play_ok
  37.         $game_quest = @list_window.quest_list[@list_window.index]
  38.         $game_temp.reserve_common_event($game_quest['ev_id'])
  39.         Audio.me_play("Audio/ME/Item")
  40.         return_scene
  41.       end     
  42.       if Input.trigger?(:B) #按下取消的情形
  43.         Sound.play_cancel
  44.         @list_window.activate
  45.         @info_window.deactivate
  46.         @info_window.refresh
  47.       end
  48.     when 2
  49.       if Input.trigger?(:A)
  50.         show_type_window
  51.       end
  52.       if Input.trigger?(:UP) || Input.trigger?(:DOWN)
  53.         @info_window.refresh
  54.       end
  55.       if Input.trigger?(:B)
  56.         return_scene
  57.       end
  58.       if Input.trigger?(:C)
  59.         if @list_window.quest_list.empty?
  60.           Sound.play_cancel
  61.           return_scene
  62.         elsif crack_quest_state
  63.           Sound.play_ok
  64.           @list_window.deactivate
  65.           @info_window.activate
  66.           @info_window.refresh
  67.         else
  68.           Sound.play_buzzer
  69.         end
  70.       end
  71.     when 3
  72.       if Input.trigger?(:B)
  73.         hide_type_window
  74.       end
  75.     when 4
  76.       if Input.trigger?(:C)
  77.         Audio.se_play("Audio/SE/Save")
  78.         $game_quest = nil
  79.         hide_check_window
  80.       end
  81.       if Input.trigger?(:B)
  82.         Sound.play_cancel
  83.         return_scene
  84.       end
  85.     end
  86.   end
  87.   #--------------------------------------------------------------------------
  88.   # ● 終了処理
  89.   #--------------------------------------------------------------------------
  90.   def terminate
  91.     super
  92.     dispose_background
  93.   end
  94.   #--------------------------------------------------------------------------
  95.   # ● 任務類型視窗的生成
  96.   #--------------------------------------------------------------------------
  97.   def create_type_window
  98.     @type_window = Window_QuestType.new
  99.     @type_window.set_handler(:all_quests, method(:view_all_quests))
  100.     @type_window.set_handler(:unfinished_quests,method(:view_unfinished_quests))
  101.     @type_window.set_handler(:loop_quests,method(:view_loop_quests))
  102.     @type_window.set_handler(:cancel,method(:hide_type_window))
  103.   end
  104.   #--------------------------------------------------------------------------
  105.   # ● 任務清單視窗的生成
  106.   #--------------------------------------------------------------------------
  107.   def create_list_window
  108.     @list_window = Window_QuestList.new
  109. #~     @list_window.set_finish(false)
  110.     @list_window.refresh
  111.   end
  112.   #--------------------------------------------------------------------------
  113.   # ● 任務內容視窗的生成
  114.   #--------------------------------------------------------------------------
  115.   def create_info_window
  116.     @info_window = Window_QuestInfo.new
  117.     @info_window.list_window=(@list_window)
  118.     @info_window.refresh
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # ● 取消任務視窗的生成
  122.   #--------------------------------------------------------------------------
  123.   def create_check_window
  124.     @check_window = Window_Base.new(128, 184, 288, 48)
  125.     @check_window.draw_text_ex( 0, 0, "已接受任務,要取消嗎?")
  126.     @check_window.openness = 0
  127.     @list_window.deactivate
  128.     @list_window.opacity = 128
  129.     @info_window.opacity = 128
  130.     @check_window.activate
  131.     @check_window.open
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   # ● 切換顯示所有任務
  135.   #--------------------------------------------------------------------------
  136.   def view_all_quests
  137.     @list_window.type=(0)
  138.     @list_window.index = 0
  139.     hide_type_window
  140.   end
  141.   #--------------------------------------------------------------------------
  142.   # ● 切換顯示未完成任務
  143.   #--------------------------------------------------------------------------
  144.   def view_unfinished_quests
  145.         @list_window.type=(1)
  146.         @list_window.index = 0
  147.         hide_type_window
  148.   end
  149.   #--------------------------------------------------------------------------
  150.   # ● 切換顯示循環任務
  151.   #--------------------------------------------------------------------------
  152.   def view_loop_quests
  153.         @list_window.type=(2)
  154.         @list_window.index = 0
  155.         hide_type_window
  156.   end
  157.   #--------------------------------------------------------------------------
  158.   # ● 隱藏任務類型視窗
  159.   #--------------------------------------------------------------------------
  160.   def hide_type_window
  161.     @list_window.refresh
  162.     @list_window.activate
  163.     @list_window.opacity = 255
  164.     @info_window.opacity = 255
  165.     @info_window.refresh
  166.     @type_window.deactivate
  167.     @type_window.close
  168. #~     @type_window.hide
  169. end
  170.   #--------------------------------------------------------------------------
  171.   # ● 隱藏任務取消視窗
  172.   #--------------------------------------------------------------------------
  173.   def hide_check_window
  174.     @list_window.activate
  175.     @list_window.opacity = 255
  176.     @info_window.opacity = 255
  177.     @check_window.deactivate
  178.     @check_window.close
  179.   end
  180.   #--------------------------------------------------------------------------
  181.   # ● 顯示任務類型視窗
  182.   #--------------------------------------------------------------------------
  183.   def show_type_window
  184.     @list_window.deactivate
  185.     @list_window.opacity = 128
  186.     @info_window.opacity = 128
  187. #~     @type_window.show
  188.     @type_window.open
  189.     @type_window.activate
  190.     @type_window.index = @list_window.type
  191.   end
  192.   #--------------------------------------------------------------------------
  193.   # ● 背景の作成
  194.   #--------------------------------------------------------------------------
  195.   def create_background
  196.     @background_sprite = Sprite.new
  197.     @background_sprite.bitmap = SceneManager.background_bitmap
  198.     @background_sprite.color.set(16, 16, 16, 128)
  199.   end
  200.   #--------------------------------------------------------------------------
  201.   # ● 背景の解放
  202.   #--------------------------------------------------------------------------
  203.   def dispose_background
  204.     @background_sprite.dispose
  205.   end
  206.   #--------------------------------------------------------------------------
  207.   # ● 確認當前任務狀態
  208.   #--------------------------------------------------------------------------
  209.   def crack_quest_state
  210.     q = @list_window.quest_list[@list_window.index]
  211.     if q['finished'] == true && q['loop'] != true
  212.       return false
  213.     else
  214.       return true
  215.     end
  216.   end
  217. end
复制代码


Questsystem.part1.rar (999 KB, 下载次数: 230)
Questsystem.part2.rar (456.81 KB, 下载次数: 210)   

评分

参与人数 3星屑 +397 收起 理由
swbxhlh + 12 塞糖
Mic_洛洛 + 45 VA党,追加奖赏
feizhaodan + 340 奖赏条例

查看全部评分

梦石
0
星屑
50
在线时间
164 小时
注册时间
2011-8-15
回帖
209
发表于 2012-11-23 22:13:51 | 显示全部楼层
或许如果LZ直接在菜单上把可重复任务和不可重复任务分开来会更好。

点评

還是看使用者想怎麼呈現吧,要修改也只要改改幾行而已  发表于 2012-11-23 23:09
回复

使用道具 举报

梦石
0
星屑
50
在线时间
206 小时
注册时间
2012-9-27
回帖
7
发表于 2012-11-24 14:35:26 | 显示全部楼层
请问下,
怎么样才能使接取任务后
不重复跳出"已接受任务,要取消吗?"
直接将create_check_window if $game_quest != nil覆盖么?

点评

對 把這句刪掉就好了  发表于 2012-11-24 16:52
回复

使用道具 举报

梦石
0
星屑
9292
在线时间
2504 小时
注册时间
2011-5-20
回帖
14521

开拓者

发表于 2012-12-1 13:07:36 | 显示全部楼层
1L附带的2个压缩包下完放到一起吗还是怎么回事···
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复

使用道具 举报

梦石
0
星屑
50
在线时间
46 小时
注册时间
2013-12-6
回帖
21
发表于 2014-1-28 17:27:37 | 显示全部楼层
装上脚本后,没有bug,但游戏卡了,卡得很慢很慢,求解决

点评

跟哪個腳本衝突到了吧,只能請你自己檢查看看  发表于 2014-2-2 03:48
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部