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

Project1

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

[已经过期] 如何在这个任务系统中,按键变更地图坐标变量。

[复制链接]

Lv4.逐梦者

梦石
8
星屑
3943
在线时间
396 小时
注册时间
2017-10-11
帖子
154
跳转到指定楼层
1
发表于 2018-9-4 15:53:37 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
想要实现的功能是:在任务系统里,对某任务按C键,然后弹出一个对话框显示“任务地图位置已更新”然后一秒后自动消失,然后地图里显示的目的地位置更新。该任务字体颜色变更,表示现在对应地图目的地的是这个任务。
地图界面我是直接用图片,以及变量控制坐标位置。
而任务系统,暂时是用下面这个任务系统
https://rpg.blue/thread-167490-1-1.html
目前想到的是,在脚本大概394行中,按C键的反应里改为,显示提示框,变更该项的字体颜色,以及变更变量。而具体脚本不知道怎么写,望指教。
  1. #==============================================================================#
  2. #                          便民任务界面 by EngShun                             #
  3. #                                                                              #
  4. #    由于此版本仅做出了一些小优化,                                            #
  5. #    因此设置方法请参考v0.7的范例                                              #
  6. #                                                                              #
  7. #    效果说明:                                                                #
  8. #    支持普通对话框效果                                                        #
  9. #    \a[号码]     :更改左右对齐方式(0,1,2)。                                 #
  10. #    \itm[物品id] :物品数量                                                    #
  11. #    \wpn[武器id] :武器数量                                                    #
  12. #    \amr[防具id] :防具数量                                                    #
  13. #    \eval{脚本}  :运行脚本                                                    #
  14. #    \1line{内容} :把多行的内容显示为一行                                      #
  15. #    \bold        :字体加粗,插入多一次关闭                                    #
  16. #    \italic      :字体打斜,插入多一次关闭                                    #
  17. #    \f[字体名称] :更改字体                                                    #
  18. #    \s[号码]     :更改字体大小                                                #
  19. #    \p[名称]     :插入图片                                                    #
  20. #    \icon[名称]  :插入图标                                                    #
  21. #                                                                              #
  22. #==============================================================================#

  23. #===============================================================================
  24. # ■ 队伍
  25. #===============================================================================
  26. class Game_Party
  27.   Mission = Struct.new(:id, :name, :info, :status)
  28.   alias org_init_mission initialize if !defined?(org_init_mission)
  29.   #--------------------------------------------------------------------------
  30.   # ● 重定义初始化
  31.   #--------------------------------------------------------------------------
  32.   def initialize
  33.     @mission = {}
  34.     org_init_mission
  35.   end
  36.   def no_mission?
  37.     return @mission == {}
  38.   end
  39.   def missions
  40.     if no_mission?
  41.       m = Mission.new(0,"没有任务","\n\n\n\\a[1]\\s[32]你还没有领取任何任务",0)
  42.       return [m]
  43.     end
  44.     return @mission.values.sort_by {|m|m.id}
  45.   end
  46.   def get_mission(mission,info)
  47.     return if @mission.has_key?(mission)
  48.     id = missions[-1].id + 1
  49.     @mission[mission] = Mission.new(id,mission,info,0)
  50.   end
  51.   def done_mission(mission)
  52.     @mission[mission].status = 1 if @mission[mission].status == 0
  53.   end
  54.   def delete_mission(mission)
  55.     @mission.delete(mission)
  56.   end
  57.   def fail_mission(mission)
  58.     @mission[mission].status = 2 if @mission[mission].status == 0
  59.   end
  60.   def resume_mission(mission)
  61.     @mission[mission].status = 0 if @mission[mission].status == 2
  62.   end
  63.   def done_all_mission
  64.     @mission.each{|k,m|m.status = 1}
  65.   end
  66.   def update_mission(mission,info)
  67.     @mission[mission].info = info
  68.   end
  69.   def add_mission_info(mission,info)
  70.     @mission[mission].info += "\n" + info
  71.   end
  72.   def delete_all_mission
  73.     @mission = {}
  74.   end
  75.   def resume_all_mission
  76.     @mission.each{|k,m|m.status = 0 if m.status == 2}
  77.   end
  78. end

  79. #===============================================================================
  80. # ■ 任务列表窗口
  81. #===============================================================================
  82. class Window_Mission < Window_Selectable
  83.   #--------------------------------------------------------------------------
  84.   # ● 初始化对象
  85.   #--------------------------------------------------------------------------
  86.   def initialize
  87.     super(0, 64, 200, 416)
  88.     self.index = 0
  89.     @mission = $game_party.missions
  90.     @item_max = @mission.size
  91.     if self.contents != nil
  92.       self.contents.dispose
  93.       self.contents = nil
  94.     end
  95.     self.contents = Bitmap.new(width - 32, @item_max * 32)
  96.     for i in [email][email protected][/email]
  97.       t = @mission[i].status != 0
  98.       self.contents.font.color = t ? disabled_color : normal_color
  99.       text = @mission[i].name
  100.       self.contents.draw_text(4, i * 32, 160, 32, text.to_s)
  101.       self.contents.font.color = system_color
  102.       self.contents.draw_text(self.contents.width-32, i * 32, 32, 32, "□",1) unless $game_party.no_mission?
  103.       if @mission[i].status == 1
  104.         self.contents.font.color = crisis_color
  105.         self.contents.draw_text(self.contents.width-32, i * 32, 32, 32, "√",1)
  106.       elsif @mission[i].status == 2
  107.         self.contents.font.color = knockout_color
  108.         self.contents.draw_text(self.contents.width-32, i * 32, 32, 32, "×",1)
  109.       end
  110.     end
  111.   end
  112. end

  113. #===============================================================================
  114. # ■ 任务详情窗口
  115. #===============================================================================
  116. class Window_MissionInfo < Window_Base
  117.   attr_accessor :wait
  118.   attr_accessor :scroll_up
  119.   #--------------------------------------------------------------------------
  120.   # ● 初始化对象
  121.   #--------------------------------------------------------------------------
  122.   def initialize
  123.     super(200,64,440,416)
  124.     self.contents =  Bitmap.new(408, 384)
  125.     @scroll_up = false
  126.     @wait = 90
  127.     @items = []
  128.     @progress = 0
  129.     @draw_y = 0
  130.     @align = 0
  131.     @cache = Bitmap.new(160,160)
  132.     @font = Font.new
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   # ● 刷新画面
  136.   #--------------------------------------------------------------------------
  137.   def update
  138.     super
  139.     parse_items if @items.size > 0
  140.     return if self.contents.height <= 384
  141.     return @wait -= 1 if @wait > 0
  142.     self.oy += @scroll_up ? -1 : 1
  143.     self.oy = 0 if self.oy < 0
  144.     self.oy = oy_max if self.oy > oy_max
  145.     if self.oy <= 0
  146.       @scroll_up = false
  147.       @wait = 60
  148.     elsif self.oy >= oy_max
  149.       @scroll_up = true
  150.       @wait = 60
  151.     end
  152.   end
  153.   #--------------------------------------------------------------------------
  154.   # ● 释放
  155.   #--------------------------------------------------------------------------
  156.   def dispose
  157.     super
  158.     @cache.dispose
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # ● 滚动最大值
  162.   #--------------------------------------------------------------------------
  163.   def oy_max
  164.     return self.contents.height - 384
  165.   end
  166.   #--------------------------------------------------------------------------
  167.   # ● 刷新
  168.   #--------------------------------------------------------------------------
  169.   def refresh(str)
  170.     str = str.clone
  171.     @scroll_up = false
  172.     @wait = 120
  173.     @draw_y = 0
  174.     @align = 0
  175.     @progress = 0
  176.     @lines = []
  177.     self.oy = 0
  178.     @cache.font = Font.new
  179.     @font = Font.new
  180.     self.contents.dispose
  181.     self.contents = Bitmap.new(408, 384)
  182.     parse_text(str)
  183.     12.times{parse_items}
  184.   end
  185.   #--------------------------------------------------------------------------
  186.   # ● 描绘行
  187.   #--------------------------------------------------------------------------
  188.   def draw_line(width, height, items)
  189.     bitmap = Bitmap.new(width, height)
  190.     bitmap.font = @font
  191.     x = 0
  192.     for item in items
  193.       if item.is_a?(Color)
  194.         bitmap.font.color = item
  195.       elsif item.is_a?(Integer)
  196.         bitmap.font.size = item
  197.       elsif item.is_a?(Array)
  198.         bitmap.font.name = item[0] if item.size == 1
  199.       elsif item.is_a?(Bitmap)
  200.         bitmap.blt(x + 2, (height - item.height) / 2,
  201.                    item, Rect.new(0,0,item.width,item.height))
  202.         x += item.width + 4
  203.       elsif item == :bold
  204.         bitmap.font.italic = !bitmap.font.bold
  205.       elsif item == :italic
  206.         bitmap.font.italic = !bitmap.font.italic
  207.       else
  208.         bitmap.draw_text(x,0,width,height,item)
  209.         x += bitmap.text_size(item).width
  210.       end
  211.     end
  212.     return bitmap
  213.   end
  214.   #--------------------------------------------------------------------------
  215.   # ● 解析文本
  216.   #--------------------------------------------------------------------------
  217.   def parse_text(str)
  218.     begin
  219.       last_text = str.clone
  220.       str.gsub!(/\\v\[(\d+)\]/i) { $game_variables[$1.to_i] }
  221.       str.gsub!(/\\g/i) { $game_party.gold.to_s }
  222.       str.gsub!(/\\itm\[(\d+)\]/i) { $game_party.item_number($1.to_i) }
  223.       str.gsub!(/\\wpn\[(\d+)\]/i) { $game_party.weapon_number($1.to_i) }
  224.       str.gsub!(/\\amr\[(\d+)\]/i) { $game_party.armor_number($1.to_i) }
  225.       str.gsub!(/\\1line{(.+?)}/im) { $1.delete("\n") }
  226.       str.gsub!(/\\eval{(.+?)}/im) { eval($1) }
  227.     end until str == last_text
  228.     str.gsub!(/\\n\[(\d+)\]/i) do
  229.       $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  230.     end
  231.     str.gsub!(/\n/){"\000\002n\000"}
  232.     str.gsub!(/\\\\/) { "\001" }
  233.     str.gsub!(/\\a\[([0-2])\]/i){ "\000\0027#{$1}" }
  234.     str.gsub!(/\\c\[(\d+)\]/i) { "\000\0020#{$1}\000" }
  235.     str.gsub!(/\\bold/i) { "\000\0021\000" }
  236.     str.gsub!(/\\italic/i) { "\000\0022\000" }
  237.     str.gsub!(/\\f\[(\w+)\]/i) { "\000\0023#{$1}\000" }
  238.     str.gsub!(/\\s\[(\d+)\]/i) { "\000\0024#{$1}\000" }
  239.     str.gsub!(/\\p\[(.+?)\]/i) { "\000\0025#{$1}\000" }
  240.     str.gsub!(/\\icon\[(.+?)\]/i){ "\000\0026#{$1}\000" }
  241.     str.gsub!(/\001/) {"\\"}
  242.     @items = str.split("\000")
  243.     @items.delete("")
  244.   end
  245.   #--------------------------------------------------------------------------
  246.   # ● 深度解析
  247.   #--------------------------------------------------------------------------
  248.   def parse_items
  249.     return unless @items.size > 0
  250.     bitmap = @cache
  251.     width, height, items = 1, 32, []
  252.     while item = @items.delete_at(0)
  253.       if item[/^\002([0-9a-z])(.*)/]
  254.         case (a = $1)
  255.         when '7'
  256.           @align = $2.to_i
  257.         when '0'
  258.           color = $2.to_i
  259.           bitmap.font.color = if color >= 0 and color <= 9
  260.             text_color(color)
  261.           elsif color == 8
  262.             disabled_color
  263.           elsif color == 9
  264.             system_color
  265.           end
  266.           items.push bitmap.font.color
  267.         when '1'
  268.           items.push :bold
  269.         when '2'
  270.           items.push :italic
  271.         when '3'
  272.           bitmap.font.name = $2
  273.           items.push [bitmap.font.name]
  274.         when '4'
  275.           bitmap.font.size = $2.to_i
  276.           items.push bitmap.font.size
  277.         when '5', '6'
  278.           item = (a == 5) ? RPG::Cache.picture($2) : RPG::Cache.icon($2)
  279.           if item.width > 408
  280.             item.dispose
  281.             items.unshift("[图片太大无法显示]")
  282.             next
  283.           elsif width + item.width > 408
  284.             @items.unshift(item)
  285.             break
  286.           end
  287.           items.push(item)
  288.           width += item.width + 4
  289.           height = item.height + 4 if item.height + 4 > height
  290.         when 'n'
  291.           break
  292.         end
  293.       else
  294.         str = ""
  295.         size = Rect.new(0, 0, 0, 0)
  296.         while s = item.slice!(/./)
  297.           size = bitmap.text_size(str + s)
  298.           if width + size.width > 408
  299.             item.insert(0, s)
  300.             break
  301.           else
  302.             str += s
  303.           end
  304.         end
  305.         if items[-1].is_a?(String)
  306.           items[-1] += str
  307.         else
  308.           items.push(str)
  309.         end
  310.         width += size.width
  311.         height = size.height + 4 if size.height + 4 > height
  312.         if item != ""
  313.           @items.unshift(item)
  314.           break
  315.         end
  316.       end
  317.     end
  318.     b = draw_line(width, height, items)
  319.     if @draw_y + b.height > 384
  320.       c = self.contents
  321.       self.contents = Bitmap.new(408, @draw_y + b.height)
  322.       self.contents.blt(0, 0, c, Rect.new(0,0,c.width, c.height))
  323.       c.dispose
  324.     end
  325.     x = 0
  326.     x = 204 - (b.width / 2) if @align == 1
  327.     x = 408 - b.width if @align == 2
  328.     self.contents.blt(x, @draw_y, b, Rect.new(0,0,b.width, b.height))
  329.     @draw_y += b.height
  330.   end
  331. end

  332. #===============================================================================
  333. # ■ 任务界面
  334. #===============================================================================
  335. class Scene_Mission
  336.   #--------------------------------------------------------------------------
  337.   # ● 初始化
  338.   #--------------------------------------------------------------------------
  339.   def initialize
  340.     @last_scene = $scene
  341.   end
  342.   #--------------------------------------------------------------------------
  343.   # ● 主处理
  344.   #--------------------------------------------------------------------------
  345.   def main
  346.     @mission = $game_party.missions
  347.     @window1 = Window_Base.new(0,0,200,64)
  348.     @window1.contents = Bitmap.new(168,32)
  349.     @window1.contents.draw_text(0,0,168,32,"任务",1)
  350.     @window2 = Window_Base.new(200,0,440,64)
  351.     @window2.contents = Bitmap.new(408,32)
  352.     @window2.contents.draw_text(0,0,408,32,"任务说明",1)
  353.     @mission_window = Window_Mission.new
  354.     @mission_window.index = @mission.size - 1
  355.     @index = @mission_window.index
  356.     @info_window = Window_MissionInfo.new
  357.     @info_window.refresh(@mission[@index].info)
  358.     Graphics.transition
  359.     loop do
  360.       Graphics.update
  361.       Input.update
  362.       update
  363.       if $scene != self
  364.         break
  365.       end
  366.     end
  367.     Graphics.freeze
  368.     @window1.dispose
  369.     @window2.dispose
  370.     @mission_window.dispose
  371.     @info_window.dispose
  372.   end
  373.   #--------------------------------------------------------------------------
  374.   # ● 刷新画面
  375.   #--------------------------------------------------------------------------
  376.   def update
  377.     @mission_window.update
  378.     @info_window.update
  379.     if @index != @mission_window.index
  380.       @index = @mission_window.index
  381.       @info_window.refresh(@mission[@index].info)
  382.     end
  383.     return update_mission if @mission_window.active
  384.     update_info
  385.   end
  386.   #--------------------------------------------------------------------------
  387.   # ● 刷新任务
  388.   #--------------------------------------------------------------------------
  389.   def update_mission
  390.     if Input.trigger?(Input::C)
  391.       $game_system.se_play($data_system.decision_se)
  392.       @mission_window.active = false
  393.       @info_window.oy = 0
  394.     elsif Input.trigger?(Input::B)
  395.       $game_system.se_play($data_system.cancel_se)
  396.       $scene = @last_scene
  397.       return
  398.     end
  399.   end
  400.   #--------------------------------------------------------------------------
  401.   # ● 刷新人物详情
  402.   #--------------------------------------------------------------------------
  403.   def update_info
  404.     @info_window.wait = 90
  405.     if Input.press?(Input::UP)
  406.       @info_window.oy -= 3
  407.       @info_window.oy = 0 if @info_window.oy < 0
  408.     elsif Input.press?(Input::DOWN)
  409.       @info_window.oy += 3
  410.       @info_window.oy = @info_window.oy_max if @info_window.oy > @info_window.oy_max
  411.     elsif Input.repeat?(Input::L)
  412.       $game_system.se_play($data_system.cursor_se)
  413.       @mission_window.index -= 1
  414.       @mission_window.index = $game_party.missions.size - 1 if @mission_window.index < 0
  415.     elsif Input.repeat?(Input::R)
  416.       $game_system.se_play($data_system.cursor_se)
  417.       @mission_window.index += 1
  418.       @mission_window.index = 0 if @mission_window.index >= $game_party.missions.size
  419.     elsif Input.trigger?(Input::B)
  420.       $game_system.se_play($data_system.cancel_se)
  421.       @mission_window.active = true
  422.       @info_window.scroll_up = false
  423.       @info_window.oy = 0
  424.     end
  425.   end
  426. end

  427. #===============================================================================
  428. # ■ 事件处理器
  429. #===============================================================================
  430. class Interpreter
  431.   alias orig_ec_mission execute_command if !defined?(orig_ec_mission)
  432.   #--------------------------------------------------------------------------
  433.   # ● 重定义执行事件命令
  434.   #--------------------------------------------------------------------------
  435.   def execute_command
  436.     if @index >= @list.size - 1
  437.       command_end
  438.       return true
  439.     end
  440.     @parameters = @list[@index].parameters
  441.     return command_108 if @list[@index].code == 108
  442.     return orig_ec_mission
  443.   end
  444.   #--------------------------------------------------------------------------
  445.   # ● 注释
  446.   #--------------------------------------------------------------------------
  447.   def command_108
  448.     case @list[@index].parameters[0]
  449.     when (/^删除任务\[(\w+)\]$/)
  450.       $game_party.delete_mission($1)
  451.       return true
  452.     when (/^完成任务\[(\w+)\]$/)
  453.       $game_party.done_mission($1)
  454.       return true
  455.     when "删除所有任务"
  456.       $game_party.delete_all_mission
  457.       return true
  458.     when "完成所有任务"
  459.       $game_party.done_all_mission
  460.       return true
  461.     when (/^放弃任务\[(\w+)\]$/)
  462.       $game_party.fail_mission($1)
  463.       return true
  464.     when (/^恢复任务\[(\w+)\]$/)
  465.       $game_party.resume_mission($1)
  466.       return true
  467.     when "恢复所有任务"
  468.       $game_party.resume_all_mission
  469.       return true
  470.     end
  471.     text = @list[@index].parameters[0]
  472.     loop do
  473.       if @list[@index+1].code == 108 or @list[@index+1].code == 408
  474.         text += "\n" + @list[@index+1].parameters[0]
  475.       else
  476.         break
  477.       end
  478.       @index += 1
  479.     end
  480.     split = text.split("\n")
  481.     if (split[0] == "任务设置" or split[0] == "任务更新" or split[0] == "追加说明") and split.size >= 3
  482.       info , name = split[2] , split[1]
  483.       if split.size >= 4
  484.         for i in 3...split.size
  485.           info += "\n" + split[i]
  486.         end
  487.       end
  488.       $game_party.get_mission(name,info) if split[0] == "任务设置"
  489.       $game_party.update_mission(name,info) if split[0] == "任务更新"
  490.       $game_party.add_mission_info(name,info) if split[0] == "追加说明"
  491.     end
  492.     return true
  493.   end
  494. end
复制代码


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

本版积分规则

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

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

GMT+8, 2024-4-24 03:39

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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