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

Project1

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

[RMVX发布] 【XP→VX】MTV脚本

[复制链接]

Lv4.逐梦者

醉啸 长风万里

梦石
0
星屑
6137
在线时间
6591 小时
注册时间
2007-12-16
帖子
4501

贵宾

跳转到指定楼层
1
发表于 2010-7-4 12:17:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
以前的VXMTV脚本已经失踪,我整合了一下XP的
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================
  4. # ------------------------------------------------------------------------
  5. # 高精度计时器 by FantasyDR
  6. # ------------------------------------------------------------------------
  7. # E-mail: [email protected]
  8. # ------------------------------------------------------------------------
  9. # 2005.10.18
  10. # ------------------------------------------------------------------------
  11. # 该类已经被定义为全局变量 $sys_timer
  12. # 如果只需要精确到毫秒,请设置初始化参数为true
  13. # decimal属性设置返回时间值的小数位数。
  14. # ------------------------------------------------------------------------
  15. # 下面是一些有用的方法列表,调用时写:$sys_timer.方法名
  16. # 例如 $sys_timer.clear()
  17. # ------------------------------------------------------------------------
  18. # clear() :计时器清零
  19. # now() :获取当前经过的时间,单位毫秒
  20. # now_s() :获取当前经过的时间,单位秒
  21. # ------------------------------------------------------------------------
  22. class SystemTimer
  23. attr_accessor:decimal #小数位数设定,默认为3

  24. def initialize(use_GetTime=false)
  25. # 初始化,根据系统选择不同精度计时器
  26. @qpFrequency = Win32API.new("kernel32","QueryPerformanceFrequency",'p','L')
  27. @qpCounter = Win32API.new("kernel32","QueryPerformanceCounter",'p','L')
  28. @tGetTime = Win32API.new("winmm","timeGetTime",'','L')

  29. @decimal=3
  30. @perf_cnt=" " * 8
  31. @time_start=" " * 8
  32. @time_now=" " * 8

  33. result = @qpFrequency.call(@perf_cnt)

  34. if use_GetTime
  35. result = 0
  36. end

  37. if result!=0
  38. @perf_flag=true
  39. else
  40. @perf_flag=false
  41. @perf_cnt=[1000,0].pack('LL')
  42. end

  43. #设置时间比例因数
  44. @time_scale=@perf_cnt.unpack('LL')
  45. @time_scale[0] /= 1000.0
  46. @time_scale[1] /= 1000.0

  47. #起始时间清零
  48. self.clear()
  49. end

  50. #-=====================-#
  51. # 计时器清零
  52. #-=====================-#
  53. def clear()
  54. if @perf_flag
  55. @qpCounter.call(@time_start)
  56. else
  57. @time_start=[@tGetTime.call(),0].pack('LL')
  58. end
  59. end

  60. #-==============================-#
  61. # 获取当前经过的时间,单位毫秒
  62. #-==============================-#
  63. def now()
  64. now_time = 0.0e1
  65. now_time += self.timer() - self.start()
  66. now_time /= self.scale()
  67. return self.debug(now_time)
  68. end

  69. #-==============================-#
  70. # 获取当前经过的时间,单位秒
  71. #-==============================-#
  72. def now_s()
  73. now_time = 0.0e1
  74. now_time += self.timer() - self.start()
  75. now_time /= (self.scale()*1000)
  76. return self.debug(now_time)
  77. end

  78. #-==============================-#
  79. # 帧错...
  80. #-==============================-#
  81. def debug(now_time)
  82. if @decimal>0
  83. now_time = (now_time * (10**@decimal)).floor/(10.0**@decimal)
  84. else
  85. now_time = now_time.floor
  86. end
  87. return now_time

  88. #以下用于debug模式
  89. if now_time < 0
  90. p "Timer Wrong!! Clear...",now_time,\
  91. @perf_flag,@qpCounter,@tGetTime,
  92. @time_now.unpack('LL')[0],@time_now.unpack('LL')[1],
  93. @time_start.unpack('LL')[0],@time_start.unpack('LL')[1]
  94. self.clear()
  95. return 0.0
  96. else
  97. return now_time
  98. end
  99. end

  100. #-=====================-#
  101. # 获取时间比例因数
  102. #-=====================-#
  103. def scale()
  104. return @time_scale[0]+\
  105. @time_scale[1]*0xffffffff
  106. end

  107. #-=====================-#
  108. # 获取起始滴答数
  109. #-=====================-#
  110. def start()
  111. return @time_start.unpack('LL')[0]+\
  112. @time_start.unpack('LL')[1]*0xffffffff
  113. end

  114. #-=====================-#
  115. # 获取当前的嘀哒数
  116. #-=====================-#
  117. def timer()
  118. if @perf_flag
  119. @qpCounter.call(@time_now)
  120. else
  121. @time_now=[@tGetTime.call(),0].pack('LL')
  122. end
  123. return @time_now.unpack('LL')[0]+\
  124. @time_now.unpack('LL')[1]*0xffffffff
  125. end
  126. end
  127. #-------------------------------------#
  128. # 初始化自身成一个全局变量
  129. #-------------------------------------#
  130. $sys_timer=SystemTimer.new()
  131. #-------------------------------------#




  132. #==============================================================================
  133. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  134. #==============================================================================

  135. #==============================================================================
  136. # 仭 EasyConv module - Ver 0.90
  137. #------------------------------------------------------------------------------
  138. # Moonlight INN
  139. # http://cgi.members.interq.or.jp/aquarius/rasetsu/
  140. # RaTTiE
  141. # [email protected]
  142. #------------------------------------------------------------
  143. # EasyConv::s2u(text) : S-JIS -> UTF-8
  144. # EasyConv::u2s(text) : UTF-8 -> S-JIS
  145. #==============================================================================
  146. module EasyConv
  147. # API梡掕悢掕媊
  148.    CP_ACP = 0
  149.    CP_UTF8 = 65001

  150. #--------------------------------------------------------------------------
  151. # 仠 S-JIS -> UTF-8
  152. #--------------------------------------------------------------------------
  153. def s2u(text)
  154. # API掕媊
  155.    m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
  156.    w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')

  157. # S-JIS -> Unicode
  158.    len = m2w.call(CP_ACP, 0, text, -1, nil, 0);
  159.    buf = "\0" * (len*2)
  160.    m2w.call(CP_ACP, 0, text, -1, buf, buf.size/2);

  161. # Unicode -> UTF-8
  162.    len = w2m.call(CP_UTF8, 0, buf, -1, nil, 0, nil, nil);
  163.    ret = "\0" * len
  164.    w2m.call(CP_UTF8, 0, buf, -1, ret, ret.size, nil, nil);
  165.    
  166.    return ret
  167. end
  168. # module_function偲偟偰岞奐
  169. module_function :s2u
  170. #--------------------------------------------------------------------------
  171. # 仠 UTF-8 -> S-JIS
  172. #--------------------------------------------------------------------------
  173. def u2s(text)
  174. # API掕媊
  175.    m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
  176.    w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')

  177. # UTF-8 -> Unicode
  178.    len = m2w.call(CP_UTF8, 0, text, -1, nil, 0);
  179.    buf = "\0" * (len*2)
  180.    m2w.call(CP_UTF8, 0, text, -1, buf, buf.size/2);

  181. # Unicode -> S-JIS
  182.    len = w2m.call(CP_ACP, 0, buf, -1, nil, 0, nil, nil);
  183.    ret = "\0" * len
  184.    w2m.call(CP_ACP, 0, buf, -1, ret, ret.size, nil, nil);
  185.    
  186.    return ret
  187. end
  188. # module_function偲偟偰岞奐
  189. module_function :u2s
  190. end

  191. #=================================================================
  192. # MTV 脚本,by 66RPG_柳柳
  193. #=================================================================
  194. module MTV  
  195.   #===============================================================
  196.   # 读取文件。文件相对地址:Audio/BGM
  197.   # file_name:文件名;length:MTV长度,按照.1秒为单位记数
  198.   #===============================================================
  199.   def self.load(file_name,length = 0)
  200.     $mtv_time = []
  201.     $mtv_text = []
  202.     $game_system.mtv_length = length
  203.     #=============================================================
  204.     # 打开文件并且读取之
  205.     #=============================================================
  206.     file =  File.open("Audio/BGM/"+file_name)
  207.     #=============================================================
  208.     # 读取歌词
  209.     #=============================================================
  210.     for line in file.readlines
  211.       #===========================================================
  212.       # 转为UTF-8编码
  213.       #===========================================================
  214.       line = EasyConv.s2u(line)
  215.       #===========================================================
  216.       # 寻找本行歌词
  217.       #===========================================================
  218.       this_line_text = line[line.scan(/\]/).size*10,line.size]
  219.       #===========================================================
  220.       # 把读取的行分存成时间与文字
  221.       #===========================================================
  222.       for i in 0...line.scan(/\]/).size
  223.         temp_b = line[i*10+1,8]
  224.         temp_c = temp_b.split(/:/)[0]
  225.         mmsecond = 600 * temp_c.to_i
  226.         temp_c = temp_b.split(/:/)[1]
  227.         mmsecond += 10 * temp_c.to_f
  228.         $mtv_time.push(mmsecond.to_i)
  229.         $mtv_text.push(this_line_text)
  230.       end
  231.     end
  232.     file.close
  233.   end
  234.   #===============================================================
  235.   # 开始MTV字幕
  236.   #===============================================================
  237.   def self.mtv_begin
  238.     $game_system.mtv_now = true
  239.     $game_system.mtv_begin_time = $sys_timer.now()
  240.     $lrc_text = ""
  241.     return
  242.   end
  243.   #===============================================================
  244.   # 结束MTV字幕
  245.   #===============================================================
  246.   def self.stop
  247.     $game_system.mtv_now = false
  248.     return
  249.   end
  250.   #===============================================================
  251.   # 测试MTV是否播放
  252.   #===============================================================
  253.   def self.mtv?
  254.     return $game_system.mtv_now
  255.   end
  256.   #===============================================================
  257.   # 获取MTV字幕
  258.   #===============================================================
  259.   def self.new_text
  260.     if $game_system.mtv_now
  261.       #===========================================================
  262.       # 求出已经经过的时间
  263.       #===========================================================
  264.       nt = $sys_timer.now()
  265.       nt -= $game_system.mtv_begin_time
  266.       nt = nt.to_i
  267.       nt /= 100      
  268.       #===========================================================
  269.       # 制作循环
  270.       #===========================================================
  271.       if $game_system.mtv_length>0 and nt > $game_system.mtv_length
  272.         nt -= $game_system.mtv_length
  273.       end
  274.       #===========================================================
  275.       # 放出字幕
  276.       #===========================================================
  277.       for tm in 0...$mtv_time.size
  278.         if $mtv_time[tm] == nt
  279.           $lrc_text = $mtv_text[tm]
  280.           break
  281.         end
  282.       end
  283.     else
  284.       $lrc_text = ""
  285.     end
  286.   end
  287. end

  288. #==============================================================================
  289. # ■ Game_System
  290. #------------------------------------------------------------------------------
  291. #  处理系统附属数据的类。也可执行诸如 BGM 管理之类的功能。本类的实例请参考
  292. # $game_system 。
  293. #==============================================================================
  294. class Game_System
  295.   #--------------------------------------------------------------------------
  296.   # ● 定义实例变量
  297.   #--------------------------------------------------------------------------
  298.   attr_accessor :mtv_begin_time
  299.   attr_accessor :mtv_now
  300.   attr_accessor :mtv_length
  301.   #--------------------------------------------------------------------------
  302.   # ● 初始化对像
  303.   #--------------------------------------------------------------------------
  304.   alias mtv_gamesystem_initialize initialize
  305.   def initialize
  306.     mtv_gamesystem_initialize
  307.     @mtv_begin_time = $sys_timer.now()
  308.     @mtv_now = false
  309.     @mtv_length = 0
  310.   end
  311. end  

  312. #==============================================================================
  313. # ■ Scene_Map
  314. #------------------------------------------------------------------------------
  315. #  处理地图画面的类。
  316. #==============================================================================
  317. class Scene_Map
  318.   #--------------------------------------------------------------------------
  319.   # ● 刷新画面
  320.   #--------------------------------------------------------------------------
  321.   alias mtv_scenemap_update update
  322.   def update
  323.     @mtv_window.refresh
  324.     mtv_scenemap_update
  325.   end
  326.   #--------------------------------------------------------------------------
  327.   # ● 主处理
  328.   #--------------------------------------------------------------------------
  329.   alias mtv_scenemap_main main
  330.   def main
  331.     @mtv_window = Window_MTV.new
  332.     mtv_scenemap_main
  333.     @mtv_window.dispose
  334.   end
  335.   #--------------------------------------------------------------------------
  336.   # ● 调用战斗 (调整自动切换BGM)
  337.   #--------------------------------------------------------------------------
  338.   def call_battle
  339.     gtbs_call_battle
  340.     if $game_system.tbs_enabled
  341.       $scene = Scene_Battle.new
  342.     end
  343.   end
  344. end

  345. #==============================================================================
  346. # ■ Scene_Battle
  347. #------------------------------------------------------------------------------
  348. #  处理战斗的类。
  349. #==============================================================================
  350. class Scene_Battle_TBS
  351.   #--------------------------------------------------------------------------
  352.   # ● 刷新画面
  353.   #--------------------------------------------------------------------------
  354.   alias mtv_scenebattle_update update
  355.   def update
  356.     @mtv_window.refresh
  357.     mtv_scenebattle_update
  358.   end
  359.   #--------------------------------------------------------------------------
  360.   # ● 主处理
  361.   #--------------------------------------------------------------------------
  362.   alias mtv_scenebattle_main main
  363.   def main
  364.     @mtv_window = Window_MTV.new
  365.     mtv_scenebattle_main
  366.     @mtv_window.dispose
  367.   end
  368. end

  369. #==============================================================================
  370. # ■ Window_MTV
  371. #------------------------------------------------------------------------------
  372. #  显示MTV字幕的窗口。
  373. #==============================================================================

  374. class Window_MTV < Window_Base
  375.   #--------------------------------------------------------------------------
  376.   # ● 初始化窗口
  377.   #--------------------------------------------------------------------------
  378.   def initialize
  379.     super(0, 0, 544+64, 64)
  380.     self.contents = Bitmap.new(width - 32, height - 32)
  381.     $lrc_text = ""
  382.     self.z = 9999
  383.     refresh
  384.   end
  385.   #--------------------------------------------------------------------------
  386.   # ● 刷新
  387.   #--------------------------------------------------------------------------
  388.   def refresh(text = "")
  389.     MTV.new_text
  390.     self.contents.clear   
  391.     if $game_temp.in_battle
  392.       self.opacity = 0
  393.     else
  394.       self.opacity = 0
  395.     end
  396.     self.contents.font.color = Color.new(0,0,0,255)
  397.     self.contents.draw_text(-11, 1, 512+64, 32, $lrc_text, 2)
  398.     self.contents.font.color = Color.new(255,255,255,255)
  399.     self.contents.draw_text(-10, 0, 512+64, 32, $lrc_text, 2)
  400.   end
  401. end
复制代码
使用方法和XP的一样
范例工程就不提供了

还在龟速填坑中

Lv1.梦旅人

风雪夜不归人

梦石
0
星屑
50
在线时间
276 小时
注册时间
2006-3-7
帖子
6721

贵宾

2
发表于 2010-7-8 15:58:21 | 只看该作者
支持一下,最近正在找这个呢
有些人,到了七八月份就会诈尸。
宫斗,是女生永远的爱。
冷门,是本人不变的欲。
作弊,是玩家自由的痛。
练级,是橙光割舍的情。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

PIG·KIN

梦石
0
星屑
45
在线时间
442 小时
注册时间
2009-1-26
帖子
3298

贵宾

3
发表于 2010-7-8 16:33:40 | 只看该作者
无图无真相
回复 支持 反对

使用道具 举报

Lv4.逐梦者

醉啸 长风万里

梦石
0
星屑
6137
在线时间
6591 小时
注册时间
2007-12-16
帖子
4501

贵宾

4
 楼主| 发表于 2010-7-9 14:53:17 | 只看该作者
回复 ★PIG★ 的帖子

和XP的一样,只是改了窗口显示坐标并VX化
   
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
262 小时
注册时间
2009-1-10
帖子
309
5
发表于 2010-7-9 15:55:22 | 只看该作者
话说给个 xp 原版的帖子地址吧
回复 支持 反对

使用道具 举报

Lv4.逐梦者

醉啸 长风万里

梦石
0
星屑
6137
在线时间
6591 小时
注册时间
2007-12-16
帖子
4501

贵宾

6
 楼主| 发表于 2010-7-9 16:15:27 | 只看该作者
回复 PAME 的帖子


    XP原版的有好几个,自己搜吧
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
7 小时
注册时间
2009-7-12
帖子
108
7
发表于 2010-7-20 18:27:38 | 只看该作者
嗯,这个蛮好。
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-20 00:30

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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