| 赞 | 14 |
| VIP | |
| 好人卡 | |
| 积分 | 6 |
| 经验 | |
| 最后登录 | 2026-8-9 |
| 在线时间 | 797 小时 |
- 梦石
- 0
- 星屑
- 606
- 在线时间
- 797 小时
- 注册时间
- 2014-7-1
- 回帖
- 501

|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 jiushiainilip19 于 2016-9-24 17:49 编辑
save_data($data_weapons, "Data/Weapons.rxdata")
save_data($data_armors, "Data/Armors.rxdata")
save_data($data_classes, "Data/Classes.rxdata")
save_data($data_skills, "Data/Skills.rxdata")
save_data($data_states, "Data/States.rxdata")
用这些命令写入存档 游戏中强化等等都可以永久保存
但是只要一打开游戏的数据库就会还原,怎么回事?有什么办法解决吗?
如果仿造
$data_weapons = Marshal.load(file)
类来写入存档的话 就会固定死数据库原来的设定
比如数据中 武器名字叫 A 你写入上面存档后就永远是A 无论你怎么在数据库更改都不行
只有在游戏中用事件命令去更改!好不科学啊!
其实我就是想通过一些简单事件命令来强化一些需求的东西
比如技能 防具 武器 的属性等等 $data_skills[@skill_id].str_f 等等之类的
可问题是更本没用 重启游戏就消失了 强行写入存档又会固定死数据库的设定 想改都改不了
下面我是这样来做技能升级脚本的
脚本一
- $C力= [54,60,61,62,66,69,71,100,104,108,109,112,115,118,124]
- $C元= [55,56,57,58,63,65,68,70,75,76,101,102,103,106,107,110,114,116,121,123,
- 125,126]
- $C速= [74,78,120,128]
- $C综= [54,64,72,73,77,111,117,119,122,127]
- $C奶= [59,67,105,113]
- $S神力 = [950,954,959,960,961,964,967,970,973,978,
- 900,904,908,909,912,915,918,924,927]
- $S神元 = [951,952,953,957,958,962,966,968,975,977,979,
- 901,902,903,906,907,910,914,916,921,923,925]
- $S神速 = [974,982,920,928]
- $S神综 = [963,969,971,976,980,981,911,917,919,922,926]
- $S神奶 = [956,965,972,905,913]
- module RPG
- class Skill
-
- def dex_f
- n = @dex_f
-
- $C元.each do |a|
- if @id == a
- n+=@power * 5
- end;end
-
- $C奶.each do |a|
- if @id == a
- n+=@power * 2
- end;end
-
- $C综.each do |a|
- if @id == a
- n+=@power * 2
- end;end
-
- $S神元.each do |a|
- if @id == a
- n+=@power * 20
- end;end
-
- $S神综.each do |a|
- if @id == a
- n+=@power * 10
- end;end
-
- return n
- end
-
-
- def str_f
- n = @str_f
-
- $C力.each do |a|
- if @id == a
- n+=@power * 5
- end;end
-
- $C综.each do |a|
- if @id == a
- n+=@power * 2
- end;end
-
- $S神力.each do |a|
- if @id == a
- n+=@power * 20
- end;end
-
- $S神综.each do |a|
- if @id == a
- n+=@power * 10
- end;end
-
- return n
- end
-
-
-
- def agi_f
- n = @agi_f
-
- $C速.each do |a|
- if @id == a
- n+=@power * 5
- end;end
-
- $C综.each do |a|
- if @id == a
- n+=@power * 2
- end;end
-
- $S神速.each do |a|
- if @id == a
- n+=@power * 20
- end;end
-
- $S神综.each do |a|
- if @id == a
- n+=@power * 10
- end;end
-
- return n
- end
-
-
-
-
-
-
- def name
- n = @name
- case @id
- when 54..78
- if @power>=10
- n = @name+"Lv:"+"Max"
- else
- n = @name+"Lv:"+@power.to_s
- end
- when 100..128
- if @power>=15
- n = @name+"Lv:"+"Max"
- else
- n = @name+"Lv:"+@power.to_s
- end
- when 950..982 #神
- if @power>=4
- n = @name+"Lv:"+"Max"
- else
- n = @name+"Lv:"+@power.to_s
- end
- when 900..928 #圣
- if @power>=6
- n = @name+"Lv:"+"Max"
- else
- n = @name+"Lv:"+@power.to_s
- end
-
- end
- return n
- end
-
- end
- end
复制代码
脚本二
- class Window_C_Level < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # actor : 角色
- #--------------------------------------------------------------------------
- def initialize(actor)
- super(300, 100, 260, 250)
- @actor = actor
- @column_max = 1
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 获取特技
- #--------------------------------------------------------------------------
- def skill
- return @data[self.index]
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- @data = []
- for i in [email]0...@actor.skills.size[/email]
- skill = $data_skills[@actor.skills[i]]
- if skill != nil
- case skill.id
- when 54..200 #小
- @data.push(skill)
- when 950..982 #神
- @data.push(skill)
- when 900..928 #圣
- @data.push(skill)
- end
- end
- end
- # 如果项目数不是 0 就生成位图、重新描绘全部项目
- @item_max = @data.size
- if @item_max > 0
- self.contents = Bitmap.new(width - 32, row_max * 32)
- for i in 0...@item_max
- draw_item(i)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘项目
- # index : 项目编号
- #--------------------------------------------------------------------------
- def draw_item(index)
- skill = @data[index]
- x = 4 + index % 1 * (288 + 32)
- y = index / 1 * 32
- rect = Rect.new(x, y, self.width / @column_max - 32, 32)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- bitmap = RPG::Cache.icon(skill.icon_name)
- opacity = self.contents.font.color == normal_color ? 255 : 128
- self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
- self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
- self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
- end
- #--------------------------------------------------------------------------
- # ● 刷新帮助文本
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_text(self.skill == nil ? "" : self.skill.description)
- end
- end
复制代码
脚本三
- class Window_Status_Level < Window_Base
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # actor : 角色
- #--------------------------------------------------------------------------
- def initialize(actor)
- super(40, 100, 260, 250)
- self.contents = Bitmap.new(width - 32, height - 32)
- @actor = actor
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- draw_actor_name(@actor, 100, 0)
- draw_actor_fas(@actor, 5, 10)
- text = "消耗角色魂力来提升当前技能,"
- text1 = "的等级.每个级别的技能等级"
- text2 = "上限都有所不同。品质越高"
- text3 = "可以提升的等级就越高哦!"
- self.contents.draw_text(x-30, y, 260, 32,text)
- self.contents.draw_text(x-30, y+20, 260, 32,text1)
- self.contents.draw_text(x-30, y+40, 260, 32,text2)
- self.contents.draw_text(x-30, y+60, 260, 32,text3)
- end
- end
复制代码
脚本四
然后裁图脚本写入
- #==============================================================================
- # 本脚本来自[url]www.66RPG.com[/url],转载和使用请保留此信息
- #===============================================================================
- BBS_66RPG_DIR = "Save/" # 储存文件夹名,请制作游戏时自行建立此文件夹
- # 若想使用自定义背景图,脚本62行的井号去掉,并放置一张相应图形。
- # 在你的Scene_Title中找到这一段(如果使用其他插件脚本,在插件中找):
- # for i in 0..3
- # if FileTest.exist?("Save#{i+1}.rxdata")
- # 请自行把0..3改为0..最大进度号,比如0..9
- # "Save#{i+1}.rxdata" 改为"Save/Save#{i}.rxdata"
- # 增加进度的方法:138,258行,继续添加。你也可以改“进度X”为“回忆X”或者“红/绿/蓝笔记本”
- #===============================================================================
- module Screen
- @screen = Win32API.new 'screenshot', 'Screenshot', %w(l l l l p l l), ''
- @readini = Win32API.new 'kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l'
- @findwindow = Win32API.new 'user32', 'FindWindowA', %w(p p), 'l'
- module_function
- #-----------------------------------------------------------------------------
- def shot(file = "shot", typ = 1)
- # to add the right extension...
- if typ == 0
- typname = ".bmp"
- elsif typ == 1
- typname = ".jpg"
- elsif typ == 2
- typname = ".png"
- end
- file_index = 0
- dir = "Save/"
- # make the filename....
- file_name = dir + file.to_s + typname.to_s
- # make the screenshot.... Attention dont change anything from here on....
- @screen.call(0,0,640,480,file_name,handel,typ)
- end
- # find the game window...
- def handel
- game_name = "\0" * 256
- @readini.call('Game','Title','',game_name,255,".\\Game.ini")
- game_name.delete!("\0")
- return @findwindow.call('RGSS Player',game_name)
- end
- end
- class Window_File < Window_Base
- attr_accessor :index
- def initialize(index = 0)
- @backsp = Sprite.new
- #@backsp.bitmap = Bitmap.new("Graphics/Pictures/存盘背景.jpg")
- @backsp.z = 99
- super(160,0,480,480)
- #这行可以不用
- self.contents = Bitmap.new(width - 32, height - 32)
- @index = index
- #这里我要说明一句,之所以用sprite是为了放缩图片
- @sprite = Sprite.new
- @sprite.visible = false
- @sprite.z = 100
- @sp_ch = []
- @sp_ch[0] = Sprite.new
- refresh
- end
- def refresh
- self.contents.clear
- for i in @sp_ch
- i.visible = false
- end
- @sprite.visible = false
- if FileTest.exist?(BBS_66RPG_DIR+"Save#{@index}.rxdata")
- @sprite.visible = true
- if FileTest.exist?(BBS_66RPG_DIR+"Save#{@index}.jpg")
- @sprite.bitmap = Bitmap.new(BBS_66RPG_DIR+"Save#{@index}.jpg")
- else
- self.contents.draw_text(32,64,400,32,"截图似乎有点问题……您搞什么了您?")
- end
- @sprite.x = 176
- @sprite.y = 16
- @sprite.zoom_x = 0.7
- @sprite.zoom_y = 0.7
- file = File.open(BBS_66RPG_DIR+"Save#{@index}.rxdata", "r")
- @time_stamp = file.mtime
- @characters = Marshal.load(file)
- @frame_count = Marshal.load(file)
- @game_system = Marshal.load(file)
- @game_switches = Marshal.load(file)
- @game_variables = Marshal.load(file)
- @total_sec = @frame_count / Graphics.frame_rate
- file.close
- for i in [email]0...@characters.size[/email]
- @sp_ch[i] = Sprite.new
- @sp_ch[i].visible = true
- @sp_ch[i].bitmap = RPG::Cache.battler(@characters[i][3], @characters[i][4])
- @sp_ch[i].x = 180 + i*80
- @sp_ch[i].y = 440 - @sp_ch[i].bitmap.height
- @sp_ch[i].z = 101
- end
- self.contents.font.color = normal_color
- self.contents.draw_text(324, 360, 420, 32,"风云III残破的世界")
- # 描绘游戏时间
- 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, 390, 420, 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, 420, 420, 32, time_string, 2)
- else
- self.contents.draw_text(32,32,420,32,"这个存档是空的")
- end
- end
- def dispose
- super
- @sprite.dispose
- @backsp.dispose
- for i in @sp_ch
- i.dispose
- end
- end
- end
- class Scene_Save
- def main
- @command_window = Window_Command.new(160,["记录一","记录二","记录三","记录四","记录五","记录六"])
- @command_window.y = 96
- @command_window.index = $game_temp.last_file_index
- @content_window = Window_File.new($game_temp.last_file_index)
- # 执行过渡
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- # 如果画面被切换的话就中断循环
- if $scene != self
- break
- end
- end
- # 准备过渡
- Graphics.freeze
- @command_window.dispose
- @content_window.dispose
- end
- def update
- @command_window.update
- if @command_window.index != @content_window.index
- @content_window.index = @command_window.index
- @content_window.refresh
- end
- #——————下面这一部分是原装脚本——————#
- if Input.trigger?(Input::B)
- $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)
- end
- #———————————————————————#
- if Input.trigger?(Input::C)
- # 演奏存档 SE
- $game_system.se_play($data_system.save_se)
- # 写入存档数据
- file = File.open(BBS_66RPG_DIR+"Save#{@command_window.index}.rxdata", "wb")
- write_save_data(file)
- if FileTest.exist?(BBS_66RPG_DIR+"shot.jpg")
- File.rename(BBS_66RPG_DIR+"shot.jpg", BBS_66RPG_DIR+"Save#{@command_window.index}.jpg")
- end
- file.close
- $game_temp.last_file_index = @command_window.index
- # 如果被事件调用
- if $game_temp.save_calling
- # 清除存档调用标志
- $game_temp.save_calling = false
- # 切换到地图画面
- $scene = Scene_Map.new
- return
- end
- # 切换到菜单画面
- $scene = Scene_Map.new
- 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, actor.id, actor.battler_name, actor.battler_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)
-
- save_data($data_weapons, "Data/Weapons.rxdata")
- save_data($data_armors, "Data/Armors.rxdata")
- save_data($data_classes, "Data/Classes.rxdata")
- save_data($data_skills, "Data/Skills.rxdata")
-
- save_data($data_states, "Data/States.rxdata")
-
-
-
-
-
- end
- end
- class Scene_Load
- def initialize
- # 再生成临时对像
- $game_temp = Game_Temp.new
- # 选择存档时间最新的文件
- $game_temp.last_file_index = 0
- latest_time = Time.at(0)
- for i in 0..6
- filename = BBS_66RPG_DIR+"Save#{i}.rxdata"
- if FileTest.exist?(filename)
- file = File.open(filename, "r")
- if file.mtime > latest_time
- latest_time = file.mtime
- $game_temp.last_file_index = i
- end
- file.close
- end
- end
- end
- def main
- @command_window = Window_Command.new(160,["进度一","进度二","进度三","进度四","进度五","进度六"])
- @command_window.y = 96
- @command_window.index = $game_temp.last_file_index
- @content_window = Window_File.new($game_temp.last_file_index)
- # 执行过渡
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- # 如果画面被切换的话就中断循环
- if $scene != self
- break
- end
- end
- # 准备过渡
- Graphics.freeze
- @command_window.dispose
- @content_window.dispose
- end
- def update
- @command_window.update
- if @command_window.index != @content_window.index
- @content_window.index = @command_window.index
- @content_window.refresh
- end
- #——————下面这一部分是原装脚本——————#
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 切换到标题画面
- $scene = Scene_Title.new
- end
- #———————————————————————#
- if Input.trigger?(Input::C)
- # 文件不存在的情况下
- unless FileTest.exist?(BBS_66RPG_DIR+"Save#{@command_window.index}.rxdata")
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # 演奏读档 SE
- $game_system.se_play($data_system.load_se)
- # 写入存档数据
- file = File.open(BBS_66RPG_DIR+"Save#{@command_window.index}.rxdata", "rb")
- read_save_data(file)
- file.close
- # 还原 BGM、BGS
- $game_system.bgm_play($game_system.playing_bgm)
- $game_system.bgs_play($game_system.playing_bgs)
- # 刷新地图 (执行并行事件)
- $game_map.update
- # 切换到地图画面
- $scene = Scene_Map.new
- end
- #———————————————————————#
- end
- #--------------------------------------------------------------------------
- # ● 写入存档数据
- # file : 写入用文件对像 (已经打开)
- #--------------------------------------------------------------------------
- def read_save_data(file)
- # 读取描绘存档文件用的角色数据
- characters = Marshal.load(file)
- # 读取测量游戏时间用画面计数
- Graphics.frame_count = Marshal.load(file)
- # 读取各种游戏对像
- $game_system = Marshal.load(file)
- $game_switches = Marshal.load(file)
- $game_variables = Marshal.load(file)
- $game_self_switches = Marshal.load(file)
- $game_screen = Marshal.load(file)
- $game_actors = Marshal.load(file)
- $game_party = Marshal.load(file)
- $game_troop = Marshal.load(file)
- $game_map = Marshal.load(file)
- $game_player = Marshal.load(file)
-
- save_data($data_weapons, "Data/Weapons.rxdata")
- save_data($data_armors, "Data/Armors.rxdata")
- save_data($data_classes, "Data/Classes.rxdata")
- save_data($data_skills, "Data/Skills.rxdata")
-
- # 魔法编号与保存时有差异的情况下
- # (加入编辑器的编辑过的数据)
- if $game_system.magic_number != $data_system.magic_number
- # 重新装载地图
- $game_map.setup($game_map.map_id)
- $game_player.center($game_player.x, $game_player.y)
- end
- # 刷新同伴成员
- $game_party.refresh
- end
- end
- class Scene_Menu
- alias bbs_66rpg_shotsave_main main
- def main
- if @menu_index == 0
- Screen::shot
- end
- bbs_66rpg_shotsave_main
- end
- end
- class Interpreter
- #--------------------------------------------------------------------------
- # ● 调用存档画面
- #--------------------------------------------------------------------------
- def command_352
- # 设置战斗中断标志
- $game_temp.battle_abort = true
- # 设置调用存档标志
- $game_temp.save_calling = true
- # 推进索引
- @index += 1
- # 结束
- Screen::shot
- return false
- end
- end
复制代码
|
|