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

Project1

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

[有事请教] 一个任务脚本问题

[复制链接]

Lv2.观梦者

梦石
0
星屑
800
在线时间
166 小时
注册时间
2019-6-11
帖子
52
跳转到指定楼层
1
发表于 2019-7-10 22:29:13 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 丝月 于 2019-7-16 04:18 编辑

任务脚本:
弹出下面的框框,如下。没办法运行,该怎么办呢。

脚本如下
RUBY 代码复制
  1. #============================================================================
  2. # ** 任务系统
  3. #    基本:
  4. #      $scene = Scene_Task.new(返回的场景, 游标初始index)       召唤查看任务场景
  5. #    说明:
  6. #      $game_party.accept_task(id)                                  接受id号任务
  7. #      $game_party.delete_task(Game_Task.new(id))             删除(放弃)id号任务
  8. #      $game_party.completed_task(id)                               完成id号任务
  9. #      $game_party.accept_task?(id)                   判断角色是否接受了id号任务
  10. #    快捷手段:
  11. #      visible_ts(id, kind)
  12. #                   在地图画面上显示id号任务的状态.kind:0为接受任务时显示的信息;
  13. #                               1为完成任务时显示的信息;2为任务失败时显示的信息;
  14. #                           3为放弃任务时显示的信息;4为无法放弃任务时显示的信息;
  15. #                                                           5为已接此任务的提示.
  16. #      accept_task(id)            接受id号任务并在地图上显示接受任务时显示的信息
  17. #      complete_task(id)          删除id号任务并在地图上显示完成任务时显示的信息
  18. #      fali_task(id)              删除id号任务并在地图上显示任务失败时显示的信息
  19. #      abandonment_task(id)       删除id号任务并在地图上显示放弃任务时显示的信息
  20. #============================================================================
  21.  
  22. module DOS
  23. #============================================================================
  24. #-------------------------------任务设置-------------------------------------
  25. #============================================================================
  26.  
  27.   Task_Abandonment_Task_Input = Input::Letters["E"] # 放弃任务按钮........[按键]
  28.   Task_Left_Change_Page = Input::LEFT # 左翻页按键........................[按键]
  29.   Task_Right_Change_Page = Input::RIGHT # 右翻页按键......................[按键]
  30.   Task_Filament_Color = Color.new(0, 0, 0) # 描绘报酬表格时,线条的颜色....[颜色]
  31.   # ▼ 绘制确定放弃任务时疑问的文字色.....................................[颜色]
  32.   Task_Query_Word_Color = Color.new(255, 255, 0)
  33.   Task_Gold_Icon_Index = 205 # 金钱的图标id...............................[数字]
  34.   #--任务资料设置(此处省略分类)
  35.   Task = []
  36.   #--村民的烦恼---------------------------------------------------
  37.   Task[0] = { # 任务id
  38.   "Icon" => 50, # 图标id
  39.   "Name" => "村民的烦恼",# 任务名称
  40.   "Caption" => "   最近海边来了一只大虾,时常骚扰村民,你能帮村民解决这只大虾吗?
  41. 提示:大虾的属性为水,可以用火系魔法达到双倍伤害的效果",
  42.   "Reward" => {"Item" => [[1, 5], [2, 2]],       # 完成任务后奖励的物品
  43.                "Weapon" => [[1, 1], [2, 2]],           # 完成任务后奖励的武器
  44.                "Armor" => [[5, 5], [6, 6]],            # 完成任务后奖励的防具
  45.                "Gold" => 1000,           # 完成任务后奖励的金钱
  46.                "Level_Plus" => [[1, 5]], # 完成任务后奖励的等级
  47.                "Exp_Plus" => [[1, 100], [3, 50]]  # 完成任务后奖励的经验
  48.                },
  49.   "Can Abandonment?" => false, # 可否放弃此任务
  50.   "Level" => 5  # 任务等级
  51.   }
  52.   #--闹鬼的屋子--------------------------------------------------
  53.   Task[1] = {
  54.   "Icon" => 136,
  55.   "Name" => "闹鬼的屋子",
  56.   "Caption" => "      村庄里有一间恐怖的大屋子,每天晚上都会发出鬼哭狼嚎的声音.
  57. 虽然人们都很好奇屋子里到底有什么,但是都没有人敢进去,你能帮他们进去看看吗?",
  58.   "Reward" => {"Item" => [[1, 5]],
  59.                "Weapon" => [],
  60.                "Armor" => [],
  61.                "Gold" => 1000,
  62.                "Level_Plus" => [],
  63.                "Exp_Plus" => [[1, 100], [2, 100]]
  64.                },
  65.   "Can Abandonment?" => true, # 可否放弃此任务
  66.   "Level" => 2  # 任务等级
  67.   }
  68. end
  69.  
  70. module Vocab
  71. #============================================================================
  72. #---------------------------任务用语设置-------------------------------------
  73. #============================================================================
  74.  
  75.   Task_Accept = "接受了任务[%s]"
  76.   Task_Complete = "任务[%s]被完成!"
  77.   Task_Fail = "任务[%s]已失败"
  78.   Task_Abandonment = "放弃任务[%s]"
  79.   Task_Can_Not_Abandonment = "无法放弃任务[%s]"
  80.   Task_Adandonment_Query = "你确定要放弃[%s]这个任务吗?"
  81.   Task_Accepted = "已接受任务[%s]"
  82.   Task_Difficulty = "任务难度:"
  83.   Task_Level_Word = ["", "普通任务", "二星任务", "三星任务", "四星任务", "紧急任务"]
  84.   Task_Can_Abandonment_Word = ["可放弃", "不可放弃"]
  85.   Task_Change_Page = ["按下右键翻到下一页 >", "< 按下左键翻到上一页"]
  86. end
  87.  
  88. #============================================================================
  89. # ** Game_Task
  90. #============================================================================
  91. class Game_Task
  92.   #----------------------------------------------------------------------
  93.   # * 初始化
  94.   #----------------------------------------------------------------------
  95.   def initialize(id)
  96.     @id = id
  97.     @task = DOS::Task[id]
  98.   end
  99.   #----------------------------------------------------------------------
  100.   # * 获取任务id
  101.   #----------------------------------------------------------------------
  102.   def id
  103.     return @id
  104.   end
  105.   #----------------------------------------------------------------------
  106.   # * 获取任务图标索引
  107.   #----------------------------------------------------------------------
  108.   def icon_index
  109.     return @task["Icon"]
  110.   end
  111.   #----------------------------------------------------------------------
  112.   # * 获取任务名
  113.   #----------------------------------------------------------------------
  114.   def name
  115.     return @task["Name"]
  116.   end
  117.   #----------------------------------------------------------------------
  118.   # * 获取任务说明
  119.   #----------------------------------------------------------------------
  120.   def caption
  121.     return @task["Caption"]
  122.   end
  123.   #----------------------------------------------------------------------
  124.   # * 获取任务奖赏资料(不包括物品/武器/防具数量)
  125.   #     kind:0为道具;1为武器;2为防具;3为金钱;4为lv;5为exp.
  126.   #----------------------------------------------------------------------
  127.   def reward(kind, index=0)
  128.     case kind
  129.     when 0
  130.       return $data_items[@task["Reward"]["Item"][index][0]]
  131.     when 1
  132.       return $data_weapons[@task["Reward"]["Weapon"][index][0]]
  133.     when 2
  134.       return $data_armors[@task["Reward"]["Armor"][index][0]]
  135.     when 3
  136.       return @task["Reward"]["Gold"]
  137.     when 4
  138.       if @task["Reward"]["Level_Plus"][index] != nil
  139.         return @task["Reward"]["Level_Plus"][index][1]
  140.       else return nil
  141.       end
  142.     when 5
  143.       if @task["Reward"]["Exp_Plus"][index] != nil
  144.         return @task["Reward"]["Exp_Plus"][index][1]
  145.       else return nil
  146.       end
  147.     end
  148.   end
  149.   #----------------------------------------------------------------------
  150.   # * 获取任务奖赏多少种道具
  151.   #     kind:0为道具;1为武器;2为防具.
  152.   #----------------------------------------------------------------------
  153.   def reward_size(kind)
  154.     case kind
  155.     when 0
  156.       return @task["Reward"]["Item"].size
  157.     when 1
  158.       return @task["Reward"]["Weapon"].size
  159.     when 2
  160.       return @task["Reward"]["Armor"].size
  161.     end
  162.   end
  163.   #----------------------------------------------------------------------
  164.   # * 获取任务奖赏等级/经验的受益人(le = level & exp)
  165.   #     kind:0为level;1为exp.
  166.   #----------------------------------------------------------------------
  167.   def reward_le_actor(kind, index)
  168.     case kind
  169.     when 0
  170.       return $game_party.members[@task["Reward"]["Level_Plus"][index][0]]
  171.     when 1
  172.       return $game_party.members[@task["Reward"]["Exp_Plus"][index][0]]
  173.     end
  174.   end
  175.   #----------------------------------------------------------------------
  176.   # * 获取任务奖赏等级/经验的受益人总数(le = level & exp)
  177.   #     kind:0为level;1为exp.
  178.   #----------------------------------------------------------------------
  179.   def reward_le_actor_size(kind)
  180.     case kind
  181.     when 0
  182.       return @task["Reward"]["Level_Plus"].size
  183.     when 1
  184.       return @task["Reward"]["Exp_Plus"].size
  185.     end
  186.   end
  187.   #----------------------------------------------------------------------
  188.   # * 获取任务奖赏道具数量
  189.   #     kind:0为道具;1为武器;2为防具.
  190.   #----------------------------------------------------------------------
  191.   def reward_item_amount(kind,index)
  192.     case kind
  193.     when 0
  194.       return @task["Reward"]["Item"][index][1]
  195.     when 1
  196.       return @task["Reward"]["Weapon"][index][1]
  197.     when 2
  198.       return @task["Reward"]["Armor"][index][1]
  199.     end
  200.   end
  201.   #----------------------------------------------------------------------
  202.   # * 获取任务等级
  203.   #----------------------------------------------------------------------
  204.   def level
  205.     return @task["Level"]
  206.   end
  207.   #----------------------------------------------------------------------
  208.   # * 获取描述任务等级用语
  209.   #----------------------------------------------------------------------
  210.   def level_word
  211.     return Vocab::Task_Level_Word[@task["Level"]]
  212.   end
  213.   #----------------------------------------------------------------------
  214.   # * 获取可否放弃标识
  215.   #----------------------------------------------------------------------
  216.   def can_abandonment?
  217.     return @task["Can Abandonment?"]
  218.   end
  219.   #----------------------------------------------------------------------
  220.   # * 获取可否放弃文字
  221.   #----------------------------------------------------------------------
  222.   def can_abandonment_word
  223.     if @task["Can Abandonment?"] == true
  224.       return Vocab::Task_Can_Abandonment_Word[0]
  225.     else return Vocab::Task_Can_Abandonment_Word[1]
  226.     end
  227.   end
  228. end
  229.  
  230. #==============================================================================
  231. # ** Game_Party
  232. #------------------------------------------------------------------------------
  233. #  這個類用來操控主角隊伍,包含了隊伍所攜資金和物品等資訊。
  234. #  這個類的實例被全域變數 $game_party 所引用。
  235. #==============================================================================
  236.  
  237. class Game_Party < Game_Unit
  238.   attr_reader :accepted_task
  239.   def initialize
  240.     super
  241.     @gold = 100
  242.     @steps = 0
  243.     @last_item_id = 0
  244.     @last_actor_index = 0
  245.     @last_target_index = 0
  246.     @actors = []      # 隊員類型 (主角編號)
  247.     @items = {}       # 所攜物品 HASH 表 (物品編號)
  248.     @weapons = {}     # 所攜武器 HASH 表 (武器編號)
  249.     @armors = {}      # 所攜護具 HASH 表 (護具編號)
  250.     @accepted_task = []
  251.   end
  252.   def accept_task(id)
  253.     @accepted_task.push(Game_Task.new(id))
  254.   end
  255.   def delete_task(task)
  256.     @accepted_task.delete(task)
  257.   end
  258.   def completed_task(id)
  259.     delete_task(Game_Task.new(id))
  260.     for item in 0...@accepted_task[id].reward_size(0)
  261.       gain_item(@accepted_task[id].reward(0, item),@accepted_task[id].reward_item_amount(0,item))
  262.     end
  263.     for item in 0...@accepted_task[id].reward_size(1)
  264.       gain_item(@accepted_task[id].reward(1, item),@accepted_task[id].reward_item_amount(1,item))
  265.     end
  266.     for item in 0...@accepted_task[id].reward_size(2)
  267.       gain_item(@accepted_task[id].reward(2, item),@accepted_task[id].reward_item_amount(2,item))
  268.     end
  269.     for index in 0...@accepted_task[id].reward_le_actor_size(0)
  270.       @accepted_task[id].reward_le_actor(0, index).change_level(@accepted_task[id].reward(5, index), true)
  271.     end
  272.     for index in 0...@accepted_task[id].reward_le_actor_size(1)
  273.       @accepted_task[id].reward_le_actor(0, index).change_exp(@accepted_task[id].reward(4, index), true)
  274.     end
  275.     gain_gold(@accepted_task[id].reward(3))
  276.   end
  277.   def accept_task?(id)
  278.     return @accepted_task.include?(Game_Task.new(id))
  279.   end
  280.   def accept_task_amount
  281.     return @accepted_task.size
  282.   end
  283. end
  284.  
  285. #============================================================================
  286. # ** Window_TaskHelp
  287. #============================================================================
  288. class Window_TaskHelp < Window_Base
  289.   attr_accessor :paga
  290.   def initialize(id, paga=0)
  291.     super(160, 20, 384, 376)
  292.     @paga = paga
  293.     refresh(id)
  294.   end
  295.   def refresh(id)
  296.     dw = self.width - 32
  297.     dh = self.height - 32
  298.     task = Game_Task.new(id)
  299.     self.contents.clear
  300.     if @paga == 0 # 描绘第一页
  301.       draw_icon(task.icon_index, 0, 0)
  302.       self.contents.draw_text(28, 0, dw, 24, task.name)
  303.       self.contents.draw_text(0, 24, dw, 24, Vocab::Task_Difficulty)
  304.       w = self.contents.text_size(Vocab::Task_Difficulty).width
  305.       self.contents.draw_text(w, 24, dw, 24, task.level_word)
  306.       self.contents.draw_text(28, 0, dw-28, 24, task.can_abandonment_word, 2)
  307.       chenge_special_character(task.caption.clone, 0, 48)
  308.     elsif @paga == 1 # 描绘第二页
  309.       #-描绘表格-------------------------------------------------------------
  310.       # 边框
  311.       draw_straight_filament(0, 0, dw, 0, 1, DOS::Task_Filament_Color)
  312.       draw_straight_filament(0, 0, 0, dh, 1, DOS::Task_Filament_Color)
  313.       draw_straight_filament(0, 27, dw, 27, 1, DOS::Task_Filament_Color)
  314.       draw_straight_filament(0, dh-1, dw/2, dh-1, 1, DOS::Task_Filament_Color)
  315.       draw_straight_filament(dw/2+2, dh-5, dw-1, dh-5, 1, DOS::Task_Filament_Color)
  316.       draw_straight_filament(dw-1, 0, dw-1, dh-4, 1, DOS::Task_Filament_Color)
  317.       # 中线
  318.       draw_straight_filament(dw/2-1, 27, dw/2-1, dh, 1, DOS::Task_Filament_Color)
  319.       draw_straight_filament(dw/2+1, 27, dw/2+1, dh-4, 1, DOS::Task_Filament_Color)
  320.       # 队伍成员分割线
  321.       h = (dh-27-1)/4
  322.       draw_straight_filament(0, h*1+27, dw/2-1, h*1+27, 1, DOS::Task_Filament_Color)
  323.       draw_straight_filament(0, h*2+27, dw/2-1, h*2+27, 1, DOS::Task_Filament_Color)
  324.       draw_straight_filament(0, h*3+27, dw/2-1, h*3+27, 1, DOS::Task_Filament_Color)
  325.       draw_straight_filament(0, h*4+27, dw/2-1, h*4+27, 1, DOS::Task_Filament_Color)
  326.       # 头像分割线
  327.       draw_straight_filament(79, 27, 79, dh, 1, DOS::Task_Filament_Color)
  328.       # 描绘成员奖励分割线
  329.       draw_straight_filament(79, (h-h/2)*1+27, dw/2-1, (h-h/2)*1+27, 1, DOS::Task_Filament_Color)
  330.       draw_straight_filament(79, (h-h/2)+h+27, dw/2-1, (h-h/2)+h+27, 1, DOS::Task_Filament_Color)
  331.       draw_straight_filament(79, (h-h/2)+h*2+27, dw/2-1, (h-h/2)+h*2+27, 1, DOS::Task_Filament_Color)
  332.       draw_straight_filament(79, (h-h/2)+h*3+27, dw/2-1, (h-h/2)+h*3+27, 1, DOS::Task_Filament_Color)
  333.       # 描绘奖励分割线
  334.       a = (dw-28)/24
  335.       for i in 0...a
  336.         draw_straight_filament(dw/2+2, 24*i+27, dw-1, 24*i+27, 1, DOS::Task_Filament_Color)
  337.       end
  338.       #-结束描绘-------------------------------------------------------------
  339.       #-描绘内容-------------------------------------------------------------
  340.       # 描绘标题
  341.       self.contents.draw_text(1, 1, dw-1, 24, "奖赏表", 1)
  342.       # 描绘头像等
  343.       for i in 0...$game_party.members.size
  344.         draw_actor_face($game_party.members[i], 1, h*i+28, h-1)
  345.         self.contents.font.size = 20
  346.         self.contents.draw_text(1, 1+h*i+27, 96, 24, $game_party.members[i].name)
  347.         self.contents.font.size = 18
  348.         self.contents.draw_text(81,1+h*i+27, dw/2-81, 24,"奖励#{Vocab.level}:")
  349.         self.contents.draw_text(81,1+h*i+27+h/2, dw/2-81, 24,"奖励经验:")
  350.         if task.reward(4, i) != nil
  351.           self.contents.draw_text(81,1+h*i+27+h/4, dw/2-82, 24, task.reward(4, i), 2)
  352.           else self.contents.draw_text(81,1+h*i+27+h/4, dw/2-82, 24, "无", 2)
  353.         end
  354.         if task.reward(5, i) != nil
  355.           self.contents.draw_text(81,1+h*i+27+h/4+h/2, dw/2-82, 24, task.reward(5, i), 2)
  356.           else self.contents.draw_text(81,1+h*i+27+h/4+h/2, dw/2-82, 24, "无", 2)
  357.         end
  358.       end
  359.       self.contents.font.size = 20
  360.       x = dw/2+1
  361.       # 描绘金钱奖励
  362.       draw_icon(DOS::Task_Gold_Icon_Index, x, 26)
  363.       self.contents.draw_text(x+25, 26, dw/2-1, 24,"金币:#{task.reward(3, 0)}#{Vocab.gold}")
  364.       y = 26+24
  365.       # 描绘道具奖励
  366.       for i in 0...task.reward_size(0)
  367.         draw_icon(task.reward(0, i).icon_index, x, y+i*24)
  368.         self.contents.draw_text(x+25, y+i*24, dw/2-1, 24,"#{task.reward(0, i).name}*#{task.reward_item_amount(0, i)}")
  369.       end
  370.       y = 26 + 24 + task.reward_size(0)*24
  371.       # 描绘武器奖励
  372.       for i in 0...task.reward_size(1)
  373.         draw_icon(task.reward(1, i).icon_index, x, y+i*24)
  374.         self.contents.draw_text(x+25, y+i*24, dw/2-1, 24,"#{task.reward(1, i).name}*#{task.reward_item_amount(1, i)}")
  375.       end
  376.       y = 26 + 24 + task.reward_size(0)*24 + task.reward_size(1)*24
  377.       # 描绘防具奖励
  378.       for i in 0...task.reward_size(2)
  379.         draw_icon(task.reward(2, i).icon_index, x, y+i*24)
  380.         self.contents.draw_text(x+25, y+i*24, dw/2-1, 24,"#{task.reward(2, i).name}*#{task.reward_item_amount(2, i)}")
  381.       end
  382.       #-结束描绘-------------------------------------------------------------
  383.     end
  384.   end
  385. end
  386.  
  387. #=============================================================================
  388. # ** Scene_Task
  389. #=============================================================================
  390. class Scene_Task < Scene_Base
  391.   #---------------------------------------------------------------------------
  392.   # * 初始化变量
  393.   #---------------------------------------------------------------------------
  394.   def initialize(return_scene, index=0)
  395.     @index = index
  396.     @return_scene = return_scene
  397.   end
  398.   #---------------------------------------------------------------------------
  399.   # * 开始处理
  400.   #---------------------------------------------------------------------------
  401.   def start
  402.     create_menu_background
  403.     @th = Window_TaskHelp.new($game_party.accepted_task[0].id)
  404.     @paga = @th.paga
  405.     tn = []
  406.     for i in 0...$game_party.accepted_task.size
  407.       tn[i] = $game_party.accepted_task[i].name
  408.     end
  409.     @hc = Window_Command.new(160, tn)
  410.     @hc.y = 20
  411.     @hc.height = 376
  412.     @hc.index = @index
  413.     @query = Window_Base.new(40, 152, 464, 56)
  414.     a = sprintf(Vocab::Task_Adandonment_Query, $game_party.accepted_task[0].name)
  415.     @query.contents.font.color = DOS::Task_Query_Word_Color
  416.     @query.contents.draw_text(0, 0, 432, 24, a, 1)
  417.     @query.contents.font.color = Color.new(0, 0, 0)
  418.     @qc = Window_Command.new(160, ["          是", "          否"])
  419.     @qc.x = 192
  420.     @qc.y = 208
  421.     @query.visible = false
  422.     @qc.visible = false
  423.     @qc.active = false
  424.     @sprite = Sprite.new
  425.     @sprite.bitmap = Bitmap.new(384, 24)
  426.     @sprite.bitmap.draw_text(0, 0, 384, 24, Vocab::Task_Change_Page[@paga], 1)
  427.     @sprite.x = 0
  428.     @sprite.y = 416-24
  429.   end
  430.   #--------------------------------------------------------------------------
  431.   # * 结束处理
  432.   #--------------------------------------------------------------------------
  433.   def terminate
  434.     dispose_menu_background
  435.     @hc.dispose
  436.     @th.dispose
  437.     @query.dispose
  438.     @qc.dispose
  439.     @sprite.dispose
  440.   end
  441.   #--------------------------------------------------------------------------
  442.   # * 更新帧
  443.   #--------------------------------------------------------------------------
  444.   def update
  445.     @sprite.update
  446.     @sprite.x + 10 if @sprite.x != 160
  447.     @hc.update
  448.     @th.update
  449.     update_input
  450.     if @hc.index != @index
  451.       @th.refresh($game_party.accepted_task[@hc.index].id)
  452.       @index = @hc.index
  453.     end
  454.     @query.update
  455.     if @query.active == true
  456.       @qc.update
  457.     end
  458.     if @paga != @th.paga
  459.       @sprite.bitmap.clear
  460.       @sprite.bitmap.draw_text(0, 0, 384, 24, Vocab::Task_Change_Page[@th.paga], 1)
  461.       @sprite.x = 0
  462.       @paga = @th.paga
  463.     end
  464.   end
  465.   #--------------------------------------------------------------------------
  466.   # * 刷新按键
  467.   #--------------------------------------------------------------------------
  468.   def update_input
  469.     if Input.trigger?(Input::B)
  470.       if @hc.active == true
  471.         Sound.play_cancel
  472.         $scene = @return_scene
  473.       elsif @query.visible == true
  474.         Sound.play_cancel
  475.         @hc.active = true
  476.         @query.visible = false
  477.         @qc.visible = false
  478.         @qc.active = false
  479.       end
  480.     elsif Input.trigger?(DOS::Task_Abandonment_Task_Input)
  481.       if @hc.active == true
  482.         if $game_party.accepted_task[@hc.index].can_abandonment? == true
  483.           Sound.play_decision
  484.           a = sprintf(Vocab::Task_Adandonment_Query, $game_party.accepted_task[@hc.index].name)
  485.           @query.contents.clear
  486.           @query.contents.font.color = DOS::Task_Query_Word_Color
  487.           @query.contents.draw_text(0, 0, 432, 24, a, 1)
  488.           @query.contents.font.color = Color.new(0, 0, 0)
  489.           @query.visible = true
  490.           @qc.visible = true
  491.           @qc.active = true
  492.           @hc.active = false
  493.         else Sound.play_buzzer
  494.           @query.contents.clear
  495.           a = sprintf(Vocab::Task_Can_Not_Abandonment, $game_party.accepted_task[@hc.index].name)
  496.           @query.contents.font.color = DOS::Task_Query_Word_Color
  497.           @query.contents.draw_text(0, 0, 432, 24, a, 1)
  498.           @query.contents.font.color = Color.new(0, 0, 0)
  499.           @query.visible = true
  500.           @hc.active = false
  501.         end
  502.       end
  503.     elsif Input.trigger?(Input::C)
  504.       if @qc.visible == true
  505.         if @qc.index == 0
  506.           Sound.play_decision
  507.           @query.contents.clear
  508.           a = sprintf(Vocab::Task_Abandonment, $game_party.accepted_task[@hc.index].name)
  509.           @query.contents.font.color = DOS::Task_Query_Word_Color
  510.           @query.contents.draw_text(0, 0, 432, 24, a, 1)
  511.           @query.contents.font.color = Color.new(0, 0, 0)
  512.           @qc.visible = false
  513.           @query.visible = true
  514.           $game_party.delete_task($game_party.accepted_task[@hc.index])
  515.           Graphics.wait(40)
  516.           $scene = Scene_Task.new(@return_scene)
  517.         else @hc.active = true
  518.           Sound.play_cancel
  519.           @query.visible = false
  520.           @qc.visible = false
  521.           @qc.active = false
  522.         end
  523.       end
  524.     elsif Input.trigger?(DOS::Task_Left_Change_Page)
  525.       if @th.paga == 1
  526.         @th.paga = 0
  527.         @th.refresh($game_party.accepted_task[@hc.index].id)
  528.       end
  529.     elsif Input.trigger?(DOS::Task_Right_Change_Page)
  530.       if @th.paga == 0
  531.         @th.paga = 1
  532.         @th.refresh($game_party.accepted_task[@hc.index].id)
  533.       end
  534.     end
  535.   end
  536. end
  537.  
  538. #==============================================================================
  539. # ** Game_Map
  540. #------------------------------------------------------------------------------
  541. #  這個類用來操控地圖,包含了地圖滾動設置和通行度判定等資訊。
  542. #  這個類的實例被全域變數 $game_map 所引用。
  543. #==============================================================================
  544.  
  545. class Game_Map
  546.   #--------------------------------------------------------------------------
  547.   # * 宣告執行個體變數
  548.   #--------------------------------------------------------------------------
  549.   attr_accessor :task_id
  550.   attr_reader :ts_visible
  551.   attr_reader :task_word
  552.   alias old_ini initialize
  553.   def initialize
  554.     old_ini
  555.     @task_word = ""
  556.     @ts_visible = false
  557.     @task_id = 0
  558.   end
  559.   def visible_task_status
  560.     if @ts_visible == false
  561.       @ts_visible = true
  562.     else @ts_visible = false
  563.     end
  564.   end
  565.   def set_task_word(kind)
  566.     case kind
  567.     when 0               # 接受了任务
  568.       @task_word = Vocab::Task_Accept
  569.     when 1               # 完成了任务
  570.       @task_word = Vocab::Task_Complete
  571.     when 2               # 任务失败了
  572.       @task_word = Vocab::Task_Fail
  573.     when 3               # 放弃了任务
  574.       @task_word = Vocab::Task_Abandonment
  575.     when 4               # 无法放弃任务
  576.       @task_word = Vocab::Task_Can_Not_Abandonment
  577.     when 5               # 已接受了任务
  578.       @task_word = Vocab::Task_Accepted
  579.     when nil
  580.       @task_word = nil
  581.     end
  582.   end
  583. end
  584.  
  585. #==============================================================================
  586. # ** Scene_Map
  587. #------------------------------------------------------------------------------
  588. #  這個類用來執行顯示地圖場景畫面的程式。
  589. #==============================================================================
  590.  
  591. class Scene_Map < Scene_Base
  592.   alias old_sta start
  593.   alias old_upd update
  594.   alias old_ter terminate
  595.   def start
  596.     old_sta
  597.     @ts = Window_Base.new(40, 152, 464, 56)
  598.     @ts.visible = false
  599.   end
  600.   def terminate
  601.     old_ter
  602.     @ts.dispose
  603.   end
  604.   def update
  605.     old_upd
  606.     if $game_map.ts_visible == true
  607.       @ts.contents.clear
  608.       tw = sprintf($game_map.task_word, Game_Task.new($game_map.task_id).name)
  609.       @ts.contents.draw_text(28, 0, 408, 24, tw)
  610.       @ts.draw_icon(Game_Task.new($game_map.task_id).icon_index, 0, 0)
  611.       @ts.visible = true
  612.       Graphics.wait(40)
  613.       $game_map.visible_task_status
  614.       @ts.visible = false
  615.     end
  616.   end
  617. end
  618.  
  619. #==============================================================================
  620. # ** Game_Interpreter
  621. #------------------------------------------------------------------------------
  622. #  這個類是用來執行事件指令的直譯器。
  623. #  這個類作為 Game_Map、Game_Troop 和 Game_Event 的內部類使用。
  624. #==============================================================================
  625.  
  626. class Game_Interpreter
  627.   def accept_task(id)
  628.     $game_party.accept_task(id)
  629.     visible_ts(id, 0)
  630.   end
  631.   def complete_task(id)
  632.     $game_party.completed_task(id)
  633.     visible_ts(id, 1)
  634.   end
  635.   def fali_task(id)
  636.     $game_party.delete_task(Game_Task.new(id))
  637.     visible_ts(id, 2)
  638.   end
  639.   def abandonment_task(id)
  640.     $game_party.delete_task(Game_Task.new(id))
  641.     visible_ts(id, 3)
  642.   end
  643.   def visible_ts(id, kind)
  644.     $game_map.task_id = id
  645.     $game_map.set_task_word(kind)
  646.     $game_map.visible_task_status
  647.   end
  648. end
  649.  
  650. class Window_Base < Window
  651.   #--------------------------------------------------------------------------
  652.   # * 描绘直线 by 945127391
  653.   # begin_x : 直线开始的x坐标
  654.   # begin_y : 直线开始的y坐标
  655.   # end_x   : 直线结束的x坐标
  656.   # end_y   : 直线结束的y坐标
  657.   # color   : 直线的颜色
  658.   # width   : 直线的宽度(厚度)
  659.   #--------------------------------------------------------------------------
  660.   def draw_straight_filament(begin_x, begin_y, end_x, end_y, width, color)
  661.     if begin_x == end_x
  662.       bitmap = Bitmap.new(width, end_y-begin_y)
  663.     elsif begin_y == end_y
  664.       bitmap = Bitmap.new(end_x-begin_x, width)
  665.     else return
  666.     end
  667.     bitmap.fill_rect(0, 0, bitmap.width, bitmap.height, color)
  668.     rect = Rect.new(0, 0, bitmap.width, bitmap.height)
  669.     self.contents.blt(begin_x, begin_y, bitmap, rect)
  670.     bitmap.dispose
  671.   end
  672.   #--------------------------------------------------------------------------
  673.   # * 描绘自动换行文字 by 叶子
  674.   #                    修改 945127391
  675.   #--------------------------------------------------------------------------
  676.    def chenge_special_character(text, x=0, y=0)
  677.     # 记录换行时y坐标最小加值
  678.     min_y = 0
  679.     while ((c = text.slice!(/./m)) != nil)
  680.       # 另起一行文字的情况下
  681.       if c == "\n"
  682.         y += [WLH, min_y].max
  683.         min_y = 0
  684.         x = 0
  685.         # 下面的文字
  686.         next
  687.       end
  688.       # 自动换行处理
  689.       if x + self.contents.text_size(c).width > self.contents.width
  690.         y += [WLH, min_y].max
  691.         min_y = 0
  692.         x = 0
  693.       end
  694.       # 描绘文字
  695.       self.contents.draw_text(4 + x, y, 40, WLH, c)
  696.       # x 为要描绘文字的加法运算
  697.       x += self.contents.text_size(c).width
  698.     end
  699.   end
  700. end

Lv2.观梦者

梦石
0
星屑
800
在线时间
166 小时
注册时间
2019-6-11
帖子
52
2
 楼主| 发表于 2019-7-15 21:36:44 | 只看该作者
因为之前帖子里的内容没有任何回复。所以换了另一个问题~如果这个改过的
帖子有版规冲突的话,
告诉我下。
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-25 07:41

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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