Project1
标题:
请问这个脚本怎样加入别的脚本中
[打印本页]
作者:
坚强的羁绊
时间:
2011-2-7 00:14
标题:
请问这个脚本怎样加入别的脚本中
本帖最后由 坚强的羁绊 于 2011-2-7 14:18 编辑
#==============================================================================
# ■ 存取档合并脚本
#------------------------------------------------------------------------------
# BY:美兽
#插入main之前,地图呼出方式$scene = Scene_Loadsave.new,主菜单里默认的也是该界面
#不与默认的存取档功能冲突,方便个别地方只需存或者取的功能,虽然很简单,实际做起
#来,考虑的地方还是比较多。
#==============================================================================
#==============================================================================
# ■ Scene_Load
#------------------------------------------------------------------------------
# 处理读档画面的类。
#==============================================================================
class Scene_Load < Scene_File
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
# 再生成临时对像
$game_temp = Game_Temp.new
# 选择存档时间最新的文件
$game_temp.last_file_index = 0
latest_time = Time.at(0)
for i in 0..3
filename = make_filename(i)
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
super("要载入哪个文件?")
end
#--------------------------------------------------------------------------
# ● 确定时的处理
#--------------------------------------------------------------------------
def on_decision(filename)
# 文件不存在的情况下
unless FileTest.exist?(filename)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
$menu_call = false
# 演奏读档 SE
$game_system.se_play($data_system.load_se)
# 写入存档数据
file = File.open(filename, "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
#--------------------------------------------------------------------------
# ● 取消时的处理
#--------------------------------------------------------------------------
def on_cancel
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到标题画面
$scene = Scene_Title.new
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)
# 魔法编号与保存时有差异的情况下
# (加入编辑器的编辑过的数据)
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
#==============================================================================
# ■ Window_LoadHelp
#------------------------------------------------------------------------------
# 存取档画面帮助信息的显示窗口。
#==============================================================================
class Window_LoadHelp < Window_Base
#--------------------------------------------------------------------------
# 初始化对象
#--------------------------------------------------------------------------
def initialize
super(0, 0, 320, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = "黑体"
self.contents.font.size = 18
end
#--------------------------------------------------------------------------
# 刷新文本
#--------------------------------------------------------------------------
def set_text(text, align = 1)
if text != @text or align != @align
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
@text = text
@align = align
@actor = nil
end
self.visible = true
end
end
#==============================================================================
# Window_LoadCommand
#------------------------------------------------------------------------------
# 存取档画面选择按钮窗口
#==============================================================================
class Window_LoadCommand < Window_Selectable
#--------------------------------------------------------------------------
# 初始化对象
#--------------------------------------------------------------------------
def initialize
super(320, 0, 320, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = "黑体"
self.contents.font.size = 18
@item_max = 2
@column_max = 2
@commands = ["读取", "存储"]
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# 描画按钮文字
#--------------------------------------------------------------------------
def draw_item(index)
x = 4 + index * 160
self.contents.draw_text(x, 0, 144, 32, @commands[index])
end
#--------------------------------------------------------------------------
# ● 项目无效化
# index : 项目编号
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
end
#==============================================================================
# ■ Scene_Menu
#------------------------------------------------------------------------------
# 处理菜单画面的类。
#==============================================================================
class Scene_Menu
#--------------------------------------------------------------------------
# ● 初始化对像
# menu_index : 命令光标的初期位置
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
@spriteset = Spriteset_Map.new
# 生成命令窗口
s1 = $data_system.words.item
s2 = $data_system.words.skill
s3 = $data_system.words.equip
s4 = "状态"
s5 = "记录"
s6 = "任务"
s7 = "队列"
s8 = "结束"
@cmd = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7, s8])
@cmd.index = @menu_index
# 同伴人数为 0 的情况下
if $game_party.actors.size == 0
# 物品、特技、装备、状态无效化
@cmd.disable_item(0)
@cmd.disable_item(1)
@cmd.disable_item(2)
@cmd.disable_item(3)
end
# 生成游戏时间窗口
@playtime_window = Window_PlayTime.new
@playtime_window.x = 0
@playtime_window.y = 320
# 生成步数窗口
#@steps_window = Window_Steps.new
#@steps_window.x = 0
#@steps_window.y = 320
# 生成金钱窗口
@gold_window = Window_Gold.new
@gold_window.x = 0
@gold_window.y = 416
# 生成状态窗口
@status_window = Window_MenuStatus.new
@status_window.x = 160
@status_window.y = 0
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果切换画面就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@cmd.dispose
@playtime_window.dispose
@spriteset.dispose
# @steps_window.dispose
@gold_window.dispose
@status_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@cmd.update
@playtime_window.update
#@steps_window.update
@gold_window.update
@status_window.update
# 命令窗口被激活的情况下: 调用 update_command
if @cmd.active
update_command
return
end
# 状态窗口被激活的情况下: 调用 update_status
if @status_window.active
update_status
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (命令窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_command
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换的地图画面
$scene = Scene_Map.new
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 同伴人数为 0、存档、游戏结束以外的场合
if $game_party.actors.size == 0 and @cmd.index < 4
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 命令窗口的光标位置分支
case @cmd.index
when 0 # 物品
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到物品画面
$scene = Scene_Item.new
when 1 # 特技
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 激活状态窗口
@cmd.active = false
@status_window.active = true
@status_window.index = 0
when 2 # 装备
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 激活状态窗口
@cmd.active = false
@status_window.active = true
@status_window.index = 0
when 3 # 状态
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 激活状态窗口
@cmd.active = false
@status_window.active = true
@status_window.index = 0
when 4 # 记录
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到存取档画面
$menu_call = true
$scene = Scene_Loadsave.new
when 5 # 任务
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到任务画面
$scene = Scene_Task.new
when 6 # 队列
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
#切换到队列画面
$scene = Scene_Change_Turn.new
end
return
end
end
end
#==============================================================================
# Scene_Loadsave
#------------------------------------------------------------------------------
# 处理存取档画面的类。
#==============================================================================
class Scene_Loadsave
#--------------------------------------------------------------------------
# ● 初始化对像
# $last_savefile_index : 记录光标位置
#--------------------------------------------------------------------------
def initialize
$last_savefile_index = 0 if $last_savefile_index == nil
end
#--------------------------------------------------------------------------
# 主处理
#--------------------------------------------------------------------------
def main
@savestate = 0
# 生成窗口
@help_window = Window_LoadHelp.new
@help_window.set_text("请选择.")
@option_window = Window_LoadCommand.new
@savefile_windows = []
for i in 0..3
@savefile_windows.push(Window_SaveFile.new(i, make_filename(i)))
end
@option_window.index = $last_savefile_index
@file_index = 0
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面被切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@help_window.dispose
@option_window.dispose
for i in @savefile_windows
i.dispose
end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@help_window.update
@option_window.update
for i in @savefile_windows
i.update
end
case @savestate
when 0
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
# 淡入淡出 BGM
Audio.bgm_fade(800)
# 返回地图
if $menu_call == false
# 切换到地图画面
$scene = Scene_Map.new
return
end
# 切换到菜单画面
$menu_call = false
$scene = Scene_Menu.new(4)
end
if Input.trigger?(Input::C)
case @option_window.index
when 0
@savefile_windows[@file_index].selected = true
@option_window.active = false
@help_window.set_text("请选择一个文件进行读取.")
@savestate = 1
return
when 1
@savefile_windows[@file_index].selected = true
@option_window.active = false
@help_window.set_text("请选择一个文件进行存储.")
@savestate = 2
return
return
end
end
when 1,2
if Input.trigger?(Input::C)
if @savestate == 1
$menu_call = false
load_file(make_filename(@file_index))
return
else
# 禁止存档的情况下
if $game_system.save_disabled
@help_window.set_text("抱歉,这里禁止存储.")
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
$last_savefile_index = @option_window.index
save_file(make_filename(@file_index))
return
end
end
# 取消
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@savefile_windows[@file_index].selected = false
@help_window.set_text("请选择.")
@savestate = 0
@option_window.active = true
return
end
# 向下选择
if Input.repeat?(Input::DOWN)
$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
# 向上选择
if Input.repeat?(Input::UP)
$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
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@savestate = 2
@savefile_windows[@file_index].selected = true
return
end
end
end
#--------------------------------------------------------------------------
# 建立记录文件索引
#--------------------------------------------------------------------------
def make_filename(file_index)
return "Save#{file_index + 1}.rxdata"
end
#--------------------------------------------------------------------------
# 读取记录文件
# filename : 被读取文件
#--------------------------------------------------------------------------
def load_file(filename)
# 文件不存在的情况下
unless FileTest.exist?(filename)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏读档 SE
$game_system.se_play($data_system.load_se)
# 以二进制方式打开文件
# 写入存档数据
file = File.open(filename, "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
# 切换到地图画面
$menu_call == false
$scene = Scene_Map.new
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)
# 魔法编号与保存时有差异的情况下
# (加入编辑器的编辑过的数据)
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
#--------------------------------------------------------------------------
# ● 写入存档文件
#--------------------------------------------------------------------------
def save_file(filename)
# 演奏存档 SE
$game_system.se_play($data_system.save_se)
# 写入存档数据
file = File.open(filename, "wb")
write_save_data(file)
file.close
# 切换到菜单画面
$scene = Scene_Loadsave.new
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
复制代码
我想把它放到结束菜单里面,怎样才能把它给加进去
就是想把这个添加到结束菜单中,应该怎样改Scene_End脚本?
作者:
水野·迪尔
时间:
2011-2-7 02:16
这个脚本可能因为作者的需要添加了任务以及队列的系统,
已经帮你删去了。
把以下脚本添加进去,然后在Scence_Menu的160行
把$scene = Scene_Save.new改成$scene = Scene_Loadsave.new就可以了
#==============================================================================
# ■ 存取档合并脚本
#------------------------------------------------------------------------------
# BY:美兽
#插入main之前,地图呼出方式$scene = Scene_Loadsave.new,主菜单里默认的也是该界面
#不与默认的存取档功能冲突,方便个别地方只需存或者取的功能,虽然很简单,实际做起
#来,考虑的地方还是比较多。
#==============================================================================
#==============================================================================
# ■ Scene_Load
#------------------------------------------------------------------------------
# 处理读档画面的类。
#==============================================================================
class Scene_Load < Scene_File
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
# 再生成临时对像
$game_temp = Game_Temp.new
# 选择存档时间最新的文件
$game_temp.last_file_index = 0
latest_time = Time.at(0)
for i in 0..3
filename = make_filename(i)
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
super("要载入哪个文件?")
end
#--------------------------------------------------------------------------
# ● 确定时的处理
#--------------------------------------------------------------------------
def on_decision(filename)
# 文件不存在的情况下
unless FileTest.exist?(filename)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
$menu_call = false
# 演奏读档 SE
$game_system.se_play($data_system.load_se)
# 写入存档数据
file = File.open(filename, "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
#--------------------------------------------------------------------------
# ● 取消时的处理
#--------------------------------------------------------------------------
def on_cancel
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到标题画面
$scene = Scene_Title.new
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)
# 魔法编号与保存时有差异的情况下
# (加入编辑器的编辑过的数据)
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
#==============================================================================
# ■ Window_LoadHelp
#------------------------------------------------------------------------------
# 存取档画面帮助信息的显示窗口。
#==============================================================================
class Window_LoadHelp < Window_Base
#--------------------------------------------------------------------------
# 初始化对象
#--------------------------------------------------------------------------
def initialize
super(0, 0, 320, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = "黑体"
self.contents.font.size = 18
end
#--------------------------------------------------------------------------
# 刷新文本
#--------------------------------------------------------------------------
def set_text(text, align = 1)
if text != @text or align != @align
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
@text = text
@align = align
@actor = nil
end
self.visible = true
end
end
#==============================================================================
# Window_LoadCommand
#------------------------------------------------------------------------------
# 存取档画面选择按钮窗口
#==============================================================================
class Window_LoadCommand < Window_Selectable
#--------------------------------------------------------------------------
# 初始化对象
#--------------------------------------------------------------------------
def initialize
super(320, 0, 320, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = "黑体"
self.contents.font.size = 18
@item_max = 2
@column_max = 2
@commands = ["读取", "存储"]
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# 描画按钮文字
#--------------------------------------------------------------------------
def draw_item(index)
x = 4 + index * 160
self.contents.draw_text(x, 0, 144, 32, @commands[index])
end
#--------------------------------------------------------------------------
# ● 项目无效化
# index : 项目编号
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
end
#==============================================================================
# Scene_Loadsave
#------------------------------------------------------------------------------
# 处理存取档画面的类。
#==============================================================================
class Scene_Loadsave
#--------------------------------------------------------------------------
# ● 初始化对像
# $last_savefile_index : 记录光标位置
#--------------------------------------------------------------------------
def initialize
$last_savefile_index = 0 if $last_savefile_index == nil
end
#--------------------------------------------------------------------------
# 主处理
#--------------------------------------------------------------------------
def main
@savestate = 0
# 生成窗口
@help_window = Window_LoadHelp.new
@help_window.set_text("请选择.")
@option_window = Window_LoadCommand.new
@savefile_windows = []
for i in 0..3
@savefile_windows.push(Window_SaveFile.new(i, make_filename(i)))
end
@option_window.index = $last_savefile_index
@file_index = 0
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面被切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@help_window.dispose
@option_window.dispose
for i in @savefile_windows
i.dispose
end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@help_window.update
@option_window.update
for i in @savefile_windows
i.update
end
case @savestate
when 0
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
# 淡入淡出 BGM
Audio.bgm_fade(800)
# 返回地图
if $menu_call == false
# 切换到地图画面
$scene = Scene_Map.new
return
end
# 切换到菜单画面
$menu_call = false
$scene = Scene_Menu.new(4)
end
if Input.trigger?(Input::C)
case @option_window.index
when 0
@savefile_windows[@file_index].selected = true
@option_window.active = false
@help_window.set_text("请选择一个文件进行读取.")
@savestate = 1
return
when 1
@savefile_windows[@file_index].selected = true
@option_window.active = false
@help_window.set_text("请选择一个文件进行存储.")
@savestate = 2
return
return
end
end
when 1,2
if Input.trigger?(Input::C)
if @savestate == 1
$menu_call = false
load_file(make_filename(@file_index))
return
else
# 禁止存档的情况下
if $game_system.save_disabled
@help_window.set_text("抱歉,这里禁止存储.")
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
$last_savefile_index = @option_window.index
save_file(make_filename(@file_index))
return
end
end
# 取消
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@savefile_windows[@file_index].selected = false
@help_window.set_text("请选择.")
@savestate = 0
@option_window.active = true
return
end
# 向下选择
if Input.repeat?(Input::DOWN)
$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
# 向上选择
if Input.repeat?(Input::UP)
$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
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@savestate = 2
@savefile_windows[@file_index].selected = true
return
end
end
end
#--------------------------------------------------------------------------
# 建立记录文件索引
#--------------------------------------------------------------------------
def make_filename(file_index)
return "Save#{file_index + 1}.rxdata"
end
#--------------------------------------------------------------------------
# 读取记录文件
# filename : 被读取文件
#--------------------------------------------------------------------------
def load_file(filename)
# 文件不存在的情况下
unless FileTest.exist?(filename)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏读档 SE
$game_system.se_play($data_system.load_se)
# 以二进制方式打开文件
# 写入存档数据
file = File.open(filename, "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
# 切换到地图画面
$menu_call == false
$scene = Scene_Map.new
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)
# 魔法编号与保存时有差异的情况下
# (加入编辑器的编辑过的数据)
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
#--------------------------------------------------------------------------
# ● 写入存档文件
#--------------------------------------------------------------------------
def save_file(filename)
# 演奏存档 SE
$game_system.se_play($data_system.save_se)
# 写入存档数据
file = File.open(filename, "wb")
write_save_data(file)
file.close
# 切换到菜单画面
$scene = Scene_Loadsave.new
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
复制代码
作者:
忧雪の伤
时间:
2011-2-7 12:13
没看懂您需要达到的要求。
作者:
坚强的羁绊
时间:
2011-2-7 18:59
回复
水野·迪尔
的帖子
任务和队列是我加上去的
,而且我想知道的是怎么把这个加到结束菜单里去
作者:
忧雪の伤
时间:
2011-2-7 19:02
回复
坚强的羁绊
的帖子
增加结束菜单的项目数。
接着加入选择该项的处理。
作者:
坚强的羁绊
时间:
2011-2-7 19:07
回复
忧雪の伤
的帖子
怎么加啊
#==============================================================================
# ■ Scene_End
#------------------------------------------------------------------------------
# 处理游戏结束画面的类。
#==============================================================================
class Scene_End
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 生成命令窗口
s1 = "记录"
s2 = "返回标题"
s3 = "结束"
s4 = "取消"
@command_window = Window_Command.new(192, [s1, s2, s3, s4])
@command_window.x = 320 - @command_window.width / 2
@command_window.y = 240 - @command_window.height / 2
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入情报
Input.update
# 刷新画面
update
# 如果画面切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@command_window.dispose
# 如果在标题画面切换中的情况下
if $scene.is_a?(Scene_Title)
# 淡入淡出画面
Graphics.transition
Graphics.freeze
end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新命令窗口
@command_window.update
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到菜单画面
$scene = Scene_Menu.new(5)
return
end
# 按下 C 键的场合下
if Input.trigger?(Input::C)
# 命令窗口光标位置分支
case @command_window.index
when 0 # 记录
when 1 # 返回标题画面
command_to_title
when 2 # 退出
command_shutdown
when 3 # 取消
command_cancel
end
return
end
end
#--------------------------------------------------------------------------
# ● 选择命令 [返回标题画面] 时的处理
#--------------------------------------------------------------------------
def command_to_title
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 淡入淡出 BGM、BGS、ME
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
# 切换到标题画面
$scene = Scene_Title.new
end
#--------------------------------------------------------------------------
# ● 选择命令 [退出] 时的处理
#--------------------------------------------------------------------------
def command_shutdown
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 淡入淡出 BGM、BGS、ME
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
# 退出
$scene = nil
end
#--------------------------------------------------------------------------
# ● 选择命令 [取消] 时的处理
#--------------------------------------------------------------------------
def command_cancel
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到菜单画面
$scene = Scene_Menu.new(5)
#--------------------------------------------------------------------------
# ● 选择命令 [记录] 时的处理
#--------------------------------------------------------------------------
def
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到记录画面
$scene = Scene_Loadsave.new
end
end
end
复制代码
65行上不会弄的说
作者:
忧雪の伤
时间:
2011-2-7 19:11
加多一个处理“def XXXXX”。并在那里输入“XXXXX”
作者:
坚强的羁绊
时间:
2011-2-7 19:13
还是有些不懂
作者:
忧雪の伤
时间:
2011-2-7 19:20
你的写的差不多了啊。
113行def随便加个名称,接着65输入那个名称即可。
作者:
坚强的羁绊
时间:
2011-2-7 19:24
加上后总显示65行错误
作者:
陆娘
时间:
2011-2-7 19:38
#==============================================================================
# ■ Scene_End
#------------------------------------------------------------------------------
# 处理游戏结束画面的类。
#==============================================================================
class Scene_End
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 生成命令窗口
s1 = "记录"
s2 = "返回标题"
s3 = "结束"
s4 = "取消"
@command_window = Window_Command.new(192, [s1, s2, s3, s4])
@command_window.x = 320 - @command_window.width / 2
@command_window.y = 240 - @command_window.height / 2
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入情报
Input.update
# 刷新画面
update
# 如果画面切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@command_window.dispose
# 如果在标题画面切换中的情况下
if $scene.is_a?(Scene_Title)
# 淡入淡出画面
Graphics.transition
Graphics.freeze
end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新命令窗口
@command_window.update
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到菜单画面
$scene = Scene_Menu.new(5)
return
end
# 按下 C 键的场合下
if Input.trigger?(Input::C)
# 命令窗口光标位置分支
case @command_window.index
when 0 # 记录
command_xxxxx
when 1 # 返回标题画面
command_to_title
when 2 # 退出
command_shutdown
when 3 # 取消
command_cancel
end
end
end
#--------------------------------------------------------------------------
# ● 选择命令 [返回标题画面] 时的处理
#--------------------------------------------------------------------------
def command_to_title
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 淡入淡出 BGM、BGS、ME
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
# 切换到标题画面
$scene = Scene_Title.new
end
#--------------------------------------------------------------------------
# ● 选择命令 [退出] 时的处理
#--------------------------------------------------------------------------
def command_shutdown
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 淡入淡出 BGM、BGS、ME
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
# 退出
$scene = nil
end
#--------------------------------------------------------------------------
# ● 选择命令 [取消] 时的处理
#--------------------------------------------------------------------------
def command_cancel
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到菜单画面
$scene = Scene_Menu.new(5)
end
#--------------------------------------------------------------------------
# ● 选择命令 [记录] 时的处理
#--------------------------------------------------------------------------
def command_xxxxx
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到记录画面
$scene = Scene_Loadsave.new
end
end
复制代码
作者:
坚强的羁绊
时间:
2011-2-7 20:01
#==============================================================================
# 分类物品的命令窗口
#==============================================================================
class Window_ItemCommand < Window_Selectable
#———— 初始化 ————
def initialize
super(453, 190, 142, 192)
self.contents = Bitmap.new(width - 32, height - 32)
@item_max = 5
@commands = ["药物类", "武器类", "防具类", "装饰类", "特殊类"]
refresh
self.index = 0
end
#———— 刷新 ————
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color)
end
end
#—— 描绘项目 ——| index:编号,color:颜色——————
def draw_item(index, color)
self.contents.font.color = color
y = index * 32
self.contents.draw_text(4, y, 128, 32, @commands[index])
end
#—— 帮助部分更新 ————
def update_help
@help_window.set_text(@commands[self.index])
end
end
#==============================================================================
# 物品清单窗口
#==============================================================================
class Window_ItemList < Window_Selectable
#———— 初始化 ————
def initialize
super(30, 20, 378, 362)
# @column_max = 2
refresh
self.index = 0
end
#—— 取得现在选择的物品 ——
def item
return @data[self.index]
end
#—— 刷新 ———
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
end
#—— 设置不同类别的物品 ———
def set_item(command)
refresh
#—— 根据现在的选项决定物品 ——
case command
when 0 #药品类
for i in 1...$data_items.size
if ($data_items[i].type == "药物" and $game_party.item_number(i) > 0)
@data.push($data_items[i])
end
end
when 1 #武器类
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
@data.push($data_weapons[i])
end
end
when 2 #防具类
for i in 1...$data_armors.size
if $data_armors[i].kind == 0 and $game_party.armor_number(i) > 0
@data.push($data_armors[i])
end
end
for i in 1...$data_armors.size
if $data_armors[i].kind == 1 and $game_party.armor_number(i) > 0
@data.push($data_armors[i])
end
end
for i in 1...$data_armors.size
if $data_armors[i].kind == 2 and $game_party.armor_number(i) > 0
@data.push($data_armors[i])
end
end
when 3 #装饰类
for i in 1...$data_armors.size
if $data_armors[i].kind == 3 and $game_party.armor_number(i) > 0
@data.push($data_armors[i])
end
end
when 4 #特殊类
for i in 1...$data_items.size
if ($data_items[i].type == "特殊" and $game_party.item_number(i) > 0)
@data.push($data_items[i])
end
end
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
end
#——— 单类物品的个数 ————
def item_number
return @item_max
end
#——— 项目内容的描画 ————
def draw_item(index)
item = @data[index]
#—— 取得具体物品数量 ——
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
#—— 给出物品的颜色 ——
if item.is_a?(RPG::Item)
if $game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
else
self.contents.font.color = normal_color
end
#—— 描绘物体图标、物体名、数量 ——
# x = 4 + index % 2 * 173
# y = index / 2 * 32
x = 4
y = index*32
bitmap = RPG::Cache.icon(item.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, 212, 32, item.name, 0)
self.contents.draw_text(x + 300, y, 16, 32, "×", 1)
self.contents.draw_text(x + 314, y, 24, 32, number.to_s, 2)
end
#——— 更新帮助窗口 ————
def update_help
@help_window.set_text(make_description(self.item))
end
end
#############################################################################
#############################################################################
#==============================================================================
# ■ Scene_Item
#------------------------------------------------------------------------------
# 处理物品画面的类。
#==============================================================================
#############################################################################
#############################################################################
class Scene_Item
#——— 主处理 ————
def main
cmd = Window_Command_New.new($game_party.actors.size)
cmd.index = 1
cmd.active = false
# 右边命令窗口
@itemcommand_window = Window_ItemCommand.new
@itemcommand_window.opacity = HS::OPACITY
@itemcommand_window.y = 672
@item_command_index = @itemcommand_window.index
# 物品窗口
@itemlist_window = Window_ItemList.new
@itemlist_window.opacity = HS::OPACITY
@itemlist_window.active = false
@itemlist_window.set_item(@item_command_index)
@itemlist_window.x = -378
# 帮助窗口
@item_help_window = Window_Help_New.new
@item_help_window.x = -580
@item_help_window.y = 396
@item_help_window.opacity = HS::OPACITY
# 关联帮助窗口
@itemcommand_window.help_window = @item_help_window
@itemlist_window.help_window = @item_help_window
# 目标窗口
@item_target_window = Window_Target.new
@item_target_window.y = 480
@item_target_window.opacity = HS::OPACITY
@item_target_window.visible = false
@item_target_window.active = false
# 目标装备窗口
@item_target_window_equip = Window_Target_Equip.new
@item_target_window_equip.y = 480
@item_target_window_equip.opacity = HS::OPACITY
@item_target_window_equip.visible = false
@item_target_window_equip.active = false
#—— 主循环 ——
Graphics.transition
# 窗口的滑动
for i in 1..8
@item_help_window.x += 76
@itemcommand_window.y -= 60
@itemlist_window.x += 51
if i == 8
@item_help_window.x = 30
@itemcommand_window.y = 190
@itemlist_window.x = 30
end
Graphics.update
end
loop do
Graphics.update
Input.update
# 更新item
update_item_scene
if $scene != self
break
end
end
#—— 释放窗口 ——
# 窗口的滑动
for i in 1..9
@item_help_window.x -= 76
@itemcommand_window.y += 60
@itemlist_window.x -= 51
Graphics.update
end
Graphics.freeze
cmd.dispose
@itemcommand_window.dispose
@itemlist_window.dispose
@item_help_window.dispose
@item_target_window.dispose
@item_target_window_equip.dispose
end
#—— update的定义 ——
def update_item_scene
@itemcommand_window.update
@itemlist_window.update
@item_help_window.update
@item_target_window.update
@item_target_window_equip.update
if @item_command_index != @itemcommand_window.index
@item_command_index = @itemcommand_window.index
@itemlist_window.set_item(@item_command_index)
end
#—— 当某窗体在active的时候,更新之 ——
if @itemcommand_window.active
item_update_itemcommand
return
end
if @itemlist_window.active
item_update_itemlist
return
end
if @item_target_window.active
item_update_target
return
end
if @item_target_window_equip.active
item_update_target_equip
return
end
end # update的
#————具体更新定义————
def item_update_itemcommand
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到菜单画面
$scene = Scene_Menu.new(1)
return
end
if Input.trigger?(Input::C)
if @itemlist_window.item_number == 0
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
@itemcommand_window.active = false
@itemlist_window.active = true
@itemlist_window.index = 0
return
end
end
#————具体更新定义————
def item_update_itemlist
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@itemcommand_window.active = true
@itemlist_window.active = false
@itemlist_window.index = 0
@itemcommand_window.index = @item_command_index
return
end
if Input.trigger?(Input::C)
@item = @itemlist_window.item
if @item.is_a?(RPG::Item)
unless $game_party.item_can_use?(@item.id)
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
if @item.scope >= 3
@itemlist_window.active = false
# 先打开目标窗口的显示,才开始滑动
@item_target_window.visible = true
@item_target_window.active = true
for i in 1..8
@item_target_window.y -= 39
if i==8
@item_target_window.y = 164
end
Graphics.update
end
if @item.scope == 4 || @item.scope == 6
@item_target_window.index = -1
else
@item_target_window.index = 0
end
else
if @item.common_event_id > 0
$game_temp.common_event_id = @item.common_event_id
$game_system.se_play(@item.menu_se)
if @item.consumable
$game_party.lose_item(@item.id, 1)
@itemlist_window.draw_item(@itemlist_window.index)
end
$scene = Scene_Map.new
return
end
end
return
else
$game_system.se_play($data_system.decision_se)
@itemlist_window.active = false
@item_target_window_equip.set_item(@item)
@item_target_window_equip.visible = true
@item_target_window_equip.active = true
for i in 1..8
@item_target_window_equip.y -= 39
if i==8
@item_target_window_equip.y = 164
end
Graphics.update
end
@item_target_window_equip.index = 0
return
end
end
end
def item_update_target_equip
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@itemlist_window.active = true
# 目标窗口滑动,滑动结束后才关闭显示
for i in 1..9
@item_target_window_equip.y += 39
Graphics.update
end
@item_target_window_equip.visible = false
@item_target_window_equip.active = false
@itemlist_window.set_item(@item_command_index)
return
end
if Input.trigger?(Input::C)
target_actor = $game_party.actors[@item_target_window_equip.index]
if target_actor.equippable?(@item) and $game_party.item_can_equip?(target_actor,@item)
# 演奏装备 SE
$game_system.se_play($data_system.equip_se)
if @item.is_a?(RPG::Weapon)
equip_position = 0
elsif @item.kind == 0
equip_position = 1
elsif @item.kind == 1
equip_position = 2
elsif @item.kind == 2
equip_position = 3
elsif @item.kind == 3
equip_position = 4
end
# 固定装备的情况下
if target_actor.equip_fix?(equip_position)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
target_actor.equip(equip_position,@item.id)
@itemlist_window.active = true
# 目标窗口滑动,滑动结束后才关闭显示
for i in 1..9
@item_target_window_equip.y += 39
Graphics.update
end
@item_target_window_equip.visible = false
@item_target_window_equip.active = false
@itemlist_window.draw_item(@itemlist_window.index)
@itemlist_window.set_item(@item_command_index)
else
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
end
end
end
#———— 更新target窗口————
def item_update_target
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
unless $game_party.item_can_use?(@item.id)
@itemlist_window.refresh
end
@itemlist_window.active = true
# 目标窗口滑动,滑动结束后才关闭显示
for i in 1..9
@item_target_window.y += 39
Graphics.update
end
@item_target_window.visible = false
@item_target_window.active = false
@itemlist_window.set_item(@item_command_index)
return
end
if Input.trigger?(Input::C)
if $game_party.item_number(@item.id) == 0
$game_system.se_play($data_system.buzzer_se)
return
end
if @item_target_window.index == -1
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
if @item_target_window.index >= 0
target = $game_party.actors[@item_target_window.index]
used = target.item_effect(@item)
end
if used
$game_system.se_play(@item.menu_se)
if @item.consumable
$game_party.lose_item(@item.id, 1)
@itemlist_window.draw_item(@itemlist_window.index)
@itemlist_window.set_item(@item_command_index)
end
@item_target_window.refresh
if $game_party.all_dead?
$scene = Scene_Gameover.new
return
end
if @item.common_event_id > 0
$game_temp.common_event_id = @item.common_event_id
$scene = Scene_Map.new
return
end
end
unless used
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
复制代码
顺便问一下,这个脚本怎么显示钱数啊
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1