Project1

标题: 事件中的“禁止存档”失效了? [打印本页]

作者: zl90349166    时间: 2008-10-17 17:38
提示: 作者被禁止或删除 内容自动屏蔽
作者: zl90349166    时间: 2008-10-17 20:21
提示: 作者被禁止或删除 内容自动屏蔽
作者: 劍之飛龍☆    时间: 2008-10-17 21:11
修改完毕:
用此脚本替换原来的截图存档
  1. #===============================================================================

  2. BBS_66RPG_DIR = "Save/"  # 储存文件夹名,请制作游戏时自行建立此文件夹

  3. # 若想使用自定义背景图,脚本62行的井号去掉,并放置一张相应图形。

  4. # 在你的Scene_Title中找到这一段(如果使用其他插件脚本,在插件中找):
  5. #    for i in 0..3
  6. #      if FileTest.exist?("Save#{i+1}.rxdata")
  7. # 请自行把0..3改为0..最大进度号,比如0..9
  8. # "Save#{i+1}.rxdata" 改为"Save/Save#{i}.rxdata"

  9. # 增加进度的方法:138,258行,继续添加。你也可以改“进度X”为“回忆X”或者“红/绿/蓝笔记本”

  10. # 注意:这个脚本是兼容亿万星辰的“轩辕剑菜单”的版本,不过用在其他场合貌似也不会出错
  11. #   使用时把这个脚本放在“轩辕剑菜单”脚本的下方,也就是更靠近Main的位置
  12. # 兼容处理:叶子
  13. #===============================================================================
  14. module Screen  
  15. @screen = Win32API.new 'screenshot', 'Screenshot', %w(l l l l p l l), ''
  16. @readini = Win32API.new 'kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l'
  17. @findwindow = Win32API.new 'user32', 'FindWindowA', %w(p p), 'l'
  18. module_function
  19. #-----------------------------------------------------------------------------
  20. # here comes the stuff...
  21. # i add here the stuff for automatic change of the number for the screenshot
  22. # so it wont overrite the old one...
  23. # if you want to change so stuff change them in this line below
  24. # or you can change them in your command line... like
  25. # Screen::shot("screenshot", 2)
  26. # this change the name and the type of the screenshot
  27. # (0 = bmp, 1 = jpg and 2 = png)
  28. # ----------------------------------------------------------------------------
  29. def shot(file = "shot", typ = 1)
  30.   # to add the right extension...
  31.   if typ == 0
  32.     typname = ".bmp"
  33.   elsif typ == 1
  34.     typname = ".jpg"
  35.   elsif typ == 2
  36.     typname = ".png"
  37.   end   
  38.   file_index = 0   
  39.   dir = "Save/"   
  40.   # make the filename....
  41.   file_name = dir + file.to_s + typname.to_s   
  42.   if $shot_guodu == 1
  43.     file_name = "Graphics/Pictures/sys_screen.jpg"
  44.     $shot_guodu = 0
  45.   end
  46.   # make the screenshot.... Attention dont change anything from here on....
  47.   @screen.call(0,0,640,480,file_name,handel,typ)
  48. end
  49. # find the game window...
  50. def handel
  51.   game_name = "\0" * 256
  52.   @readini.call('Game','Title','',game_name,255,".\\Game.ini")
  53.   game_name.delete!("\0")
  54.   return @findwindow.call('RGSS Player',game_name)
  55. end
  56. end

  57. class Window_File < Window_Base
  58. attr_accessor :index
  59. def initialize(index = 0)
  60.   @backsp = Sprite.new
  61.   @backsp.z = 99
  62.   super(160,0,480,480)
  63.   #这行可以不用
  64.   self.contents = Bitmap.new(width - 32, height - 32)
  65.   @index = index
  66.   #这里我要说明一句,之所以用sprite是为了放缩图片
  67.   @sprite = Sprite.new
  68.   @sprite.visible = false
  69.   @sprite.z = 100
  70.   @sp_ch = []
  71.   @sp_ch[0] = Sprite.new
  72.   refresh
  73. end
  74. def refresh
  75.   self.contents.clear
  76.   for i in @sp_ch
  77.     i.visible = false
  78.   end
  79.   @sprite.visible = false
  80.   if FileTest.exist?(BBS_66RPG_DIR+"Save#{@index}.rxdata")
  81.     @sprite.visible = true
  82.     if FileTest.exist?(BBS_66RPG_DIR+"Save#{@index}.jpg")
  83.       @sprite.bitmap = Bitmap.new(BBS_66RPG_DIR+"Save#{@index}.jpg")
  84.     else
  85.       self.contents.draw_text(32,64,400,32,"截图似乎有点问题……您搞什么了您?")
  86.     end
  87.     @sprite.x = 176
  88.     @sprite.y = 16
  89.     @sprite.zoom_x = 0.7
  90.     @sprite.zoom_y = 0.7
  91.     file = File.open(BBS_66RPG_DIR+"Save#{@index}.rxdata", "r")
  92.     @time_stamp = file.mtime
  93.     @gold = Marshal.load(file)
  94.     @save_map_name = Marshal.load(file)
  95.     @characters = Marshal.load(file)
  96.     @frame_count = Marshal.load(file)
  97.     @game_system = Marshal.load(file)
  98.     @game_switches = Marshal.load(file)
  99.     @game_variables = Marshal.load(file)
  100.     @total_sec = @frame_count / Graphics.frame_rate
  101.     file.close
  102.     for i in [email protected]
  103.       @sp_ch[i] = Sprite.new
  104.       @sp_ch[i].visible = true
  105.       @sp_ch[i].bitmap = Bitmap.new("Graphics/system/menu/headp/" + @characters[i][3] + "_save.png")
  106.       @sp_ch[i].x = 180 + i*42      
  107.       @sp_ch[i].y = 460 - @sp_ch[i].bitmap.height
  108.       @sp_ch[i].z = 101
  109.     end
  110.     # 描绘游戏时间
  111.     hour = @total_sec / 60 / 60
  112.     min = @total_sec / 60 % 60
  113.     sec = @total_sec % 60
  114.     time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
  115.     self.contents.font.color = normal_color
  116.     self.contents.draw_text(4, 390, 420 + 16, 32, time_string, 2)
  117.     # 描绘时间标记
  118.     self.contents.font.color = normal_color
  119.     time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
  120.     self.contents.draw_text(4, 420, 420 + 16, 32, time_string, 2)
  121.     self.contents.draw_text(4, 420 - 64, 420 + 16, 32, @save_map_name, 2)
  122.     self.contents.draw_text(4, 4, 420 + 16, 32, @gold, 2)
  123.     src_rect = Rect.new(0,0,16,16)
  124.     bitmap = Bitmap.new("Graphics/system/menu/back/money.png")
  125.     self.contents.blt(420 + 16 - @gold.size * 16, 4 + 8, bitmap, src_rect)
  126.   else
  127.     self.contents.draw_text(32,32,420 + 16,32,"空白记忆")
  128.   end
  129. end
  130. def dispose
  131.   super
  132.   @sprite.dispose
  133.   @backsp.dispose
  134.   for i in @sp_ch
  135.     i.dispose
  136.   end
  137. end
  138. end


  139. class Scene_Save
  140. def main
  141.   @command_window = Window_Command.new(160,["回忆 1","回忆 2","回忆 3","回忆 4","回忆 5","回忆 6","回忆 7","回忆 8","回忆 9","回忆10","回忆11","回忆12","回忆13","回忆14"])
  142.   @command_window.y = 0
  143.   @command_window.index = $game_temp.last_file_index
  144.   @content_window = Window_File.new($game_temp.last_file_index)
  145.   # 执行过渡
  146.   Graphics.transition
  147.   # 主循环
  148.   loop do
  149.     # 刷新游戏画面
  150.     Graphics.update
  151.     # 刷新输入信息
  152.     Input.update
  153.     # 刷新画面
  154.     update
  155.     # 如果画面被切换的话就中断循环
  156.     if $scene != self
  157.       break
  158.     end
  159.   end
  160.   # 准备过渡
  161.   Graphics.freeze
  162.   @command_window.dispose
  163.   @content_window.dispose
  164. end
  165. def update
  166.   @command_window.update   
  167.   if @command_window.index != @content_window.index
  168.     @content_window.index = @command_window.index
  169.     @content_window.refresh
  170.   end   
  171.   #——————下面这一部分是原装脚本——————#
  172.   if Input.trigger?(Input::B)  
  173.     $game_system.se_play($data_system.cancel_se)
  174.     if $game_temp.save_calling
  175.       $game_temp.save_calling = false
  176.       $scene = Scene_Map.new
  177.       return
  178.     end
  179.     $scene = Scene_Menu.new(4)
  180.   end   
  181.   #———————————————————————#   
  182.   if Input.trigger?(Input::C)
  183.    # 禁止存档的情况下
  184.         if $game_system.save_disabled
  185.           # 演奏冻结 SE
  186.           $game_system.se_play($data_system.buzzer_se)
  187.           return
  188.         else
  189.         # 演奏存档 SE
  190.     $game_system.se_play($data_system.save_se)
  191.     # 写入存档数据
  192.     file = File.open(BBS_66RPG_DIR+"Save#{@command_window.index}.rxdata", "wb")
  193.     write_save_data(file)
  194.     if FileTest.exist?(BBS_66RPG_DIR+"shot.jpg")
  195.       File.rename(BBS_66RPG_DIR+"shot.jpg", BBS_66RPG_DIR+"Save#{@command_window.index}.jpg")
  196.     end
  197.     file.close
  198.     $game_temp.last_file_index = @command_window.index
  199.     # 如果被事件调用
  200.     if $game_temp.save_calling
  201.       # 清除存档调用标志
  202.       $game_temp.save_calling = false
  203.       # 切换到地图画面
  204.       $scene = Scene_Map.new
  205.       return
  206.     end
  207.     # 切换到菜单画面
  208.     $scene = Scene_Map.new
  209.   end
  210.   #———————————————————————#
  211. end
  212.         end
  213.    
  214. #--------------------------------------------------------------------------
  215. # ● 写入存档数据
  216. #     file : 写入用文件对像 (已经打开)
  217. #--------------------------------------------------------------------------
  218. def write_save_data(file)
  219.   # 生成描绘存档文件用的角色图形
  220.   characters = []
  221.   for i in 0...$game_party.actors.size
  222.     actor = $game_party.actors[i]
  223.     characters.push([actor.character_name, actor.character_hue, actor.id, actor.battler_name, actor.battler_hue])
  224.   end
  225.   #####################################################################
  226.   id = $game_map.map_id
  227.   name = $data_mapinfos[id].name
  228.   if name.include?("★")
  229.     @save_map_name = name.split(/★/)[0]
  230.   else
  231.     @save_map_name = name
  232.   end
  233.   Marshal.dump($game_party.gold.to_s, file)
  234.   Marshal.dump(@save_map_name, file)
  235.   #####################################################################
  236.   # 写入描绘存档文件用的角色数据
  237.   Marshal.dump(characters, file)
  238.   # 写入测量游戏时间用画面计数
  239.   Marshal.dump(Graphics.frame_count, file)
  240.   # 增加 1 次存档次数
  241.   $game_system.save_count += 1
  242.   # 保存魔法编号
  243.   # (将编辑器保存的值以随机值替换)
  244.   $game_system.magic_number = $data_system.magic_number
  245.   # 写入各种游戏对像
  246.   Marshal.dump($game_system, file)
  247.   Marshal.dump($game_switches, file)
  248.   Marshal.dump($game_variables, file)
  249.   Marshal.dump($game_self_switches, file)
  250.   Marshal.dump($game_screen, file)
  251.   Marshal.dump($game_actors, file)
  252.   Marshal.dump($game_party, file)
  253.   Marshal.dump($game_troop, file)
  254.   Marshal.dump($game_map, file)
  255.   Marshal.dump($game_player, file)
  256. end
  257. end


  258. class Scene_Load
  259. def initialize(force = false)
  260.   @in_game = force
  261.   # 再生成临时对像
  262.   $game_temp = Game_Temp.new
  263.   # 选择存档时间最新的文件
  264.   $game_temp.last_file_index = 0
  265.   latest_time = Time.at(0)
  266.   for i in 0..6
  267.     filename = BBS_66RPG_DIR+"Save#{i}.rxdata"
  268.     if FileTest.exist?(filename)
  269.       file = File.open(filename, "r")
  270.       if file.mtime > latest_time
  271.         latest_time = file.mtime
  272.         $game_temp.last_file_index = i
  273.       end
  274.       file.close
  275.     end
  276.   end
  277. end  
  278. def main
  279.   @command_window = Window_Command.new(160,["回忆 1","回忆 2","回忆 3","回忆 4","回忆 5","回忆 6","回忆 7","回忆 8","回忆 9","回忆10","回忆11","回忆12","回忆13","回忆14"])
  280.   @command_window.y = 0
  281.   @command_window.index = $game_temp.last_file_index
  282.   @content_window = Window_File.new($game_temp.last_file_index)
  283.   # 执行过渡
  284.   Graphics.transition
  285.   # 主循环
  286.   loop do
  287.     # 刷新游戏画面
  288.     Graphics.update
  289.     # 刷新输入信息
  290.     Input.update
  291.     # 刷新画面
  292.     update
  293.     # 如果画面被切换的话就中断循环
  294.     if $scene != self
  295.       break
  296.     end
  297.   end
  298.   # 准备过渡
  299.   Graphics.freeze
  300.   @command_window.dispose
  301.   @content_window.dispose
  302. end
  303. def update
  304.   @command_window.update   
  305.   if @command_window.index != @content_window.index
  306.     @content_window.index = @command_window.index
  307.     @content_window.refresh
  308.   end   
  309.   #——————下面这一部分是原装脚本——————#
  310.   if Input.trigger?(Input::B)  
  311.   # 演奏取消 SE
  312.   $game_system.se_play($data_system.cancel_se)
  313.    if @in_game
  314.      $scene = $scene = Scene_Menu.new(4)
  315.    else
  316.      # 切换到标题画面
  317.      $scene = Scene_Title.new
  318.    end
  319.   end   
  320.   #———————————————————————#   
  321.   if Input.trigger?(Input::C)
  322.     # 文件不存在的情况下
  323.     unless FileTest.exist?(BBS_66RPG_DIR+"Save#{@command_window.index}.rxdata")
  324.       # 演奏冻结 SE
  325.       $game_system.se_play($data_system.buzzer_se)
  326.       return
  327.     end
  328.     if $piantou == 1
  329.       for i in 1..3
  330.         $menupicback[i].bitmap.dispose
  331.       end
  332.     end
  333.     # 演奏读档 SE
  334.     $game_system.se_play($data_system.load_se)
  335.     # 写入存档数据
  336.     file = File.open(BBS_66RPG_DIR+"Save#{@command_window.index}.rxdata", "rb")
  337.     read_save_data(file)
  338.     file.close
  339.     # 还原 BGM、BGS
  340.     $game_system.bgm_play($game_system.playing_bgm)
  341.     $game_system.bgs_play($game_system.playing_bgs)
  342.     # 刷新地图 (执行并行事件)
  343.     $game_map.update
  344.     # 切换到地图画面
  345.     $scene = Scene_Map.new
  346.   end
  347.   #———————————————————————#
  348. end
  349. #--------------------------------------------------------------------------
  350. # ● 写入存档数据
  351. #     file : 写入用文件对像 (已经打开)
  352. #--------------------------------------------------------------------------
  353. def read_save_data(file)
  354.   @gold = Marshal.load(file)
  355.   @save_map_name = Marshal.load(file)
  356.   # 读取描绘存档文件用的角色数据
  357.   characters = Marshal.load(file)
  358.   # 读取测量游戏时间用画面计数
  359.   Graphics.frame_count = Marshal.load(file)
  360.   # 读取各种游戏对像
  361.   $game_system        = Marshal.load(file)
  362.   $game_switches      = Marshal.load(file)
  363.   $game_variables     = Marshal.load(file)
  364.   $game_self_switches = Marshal.load(file)
  365.   $game_screen        = Marshal.load(file)
  366.   $game_actors        = Marshal.load(file)
  367.   $game_party         = Marshal.load(file)
  368.   $game_troop         = Marshal.load(file)
  369.   $game_map           = Marshal.load(file)
  370.   $game_player        = Marshal.load(file)
  371.   # 魔法编号与保存时有差异的情况下
  372.   # (加入编辑器的编辑过的数据)
  373.   if $game_system.magic_number != $data_system.magic_number
  374.     # 重新装载地图
  375.     $game_map.setup($game_map.map_id)
  376.     $game_player.center($game_player.x, $game_player.y)
  377.   end
  378.   # 刷新同伴成员
  379.   $game_party.refresh
  380. end
  381. end

  382. class Scene_Menu
  383. alias bbs_66rpg_shotsave_main main
  384. def main
  385.   if @menu_index == 0
  386.     Screen::shot
  387.   end   
  388.   bbs_66rpg_shotsave_main
  389. end
  390. end

  391. class Interpreter
  392. #--------------------------------------------------------------------------
  393. # ● 调用存档画面
  394. #--------------------------------------------------------------------------
  395. def command_352
  396.   # 设置战斗中断标志
  397.   $game_temp.battle_abort = true
  398.   # 设置调用存档标志
  399.   $game_temp.save_calling = true
  400.   # 推进索引
  401.   @index += 1
  402.   # 结束
  403.   Screen::shot
  404.   return false
  405. end
  406. end
复制代码
[LINE]1,#dddddd[/LINE]系统信息:本贴由本区版主认可为正确答案,66RPG感谢您的热情解答~




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1