Project1
标题:
求助多周目Scene_Title的设定
[打印本页]
作者:
gaoling0727
时间:
2011-4-2 00:01
标题:
求助多周目Scene_Title的设定
看了XP的教程 实在脚本无能找了半天改成这样 72行出错
是读取游戏的错误 实在不知道怎么办了求好人~!~
还希望请教我想8周目 开头都是一样的 周目区别为 半路分歧换主角
请教最简单的周目方法 只希望半路换主角就行
#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
# 这个类用来执行显示标题画面的程式。
#==============================================================================
class Scene_Title < Scene_Base
#--------------------------------------------------------------------------
# * 主程式
#--------------------------------------------------------------------------
def main
if $BTEST # 战斗测试?
battle_test # 开始战斗测试
else # 正常游戏
super # 正常执行主程式
end
end
#--------------------------------------------------------------------------
# * 程式开始
#--------------------------------------------------------------------------
def start
super
load_database # 加载数据库
create_game_objects # 创建游戏对象
check_continue # 读档可行性判定
create_title_graphic # 创建标题图形
create_command_window # 创建命令窗口
play_title_music # 播放标题画面BGM
end
#--------------------------------------------------------------------------
# * 执行画面过渡显示渐变
#--------------------------------------------------------------------------
def perform_transition
Graphics.transition(20)
end
#--------------------------------------------------------------------------
# * 程式开始后的处理
#--------------------------------------------------------------------------
def post_start
super
open_command_window
end
#--------------------------------------------------------------------------
# * 程式终止前的处理
#--------------------------------------------------------------------------
def pre_terminate
super
close_command_window
end
#--------------------------------------------------------------------------
# * 终止程式
#--------------------------------------------------------------------------
def terminate
super
dispose_command_window
snapshot_for_background
dispose_title_graphic
end
#--------------------------------------------------------------------------
# * 更新帧
#--------------------------------------------------------------------------
def update
super
@command_window.update
if Input.trigger?(Input::C)
case @command_window.index
when 0
if FileTest.exist?("Finished") # 重新轮回
command_renascence
else # 新的剧情
command_new_game
when 1 # 读取存档
command_continue
when 2 # 退出游戏
command_shutdown
end
#--------------------------------------------------------------------------
# * 读取数据
#--------------------------------------------------------------------------
def load_database
$data_actors = load_data("Data/Actors.rvdata")
$data_classes = load_data("Data/Classes.rvdata")
$data_skills = load_data("Data/Skills.rvdata")
$data_items = load_data("Data/Items.rvdata")
$data_weapons = load_data("Data/Weapons.rvdata")
$data_armors = load_data("Data/Armors.rvdata")
$data_enemies = load_data("Data/Enemies.rvdata")
$data_troops = load_data("Data/Troops.rvdata")
$data_states = load_data("Data/States.rvdata")
$data_animations = load_data("Data/Animations.rvdata")
$data_common_events = load_data("Data/CommonEvents.rvdata")
$data_system = load_data("Data/System.rvdata")
$data_areas = load_data("Data/Areas.rvdata")
end
#--------------------------------------------------------------------------
# * 读取数据(战斗测试用)
#--------------------------------------------------------------------------
def load_bt_database
$data_actors = load_data("Data/BT_Actors.rvdata")
$data_classes = load_data("Data/BT_Classes.rvdata")
$data_skills = load_data("Data/BT_Skills.rvdata")
$data_items = load_data("Data/BT_Items.rvdata")
$data_weapons = load_data("Data/BT_Weapons.rvdata")
$data_armors = load_data("Data/BT_Armors.rvdata")
$data_enemies = load_data("Data/BT_Enemies.rvdata")
$data_troops = load_data("Data/BT_Troops.rvdata")
$data_states = load_data("Data/BT_States.rvdata")
$data_animations = load_data("Data/BT_Animations.rvdata")
$data_common_events = load_data("Data/BT_CommonEvents.rvdata")
$data_system = load_data("Data/BT_System.rvdata")
end
#--------------------------------------------------------------------------
# * 创建游戏对象
#--------------------------------------------------------------------------
def create_game_objects
$game_temp = Game_Temp.new
$game_message = Game_Message.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
end
#--------------------------------------------------------------------------
# * 读档可行性判定
#--------------------------------------------------------------------------
def check_continue
@continue_enabled = (Dir.glob('Save*.rvdata').size > 0)
end
#--------------------------------------------------------------------------
# * 创建标题图形
#--------------------------------------------------------------------------
def create_title_graphic
@sprite = Sprite.new
@sprite.bitmap = Cache.system("Title")
if filetet.exist?("finished.rxdata")
s1 = Vocab::new_game
s2 = Vocab::continue
s3 = Vocab::shutdown
S4 = Vocab::renascence
@command_window = Window_Command.new(172, [s1, s2, s3.s4])
@command_window.x = (544 - @command_window.width) / 2
@command_window.y = 288
else
s1 = Vocab::new_game
s2 = Vocab::continue
s3 = Vocab::shutdown
@command_window = Window_Command.new(172, [s1, s2, s3])
@command_window.x = (544 - @command_window.width) / 2
@command_window.y = 288
end
#--------------------------------------------------------------------------
# * 清除标题图形
#--------------------------------------------------------------------------
def dispose_title_graphic
@sprite.bitmap.dispose
@sprite.dispose
end
#--------------------------------------------------------------------------
# * 创建命令窗口
#--------------------------------------------------------------------------
def create_command_window
if @continue_enabled # 如果[读取存档]可用
@command_window.index = 1 # 移动光标至该命令项目上
else # 如果[读取存档]不可用
@command_window.draw_item(1, false) # 半透明显示该命令项目
end
@command_window.openness = 0
@command_window.open
end
#--------------------------------------------------------------------------
# * 清除命令窗口
#--------------------------------------------------------------------------
def dispose_command_window
@command_window.dispose
end
#--------------------------------------------------------------------------
# * 展开命令窗口
#--------------------------------------------------------------------------
def open_command_window
@command_window.open
begin
@command_window.update
Graphics.update
end until @command_window.openness == 255
end
#--------------------------------------------------------------------------
# * 合拢命令窗口
#--------------------------------------------------------------------------
def close_command_window
@command_window.close
begin
@command_window.update
Graphics.update
end until @command_window.openness == 0
end
#--------------------------------------------------------------------------
# * 播放标题画面BGM
#--------------------------------------------------------------------------
def play_title_music
$data_system.title_bgm.play
RPG::BGS.stop
RPG::ME.stop
end
#--------------------------------------------------------------------------
# * 检查玩家起点事件块是否存在
#--------------------------------------------------------------------------
def confirm_player_location
if $data_system.start_map_id == 0
print "玩家起始位置没有被指定。"
exit
end
end
#--------------------------------------------------------------------------
# * 命令项目:新的剧情
#--------------------------------------------------------------------------
def command_new_game
confirm_player_location
Sound.play_decision
$game_party.setup_starting_members # 队伍初期阵容设置
$game_map.setup($data_system.start_map_id) # 玩家起始位置设置
$game_player.moveto($data_system.start_x, $data_system.start_y)
$game_player.refresh
$scene = Scene_Map.new
RPG::BGM.fade(1500)
close_command_window
Graphics.fadeout(60)
Graphics.wait(40)
Graphics.frame_count = 0
if filetet.exist?("finished.rxdata")
File = file.open("Finished.rxdata","rb")
Marshal.dump($game_variables,file)
file.close
else
$game_variables =Game_Variablesn.new
end
RPG::BGM.stop
$game_map.autoplay
end #--------------------------------------------------------------------------
# * 命令项目:重新轮回
#--------------------------------------------------------------------------
def command_renascence
confirm_player_location
Sound.play_decision
$game_party.setup_starting_members # 队伍初期阵容设置
$game_map.setup($data_system.start_map_id) # 玩家起始位置设置
$game_player.moveto($data_system.start_x, $data_system.start_y)
$game_player.refresh
$scene = Scene_Map.new
RPG::BGM.fade(1500)
close_command_window
Graphics.fadeout(60)
Graphics.wait(40)
Graphics.frame_count = 0
if filetet.exist?("finished.rxdata")
File = file.open("Finished.rxdata","rb")
Marshal.dump($game_variables,file)
file.close
else
$game_variables =Game_Variablesn.new
end
RPG::BGM.stop
$game_map.autoplay
end
#--------------------------------------------------------------------------
# * 命令项目:读取存档
#--------------------------------------------------------------------------
def command_continue
if @continue_enabled
Sound.play_decision
$scene = Scene_File.new(false, true, false)
else
Sound.play_buzzer
end
end
#--------------------------------------------------------------------------
# * 命令项目:退出游戏
#--------------------------------------------------------------------------
def command_shutdown
Sound.play_decision
RPG::BGM.fade(800)
RPG::BGS.fade(800)
RPG::ME.fade(800)
$scene = nil
end
#--------------------------------------------------------------------------
# * 战斗测试
#--------------------------------------------------------------------------
def battle_test
load_bt_database # 从数据库中加载战斗测试所需数据
create_game_objects # 创建游戏对象
Graphics.frame_count = 0 # 初始化游戏时间
$game_party.setup_battle_test_members
$game_troop.setup($data_system.test_troop_id)
$game_troop.can_escape = true
$game_system.battle_bgm.play
snapshot_for_background
$scene = Scene_Battle.new
end
dsu_plus_rewardpost_czw
作者:
祸忌
时间:
2011-4-2 00:24
提示:
作者被禁止或删除 内容自动屏蔽
作者:
一箭烂YiJL
时间:
2011-4-2 11:04
72行错误是因为68行的if判断最后没有下end,所以应该:
if FileTest.exist?("Finished") # 重新轮回
command_renascence
else # 新的剧情
command_new_game
end
复制代码
改完后,多了一行。
然后会说146行错误,那是因为Vacab没有这个词。
那么开一个脚本页,然后输入:
module Vocab
renascence = "重新轮回"
end
复制代码
还有另外就是S4不能用,因为大写是常量,应该改为:
s4 = Vocab::renascence
复制代码
之后回到脚本。147行有问题,不能用"."来分割,应该用",",改为:
@command_window = Window_Command.new(172, [s1, s2, s3, s4])
复制代码
之后很有问题的是:filetet.exist? # 有这个函数么?
将filetet.exist?全部应该改为FileTest.exist?,
你可以"右键"-->"取代",然后操作取代掉,
或者搜索手动取代。
238行和264行大小写混乱及常量问题,应改为:
file = file.open("finished.rxdata","rb")
复制代码
309添加end
update方法(函数)最后应该添加2个end
create_title_graphic最后也应该添加一个end
然后测试就有成果了!!!
但是新的游戏会杯具= =(245行)
那么245行就改为:
load_database
复制代码
再来一次,没问题!:victory:
但是很遗憾的告诉你,你目前的功能跟不同的标题没有任何分别= =,
那么告诉你什么用处吧,当你的文件夹下有:finished.
rx
data
的话,那么就会有两个可能性:
新的开始
将$game_variables储存
多一个选择:"重新轮回"
也是储存$game_variables
但是确定的是那时候$game_variables还没建立= =
更何况finished.
rx
data是xp的存档格式= =
那么将他改为finished.
rv
data
最后
有关那个finished.rvdata的做法以及用法可以后来找我帮你解决,
那么如果是看不明白上面的解决方法,我就发脚本了:
#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
# 这个类用来执行显示标题画面的程式。
#==============================================================================
class Scene_Title < Scene_Base
#--------------------------------------------------------------------------
# * 主程式
#--------------------------------------------------------------------------
def main
if $BTEST # 战斗测试?
battle_test # 开始战斗测试
else # 正常游戏
super # 正常执行主程式
end
end
#--------------------------------------------------------------------------
# * 程式开始
#--------------------------------------------------------------------------
def start
super
load_database # 加载数据库
create_game_objects # 创建游戏对象
check_continue # 读档可行性判定
create_title_graphic # 创建标题图形
create_command_window # 创建命令窗口
play_title_music # 播放标题画面BGM
end
#--------------------------------------------------------------------------
# * 执行画面过渡显示渐变
#--------------------------------------------------------------------------
def perform_transition
Graphics.transition(20)
end
#--------------------------------------------------------------------------
# * 程式开始后的处理
#--------------------------------------------------------------------------
def post_start
super
open_command_window
end
#--------------------------------------------------------------------------
# * 程式终止前的处理
#--------------------------------------------------------------------------
def pre_terminate
super
close_command_window
end
#--------------------------------------------------------------------------
# * 终止程式
#--------------------------------------------------------------------------
def terminate
super
dispose_command_window
snapshot_for_background
dispose_title_graphic
end
#--------------------------------------------------------------------------
# * 更新帧
#--------------------------------------------------------------------------
def update
super
@command_window.update
if Input.trigger?(Input::C)
case @command_window.index
when 0
if FileTest.exist?("Finished") # 重新轮回
command_renascence
else # 新的剧情
command_new_game
end
when 1 # 读取存档
command_continue
when 2 # 退出游戏
command_shutdown
end
end
end
#--------------------------------------------------------------------------
# * 读取数据
#--------------------------------------------------------------------------
def load_database
$data_actors = load_data("Data/Actors.rvdata")
$data_classes = load_data("Data/Classes.rvdata")
$data_skills = load_data("Data/Skills.rvdata")
$data_items = load_data("Data/Items.rvdata")
$data_weapons = load_data("Data/Weapons.rvdata")
$data_armors = load_data("Data/Armors.rvdata")
$data_enemies = load_data("Data/Enemies.rvdata")
$data_troops = load_data("Data/Troops.rvdata")
$data_states = load_data("Data/States.rvdata")
$data_animations = load_data("Data/Animations.rvdata")
$data_common_events = load_data("Data/CommonEvents.rvdata")
$data_system = load_data("Data/System.rvdata")
$data_areas = load_data("Data/Areas.rvdata")
end
#--------------------------------------------------------------------------
# * 读取数据(战斗测试用)
#--------------------------------------------------------------------------
def load_bt_database
$data_actors = load_data("Data/BT_Actors.rvdata")
$data_classes = load_data("Data/BT_Classes.rvdata")
$data_skills = load_data("Data/BT_Skills.rvdata")
$data_items = load_data("Data/BT_Items.rvdata")
$data_weapons = load_data("Data/BT_Weapons.rvdata")
$data_armors = load_data("Data/BT_Armors.rvdata")
$data_enemies = load_data("Data/BT_Enemies.rvdata")
$data_troops = load_data("Data/BT_Troops.rvdata")
$data_states = load_data("Data/BT_States.rvdata")
$data_animations = load_data("Data/BT_Animations.rvdata")
$data_common_events = load_data("Data/BT_CommonEvents.rvdata")
$data_system = load_data("Data/BT_System.rvdata")
end
#--------------------------------------------------------------------------
# * 创建游戏对象
#--------------------------------------------------------------------------
def create_game_objects
$game_temp = Game_Temp.new
$game_message = Game_Message.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
end
#--------------------------------------------------------------------------
# * 读档可行性判定
#--------------------------------------------------------------------------
def check_continue
@continue_enabled = (Dir.glob('Save*.rvdata').size > 0)
end
#--------------------------------------------------------------------------
# * 创建标题图形
#--------------------------------------------------------------------------
def create_title_graphic
@sprite = Sprite.new
@sprite.bitmap = Cache.system("Title")
if FileTest.exist?("finished.rvdata")
s1 = Vocab::new_game
s2 = Vocab::continue
s3 = Vocab::shutdown
s4 = Vocab::renascence
@command_window = Window_Command.new(172, [s1, s2, s3, s4])
@command_window.x = (544 - @command_window.width) / 2
@command_window.y = 288
else
s1 = Vocab::new_game
s2 = Vocab::continue
s3 = Vocab::shutdown
@command_window = Window_Command.new(172, [s1, s2, s3])
@command_window.x = (544 - @command_window.width) / 2
@command_window.y = 288
end
end
#--------------------------------------------------------------------------
# * 清除标题图形
#--------------------------------------------------------------------------
def dispose_title_graphic
@sprite.bitmap.dispose
@sprite.dispose
end
#--------------------------------------------------------------------------
# * 创建命令窗口
#--------------------------------------------------------------------------
def create_command_window
if @continue_enabled # 如果[读取存档]可用
@command_window.index = 1 # 移动光标至该命令项目上
else # 如果[读取存档]不可用
@command_window.draw_item(1, false) # 半透明显示该命令项目
end
@command_window.openness = 0
@command_window.open
end
#--------------------------------------------------------------------------
# * 清除命令窗口
#--------------------------------------------------------------------------
def dispose_command_window
@command_window.dispose
end
#--------------------------------------------------------------------------
# * 展开命令窗口
#--------------------------------------------------------------------------
def open_command_window
@command_window.open
begin
@command_window.update
Graphics.update
end until @command_window.openness == 255
end
#--------------------------------------------------------------------------
# * 合拢命令窗口
#--------------------------------------------------------------------------
def close_command_window
@command_window.close
begin
@command_window.update
Graphics.update
end until @command_window.openness == 0
end
#--------------------------------------------------------------------------
# * 播放标题画面BGM
#--------------------------------------------------------------------------
def play_title_music
$data_system.title_bgm.play
RPG::BGS.stop
RPG::ME.stop
end
#--------------------------------------------------------------------------
# * 检查玩家起点事件块是否存在
#--------------------------------------------------------------------------
def confirm_player_location
if $data_system.start_map_id == 0
print "玩家起始位置没有被指定。"
exit
end
end
#--------------------------------------------------------------------------
# * 命令项目:新的剧情
#--------------------------------------------------------------------------
def command_new_game
confirm_player_location
Sound.play_decision
$game_party.setup_starting_members # 队伍初期阵容设置
$game_map.setup($data_system.start_map_id) # 玩家起始位置设置
$game_player.moveto($data_system.start_x, $data_system.start_y)
$game_player.refresh
$scene = Scene_Map.new
RPG::BGM.fade(1500)
close_command_window
Graphics.fadeout(60)
Graphics.wait(40)
Graphics.frame_count = 0
if FileTest.exist?("finished.rvdata")
file = file.open("finished.rvdata","rb")
Marshal.dump($game_variables,file)
file.close
else
load_database
end
RPG::BGM.stop
$game_map.autoplay
end#--------------------------------------------------------------------------
# * 命令项目:重新轮回
#--------------------------------------------------------------------------
def command_renascence
confirm_player_location
Sound.play_decision
$game_party.setup_starting_members # 队伍初期阵容设置
$game_map.setup($data_system.start_map_id) # 玩家起始位置设置
$game_player.moveto($data_system.start_x, $data_system.start_y)
$game_player.refresh
$scene = Scene_Map.new
RPG::BGM.fade(1500)
close_command_window
Graphics.fadeout(60)
Graphics.wait(40)
Graphics.frame_count = 0
if FileTest.exist?("finished.rvdata")
file = file.open("finished.rvdata","rb")
Marshal.dump($game_variables,file)
file.close
else
$game_variables =Game_Variablesn.new
end
RPG::BGM.stop
$game_map.autoplay
end
#--------------------------------------------------------------------------
# * 命令项目:读取存档
#--------------------------------------------------------------------------
def command_continue
if @continue_enabled
Sound.play_decision
$scene = Scene_File.new(false, true, false)
else
Sound.play_buzzer
end
end
#--------------------------------------------------------------------------
# * 命令项目:退出游戏
#--------------------------------------------------------------------------
def command_shutdown
Sound.play_decision
RPG::BGM.fade(800)
RPG::BGS.fade(800)
RPG::ME.fade(800)
$scene = nil
end
#--------------------------------------------------------------------------
# * 战斗测试
#--------------------------------------------------------------------------
def battle_test
load_bt_database # 从数据库中加载战斗测试所需数据
create_game_objects # 创建游戏对象
Graphics.frame_count = 0 # 初始化游戏时间
$game_party.setup_battle_test_members
$game_troop.setup($data_system.test_troop_id)
$game_troop.can_escape = true
$game_system.battle_bgm.play
snapshot_for_background
$scene = Scene_Battle.new
end
end
module Vocab
renascence = "重新轮回"
end
复制代码
作者:
gaoling0727
时间:
2011-4-2 18:19
啊我明白一点 是不是现在新游戏和新选项是一个功能 如果把脚本的240~247多余的地方删掉 然后新的剧情是不是就正常了
作者:
一箭烂YiJL
时间:
2011-4-2 18:29
回复
gaoling0727
的帖子
是的,240-247应该删掉。
但是新选项是不是想读取公用的变量?(你现在是储存)
如果是读取请将266-272改为:
file = file.open("finished.rvdata","rb")
Marshal.load($game_variables)
file.close
复制代码
作者:
gaoling0727
时间:
2011-4-2 18:42
再次麻烦再次问一下 正常通关怎么设置对话脚本?
File = file.open("Finished.rvdata","wb")
Marshal.dump($game_variables,file)
Marshal.dump($game_actors,file)
file.close
对么?
我一跟设置这个事件脚本的NPC说话就出现什么
Name Error.
undefinde local variable or method "file" for #<Game Interpretre:0x13 cd950>
作者:
一箭烂YiJL
时间:
2011-4-3 22:04
回复
gaoling0727
的帖子
大小写不要乱用,大写是常量,无法变。
还有是File.open,不是file.open。
file = File.open("Finished.txt","wb")
Marshal.dump($game_variables,file)
Marshal.dump($game_actors,file)
file.close
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1