#============================================================================== # 本脚本来自www.66RPG.com,使用和转载请保留此信息 #============================================================================== class Scene_Save #-------------------------------------------------------------------------- # ● 写入存档数据 # file : 写入用文件对像 (已经打开) #-------------------------------------------------------------------------- def write_save_data(file) # 生成描绘存档文件用的角色图形 characters = [] for i in 0...[$game_party.actors.size,4].min 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 class Scene_Battle #-------------------------------------------------------------------------- # ● 设置物品或特技对像方的战斗者 # scope : 特技或者是物品的范围 #-------------------------------------------------------------------------- def set_target_battlers(scope) # 行动方的战斗者是敌人的情况下 if @active_battler.is_a?(Game_Enemy) # 效果范围分支 case scope when 1 # 敌单体 index = @active_battler.current_action.target_index @target_battlers.push($game_party.smooth_target_actor(index)) when 2 # 敌全体 for actor in 0...[$game_party.actors.size,4].min if $game_party.actors[actor].exist? @target_battlers.push($game_party.actors[actor]) end end when 3 # 我方单体 index = @active_battler.current_action.target_index @target_battlers.push($game_troop.smooth_target_enemy(index)) when 4 # 我方全体 for enemy in $game_troop.enemies if enemy.exist? @target_battlers.push(enemy) end end when 5 # 我方单体 (HP 0) index = @active_battler.current_action.target_index enemy = $game_troop.enemies[index] if enemy != nil and enemy.hp0? @target_battlers.push(enemy) end when 6 # 我方全体 (HP 0) for enemy in $game_troop.enemies if enemy != nil and enemy.hp0? @target_battlers.push(enemy) end end when 7 # 使用者 @target_battlers.push(@active_battler) end end # 行动方的战斗者是角色的情况下 if @active_battler.is_a?(Game_Actor) # 效果范围分支 case scope when 1 # 敌单体 index = @active_battler.current_action.target_index @target_battlers.push($game_troop.smooth_target_enemy(index)) when 2 # 敌全体 for enemy in $game_troop.enemies if enemy.exist? @target_battlers.push(enemy) end end when 3 # 我方单体 index = @active_battler.current_action.target_index @target_battlers.push($game_party.smooth_target_actor(index)) when 4 # 我方全体 for actor in 0...[$game_party.actors.size,4].min if $game_party.actors[actor].exist? @target_battlers.push($game_party.actors[actor]) end end when 5 # 我方单体 (HP 0) index = @active_battler.current_action.target_index actor = $game_party.actors[index] if actor != nil and actor.hp0? @target_battlers.push(actor) end when 6 # 我方全体 (HP 0) for actor in 0...[$game_party.actors.size,4].min if $game_party.actors[actor] != nil and $game_party.actors[actor].hp0? @target_battlers.push($game_party.actors[actor]) end end when 7 # 使用者 @target_battlers.push(@active_battler) end end end #-------------------------------------------------------------------------- # ● 生成行动循序 #-------------------------------------------------------------------------- def make_action_orders # 初始化序列 @action_battlers @action_battlers = [] # 添加敌人到 @action_battlers 序列 for enemy in $game_troop.enemies @action_battlers.push(enemy) end # 添加角色到 @action_battlers 序列 for actor in 0...[$game_party.actors.size,4].min @action_battlers.push($game_party.actors[actor]) end # 确定全体的行动速度 for battler in @action_battlers battler.make_action_speed end # 按照行动速度从大到小排列 @action_battlers.sort! {|a,b| b.current_action.speed - a.current_action.speed } end #-------------------------------------------------------------------------- # ● 开始结束战斗回合 #-------------------------------------------------------------------------- def start_phase5 # 转移到回合 5 @phase = 5 # 演奏战斗结束 ME $game_system.me_play($game_system.battle_end_me) # 还原为战斗开始前的 BGM $game_system.bgm_play($game_temp.map_bgm) # 初始化 EXP、金钱、宝物 exp = 0 gold = 0 treasures = [] # 循环 for enemy in $game_troop.enemies # 敌人不是隐藏状态的情况下 unless enemy.hidden # 获得 EXP、增加金钱 exp += enemy.exp gold += enemy.gold # 出现宝物判定 if rand(100) < enemy.treasure_prob if enemy.item_id > 0 treasures.push($data_items[enemy.item_id]) end if enemy.weapon_id > 0 treasures.push($data_weapons[enemy.weapon_id]) end if enemy.armor_id > 0 treasures.push($data_armors[enemy.armor_id]) end end end end # 限制宝物数为 6 个 treasures = treasures[0..5] # 获得 EXP for i in 0...[$game_party.actors.size,4].min actor = $game_party.actors[i] if actor.cant_get_exp? == false last_level = actor.level actor.exp += exp if actor.level > last_level @status_window.level_up(i) end end end # 获得金钱 $game_party.gain_gold(gold) # 获得宝物 for item in treasures case item when RPG::Item $game_party.gain_item(item.id, 1) when RPG::Weapon $game_party.gain_weapon(item.id, 1) when RPG::Armor $game_party.gain_armor(item.id, 1) end end # 生成战斗结果窗口 @result_window = Window_BattleResult.new(exp, gold, treasures) # 设置等待计数 @phase5_wait_count = 100 end #-------------------------------------------------------------------------- # ● 转到输入下一个角色的命令 #-------------------------------------------------------------------------- def phase3_next_actor # 循环 begin # 角色的明灭效果 OFF if @active_battler != nil @active_battler.blink = false end # 最后的角色的情况 if @actor_index == [$game_party.actors.size-1,3].min # 开始主回合 start_phase4 return end # 推进角色索引 @actor_index += 1 @active_battler = $game_party.actors[@actor_index] @active_battler.blink = true # 如果角色是在无法接受指令的状态就再试 end until @active_battler.inputable? # 设置角色的命令窗口 phase3_setup_command_window end end class Arrow_Actor < Arrow_Base #-------------------------------------------------------------------------- # ● 刷新画面 #-------------------------------------------------------------------------- def update super # 光标右 if Input.repeat?(Input::RIGHT) $game_system.se_play($data_system.cursor_se) @index += 1 @index %= [$game_party.actors.size,4].min end # 光标左 if Input.repeat?(Input::LEFT) $game_system.se_play($data_system.cursor_se) @index += $game_party.actors.size - 1 @index %= [$game_party.actors.size,4].min end # 设置活动块坐标 if self.actor != nil self.x = self.actor.screen_x self.y = self.actor.screen_y end end end #============================================================================== # ■ Window_Target #------------------------------------------------------------------------------ # 物品画面与特技画面的、使用对像角色选择窗口。 #============================================================================== class Window_Target < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对像 #-------------------------------------------------------------------------- def initialize super(0, 0, 336, 480) self.contents = Bitmap.new(width - 32, $game_party.actors.size*112) self.z += 10 @item_max = $game_party.actors.size @top_row = 0 refresh end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh self.contents.clear for i in 0...$game_party.actors.size x = 4 y = i * 112 actor = $game_party.actors[i] draw_actor_name(actor, x, y) draw_actor_class(actor, x + 144, y) draw_actor_level(actor, x + 8, y + 32) draw_actor_state(actor, x + 8, y + 64) draw_actor_hp(actor, x + 152, y + 32) draw_actor_sp(actor, x + 152, y + 64) end end #-------------------------------------------------------------------------- # ● 刷新光标矩形 #-------------------------------------------------------------------------- def update_cursor_rect # 光标位置 -1 为全选、-2 以下为单独选择 (使用者自身) if @index <= -2 self.cursor_rect.set(0, (@index + 10) * 112, self.width - 32, 96) elsif @index == -1 self.cursor_rect.set(0, 0, self.width - 32, @item_max * 112 - 20) else tpy = @index * 112 - self.oy self.cursor_rect.set(0, tpy, self.width - 32, 96) if @index < @top_row @top_row = @index self.oy = @top_row *112 end if @index > @top_row+3 @top_row = @index-3 self.oy = @top_row *112 end end end end #============================================================================== # ■ Window_MenuStatus #------------------------------------------------------------------------------ # 显示菜单画面和同伴状态的窗口。 #============================================================================== class Window_MenuStatus < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化目标 #-------------------------------------------------------------------------- def initialize super(0, 0, 480, 480) self.contents = Bitmap.new(width - 32, $game_party.actors.size*112) refresh @top_row = 0 self.active = false self.index = -1 end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh self.contents.clear @item_max = $game_party.actors.size for i in 0...$game_party.actors.size x = 64 y = i * 112 if i <=3 self.contents.font.color = Color.new(255,255,0,255) self.contents.draw_text(x,y,340,32,"[出战]",2) self.contents.font.color = normal_color else self.contents.font.color = Color.new(128,128,128,255) self.contents.draw_text(x,y,340,32,"[待机]",2) self.contents.font.color = normal_color end actor = $game_party.actors[i] draw_actor_graphic(actor, x - 40, y + 80) draw_actor_name(actor, x, y) draw_actor_class(actor, x + 144, y) draw_actor_level(actor, x, y + 32) draw_actor_state(actor, x + 90, y + 32) draw_actor_exp(actor, x, y + 64) draw_actor_hp(actor, x + 236, y + 32) draw_actor_sp(actor, x + 236, y + 64) end end #-------------------------------------------------------------------------- # ● 刷新光标矩形 #-------------------------------------------------------------------------- def update_cursor_rect if @index < 0 self.cursor_rect.empty else tpy = @index * 112 - self.oy self.cursor_rect.set(0, tpy, self.width - 32, 96) if @index < @top_row @top_row = @index self.oy = @top_row *112 end if @index > @top_row+3 @top_row = @index-3 self.oy = @top_row *112 end end end end class Game_Party #-------------------------------------------------------------------------- # ● 全灭判定 #-------------------------------------------------------------------------- def all_dead? # 同伴人数为 0 的情况下 if $game_party.actors.size == 0 return false end # 同伴中无人 HP 在 0 以上 for i in 0..3 if @actors[i] != nil and@actors[i].hp >0 return false end end # 全灭 return true end #-------------------------------------------------------------------------- # ● 加入同伴 # actor_id : 角色 ID #-------------------------------------------------------------------------- def add_actor(actor_id) # 获取角色 actor = $game_actors[actor_id] # 同伴人数未满 4 人、本角色不在队伍中的情况下 if not @actors.include?(actor) # 添加角色 @actors.push(actor) # 还原主角 $game_player.refresh end end end #============================================================================== # 本脚本来自www.66RPG.com,使用和转载请保留此信息 #============================================================================== class Scene_Menu # -------------------------------- def initialize(menu_index = 0) @menu_index = menu_index @changer = 0 @where = 0 @checker = 0 end # -------------------------------- def main s1 = $data_system.words.item s2 = $data_system.words.skill s3 = $data_system.words.equip s4 = "状态" s5 = "储存进度" s6 = "离开游戏" s7 = "调整队伍" s8 = "升级加点" s9 = "人物介绍" @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7, s8, s9]) @command_window.index = @menu_index if $game_party.actors.size == 0 @command_window.disable_item(0) @command_window.disable_item(1) @command_window.disable_item(2) @command_window.disable_item(3) end if $game_system.save_disabled @command_window.disable_item(4) end if $game_party.actors.size == 1 @command_window.disable_item(6) end @playtime_window = Window_PlayTime.new @playtime_window.x = 0 @playtime_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 @command_window.dispose @playtime_window.dispose @gold_window.dispose @status_window.dispose end # -------------------------------- def update @command_window.update @playtime_window.update @gold_window.update @status_window.update if @command_window.active update_command return end if @status_window.active update_status return end end # -------------------------------- def update_command if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) $scene = Scene_Map.new return end if Input.trigger?(Input::C) if $game_party.actors.size == 0 and @command_window.index < 4 $game_system.se_play($data_system.buzzer_se) return end if $game_party.actors.size == 1 and @command_window.index ==6 $game_system.se_play($data_system.buzzer_se) return end case @command_window.index when 0 $game_system.se_play($data_system.decision_se) $scene = Scene_Item.new when 1 $game_system.se_play($data_system.decision_se) @command_window.active = false @status_window.active = true @status_window.index = 0 when 2 $game_system.se_play($data_system.decision_se) @command_window.active = false @status_window.active = true @status_window.index = 0 when 3 $game_system.se_play($data_system.decision_se) @command_window.active = false @status_window.active = true @status_window.index = 0 when 4 if $game_system.save_disabled $game_system.se_play($data_system.buzzer_se) return end $game_system.se_play($data_system.decision_se) $scene = Scene_Save.new when 5 $game_system.se_play($data_system.decision_se) $scene = Scene_End.new when 6 $game_system.se_play($data_system.decision_se) @checker = 0 @command_window.active = false @status_window.active = true @status_window.index = 0 when 7 $game_system.se_play($data_system.decision_se) @command_window.active = false @status_window.active = true @status_window.index = 0 when 8
|