赞 | 153 |
VIP | 10 |
好人卡 | 39 |
积分 | 93 |
经验 | 146191 |
最后登录 | 2024-5-6 |
在线时间 | 2504 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 9280
- 在线时间
- 2504 小时
- 注册时间
- 2011-5-20
- 帖子
- 15389
|
LZ的任务脚本很多问题的说···建议这个- ==============================================================================
- # 任务系统v0.3 by EngShun
- #
- # 设置方法请参考范例
- #
- # 效果说明:
- # 支持普通对话框效果
- # a[号码] :更改对齐方式(0,1,2)。
- # itm[物品id] :物品数量
- # wpn[武器id] :武器数量
- # amr[防具id] :防具数量
- # eval{脚本} :运行脚本
- # old :字体加粗,插入多一次关闭
- # italic :字体打斜,插入多一次关闭
- # f[字体名称] :更改字体
- # s[号码] :更改字体大小
- # p[名称] :插入图片
- # icon[名称] :插入图标
- #任务全由注释来设置
- #设置标识有:
- # 1.任务设置
- # 2.完成任务[任务名]
- # 3.放弃任务[任务名]
- # 4.恢复任务[任务名]
- # 5.删除任务[任务名]
- # 6.完成所有任务
- # 7.恢复所有任务
- # 8.删除所有任务
- # 注释内容至少要有三行,第一行未标识,第二行为任务名字,第三行及以下为任务说明
- # ,若一页注释无法完成所有的说明没关系,可以延伸到下一页。
- # 完成匹配的任务,若已放弃的任务便无法完成。
- # 放弃匹配的任务,若已完成的任务便无法放弃。
- # 恢复匹配已放弃的任务。
- # 删除匹配的任务。
- # 完成所有的任务,若已放弃的任务便无法完成。
- # 恢复所有已放弃的任务。
- # 删除所有的任务
- # *注意*所有的标识必须在注释的第一行*
- #==============================================================================
- class Game_Mission
- attr_reader :doned
- attr_reader :failed
- def initialize
- @mission = []
- @info = []
- @doned = []
- @failed = []
- end
- def none?
- return @mission == []
- end
- def mission
- if @mission == []
- return ["当前没有任何任务"]
- end
- return @mission
- end
- def info
- if @info == []
- return ["a[1]c[2]s[50]f[楷体]当前没有任何任务"]
- end
- return @info
- end
- def get(mission,info)
- unless @mission.include?(mission)
- @mission.push(mission)
- @info.push(info)
- end
- end
- def done(done_mission)
- for i in [email protected]
- if @mission[i] == done_mission and [email protected]?(i)
- @doned.delete(i) if @doned.include?(i)
- @doned.push(i)
- end
- end
- end
- def delete(delete_mission)
- for i in [email protected]
- if @mission[i] == delete_mission
- @mission.delete(delete_mission)
- delete_info = @info[i]
- @info.delete(delete_info)
- @doned.delete(i) if @doned.include?(i)
- end
- end
- end
- def fail(mission)
- for i in [email protected]
- if @mission[i] == mission and [email protected]?(i)
- @failed.delete(i) if @failed.include?(i)
- @failed.push(i)
- end
- end
- end
- def resume(mission)
- for i in [email protected]
- if @mission[i] == mission and
- @failed.delete(i)
- end
- end
- end
- def done_all
- for i in [email protected]
- @doned.delete(i) if @doned.include?(i)
- @doned.push(i)
- end
- end
- def delete_all
- @mission = []
- @info = []
- @doned = []
- @failed = []
- end
- def resume_all
- @failed = []
- end
- end
- class Window_Mission < Window_Selectable
- def initialize
- super(0, 64, 200, 416)
- self.index = 0
- @item_max = $game_party.mission.mission.size
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- self.contents = Bitmap.new(width - 32, @item_max * 32)
- for i in 0...$game_party.mission.mission.size
- t = ($game_party.mission.doned.include?(i) or $game_party.mission.failed.include?(i))
- self.contents.font.color = t ? disabled_color : normal_color
- text = $game_party.mission.mission[i]
- self.contents.draw_text(4, i * 32, 160, 32, text.to_s)
- self.contents.font.color = system_color
- self.contents.draw_text(self.contents.width-32, i * 32, 32, 32, "□",1) unless $game_party.mission.none?
- if $game_party.mission.doned.include?(i)
- self.contents.font.color = crisis_color
- self.contents.draw_text(self.contents.width-32, i * 32, 32, 32, "√",1)
- elsif $game_party.mission.failed.include?(i)
- self.contents.font.color = knockout_color
- self.contents.draw_text(self.contents.width-32, i * 32, 32, 32, "×",1)
- end
- end
- end
- end
- class Window_Info < Window_Base
- def initialize
- super(200,64,440,416)
- self.contents = Bitmap.new(408, 384)
- end
- def refresh(str)
- self.contents = Bitmap.new(408, 384) if self.contents == nil
- self.contents.clear
- y = 0
- align = 0
- begin
- last_text = str.clone
- str.gsub!(/[Vv][([0-9]+)]/) { $game_variables[$1.to_i] }
- str.gsub!(/[Gg]/) { $game_party.gold.to_s }
- str.gsub!(/[Ii][Tt][Mm][(d+)]/) { $game_party.item_number($1.to_i) }
- str.gsub!(/[Ww][Pp][Nn][(d+)]/) { $game_party.weapon_number($1.to_i) }
- str.gsub!(/[Aa][Mm][Rr][(d+)]/) { $game_party.armor_number($1.to_i) }
- str.gsub!(/[Ee][Vv][Aa][Ll]{([.,
, - ]+)}/) { eval($1) }
- end until str == last_text
- str.gsub!(/[Nn][([0-9]+)]/) do
- $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
- end
- lines = str.split("
- ")
- for line in lines
- bitmap,align = bitmap_line(line,align)
- w = bitmap.width
- h = bitmap.height
- case align
- when 0
- x = 4
- when 1
- x = 204 - w / 2
- when 2
- x = 404 - w
- end
- self.contents.blt(x,y,bitmap,Rect.new(0,0,w,h))
- y += h
- end
- end
- def bitmap_line(str,old_align)
- w,h = get_wh(str.clone)
- w = 1 if w == 0
- bitmap = Bitmap.new(w,h)
- text = str
- align = old_align
- x = 0
- text.gsub!(//) { "\000" }
- text.gsub!(/[Aa][(d+)]/){
- align = $1.to_i
- ""
- }
- text.gsub!(/[Cc][([0-9]+)]/) { "\001[#{$1}]" }
- text.gsub!(/[Bb][Oo][Ll][Dd]/) { "\002" }
- text.gsub!(/[Ii][Tt][Aa][Ll][Ii][Cc]/) { "\003" }
- text.gsub!(/[Ff][(w+)]/) { "\004[#{$1}]" }
- text.gsub!(/[Bb][Dd][(w+)]/) { "\005[#{$1}]" }
- text.gsub!(/[Ss][(d+)]/) { "\006[#{$1}]" }
- text.gsub!(/[Pp][([w,-]+)]/) { "\007[#{$1}]" }
- text.gsub!(/[Ii][Cc][Oo][Nn][([w,-]+)]/){ "201[#{$1}]" }
- while ((c = text.slice!(/./m)) != nil)
- if c == "\000"
- c = ""
- end
- if c == "\001"
- text.sub!(/[([0-9]+)]/, "")
- color = $1.to_i
- if color >= 0 and color <= 9
- bitmap.font.color = text_color(color)
- elsif color == 8
- bitmap.font.color = disabled_color
- elsif color == 9
- bitmap.font.color = system_color
- end
- next
- end
- if c == "\002"
- bitmap.font.bold = bitmap.font.bold ? false : true
- next
- end
- if c == "\003"
- bitmap.font.italic = bitmap.font.italic ? false : true
- next
- end
- if c == "\004"
- text.sub!(/[(w+)]/,"")
- bitmap.font.name = $1
- next
- end
- if c == "\005"
- text.sub!(/[(w+)]/,"")
- color = bitmap.font.color.clone
- w = bitmap.text_size($1).width
- bitmap.font.color = Color.new(0,0,0,255)
- bitmap.draw_text((4 + x)-1, y-1, w, 32, $1)
- bitmap.draw_text((4 + x)-1, y+1, w, 32, $1)
- bitmap.draw_text((4 + x)+1, y-1, w, 32, $1)
- bitmap.draw_text((4 + x)+1, y+1, w, 32, $1)
- bitmap.font.color = color
- bitmap.draw_text(4 + x, y, w, 32, $1)
- x += bitmap.text_size($1).width
- next
- end
- if c == "\006"
- text.sub!(/[(d+)]/,"")
- bitmap.font.size = $1.to_i
- next
- end
- if c == "\007"
- text.sub!(/[([w,-]+)]/,"")
- pic = RPG::Cache.picture($1)
- r = Rect.new(0,0,pic.width,pic.height)
- y = h / 2 - pic.height / 2
- bitmap.blt(x+2,y,pic,r)
- x += pic.width + 4
- next
- end
- if c == "201"
- text.sub!(/[([w,-]+)]/,"")
- pic = RPG::Cache.icon($1)
- r = Rect.new(0,0,pic.width,pic.height)
- y = h / 2 - pic.height / 2
- bitmap.blt(x+2,y,pic,r)
- x += pic.width + 4
- next
- end
- bitmap.draw_text(x,0,w,h,c)
- x += bitmap.text_size(c).width
- end
- return bitmap.clone,align
- end
- def get_wh(str)
- bitmap = Bitmap.new(160,160)
- w = 0
- h = 32
- text = str
- text.gsub!(//) { "\000" }
- text.gsub!(/[Aa][(d+)]/) { "" }
- text.gsub!(/[Cc][([0-9]+)]/) { "" }
- text.gsub!(/[Bb][Oo][Ll][Dd]/) { "" }
- text.gsub!(/[Ii][Tt][Aa][Ll][Ii][Cc]/) { "" }
- text.gsub!(/[Ff][(w+)]/) { "\001[#{$1}]" }
- text.gsub!(/[Bb][Dd][(w+)]/) { $1 }
- text.gsub!(/[Ss][(d+)]/) { "\002[#{$1}]" }
- text.gsub!(/[Pp][([w,-]+)]/) { "\003[#{$1}]" }
- text.gsub!(/[Ii][Cc][Oo][Nn][(w,[A-Za-z0-9_-]+)]/) { "\004[#{$1}]" }
- while ((c = text.slice!(/./m)) != nil)
- if c == "\000"
- c = ""
- end
- if c == "\001"
- text.sub!(/[(w+)]/,"")
- bitmap.font.name = $1
- next
- end
- if c == "\002"
- text.sub!(/[(d+)]/,"")
- bitmap.font.size = $1.to_i
- next
- end
- if c == "\003"
- text.sub!(/[([w,-]+)]/,"")
- w += RPG::Cache.picture($1).width+4
- h = RPG::Cache.picture($1).height if RPG::Cache.picture($1).height > 32 and RPG::Cache.picture($1).height > h
- next
- end
- if c == "\004"
- text.sub!(/[([w,-]+)]/,"")
- w += RPG::Cache.icon($1).width+4
- h = RPG::Cache.icon($1).height if RPG::Cache.icon($1).height > 32 and RPG::Cache.icon($1).height > h
- next
- end
- w += bitmap.text_size(c).width
- h = bitmap.text_size(c).height if bitmap.text_size(c).height > 32 and bitmap.text_size(c).height > h
- end
- return w,h
- end
- end
- class Scene_Mission
- def main
- @window1 = Window_Base.new(0,0,200,64)
- @window1.contents = Bitmap.new(168,32)
- @window1.contents.draw_text(0,0,168,32,"任务概述",1)
- @window2 = Window_Base.new(200,0,440,64)
- @window2.contents = Bitmap.new(408,32)
- @window2.contents.draw_text(0,0,408,32,"任务简介",1)
- @mission_window = Window_Mission.new
- @mission_window.index = $game_party.mission.mission.size - 1
- @info_window = Window_Info.new
- info = $game_party.mission.info[@mission_window.index].clone
- @info_window.refresh(info)
- Graphics.transition
- loop do
- Graphics.update
- Input.update
- update
- if $scene != self
- break
- end
- end
- Graphics.freeze
- @window1.dispose
- @window2.dispose
- @mission_window.dispose
- @info_window.dispose
- end
- def update
- @mission_window.update
- @info_window.update
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- $scene = Scene_Map.new
- return
- end
- if Input.repeat?(Input::UP) or
- Input.repeat?(Input::DOWN)
- info = $game_party.mission.info[@mission_window.index].clone
- @info_window.refresh(info)
- end
- end
- end
- class Game_Party
- attr_accessor :mission
- alias orig_init initialize
- def initialize
- @mission = Game_Mission.new
- orig_init
- end
- end
- class Interpreter
- alias orig_ec execute_command
- def execute_command
- if @index >= @list.size - 1
- command_end
- return true
- end
- @parameters = @list[@index].parameters
- return command_108 if @list[@index].code == 108
- return orig_ec
- end
- def command_108
- text = @list[@index].parameters[0]
- if text.sub!(/删除任务[(w+)]/,"") != nil
- $game_party.mission.delete($1)
- return true
- elsif text.sub!(/完成任务[(w+)]/,"") != nil
- $game_party.mission.done($1)
- return true
- elsif text.sub!(/删除所有任务/,"") != nil
- $game_party.mission.delete_all
- return true
- elsif text.sub!(/完成所有任务/,"") != nil
- $game_party.mission.done_all
- return true
- elsif text.sub!(/放弃任务[(w+)]/,"") != nil
- $game_party.mission.fail($1)
- return true
- elsif text.sub!(/恢复任务[(w+)]/,"") != nil
- $game_party.mission.resume($1)
- return true
- elsif text.sub!(/恢复所有任务/,"") != nil
- $game_party.mission.resume_all
- return true
- end
- loop do
- if @list[@index+1].code == 108 or @list[@index+1].code == 408
- text += "
- " + @list[@index+1].parameters[0]
- else
- break
- end
- @index += 1
- end
- split = text.split("
- ")
- if split[0] == "任务设置" and split.size >= 3
- info , name = split[2] , split[1]
- if split.size >= 4
- for i in 3...split.size
- info += "
- " + split[i]
- end
- end
- $game_party.mission.get(name,info)
- end
- return true
- end
- end
复制代码
‘‘──chd114于2012-5-26 14:42补充以下内容
- 任务设置
- 寻找恢复剂
- a[1]s[26]寻找恢复剂s[22]
- a[0]
- 必须寻找五个 icon[021-Potion01]回复剂。
- 进度 itm[1]/5
复制代码 收集任务在注释这样放
长介绍任务这样- 任务设置
- 不可能的任务
- 这是一个c[2]不可能的任务c[0]
- 这个任务的说明很长
- a[1]很长很长很长很长很长很长
- 很长很长很长很长很长很长
复制代码 上面是注释第一部分,第二部分- 很长很长很长很长很长很长
- 很长很长很长很长很长很长
- a[2]很长很长很长很长很长很长
- 很长很长很长很长很长很长
- 很长很长很长很长很长很长
- 很长很长很长很长很长很长
复制代码 这样就算再长的任务介绍也能放下
完成任务是这样放弃任务(暂时)彻底删除一个任务就是这样!
’’
‘‘──chd114于2012-5-26 14:43补充以下内容
这些短的代码是放到注释里用
’’
‘‘──chd114于2012-5-26 14:43补充以下内容
说白了就是可以在游戏中临时创建任何任务!而且不需要额外在脚本编辑器设定
’’ |
|