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

Project1

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

[已经解决] 求助直线任务系统

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
16 小时
注册时间
2014-12-22
帖子
10
跳转到指定楼层
1
发表于 2014-12-27 19:46:44 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
怎么做一个支线任务系统啊,就是在在菜单栏里有一个任务栏选项,然后可以自己添加别的事件作为任务的。真心求助啊,求助。

Lv4.逐梦者

【欧皇】

梦石
3
星屑
2046
在线时间
1004 小时
注册时间
2013-8-19
帖子
3486

开拓者

2
发表于 2014-12-27 22:47:40 | 只看该作者
自己搜索“任务”
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
658
在线时间
7 小时
注册时间
2013-6-15
帖子
4
3
发表于 2015-1-2 13:39:37 | 只看该作者
本帖最后由 RyanBern 于 2015-1-2 14:29 编辑

可以添加脚本
使用方法
main之前右键插入,全选RGSS代码后,粘贴即可.脚本名可自己取.
添加主线任务的方法 : 在事件中代入脚本: $任务 = "这里写你的任务" (注意输入的时候引号不要丢.)
添加支线任务的方法 : 在事件中代入脚本: $支线 = "这里写你的任务" 完成任务的时候输入脚本: $支线完成 = "这里任务与添加时务必一样" (这里输入脚本里的任务名称务必与添加时一至,否则不起任何效果.)
注意:添加多个支线任务时,中间必须有对话或者其他事件隔开,不能都密密麻麻写在一起,否则只会读取最后一个任务。如图
脚本冲突可能:所有修改菜单的类。有一个简单的解决方法:虽然同样是插入在Main的前面,可是,尽可能让这个脚本处在列表靠上的地方,冲突会小一些(比如插入在Scene_Debug上面一行)

脚本内容

RUBY 代码复制
  1. #==============================================================================
  2. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  3. #==============================================================================  
  4. #==============================================================================
  5. # Game_System
  6. #------------------------------------------------------------------------------
  7. # 添加内容
  8. #==============================================================================
  9. class Game_System
  10.   attr_accessor :mission #现在执行的任务
  11.   attr_accessor :partmission
  12.   alias carol3_ini initialize
  13.   def initialize
  14.     carol3_ini
  15.     @mission = ""
  16.     @partmission = []
  17.   end
  18. end
  19. #==============================================================================
  20. # ■ Scene_Title
  21. #------------------------------------------------------------------------------
  22. #  处理标题画面的类。
  23. #==============================================================================
  24. class Scene_Title
  25.   alias carol3_title1 main
  26.   def main
  27.     $map_infos = load_data("Data/MapInfos.rxdata")  
  28.     for key in $map_infos.keys  
  29.       $map_infos[key] = $map_infos[key].name  
  30.     end  
  31.     $任务 = ""
  32.     $支线 = nil
  33.     $支线完成 = nil
  34.     carol3_title1
  35.   end
  36. end
  37. class Scene_Map
  38.   alias carol3_update update
  39.   def update
  40.     carol3_update
  41.     if $支线 != nil
  42.       for i in 0...$game_system.partmission.size
  43.         if $game_system.partmission[i] == $支线
  44.           $支线 = nil
  45.           break
  46.         end
  47.       end
  48.       if $支线 != nil
  49.         $game_system.partmission.push($支线)
  50.         $支线 = nil
  51.       end
  52.     end
  53.     if $支线完成 != nil
  54.       for i in 0...$game_system.partmission.size
  55.         if $game_system.partmission[i] == $支线完成
  56.           $game_system.partmission.delete($game_system.partmission[i])
  57.           break
  58.         end
  59.       end
  60.       $支线完成 = nil
  61.     end
  62.   end
  63. end  
  64. #==============================================================================
  65. # Window_MenuStatus
  66. #------------------------------------------------------------------------------
  67. # 显示菜单画面和同伴状态的窗口。
  68. #==============================================================================
  69. class Window_MenuStatus < Window_Selectable
  70.   #--------------------------------------------------------------------------
  71.   # ● 初始化目标
  72.   #--------------------------------------------------------------------------
  73.   def initialize
  74.     super(0, 0, 480, 384)
  75.     self.contents = Bitmap.new(width - 32, height - 32)
  76.     self.active = false
  77.     self.index = -1
  78.     @position = 0
  79.     @count = 0
  80.     @oldposition = 0
  81.     refresh
  82.   end
  83.   #--------------------------------------------------------------------------
  84.   # ● 刷新
  85.   #--------------------------------------------------------------------------
  86.   def refresh
  87.     self.contents.clear
  88.     @item_max = $game_party.actors.size
  89.     for i in 0...$game_party.actors.size
  90.       x = 64
  91.       y = i * 90
  92.       actor = $game_party.actors[i]
  93.       self.contents.font.size = 18
  94.       draw_actor_active_graphic(actor, x - 40, y + 50)
  95.       draw_actor_name(actor, x, y)
  96.       draw_actor_class(actor, x + 144, y)
  97.       draw_actor_level(actor, x, y + 25)
  98.       draw_actor_state(actor, x + 90, y + 25)
  99.       draw_actor_exp(actor, x, y + 50)
  100.       draw_actor_hp(actor, x + 236, y + 25)
  101.       draw_actor_sp(actor, x + 236, y + 50)
  102.     end
  103.   end
  104.   #--------------------------------------------------------------------------
  105.   # ● 绘制行走图
  106.   #--------------------------------------------------------------------------
  107.   def draw_actor_active_graphic(actor, x, y)
  108.     bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
  109.     cw = bitmap.width / 4
  110.     ch = bitmap.height / 4
  111.     p = @position * cw
  112.     src_rect = Rect.new(p, 0, cw, ch)
  113.     self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  114.   end
  115.   #--------------------------------------------------------------------------
  116.   # ● 刷新光标矩形
  117.   #--------------------------------------------------------------------------
  118.   def update_cursor_rect
  119.     if @index < 0
  120.       self.cursor_rect.empty
  121.     else
  122.       self.cursor_rect.set(0, @index *90-5, self.width - 32, 90)
  123.     end
  124.   end   
  125.   def update
  126.     super
  127.     @count += 1
  128.     @count %= 15
  129.     if @count == 0
  130.       @position = (@position + 1) % 4
  131.     end
  132.     if @position != @oldposition
  133.       @oldposition = @position
  134.       refresh
  135.     end
  136.   end
  137. end
  138. #==============================================================================
  139. # ■ Game_Map
  140. #------------------------------------------------------------------------------
  141. #  处理地图的类。包含卷动以及可以通行的判断功能。
  142. # 本类的实例请参考 $game_map 。
  143. #==============================================================================
  144. class Game_Map
  145.   def name  
  146.     return $map_infos[@map_id]  
  147.   end  
  148. end
  149. #==============================================================================
  150. # Window_RecordBook
  151. #------------------------------------------------------------------------------
  152. # 菜单界面表示信息的窗口
  153. #==============================================================================
  154. class Window_RecordBook < Window_Base
  155.   #--------------------------------------------------------------------------
  156.   # ● 初始化对象
  157.   #--------------------------------------------------------------------------
  158.   def initialize
  159.     super(160, 384, 480, 480)
  160.     self.contents = Bitmap.new(width - 32, height - 32)
  161.     if $任务 == ""
  162.       $任务 = $game_system.mission
  163.     else  
  164.       $game_system.mission = $任务
  165.     end
  166.     refresh
  167.   end
  168.   #--------------------------------------------------------------------------
  169.   # ● 刷新画面
  170.   #--------------------------------------------------------------------------
  171.   def refresh
  172.     self.contents.clear
  173.     self.contents.font.color = system_color
  174.     self.contents.font.size = 20
  175.     cx = self.contents.text_size("现在地点").width + 24
  176.     self.contents.draw_text(4, 0, cx, 24, "现在地点")
  177.     self.contents.font.color = normal_color
  178.     self.contents.draw_text(4 + cx, 0, 444 - cx, 24, $game_map.name.to_s)   
  179.     self.contents.font.color = system_color
  180.     cx = self.contents.text_size("主线任务").width + 24
  181.     self.contents.draw_text(4, 32, cx, 24, "主线任务")
  182.     self.contents.font.color = Color.new(240,250,75,255)
  183.     self.contents.draw_text(4 + cx, 32, 444 - cx, 24, $game_system.mission.to_s)   
  184.     self.contents.font.color = system_color
  185.     cx = self.contents.text_size("支线任务").width + 24
  186.     self.contents.draw_text(4, 96, cx, 24, "支线任务")
  187.     self.contents.font.color = normal_color
  188.     for i in 0...$game_system.partmission.size
  189.       self.contents.draw_text(4 + cx, 96 + i * 32, 444 - cx, 24, $game_system.partmission[i].to_s)
  190.     end
  191.   end
  192. end
  193. #==============================================================================
  194. # ■ Scene_Menu
  195. #------------------------------------------------------------------------------
  196. #  处理菜单画面的类。
  197. #==============================================================================
  198. class Scene_Menu
  199.   #--------------------------------------------------------------------------
  200.   # ● 初始化对像
  201.   # menu_index : 命令光标的初期位置
  202.   #--------------------------------------------------------------------------
  203.   def initialize(menu_index = 0)
  204.     @menu_index = menu_index
  205.     @切换状态暂停 = ""
  206.   end
  207.   #--------------------------------------------------------------------------
  208.   # ● 主处理
  209.   #--------------------------------------------------------------------------
  210.   def main
  211.     # 生成命令窗口
  212.     s1 = " 使用物品"#$data_system.words.item
  213.     s2 = " 查看武功"#$data_system.words.skill
  214.     s3 = " 更改武器"#$data_system.words.equip
  215.     s4 = " 查看状态"
  216.     s5 = " 江湖记录"
  217.     s6 = " 封剑归山"
  218.     s7 = " 查看任务"
  219.     @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
  220.     @command_window.index = @menu_index
  221.     # 同伴人数为 0 的情况下
  222.     if $game_party.actors.size == 0
  223.       # 物品、特技、装备、状态无效化
  224.       @command_window.disable_item(0)
  225.       @command_window.disable_item(1)
  226.       @command_window.disable_item(2)
  227.       @command_window.disable_item(3)
  228.     end
  229.     # 禁止存档的情况下
  230.     if $game_system.save_disabled
  231.       # 存档无效
  232.       @command_window.disable_item(4)
  233.     end
  234.     # 生成游戏时间窗口
  235.     @playtime_window = Window_PlayTime.new
  236.     @playtime_window.x = 0
  237.     @playtime_window.y = 256
  238.     # 生成金钱窗口
  239.     @gold_window = Window_Gold.new
  240.     @gold_window.x = 0
  241.     @gold_window.y = 416
  242.     # 生成状态窗口
  243.     @status_window = Window_MenuStatus.new
  244.     @status_window.x = 160
  245.     @status_window.y = 0
  246.     #—— 生成天书窗口
  247.     @recordbook_window = Window_RecordBook.new
  248.     @recordbook_window.z = 1000
  249.     #—— 生成外边框窗口
  250.     @outside_window = Window_Outside.new
  251.     @outside_window.visible = true
  252.     @outside_window.z = 1001
  253.     # 执行过渡
  254.     Graphics.transition
  255.     # 主循环
  256.     loop do
  257.       # 刷新游戏画面
  258.       Graphics.update
  259.       # 刷新输入信息
  260.       Input.update
  261.       # 刷新画面
  262.       update
  263.       # 如果切换画面就中断循环
  264.       if $scene != self
  265.         break
  266.       end
  267.     end
  268.     # 准备过渡
  269.     Graphics.freeze
  270.     # 释放窗口
  271.     @command_window.dispose
  272.     @playtime_window.dispose
  273.     @gold_window.dispose
  274.     @status_window.dispose
  275.     @outside_window.dispose
  276.     @recordbook_window.dispose
  277.   end
  278.   #--------------------------------------------------------------------------
  279.   # ● 刷新画面
  280.   #--------------------------------------------------------------------------
  281.   def update
  282.     # 刷新窗口
  283.     @command_window.update
  284.     @playtime_window.update
  285.     @gold_window.update
  286.     @status_window.update
  287.     # 命令窗口被激活的情况下: 调用 update_command
  288.     if @command_window.active
  289.       update_command
  290.       return
  291.     end
  292.     # 状态窗口被激活的情况下: 调用 update_status
  293.     if @status_window.active
  294.       update_status
  295.       return
  296.     end
  297.     if @outside_window.visible == false
  298.       update_recordbook
  299.       return
  300.     end
  301.   end
  302.   #--------------------------------------------------------------------------
  303.   # ● 刷新画面 (命令窗口被激活的情况下)
  304.   #--------------------------------------------------------------------------
  305.   def update_command
  306.     # 按下 B 键的情况下
  307.     if Input.trigger?(Input::B)
  308.       # 演奏取消 SE
  309.       $game_system.se_play($data_system.cancel_se)
  310.       # 切换的地图画面
  311.       $scene = Scene_Map.new
  312.       return
  313.     end
  314.     # 按下 C 键的情况下
  315.     if Input.trigger?(Input::C)
  316.       # 同伴人数为 0、存档、游戏结束以外的场合
  317.       if $game_party.actors.size == 0 and @command_window.index < 4
  318.         # 演奏冻结 SE
  319.         $game_system.se_play($data_system.buzzer_se)
  320.         return
  321.       end
  322.       # 命令窗口的光标位置分支
  323.       case @command_window.index
  324.       when 0 # 物品
  325.         # 演奏确定 SE
  326.         $game_system.se_play($data_system.decision_se)
  327.         # 切换到物品画面
  328.         $scene = Scene_Item.new
  329.       when 1 # 特技
  330.         # 演奏确定 SE
  331.         $game_system.se_play($data_system.decision_se)
  332.         # 激活状态窗口
  333.         @command_window.active = false
  334.         @status_window.active = true
  335.         @status_window.index = 0
  336.       when 2 # 装备
  337.         # 演奏确定 SE
  338.         $game_system.se_play($data_system.decision_se)
  339.         # 激活状态窗口
  340.         @command_window.active = false
  341.         @status_window.active = true
  342.         @status_window.index = 0
  343.       when 3 # 状态
  344.         # 演奏确定 SE
  345.         $game_system.se_play($data_system.decision_se)
  346.         # 激活状态窗口
  347.         @command_window.active = false
  348.         @status_window.active = true
  349.         @status_window.index = 0
  350.       when 4 # 存档
  351.         # 禁止存档的情况下
  352.         if $game_system.save_disabled
  353.           # 演奏冻结 SE
  354.           $game_system.se_play($data_system.buzzer_se)
  355.           return
  356.         end
  357.         # 演奏确定 SE
  358.         $game_system.se_play($data_system.decision_se)
  359.         # 切换到存档画面
  360.         $scene = Scene_Save.new
  361.       when 5 # 游戏结束
  362.         # 演奏确定 SE
  363.         $game_system.se_play($data_system.decision_se)
  364.         # 切换到游戏结束画面
  365.         $scene = Scene_End.new
  366.       when 6 # 查看任务
  367.         # 演奏确定 SE
  368.         $game_system.se_play($data_system.decision_se)
  369.         @command_window.active = false
  370.         @outside_window.visible = false
  371.       end
  372.       return
  373.     end
  374.   end
  375.   #--------------------------------------------------------------------------
  376.   # ● 刷新画面 (查看天书的情况下)
  377.   #--------------------------------------------------------------------------
  378.   def update_recordbook
  379.     if @切换状态暂停 == "天书消失"
  380.       if @recordbook_window.y < 384
  381.         @recordbook_window.y +=64
  382.         @status_window.y -= 16
  383.         return
  384.       else
  385.         @切换状态暂停 = ""
  386.         @outside_window.visible = true
  387.         @command_window.active = true
  388.       end
  389.     else
  390.       if @recordbook_window.y >0
  391.         @recordbook_window.y -= 32
  392.         @status_window.y += 8
  393.         return
  394.       else
  395.         @status_window.visible = false
  396.         if Input.trigger?(Input::B)
  397.           @切换状态暂停 = "天书消失"
  398.           $game_system.se_play($data_system.cancel_se)
  399.           @status_window.visible = true
  400.           return
  401.         end
  402.       end
  403.     end
  404.   end   
  405.   #--------------------------------------------------------------------------
  406.   # ● 刷新画面 (状态窗口被激活的情况下)
  407.   #--------------------------------------------------------------------------
  408.   def update_status
  409.     # 按下 B 键的情况下
  410.     if Input.trigger?(Input::B)
  411.       # 演奏取消 SE
  412.       $game_system.se_play($data_system.cancel_se)
  413.       # 激活命令窗口
  414.       @command_window.active = true
  415.       @status_window.active = false
  416.       @status_window.index = -1
  417.       return
  418.     end
  419.     # 按下 C 键的情况下
  420.     if Input.trigger?(Input::C)
  421.       # 命令窗口的光标位置分支
  422.       case @command_window.index
  423.       when 1 # 特技
  424.         # 本角色的行动限制在 2 以上的情况下
  425.         if $game_party.actors[@status_window.index].restriction >= 2
  426.           # 演奏冻结 SE
  427.           $game_system.se_play($data_system.buzzer_se)
  428.           return
  429.         end
  430.         # 演奏确定 SE
  431.         $game_system.se_play($data_system.decision_se)
  432.         # 切换到特技画面
  433.         $scene = Scene_Skill.new(@status_window.index)
  434.       when 2 # 装备
  435.         # 演奏确定 SE
  436.         $game_system.se_play($data_system.decision_se)
  437.         # 切换的装备画面
  438.         $scene = Scene_Equip.new(@status_window.index)
  439.       when 3 # 状态
  440.         # 演奏确定 SE
  441.         $game_system.se_play($data_system.decision_se)
  442.         # 切换到状态画面
  443.         $scene = Scene_Status.new(@status_window.index)
  444.       end
  445.       return
  446.     end
  447.   end
  448. end
  449. #==============================================================================
  450. # Window_Outside
  451. #------------------------------------------------------------------------------
  452. # 外边框窗口
  453. #==============================================================================
  454. class Window_Outside < Window_Base
  455.   #--------------------------------------------------------------------------
  456.   # ● 初始化对象
  457.   #--------------------------------------------------------------------------
  458.   def initialize
  459.     super(160, 384, 480, 96)
  460.     self.back_opacity = 0
  461.   end
  462. end
  463. #==============================================================================
  464. # ■ Window_PlayTime
  465. #------------------------------------------------------------------------------
  466. # 菜单画面的系统时间表示
  467. #==============================================================================
  468. class Window_PlayTime < Window_Base
  469.   #--------------------------------------------------------------------------
  470.   # ● 初始化对像
  471.   #--------------------------------------------------------------------------
  472.   def initialize
  473.     super(0, 0, 160, 128)
  474.     self.contents = Bitmap.new(width - 32, height - 32)
  475.     self.contents.font.size = 18
  476.     refresh
  477.   end
  478.   #--------------------------------------------------------------------------
  479.   # ● 刷新
  480.   #--------------------------------------------------------------------------
  481.   def refresh
  482.     self.contents.clear
  483.     self.contents.font.color = system_color
  484.     self.contents.font.color = text_color(6)
  485.     time = Time.now
  486.     text = time.strftime("%x %X")
  487.     self.contents.draw_text(-2, 32, 130, 32, text, 2)
  488.     @total_sec = Graphics.frame_count / Graphics.frame_rate
  489.     hour = @total_sec / 60 / 60
  490.     min = @total_sec / 60 % 60
  491.     sec = @total_sec % 60
  492.     text = sprintf("%02d:%02d:%02d", hour, min, sec)
  493.     self.contents.font.color = normal_color
  494.     self.contents.draw_text(4, 0, 160, 32, "日期与游戏时间")
  495.     self.contents.draw_text(-2, 64, 130, 32, text, 2)
  496.   end
  497.   #--------------------------------------------------------------------------
  498.   # ● 更新
  499.   #--------------------------------------------------------------------------
  500.   def update
  501.     super
  502.     if Graphics.frame_count / Graphics.frame_rate != @total_sec
  503.       refresh
  504.     end
  505.   end
  506. end
  507.  
  508. #==============================================================================
  509. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  510. #==============================================================================

点评

脚本冲突其实没用什么很好的解决办法,原则上插入到Main前的脚本都有可能打架。所以还是学会自己写脚本吧(pia~)  发表于 2015-1-2 14:30

评分

参与人数 1星屑 +100 收起 理由
hys111111 + 100 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-22 13:35

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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