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

Project1

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

[已经过期] 再次提问..........任务系统

[复制链接]

Lv1.梦旅人

梦石
0
星屑
55
在线时间
135 小时
注册时间
2013-8-7
帖子
79
跳转到指定楼层
1
发表于 2013-10-19 15:33:22 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
RUBY 代码复制
  1. #==============================================================================#
  2. #                        便民任务界面v0.5 by EngShun                           #
  3. #                                                                              #
  4. #    设置方法请参考范例                                                        #
  5. #                                                                              #
  6. #    效果说明:                                                                #
  7. #    支持普通对话框效果                                                        #
  8. #    \a[号码]     :更改对齐方式(0,1,2)。                                     #
  9. #    \itm[物品id] :物品数量                                                    #
  10. #    \wpn[武器id] :武器数量                                                    #
  11. #    \amr[防具id] :防具数量                                                    #
  12. #    \eval{脚本}  :运行脚本                                                    #
  13. #    \bold        :字体加粗,插入多一次关闭                                    #
  14. #    \italic      :字体打斜,插入多一次关闭                                    #
  15. #    \f[字体名称] :更改字体                                                    #
  16. #    \s[号码]     :更改字体大小                                                #
  17. #    \p[名称]     :插入图片                                                    #
  18. #    \icon[名称]  :插入图标                                                    #
  19. #                                                                              #
  20. #==============================================================================#
  21.  
  22. #===============================================================================
  23. # ■ 队伍
  24. #===============================================================================
  25. class Game_Party
  26.   Mission = Struct.new(:name, :info, :status)
  27.   alias org_init_mission initialize
  28.   def initialize
  29.     [url=home.php?mod=space&uid=364398]@mission[/url] = []
  30.     org_init_mission
  31.   end
  32.   def no_mission?
  33.     return @mission == []
  34.   end
  35.   def mission
  36.     if @mission == []
  37.       m = Mission.new("没有任务","\n\n\n\\a[1]\\s[32]你还没有领取任何任务",0)
  38.       return [m]
  39.     end
  40.     return @mission
  41.   end
  42.   def get_mission(mission,info)
  43.     for i in [email]0...@mission.size[/email]
  44.       if @mission[i].name == mission
  45.         return
  46.       end
  47.     end
  48.     @mission.push(Mission.new(mission,info,0))
  49.   end
  50.   def done_mission(done_mission)
  51.     for i in [email]0...@mission.size[/email]
  52.       if @mission[i].name == done_mission
  53.         @mission[i].status = 1 if @mission[i].status == 0
  54.       end
  55.     end
  56.   end
  57.   def delete_mission(delete_mission)
  58.     for i in [email]0...@mission.size[/email]
  59.       if @mission[i].name == delete_mission
  60.         @mission.delete(@mission[i])
  61.         return
  62.       end
  63.     end
  64.   end
  65.   def fail_mission(mission)
  66.     for i in [email]0...@mission.size[/email]
  67.       if @mission[i].name == mission
  68.         @mission[i].status = 2 if @mission[i].status == 0
  69.       end
  70.     end
  71.   end
  72.   def resume_mission(mission)
  73.     for i in [email]0...@mission.size[/email]
  74.       if @mission[i].name == mission
  75.         @mission[i].status = 0 if @mission[i].status == 2
  76.       end
  77.     end
  78.   end
  79.   def done_all_mission
  80.     @mission.each{|m|m.status = 1}
  81.   end
  82.   def update_mission(mission,info)
  83.     for i in [email]0...@mission.size[/email]
  84.       if @mission[i].name == mission
  85.         @mission[i].info = info
  86.       end
  87.     end
  88.   end
  89.   def add_mission_info(mission,info)
  90.     for i in [email]0...@mission.size[/email]
  91.       if @mission[i].name == mission
  92.         @mission[i].info += "\n" + info
  93.       end
  94.     end
  95.   end
  96.   def delete_all_mission
  97.     @mission = []
  98.   end
  99.   def resume_all_mission
  100.     @mission.each{|m|m.status = 0 if m.status == 2}
  101.   end
  102. end
  103.  
  104. #===============================================================================
  105. # ■ 任务列表窗口
  106. #===============================================================================
  107. class Window_Mission < Window_Selectable
  108.   def initialize
  109.     super(0, 64, 200, 416)
  110.     self.index = 0
  111.     @item_max = $game_party.mission.size
  112.     if self.contents != nil
  113.       self.contents.dispose
  114.       self.contents = nil
  115.     end
  116.     self.contents = Bitmap.new(width - 32, @item_max * 32)
  117.     for i in 0...$game_party.mission.size
  118.       t = $game_party.mission[i].status != 0
  119.       self.contents.font.color = t ? disabled_color : normal_color
  120.       text = $game_party.mission[i].name
  121.       self.contents.draw_text(4, i * 32, 160, 32, text.to_s)
  122.       self.contents.font.color = system_color
  123.       self.contents.draw_text(self.contents.width-32, i * 32, 32, 32, "□",1) unless $game_party.no_mission?
  124.       if $game_party.mission[i].status == 1
  125.         self.contents.font.color = crisis_color
  126.         self.contents.draw_text(self.contents.width-32, i * 32, 32, 32, "√",1)
  127.       elsif $game_party.mission[i].status == 2
  128.         self.contents.font.color = knockout_color
  129.         self.contents.draw_text(self.contents.width-32, i * 32, 32, 32, "×",1)
  130.       end
  131.     end
  132.   end
  133. end
  134.  
  135. #===============================================================================
  136. # ■ 任务详情窗口
  137. #===============================================================================
  138. class Window_MissionInfo < Window_Base
  139.   def initialize
  140.     super(200,64,440,416)
  141.     self.contents =  Bitmap.new(408, 384)
  142.   end
  143.   def refresh(str)
  144.     self.contents = Bitmap.new(408, 384) if self.contents == nil
  145.     self.contents.clear
  146.     y = 0
  147.     align = 0
  148.     begin
  149.       last_text = str.clone
  150.       str.gsub!(/\\v\[(\d+)\]/i) { $game_variables[$1.to_i] }
  151.       str.gsub!(/\\g/i) { $game_party.gold.to_s }
  152.       str.gsub!(/\\itm\[(\d+)\]/i) { $game_party.item_number($1.to_i) }
  153.       str.gsub!(/\\wpn\[(\d+)\]/i) { $game_party.weapon_number($1.to_i) }
  154.       str.gsub!(/\\amr\[(\d+)\]/i) { $game_party.armor_number($1.to_i) }
  155.       str.gsub!(/\\eval{(.+?)}/im) { eval($1) }
  156.     end until str == last_text
  157.       str.gsub!(/\\n\[(\d+)\]/i) do
  158.       $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  159.     end
  160.     lines = str.split("\n")
  161.     for line in lines
  162.       bitmap,align = bitmap_line(line,align)
  163.       w = bitmap.width
  164.       h = bitmap.height
  165.       case align
  166.       when 0
  167.         x = 4
  168.       when 1
  169.         x = 204 - w / 2
  170.       when 2
  171.         x = 404 - w
  172.       end
  173.       self.contents.blt(x,y,bitmap,Rect.new(0,0,w,h))
  174.       y += h
  175.     end
  176.   end
  177.   def bitmap_line(str,old_align)
  178.     w,h = get_wh(str.clone)
  179.     w = 1 if w == 0
  180.     bitmap = Bitmap.new(w,h)
  181.     text = str
  182.     align = old_align
  183.     x = 0
  184.     text.gsub!(/\\\\/) { "\000" }
  185.     text.gsub!(/\\a\[([0-2])\]/i){ align = $1.to_i; "" }
  186.     text.gsub!(/\\c\[(\d+)\]/i) { "\001[#{$1}]" }
  187.     text.gsub!(/\\bold/i) { "\002" }
  188.     text.gsub!(/\\italic/i) { "\003" }
  189.     text.gsub!(/\\f\[(\w+)\]/i) { "\004[#{$1}]" }
  190.     text.gsub!(/\\bd\[(\w+)\]/i) { "\005[#{$1}]" }
  191.     text.gsub!(/\\s\[(\d+)\]/i) { "\006[#{$1}]" }
  192.     text.gsub!(/\\p\[(.+?)\]/i) { "\007[#{$1}]" }
  193.     text.gsub!(/\\icon\[(.+?)\]/i){ "\201[#{$1}]" }
  194.     while ((c = text.slice!(/./m)) != nil)
  195.       if c == "\000"
  196.         c = "\\"
  197.       end
  198.       if c == "\001"
  199.         text.sub!(/\[(\d+)\]/, "")
  200.         color = $1.to_i
  201.         if color >= 0 and color <= 9
  202.           bitmap.font.color = text_color(color)
  203.         elsif color == 8
  204.           bitmap.font.color = disabled_color
  205.         elsif color == 9
  206.           bitmap.font.color = system_color
  207.         end
  208.         next
  209.       end
  210.       if c == "\002"
  211.         bitmap.font.bold = bitmap.font.bold ? false : true
  212.         next
  213.       end
  214.       if c == "\003"
  215.         bitmap.font.italic = bitmap.font.italic ? false : true
  216.         next
  217.       end
  218.       if c == "\004"
  219.         text.sub!(/\[(\w+)\]/,"")
  220.         bitmap.font.name = $1
  221.         next
  222.       end
  223.       if c == "\005"
  224.         text.sub!(/\[(\w+)\]/,"")
  225.         color = bitmap.font.color.clone
  226.         w = bitmap.text_size($1).width
  227.         bitmap.font.color = Color.new(0,0,0,255)
  228.         bitmap.draw_text((4 + x)-1, y-1, w, 32, $1)
  229.         bitmap.draw_text((4 + x)-1, y+1, w, 32, $1)
  230.         bitmap.draw_text((4 + x)+1, y-1, w, 32, $1)
  231.         bitmap.draw_text((4 + x)+1, y+1, w, 32, $1)
  232.         bitmap.font.color = color
  233.         bitmap.draw_text(4 + x, y, w, 32, $1)
  234.         x += bitmap.text_size($1).width
  235.         next
  236.       end
  237.       if c == "\006"
  238.         text.sub!(/\[(\d+)\]/,"")
  239.         bitmap.font.size = $1.to_i
  240.         next
  241.       end
  242.       if c == "\007"
  243.         text.sub!(/\[(.+?)\]/,"")
  244.         pic = RPG::Cache.picture($1)
  245.         r = Rect.new(0,0,pic.width,pic.height)
  246.         y = h / 2 - pic.height / 2
  247.         bitmap.blt(x+2,y,pic,r)
  248.         x += pic.width + 4
  249.         next
  250.       end
  251.       if c == "\201"
  252.         text.sub!(/\[(.+?)\]/,"")
  253.         pic = RPG::Cache.icon($1)
  254.         r = Rect.new(0,0,pic.width,pic.height)
  255.         y = h / 2 - pic.height / 2
  256.         bitmap.blt(x+2,y,pic,r)
  257.         x += pic.width + 4
  258.         next
  259.       end
  260.       bitmap.draw_text(x,0,w,h,c)
  261.       x += bitmap.text_size(c).width
  262.     end
  263.     return bitmap.clone,align
  264.   end
  265.   def get_wh(str)
  266.     bitmap = Bitmap.new(160,160)
  267.     w = 0
  268.     h = 32
  269.     text = str
  270.     text.gsub!(/\\\\/) { "\000" }
  271.     text.gsub!(/\\a\[([0-2])\]/i) { "" }
  272.     text.gsub!(/\\c\[(\d+)\]/i) { "" }
  273.     text.gsub!(/\\bold/i) { "" }
  274.     text.gsub!(/\\italic/i) { "" }
  275.     text.gsub!(/\\f\[(\w+)\]/i) { "\001[#{$1}]" }
  276.     text.gsub!(/\\bd\[(\w+)\]/i) { $1 }
  277.     text.gsub!(/\\s\[(\d+)\]/i) { "\002[#{$1}]" }
  278.     text.gsub!(/\\p\[(.+?)\]/i) { "\003[#{$1}]" }
  279.     text.gsub!(/\\icon\[(.+?)\]/i) { "\004[#{$1}]" }
  280.     while ((c = text.slice!(/./m)) != nil)
  281.       if c == "\000"
  282.         c = "\\"
  283.       end
  284.       if c == "\001"
  285.         text.sub!(/\[(\w+)]/,"")
  286.         bitmap.font.name = $1
  287.         next
  288.       end
  289.       if c == "\002"
  290.         text.sub!(/\[(\d+)]/,"")
  291.         bitmap.font.size = $1.to_i
  292.         next
  293.       end
  294.       if c == "\003"
  295.         text.sub!(/\[(.+?)\]/,"")
  296.         w += RPG::Cache.picture($1).width+4
  297.         h = RPG::Cache.picture($1).height if RPG::Cache.picture($1).height > 32 and RPG::Cache.picture($1).height > h
  298.         next
  299.       end
  300.       if c == "\004"
  301.         text.sub!(/\[(.+?)\]/,"")
  302.         w += RPG::Cache.icon($1).width+4
  303.         h = RPG::Cache.icon($1).height if RPG::Cache.icon($1).height > 32 and RPG::Cache.icon($1).height > h
  304.         next
  305.       end
  306.       w += bitmap.text_size(c).width
  307.       h = bitmap.text_size(c).height if bitmap.text_size(c).height > 32 and bitmap.text_size(c).height > h
  308.     end
  309.     return w,h
  310.   end
  311. end
  312.  
  313. #===============================================================================
  314. # ■ 任务界面
  315. #===============================================================================
  316. class Scene_Mission
  317.   def main
  318.     @window1 = Window_Base.new(0,0,200,64)
  319.     @window1.contents = Bitmap.new(168,32)
  320.     @window1.contents.draw_text(0,0,168,32,"任务",1)
  321.     @window2 = Window_Base.new(200,0,440,64)
  322.     @window2.contents = Bitmap.new(408,32)
  323.     @window2.contents.draw_text(0,0,408,32,"任务说明",1)
  324.     @mission_window = Window_Mission.new
  325.     @mission_window.index = $game_party.mission.size - 1
  326.     [url=home.php?mod=space&uid=370741]@Index[/url] = @mission_window.index
  327.     @info_window = Window_MissionInfo.new
  328.     info = $game_party.mission[@index].info.clone
  329.     @info_window.refresh(info)
  330.     Graphics.transition
  331.     loop do
  332.       Graphics.update
  333.       Input.update
  334.       update
  335.       if $scene != self
  336.         break
  337.       end
  338.     end
  339.     Graphics.freeze
  340.     @window1.dispose
  341.     @window2.dispose
  342.     @mission_window.dispose
  343.     @info_window.dispose
  344.   end
  345.   def update
  346.     @mission_window.update
  347.     @info_window.update
  348.     if Input.trigger?(Input::B)
  349.       $game_system.se_play($data_system.cancel_se)
  350.       $scene = Scene_Map.new
  351.       return
  352.     end
  353.     if @index != @mission_window.index
  354.       @index = @mission_window.index
  355.       info = $game_party.mission[@index].info.clone
  356.       @info_window.refresh(info)
  357.     end
  358.   end
  359. end
  360.  
  361. #===============================================================================
  362. # ■ 事件处理器
  363. #===============================================================================
  364. class Interpreter
  365.   alias orig_ec execute_command
  366.   def execute_command
  367.     if @index >= @list.size - 1
  368.       command_end
  369.       return true
  370.     end
  371.     @parameters = @list[@index].parameters
  372.     return command_108 if @list[@index].code == 108
  373.     return orig_ec
  374.   end
  375.   def command_108
  376.     case @list[@index].parameters[0]
  377.     when (/^删除任务\[(\w+)\]$/)
  378.       $game_party.delete_mission($1)
  379.       return true
  380.     when (/^完成任务\[(\w+)\]$/)
  381.       $game_party.done_mission($1)
  382.       return true
  383.     when "删除所有任务"
  384.       $game_party.delete_all_mission
  385.       return true
  386.     when "完成所有任务"
  387.       $game_party.done_all_mission
  388.       return true
  389.     when (/^放弃任务\[(\w+)\]$/)
  390.       $game_party.fail_mission($1)
  391.       return true
  392.     when (/^恢复任务\[(\w+)\]$/)
  393.       $game_party.resume_mission($1)
  394.       return true
  395.     when "恢复所有任务"
  396.       $game_party.resume_all_mission
  397.       return true
  398.     end
  399.     text = @list[@index].parameters[0]
  400.     loop do
  401.       if @list[@index+1].code == 108 or @list[@index+1].code == 408
  402.         text += "\n" + @list[@index+1].parameters[0]
  403.       else
  404.         break
  405.       end
  406.       @index += 1
  407.     end
  408.     split = text.split("\n")
  409.     if (split[0] == "任务设置" or split[0] == "任务更新" or split[0] == "追加说明") and split.size >= 3
  410.       info , name = split[2] , split[1]
  411.       if split.size >= 4
  412.         for i in 3...split.size
  413.           info += "\n" + split[i]
  414.         end
  415.       end
  416.       $game_party.get_mission(name,info) if split[0] == "任务设置"
  417.       $game_party.update_mission(name,info) if split[0] == "任务更新"
  418.       $game_party.add_mission_info(name,info) if split[0] == "追加说明"
  419.     end
  420.     return true
  421.   end
  422. end

这个任务系统怎么设置任务?

点评

http://bbs.66rpg.com/thread-167490-1-1.html  发表于 2013-10-20 21:04

Lv4.逐梦者

梦石
0
星屑
9280
在线时间
2504 小时
注册时间
2011-5-20
帖子
15389

开拓者

2
发表于 2013-10-19 18:00:46 | 只看该作者
  1. 完成任务[XXX]
复制代码
在事件指令的注释里面用这句就可以了,XXX为任务名称
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复 支持 反对

使用道具 举报

Lv1.梦旅人

路人党员

梦石
0
星屑
52
在线时间
2276 小时
注册时间
2010-12-30
帖子
3225
3
发表于 2013-10-19 20:00:58 | 只看该作者
去下载范例吧,我记得我在范例里给了方法了==

点评

能发地址吗  发表于 2013-10-19 23:01

评分

参与人数 1星屑 +60 收起 理由
myownroc + 60 塞糖

查看全部评分

本人擅长XP,如果有脚本或者Ruby方面的问题欢迎发电邮到[email protected]咨询,本人很少检查电邮所以不一定会及时回复,本人不会直接出手解决问题只会提供一个方向,所以谢绝伸手党
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-30 02:11

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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