赞 | 0 |
VIP | 0 |
好人卡 | 5 |
积分 | 1 |
经验 | 7181 |
最后登录 | 2015-11-28 |
在线时间 | 116 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 116 小时
- 注册时间
- 2009-7-17
- 帖子
- 139
|
3楼
楼主 |
发表于 2015-1-6 11:56:03
|
只看该作者
喵呜喵5 发表于 2015-1-6 11:46
印象中每次读取存档时就是重新读取脚本吧…………
任务不刷新的问题,请检查任务的数据是否作为变量被保存 ...
报告喵大,用的是疾风怒涛汉化的那个日版的任务系统,这个是那个任务系统数据库的脚本,请教如何可以在读档时重新载入- #==============================================================================
- # ■ VXAce-RGSS3-4-db 任务系统【数据库】 by Claimh 汉化:疾风怒涛
- #------------------------------------------------------------------------------
- # 任务内容管理部分
- #------------------------------------------------------------------------------
- #【任务情报的参照方法】
- #◆ 任务开始可能? (检查前提条件Rank等级)
- # $game_system.quest[任务ID].can_start?
- #◆ 任务的clear条件是否满足? (检查clear条件)
- # $game_system.quest[任务ID].quest_clear?
- #◆ 任务进行中
- # $game_system.quest[任务ID].playing
- #◆ 任务成功
- # $game_system.quest[任务ID].clear_finish
- #◆ 任务失败
- # $game_system.quest[任务ID].fail_finish
- #==============================================================================
- module Quest
- #=============================================================================
- # ■ 报酬用类(本体)
- #=============================================================================
- class Result
- #--------------------------------------------------------------------------
- # ● 公开实例变量
- #--------------------------------------------------------------------------
- attr_reader :type # ITEM / WEAPON / ARMOR / MONEY
- attr_reader :id # ID
- attr_reader :num # 数
- attr_reader :view # 显示
- attr_reader :penalty # 惩罚
- #--------------------------------------------------------------------------
- # ● object实体
- #--------------------------------------------------------------------------
- def obj
- case @type
- when ITEM; return $data_items[@id]
- when WEAPON; return $data_weapons[@id]
- when ARMOR; return $data_armors[@id]
- when SKILL; return $data_skills[@id]
- when EV; return $data_common_events[@id]
- when CLASS; return $data_classes[@id]
- when LEVEL; return (@id == 0 ? LvAve.new : $game_actors[@id])
- when ACTOR; return $game_actors[@id]
- when QUEST_T, QUEST_F, QUEST_S
- return $game_system.quest[@id]
- end
- end
- #--------------------------------------------------------------------------
- # ● 报酬入手
- #--------------------------------------------------------------------------
- def gain
- return if @penalty
- case @type
- when ITEM; $game_party.gain_item(obj, @num)
- when WEAPON; $game_party.gain_item(obj, @num)
- when ARMOR; $game_party.gain_item(obj, @num)
- when MONEY; $game_party.gain_gold(@num)
- when SKILL
- @view = false if $game_actors[@num].skill_learn?(obj)
- $game_actors[@num].learn_skill(@id)
- when EV; exec_interpreter
- when CLASS;
- @view = false if $game_actors[@num].class_id == @id
- $game_actors[@num].change_class(@id, CLASS_EXP)
- when ACTOR; $game_party.add_actor(@id)
- when LEVEL
- if @id == 0
- $game_party.members.each do |actor|
- actor.change_level(actor.level + @num, false)
- end
- else
- obj.change_level(obj.level + @num, false)
- end
- when QUEST_T
- @view = false if $game_system.quest[@id].visible
- @view = false if $game_system.quest[@id].finish
- $game_system.quest[@id].visible = true
- when QUEST_F
- @view = false if !$game_system.quest[@id].visible
- @view = false if $game_system.quest[@id].finish
- $game_system.quest[@id].visible = false
- when QUEST_S
- if $game_system.quest[@id].finish
- @view = false
- else
- $game_system.quest[@id].quest_start
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 惩罚
- #--------------------------------------------------------------------------
- def lose
- return if !@penalty
- case @type
- when ITEM; $game_party.gain_item(obj, -@num)
- when WEAPON; $game_party.gain_item(obj, -@num)
- when ARMOR; $game_party.gain_item(obj, -@num)
- when MONEY; $game_party.lose_gold(@num)
- when SKILL
- @view = false if !$game_actors[@num].skill_learn?(obj)
- $game_actors[@num].forget_skill(@id)
- when EV; exec_interpreter
- when CLASS
- @view = false if $game_actors[@num].class_id == @id
- $game_actors[@num].change_class(@id, CLASS_EXP)
- when LEVEL
- if @id == 0
- $game_party.members.each do |actor|
- actor.change_level(actor.level - @num, false)
- end
- else
- obj.change_level(obj.level - @num, false)
- end
- when ACTOR; $game_party.remove_actor(@id)
- when QUEST_T
- @view = false if $game_system.quest[@id].visible
- @view = false if $game_system.quest[@id].finish
- $game_system.quest[@id].visible = true
- when QUEST_F
- @view = false if !$game_system.quest[@id].visible
- @view = false if $game_system.quest[@id].finish
- $game_system.quest[@id].visible = false
- when QUEST_S
- if $game_system.quest[@id].finish
- @view = false
- else
- $game_system.quest[@id].quest_start
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 公共事件发动
- #--------------------------------------------------------------------------
- def exec_interpreter
- $game_temp.reserve_common_event(@id)
- if SceneManager.scene_is?(Scene_Map) or SceneManager.scene_is?(Scene_Battle)
- return #可在Map或Battle中的场景使用interpreter
- #else # 该方法还可以使用文字显示、但该方法必定返回Map(不推荐)
- # $game_temp.common_event_id = @id
- # return_scene
- end
- # Guild实行的场合会运行独自的interpreter
- ev = Game_Interpreter.new
- ev.setup_reserved_common_event
- loop do
- ev.update
- break if ev.running?
- end
- end
- end
- #=============================================================================
- # ■ 条件用类(本体)
- #=============================================================================
- class Condition
- class LvAve
- attr_reader :name
- attr_reader :level
- def initialize
- @name = "平均Level"
- @level = Quest.level_ave
- end
- end
- #--------------------------------------------------------------------------
- # ● 公开实例変量
- #--------------------------------------------------------------------------
- attr_reader :type # 0~9
- attr_reader :id # ID(MONEY以外)
- attr_reader :num # 数
- attr_reader :lose # 减少
- #--------------------------------------------------------------------------
- # ● object实体
- #--------------------------------------------------------------------------
- def obj
- case @type
- when ITEM; return $data_items[@id]
- when WEAPON; return $data_weapons[@id]
- when ARMOR; return $data_armors[@id]
- when MONEY; return $game_party.gold
- when SW; return $game_switches[@id]
- when VAL; return $game_variables[@id]
- when ACTOR; return $game_actors[@id]
- when LEVEL; return (@id == 0 ? LvAve.new : $game_actors[@id])
- when ENEMY; return $data_enemies[@id]
- when QUEST_T; return $game_system.quest[@id]
- when QUEST_F; return $game_system.quest[@id]
- when SKILL; return $data_skills[@id]
- when CLASS; return $data_classes[@id]
- when SCRIPT; return nil # 无实体
- end
- return nil
- end
- def obj_num
- case @type
- when ITEM; return $game_party.item_number(obj)
- when WEAPON; return $game_party.item_number(obj)
- when ARMOR; return $game_party.item_number(obj)
- when MONEY; return $game_party.gold
- when SW; return 0#$game_switches[@id]
- when VAL; return $game_variables[@id]
- when EV; return 0
- when ACTOR; return 0
- when LEVEL; return (@id == 0 ? Quest.level_ave : $game_actors[@id].level)
- when ENEMY; return (defined?(DefeatCounter) ? $game_actors.defeat_all(@id) : 0)
- when QUEST_T; return 0
- when QUEST_F; return 0
- when SKILL; return 0
- when CLASS; return 0
- when SCRIPT; return 0
- end
- return 0
- end
- def obj_name
- if @name == ""
- case @type
- when ITEM; return $data_items[@id].name
- when WEAPON; return $data_weapons[@id].name
- when ARMOR; return $data_armors[@id].name
- when MONEY; return $game_system.terms.gold
- when ACTOR; return $game_actors[@id].name
- when LEVEL; return (@id == 0 ? LvAve.new.name : $game_actors[@id].name)
- when ENEMY; return $data_enemies[@id].name
- when QUEST_T; return Quest.conv_text($game_system.quest[@id].name)
- when QUEST_F; return Quest.conv_text($game_system.quest[@id].name)
- when SKILL; return $data_skills[@id].name
- when CLASS; return $data_classes[@id].name
- end
- end
- return Quest.conv_text(@name)
- end
- #--------------------------------------------------------------------------
- # ● 报告是义务的?
- #--------------------------------------------------------------------------
- def report?
- return (@type == EV)
- end
- #--------------------------------------------------------------------------
- # ● 条件检查
- #--------------------------------------------------------------------------
- def condition_clear?(report=false)
- case @type
- when ITEM; return ($game_party.item_number(obj) >= @num)
- when WEAPON; return ($game_party.item_number(obj) >= @num)
- when ARMOR; return ($game_party.item_number(obj) >= @num)
- when MONEY; return ($game_party.gold >= @num)
- when SW; return ($game_switches[@id])
- when VAL; return ($game_variables[@id] >= @num)
- when EV; return report # 如果在事件报告中则返回report状态
- when ACTOR;
- if @num == 0
- return ($game_party.members.include?($game_actors[@id]))
- else
- return (!$game_party.members.include?($game_actors[@id]))
- end
- when LEVEL; return (@id == 0 ? (Quest.level_ave >= @num) : ($game_actors[@id].level >= @num))
- when ENEMY; return (defined?(DefeatCounter) ? ($game_actors.defeat_all(@id) >= @num) : false)
- when QUEST_T; return $game_system.quest[@id].clear_finish
- when QUEST_F; return $game_system.quest[@id].fail_finish
- when SKILL
- if @num == 0
- $game_party.members.each do |actor|
- return true if actor.skill_learn?(obj)
- end
- else
- return $game_actors[@num].skill_learn?(obj)
- end
- when CLASS
- if @num == 0
- $game_party.members.each do |actor|
- return true if actor.class_id == @id
- end
- else
- return ($game_actors[@num].class_id == @id)
- end
- when SCRIPT; return script_clear?(@id, @num)
- end
- return false
- end
- #--------------------------------------------------------------------------
- # ● 任务物品减少
- #--------------------------------------------------------------------------
- def condition_lose
- return unless @lose
- case @type
- when ITEM; $game_party.gain_item(obj, -@num)
- when WEAPON; $game_party.gain_item(obj, -@num)
- when ARMOR; $game_party.gain_item(obj, -@num)
- when MONEY; $game_party.lose_gold(@num)
- when ACTOR; $game_party.remove_actor(@id)
- end
- end
- #--------------------------------------------------------------------------
- # ● 条件未满足時的说明
- #--------------------------------------------------------------------------
- def cause(txt)
- case @type
- when ITEM, WEAPON, ARMOR
- return "所需#{obj_name}还差\\n#{(@num - obj_num)}个"
- when MONEY
- return "所持金钱还差#{(@num - obj_num)} #{$data_system.currency_unit}"
- when ACTOR
- if @num == 0
- return "#{obj_name}\\n不在队伍中"
- else
- return "#{obj_name}\\n还在队伍中"
- end
- when LEVEL
- if @id == 0
- return "#{obj_name}所需的Lv \\n#{num}没有达到"
- else
- return "#{obj_name}所需的Level\\n#{num}没有达到"
- end
- when ENEMY
- return "还需要讨伐#{obj_name}\\n#{(@num - obj_num)}只"
- when QUEST_T
- return "『#{obj_name}』\\n尚未完成" if obj.visible
- when QUEST_F
- return "『#{obj_name}』\\n已经完成" if obj.visible
- when SKILL
- if @num == 0
- return "#{obj_name}\\n尚未习得"
- else
- return "#{$game_actors[@num].name}的#{obj_name}\\n技能尚未习得"
- end
- when CLASS
- if @num == 0
- return "职业为#{obj_name}的成员尚未加入"
- else
- return "#{$game_actors[@num].name}的职业不是\\n#{obj_name}"
- end
- when SCRIPT
- return script_cause((txt=="开始" ? 0 : 1), @id, @num)
- end
- return txt+"条件尚未满足"
- end
- end
- #=============================================================================
- # ■ SW操作用类(本体)
- #=============================================================================
- class Sw
- #--------------------------------------------------------------------------
- # ● 公开实例变量
- #--------------------------------------------------------------------------
- attr_reader :play # 开始時切换到ON的ID
- attr_reader :clear # 成功時切换到ON的ID
- attr_reader :fail # 失败時切换到ON的ID
- #--------------------------------------------------------------------------
- # ● SW复位
- #--------------------------------------------------------------------------
- def reset
- $game_switches[@play] = false if [url=home.php?mod=space&uid=283834]@play[/url] != 0
- $game_switches[@clr] = false if @clr != 0
- $game_switches[@fail] = false if @fail != 0
- $game_map.need_refresh = true
- end
- #--------------------------------------------------------------------------
- # ● 任务开始時SW操作
- #--------------------------------------------------------------------------
- def play
- $game_switches[@play] = true if @play != 0
- $game_switches[@clr] = false if @clr != 0
- $game_switches[@fail] = false if @fail != 0
- $game_map.need_refresh = true
- end
- #--------------------------------------------------------------------------
- # ● 任务成功時SW操作
- #--------------------------------------------------------------------------
- def clear
- $game_switches[@play] = false if @play != 0
- $game_switches[@clr] = true if @clr != 0
- $game_switches[@fail] = false if @fail != 0
- $game_map.need_refresh = true
- end
- #--------------------------------------------------------------------------
- # ● 任务失败時SW操作
- #--------------------------------------------------------------------------
- def fail
- $game_switches[@play] = false if @play != 0
- $game_switches[@clr] = false if @clr != 0
- $game_switches[@fail] = true if @fail != 0
- $game_map.need_refresh = true
- end
- end
- #=============================================================================
- # ■ 任务管理情报
- #=============================================================================
- class QuestData
- #--------------------------------------------------------------------------
- # ● 公开实例变数
- #--------------------------------------------------------------------------
- attr_reader :id # 任务ID(変更不可)
- attr_accessor :name # 任务名
- attr_accessor :client # 委托人
- attr_accessor :rank # 任务Rank等级
- attr_accessor :visible # 显示许可
- attr_accessor :enable # 公会接受许可
- attr_accessor :pre # 前提条件
- attr_accessor :condition# clear条件
- attr_accessor :result # 报酬
- attr_accessor :view_res # 报酬=有显示
- attr_accessor :view_cond# 有进展显示
- attr_reader :sw # 开关操作(play/clear/fail)
- attr_accessor :text # 委托内容
- attr_reader :playing # 任务实行中
- attr_reader :status # 任务结果
- attr_reader :report # 任务报告OK
- #--------------------------------------------------------------------------
- # ● object初期化
- #--------------------------------------------------------------------------
- def initialize(id)
- @id = id
- reset
- end
- #--------------------------------------------------------------------------
- # ● data重置
- #--------------------------------------------------------------------------
- def reset
- @name = Quest::QUEST[@id][0].dup
- @client = Quest::QUEST[@id][1].dup
- [url=home.php?mod=space&uid=30039]@RAnk[/url] = Quest::QUEST[@id][2].dup
- @visible = Quest::QUEST[@id][3].visible
- @enable = Quest::QUEST[@id][3].enable
- @view_res = Quest::QUEST[@id][3].v_res
- @view_cond= Quest::QUEST[@id][3].v_cond
- @chg_ev = Quest::QUEST[@id][3].chg_ev
- @shop_ids = Quest::QUEST[@id][3].ids
- [url=home.php?mod=space&uid=395398]@PRE[/url] = Quest::QUEST[@id][4].dup
- @condition= Quest::QUEST[@id][5].dup
- @result = Quest::QUEST[@id][6].dup
- @sw = Quest::QUEST[@id][7].dup
- @text = Quest::QUEST[@id][8].dup
- @playing = false
- @status = STAY
- @report = false
- @sw.reset
- end
- #--------------------------------------------------------------------------
- # ● 状态
- #--------------------------------------------------------------------------
- def clear # 成功
- return (@status == CLEAR)
- end
- def fail # 失败
- return (@status == FAIL)
- end
- def finish # 结束(不论结果)
- return ((@status != STAY) and !@report) # 报告后尚未结束
- end
- def clear_finish # 任务成功结束
- return (finish and clear)
- end
- def fail_finish # 任务失败结束
- return (finish and fail)
- end
- def guild_report # 等待向公会报告
- return (!finish and @enable and @playing)
- end
- def guild_enable(id=0) # 公会可接受任务
- if !@shop_ids.empty?
- return false if !@shop_ids.include?(id)
- end
- return (!finish and @enable and !@playing)
- end
- #--------------------------------------------------------------------------
- # ● 页面数
- #--------------------------------------------------------------------------
- def page_num
- return @text.split(/\\p/).size
- end
- #--------------------------------------------------------------------------
- # ● 指定页面上的文本
- #--------------------------------------------------------------------------
- def page_text(page)
- txt = @text.split(/\\p/)
- return txt
- end
- #--------------------------------------------------------------------------
- # ● 手续费
- #--------------------------------------------------------------------------
- def commission
- ret = 0
- for item in @pre
- next if item.type != MONEY
- ret += item.num
- end
- return ret
- end
- #--------------------------------------------------------------------------
- # ● 报酬金额
- #--------------------------------------------------------------------------
- def premium
- ret = 0
- @result.each do |item|
- next if item.penalty or item.type != MONEY
- ret += item.num
- end
- return ret
- end
- #--------------------------------------------------------------------------
- # ● 报酬金额 变更
- #--------------------------------------------------------------------------
- def change_premium(money)
- @result.each_index do |i|
- next if @result[i].penalty or @result[i].type != MONEY
- @result.delete_at(i) # 减去所有MONEY
- end
- @result.push(RsltMoney.new(money))
- end
- #--------------------------------------------------------------------------
- # ● 报酬金额 追加
- #--------------------------------------------------------------------------
- def add_premium(money)
- money += premium
- change_premium(money)
- end
- #--------------------------------------------------------------------------
- # ● 惩罚ー金额
- #--------------------------------------------------------------------------
- def penalty
- ret = 0
- @result.each do |item|
- next if !item.penalty or item.type != MONEY
- ret += item.num
- end
- return ret
- end
- #--------------------------------------------------------------------------
- # ● 惩罚ー金额 变更
- #--------------------------------------------------------------------------
- def change_penalty(money)
- @result.each_index do |i|
- next if !@result[i].penalty or @result[i].type != MONEY
- @result.delete_at(i) # 减去所有MONEY
- end
- @result.push(RsltMoneyP.new(money))
- end
- #--------------------------------------------------------------------------
- # ● 惩罚ー金额 追加
- #--------------------------------------------------------------------------
- def add_penalty(money)
- money += penalty
- change_penalty(money)
- end
- #--------------------------------------------------------------------------
- # ● 任务开始可能?
- #--------------------------------------------------------------------------
- def can_start?
- return false if finish
- @pre.each do |cond|
- return false unless cond.condition_clear?(true) # 前提条件未满足
- end
- return true if @rank.quest.nil?
- return (@rank.quest <= $game_party.quest_rank)
- end
- #--------------------------------------------------------------------------
- # ● 任务不能开始的理由[文本]
- #--------------------------------------------------------------------------
- def start_cause
- unless @rank.quest.nil?
- if @rank.quest > $game_party.quest_rank
- return "Rank等级\\n不够接受该任务"
- end
- end
- cause = []
- @pre.each do |cond|
- cause.push(cond) unless cond.condition_clear?(true)
- end
- unless cause.empty?
- return cause[0].cause("开始") if cause.size == 1
- return "开始条件尚未满足"
- end
- p "QuestData[#{@id}].start_cause no cause"
- return "" ## 在这里使用不好
- end
- #--------------------------------------------------------------------------
- # ● 有报告的义务?
- #--------------------------------------------------------------------------
- def report?
- return false if !@enable or @report # 没有公会任务 or 报告已完成
- @condition.each do |cond|
- return true if cond.report?
- end
- return false
- end
- #--------------------------------------------------------------------------
- # ● 报告等待?
- #--------------------------------------------------------------------------
- def wait_report?
- return (report? and @playing)
- end
- #--------------------------------------------------------------------------
- # ● 任务的clear条件是否满足?
- #--------------------------------------------------------------------------
- def quest_clear?
- @condition.each do |cond|
- return false unless cond.condition_clear?(@report)
- end
- return true
- end
- #--------------------------------------------------------------------------
- # ● 任务未成功的理由[文本]
- #--------------------------------------------------------------------------
- def clear_cause
- cause = []
- @condition.each do |cond|
- cause.push(cond) unless cond.condition_clear?(@report)
- end
- unless cause.empty?
- return cause[0].cause("clear") if cause.size == 1
- return "clear条件不满足"
- end
- p "QuestData[#{@id}].clear_cause no cause"
- return "" ## 在这里使用不好
- end
- #--------------------------------------------------------------------------
- # ● 任务开始
- #--------------------------------------------------------------------------
- def quest_start
- $game_temp.questresult_id = @id
- @enable = false if @chg_ev ## 公会任务→事件任务变更
- @visible = true
- @playing = true
- @status = STAY
- @report = false
- @sw.play
- @pre.each { |cond| cond.condition_lose } # 完成条件物品减少
- end
- #--------------------------------------------------------------------------
- # ● 任务clear
- #--------------------------------------------------------------------------
- def quest_clear(force=false, audio=true)
- if report? and !force # 是否有义务去报告、等待报告
- @status = CLEAR
- @report = true
- else
- $game_temp.questresult_id = @id
- @playing = false
- @status = CLEAR
- @report = false
- @view_cond = false # 进展显示OFF
- @sw.clear
- @condition.each { |cond| cond.condition_lose } # 完成条件物品减少
- @result.each { |item| item.gain } # 报酬
- $game_temp.questresult_old_rank = $game_party.quest_rank
- if @rank.r_next.nil?
- # 什么也没有
- elsif @rank.r_next == 0 # 加算
- $game_party.quest_rank = [10, ($game_party.quest_rank+1)].min
- elsif $game_party.quest_rank < @rank.r_next # jump up
- $game_party.quest_rank = @rank.r_next
- end
- clear_audio if audio
- end
- end
- #--------------------------------------------------------------------------
- # ◆任务失败
- #--------------------------------------------------------------------------
- def quest_fail(force=false, audio=true)
- if report? and !force # 是否有义务去报告、等待报告
- @status = FAIL
- @report = true
- else
- $game_temp.questresult_id = @id
- @playing = false
- @status = FAIL
- @report = false
- @view_cond = false # 进展显示OFF
- @sw.fail
- @result.each { |item| item.lose } # 惩罚
- $game_temp.questresult_old_rank = $game_party.quest_rank
- if @rank.r_down.nil?
- # 什么也没有
- elsif @rank.r_down == 0 # 减算
- $game_party.quest_rank = [1, ($game_party.quest_rank-1)].max
- elsif $game_party.quest_rank > @rank.r_down # jump up
- $game_party.quest_rank = @rank.r_down
- end
- fail_audio if audio
- end
- end
- #----------------------------------------------------------------------------
- # ● 成功時音效
- #----------------------------------------------------------------------------
- def clear_audio
- CLR_A_FILE.play
- end
- #----------------------------------------------------------------------------
- # ● 失败時音效
- #----------------------------------------------------------------------------
- def fail_audio
- FAIL_A_FILE.play
- end
- end
- #=============================================================================
- # ■ 任务列表的管理情报
- #=============================================================================
- class QuestList
- #--------------------------------------------------------------------------
- # ● 公开实例变量
- #--------------------------------------------------------------------------
- attr_reader :ids
- #--------------------------------------------------------------------------
- # ● object初期化
- #--------------------------------------------------------------------------
- def initialize
- reset
- end
- #--------------------------------------------------------------------------
- # ● 任务列表重置
- #--------------------------------------------------------------------------
- def reset(id_only=false)
- # reset时创建数据库、read時依序生成
- @list = {} unless id_only
- # 读取任务设定的ID
- @ids = QUEST.keys.sort.dup
- end
- #--------------------------------------------------------------------------
- # ● data参照
- #--------------------------------------------------------------------------
- def [](id)
- unless @ids.include?(id)
- unless QUEST.keys.include?(id)
- p "不正确的任务ID[#{id}]被指定"
- return nil # nil返回。应该会出现NoMethodError
- end
- @ids.push(id)
- @ids.sort!
- end
- if @list[id].nil? # 因为没有object
- @list[id] = QuestData.new(id)
- end
- return @list[id]
- end
- #--------------------------------------------------------------------------
- # ● 进行中任务数
- #--------------------------------------------------------------------------
- def num_of_playing
- cnt = 0
- for id in @ids
- cnt += 1 if @list[id].playing
- end
- return cnt
- end
- #--------------------------------------------------------------------------
- # ● clear任务数
- #--------------------------------------------------------------------------
- def num_of_clear
- cnt = 0
- for id in @ids
- cnt += 1 if @list[id].clear
- end
- return cnt
- end
- #--------------------------------------------------------------------------
- # ● 失败任务数
- #--------------------------------------------------------------------------
- def num_of_fail
- cnt = 0
- for id in @ids
- cnt += 1 if @list[id].fail
- end
- return cnt
- end
- #--------------------------------------------------------------------------
- # ● 进行中公会任务数
- #--------------------------------------------------------------------------
- def num_of_shop_playing
- cnt = 0
- for id in @ids
- cnt += 1 if @list[id].enable and @list[id].playing
- end
- return cnt
- end
- #--------------------------------------------------------------------------
- # ● 进行中任务数是否超过规定上限?
- #--------------------------------------------------------------------------
- def over_playing?
- return false if MAX == nil
- return (num_of_shop_playing >= MAX)
- end
- end
- #--------------------------------------------------------------------------
- # ● 平均Level
- #--------------------------------------------------------------------------
- def self.level_ave
- lv = 0
- $game_party.members.each { |actor| lv += actor.level }
- return (lv / $game_party.members.size).truncate
- end
- #----------------------------------------------------------------------------
- # ● 任务列表名称
- #----------------------------------------------------------------------------
- def self.questlist_name
- QUEST_LIST.collect { |c| LIST_NAME[c] }
- end
- #----------------------------------------------------------------------------
- # ● 公会命令列表名称
- #----------------------------------------------------------------------------
- def self.guild_name
- GUILD_LIST.collect { |c| GUILD_NAME[c] }
- end
- #--------------------------------------------------------------------------
- # ● 控制文字的变换
- #--------------------------------------------------------------------------
- def self.conv_text(txt)
- return "" if txt.nil? or txt == ""
- text = txt.dup
- ## 控制字符的解码变换
- # 会先进行名称转换
- # \\n[n] : ID:n-角色ー名
- text.gsub!(/\\[Nn]\[([0-9]+)\]/) { $game_actors[$1.to_i].name }
- # \\e[n] : ID:n-敌人ー名
- text.gsub!(/\\[Ee]\[([0-9]+)\]/) { $data_enemies[$1.to_i].name }
- # \\j[n] : ID:n-职业名
- text.gsub!(/\\[Jj]\[([0-9]+)\]/) { $data_classes[$1.to_i].name }
- # \\s[n] : ID:n-技能名
- text.gsub!(/\\[Ss]\[([0-9]+)\]/) { $data_skills[$1.to_i].name }
- # \\i[n] : ID:n-物品名
- text.gsub!(/\\[Tt]\[([0-9]+)\]/) { $data_items[$1.to_i].name }
- # \\w[n] : ID:n-武器名
- text.gsub!(/\\[Ww]\[([0-9]+)\]/) { $data_weapons[$1.to_i].name }
- # \\a[n] : ID:n-防具名
- text.gsub!(/\\[Aa]\[([0-9]+)\]/) { $data_armors[$1.to_i].name }
- # \\m[n] : ID:n-地图名
- text.gsub!(/\\[Mm]\[([0-9]+)\]/) { load_data(sprintf("Data/Map%03d.rvdata2", $1.to_i)).display_name }
- # \\q[n] : ID:n-任务名
- text.gsub!(/\\[Qq]\[([0-9]+)\]/) { $game_system.quest[$1.to_i].name }
- return text
- end
- #--------------------------------------------------------------------------
- # ● 委托内容描画
- #--------------------------------------------------------------------------
- def self.draw_quest_text(bitmap, x, y, w, text_h, txt)
- txt = "" if txt.nil?
- text = self.conv_text(txt)
- y_org = y
- xx = 0
- line = 0
-
- # 便宜上
- text.gsub!(/\\\\/) { "\000" }
- # \\c[n] : 文字色変更
- text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
- # \\+ : 加粗表示 开始/结束
- text.gsub!(/\\[+]/) { "\002" }
- # \\- : 斜体表示 开始/结束
- text.gsub!(/\\[-]/) { "\003" }
- # \\x[n] : X轴方向 n 的当前位置刻画
- text.gsub!(/\\[Xx]\[([0-9]+)\]/) { "\004[#{$1}]" }
- # \\y[n] : 指定行CR回车
- text.gsub!(/\\[Yy]\[([0-9]+)\]/) { "\005[#{$1}]" }
- # \\i : icon表示
- text.gsub!(/\\[Ii]\[(.*?+)\]/) { "\006[#{$1}]" }
- # \\{} : 扩大・缩小
- text.gsub!(/\\{/) { "\007" }
- text.gsub!(/\\}/) { "\008" }
- # \\n : 改行
- text.gsub!(/\\[Nn]/) { "\n" }
-
-
- bold = bitmap.font.bold
- italic = bitmap.font.italic
- color = bitmap.font.color.dup
- size = bitmap.font.size
- while ((c = text.slice!(/./m)) != nil)
- case c
- when "\000" # \\ 的场合,还原原来的文字
- c = "\\"
- when "\n" # \\n : 改行
- xx = 0; y += text_h; line += 1
- next # 下一个字符
- when "\001" # \\c[n] : 文字色变更
- text.sub!(/\[([0-9]+)\]/, "")
- bitmap.font.color = self.text_color($1.to_i)
- next # 下一个字符
- when "\002" # \\+ : 加粗表示 开始/结束
- bitmap.font.bold = !bitmap.font.bold
- next # 下一个字符
- when "\003" # \\- : 斜体表示 开始/结束
- bitmap.font.italic = !bitmap.font.italic
- next # 下一个字符
- when "\004" # \\x[n] : X轴方向 n 的当前位置刻画
- text.sub!(/\[([0-9]+)\]/, "")
- xx = $1.to_i
- next # 下一个字符
- when "\005" # \\y[n] : 指定行CR回车
- text.sub!(/\[([0-9]+)\]/, "")
- y = y_org + $1.to_i * text_h
- xx = 0
- next # 下一个字符
- when "\006" # \\i : icon显示
- text.sub!(/\[(.*?+)\]/, "")
- xx += self.draw_icon(bitmap, x+xx, y, text_h, $1.to_i)
- next # 下一个字符
- when "\007" # \\{ : 扩大
- bitmap.font.size += 8 if bitmap.font.size <= 64
- next # 下一个字符
- when "\008" # \\} : 缩小
- bitmap.font.size -= 8 if bitmap.font.size >= 16
- next # 下一个字符
- end
- # 文字描画
- bitmap.draw_text(x+xx, y, 40, text_h, c)
- # x 被绘制字符宽度的加算
- xx += bitmap.text_size(c).width
- # 自动改行
- if xx > w
- xx = 0; y += text_h
- end
- end
- # 作为预防措施,还原初始设定
- bitmap.font.bold = bold
- bitmap.font.italic = italic
- bitmap.font.color = color.dup
- bitmap.font.size = size
- end
- #--------------------------------------------------------------------------
- # ● 描画(Icon) \\icon用
- #--------------------------------------------------------------------------
- def self.draw_icon(bitmap, x, y, h, icon_index)
- bit = Cache.system("Iconset")
- rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
- bitmap.blt(x, y, bit, rect)
- return rect.width
- end
- #--------------------------------------------------------------------------
- # ● 描画色 \\c用
- #--------------------------------------------------------------------------
- def self.text_color(n)
- return Cache.system("Window").get_pixel(64 + (n % 8) * 8, 96 + (n / 8) * 8)
- end
- end
- #==============================================================================
- # ■ Game_System
- #==============================================================================
- class Game_System
- #--------------------------------------------------------------------------
- # ● 公开实例变量
- #--------------------------------------------------------------------------
- attr_reader :quest # 任务列表
- #--------------------------------------------------------------------------
- # ● object初期化
- #--------------------------------------------------------------------------
- alias initialize_quest initialize
- def initialize
- initialize_quest
- @quest = Quest::QuestList.new
- end
- end
- #==============================================================================
- # ■ Game_Party
- #==============================================================================
- class Game_Party
- #--------------------------------------------------------------------------
- # ● 公开实例变量
- #--------------------------------------------------------------------------
- attr_accessor :quest_rank
- #--------------------------------------------------------------------------
- # ● object初期化
- #--------------------------------------------------------------------------
- alias initialize_quest initialize
- def initialize
- initialize_quest
- @quest_rank = 1
- end
- end
复制代码 |
|