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

Project1

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

[已经解决] 求修改mtv脚本,RMXP1.03 “口”的问题

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
420 小时
注册时间
2011-3-13
帖子
251
跳转到指定楼层
1
发表于 2013-6-3 16:21:37 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
5星屑
本帖最后由 2000zs66rpg 于 2013-6-3 16:24 编辑

RUBY 代码复制
  1. #==============================================
  2. # 增加两个用来进行条件判断的临时变量
  3. #==============================================
  4.  
  5. # 脚本:MTV.load("歌词.lrc")
  6. #演奏BGM:童话
  7. #脚本:MTV.mtv_begin
  8. #注意:必须是LRC格式
  9. #停止:MTV.stop,关掉歌词。BGM用事件关就行了
  10. #==============================================
  11.  
  12. #设置文字颜色
  13. FONT_COLOR = Color.new(255,255,0,0) #这里指定RGB颜色
  14. FONT_SIZE = 28  #这个是字体的大小
  15. FONT_NAME = "楷体"
  16.  
  17. #==============================================
  18. # 增加两个用来进行条件判断的临时变量
  19. #==============================================
  20. class Game_Temp
  21.    attr_accessor :old_text
  22.    attr_accessor :refresh_times
  23. alias meanfree_initialize initialize
  24.   def initialize
  25.     meanfree_initialize
  26.     @old_text = ""
  27.     @refresh_times = 0
  28.   end
  29. end
  30.  
  31. module MTV  
  32. #===============================================================
  33. # 读取文件。文件相对地址:Audio/BGM
  34. # file_name:文件名;length:MTV长度,按照.1秒为单位记数
  35. #===============================================================
  36. def self.load(file_name,length = 0)
  37.   $mtv_time = []
  38.   $mtv_text = []
  39.   $game_system.mtv_length = length
  40.   #=============================================================
  41.   # 打开文件并且读取之
  42.   #=============================================================
  43.   file =  File.open("Audio/BGM/"+file_name)
  44.   #=============================================================
  45.   # 读取歌词
  46.   #=============================================================
  47.   for line in file.readlines
  48.     #===========================================================
  49.     # 转为UTF-8编码
  50.     #===========================================================
  51.     line = EasyConv.s2u(line)
  52.     #===========================================================
  53.     # 寻找本行歌词
  54.     #===========================================================
  55.     this_line_text = line[line.scan(/\]/).size*10,line.size]
  56.     #===========================================================
  57.     # 把读取的行分存成时间与文字
  58.     #===========================================================
  59.     for i in 0...line.scan(/\]/).size
  60.       temp_b = line[i*10+1,8]
  61.       temp_c = temp_b.split(/:/)[0]
  62.       mmsecond = 600 * temp_c.to_i
  63.       temp_c = temp_b.split(/:/)[1]
  64.       mmsecond += 10 * temp_c.to_f
  65.       $mtv_time.push(mmsecond.to_i)
  66.       $mtv_text.push(this_line_text)
  67.     end
  68.   end
  69.   file.close
  70. end
  71. #===============================================================
  72. # 开始MTV字幕
  73. #===============================================================
  74. def self.mtv_begin
  75.   $game_system.mtv_now = true
  76.   $game_system.mtv_begin_time = $sys_timer.now()
  77.   $lrc_text = ""
  78.   return
  79. end
  80. #===============================================================
  81. # 结束MTV字幕
  82. #===============================================================
  83. def self.stop
  84.   $game_system.mtv_now = false
  85.   return
  86. end
  87. #===============================================================
  88. # 测试MTV是否播放
  89. #===============================================================
  90. def self.mtv?
  91.   return $game_system.mtv_now
  92. end
  93. #===============================================================
  94. # 获取MTV字幕
  95. #===============================================================
  96. def self.new_text
  97.   if $game_system.mtv_now
  98.     #===========================================================
  99.     # 求出已经经过的时间
  100.     #===========================================================
  101.     nt = $sys_timer.now()
  102.     nt -= $game_system.mtv_begin_time
  103.     nt = nt.to_i
  104.     nt /= 100      
  105.     #===========================================================
  106.     # 制作循环
  107.     #===========================================================
  108.     if $game_system.mtv_length>0 and nt > $game_system.mtv_length
  109.       nt -= $game_system.mtv_length
  110.     end
  111.     #===========================================================
  112.     # 放出字幕
  113.     #===========================================================
  114.     for tm in 0...$mtv_time.size
  115.       if $mtv_time[tm] == nt
  116.         $lrc_text = $mtv_text[tm]
  117.         #=======================================
  118.         # 时间有限
  119.         $game_temp.old_text = $lrc_text
  120.         $game_temp.refresh_times += 1
  121.         # 面粉无敌
  122.         #=======================================
  123.         break
  124.       end
  125.     end
  126.   else
  127.     $lrc_text = ""
  128.   end
  129. end
  130. end
  131. # ------------------------------------------------------------------------
  132. # 高精度计时器 by FantasyDR
  133. # ------------------------------------------------------------------------
  134. # E-mail: [email][email protected][/email]
  135. # ------------------------------------------------------------------------
  136. # 2005.10.18
  137. # ------------------------------------------------------------------------
  138. # 该类已经被定义为全局变量 $sys_timer
  139. # 如果只需要精确到毫秒,请设置初始化参数为true
  140. # decimal属性设置返回时间值的小数位数。
  141. # ------------------------------------------------------------------------
  142. # 下面是一些有用的方法列表,调用时写:$sys_timer.方法名
  143. # 例如 $sys_timer.clear()
  144. # ------------------------------------------------------------------------
  145. # clear() :计时器清零
  146. # now() :获取当前经过的时间,单位毫秒
  147. # now_s() :获取当前经过的时间,单位秒
  148. # ------------------------------------------------------------------------
  149. class SystemTimer
  150. attr_accessor:decimal #小数位数设定,默认为3
  151.  
  152. def initialize(use_GetTime=false)
  153. # 初始化,根据系统选择不同精度计时器
  154. @qpFrequency = Win32API.new("kernel32","QueryPerformanceFrequency",'p','L')
  155. @qpCounter = Win32API.new("kernel32","QueryPerformanceCounter",'p','L')
  156. @tGetTime = Win32API.new("winmm","timeGetTime",'','L')
  157.  
  158. @decimal=3
  159. @perf_cnt=" " * 8
  160. @time_start=" " * 8
  161. @time_now=" " * 8
  162.  
  163. result = @qpFrequency.call(@perf_cnt)
  164.  
  165. if use_GetTime
  166. result = 0
  167. end
  168.  
  169. if result!=0
  170. @perf_flag=true
  171. else
  172. @perf_flag=false
  173. @perf_cnt=[1000,0].pack('LL')
  174. end
  175.  
  176. #设置时间比例因数
  177. @time_scale=@perf_cnt.unpack('LL')
  178. @time_scale[0] /= 1000.0
  179. @time_scale[1] /= 1000.0
  180.  
  181. #起始时间清零
  182. self.clear()
  183. end
  184.  
  185. #-=====================-#
  186. # 计时器清零
  187. #-=====================-#
  188. def clear()
  189. if @perf_flag
  190. @qpCounter.call(@time_start)
  191. else
  192. @time_start=[@tGetTime.call(),0].pack('LL')
  193. end
  194. end
  195.  
  196. #-==============================-#
  197. # 获取当前经过的时间,单位毫秒
  198. #-==============================-#
  199. def now()
  200. now_time = 0.0e1
  201. now_time += self.timer() - self.start()
  202. now_time /= self.scale()
  203. return self.debug(now_time)
  204. end
  205.  
  206. #-==============================-#
  207. # 获取当前经过的时间,单位秒
  208. #-==============================-#
  209. def now_s()
  210. now_time = 0.0e1
  211. now_time += self.timer() - self.start()
  212. now_time /= (self.scale()*1000)
  213. return self.debug(now_time)
  214. end
  215.  
  216. #-==============================-#
  217. # 帧错...
  218. #-==============================-#
  219. def debug(now_time)
  220. if @decimal>0
  221. now_time = (now_time * (10**@decimal)).floor/(10.0**@decimal)
  222. else
  223. now_time = now_time.floor
  224. end
  225. return now_time
  226.  
  227. #以下用于debug模式
  228. if now_time < 0
  229. p "Timer Wrong!! Clear...",now_time,\
  230. @perf_flag,@qpCounter,@tGetTime,
  231. @time_now.unpack('LL')[0],@time_now.unpack('LL')[1],
  232. @time_start.unpack('LL')[0],@time_start.unpack('LL')[1]
  233. self.clear()
  234. return 0.0
  235. else
  236. return now_time
  237. end
  238. end
  239.  
  240. #-=====================-#
  241. # 获取时间比例因数
  242. #-=====================-#
  243. def scale()
  244. return @time_scale[0]+\
  245. @time_scale[1]*0xffffffff
  246. end
  247.  
  248. #-=====================-#
  249. # 获取起始滴答数
  250. #-=====================-#
  251. def start()
  252. return @time_start.unpack('LL')[0]+\
  253. @time_start.unpack('LL')[1]*0xffffffff
  254. end
  255.  
  256. #-=====================-#
  257. # 获取当前的嘀哒数
  258. #-=====================-#
  259. def timer()
  260. if @perf_flag
  261. @qpCounter.call(@time_now)
  262. else
  263. @time_now=[@tGetTime.call(),0].pack('LL')
  264. end
  265. return @time_now.unpack('LL')[0]+\
  266. @time_now.unpack('LL')[1]*0xffffffff
  267. end
  268. end
  269. #-------------------------------------#
  270. # 初始化自身成一个全局变量
  271. #-------------------------------------#
  272. $sys_timer=SystemTimer.new()
  273. #-------------------------------------#
  274.  
  275. #==============================================================================
  276. # 仭 EasyConv module - Ver 0.90
  277. #------------------------------------------------------------------------------
  278. # Moonlight INN
  279. # [url]http://cgi.members.interq.or.jp/aquarius/rasetsu/[/url]
  280. # RaTTiE
  281. # [email][email protected][/email]
  282. #------------------------------------------------------------
  283. # EasyConv::s2u(text) : S-JIS -> UTF-8
  284. # EasyConv::u2s(text) : UTF-8 -> S-JIS
  285. #==============================================================================
  286. module EasyConv
  287. # API梡掕悢掕媊
  288. CP_ACP = 0
  289. CP_UTF8 = 65001
  290.  
  291. #--------------------------------------------------------------------------
  292. # 仠 S-JIS -> UTF-8
  293. #--------------------------------------------------------------------------
  294. def s2u(text)
  295. # API掕媊
  296. m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
  297. w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')
  298.  
  299. # S-JIS -> Unicode
  300. len = m2w.call(CP_ACP, 0, text, -1, nil, 0);
  301. buf = "\0" * (len*2)
  302. m2w.call(CP_ACP, 0, text, -1, buf, buf.size/2);
  303.  
  304. # Unicode -> UTF-8
  305. len = w2m.call(CP_UTF8, 0, buf, -1, nil, 0, nil, nil);
  306. ret = "\0" * len
  307. w2m.call(CP_UTF8, 0, buf, -1, ret, ret.size, nil, nil);
  308.  
  309. return ret
  310. end
  311. # module_function偲偟偰岞奐
  312. module_function :s2u
  313. #--------------------------------------------------------------------------
  314. # 仠 UTF-8 -> S-JIS
  315. #--------------------------------------------------------------------------
  316. def u2s(text)
  317. # API掕媊
  318. m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
  319. w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')
  320.  
  321. # UTF-8 -> Unicode
  322. len = m2w.call(CP_UTF8, 0, text, -1, nil, 0);
  323. buf = "\0" * (len*2)
  324. m2w.call(CP_UTF8, 0, text, -1, buf, buf.size/2);
  325.  
  326. # Unicode -> S-JIS
  327. len = w2m.call(CP_ACP, 0, buf, -1, nil, 0, nil, nil);
  328. ret = "\0" * len
  329. w2m.call(CP_ACP, 0, buf, -1, ret, ret.size, nil, nil);
  330.  
  331. return ret
  332. end
  333. # module_function偲偟偰岞奐
  334. module_function :u2s
  335. end
  336.  
  337.  
  338. #==============================================================================
  339. # ■ Game_System
  340. #------------------------------------------------------------------------------
  341. #  处理系统附属数据的类。也可执行诸如 BGM 管理之类的功能。本类的实例请参考
  342. # $game_system 。
  343. #==============================================================================
  344. class Game_System
  345. #--------------------------------------------------------------------------
  346. # ● 定义实例变量
  347. #--------------------------------------------------------------------------
  348. attr_accessor :mtv_begin_time
  349. attr_accessor :mtv_now
  350. attr_accessor :mtv_length
  351. #--------------------------------------------------------------------------
  352. # ● 初始化对像
  353. #--------------------------------------------------------------------------
  354. alias mtv_gamesystem_initialize initialize
  355. def initialize
  356.   mtv_gamesystem_initialize
  357.   @mtv_begin_time = $sys_timer.now()
  358.   @mtv_now = false
  359.   @mtv_length = 0
  360. end
  361. end  
  362.  
  363. #==============================================================================
  364. # ■ Scene_Map
  365. #------------------------------------------------------------------------------
  366. #  处理地图画面的类。
  367. #==============================================================================
  368. class Scene_Map
  369. #--------------------------------------------------------------------------
  370. # ● 刷新画面
  371. #--------------------------------------------------------------------------
  372. alias mtv_scenemap_update update
  373. def update
  374.   MTV.new_text
  375.   @mtv_window.refresh
  376.   mtv_scenemap_update
  377. end
  378. #--------------------------------------------------------------------------
  379. # ● 主处理
  380. #--------------------------------------------------------------------------
  381. alias mtv_scenemap_main main
  382. def main
  383.   @mtv_window = Window_MTV.new
  384.   mtv_scenemap_main
  385.   @mtv_window.dispose
  386. end
  387. #--------------------------------------------------------------------------
  388. # ● 调用战斗 (调整自动切换BGM)
  389. #--------------------------------------------------------------------------
  390. def call_battle
  391.   # 清除战斗调用标志
  392.   $game_temp.battle_calling = false
  393.   # 清除菜单调用标志
  394.   $game_temp.menu_calling = false
  395.   $game_temp.menu_beep = false
  396.   # 生成遇敌计数
  397.   $game_player.make_encounter_count
  398.   # 记忆地图 BGM 、停止 BGM
  399.   $game_temp.map_bgm = $game_system.playing_bgm
  400.   unless MTV.mtv?      
  401.     $game_system.bgm_play($game_system.battle_bgm)
  402.     # 演奏战斗开始 SE
  403.     $game_system.se_play($data_system.battle_start_se)
  404.   end
  405.   # 矫正主角姿势
  406.   $game_player.straighten
  407.   # 切换到战斗画面
  408.   $scene = Scene_Battle.new
  409. end
  410. end
  411.  
  412. #==============================================================================
  413. # ■ Scene_Battle
  414. #------------------------------------------------------------------------------
  415. #  处理战斗的类。
  416. #==============================================================================
  417.  
  418.  
  419. #==============================================================================
  420. # ■ Window_MTV
  421. #------------------------------------------------------------------------------
  422. #  显示MTV字幕的窗口。
  423. #==============================================================================
  424.  
  425. class Window_MTV < Window_Base
  426. #--------------------------------------------------------------------------
  427. # ● 初始化窗口
  428. #--------------------------------------------------------------------------
  429.   def initialize
  430.     super(0, 416, 640, 64)
  431.     self.contents = Bitmap.new(width - 32, height - 32)
  432.     $lrc_text = ""
  433.     self.z = 9999
  434.     #===========================
  435.     # 时间有限
  436.     @temp_text = ""
  437.     $game_temp.old_text = ""
  438.     # 面粉无敌
  439.     #===========================
  440.     refresh
  441.  
  442.   end
  443. #--------------------------------------------------------------------------
  444. # ● 刷新
  445. #--------------------------------------------------------------------------
  446.   def refresh(text = "")
  447.     #=================================================
  448.     # 时间有限
  449.     if $game_temp.in_battle
  450.       self.opacity = 120
  451.     else
  452.       self.opacity = 0
  453.     end
  454.     if $game_system.mtv_now == false or $lrc_text == ""
  455.       self.contents.clear
  456.       else
  457.     if $game_temp.refresh_times != 1
  458.       if $game_temp.old_text != @temp_text
  459.         self.contents.clear
  460.         self.contents.font.color = FONT_COLOR
  461.         self.contents.font.size = FONT_SIZE
  462.         self.contents.font.name = FONT_NAME
  463.         self.contents.draw_text(0, 0, 608, 32, $lrc_text, 1)   
  464.         self.contents.font.color = Color.new(255,255,255,255)
  465.         self.contents.draw_text(1, 1, 608, 32, $lrc_text, 1)
  466.         @temp_text = $lrc_text
  467.       end
  468.     else
  469.       self.contents.clear
  470.       self.contents.font.color = FONT_COLOR
  471.       self.contents.font.size = FONT_SIZE
  472.       self.contents.font.name = FONT_NAME
  473.       self.contents.draw_text(0, 0, 608, 32, $lrc_text, 1)   
  474.       self.contents.font.color = Color.new(255,255,255,255)
  475.       self.contents.draw_text(1, 1, 608, 32, $lrc_text, 1)
  476.       @temp_text = $lrc_text
  477.       end
  478.     end
  479.     # 面粉无敌
  480.     #==================================================
  481.   end
  482. end



以上的是MTV脚本,放在RMXP1.02版本没问题 但是在rmxp1.03版本中运行 每行最后会有"口",请高手修改下该脚本,使它完美支持rmxp1.03。然后发一个完整的脚本给我。谢谢啦

PS1.02和1.03哪个好啊 还有传说的1.04?

最佳答案

查看完整内容

既然已经回答了,大概解释下这个情况出现的原因,包括以前所谓的1.03(1.02?)不能用某个版本的FUKI对话框脚本,还一度说是 dll 引起的错误,不修正的话就无解了……其实就是个\n换行符和\000引起的惨案而已……逐字处理的时候略过这两个符号就好了。。。

Lv2.观梦者

梦石
0
星屑
260
在线时间
1373 小时
注册时间
2005-10-16
帖子
5113

贵宾

2
发表于 2013-6-3 16:21:38 | 只看该作者
既然已经回答了,大概解释下这个情况出现的原因,包括以前所谓的1.03(1.02?)不能用某个版本的FUKI对话框脚本,还一度说是 dll 引起的错误,不修正的话就无解了……其实就是个\n换行符和\000引起的惨案而已……逐字处理的时候略过这两个符号就好了。。。

点评

呵呵,对于高手来说确实赚的很容易,但是对于我就是个超级大难题啊 呵呵 还是值得的。  发表于 2013-6-5 14:21
我只个搬答案的
叔叔我已经当爹了~
婚后闪人了……
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
47
在线时间
976 小时
注册时间
2011-4-30
帖子
860
3
发表于 2013-6-5 12:57:21 | 只看该作者
111行~125行修改为:
    for tm in 0...$mtv_time.size
      if $mtv_time[tm] == nt
        text = $mtv_text[tm].clone
        text2 = ""
        while ((c = text.slice!(/./m)) != nil)
          if c == "\000" or c == "\n"
            c = ""
          end
          text2 += c
        end
        #=======================================
        # 时间有限
        $game_temp.old_text = $lrc_text = text2
        $game_temp.refresh_times += 1
        # 面粉无敌
        #=======================================
        break
      end
    end

点评

没事,我转给他。  发表于 2013-6-5 22:06
完了 我最佳答案设错了? 我把羞射当成亿万星辰了,没发现羞射  发表于 2013-6-5 14:29
这也赚的太轻松了…… =。=  发表于 2013-6-5 13:46

评分

参与人数 1星屑 +45 收起 理由
2000zs66rpg + 45 认可答案

查看全部评分

湿滑落式骑!
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
420 小时
注册时间
2011-3-13
帖子
251
4
 楼主| 发表于 2013-6-5 14:27:15 | 只看该作者
亿万星辰 发表于 2013-6-5 13:49
既然已经回答了,大概解释下这个情况出现的原因,包括以前所谓的1.03(1.02?)不能用某个版本的FUKI对话框 ...

对了,我发现正在播放的时候歌词和歌曲很同步。
游戏切出去之后,过一会再切回去。发现播放的歌词是切出去时的文字,但是随着歌曲的播放,下一句歌词又会与歌曲同步。
能不能做个改进,就是切回去的时候已经就是同步的,实现歌词始终与歌曲同步呢?
呵呵 我有点追求完美了。{:2_287:}
PS:这属于另一个问题了 要不我再开一贴?
回复

使用道具 举报

Lv2.观梦者

梦石
0
星屑
260
在线时间
1373 小时
注册时间
2005-10-16
帖子
5113

贵宾

5
发表于 2013-6-5 22:07:37 | 只看该作者
2000zs66rpg 发表于 2013-6-5 14:27
对了,我发现正在播放的时候歌词和歌曲很同步。
游戏切出去之后,过一会再切回去。发现播放的歌词是切出 ...

可以考虑挂个真后台运行。。。

点评

哈哈 搜索了下 下载了真后台脚本 完美解决了 谢谢啦  发表于 2013-6-5 23:13

评分

参与人数 1星屑 +40 收起 理由
2000zs66rpg + 40 塞糖

查看全部评分

我只个搬答案的
叔叔我已经当爹了~
婚后闪人了……
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-29 23:01

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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