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

Project1

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

[已经过期] 如何将任务脚本分成4个毫不相干的脚本?

[复制链接]

Lv3.寻梦者

梦石
0
星屑
3176
在线时间
1442 小时
注册时间
2009-7-27
帖子
1454
跳转到指定楼层
1
发表于 2012-7-16 22:03:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 爆焰 于 2012-7-18 12:59 编辑

比如:我第一个角色用第一个任务脚本。
第二个角色用第二个任务脚本。
以此类推。每个脚本都毫不相干。
我试过了,但是却和第一个脚本冲突。请高手帮帮忙。

修改不用太大幅度,只需要分开就行了。
设置时比如:任务设置。那第二个脚本就:设置任务。
这样比较方便。

以下是脚本:
  1. #==============================================================================#
  2. #           任务系统v0.3 by EngShun                                            #
  3. #                                                                              #
  4. #    设置方法请参考范例
  5. #
  6. #    呼出界面:$scene = Scene_Mission.new
  7. #
  8. #    效果说明:                                                                #
  9. #    支持普通对话框效果                                                        #
  10. #    \a[号码]     :更改对齐方式(0,1,2)。                                     #
  11. #    \itm[物品id] :物品数量                                                    #
  12. #    \wpn[武器id] :武器数量                                                    #
  13. #    \amr[防具id] :防具数量                                                    #
  14. #    \eval{脚本}  :运行脚本                                                    #
  15. #    \bold        :字体加粗,插入多一次关闭                                    #
  16. #    \italic      :字体打斜,插入多一次关闭                                    #
  17. #    \f[字体名称] :更改字体                                                    #
  18. #    \s[号码]     :更改字体大小                                                #
  19. #    \p[名称]     :插入图片                                                    #
  20. #    \icon[名称]  :插入图标                                                    #
  21. #                                                                              #
  22. #==============================================================================#

  23. class Game_Mission
  24.   attr_reader :doned
  25.   attr_reader :failed
  26.   def initialize
  27.     @mission = []
  28.     @info = []
  29.     @doned = []
  30.     @failed = []
  31.   end
  32.   def none?
  33.     return @mission == []
  34.   end
  35.   def mission
  36.     if @mission == []
  37.       return ["无"]
  38.     end
  39.     return @mission
  40.   end
  41.   def info
  42.     if @info == []
  43.       return ["\\a[1]\\c[2]\\s[50]\\f[楷体]没有任务"]
  44.     end
  45.     return @info
  46.   end
  47.   def get(mission,info)
  48.     unless @mission.include?(mission)
  49.       @mission.push(mission)
  50.       @info.push(info)
  51.     end
  52.   end
  53.   def done(done_mission)
  54.     for i in [email protected]
  55.       if @mission[i] == done_mission and [email protected]?(i)
  56.         @doned.delete(i) if @doned.include?(i)
  57.         @doned.push(i)
  58.       end
  59.     end
  60.   end
  61.   def delete(delete_mission)
  62.     for i in [email protected]
  63.       if @mission[i] == delete_mission
  64.         @mission.delete(delete_mission)
  65.         delete_info = @info[i]
  66.         @info.delete(delete_info)
  67.         @doned.delete(i) if @doned.include?(i)
  68.       end
  69.     end
  70.   end
  71.   def fail(mission)
  72.     for i in [email protected]
  73.       if @mission[i] == mission and [email protected]?(i)
  74.         @failed.delete(i) if @failed.include?(i)
  75.         @failed.push(i)
  76.       end
  77.     end
  78.   end
  79.   def resume(mission)
  80.     for i in [email protected]
  81.       if @mission[i] == mission and
  82.         @failed.delete(i)
  83.       end
  84.     end
  85.   end
  86.   def done_all
  87.     for i in [email protected]
  88.       @doned.delete(i) if @doned.include?(i)
  89.       @doned.push(i)
  90.     end
  91.   end
  92.   def delete_all
  93.     @mission = []
  94.     @info = []
  95.     @doned = []
  96.     @failed = []
  97.   end
  98.   def resume_all
  99.     @failed = []
  100.   end
  101. end

  102. class Window_Mission < Window_Selectable
  103.   def initialize
  104.     super(0, 64, 200, 416)
  105.     self.index = 0
  106.     @item_max = $game_party.mission.mission.size
  107.     if self.contents != nil
  108.       self.contents.dispose
  109.       self.contents = nil
  110.     end
  111.     self.contents = Bitmap.new(width - 32, @item_max * 32)
  112.     for i in 0...$game_party.mission.mission.size
  113.       t = ($game_party.mission.doned.include?(i) or $game_party.mission.failed.include?(i))
  114.       self.contents.font.color = t ? disabled_color : normal_color
  115.       text = $game_party.mission.mission[i]
  116.       self.contents.draw_text(4, i * 32, 160, 32, text.to_s)
  117.       self.contents.font.color = system_color
  118.       self.contents.draw_text(self.contents.width-32, i * 32, 32, 32, "□",1) unless $game_party.mission.none?
  119.       if $game_party.mission.doned.include?(i)
  120.         self.contents.font.color = crisis_color
  121.         self.contents.draw_text(self.contents.width-32, i * 32, 32, 32, "√",1)
  122.       elsif $game_party.mission.failed.include?(i)
  123.         self.contents.font.color = knockout_color
  124.         self.contents.draw_text(self.contents.width-32, i * 32, 32, 32, "×",1)
  125.       end
  126.     end
  127.   end
  128. end
  129. class Window_Info < Window_Base
  130.   def initialize
  131.     super(200,64,440,416)
  132.     self.contents =  Bitmap.new(408, 384)
  133.   end
  134.   def refresh(str)
  135.     self.contents = Bitmap.new(408, 384) if self.contents == nil
  136.     self.contents.clear
  137.     y = 0
  138.     align = 0
  139.     begin
  140.       last_text = str.clone
  141.       str.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  142.       str.gsub!(/\\[Gg]/) { $game_party.gold.to_s }
  143.       str.gsub!(/\\[Ii][Tt][Mm]\[(\d+)\]/) { $game_party.item_number($1.to_i) }
  144.       str.gsub!(/\\[Ww][Pp][Nn]\[(\d+)\]/) { $game_party.weapon_number($1.to_i) }
  145.       str.gsub!(/\\[Aa][Mm][Rr]\[(\d+)\]/) { $game_party.armor_number($1.to_i) }
  146.       str.gsub!(/\\[Ee][Vv][Aa][Ll]{([.,\r,\n]+)}/) { eval($1) }
  147.     end until str == last_text
  148.       str.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  149.       $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  150.     end
  151.     lines = str.split("\n")
  152.     for line in lines
  153.       bitmap,align = bitmap_line(line,align)
  154.       w = bitmap.width
  155.       h = bitmap.height
  156.       case align
  157.       when 0
  158.         x = 4
  159.       when 1
  160.         x = 204 - w / 2
  161.       when 2
  162.         x = 404 - w
  163.       end
  164.       self.contents.blt(x,y,bitmap,Rect.new(0,0,w,h))
  165.       y += h
  166.     end
  167.   end
  168.   def bitmap_line(str,old_align)
  169.     w,h = get_wh(str.clone)
  170.     w = 1 if w == 0
  171.     bitmap = Bitmap.new(w,h)
  172.     text = str
  173.     align = old_align
  174.     x = 0
  175.     text.gsub!(/\\\\/) { "\000" }
  176.     text.gsub!(/\\[Aa]\[(\d+)\]/){
  177.       align = $1.to_i
  178.       ""
  179.     }
  180.     text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  181.     text.gsub!(/\\[Bb][Oo][Ll][Dd]/) { "\002" }
  182.     text.gsub!(/\\[Ii][Tt][Aa][Ll][Ii][Cc]/) { "\003" }
  183.     text.gsub!(/\\[Ff]\[(\w+)\]/) { "\004[#{$1}]" }
  184.     text.gsub!(/\\[Bb][Dd]\[(\w+)\]/) { "\005[#{$1}]" }
  185.     text.gsub!(/\\[Ss]\[(\d+)\]/) { "\006[#{$1}]" }
  186.     text.gsub!(/\\[Pp]\[([\w,-]+)\]/) { "\007[#{$1}]" }
  187.     text.gsub!(/\\[Ii][Cc][Oo][Nn]\[([\w,-]+)\]/){ "\201[#{$1}]" }
  188.     while ((c = text.slice!(/./m)) != nil)
  189.       if c == "\000"
  190.         c = "\\"
  191.       end
  192.       if c == "\001"
  193.         text.sub!(/\[([0-9]+)\]/, "")
  194.         color = $1.to_i
  195.         if color >= 0 and color <= 9
  196.           bitmap.font.color = text_color(color)
  197.         elsif color == 8
  198.           bitmap.font.color = disabled_color
  199.         elsif color == 9
  200.           bitmap.font.color = system_color
  201.         end
  202.         next
  203.       end
  204.       if c == "\002"
  205.         bitmap.font.bold = bitmap.font.bold ? false : true
  206.         next
  207.       end
  208.       if c == "\003"
  209.         bitmap.font.italic = bitmap.font.italic ? false : true
  210.         next
  211.       end
  212.       if c == "\004"
  213.         text.sub!(/\[(\w+)\]/,"")
  214.         bitmap.font.name = $1
  215.         next
  216.       end
  217.       if c == "\005"
  218.         text.sub!(/\[(\w+)\]/,"")
  219.         color = bitmap.font.color.clone
  220.         w = bitmap.text_size($1).width
  221.         bitmap.font.color = Color.new(0,0,0,255)
  222.         bitmap.draw_text((4 + x)-1, y-1, w, 32, $1)
  223.         bitmap.draw_text((4 + x)-1, y+1, w, 32, $1)
  224.         bitmap.draw_text((4 + x)+1, y-1, w, 32, $1)
  225.         bitmap.draw_text((4 + x)+1, y+1, w, 32, $1)
  226.         bitmap.font.color = color
  227.         bitmap.draw_text(4 + x, y, w, 32, $1)
  228.         x += bitmap.text_size($1).width
  229.         next
  230.       end
  231.       if c == "\006"
  232.         text.sub!(/\[(\d+)\]/,"")
  233.         bitmap.font.size = $1.to_i
  234.         next
  235.       end
  236.       if c == "\007"
  237.         text.sub!(/\[([\w,-]+)\]/,"")
  238.         pic = RPG::Cache.picture($1)
  239.         r = Rect.new(0,0,pic.width,pic.height)
  240.         y = h / 2 - pic.height / 2
  241.         bitmap.blt(x+2,y,pic,r)
  242.         x += pic.width + 4
  243.         next
  244.       end
  245.       if c == "\201"
  246.         text.sub!(/\[([\w,-]+)\]/,"")
  247.         pic = RPG::Cache.icon($1)
  248.         r = Rect.new(0,0,pic.width,pic.height)
  249.         y = h / 2 - pic.height / 2
  250.         bitmap.blt(x+2,y,pic,r)
  251.         x += pic.width + 4
  252.         next
  253.       end
  254.       bitmap.draw_text(x,0,w,h,c)
  255.       x += bitmap.text_size(c).width
  256.     end
  257.     return bitmap.clone,align
  258.   end
  259.   def get_wh(str)
  260.     bitmap = Bitmap.new(160,160)
  261.     w = 0
  262.     h = 32
  263.     text = str
  264.     text.gsub!(/\\\\/) { "\000" }
  265.     text.gsub!(/\\[Aa]\[(\d+)\]/) { "" }
  266.     text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "" }
  267.     text.gsub!(/\\[Bb][Oo][Ll][Dd]/) { "" }
  268.     text.gsub!(/\\[Ii][Tt][Aa][Ll][Ii][Cc]/) { "" }
  269.     text.gsub!(/\\[Ff]\[(\w+)\]/) { "\001[#{$1}]" }
  270.     text.gsub!(/\\[Bb][Dd]\[(\w+)\]/) { $1 }
  271.     text.gsub!(/\\[Ss]\[(\d+)\]/) { "\002[#{$1}]" }
  272.     text.gsub!(/\\[Pp]\[([\w,-]+)\]/) { "\003[#{$1}]" }
  273.     text.gsub!(/\\[Ii][Cc][Oo][Nn]\[(\w,[A-Za-z0-9_-]+)\]/) { "\004[#{$1}]" }
  274.     while ((c = text.slice!(/./m)) != nil)
  275.       if c == "\000"
  276.         c = "\\"
  277.       end
  278.       if c == "\001"
  279.         text.sub!(/\[(\w+)]/,"")
  280.         bitmap.font.name = $1
  281.         next
  282.       end
  283.       if c == "\002"
  284.         text.sub!(/\[(\d+)]/,"")
  285.         bitmap.font.size = $1.to_i
  286.         next
  287.       end
  288.       if c == "\003"
  289.         text.sub!(/\[([\w,-]+)\]/,"")
  290.         w += RPG::Cache.picture($1).width+4
  291.         h = RPG::Cache.picture($1).height if RPG::Cache.picture($1).height > 32 and RPG::Cache.picture($1).height > h
  292.         next
  293.       end
  294.       if c == "\004"
  295.         text.sub!(/\[([\w,-]+)\]/,"")
  296.         w += RPG::Cache.icon($1).width+4
  297.         h = RPG::Cache.icon($1).height if RPG::Cache.icon($1).height > 32 and RPG::Cache.icon($1).height > h
  298.         next
  299.       end
  300.       w += bitmap.text_size(c).width
  301.       h = bitmap.text_size(c).height if bitmap.text_size(c).height > 32 and bitmap.text_size(c).height > h
  302.     end
  303.     return w,h
  304.   end
  305. end
  306. class Scene_Mission
  307.   def main
  308.     @window1 = Window_Base.new(0,0,200,64)
  309.     @window1.contents = Bitmap.new(168,32)
  310.     @window1.contents.draw_text(0,0,168,32,"任务",1)
  311.     @window2 = Window_Base.new(200,0,440,64)
  312.     @window2.contents = Bitmap.new(408,32)
  313.     @window2.contents.draw_text(0,0,408,32,"任务说明",1)
  314.     @mission_window = Window_Mission.new
  315.     @mission_window.index = $game_party.mission.mission.size - 1
  316.     @info_window = Window_Info.new
  317.     info = $game_party.mission.info[@mission_window.index].clone
  318.     @info_window.refresh(info)
  319.     Graphics.transition
  320.     loop do
  321.       Graphics.update
  322.       Input.update
  323.       update
  324.       if $scene != self
  325.         break
  326.       end
  327.     end
  328.     Graphics.freeze
  329.     @window1.dispose
  330.     @window2.dispose
  331.     @mission_window.dispose
  332.     @info_window.dispose
  333.   end
  334.   def update
  335.     @mission_window.update
  336.     @info_window.update
  337.     if Input.trigger?(Input::B)
  338.       $game_system.se_play($data_system.cancel_se)
  339.       $scene = Scene_Map.new
  340.       return
  341.     end
  342.     if Input.repeat?(Input::UP) or
  343.        Input.repeat?(Input::DOWN)
  344.       info = $game_party.mission.info[@mission_window.index].clone
  345.       @info_window.refresh(info)
  346.     end
  347.   end
  348. end
  349. class Game_Party
  350.   attr_accessor :mission
  351.   alias orig_init initialize
  352.   def initialize
  353.     @mission = Game_Mission.new
  354.     orig_init
  355.   end
  356. end
  357. class Interpreter
  358.   alias orig_ec execute_command
  359.   def execute_command
  360.     if @index >= @list.size - 1
  361.       command_end
  362.       return true
  363.     end
  364.     @parameters = @list[@index].parameters
  365.     return command_108 if @list[@index].code == 108
  366.     return orig_ec
  367.   end
  368.   def command_108
  369.     text = @list[@index].parameters[0]
  370.     if text.sub!(/删除任务\[(\w+)\]/,"") != nil
  371.       $game_party.mission.delete($1)
  372.       return true
  373.     elsif text.sub!(/完成任务\[(\w+)\]/,"") != nil
  374.       $game_party.mission.done($1)
  375.       return true
  376.     elsif text.sub!(/删除所有任务/,"") != nil
  377.       $game_party.mission.delete_all
  378.       return true
  379.     elsif text.sub!(/完成所有任务/,"") != nil
  380.       $game_party.mission.done_all
  381.       return true
  382.     elsif text.sub!(/放弃任务\[(\w+)\]/,"") != nil
  383.       $game_party.mission.fail($1)
  384.       return true
  385.     elsif text.sub!(/恢复任务\[(\w+)\]/,"") != nil
  386.       $game_party.mission.resume($1)
  387.       return true
  388.     elsif text.sub!(/恢复所有任务/,"") != nil
  389.       $game_party.mission.resume_all
  390.       return true
  391.     end
  392.     loop do
  393.       if @list[@index+1].code == 108 or @list[@index+1].code == 408
  394.         text += "\n" + @list[@index+1].parameters[0]
  395.       else
  396.         break
  397.       end
  398.       @index += 1
  399.     end
  400.     split = text.split("\n")
  401.     if split[0] == "任务设置" and split.size >= 3
  402.       info , name = split[2] , split[1]
  403.       if split.size >= 4
  404.         for i in 3...split.size
  405.           info += "\n" + split[i]
  406.         end
  407.       end
  408.       $game_party.mission.get(name,info)
  409.     end
  410.     return true
  411.   end
  412. end
复制代码

博客:我的博客

Lv5.捕梦者

梦石
0
星屑
38732
在线时间
5702 小时
注册时间
2006-11-10
帖子
6608
2
发表于 2012-7-16 22:54:21 | 只看该作者
本帖最后由 灯笼菜刀王 于 2012-7-16 23:33 编辑


复制4份脚本, 然后把自定义的类名和变量都加上编号,
比如
class Game_Mission1

  attr_reader :doned

  attr_reader :failed

  def initialize1

    @mission1 = []

    @info1 = []

    @doned1 = []

    @failed1 = []

  end

后面引用到的相关变量和新建的类都全部加上编号就可以同时使用4个不同的任务脚本了,  然后呼出界面:呼出界面:$scene = Scene_Mission1.new 就可以了

猜应该是多主角路线, 那就在剧情更换主角的时候,加上一个变量 全局变量1号 = 1

然后呼出界面命令改成这样 $scene = Scene_Mission#{$game_variables[编号]}.new 就完成了不同的主角有不同的任务栏了


最后,因为觉得这样做很傻,而且是个大工程, 改起来不允许有一点遗漏, 所以我不接受后继服务,,,  我闪............

点评

不行呀,一按开始游戏就冲突了。  发表于 2012-7-16 23:16
回复

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
38732
在线时间
5702 小时
注册时间
2006-11-10
帖子
6608
3
发表于 2012-7-16 23:30:14 | 只看该作者
本帖最后由 灯笼菜刀王 于 2012-7-16 23:34 编辑


当然, 我改的那一小段只是举例, 后面所有有调用到的类以及新建的类以及调用的变量以及新建的变量都要全部更改

这个是枯燥重复无聊的机械式体力活,而且不能有任何遗漏, 一个没有改就会报错.  如果是原作者的话可以比较效率点,因为知道在哪里调用, 不是作者只能一行一行检查.目测更改时间,凭我的能力,想改好不短于2小时一个脚本,而且不排除会有意外以及出错,,,

所以,我说这个是劳民伤财的行为, 已经事先发表免责声明了, 自己一个符号一个符号的改吧, 或者出VIP悬赏下,应该会有人接,,, 但是4个脚本的话,,, 可不便宜哦,哈哈

点评

差点成功了,就是修改后的alias orig_ec execute_command这一句会出错。  发表于 2012-7-17 00:38
回复

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3176
在线时间
1442 小时
注册时间
2009-7-27
帖子
1454
4
 楼主| 发表于 2012-7-17 00:28:16 | 只看该作者
本帖最后由 爆焰 于 2012-7-17 01:30 编辑
灯笼菜刀王 发表于 2012-7-16 23:30
当然, 我改的那一小段只是举例, 后面所有有调用到的类以及新建的类以及调用的变量以及新建的变量 ...


发现问题出现在:
  1. class Interpreter
  2.   alias orig_ec execute_command
  3.   def execute_command
  4.     if @index >= @list.size - 1
  5.       command_end
  6.       return true
  7.     end
  8.     @parameters = @list[@index].parameters
  9.     return command_108 if @list[@index].code == 108
  10.     return orig_ec
  11.   end
  12.   def command_108
  13.     text = @list[@index].parameters[0]
  14.     if text.sub!(/删除任务\[(\w+)\]/,"") != nil
  15.       $game_party.mission.delete($1)
  16.       return true
  17.     elsif text.sub!(/完成任务\[(\w+)\]/,"") != nil
  18.       $game_party.mission.done($1)
  19.       return true
  20.     elsif text.sub!(/删除所有任务/,"") != nil
  21.       $game_party.mission.delete_all
  22.       return true
  23.     elsif text.sub!(/完成所有任务/,"") != nil
  24.       $game_party.mission.done_all
  25.       return true
  26.     elsif text.sub!(/放弃任务\[(\w+)\]/,"") != nil
  27.       $game_party.mission.fail($1)
  28.       return true
  29.     elsif text.sub!(/恢复任务\[(\w+)\]/,"") != nil
  30.       $game_party.mission.resume($1)
  31.       return true
  32.     elsif text.sub!(/恢复所有任务/,"") != nil
  33.       $game_party.mission.resume_all
  34.       return true
  35.     end
  36.     loop do
  37.       if @list[@index+1].code == 108 or @list[@index+1].code == 408
  38.         text += "\n" + @list[@index+1].parameters[0]
  39.       else
  40.         break
  41.       end
  42.       @index += 1
  43.     end
  44.     split = text.split("\n")
  45.     if split[0] == "任务设置" and split.size >= 3
  46.       info , name = split[2] , split[1]
  47.       if split.size >= 4
  48.         for i in 3...split.size
  49.           info += "\n" + split[i]
  50.         end
  51.       end
  52.       $game_party.mission.get(name,info)
  53.     end
  54.     return true
  55.   end
  56. end
复制代码
请问该如何解决?

博客:我的博客
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-22 05:29

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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