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

Project1

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

[已经过期] 【求助】关于一个任务系统脚本的问题

[复制链接]

Lv2.观梦者

梦石
0
星屑
353
在线时间
38 小时
注册时间
2017-7-1
帖子
17
跳转到指定楼层
1
发表于 2022-4-30 01:35:06 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
我找到一个名为【V.M of D.T 简单任务系统】的脚本,初测试时感觉还挺适合的,但后来发现了一些问题,想问问看这些问题有没有办法解决

首先,脚本中支持设定多个【任务物品】(也就是任务目标),同时支持使任务物品在游戏画面和任务界面中进行隐藏或显示(演示的任务中第二个任务物品【将水送到女士手里】就是设定过的隐藏物品,通过代码指令显示)

然而在关闭游戏并读取存档后,原本隐藏或显示的的任务物品又重新恢复成任务初始的状态,而任务菜单里的任务物品的数值也归零了(在游戏界面右上角显示的物品数值反而是正常的),而这些情况使用脚本指令也无法恢复了,所以我把这个脚本发过来,不知道各位大佬能不能把这些问题修复。
RUBY 代码复制
  1. # 简单任务系统 v1.3f
  2. #----------#
  3. #特点: 任务! 好像没什么可说的.
  4. #
  5. #使用方法:   根据需要进行设定!
  6. #      可用脚本:
  7. #         accept_quest(:任务id)     - 接任务
  8. #         abandon_quest(:任务id)    - 强制放弃任务
  9. #         turnin_quest(:任务id)     - 强制完成任务
  10. #         fail_quest(:任务id)       - 强制放弃任务,并播放 ME
  11. #         ask_turnin(:任务id)       - 打开完成任务窗口
  12. #         ask_accept(:任务id)       - 打开接受任务窗口
  13. #
  14. #       adv_obj(:任务id, :obj数字, 数值)    - 获得多少任务物品(加法)
  15. #       set_obj(:任务id, :obj数字, 数值)    - 身上的任务物品变为多少(赋值)
  16. #       obj(:任务id, :obj数字)              - 获取任务物品数量(??)
  17. #       hide_obj(:任务id, :obj数字)         - 隐藏任务物品
  18. #       show_obj(:任务id, :obj数字)         - 显示任务物品
  19. #
  20. #     $game_quests[:任务id].accepted?     - 任务接受时为true
  21. #     $game_quests[:任务id].completed?    - 任务完成时为true
  22. #     $game_quests[:任务id].turned_in?    - 任务上交时为true
  23. #
  24. # 例子:
  25. #  The obj 可以用在分支条件里,用于判断任务物品的持有数是否满足任务条件
  26. #   例如:.
  27. #    #检查任务":quest89" 的任务物品":obj3"的数量是否大过 3:
  28. #     obj(:quest89, :obj3) > 3
  29. #
  30. #~ #----------#
  31. #-- Script by: V.M of D.T
  32. #
  33. #- Questions or comments can be:
  34. #    given by email: [email protected]
  35. #    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
  36. #   All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
  37. #
  38. #--- Free to use in any project, commercial or non-commercial, with credit given
  39. # - - Though a donation's always a nice way to say thank you~ (I also accept actual thank you's)
  40.  
  41. #是否在地图上显示任务列表
  42. $questlogvisibility = true
  43. #任务列表中显示的最大任务数
  44. $questlogmaxdisplay = 5
  45. #任务列表位置, 1 - 左上角, 2 - 右上角
  46. QUEST_LOG_POSITION = 2
  47. #任务列表偏移大小
  48. QUEST_LOG_OFFSET_X = 0
  49. QUEST_LOG_OFFSET_Y = 0
  50.  
  51. # 任务设定格式!
  52.  
  53. # DETAILS[:quest_id] = {
  54. #   :name => "任务名"         #任务名
  55. #   :level => 数值            #需要等级,为任意数值 (可选)
  56. #   :difficulty => "文字"     #难度,为任意文字 (可选)
  57. #   :auto_complete => true    #是否自动完成任务,当场获得奖励 (可选)
  58. #   :abandonable => false     #是否可以放弃该任务 (可选)
  59. #   :force_accept => true     #任务窗口中是否只能接受该任务 (可选)
  60. #   :force_turnin => true     #完成任务窗口中是否只允许完成该任务 (可选)
  61. #  }
  62. # DESCRIPTIONS[:quest_id] = {
  63. #   :qgiver_name => "文字"  #派发任务人的名字 (在任务列表中显示) (可选)
  64. #   :location => "文字"     #派发任务人的地点 (在任务列表中显示) (可选)
  65. #   :desc => "文字"         #任务介绍 (在任务列表中显示)(可选)
  66. #  }
  67. # OBJECTIVES[:quest_id] = {   # 任务物品, "文字"是任务物品名,id是需要的数量
  68. #                             # "隐藏"替换为true,true时会隐藏该任务物品
  69. #   :obj_id1 => ["文字", id]
  70. #   :obj_id2 => ["文字", id, 隐藏],
  71. #   etc...
  72. #  }
  73. # REWARDS[:quest_id] = {
  74. #   :gold => value        #完成任务获得金钱 (可选)
  75. #   :exp => value         #完成任务获得经验值 (可选)
  76. #   :scale_exp => value   #队员获得经验的百分比,会比较自身等级占队伍总等级的比率
  77. #   :items => [[:type,id,数量], ...]], #获得物品, :type 可以替换为 :item, :weapon, 或 :armor(可选)
  78. #  }
  79.  
  80. module QUEST
  81.   DETAILS= {}
  82.   DESCRIPTIONS = {}
  83.   OBJECTIVES = {}
  84.   REWARDS = {}
  85.  
  86.   #任务 1
  87.   DETAILS[:任务001] = {
  88.     :name => "我需要水!",
  89.     :level => 1,
  90.     :difficulty => "炒鸡简单",
  91.     :abandonable => true,
  92.     :force_accept => false,
  93.     :force_turnin => true,
  94.   }
  95.   DESCRIPTIONS[:任务001] = {
  96.     :qgiver_name => "一位女士",
  97.     :location => "本地图",
  98.     :desc => "我口渴了, 你能从商人那里买一瓶
  99. 水吗?大家都知道,水是生命的源泉,没有水..." }
  100.   OBJECTIVES[:任务001] = {
  101.     :obj1 => ["获得一罐水",1],
  102.     :obj2 => ["将水送到女士手里",1, true],}
  103.   REWARDS[:任务001] = {
  104.     :gold => 5,
  105.     :exp => 10,
  106.     :scale_exp => 5,
  107.     :items => [[:item,1,2]], }  
  108.  
  109.  
  110.  
  111.    #在这里自己添加更多
  112.  
  113.  
  114.  
  115.  
  116. end
  117.  
  118. class Game_Quests
  119.   attr_accessor :reset_hash
  120.   def initialize
  121.     @quests = {}
  122.     QUEST::DETAILS.each do |id, quest|
  123.       @quests[id] = Quest.new(id,quest)
  124.     end
  125.     @reset_hash = {}
  126.     @quests.each_value do |quest|
  127.       @reset_hash[quest.id] = {}
  128.       @reset_hash[quest.id][:accepted] = false
  129.       @reset_hash[quest.id][:turnedin] = false
  130.       quest.objectives.each do |id, obj|
  131.         @reset_hash[quest.id][id] = obj
  132.       end
  133.     end
  134.   end
  135.   def check_quests
  136.     @quests.each do |id, quest|
  137.       if !$game_party.quests[id]
  138.         $game_party.quests[id] = {}
  139.         quest.reset
  140.       end
  141.     end
  142.   end
  143.   def [](quest_id)
  144.     return msgbox("未找到任务,id " + quest_id.to_s) if @quests[quest_id].nil?
  145.     @quests[quest_id]
  146.   end
  147.   def []=(quest_id, val)
  148.     @quests[quest_id] = val
  149.   end
  150.   def quests
  151.     @quests
  152.   end
  153.   def no_quests?
  154.     @quests.each do |id, quest|
  155.       return false if quest.accepted? && !quest.turned_in
  156.     end
  157.     return true
  158.   end
  159.   def tracking?
  160.     $game_party.tracking
  161.   end
  162.   def track_quest(id)
  163.     return if $game_party.tracking.include?(id)
  164.     $game_party.tracking.push(id)
  165.     if $game_party.tracking.size > $questlogmaxdisplay = 5
  166.       $game_party.tracking.reverse!.pop
  167.       $game_party.tracking.reverse!
  168.     end
  169.   end
  170.   def untrack_quest(id)
  171.     return unless $game_party.tracking.include?(id)
  172.     $game_party.tracking.delete(id)
  173.     $game_party.tracking.compact!
  174.   end
  175. end
  176.  
  177. class Quest
  178.   attr_accessor :name
  179.   attr_accessor :level
  180.   attr_accessor :id
  181.   attr_accessor :desc
  182.   attr_accessor :objectives
  183.   attr_accessor :turned_in
  184.   attr_accessor :difficulty
  185.   attr_accessor :qgiver_name
  186.   attr_accessor :location
  187.   attr_accessor :auto_complete
  188.   attr_accessor :abandonable
  189.   attr_accessor :force_accept
  190.   attr_accessor :force_turnin
  191.   def initialize(id,quest_hash)
  192.     @id = id
  193.     @level = 0
  194.     @difficulty = 0
  195.     @name = "无任务名称"
  196.     @desc = ""
  197.     @qgiver_name = 0
  198.     @location = 0
  199.     @auto_complete = false
  200.     @abandonable = true
  201.     @need_popup = false
  202.     @force_turnin = false
  203.     @force_accept = false
  204.     @name = quest_hash[:name] if quest_hash[:name]
  205.     @level = quest_hash[:level] if quest_hash[:level]
  206.     @force_accept = quest_hash[:force_accept] if quest_hash[:force_accept]
  207.     @force_turnin = quest_hash[:force_turnin] if quest_hash[:force_turnin]
  208.     @difficulty = quest_hash[:difficulty] if quest_hash[:difficulty]
  209.     @auto_complete = quest_hash[:auto_complete] if quest_hash[:auto_complete]
  210.     @abandonable = quest_hash[:abandonable] if !quest_hash[:abandonable].nil?
  211.     @desc = QUEST::DESCRIPTIONS[id][:desc] if QUEST::DESCRIPTIONS[id][:desc]
  212.     @qgiver_name = QUEST::DESCRIPTIONS[id][:qgiver_name] if QUEST::DESCRIPTIONS[id][:qgiver_name]
  213.     @location = QUEST::DESCRIPTIONS[id][:location] if QUEST::DESCRIPTIONS[id][:location]
  214.     @objectives = {}
  215.     if QUEST::OBJECTIVES[id]
  216.       QUEST::OBJECTIVES[id].each do |id, obj|
  217.         @objectives[id] = Objective.new(id, obj)
  218.       end
  219.     else
  220.       msgbox("任务 " + id.to_s + " 无任务物品.")
  221.     end
  222.     @reward_gold = 0
  223.     @reward_exp = 0
  224.     @scale_exp = 0
  225.     @reward_items = []
  226.     begin
  227.       if QUEST::REWARDS[id][:gold]
  228.         @reward_gold = QUEST::REWARDS[id][:gold]
  229.       end
  230.       if QUEST::REWARDS[id][:exp]
  231.         @reward_exp = QUEST::REWARDS[id][:exp]
  232.         @scale_exp = QUEST::REWARDS[id][:scale_exp] if QUEST::REWARDS[id][:scale_exp]
  233.       end
  234.       if QUEST::REWARDS[id][:items]
  235.         @reward_items = QUEST::REWARDS[id][:items]
  236.       end
  237.     rescue
  238.       msgbox(id.to_s + " 未找到奖励. 你忘记设定了.")
  239.     end
  240.   end
  241.   def accept
  242.     reset
  243.     $game_party.quests[id][:accepted] = true
  244.     track_quest
  245.     $game_map.need_refresh = true
  246.     Audio.se_play("Audio/SE/Book2")
  247.   end
  248.   def abandon
  249.     reset
  250.     $game_party.quests[id][:accepted] = false
  251.   end
  252.   def fail
  253.     Audio.me_play("Audio/ME/Gag")
  254.     abandon
  255.   end
  256.   def accepted?
  257.     $game_party.quests[id][:accepted]
  258.   end
  259.   def accepted
  260.     accepted?
  261.   end
  262.   def completed?
  263.     @objectives.each do |id, obj|
  264.       return false if !$game_party.quests[@id][id].completed?
  265.     end
  266.     return true
  267.   end
  268.   def force_done
  269.     $game_party.quests[id][:accepted] = true
  270.     @objectives.each do |id, obj|
  271.       $game_party.quests[@id][id].current = obj.max
  272.     end
  273.     turnin
  274.   end
  275.   def reset
  276.     $game_party.quests[id][:accepted] = false
  277.     @objectives.each do |id, obj|
  278.       $game_party.quests[@id][id] = obj
  279.       $game_party.quests[@id][id].current = 0
  280.     end
  281.     $game_party.quests[id][:turnedin] = false
  282.   end
  283.   def objective(id)
  284.     return Objective.new(id, ["未找到任务物品",0]) if @objectives[id].nil?
  285.     $game_party.quests[@id][id]
  286.   end
  287.   def set_obj(id, value)
  288.     objective(id).current = value
  289.     @need_popup = false if !completed?
  290.     popup if completed? && !@need_popup
  291.     turnin if completed? && @auto_complete
  292.     $game_map.need_refresh = true
  293.   end
  294.   def adv_obj(id, value)
  295.     objective(id).current += value
  296.     @need_popup = false if !completed?
  297.     popup if completed? && !@need_popup
  298.     turnin if completed? && @auto_complete
  299.     $game_map.need_refresh = true
  300.   end
  301.   def reward_gold
  302.     @reward_gold
  303.   end
  304.   def reward_exp
  305.     get_mod_exp.to_i
  306.   end
  307.   def reward_items
  308.     @reward_items
  309.   end
  310.   def turnin
  311.     $game_party.quests[id][:turnedin] = true
  312.     untrack_quest
  313.     $game_map.need_refresh = true
  314.     $game_party.gain_gold(@reward_gold)
  315.     $game_party.members.each do |actor|
  316.       actor.gain_exp(@reward_exp)
  317.     end
  318.     @reward_items.each do |array|
  319.       item = $data_items[array[1]] if array[0] == :item
  320.       item = $data_weapons[array[1]] if array[0] == :weapon
  321.       item = $data_armors[array[1]] if array[0] == :armor
  322.       $game_party.gain_item(item, array[2])
  323.     end
  324.   end
  325.   def track_quest
  326.     $game_quests.track_quest(@id)
  327.   end
  328.   def untrack_quest
  329.     $game_quests.untrack_quest(@id)
  330.   end
  331.   def can_abandon?
  332.     @abandonable
  333.   end
  334.   def popup
  335.     @need_popup = true
  336.     Audio.me_play("Audio/ME/Item")
  337.     if Module.const_defined?(:Popup)
  338.       Popup.add([@name + ' 完成!'])
  339.     end
  340.   end
  341.   def turned_in?
  342.     $game_party.quests[id][:turnedin]
  343.   end
  344.   def turned_in
  345.     turned_in?
  346.   end
  347.   def active?
  348.     accepted? && !completed?
  349.   end
  350.   def get_mod_exp
  351.     pval = @scale_exp * (@level - $game_party.highest_level).to_f / 100 + 1
  352.     @reward_exp * pval
  353.   end
  354. end
  355.  
  356. class Objective
  357.   attr_accessor :id
  358.   attr_accessor :name
  359.   attr_accessor :current
  360.   attr_accessor :max
  361.   attr_accessor :hidden
  362.   def initialize(id, obj)
  363.     @name = obj[0]
  364.     @current = 0
  365.     @max = obj[1]
  366.     @hidden = obj[2] ? obj[2] : false
  367.   end
  368.   def completed?
  369.     @current >= @max
  370.   end
  371. end
  372.  
  373. module DataManager
  374.   class << self
  375.     alias quest_cgo load_database
  376.     alias quest_sng setup_new_game
  377.   end
  378.   def self.load_database
  379.     quest_cgo
  380.     $game_quests = Game_Quests.new
  381.   end
  382.   def self.setup_new_game
  383.     $game_quests = Game_Quests.new
  384.     quest_sng
  385.   end
  386. end
  387.  
  388. class Scene_Quest < Scene_MenuBase
  389.   def start
  390.     super
  391.     @help_window = Window_Help.new(1)
  392.     @help_window.set_text("任务")
  393.     @list_window = Window_SceneList.new
  394.     @list_window.set_handler(:cancel, method(:list_cancel))
  395.     @list_window.set_handler(:ok, method(:list_ok))
  396.     @list_window.refresh
  397.     @list_window.activate
  398.     @list_window.select(0)
  399.     @detail_window = Window_SceneDetail.new
  400.     @command_window = Window_QuestTrack.new
  401.     @command_window.x = Graphics.width / 2 - @command_window.width / 2
  402.     @command_window.y = Graphics.height / 2 - @command_window.height / 2
  403.     @command_window.set_handler(:track, method(:track))
  404.     @command_window.set_handler(:untrack, method(:untrack))
  405.     @command_window.set_handler(:abandon, method(:abandon))
  406.     @command_window.set_handler(:cancel, method(:command_cancel))
  407.   end
  408.   def update
  409.     super
  410.     @detail_window.quest = @list_window.current_item
  411.   end
  412.   def list_cancel
  413.     SceneManager.return
  414.   end
  415.   def list_ok
  416.     @command_window.quest(@list_window.current_item)
  417.     @command_window.refresh
  418.     @command_window.select(0)
  419.     @command_window.activate
  420.     @command_window.open
  421.   end
  422.   def track
  423.     $game_quests.track_quest(@list_window.current_item.id)
  424.     command_cancel
  425.   end
  426.   def untrack
  427.     $game_quests.untrack_quest(@list_window.current_item.id)
  428.     command_cancel
  429.   end
  430.   def abandon
  431.     @list_window.current_item.abandon
  432.     command_cancel
  433.   end
  434.   def command_cancel
  435.     @command_window.close
  436.     @list_window.refresh
  437.     @list_window.activate
  438.     list_cancel if $game_quests.no_quests?
  439.   end
  440. end
  441.  
  442. class Window_SceneList < Window_Selectable
  443.   def initialize
  444.     super(0,48,Graphics.width/5*2,Graphics.height-48)
  445.     refresh
  446.   end
  447.   def make_item_list
  448.     @data = []
  449.     $game_quests.quests.each do |id, quest|
  450.       @data.push(quest) if quest.accepted? && !quest.turned_in?
  451.     end
  452.     @data.push(nil) if @data.empty?
  453.   end
  454.   def draw_item(index)
  455.     contents.font.size = 18
  456.     item = @data[index]
  457.     if item
  458.       rect = item_rect(index)
  459.       rect.width -= 4
  460.       if $game_quests.tracking?.include?(item.id)
  461.         text = "*" + item.name
  462.       else
  463.         text = item.name
  464.       end
  465.       draw_text(rect, text)
  466.       draw_text(rect, "Lv" + item.level.to_s,2) if item.level > 0
  467.     end
  468.   end
  469.   def col_max; 1; end
  470.   def current_item
  471.     @data[@index]
  472.   end
  473.   def current_item_enabled?
  474.     true
  475.   end
  476.   def refresh
  477.     make_item_list
  478.     create_contents
  479.     draw_all_items
  480.   end
  481.   def item_max
  482.     @data ? @data.size : 0
  483.   end
  484. end
  485.  
  486. class Window_SceneDetail < Window_Base
  487.   def initialize
  488.     super(Graphics.width/5*2,48,Graphics.width-Graphics.width/5*2,Graphics.height-48)
  489.   end
  490.   def quest=(quest)
  491.     return if @quest == quest
  492.     @quest = quest
  493.     refresh
  494.   end
  495.   def refresh
  496.     contents.clear
  497.     return unless @quest
  498.     contents.font.size = 18
  499.     change_color(system_color)
  500.     draw_text(0,0,contents.width,line_height,@quest.qgiver_name) if @quest.qgiver_name != 0
  501.     draw_text(0,0,contents.width,line_height,@quest.location,2) if @quest.location != 0
  502.     change_color(normal_color)
  503.     @quest.qgiver_name != 0 || @quest.location != 0 ? yy = line_height : yy = 0
  504.     draw_text_ex(0,yy,@quest.desc)
  505.     change_color(system_color)
  506.     draw_text(0,line_height*7,contents.width,24,"任务物品:")
  507.     change_color(normal_color)
  508.     yy = line_height * 8
  509.     @quest.objectives.each do |id, obj|
  510.       next if obj.hidden
  511.       draw_objective(yy, obj)
  512.       yy += 24
  513.     end
  514.     change_color(system_color)
  515.     draw_text(0,yy,contents.width,line_height,"奖励:")
  516.     yy += line_height
  517.     if @quest.reward_exp > 0
  518.       draw_text(6,yy,contents.width/2,line_height,"XP: ")
  519.       change_color(normal_color)
  520.       draw_text(36,yy,contents.width/2,line_height,@quest.reward_exp)
  521.       yy += line_height
  522.     end
  523.     if @quest.reward_gold > 0
  524.       change_color(normal_color)
  525.       draw_text(6,yy,contents.width/2,line_height,@quest.reward_gold.to_s)
  526.       cx = text_size(@quest.reward_gold).width
  527.       change_color(system_color)
  528.       draw_text(6+cx,yy,contents.width/2,line_height,Vocab::currency_unit)
  529.     end
  530.     yy += line_height
  531.     change_color(normal_color)
  532.     @quest.reward_items.each do |array|
  533.       item = $data_items[array[1]] if array[0] == :item
  534.       item = $data_weapons[array[1]] if array[0] == :weapon
  535.       item = $data_armors[array[1]] if array[0] == :armor
  536.       draw_item_name(item, 6, yy, true, contents.width)
  537.       if array[2] > 1
  538.         draw_text(6+text_size(item.name).width+36,yy,48,24,"x"+array[2].to_s)
  539.       end
  540.       yy += line_height
  541.     end
  542.     if @quest.difficulty != 0
  543.       text = "难度: " + @quest.difficulty
  544.       draw_text(0,contents.height-line_height,contents.width,line_height,text,2)
  545.     end
  546.   end
  547.   def draw_objective(yy, obj)
  548.     draw_text(6,yy,contents.width,24,obj.name)
  549.     draw_text(0,yy,contents.width,24,obj.current.to_s+"/"+obj.max.to_s,2)
  550.   end
  551.   def reset_font_settings
  552.     change_color(normal_color)
  553.     contents.font.bold = Font.default_bold
  554.     contents.font.italic = Font.default_italic
  555.   end
  556. end
  557.  
  558. class Window_QuestTrack < Window_Command
  559.   def initialize
  560.     super(0,0)
  561.     self.openness = 0
  562.   end
  563.   def quest(quest)
  564.     @quest = quest
  565.   end
  566.   def make_command_list
  567.     return unless @quest
  568.     if !$game_quests.tracking?.include?(@quest.id)
  569.       add_command("追踪任务", :track)
  570.     else
  571.       add_command("不追踪任务", :untrack)
  572.     end
  573.     add_command("放弃任务", :abandon, @quest.can_abandon?)
  574.   end
  575.   def window_height
  576.     fitting_height(2)
  577.   end
  578. end
  579.  
  580. class Window_MenuCommand
  581.   alias quest_aoc add_original_commands
  582.   def add_original_commands
  583.     quest_aoc
  584.     add_command("任务", :quest, !$game_quests.no_quests?)
  585.   end
  586. end
  587.  
  588. class Scene_Menu
  589.   alias quest_ccw create_command_window
  590.   def create_command_window
  591.     quest_ccw
  592.     @command_window.set_handler(:quest,    method(:scene_quest))
  593.   end
  594.   def scene_quest
  595.     SceneManager.call(Scene_Quest)
  596.   end
  597. end
  598.  
  599. class Scene_Map
  600.   alias quest_start start
  601.   alias quest_update update
  602.   def start
  603.     quest_start
  604.     @quest_log = Window_QuestLog.new
  605.     @quest_confirm = Window_QuestConfirm.new
  606.     @quest_confirm.set_handler(:accept, method(:confirm_accept))
  607.     @quest_confirm.set_handler(:decline, method(:confirm_cancel))
  608.     @quest_confirm.set_handler(:cancel, method(:confirm_cancel))
  609.     @quest_turnin = Window_QuestTurnin.new
  610.     @quest_turnin.set_handler(:accept, method(:turnin_accept))
  611.     @quest_turnin.set_handler(:decline, method(:confirm_cancel))
  612.     @quest_turnin.set_handler(:cancel, method(:confirm_cancel))
  613.     @quest_apply = Window_QuestApply.new(@quest_confirm,@quest_turnin)
  614.   end
  615.   def update(*args)
  616.     @quest_log = Window_QuestLog.new if @quest_log.disposed?
  617.     quest_update(*args)
  618.   end
  619.   def show_quest(id, turnin = false)
  620.     @quest_apply.show($game_quests[id],turnin)
  621.   end
  622.   def accepting?
  623.     @quest_confirm.active || @quest_turnin.active
  624.   end
  625.   def confirm_accept
  626.     @quest_apply.accept
  627.     @quest_apply.hide
  628.   end
  629.   def confirm_cancel
  630.     @quest_apply.hide
  631.   end
  632.   def turnin_accept
  633.     @quest_apply.turnin
  634.     @quest_apply.hide
  635.   end
  636.   def update_call_menu
  637.     if $game_system.menu_disabled || $game_map.interpreter.running? || accepting?
  638.       @menu_calling = false
  639.     else
  640.       @menu_calling ||= Input.trigger?(:B)
  641.       call_menu if @menu_calling && !$game_player.moving?
  642.     end
  643.   end
  644. end
  645.  
  646. class Scene_Base
  647.   def accepting?
  648.     false
  649.   end
  650. end
  651.  
  652. class Window_QuestLog < Window_Base
  653.   def initialize
  654.     super(Graphics.width/5*3,0,Graphics.width/5*2,Graphics.height)
  655.     self.x = 0 if QUEST_LOG_POSITION == 1
  656.     self.x += QUEST_LOG_OFFSET_X
  657.     self.y += QUEST_LOG_OFFSET_Y
  658.     self.opacity = 0
  659.     self.contents.font.size = 18
  660.   end
  661.   def update
  662.     super
  663.     return unless Graphics.frame_count % 20 == 0
  664.     self.visible = $questlogvisibility
  665.     return unless self.visible
  666.     self.visible = !$game_quests.no_quests?
  667.     self.visible = $game_quests.tracking?.size > 0
  668.     return unless self.visible
  669.     contents.clear
  670.     change_color(crisis_color)
  671.     draw_text(0,0,contents.width,18,"任务:",1)
  672.     yy = 18;iter = 0
  673.     $game_quests.tracking?.each do |id|
  674.       quest = $game_quests[id]
  675.       next unless quest.accepted? && !quest.turned_in
  676.       change_color(system_color)
  677.       draw_text(6,yy,contents.width-6,18,quest.name)
  678.       change_color(normal_color)
  679.       yy += 18
  680.       quest.objectives.each do |obj_id, obj|
  681.         next if obj.hidden
  682.         draw_objective(yy, $game_party.quests[id][obj_id])
  683.         yy += 18
  684.       end
  685.       iter += 1
  686.     end
  687.   end
  688.   def draw_objective(yy, obj)
  689.     draw_text(0,yy,contents.width-24,18,obj.name)
  690.     draw_text(0,yy,contents.width,18,obj.current.to_s+"/"+obj.max.to_s,2)
  691.   end
  692. end
  693.  
  694. class Window_QuestApply < Window_Base
  695.   def initialize(confirm_window, turnin_window)
  696.     super(Graphics.width/8,Graphics.width/8,Graphics.width/5*3,Graphics.height-Graphics.width/8*2)
  697.     self.openness = 0
  698.     @confirm_window = confirm_window
  699.     @turnin_window = turnin_window
  700.     self.contents.font.size = 18
  701.   end
  702.   def refresh
  703.     return unless @quest
  704.     contents.clear
  705.     change_color(system_color)
  706.     yy = 0
  707.     if @quest.qgiver_name != 0
  708.       draw_text(0,0,contents.width/2,line_height,@quest.qgiver_name)
  709.       yy = line_height
  710.     end
  711.     if @quest.location != 0
  712.       draw_text(contents.width/2,0,contents.width/2,line_height,@quest.location,2)
  713.       yy = line_height
  714.     end
  715.     change_color(crisis_color)
  716.     draw_text(0,yy,contents.width,line_height,"Lvl: " + @quest.level.to_s) if @quest.level > 0
  717.     draw_text(0,yy,contents.width,line_height,@quest.name,1)
  718.     draw_text(0,yy,contents.width,line_height,@quest.difficulty,2) if @quest.difficulty != 0
  719.     change_color(normal_color)
  720.     draw_text_ex(0,line_height+yy,@quest.desc)
  721.     change_color(system_color)
  722.     draw_text(0,line_height*8,contents.width,line_height,"任务物品:")
  723.     change_color(normal_color)
  724.     yy = line_height * 9
  725.     @quest.objectives.each do |obj_id, obj|
  726.       next if obj.hidden
  727.       draw_objective(yy, $game_party.quests[@quest.id][obj_id])
  728.       yy += line_height
  729.     end
  730.     change_color(system_color)
  731.     draw_text(0,yy,contents.width,line_height,"奖励:")
  732.     yy += line_height
  733.     if @quest.reward_exp > 0
  734.       draw_text(6,yy,contents.width/2,line_height,"XP: ")
  735.       change_color(normal_color)
  736.       draw_text(36,yy,contents.width/2,line_height,@quest.reward_exp)
  737.       yy += line_height
  738.     end
  739.     if @quest.reward_gold > 0
  740.       change_color(normal_color)
  741.       draw_text(6,yy,contents.width/2,line_height,@quest.reward_gold.to_s)
  742.       cx = text_size(@quest.reward_gold).width
  743.       change_color(system_color)
  744.       draw_text(6+cx,yy,contents.width/2,line_height,Vocab::currency_unit)
  745.     end
  746.     yy += line_height
  747.     change_color(normal_color)
  748.     @quest.reward_items.each do |array|
  749.       item = $data_items[array[1]] if array[0] == :item
  750.       item = $data_weapons[array[1]] if array[0] == :weapon
  751.       item = $data_armors[array[1]] if array[0] == :armor
  752.       draw_item_name(item, 6, yy, true, contents.width)
  753.       if array[2] > 1
  754.         draw_text(6+text_size(item.name).width+36,yy,48,24,"x"+array[2].to_s)
  755.       end
  756.       yy += line_height
  757.     end
  758.   end
  759.   def reset_font_settings
  760.     change_color(normal_color)
  761.     contents.font.bold = Font.default_bold
  762.     contents.font.italic = Font.default_italic
  763.   end
  764.   def line_height
  765.     18
  766.   end
  767.   def draw_objective(yy, obj)
  768.     draw_text(6,yy,contents.width,24,obj.name)
  769.     draw_text(0,yy,contents.width,24,obj.current.to_s+"/"+obj.max.to_s,2)
  770.   end
  771.   def show(quest,turnin)
  772.     @quest = quest
  773.     return if @quest.turned_in
  774.     refresh
  775.     open
  776.     @confirm_window.quest(@quest)
  777.     @confirm_window.open if !turnin
  778.     if turnin
  779.       @turnin_window.quest(@quest)
  780.       @turnin_window.open
  781.     end
  782.   end
  783.   def hide
  784.     close
  785.     @confirm_window.close
  786.     @turnin_window.close
  787.   end
  788.   def accept
  789.     @quest.accept
  790.   end
  791.   def turnin
  792.     @quest.turnin
  793.   end
  794. end
  795.  
  796. class Window_QuestConfirm < Window_HorzCommand
  797.   def initialize
  798.     super(Graphics.width/8,Graphics.width/8+Graphics.height-Graphics.width/8*2)
  799.     self.openness = 0
  800.     self.active = false
  801.     @enabled = true
  802.     refresh
  803.   end
  804.   def window_width
  805.     Graphics.width/5*2
  806.   end
  807.   def window_height
  808.     48
  809.   end
  810.   def make_command_list
  811.     add_command("接受",:accept)
  812.     add_command("拒绝",:decline, @enabled)
  813.   end
  814.   def item_width
  815.     width / 2 - padding * 2
  816.   end
  817.   def open
  818.     super
  819.     activate
  820.     select(0)
  821.   end
  822.   def quest(quest)
  823.     @quest = quest
  824.     @enabled = !@quest.force_accept
  825.     refresh
  826.   end
  827.   def cancel_enabled?
  828.     super && @enabled
  829.   end
  830. end
  831.  
  832. class Window_QuestTurnin < Window_QuestConfirm
  833.   def quest(quest)
  834.     @quest = quest
  835.     @enabled = true
  836.     @enabled = !@quest.completed? if @quest.force_turnin
  837.     refresh
  838.   end
  839.   def make_command_list
  840.     return unless @quest
  841.     add_command("完成",:accept,@quest.completed? && !@quest.turned_in)
  842.     add_command("取消",:decline, @enabled)
  843.   end
  844. end
  845.  
  846. class Game_Party
  847.   attr_accessor :quests
  848.   attr_accessor :tracking
  849.   alias quests_init initialize
  850.   def initialize(*args)
  851.     quests_init(*args)
  852.     @quests = $game_quests.reset_hash unless $game_quests.nil?
  853.     @tracking = []
  854.   end
  855. end
  856.  
  857. class Game_Player
  858.   alias quest_update update
  859.   def update
  860.     return if SceneManager.scene.accepting?
  861.     quest_update
  862.   end
  863. end
  864.  
  865. class Game_Event
  866.   def obj(quest, objective)
  867.     $game_quests[quest].objective(objective).current
  868.   end
  869. end
  870.  
  871. class Game_Interpreter
  872.   def accept_quest(quest)
  873.     $game_quests[quest].accept
  874.   end
  875.   def ask_accept(quest)
  876.     return unless SceneManager.scene.is_a?(Scene_Map)
  877.     SceneManager.scene.show_quest(quest)
  878.     Fiber.yield while SceneManager.scene.accepting?
  879.   end
  880.   def abandon_quest(quest)
  881.     $game_quests[quest].abandon
  882.   end
  883.   def fail_quest(quest)
  884.     $game_quests[quest].fail
  885.   end
  886.   def turnin_quest(quest)
  887.     $game_quests[quest].turnin
  888.   end
  889.   def ask_turnin(quest)
  890.     return unless SceneManager.scene.is_a?(Scene_Map)
  891.     SceneManager.scene.show_quest(quest,true)
  892.     Fiber.yield while SceneManager.scene.accepting?
  893.   end
  894.   def adv_obj(quest, objective, value)
  895.     $game_quests[quest].adv_obj(objective, value)
  896.   end
  897.   def set_obj(quest, objective, value)
  898.     $game_quests[quest].set_obj(objective, value)
  899.   end
  900.   def obj(quest, objective)
  901.     $game_quests[quest].objective(objective).current
  902.   end
  903.   def hide_obj(quest, objective)
  904.     $game_quests[quest].objective(objective).hidden = true
  905.   end
  906.   def show_obj(quest, objective)
  907.     $game_quests[quest].objective(objective).hidden = false
  908.   end
  909. end
  910.  
  911. module DataManager
  912.   class << self
  913.     alias quest_load_game load_game
  914.   end
  915.   def self.load_game(index)
  916.     quest_load_game(index)
  917.     $game_quests.check_quests
  918.   end
  919. end
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-11-27 18:51

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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