赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 1012 |
最后登录 | 2018-10-28 |
在线时间 | 5 小时 |
Lv1.梦旅人 神之瞳
- 梦石
- 0
- 星屑
- 60
- 在线时间
- 5 小时
- 注册时间
- 2009-7-5
- 帖子
- 314
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 上帝的眼睛 于 2010-6-20 10:43 编辑
============================================
============================================
●仿 大航海时代 公正存档●
============================================
============================================
说明:
1、公正存档的作用是控制使用者无法使用S\L大
法,即保存为公正存档后必须退出游戏,退出游
戏前必须保存公正存档。如果游戏结束则自动取
消公正存档记号。
2、该脚本修改了exit方法,所以右上角的红色退
出按钮作用被修改。在以下场景且为公正进
度的存档点击该按钮会提示是否保存。
Map Menu
3、在游戏中如果像判定是否是公正存档请使用以
下脚本:$game_system.fair == -1
具体请参考范例中的艾斯迪儿事件
4、范例中1号存档是公正存档,2号存档是非公正
存档。
============================================
作用:
可以限制游戏者不得通过回档来作弊,对于公正
存档的玩家,可以有隐藏结局等奖励,具体请参
考大航海时代4+
============================================
范例下载:右击 目标另存为下载
紧急差错:349行出错,请修改为 if $scene.is_a?(Scene_Map) || $scene.is_a?(Scene_Menu)
脚本内容- #==============================================================================
- # ■ Scene_SaveE
- #------------------------------------------------------------------------------
- # 处理存档画面的类。
- #==============================================================================
- class Scene_SaveE < Scene_File
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize(mode = 0)
- super("要保存到这个文件吗?")
- @mode = mode
- end
- #--------------------------------------------------------------------------
- # ● 确定时的处理
- #--------------------------------------------------------------------------
- def on_decision(filename)
- # 演奏存档 SE
- $game_system.se_play($data_system.save_se)
- if @choose_window.active || $game_system.fair == 0
- @choose_window.active = false
- @choose_window.visible = false
- if @choose_window.index == 0 && $game_system.fair == -1
- $game_system.fair = 1
- else
- $game_system.fair = 0
- end
- # 写入存档数据
- file = File.open(filename, "wb")
- write_save_data(file)
- file.close
- $scene = nil if @mode == 0
- $scene = Scene_Title.new if @mode == 1
- else
- @help_window.set_text("是否存储为公正存档?")
- @choose_window.active = true
- @choose_window.visible = true
- end
- end
- #--------------------------------------------------------------------------
- # ● 取消时的处理
- #--------------------------------------------------------------------------
- def on_cancel
- # 演奏取消 SE
- unless @choose_window.active
- $game_system.se_play($data_system.cancel_se)
- $scene = Scene_Exit.new
- else
- @choose_window.active = false
- @choose_window.visible = false
- @help_window.set_text("要保存到这个文件吗?")
- end
- end
- #--------------------------------------------------------------------------
- # ● 写入存档数据
- # file : 写入用文件对像 (已经打开)
- #--------------------------------------------------------------------------
- def write_save_data(file)
- # 生成描绘存档文件用的角色图形
- characters = []
- for i in 0...$game_party.actors.size
- actor = $game_party.actors[i]
- characters.push([actor.character_name, actor.character_hue])
- end
- # 写入描绘存档文件用的角色数据
- Marshal.dump(characters, file)
- # 写入测量游戏时间用画面计数
- Marshal.dump(Graphics.frame_count, file)
- # 增加 1 次存档次数
- $game_system.save_count += 1
- # 保存魔法编号
- # (将编辑器保存的值以随机值替换)
- $game_system.magic_number = $data_system.magic_number
- # 写入各种游戏对像
- Marshal.dump($game_system, file)
- Marshal.dump($game_switches, file)
- Marshal.dump($game_variables, file)
- Marshal.dump($game_self_switches, file)
- Marshal.dump($game_screen, file)
- Marshal.dump($game_actors, file)
- Marshal.dump($game_party, file)
- Marshal.dump($game_troop, file)
- Marshal.dump($game_map, file)
- Marshal.dump($game_player, file)
- end
- end
- class Game_System
- #attr :save_id,true
- attr :fair,true
- alias ini initialize
- def initialize
- #@save_id = 0
- @fair = -1
- ini
- end
- end
- class Window_SaveFile < Window_Base
- def refresh
- self.contents.clear
- # 描绘文件编号
- self.contents.font.color = normal_color
- name = "文件 #{@file_index + 1}"
- self.contents.draw_text(4, 0, 600, 32, name)
- @name_width = contents.text_size(name).width
- # 存档文件存在的情况下
- if @file_exist
- # 描绘角色
- for i in [url=mailto:[email protected]][email protected][/url]
- bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
- cw = bitmap.rect.width / 4
- ch = bitmap.rect.height / 4
- src_rect = Rect.new(0, 0, cw, ch)
- x = 300 - @characters.size * 32 + i * 64 - cw / 2
- self.contents.blt(x, 68 - ch, bitmap, src_rect)
- end
- # 描绘游戏时间
- hour = @total_sec / 60 / 60
- min = @total_sec / 60 % 60
- sec = @total_sec % 60
- time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
- self.contents.font.color = normal_color
- self.contents.draw_text(4, 8, 600, 32, time_string, 2)
- # 描绘时间标记
- self.contents.font.color = normal_color
- time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
- self.contents.draw_text(4, 40, 600, 32, time_string, 2)
- if @game_system.fair == 1
- self.contents.font.color = system_color
- self.contents.draw_text(4, 8, 600-24*4, 32, "公正进度",2)
- end
- end
- end
- end
- class Scene_Load < Scene_File
- alias od on_decision
- def on_decision(filename)
- od(filename)
- # $game_system.save_id = filename
- $game_system.fair = 0 if $game_system.fair == -1
- $game_system.fair = -1 if $game_system.fair == 1
- file = File.open(filename, "wb") if FileTest.exist?(filename)
- write_save_data(file) if FileTest.exist?(filename)
- file.close if FileTest.exist?(filename)
- end
- end
- class Scene_Save < Scene_File
- def on_decision(filename)
- # 演奏存档 SE
- $game_system.se_play($data_system.save_se)
- if @choose_window.active || $game_system.fair == 0
- @choose_window.active = false
- @choose_window.visible = false
- if @choose_window.index == 0 && $game_system.fair != 0
- $game_system.fair = 1
- else
- $game_system.fair = 0
- end
- # 写入存档数据
- file = File.open(filename, "wb")
- write_save_data(file)
- file.close
- # 如果被事件调用
- # 切换到菜单画面
- if $game_system.fair == 0
- if $game_temp.save_calling
- # 清除存档调用标志
- $game_temp.save_calling = false
- # 切换到地图画面
- $scene = Scene_Map.new
- return
- end
- $scene = Scene_Menu.new(4)
- else
- $scene = nil
- end
- else
- @help_window.set_text("是否存储为公正存档?")
- @choose_window.active = true
- @choose_window.visible = true
- end
- end
- #--------------------------------------------------------------------------
- # ● 取消时的处理
- #--------------------------------------------------------------------------
- def on_cancel
- # 演奏取消 SE
- unless @choose_window.active
- $game_system.se_play($data_system.cancel_se)
- # 如果被事件调用
- if $game_temp.save_calling
- # 清除存档调用标志
- $game_temp.save_calling = false
- # 切换到地图画面
- $scene = Scene_Map.new
- return
- end
- # 切换到菜单画面
- $scene = Scene_Menu.new(4)
- else
- @choose_window.active = false
- @choose_window.visible = false
- @help_window.set_text("要保存到这个文件吗?")
- end
- end
- end
- class Scene_File
- alias m main
- def main
- @choose_window = Window_Command.new(64,["是","否"])
- @choose_window.x=640-64
- @choose_window.y = 32
- @choose_window.z = 9999
- @choose_window.active = false
- @choose_window.visible = false
- m
- @choose_window.dispose
- end
- def update
- # 刷新窗口
- @choose_window.update
- @help_window.update
- for i in @savefile_windows
- i.update
- end
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 调用过程 on_decision (定义继承目标)
- on_decision(make_filename(@file_index))
- $game_temp.last_file_index = @file_index
- return
- end
- # 按下 B 键的情况下
- if Input.trigger?(Input::B)
- # 调用过程 on_cancel (定义继承目标)
- on_cancel
- return
- end
- # 按下方向键下的情况下
- if Input.repeat?(Input::DOWN) && !@choose_window.active
- # 方向键下的按下状态不是重复的情况下、
- # 并且光标的位置在 3 以前的情况下
- if Input.trigger?(Input::DOWN) or @file_index < 3
- # 演奏光标 SE
- $game_system.se_play($data_system.cursor_se)
- # 光标向下移动
- @savefile_windows[@file_index].selected = false
- @file_index = (@file_index + 1) % 4
- @savefile_windows[@file_index].selected = true
- return
- end
- end
- # 按下方向键上的情况下
- if Input.repeat?(Input::UP) && !@choose_window.active
- # 方向键上的按下状态不是重复的情况下、
- # 并且光标的位置在 0 以后的情况下
- if Input.trigger?(Input::UP) or @file_index > 0
- # 演奏光标 SE
- $game_system.se_play($data_system.cursor_se)
- # 光标向上移动
- @savefile_windows[@file_index].selected = false
- @file_index = (@file_index + 3) % 4
- @savefile_windows[@file_index].selected = true
- return
- end
- end
- end
- end
- def write_save_data(file)
- # 生成描绘存档文件用的角色图形
- characters = []
- for i in 0...$game_party.actors.size
- actor = $game_party.actors[i]
- characters.push([actor.character_name, actor.character_hue])
- end
- # 写入描绘存档文件用的角色数据
- Marshal.dump(characters, file)
- # 写入测量游戏时间用画面计数
- Marshal.dump(Graphics.frame_count, file)
- # 增加 1 次存档次数
- $game_system.save_count += 1
- # 保存魔法编号
- # (将编辑器保存的值以随机值替换)
- $game_system.magic_number = $data_system.magic_number
- # 写入各种游戏对像
- Marshal.dump($game_system, file)
- Marshal.dump($game_switches, file)
- Marshal.dump($game_variables, file)
- Marshal.dump($game_self_switches, file)
- Marshal.dump($game_screen, file)
- Marshal.dump($game_actors, file)
- Marshal.dump($game_party, file)
- Marshal.dump($game_troop, file)
- Marshal.dump($game_map, file)
- Marshal.dump($game_player, file)
- end
- class Scene_Exit
- def initialize(mode = 0)
- @mode = mode
- end
- def main
- @help_window = Window_Base.new(0,240-32,640,64)
- @help_window.contents = Bitmap.new(640 - 32, 32)
- @help_window.contents.draw_text(0,0,640-32,32,"如果现在保存此进度将成为公正进度,是否保存?",1)
- @choose_window = Window_Command.new(64,["是","否"])
- @choose_window.x = 320-32
- @choose_window.y = 320
- @choose_window.active = true
- # 执行过渡
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- # 如果画面切换的话就中断循环
- if $scene != self
- break
- end
- end
- # 准备过渡
- Graphics.freeze
- # 释放窗口
- @help_window.dispose
- @choose_window.dispose
- end
- def update
- @choose_window.update
- if Input.trigger?(Input::C)
- $game_system.se_play($data_system.decision_se)
- if @choose_window.index == 0
- $scene = Scene_SaveE.new(@mode)
- else
- $scene = nil if @mode == 0
- $scene = Scene_Title.new if @mode == 1
- end
- end
- end
- end
- def exit(value)
- if $scene.is_a?(Scene_Map) || $scene.is_a?(Scene_Menu)
- $scene = Scene_Exit.new
- else
- $scene = nil
- end
- end
- class Scene_End
- alias tt command_to_title
- def command_to_title
- if $game_system.fair == -1
- $scene = Scene_Exit.new(1)
- else
- tt
- end
- end
- alias s command_shutdown
- def command_shutdown
- if $game_system.fair == -1
- $scene = Scene_Exit.new
- else
- s
- end
- end
- end
复制代码
|
|