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

Project1

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

[已经解决] 请教这个脚本应该怎么用?

[复制链接]

Lv2.观梦者

梦石
0
星屑
381
在线时间
238 小时
注册时间
2013-8-20
帖子
496
跳转到指定楼层
1
发表于 2013-11-11 18:08:48 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
  1. #==============================================================================
  2. #  Simple Quest-Log
  3. #
  4. #  Version : 1.2 - 02.04.08
  5. #  Created by : hellMinor
  6. #  Do NOT redistribute without my permission
  7. #  Description : A simple script for a Quest-Log
  8. #
  9. #==============================================================================
  10. #==============================================================================
  11. # F.A.Q.
  12. #==============================================================================
  13. # The Global Questlog-Name is $questlog
  14. # To open the Questlog from the menu just do $scene = Scene_Questlog.new
  15. # To open the Questlog from an event $scene = Scene_Questlog.new(false)
  16. #
  17. # To add a quest make a new call script with this Template :
  18. # $questlog.addQuest("Unique ID","Quest Title","Quest Description","State")
  19. #
  20. # To update a Quest description make a new call script with this Template :
  21. # $questlog.updateQuest("unique ID","Quest Description","State")
  22. #
  23. # To move a Quest to Completed Quests make new call script with this Template :
  24. # $questlog.completeQuest("Unique ID")
  25. #
  26. # To delete a Quest from the Active-Questlog make a call script with this
  27. # Template :
  28. # $questlog.deleteQuest("Unique ID")
  29. #
  30. # You can get the current state of a Quest with this Template :
  31. # $questlog.getQuestState("Unique ID")
  32. # This may be useful in a conditional branch if you want to react with a
  33. # special Quest-State
  34. #
  35. # If u want to add a Questmap, create a folder named Questmaps in your
  36. # Graphics folder. The name of the Questmap must be the same as the Quest
  37. # in the Game. Be sure that you set the correct MAP_FORMAT.
  38. # A Quest-Map should have a size of 265*200 px !
  39. # I.E. : If your Quest is named QuestYXZ , the picture in the Questmap folder
  40. # has to be QuestYXZ.png if your map is a .png
  41. #==============================================================================
  42. # Setup
  43. #==============================================================================
  44. QUESTLOGNAME = "Questlog"               # Questlog Menu name
  45. QUEST_MENU_ITEM_1 = "Active Quests"     # Active Quest name
  46. QUEST_MENU_ITEM_2 = "Completed Quests"  # Completed Quest name
  47. SIZE_VAR = 20                           # Character Size
  48. MAP_FORMAT = "png"                      # Quest-Map Ending
  49. #==============================================================================
  50. class Questlog
  51. #==============================================================================
  52.   def addQuest(id,header,description,state = "")
  53.     $activelog << [id,header,description,state]
  54.   end
  55. #------------------------------------------------------------------------------  
  56.   def updateQuest(id,description,state = "")
  57.     for i in 0..$activelog.size-1
  58.       if $activelog[i][0] == id
  59.         $activelog[i][2] = description
  60.         $activelog[i][3] = state
  61.         break
  62.       end
  63.     end
  64.   end
  65. #------------------------------------------------------------------------------
  66.   def completeQuest(id)
  67.     for i in 0..$activelog.size-1
  68.       if $activelog[i][0] == id
  69.         $completedlog << $activelog[i]
  70.         $activelog.delete_at(i)
  71.         break
  72.       end
  73.     end
  74.   end
  75. #------------------------------------------------------------------------------
  76.   def deleteQuest(id)
  77.     for i in 0..$activelog.size-1
  78.       if $activelog[i][0] == id
  79.         $activelog.delete_at(i)
  80.         break
  81.       end
  82.     end
  83.   end
  84. #------------------------------------------------------------------------------
  85.   def getQuestState(id)
  86.     for i in 0..$activelog.size-1
  87.       if $activelog[i][0] == id
  88.         return $activelog[i][3]
  89.         break
  90.       end
  91.     end
  92.   end
  93.   
  94. end
  95. #==============================================================================
  96. class Scene_Questlog < Scene_Base
  97. #==============================================================================
  98.   def initialize(from_menu = true)
  99.     @from_menu = from_menu
  100.   end
  101.   
  102.   def start
  103.     super
  104.     create_menu_background
  105.     @help_window = Window_Help.new
  106.     @help_window.set_text(QUESTLOGNAME,1)
  107.    
  108.     s1 = QUEST_MENU_ITEM_1
  109.     s2 = QUEST_MENU_ITEM_2
  110.    
  111.     @select_window = Window_Command.new(544,[s1,s2],2,1)
  112.     @select_window.y = 55
  113.     @select_window.active = true
  114.    
  115.   end
  116. #------------------------------------------------------------------------------
  117.   def terminate
  118.     super
  119.     dispose_menu_background
  120.     @help_window.dispose
  121.     @select_window.dispose
  122.   end
  123. #------------------------------------------------------------------------------  
  124.   def kill_questwindows
  125.     @quest_window.dispose
  126.   end  
  127. #------------------------------------------------------------------------------
  128.   def return_scene
  129.     if @from_menu
  130.       $scene = Scene_Menu.new
  131.     else
  132.       $scene = Scene_Map.new
  133.     end
  134.   end
  135. #------------------------------------------------------------------------------
  136.   def update
  137.     super
  138.     update_menu_background
  139.     @help_window.update
  140.     if @select_window.active
  141.       @select_window.update
  142.       update_select_selection
  143.     elsif @quest_window.active
  144.       @quest_window.update
  145.       update_quest_selection
  146.     end
  147.   end
  148. #------------------------------------------------------------------------------
  149.   def update_select_selection
  150.     if Input.trigger?(Input::B)
  151.       Sound.play_cancel
  152.       return_scene
  153.     elsif Input.trigger?(Input::C)
  154.       case @select_window.index
  155.       when 0
  156.         $oldlog = false
  157.         @quest_window = Window_Quest.new(0,110,272,(24*11)+42)
  158.         @select_window.active = false
  159.         @quest_window.active = true
  160.       when 1
  161.         $oldlog = true
  162.         @quest_window = Window_Quest.new(0,110,272,(24*11)+42)
  163.         @select_window.active = false
  164.         @quest_window.active = true
  165.       end      
  166.     end
  167.   end
  168. #------------------------------------------------------------------------------  
  169.   def update_quest_selection
  170.     if Input.trigger?(Input::B)
  171.       Sound.play_cancel
  172.       kill_questwindows
  173.       @select_window.active = true
  174.     end
  175.   end

  176. end
  177. #==============================================================================
  178. class Scene_Title < Scene_Base
  179. #==============================================================================
  180.   alias create_game_objects_additions create_game_objects
  181.   def create_game_objects
  182.     create_game_objects_additions
  183.     $questlog = Questlog.new
  184.     $activelog = Array.new
  185.     $completedlog = Array.new
  186.   end
  187.   
  188. end
  189. #==============================================================================
  190. class Window_Help < Window_Base
  191. #==============================================================================
  192.   def initialize(x = 0,y = 0, width = 544, height = WLH+32)
  193.     super(x, y, width, height)
  194.   end
  195.   
  196. end
  197. #==============================================================================
  198. class Window_Description < Window_Base
  199. #==============================================================================
  200.   def initialize(x = 0,y = 0, width = 544, height = WLH+32)
  201.     super(x, y, width, height)
  202.     @text = nil
  203.     @contents_x = 0
  204.     @contents_y = 0
  205.     @line_count = 0             # Line count drawn up until now
  206.     update
  207.   end
  208. #------------------------------------------------------------------------------  
  209.   def new_line
  210.     @contents_x = 0
  211.     @contents_y += WLH
  212.     @line_count += 1
  213.     @line_show_fast = false
  214.   end
  215. #------------------------------------------------------------------------------  
  216.   def finish_message
  217.     @text = nil
  218.     @line_count = 0
  219.     @contents_x = 0
  220.     @contents_y = 0
  221.   end
  222. #------------------------------------------------------------------------------  
  223.   def write_text(str)
  224.     if str != nil || str != ""
  225.       create_contents
  226.       update_msg(str)
  227.     end
  228.   end
  229. #------------------------------------------------------------------------------  
  230.   def update_msg(str)
  231.     str.each_line{|str2|iterator(str2)}
  232.     finish_message
  233.   end
  234. #------------------------------------------------------------------------------   
  235.   def iterator(str2)
  236.     contents.font.size = SIZE_VAR
  237.     contents.draw_text(@contents_x, @contents_y, str2.size*40, WLH, str2.delete("\n"))
  238.     c_width = contents.text_size(str2).width
  239.     @contents_x += c_width
  240.     new_line
  241.   end
  242.   
  243. end
  244. #==============================================================================
  245. class Window_Quest < Window_Selectable
  246. #==============================================================================
  247.   def initialize(x, y, width, height)
  248.     super(x, y, width, height)
  249.     @column_max = 1
  250.     self.index = 0
  251.    
  252.     @quest_helper = Window_Description.new(271,110,273,(24*11)+42)
  253.    
  254.     refresh
  255.   end
  256. #------------------------------------------------------------------------------
  257.   def refresh
  258.     @data = []
  259.     if !$oldlog
  260.       for i in (0..$activelog.size-1)
  261.         @data.push($activelog[i])
  262.       end
  263.     else
  264.       for i in (0..$completedlog.size-1)
  265.         @data.push($completedlog[i])
  266.       end
  267.     end
  268.     @item_max = @data.size
  269.     create_contents
  270.     for i in 0...@item_max
  271.       draw_item(i)
  272.     end
  273.   end
  274. #------------------------------------------------------------------------------
  275.   def draw_item(index)
  276.     rect = item_rect(index)
  277.     self.contents.clear_rect(rect)
  278.     item = @data[index][1]
  279.     if item != nil
  280.       rect.width -= 4
  281.       self.contents.draw_text(rect.x, rect.y, 172, WLH, item)
  282.     end
  283.   end
  284. #------------------------------------------------------------------------------
  285.   alias update_addition update
  286.   def update
  287.     update_addition
  288.     update_description(@index)
  289.     update_selection
  290.   end
  291. #------------------------------------------------------------------------------
  292.   def update_selection
  293.     if Input.trigger?(Input::B)
  294.       Sound.play_cancel
  295.       @quest_helper.dispose
  296.       if @quest_map != nil
  297.         @quest_map_bitmap.bitmap.dispose
  298.         @quest_map_bitmap.dispose
  299.         @quest_map.dispose
  300.         @quest_map_viewport.dispose
  301.         @quest_map = nil
  302.       end
  303.     end
  304.   end
  305. #------------------------------------------------------------------------------   
  306.   def update_description(id)
  307.     if defined?(@data[id][2])
  308.       @quest_helper.write_text(@data[id][2])
  309.       if @quest_map == nil
  310.         if File.exist?("Graphics/Questmaps/"+@data[id][1]+"."+MAP_FORMAT)
  311.           self.height /= 3
  312.           @quest_map = Window_Description.new(0,210,272,(24*7)+38)
  313.           @quest_map_bitmap = Sprite.new
  314.           @quest_map_viewport = Viewport.new(3,213,268,(24*7)+35)
  315.           @quest_map_bitmap.viewport = @quest_map_viewport
  316.           @quest_map_bitmap.bitmap = Cache.questmaps(@data[id][1])
  317.           @quest_map_bitmap.viewport.z = 150
  318.         end
  319.       else
  320.         if File.exist?("Graphics/Questmaps/"+@data[id][1]+"."+MAP_FORMAT)
  321.           @quest_map_bitmap.bitmap = Cache.questmaps(@data[id][1])
  322.         else
  323.           self.height *= 3
  324.           @quest_map_bitmap.bitmap.dispose
  325.           @quest_map_bitmap.dispose
  326.           @quest_map.dispose
  327.           @quest_map_viewport.dispose
  328.           @quest_map = nil
  329.         end
  330.       end
  331.     end
  332.   end
  333.   
  334. end
  335. #==============================================================================
  336. class Scene_File < Scene_Base
  337. #==============================================================================
  338.   alias write_save_data_adds write_save_data
  339.   def write_save_data(file)
  340.     write_save_data_adds(file)   
  341.     Marshal.dump($activelog,           file)
  342.     Marshal.dump($completedlog,        file)
  343.     Marshal.dump($questlog,            file)
  344.   end
  345.   
  346.   alias read_save_data_adds read_save_data
  347.   def read_save_data(file)
  348.     read_save_data_adds(file)
  349.     $activelog           = Marshal.load(file)
  350.     $completedlog        = Marshal.load(file)
  351.     $questlog            = Marshal.load(file)
  352.   end
  353. end
  354. #==============================================================================
  355. module Cache
  356. #==============================================================================  
  357.   def self.questmaps(filename)
  358.     load_bitmap("Graphics/Questmaps/", filename)
  359.   end
  360.   
  361. end
复制代码
是做什么用的?
不定期回来6R玩。
下方广告帖,欢迎点击

Lv1.梦旅人

狂気の月兔

梦石
0
星屑
231
在线时间
1245 小时
注册时间
2009-4-7
帖子
879

贵宾

2
发表于 2013-11-11 18:31:34 | 只看该作者
本帖最后由 铃仙·优昙华院·因幡 于 2013-11-15 10:33 编辑

  1. # 全局任务列表的变量名是 $questlog
  2. # 在菜单里使用的话, 使用 $scene = Scene_Questlog.new 语句
  3. # 在事件中使用的话, 使用 $scene = Scene_Questlog.new(false) 语句
  4. #
  5. # 添加新任务的脚本语句为:
  6. # $questlog.addQuest("任务唯一ID","任务标题","任务说明","状态")
  7. #
  8. # 更新任务的的语句为:
  9. # $questlog.updateQuest("任务唯一ID","新任务说明","新任务状态")
  10. #
  11. # 删除当前任务的语句为:
  12. # # $questlog.deleteQuest("任务唯一ID")
  13. #
  14. # 可以使用该语句获得任务的状态:
  15. # $questlog.getQuestState("任务唯一ID")
  16. #
  17. # 如果你想要添加一个任务说明图片, 那么在 Graphics下创建一个 Questmaps 的文件夹. 里面的图片必须和
  18. # 任务标题一致.图片的后缀可以在变量 MAP_FORMAT 处修改.
  19. # 图片尺寸为 265 * 200
  20. # 比如: 你的任务标题是 "QuestXYZ", 图片的名字为 QuestXYZ.png , 并且放到 Graphics\Questmaps  文件
  21. # 夹下
复制代码
不负责任的翻译.

评分

参与人数 1梦石 +1 收起 理由
怪蜀黍 + 1 精品文章

查看全部评分

回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
381
在线时间
238 小时
注册时间
2013-8-20
帖子
496
3
 楼主| 发表于 2013-11-11 18:49:02 | 只看该作者
铃仙·优昙华院·因幡 发表于 2013-11-11 18:31
不负责任的翻译.

多谢指导和翻译
不定期回来6R玩。
下方广告帖,欢迎点击
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-29 04:18

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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