查看: 4887|回复: 9

[RMVA发布] VA rtp提取脚本

[复制链接]
梦石
2
星屑
5550
在线时间
2566 小时
注册时间
2012-2-9
回帖
947

开拓者

发表于 2016-7-26 19:59:34 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 garfeng 于 2016-8-1 12:13 编辑

怀疑这个脚本之前有人写过,但找不到了。
自己动手吧。

因为ace的rtp有200M,全加进去太大,手动加又很麻烦。

这个脚本可以在游戏运行时,把用到的,却不存在的BGM,图片移动到游戏自己的目录下。

推荐在游戏制作整个过程中,都使用本脚本,保证每个角落要用到的图片和bgm都移过去了。
在发布前将本脚本删除。

[pre lang="ruby"]
#ACE rtp提取工具,by garfeng
#只能提取bgm,和图片
#请把原始rtp复制一份使用,不要使用原始的rtp路径
#因为是移动文件,而非复制。



$rootDir = "../rtp/"

def mvBgm(bgm)
  name = bgm.name
  p name
  path = "Audio/BGM/" + name + ".ogg"
  exist = File.exist?(path)
  if !exist
    ori = $rootDir + path
    if File.exist?(ori)
      p ori
      File.rename(ori,path)
    end
  end
end

def mvImg(img)
  path1 = img+".png"
  path2 = img+".jpg"
  exist = File.exist?(path1) || File.exist?(path2)
  if !exist
    ori1 = $rootDir + path1
    ori2 = $rootDir + path2
    if File.exist?(ori1)
      File.rename(ori1,path1)
    elsif File.exist?(ori2)
      file.rename(ori2,path2)
    end
  end
end


module Cache

  def self.normal_bitmap(path)
    mvImg(path)
    @cache[path] = Bitmap.new(path) unless include?(path)
    @cache[path]
  end

end



class Game_Map

  def autoplay
    if @map.autoplay_bgm
      mvBgm(@map.bgm)
    end
    @map.bgm.play if @map.autoplay_bgm
    @map.bgs.play if @map.autoplay_bgs
  end

end


module BattleManager

  def self.play_battle_bgm
    mvBgm($game_system.battle_bgm)
    $game_system.battle_bgm.play
    RPG::BGS.stop
  end

end

class Game_Vehicle < Game_Character

  def get_on
    @driving = true
    @walk_anime = true
    @step_anime = true
    @walking_bgm = RPG::BGM.last
    mvBgm(system_vehicle.bgm)
    system_vehicle.bgm.play
  end

  def get_off
    @driving = false
    @walk_anime = false
    @step_anime = false
    @direction = 4
    mvBgm(@walking_bgm)
    @walking_bgm.play
  end

end

class Scene_Title < Scene_Base

  def play_title_music
    mvBgm($data_system.title_bgm)
    $data_system.title_bgm.play
    RPG::BGS.stop
    RPG::ME.stop
  end

end

class Game_Interpreter

  def command_241
    mvBgm(@params[0])
    @params[0].play
  end

end[/pre]

点评

复制可以用 IO.copy_stream,参考 ruby 标准库的 FileUtils  发表于 2016-11-19 10:56

评分

参与人数 1赞 +1 收起 理由
Kim_Shyuen + 1 塞糖

查看全部评分

梦石
0
星屑
2008
在线时间
47 小时
注册时间
2016-6-7
回帖
3
发表于 2016-7-26 20:40:16 | 显示全部楼层
好东西。为什么不能直接复制呢。

点评

因为不知道ruby怎么复制文件……【归根结底是懒= - =】  发表于 2016-7-26 20:45
回复

使用道具 举报

梦石
0
星屑
2008
在线时间
47 小时
注册时间
2016-6-7
回帖
3
发表于 2016-7-26 21:46:36 | 显示全部楼层
本帖最后由 WQ3465802 于 2016-11-18 23:25 编辑

试了一下调用API可以实现复制文件


  1. $rootDir = "../rtp/" #设置rtp的位置
  2. def fileCopy(原文件,目标,覆盖=1)
  3.   sCopy = Win32API.new('kernel32', 'CopyFileA',%(p p l), 'l')
  4.   sCopy.call(原文件,目标,覆盖)
  5. end

  6. def mvBgm(bgm)
  7.   name = bgm.name
  8.   p name
  9.   path = "Audio/BGM/" + name + ".ogg"
  10.   exist = File.exist?(path)
  11.   if !exist
  12.     ori = $rootDir + path
  13.     if File.exist?(ori)
  14.       fileCopy(ori,path)
  15.     end
  16.   end
  17. end

  18. def mvImg(img)
  19.   path1 = img+".png"
  20.   path2 = img+".jpg"
  21.   exist = File.exist?(path1) || File.exist?(path2)
  22.   if !exist
  23.     ori1 = $rootDir + path1
  24.     ori2 = $rootDir + path2
  25.     if File.exist?(ori1)
  26.       fileCopy(ori1,path1)
  27.     elsif File.exist?(ori2)
  28.       fileCopy(ori2,path2)
  29.     end
  30.   end
  31. end


  32. module Cache

  33.   def self.normal_bitmap(path)
  34.     mvImg(path)
  35.     @cache[path] = Bitmap.new(path) unless include?(path)
  36.     @cache[path]
  37.   end

  38. end



  39. class Game_Map

  40.   def autoplay
  41.     if @map.autoplay_bgm
  42.       mvBgm(@map.bgm)
  43.     end
  44.     @map.bgm.play if @map.autoplay_bgm
  45.     @map.bgs.play if @map.autoplay_bgs
  46.   end

  47. end


  48. module BattleManager

  49.   def self.play_battle_bgm
  50.     mvBgm($game_system.battle_bgm)
  51.     $game_system.battle_bgm.play
  52.     RPG::BGS.stop
  53.   end

  54. end

  55. class Game_Vehicle < Game_Character

  56.   def get_on
  57.     @driving = true
  58.     @walk_anime = true
  59.     @step_anime = true
  60.     @walking_bgm = RPG::BGM.last
  61.     mvBgm(system_vehicle.bgm)
  62.     system_vehicle.bgm.play
  63.   end

  64.   def get_off
  65.     @driving = false
  66.     @walk_anime = false
  67.     @step_anime = false
  68.     @direction = 4
  69.     mvBgm(@walking_bgm)
  70.     @walking_bgm.play
  71.   end

  72. end

  73. class Scene_Title < Scene_Base

  74.   def play_title_music
  75.     mvBgm($data_system.title_bgm)
  76.     $data_system.title_bgm.play
  77.     RPG::BGS.stop
  78.     RPG::ME.stop
  79.   end

  80. end

  81. class Game_Interpreter

  82.   def command_241
  83.     mvBgm(@params[0])
  84.     @params[0].play
  85.   end

  86. end
复制代码

点评

或者我修改下发到一楼?可以吗?  发表于 2016-8-1 15:14
你好,108行开始我新加了一段,是事件bgm,我之前弄掉了……你这边需要重新加上吗?  发表于 2016-8-1 12:14

评分

参与人数 1星屑 +100 收起 理由
garfeng + 100 非常感谢!

查看全部评分

回复

使用道具 举报

梦石
0
星屑
2008
在线时间
47 小时
注册时间
2016-6-7
回帖
3
发表于 2016-11-18 23:31:19 | 显示全部楼层
本帖最后由 WQ3465802 于 2016-11-18 23:35 编辑

本来就是你的代码。有什么更新的,你就修改发布吧,你看着办吧


(我几乎不来论坛,也就找游戏玩的时候才来看看。也不会做游戏,在论坛也就回复过2次,连这次3次)

点评

好的,谢谢~  发表于 2016-11-19 09:57
回复

使用道具 举报

梦石
0
星屑
132
在线时间
20 小时
注册时间
2023-8-5
回帖
9
发表于 2023-9-11 11:01:50 | 显示全部楼层
666666666666666
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部