mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-19 21:39:57 +00:00
Added permaflag/variable functionality
This commit is contained in:
parent
bc2133b01f
commit
1762362044
4 changed files with 83 additions and 1 deletions
|
|
@ -1,4 +1,40 @@
|
|||
SAVE_FILE_NAME = Oneshot::SAVE_PATH + '/save.dat'
|
||||
PERMA_FLAGS_NAME = Oneshot::SAVE_PATH + '/p-settings.dat'
|
||||
FAKE_SAVE_NAME = Oneshot::DOCS_PATH + '\\My Games\\Oneshot\\save_progress.oneshot'
|
||||
|
||||
|
||||
def erase_game
|
||||
File.delete(SAVE_FILE_NAME)
|
||||
end
|
||||
|
||||
def fake_save
|
||||
Dir.mkdir(Oneshot::DOCS_PATH + "\\My Games") unless File.exists?(Oneshot::DOCS_PATH + "\\My Games")
|
||||
Dir.mkdir(Oneshot::DOCS_PATH + "\\My Games\\Oneshot") unless File.exists?(Oneshot::DOCS_PATH + "\\My Games\\Oneshot")
|
||||
File.open(FAKE_SAVE_NAME, 'wb') do |file|
|
||||
# Wrire frame count for measuring play time
|
||||
Marshal.dump(Graphics.frame_count, file)
|
||||
# Increase save count by 1
|
||||
$game_system.save_count += 1
|
||||
# Save magic number
|
||||
# (A random value will be written each time saving with editor)
|
||||
$game_system.magic_number = $data_system.magic_number
|
||||
# Write each type of game object
|
||||
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_map, file)
|
||||
Marshal.dump($game_player, file)
|
||||
Marshal.dump($game_followers, file)
|
||||
Marshal.dump($game_oneshot, file)
|
||||
Marshal.dump($game_fasttravel, file)
|
||||
Marshal.dump($game_temp.footstep_sfx , file)
|
||||
end
|
||||
save_perma_flags
|
||||
end
|
||||
|
||||
def save
|
||||
File.open(SAVE_FILE_NAME, 'wb') do |file|
|
||||
|
|
@ -24,6 +60,25 @@ def save
|
|||
Marshal.dump($game_fasttravel, file)
|
||||
Marshal.dump($game_temp.footstep_sfx , file)
|
||||
end
|
||||
save_perma_flags
|
||||
end
|
||||
|
||||
def save_perma_flags
|
||||
perma_flags = Array.new(25, false)
|
||||
for i in 151..175
|
||||
perma_flags[i-151] = $game_switches[i]
|
||||
end
|
||||
perma_vars = Array.new(25, 0)
|
||||
for i in 76..100
|
||||
perma_vars[i-76] = $game_variables[i]
|
||||
end
|
||||
p_name = $game_oneshot.player_name
|
||||
|
||||
File.open(PERMA_FLAGS_NAME, 'wb') do |file|
|
||||
Marshal.dump(perma_flags, file)
|
||||
Marshal.dump(perma_vars, file)
|
||||
Marshal.dump(p_name,file)
|
||||
end
|
||||
end
|
||||
|
||||
def load
|
||||
|
|
@ -62,9 +117,29 @@ def load
|
|||
f.moveto($game_player.x, $game_player.y)
|
||||
end
|
||||
end
|
||||
load_perma_flags
|
||||
return true
|
||||
end
|
||||
|
||||
def load_perma_flags
|
||||
return false if !FileTest.exist?(PERMA_FLAGS_NAME)
|
||||
perma_flags = nil
|
||||
perma_vars = nil
|
||||
p_name = nil
|
||||
File.open(PERMA_FLAGS_NAME, 'rb') do |file|
|
||||
perma_flags = Marshal.load(file)
|
||||
perma_vars = Marshal.load(file)
|
||||
p_name = Marshal.load(file)
|
||||
end
|
||||
for i in 151..175
|
||||
$game_switches[i] = perma_flags[i-151]
|
||||
end
|
||||
for i in 76..100
|
||||
$game_variables[i] = perma_vars[i-76]
|
||||
end
|
||||
$game_oneshot.player_name = p_name
|
||||
end
|
||||
|
||||
def real_load
|
||||
load
|
||||
# Restore BGM and BGS
|
||||
|
|
@ -89,6 +164,10 @@ def save_exists
|
|||
return FileTest.exist?(SAVE_FILE_NAME)
|
||||
end
|
||||
|
||||
def fake_save_exists
|
||||
return FileTest.exist?(FAKE_SAVE_NAME)
|
||||
end
|
||||
|
||||
def quit_game_bed
|
||||
$game_system.map_interpreter.index += 1
|
||||
save
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class Scene_Load < Scene_File
|
|||
$game_followers = Marshal.load(file)
|
||||
$game_oneshot = Marshal.load(file)
|
||||
$game_fasttravel = Marshal.load(file)
|
||||
$game_temp.footstep_sfx = Marshal.load(file)
|
||||
$game_temp.footstep_sfx = Marshal.load(file)
|
||||
|
||||
# If magic number is different from when saving
|
||||
# (if editing was added with editor)
|
||||
|
|
@ -99,5 +99,6 @@ class Scene_Load < Scene_File
|
|||
f.leader = $game_player
|
||||
f.moveto($game_player.x, $game_player.y)
|
||||
end
|
||||
load_perma_flags
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -84,5 +84,6 @@ class Scene_Save < Scene_File
|
|||
Marshal.dump($game_oneshot, file)
|
||||
Marshal.dump($game_fasttravel, file)
|
||||
Marshal.dump($game_temp.footstep_sfx , file)
|
||||
save_perma_flags
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ class Scene_Title
|
|||
# Load save game/initialize data
|
||||
$game_temp = Game_Temp.new
|
||||
new_game #unless load
|
||||
load_perma_flags
|
||||
# Make system object
|
||||
$game_system = Game_System.new
|
||||
# Skip title screen if debug mode (or demo, but not GDC)
|
||||
|
|
|
|||
Loading…
Reference in a new issue