查看: 3969|回复: 2

[已经解决] 任務設置腳本

[复制链接]
梦石
0
星屑
50
在线时间
158 小时
注册时间
2016-1-7
回帖
102
发表于 2016-6-5 00:20:58 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 燕征 于 2016-6-5 14:30 编辑

我使用下面這個腳本來做任務列表
詳盡任務顯示介面 v2.1 By 葉子
  1. =begin
  2. --------------------------------------------------------------------------
  3. 詳盡任務顯示介面 v2.1
  4. --------------------------------------------------------------------------
  5. By 葉子

  6. 日期與更新
  7. 3-29-2006 -v1.0
  8. 4-3-2006  -v2.0
  9. -可以改變文字顏色,顯示變數,顯示圖示,顯示圖片
  10. -大幅簡化了編寫任務內容的過程,加入自動換行功能
  11. -精簡了視窗,使其還可以用作圖鑒系統、日記系統等等
  12. 4-6-2006  -v2.1
  13. -增加了獲得全部任務與刪除全部任務命令
  14. -改正通假字,修改了示例任務3
  15. --------------------------------------------------------------------------
  16. 顧名思義,就是顯示任務資料的介面
  17. 任務資料要預先在這裡設定好
  18. 下載範例工程,能説明你更快更好地掌握使用方法
  19. --------------------------------------------------------------------------
  20. 使用方法:

  21. 1、召喚任務顯示介面:$scene = Scene_Task.new

  22. 可以在事件中的“腳本”指令加入這段東西,又或者修改 Scene_Menu 來增加一個顯示
  23. 任務的選項。如果是修改 Scene_Menu 增加選項的話,在腳本倒數第30行左右,
  24. 把 $scene = Scene_Map.new 修改成 $scene = Scene_Menu.new(任務介面index)

  25. 2、設置任務資料

  26.   2.1、相關內容解析
  27.   
  28.   所有內容文字必須用雙引號括住
  29.   
  30.   名稱:任務的名字(顯示在左邊視窗中),大小為208×32,如果全部為文字的話,
  31.         夠放九個全形字符
  32.         
  33.   簡介:任務的介紹(顯示在右邊視窗中),寬368,高不限
  34.   
  35.         文字可以自動換行
  36.   
  37.    2.1.1、控制碼解析
  38.    
  39.    名稱和內容均可用控制碼,注意兩條反斜線都要打!
  40.    
  41.    \\v[n] 顯示n號變數
  42.    \\c[n] 改變字體顏色。
  43.           n=1~7 時同“顯示文章”的\c[n],n=8 時為半透明色,n=9 時為系統色(青色)
  44.    \\n[i] 顯示i號角色名字
  45.    \\i[檔案名] 顯示圖示
  46.    \\p[檔案名] 顯示圖片
  47.    
  48.    2.1.2、高級:內嵌運算式
  49.         
  50.    請參考説明-腳本入門-字串-內嵌運算式相關內容。
  51.    它可以用來在任務的名稱和簡介那裡顯示變數。
  52.    常用的運算式(注意不要漏了井號和大括弧):
  53.    #{$game_variables[n]}       ——插入n號變數的值
  54.    #{$game_party.item_number(n)}  ——插入持有n號物品數量
  55.                                       同理還有weapon_number,armor_number
  56.    還可以預先定義一個變數,再插入(例子見示例任務3-靈魂線)
  57.    
  58.   2.2、注意事項
  59.   
  60.    2.2.1、括弧、逗號和雙引號 [ ] , " 必須使用半形符號(英文輸入),
  61.           引號內的內容則沒有關係
  62.          
  63.    2.2.2、單引號 ' 和雙引號 " 的區別:
  64.           為了不出錯誤,全部用雙引號吧!當然如果你對Ruby很熟悉,那就沒所謂了
  65.   
  66.   2.3、開始設置吧!
  67.   從107行開始設置任務資料,可以參考示例任務來設置,請仔細閱讀附加講解
  68.   
  69. 3、接受任務

  70. 事件裡的“腳本”指令輸入:get_task(任務ID)
  71. 例如 get_task(1) 就是接受1號任務

  72.   3.1、獲得全部任務
  73.   
  74.   事件裡的“腳本”指令輸入:get_all_task
  75.   這個功能基本上是用來在編寫好所有任務資料後測試排版的
  76.   

  77. 4、完成/刪除任務

  78. 事件裡的“腳本”指令輸入:finish_task(任務ID)
  79. 例如 finish_task(1) 就是完成1號任務

  80. 注意:本腳本不負責完成任務後的獎勵之類的東西,請自行在事件中判斷,
  81.        這裡的完成任務指的是從任務列表中刪去此任務

  82.   4.1、刪除全部任務
  83.   
  84.   事件裡的“腳本”指令輸入:finish_all_task
  85.   作為獲得全部任務的對應功能存在,似乎不會怎麼用到
  86. =end

  87. class Scene_Task
  88.   # 這裡設置任務內容翻頁音效
  89.   CHANGE_PAGE_SE = "Audio/SE/046-Book01"
  90. end

  91. class Game_Party
  92.   #--------------------------------------------------------------------------
  93.   # ● 設置任務資料
  94.   #--------------------------------------------------------------------------
  95.   def get_tasks_info
  96.     @tasks_info = []
  97.    
  98.     #-講解-
  99.     # 三個示例任務由淺入深,其實只要看懂第一個就可以使用了。
  100.     # 任務的寫法多種多樣,不限於這三個任務的方法
  101.     #----
  102.     #-----------------------------
  103.     # 示例任務1:沙漠中的五葉花
  104.     #-----------------------------
  105.     名稱 = "\\c[6]沙漠中的五葉花"
  106.     #-講解-
  107.     # 注意!腳本編輯器的變色功能並不是非常完善,所以換行後字變黑了,但仍然是字元
  108.     # 串的一部分,所以不要忘記在內容最後打一個雙引號
  109.     # 按回車是強制換行
  110.     #----
  111.     簡介 = "\\c[6]沙漠中的五葉花

  112. \\c[9]任務目標:
  113. 獲得5朵五葉花,交給西露達

  114. \\c[0]五葉花數目:\\v[1]/5

  115. 西露達:
  116. 人家等著你的花哦~"
  117.     #-講解-
  118.     # 每個任務最後一定要加上:
  119.     # @tasks_info[任務ID] = Game_Task.new(名稱, 簡介)
  120.     # 接受任務和完成任務都是用這個任務ID來索引
  121.     #----
  122.     @tasks_info[1] = Game_Task.new(名稱, 簡介)
  123.    
  124.     #-----------------------------
  125.     # 示例任務2:克蘿莉亞的藥瓶
  126.     #-----------------------------
  127.     名稱 = "\\c[6]克蘿莉亞的藥瓶"
  128.     #-講解-
  129.     # 這裡使用了字串相加,例如 s = "a" + "b" ,s 就是 "ab"
  130.     # 還用了內嵌運算式,$game_party.item_number(38) 就是38號物品的數量
  131.     #----
  132.     簡介 = 名稱 + "
  133.    
  134. \\c[9]任務目標:
  135. 問克蘿莉亞要一個藥瓶,交給西露達

  136. \\c[0]藥瓶:#{$game_party.item_number(38)}/1

  137. 西露達:
  138. 克蘿莉亞就在西邊的屋子裡"
  139.     @tasks_info[2] = Game_Task.new(名稱, 簡介)
  140.    
  141.     #-----------------------------
  142.     # 示例任務3:靈魂線
  143.     #-----------------------------
  144.     #-講解-
  145.     # 這裡用了條件判斷,當3號變數大於等於1時,加上“完成”字樣,同時變色
  146.     #----
  147.     if $game_variables[3] >= 1
  148.       名稱 = "\\c[8]靈魂線(完成)"
  149.       item = "\\c[8]靈魂線:#{$game_variables[3]}/1 (完成)"
  150.     else
  151.       名稱 = "\\c[2]靈魂線"
  152.       item = "\\c[0]靈魂線:#{$game_variables[3]}/1"
  153.     end
  154.     #-講解-
  155.     # 預先定義變數,用內嵌運算式插入
  156.     # 最後用了顯示圖示
  157.     #----
  158.     簡介 = "#{名稱}
  159.    
  160. \\c[9]任務目標:
  161. 找到埋起來的靈魂線,交給克蘿莉亞

  162. #{item}

  163. \\c[0]克蘿莉亞:
  164. 靈魂線就埋在其中一棵樹下,給我好好找\\i[046-Skill03]"
  165.     @tasks_info[3] = Game_Task.new(名稱, 簡介)
  166.    
  167.   end
  168. end
  169.    
  170. #==============================================================================
  171. # ■ Interpreter
  172. #------------------------------------------------------------------------------
  173. #  執行事件命令的解譯器。本類在 Game_System 類
  174. # 與 Game_Event 類的內部使用。
  175. #==============================================================================

  176. class Interpreter
  177.   #--------------------------------------------------------------------------
  178.   # ● 接受任務
  179.   #--------------------------------------------------------------------------
  180.   def get_task(id)
  181.     task = $game_party.tasks_info[id]
  182.     return true if (task.nil? or $game_party.current_tasks.include?(task.id))
  183.     $game_party.current_tasks.unshift(task.id)
  184.     return true
  185.   end
  186.   #--------------------------------------------------------------------------
  187.   # ● 獲得全部任務
  188.   #--------------------------------------------------------------------------
  189.   def get_all_task
  190.     # 清空當前任務
  191.     $game_party.current_tasks.clear
  192.     for task in $game_party.tasks_info
  193.       next if task.nil?
  194.       $game_party.current_tasks.unshift(task.id)
  195.     end
  196.     return true
  197.   end
  198.   #--------------------------------------------------------------------------
  199.   # ● 完成/放棄任務
  200.   #--------------------------------------------------------------------------
  201.   def finish_task(id)
  202.     task = $game_party.tasks_info[id]
  203.     return true if task.nil?
  204.     $game_party.current_tasks.delete(task.id)
  205.     return true
  206.   end
  207.   #--------------------------------------------------------------------------
  208.   # ● 刪除全部任務
  209.   #--------------------------------------------------------------------------
  210.   def finish_all_task
  211.     $game_party.current_tasks.clear
  212.     return true
  213.   end
  214. end

  215. #==============================================================================
  216. # ■ Game_Party
  217. #------------------------------------------------------------------------------
  218. #  處理同伴的類。包含金錢以及物品的資訊。本類的實例
  219. # 請參考 $game_party。
  220. #==============================================================================

  221. class Game_Party
  222.   #--------------------------------------------------------------------------
  223.   # ● 定義執行個體變數
  224.   #--------------------------------------------------------------------------
  225.   attr_writer     :latest_task                  # 上次查看的任務
  226.   #--------------------------------------------------------------------------
  227.   # ● 取得任務資料
  228.   #--------------------------------------------------------------------------
  229.   def tasks_info
  230.     if @tasks_info.nil?
  231.       get_tasks_info
  232.     end
  233.     return @tasks_info
  234.   end
  235.   #--------------------------------------------------------------------------
  236.   # ● 取得當前任務
  237.   #--------------------------------------------------------------------------
  238.   def current_tasks
  239.     if @current_tasks.nil?
  240.       @current_tasks = []
  241.     end
  242.     return @current_tasks
  243.   end
  244.   #--------------------------------------------------------------------------
  245.   # ● 上次查看的任務
  246.   #--------------------------------------------------------------------------
  247.   def latest_task
  248.     if !current_tasks.include?(@latest_task)
  249.       @latest_task = current_tasks[0]
  250.     end
  251.     return @latest_task
  252.   end
  253. end

  254. #==============================================================================
  255. # ■ Game_Task
  256. #------------------------------------------------------------------------------
  257. #  處理任務的類。包含任務的資訊。
  258. #==============================================================================

  259. class Game_Task
  260.   attr_accessor   :name                   # 名稱
  261.   attr_accessor   :briefing               # 簡介
  262.   def initialize(name, briefing)
  263.     @name = name
  264.     @briefing = briefing
  265.   end
  266.   def height
  267.     text = @briefing.clone
  268.     x = 0
  269.     y = 64
  270.     min_y = 0
  271.     # 限制文字處理
  272.     begin
  273.       last_text = text.clone
  274.       text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  275.     end until text == last_text
  276.     text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  277.       $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  278.     end
  279.     # 為了方便、將 "\\\" 變換為 "\000"
  280.     text.gsub!(/\\\\/) { "\000" }
  281.     # "\C" 變為 "\001"
  282.     text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  283.     # "\I" 變為 "\002"
  284.     text.gsub!(/\\[Ii]/) { "\002" }
  285.     # "\P" 變為 "\003"
  286.     text.gsub!(/\\[Pp]/) { "\003" }
  287.     # c 獲取 1 個字 (如果不能取得文字就迴圈)
  288.     while ((c = text.slice!(/./m)) != nil)
  289.       # \\ 的情況下
  290.       if c == "\000"
  291.         # 還原為本來的文字
  292.         c = "\"
  293.       end
  294.       # \C[n] 的情況下
  295.       if c == "\001"
  296.         # 更改文字色
  297.         text.sub!(/\[([0-9]+)\]/, "")
  298.         # 下面的文字
  299.         next
  300.       end
  301.       # 圖示的情況下
  302.       if c == "\002"
  303.         icon_name = ''
  304.         while ((cha = text.slice!(/./m)) != ']')
  305.           next if cha == '['
  306.           icon_name += cha
  307.         end
  308.         icon = RPG::Cache.icon(icon_name)
  309.         if x + icon.width > 368
  310.           x = 0
  311.           y += [32, min_y].max
  312.           min_y = 0
  313.         end
  314.         x += 28
  315.         next
  316.       end
  317.       # 圖片的情況下
  318.       if c == "\003"
  319.         pic_name = ''
  320.         while ((cha = text.slice!(/./m)) != ']')
  321.           next if cha == '['
  322.           pic_name += cha
  323.         end
  324.         pic = RPG::Cache.picture(pic_name)
  325.         if x + pic.width > 368
  326.           x = 0
  327.           y += [32, min_y].max
  328.           min_y = 0
  329.         end
  330.         x += pic.width
  331.         min_y = [pic.height, 32].max
  332.         next
  333.       end
  334.       # 另起一行文字的情況下
  335.       if c == "\n"
  336.         y += [32, min_y].max
  337.         min_y = 0
  338.         x = 0
  339.         # 下面的文字
  340.         next
  341.       end
  342.       # 自動換行處理
  343.       if x + 22 > 368
  344.         y += [32, min_y].max
  345.         min_y = 0
  346.         x = 0
  347.       end
  348.       # x 為要描繪文字的加法運算
  349.       x += 22
  350.     end
  351.     return (y + [32, min_y].max)
  352.   end
  353.   def id
  354.     return $game_party.tasks_info.index(self)
  355.   end
  356. end

  357. #==============================================================================
  358. # ■ Window_Task_Name
  359. #------------------------------------------------------------------------------
  360. #  任務名稱顯示視窗。
  361. #==============================================================================

  362. class Window_Task_Name < Window_Selectable
  363.   #--------------------------------------------------------------------------
  364.   # ● 初始化對像
  365.   #--------------------------------------------------------------------------
  366.   def initialize(tasks)
  367.     super(0, 0, 240, 480)
  368.     @tasks = []
  369.     for id in tasks
  370.       @tasks.push($game_party.tasks_info[id])
  371.     end
  372.     @item_max = tasks.size
  373.     self.contents = Bitmap.new(
  374.     self.width - 32, @item_max == 0 ? 32 : @item_max * 32)
  375.     refresh
  376.     self.index = 0
  377.   end
  378.   #--------------------------------------------------------------------------
  379.   # ● 刷新
  380.   #--------------------------------------------------------------------------
  381.   def refresh
  382.     self.contents.clear
  383.     if @tasks != []
  384.       for task in @tasks
  385.         draw_item(task)
  386.       end
  387.     else
  388.       draw_blank
  389.     end
  390.   end
  391.   #--------------------------------------------------------------------------
  392.   # ● 描繪項目
  393.   #--------------------------------------------------------------------------
  394.   def draw_item(task)
  395.     text = task.name.clone
  396.     x = 0
  397.     y = @tasks.index(task) * 32
  398.     # 限制文字處理
  399.     begin
  400.       last_text = text.clone
  401.       text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  402.     end until text == last_text
  403.     text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  404.       $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  405.     end
  406.     # 為了方便、將 "\\\" 變換為 "\000"
  407.     text.gsub!(/\\\\/) { "\000" }
  408.     # "\\C" 變為 "\001"
  409.     text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  410.     # "\I" 變為 "\002"
  411.     text.gsub!(/\\[Ii]/) { "\002" }
  412.     # "\P" 變為 "\003"
  413.     text.gsub!(/\\[Pp]/) { "\003" }
  414.     # c 獲取 1 個字 (如果不能取得文字就迴圈)
  415.     while ((c = text.slice!(/./m)) != nil)
  416.       # \\ 的情況下
  417.       if c == "\000"
  418.         # 還原為本來的文字
  419.         c = "\"
  420.       end
  421.       # \C[n] 的情況下
  422.       if c == "\001"
  423.         # 更改文字色
  424.         text.sub!(/\[([0-9]+)\]/, "")
  425.         color = $1.to_i
  426.         if color >= 0 and color <= 7
  427.           self.contents.font.color = text_color(color)
  428.         elsif color == 8
  429.           self.contents.font.color = disabled_color
  430.         elsif color == 9
  431.           self.contents.font.color = system_color
  432.         end
  433.         # 下面的文字
  434.         next
  435.       end
  436.       # 圖示的情況下
  437.       if c == "\002"
  438.         icon_name = ''
  439.         while ((cha = text.slice!(/./m)) != ']')
  440.           next if cha == '['
  441.           icon_name += cha
  442.         end
  443.         icon = RPG::Cache.icon(icon_name)
  444.         if x + icon.width > self.contents.width
  445.           x = 0
  446.           y += [32, min_y].max
  447.           min_y = 0
  448.         end
  449.         self.contents.blt(x + 4, y + 4, icon, Rect.new(0, 0, 24, 24))
  450.         x += 28
  451.         next
  452.       end
  453.       # 圖片的情況下
  454.       if c == "\003"
  455.         pic_name = ''
  456.         while ((cha = text.slice!(/./m)) != ']')
  457.           next if cha == '['
  458.           pic_name += cha
  459.         end
  460.         pic = RPG::Cache.picture(pic_name)
  461.         if x + pic.width > self.contents.width
  462.           x = 0
  463.           y += [32, min_y].max
  464.           min_y = 0
  465.         end
  466.         self.contents.blt(x + 4, y, pic, Rect.new(0, 0, pic.width, pic.height))
  467.         x += pic.width
  468.         next
  469.       end
  470.       # 描繪文字
  471.       self.contents.draw_text(4 + x, y, 40, 32, c)
  472.       # x 為要描繪文字的加法運算
  473.       x += self.contents.text_size(c).width
  474.     end
  475.   end
  476.   #--------------------------------------------------------------------------
  477.   # ● 描繪空行
  478.   #--------------------------------------------------------------------------
  479.   def draw_blank
  480.     self.contents.font.color = disabled_color
  481.     rect = Rect.new(4, 0, self.contents.width - 8, 32)
  482.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  483.     self.contents.draw_text(rect, '當前沒有任何任務')
  484.   end
  485.   #--------------------------------------------------------------------------
  486.   # ● 獲取任務
  487.   #--------------------------------------------------------------------------
  488.   def task
  489.     return @tasks[self.index]
  490.   end
  491. end
  492.   
  493. #==============================================================================
  494. # ■ Window_Task
  495. #------------------------------------------------------------------------------
  496. #  任務內容顯示視窗。
  497. #==============================================================================

  498. class Window_Task < Window_Base
  499.   #--------------------------------------------------------------------------
  500.   # ● 初始化對像
  501.   #--------------------------------------------------------------------------
  502.   def initialize(task_id)
  503.     super(240, 0, 400, 480)
  504.     refresh(task_id)
  505.   end
  506.   #--------------------------------------------------------------------------
  507.   # ● 刷新內容
  508.   #--------------------------------------------------------------------------
  509.   def refresh(task_id)
  510.     self.oy = 0
  511.     self.visible = true
  512.     return if task_id.nil?
  513.     task = $game_party.tasks_info[task_id]
  514.     if !task.nil?
  515.       self.contents = Bitmap.new(self.width - 32, task.height)
  516.     else
  517.       self.contents = Bitmap.new(self.width - 32, self.height - 32)
  518.       return
  519.     end
  520.     self.contents.font.color = normal_color
  521.     # 描繪任務內容
  522.     draw_task_info(task)
  523.   end
  524.   #--------------------------------------------------------------------------
  525.   # ● 描繪任務內容
  526.   #--------------------------------------------------------------------------
  527.   def draw_task_info(task)
  528.     # 記錄文字x座標
  529.     x = 0
  530.     # 記錄文字y座標
  531.     y = 0
  532.     # 記錄換行時y座標最小加值
  533.     min_y = 0
  534.     self.contents.font.color = normal_color
  535.     # 描繪任務簡介
  536.     text = task.briefing.clone
  537.     # 限制文字處理
  538.     begin
  539.       last_text = text.clone
  540.       text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  541.     end until text == last_text
  542.     text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  543.       $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  544.     end
  545.     # 為了方便、將 "\\\" 變換為 "\000"
  546.     text.gsub!(/\\\\/) { "\000" }
  547.     # "\C" 變為 "\001"
  548.     text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  549.     # "\I" 變為 "\002"
  550.     text.gsub!(/\\[Ii]/) { "\002" }
  551.     # "\P" 變為 "\003"
  552.     text.gsub!(/\\[Pp]/) { "\003" }
  553.     # c 獲取 1 個字 (如果不能取得文字就迴圈)
  554.     while ((c = text.slice!(/./m)) != nil)
  555.       # \\ 的情況下
  556.       if c == "\000"
  557.         # 還原為本來的文字
  558.         c = "\"
  559.       end
  560.       # \C[n] 的情況下
  561.       if c == "\001"
  562.         # 更改文字色
  563.         text.sub!(/\[([0-9]+)\]/, "")
  564.         color = $1.to_i
  565.         if color >= 0 and color <= 7
  566.           self.contents.font.color = text_color(color)
  567.         elsif color == 8
  568.           self.contents.font.color = disabled_color
  569.         elsif color == 9
  570.           self.contents.font.color = system_color
  571.         end
  572.         # 下面的文字
  573.         next
  574.       end
  575.       # 圖示的情況下
  576.       if c == "\002"
  577.         icon_name = ''
  578.         while ((cha = text.slice!(/./m)) != ']')
  579.           next if cha == '['
  580.           icon_name += cha
  581.         end
  582.         icon = RPG::Cache.icon(icon_name)
  583.         if x + icon.width > self.contents.width
  584.           x = 0
  585.           y += [32, min_y].max
  586.           min_y = 0
  587.         end
  588.         self.contents.blt(x + 4, y + 4, icon, Rect.new(0, 0, 24, 24))
  589.         x += 28
  590.         next
  591.       end
  592.       # 圖片的情況下
  593.       if c == "\003"
  594.         pic_name = ''
  595.         while ((cha = text.slice!(/./m)) != ']')
  596.           next if cha == '['
  597.           pic_name += cha
  598.         end
  599.         pic = RPG::Cache.picture(pic_name)
  600.         if x + pic.width > self.contents.width
  601.           x = 0
  602.           y += [32, min_y].max
  603.           min_y = 0
  604.         end
  605.         self.contents.blt(x + 4, y, pic, Rect.new(0, 0, pic.width, pic.height))
  606.         x += pic.width
  607.         min_y = [pic.height, 32].max
  608.         next
  609.       end
  610.       # 另起一行文字的情況下
  611.       if c == "\n"
  612.         y += [32, min_y].max
  613.         min_y = 0
  614.         x = 0
  615.         # 下面的文字
  616.         next
  617.       end
  618.       # 自動換行處理
  619.       if x + self.contents.text_size(c).width > self.contents.width
  620.         y += [32, min_y].max
  621.         min_y = 0
  622.         x = 0
  623.       end
  624.       # 描繪文字
  625.       self.contents.draw_text(4 + x, y, 40, 32, c)
  626.       # x 為要描繪文字的加法運算
  627.       x += self.contents.text_size(c).width
  628.     end
  629.   end
  630. end

  631. #==============================================================================
  632. # ■ Scene_Task
  633. #------------------------------------------------------------------------------
  634. #  處理任務畫面的類。
  635. #==============================================================================

  636. class Scene_Task
  637.   #--------------------------------------------------------------------------
  638.   # ● 主處理
  639.   #--------------------------------------------------------------------------
  640.   def main
  641.     # 刷新任務資料
  642.     $game_party.get_tasks_info
  643.     # 生成任務名稱窗口
  644.     @task_names_window = Window_Task_Name.new($game_party.current_tasks)
  645.     @task_names_window.active = true
  646.     if $game_party.current_tasks != []
  647.       @task_names_window.index = $game_party.current_tasks.index($game_party.latest_task)
  648.     end
  649.     # 生成任務內容視窗
  650.     @task_info_window = Window_Task.new($game_party.latest_task)
  651.     @task_info_window.active = true
  652.     # 執行過渡
  653.     Graphics.transition
  654.     # 主迴圈
  655.     loop do
  656.       # 刷新遊戲畫面
  657.       Graphics.update
  658.       # 刷新輸入資訊
  659.       Input.update
  660.       # 刷新畫面
  661.       update
  662.       # 如果畫面被切換的話就中斷迴圈
  663.       if $scene != self
  664.         break
  665.       end
  666.     end
  667.     # 準備過渡
  668.     Graphics.freeze
  669.     # 釋放窗口
  670.     @task_names_window.dispose
  671.     @task_info_window.dispose
  672.   end
  673.   #--------------------------------------------------------------------------
  674.   # ● 刷新畫面
  675.   #--------------------------------------------------------------------------
  676.   def update
  677.     # 刷新窗口
  678.     @task_names_window.update
  679.     @task_info_window.update
  680.     update_task_names_window
  681.   end
  682.   #--------------------------------------------------------------------------
  683.   # ● 刷新任務名稱窗口
  684.   #--------------------------------------------------------------------------
  685.   def update_task_names_window
  686.     # 按下 B 鍵的情況下
  687.     if Input.trigger?(Input::B)
  688.       # 演奏取消 SE
  689.       $game_system.se_play($data_system.cancel_se)
  690.       # 這裡設置返回的場景,返回地圖是Scene_Map.new,菜單是Scene_Menu.new(任務介面index)
  691.       $scene = Scene_Menu.new(5)
  692.       #$scene = Scene_Map.new
  693.       return
  694.     end
  695.     # 按下 C 鍵的情況下
  696.     if Input.trigger?(Input::C)
  697.       # 無任務可顯示的話
  698.       if @task_names_window.task == nil
  699.         # 演奏凍結 SE
  700.         $game_system.se_play($data_system.buzzer_se)
  701.         return
  702.       end
  703.       # 如果游標沒有移動的話,翻頁
  704.       if $game_party.latest_task == @task_names_window.task.id
  705.         if @task_info_window.oy + @task_info_window.height - 32 > @task_info_window.contents.height
  706.           @task_info_window.oy = 0
  707.         else
  708.           @task_info_window.oy += 480-32
  709.         end
  710.         if @task_info_window.contents.height > @task_info_window.height - 32
  711.           # 演奏翻頁 SE
  712.           Audio.se_play(CHANGE_PAGE_SE)
  713.         end
  714.       else
  715.         @task_info_window.refresh(@task_names_window.task.id)
  716.         $game_party.latest_task = @task_names_window.task.id
  717.         # 演奏確定 SE
  718.         $game_system.se_play($data_system.decision_se)
  719.       end
  720.     end
  721.   end
  722. end
复制代码


然後照著說明去設置任務
我把簡介拿來放任務目標,而一個任務裏可能有多個目標,我想任每完成一個目標就在後面加上"(完成)"
於是我這樣寫
我設置的任務1
  1. if $game_variables[11] == 2
  2.       名稱 = "\\c[8]任務1(完成)"
  3.       任務目標 =
  4.       "\\c[8]目標1(完成)\n\\c[8]目標2(完成)"
  5.     else
  6.       名稱 = "\\c[2]任務1"
  7.       任務目標 =
  8.       if $game_self_switches[[9, 6, 'A']] == true
  9.         "\\c[8]目標1(完成)\n"
  10.       else
  11.         "\\c[0]目標1"
  12.       end
  13.       if $game_self_switches[[9, 5, 'A']] == true
  14.         "\\c[8]目標2(完成)"
  15.       else
  16.         "\\c[0]目標2"
  17.       end
  18.     end
  19.     @tasks_info[1] = Game_Task.new(名稱, 任務目標)
复制代码


我的問題在於我只會顯示第二層第一個if裡的"目標1"
第二層第二個if裡要顯示的任務目標"目標2"從來都沒出現過
截圖
還沒有去找任務目標或只完成目標2

只完成目標1

雖然第二行該出現的"目標2"沒有出現過,但我確實完成"目標2"後,第一個if是有效的,兩個目標都會出現,並顯示完成
任務1完成 截圖


我有推測是不是他是不是只能讀到第二層第一個if,跳掉了第二個。(不過我覺得跳掉很不科學)
不知道我應該怎麼修正才好?是有什麼相關的特性嗎?

评分

参与人数 1星屑 +35 收起 理由
RyanBern + 35 手动认可奖励

查看全部评分

头像被屏蔽
梦石
0
星屑
88
在线时间
631 小时
注册时间
2014-8-4
回帖
3243
发表于 2016-6-5 10:28:06 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复

使用道具 举报

梦石
0
星屑
50
在线时间
158 小时
注册时间
2016-1-7
回帖
102
 楼主| 发表于 2016-6-5 14:57:33 | 显示全部楼层
嘗試照著樓上大大s+=的思路做

我只要在目標2那個if前加上 任務目標 += 就好,如下

修正
  1. if $game_variables[11] == 2
  2.       名稱 = "\\c[8]任務1(完成)"
  3.       任務目標 =
  4.       "\\c[8]目標1(完成)\n\\c[8]目標2(完成)"
  5.     else
  6.       名稱 = "\\c[2]任務1"
  7.       任務目標 =
  8.       if $game_self_switches[[9, 6, 'A']] == true
  9.         "\\c[8]目標1(完成)\n"
  10.       else
  11.         "\\c[0]目標1\n"
  12.       end
  13.       任務目標 +=
  14.       if $game_self_switches[[9, 5, 'A']] == true
  15.         "\\c[8]目標2(完成)"
  16.       else
  17.         "\\c[0]目標2"
  18.       end
  19.     end
  20.     @tasks_info[1] = Game_Task.new(名稱, 任務目標)
复制代码


我想我應該懂了原來為何不能,感謝大大提點

点评

谢谢你让我懂得了=后可以加if从句,感谢大大提点  发表于 2016-6-5 18:53
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部