加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 crow2006 于 2013-5-23 12:54 编辑
一个是死亡后执行公共事件1的脚本, 一个是退出或关闭时自动存档脚本,
请求修改,多谢!
要求实现 退出游戏时先执行公共事件1,之后存档到位置1的效果。
#-------------------------------------------------------------------------- # ● 结束战斗 # result : 结果(0:胜利,1:逃跑,2:失败) #-------------------------------------------------------------------------- def battle_end(result) if result == 2 and not $game_troop.can_lose $game_party.clear_actions $game_party.remove_states_battle $game_troop.clear if $game_temp.battle_proc != nil $game_temp.battle_proc.call(result) $game_temp.battle_proc = nil end unless $BTEST $game_temp.map_bgm.play $game_temp.map_bgs.play end $scene = Scene_Map.new @message_window.clear Graphics.fadeout(30) $game_map.interpreter.setup($data_common_events[1].list, 0) else $game_party.clear_actions $game_party.remove_states_battle $game_troop.clear if $game_temp.battle_proc != nil $game_temp.battle_proc.call(result) $game_temp.battle_proc = nil end unless $BTEST $game_temp.map_bgm.play $game_temp.map_bgs.play end $scene = Scene_Map.new @message_window.clear Graphics.fadeout(30) end $game_temp.in_battle = false end
#--------------------------------------------------------------------------
# ● 结束战斗
# result : 结果(0:胜利,1:逃跑,2:失败)
#--------------------------------------------------------------------------
def battle_end(result)
if result == 2 and not $game_troop.can_lose
$game_party.clear_actions
$game_party.remove_states_battle
$game_troop.clear
if $game_temp.battle_proc != nil
$game_temp.battle_proc.call(result)
$game_temp.battle_proc = nil
end
unless $BTEST
$game_temp.map_bgm.play
$game_temp.map_bgs.play
end
$scene = Scene_Map.new
@message_window.clear
Graphics.fadeout(30)
$game_map.interpreter.setup($data_common_events[1].list, 0)
else
$game_party.clear_actions
$game_party.remove_states_battle
$game_troop.clear
if $game_temp.battle_proc != nil
$game_temp.battle_proc.call(result)
$game_temp.battle_proc = nil
end
unless $BTEST
$game_temp.map_bgm.play
$game_temp.map_bgs.play
end
$scene = Scene_Map.new
@message_window.clear
Graphics.fadeout(30)
end
$game_temp.in_battle = false
end
module Kernel alias origin_exit exit unless method_defined? :exit def exit(*args) case $scene when Scene_Map AutoSave.common_save unless $game_map.interpreter.running? when Scene_Battle AutoSave.common_save unless $game_battle.interpreter.running? else if $scene.type != NilClass and $scene.type != Scene_Title AutoSave.common_save end end origin_exit(*args) end end module AutoSave if @scene_proc.nil? @last_scene = nil.class @scene_proc = proc do |value| if value.nil? or value.is_a?(Scene_Title) if @last_scene != NilClass and @last_scene != Scene_Title AutoSave.common_save end end @last_scene = value.type end trace_var(:$scene,@scene_proc) end module_function def common_save filename = "Save#{$game_temp.last_file_index + 1}.rvdata" file = File.open(filename, "wb") write_save_data(file) file.close end def write_save_data(file) characters = [] for actor in $game_party.members characters.push([actor.character_name, actor.character_index]) end $game_system.save_count += 1 $game_system.version_id = $data_system.version_id @last_bgm = RPG::BGM::last @last_bgs = RPG::BGS::last Marshal.dump(characters, file) Marshal.dump(Graphics.frame_count, file) Marshal.dump(@last_bgm, file) Marshal.dump(@last_bgs, file) Marshal.dump($game_system, file) Marshal.dump($game_message, file) Marshal.dump($game_switches, file) Marshal.dump($game_variables, file) Marshal.dump($game_self_switches, 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
module Kernel
alias origin_exit exit unless method_defined? :exit
def exit(*args)
case $scene
when Scene_Map
AutoSave.common_save unless $game_map.interpreter.running?
when Scene_Battle
AutoSave.common_save unless $game_battle.interpreter.running?
else
if $scene.type != NilClass and $scene.type != Scene_Title
AutoSave.common_save
end
end
origin_exit(*args)
end
end
module AutoSave
if @scene_proc.nil?
@last_scene = nil.class
@scene_proc = proc do |value|
if value.nil? or value.is_a?(Scene_Title)
if @last_scene != NilClass and @last_scene != Scene_Title
AutoSave.common_save
end
end
@last_scene = value.type
end
trace_var(:$scene,@scene_proc)
end
module_function
def common_save
filename = "Save#{$game_temp.last_file_index + 1}.rvdata"
file = File.open(filename, "wb")
write_save_data(file)
file.close
end
def write_save_data(file)
characters = []
for actor in $game_party.members
characters.push([actor.character_name, actor.character_index])
end
$game_system.save_count += 1
$game_system.version_id = $data_system.version_id
@last_bgm = RPG::BGM::last
@last_bgs = RPG::BGS::last
Marshal.dump(characters, file)
Marshal.dump(Graphics.frame_count, file)
Marshal.dump(@last_bgm, file)
Marshal.dump(@last_bgs, file)
Marshal.dump($game_system, file)
Marshal.dump($game_message, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, 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
|