module Vocab BattleParty = "队伍" end class Scene_Equip < Scene_Base #-------------------------------------------------------------------------- # * 战斗时更换装备,返回战斗场景 #-------------------------------------------------------------------------- def return_scene if $game_temp.in_battle $scene = Scene_Battle.new else $scene = Scene_Menu.new(2) end end end class Window_BattleMessage < Window_Message # 设置战斗信息显示的最大行数 MAX_LINE = 4 #-------------------------------------------------------------------------- # * 战斗信息窗口 初始化 #-------------------------------------------------------------------------- def initialize super self.openness = 255 # 设置窗口可见性 self.back_opacity = 0 # 设置窗口不透明度 @lines = [] self.x = -10 self.y = 112 self.width = 566 self.height =400 refresh end #-------------------------------------------------------------------------- # * 绘制战斗信息 index : Line number #-------------------------------------------------------------------------- def draw_line(index) rect = Rect.new(4, index * WLH, contents.width - 4, WLH) self.contents.font.color = normal_color self.contents.draw_text(rect, @lines[index]) end #-------------------------------------------------------------------------- # * 刷新信息显示 #-------------------------------------------------------------------------- def refresh self.contents.clear for i in 0...@lines.size draw_line(i) end end end class Window_TargetEnemy < Window_Base #-------------------------------------------------------------------------- # * 初始化 敌人选择光标窗口 #-------------------------------------------------------------------------- def initialize super(0, 0, 80, 80) self.back_opacity = 75 # 设置窗口不透明度 self.opacity = 255 # 设置窗口内容不透明 @alive_enemies = get_alive_enemies end #-------------------------------------------------------------------------- # * 获取活着的敌人实例 #-------------------------------------------------------------------------- def get_alive_enemies alive_enemies = [] $game_troop.members.each do |enemy| alive_enemies.push(enemy) if enemy.exist? && !enemy.dead? end alive_enemies end #-------------------------------------------------------------------------- # * 获取并绘制敌人的状态图标 #-------------------------------------------------------------------------- def draw_enemy_state(ememy_index) self.contents.clear count = 0 x = 0 y = 0 for state in @alive_enemies[ememy_index].states draw_icon(state.icon_index, x, y) count +=1 if count == 2 x = 0 y += 24 count = 0 else x += 24 end end end end class Window_TurnCount < Window_Command # 自定义类,用于实现战斗回合的显示 # #-------------------------------------------------------------------------- # * 回合显示窗口 初始化 #-------------------------------------------------------------------------- def initialize s1 = $game_troop.turn_count + 1 s2 = "回合" super(128,[s1, s2], 2, 1) draw_item(0, true) draw_item(1, true) end end class Window_BattleStatus < Window_Selectable #-------------------------------------------------------------------------- # * 角色状态窗口 初始化 #-------------------------------------------------------------------------- def initialize super(126, -10, 420, 128, spacing = 0) refresh self.active = false end #-------------------------------------------------------------------------- # * 绘制角色状态窗口的项目 #-------------------------------------------------------------------------- def draw_item(index) rect = item_rect(index) rect.x += 4 rect.width -= 8 self.contents.clear_rect(rect) self.contents.font.color = normal_color actor = $game_party.members[index] draw_actor_name(actor, 4, rect.y) draw_actor_state(actor, 80, rect.y, 120) draw_actor_hp(actor, 210, rect.y, 90) draw_actor_mp(actor, 310, rect.y, 70) end end class Window_ActorCommand < Window_Command #-------------------------------------------------------------------------- # * 角色指令菜单窗口 初始化 #-------------------------------------------------------------------------- def initialize super(128, [], 2, 2) self.active = false end end class Window_PartyCommand < Window_Command #-------------------------------------------------------------------------- # * 战斗初始指令窗口 初始化 (只有第一回合可管理队伍) #-------------------------------------------------------------------------- def initialize s1 = Vocab::fight s2 = Vocab::equip s3 = Vocab::BattleParty s4 = Vocab::escape super(128, [s1, s2, s3, s4], 2, 2) draw_item(0, true) draw_item(1, true) if $game_troop.turn_count == 0 draw_item(2, true) else draw_item(2, false) end draw_item(3, $game_troop.can_escape) self.active = false end end class Scene_Battle < Scene_Base # 定义实例变量用于全局调用 attr_accessor :draw_count #-------------------------------------------------------------------------- # * 战斗场景开始处理 #-------------------------------------------------------------------------- def start super @draw_count = 0 # 绘制行走图的切换开关 $game_temp.in_battle = true @spriteset = Spriteset_Battle.new @message_window = Window_BattleMessage.new @action_battlers = [] create_info_viewport end #-------------------------------------------------------------------------- # * 更新 #-------------------------------------------------------------------------- def update super update_basic(true) update_info_viewport # 更新信息视窗 @turnCount_window.visible = true if $game_message.visible @info_viewport.visible = false @status_window.visible = true @status_window.refresh @message_window.visible = true end unless $game_message.visible # 消息显示的情况之外 draw_actor_character # 绘制行走图 @draw_count += 1 return if judge_win_loss # 确定输赢结果 update_scene_change if @target_enemy_window != nil update_target_enemy_selection # 选择目标敌人 elsif @target_actor_window != nil update_target_actor_selection # 选择目标角色 elsif @skill_window != nil update_skill_selection # 选择技能 elsif @item_window != nil update_item_selection # 选择道具 elsif @party_command_window.active update_party_command_selection # 战斗初始指令窗口 elsif @status_window.active update_actor_selection # 角色更换装备需要进行角色选择 elsif @actor_command_window.active update_actor_command_selection # 选择角色窗口 else process_battle_event # 战斗事件处理 process_action # 战斗动作 @status_window.refresh # 刷新角色状态信息 process_battle_event # 战斗事件处理 end end end #-------------------------------------------------------------------------- # * 创建信息显示视窗 #-------------------------------------------------------------------------- def create_info_viewport @info_viewport = Viewport.new(0, 0, 544, 128) # 0,288, 544, 128 @info_viewport.z = 100 @status_window = Window_BattleStatus.new @party_command_window = Window_PartyCommand.new @party_command_window.x = 0 @party_command_window.y = 38 @actor_command_window = Window_ActorCommand.new @actor_command_window.x = 0 @actor_command_window.y = 38 @turnCount_window = Window_TurnCount.new @turnCount_window.x = 0 @turnCount_window.y = -10 @actor_character_window = Window_Base.new(-10, -10, 566, 600) @actor_character_window.back_opacity = 0 @actor_character_window.visible = true draw_character_1 @actor_command_window.visible = false @party_command_window.visible = false @turnCount_window.visible = false @status_window.visible = false @info_viewport.visible = false end #-------------------------------------------------------------------------- # * 绘制玩家角色行走图 #-------------------------------------------------------------------------- def draw_actor_character if @draw_count == 20 draw_character_1 @actor_character_window.update elsif @draw_count == 40 draw_character_2 @draw_count = 0 @actor_character_window.update else @actor_character_window.update end end #-------------------------------------------------------------------------- # * 行走图 - 动作1 #-------------------------------------------------------------------------- def draw_character_1 @actor_character_window.contents.clear x_coordinate = 120 for actor in $game_party.members @actor_character_window.draw_character_turnU(actor.character_name, actor.character_index, x_coordinate, 380) if $game_party.members.size == 4 @actor_character_window.draw_character_turnU(actor.character_name, actor.character_index, x_coordinate + 50, 380) if $game_party.members.size == 3 @actor_character_window.draw_character_turnU(actor.character_name, actor.character_index, x_coordinate + 90, 380) if $game_party.members.size == 2 @actor_character_window.draw_character_turnU(actor.character_name, actor.character_index, x_coordinate + 150, 380) if $game_party.members.size == 1 x_coordinate += 100 end end #-------------------------------------------------------------------------- # * 行走图 - 动作2 #-------------------------------------------------------------------------- def draw_character_2 @actor_character_window.contents.clear x_coordinate = 120 for actor in $game_party.members @actor_character_window.draw_character_turnU2(actor.character_name, actor.character_index, x_coordinate, 380) if $game_party.members.size == 4 @actor_character_window.draw_character_turnU2(actor.character_name, actor.character_index, x_coordinate + 50, 380) if $game_party.members.size == 3 @actor_character_window.draw_character_turnU2(actor.character_name, actor.character_index, x_coordinate + 90, 380) if $game_party.members.size == 2 @actor_character_window.draw_character_turnU2(actor.character_name, actor.character_index, x_coordinate + 150, 380) if $game_party.members.size == 1 x_coordinate += 100 end end #-------------------------------------------------------------------------- # * 逃跑动作1 #-------------------------------------------------------------------------- def draw_runaway_1 @actor_character_window.contents.clear x_coordinate = 120 for actor in $game_party.members @actor_character_window.draw_character_turnD(actor.character_name, actor.character_index, x_coordinate, 380) if $game_party.members.size == 4 @actor_character_window.draw_character_turnD(actor.character_name, actor.character_index, x_coordinate + 50, 380) if $game_party.members.size == 3 @actor_character_window.draw_character_turnD(actor.character_name, actor.character_index, x_coordinate + 90, 380) if $game_party.members.size == 2 @actor_character_window.draw_character_turnD(actor.character_name, actor.character_index, x_coordinate + 150, 380) if $game_party.members.size == 1 x_coordinate += 100 end end #-------------------------------------------------------------------------- # * 逃跑动作2 #-------------------------------------------------------------------------- def draw_runaway_2 @actor_character_window.contents.clear x_coordinate = 120 for actor in $game_party.members @actor_character_window.draw_character_turnD2(actor.character_name, actor.character_index, x_coordinate, 380) if $game_party.members.size == 4 @actor_character_window.draw_character_turnD2(actor.character_name, actor.character_index, x_coordinate + 50, 380) if $game_party.members.size == 3 @actor_character_window.draw_character_turnD2(actor.character_name, actor.character_index, x_coordinate + 90, 380) if $game_party.members.size == 2 @actor_character_window.draw_character_turnD2(actor.character_name, actor.character_index, x_coordinate + 150, 380) if $game_party.members.size == 1 x_coordinate += 100 end end #-------------------------------------------------------------------------- # * 执行角色逃跑动作 (搁置) #-------------------------------------------------------------------------- def set_runaway count = 0 if # 判断条件 loop do if count == 0 draw_runaway_1 @actor_character_window.update elsif count == 10 draw_runaway_2 count = 0 @actor_character_window.update else @actor_character_window.update end count += 1 end end end #-------------------------------------------------------------------------- # *处置(关闭)信息显示视口 #-------------------------------------------------------------------------- def dispose_info_viewport @status_window.dispose @party_command_window.dispose @actor_command_window.dispose @info_viewport.dispose @turnCount_window.dispose @actor_character_window.dispose end #-------------------------------------------------------------------------- # *更新信息显示视口 #-------------------------------------------------------------------------- def update_info_viewport @turnCount_window.active = false draw_actor_character # 绘制行走图 @draw_count += 1 @actor_command_window.update @status_window.update @turnCount_window.update @party_command_window.update if @party_command_window.active @party_command_window.visible = true @status_window.visible = true @actor_command_window.visible = false elsif @actor_command_window.active @actor_command_window.visible = true @party_command_window.visible = false end end #-------------------------------------------------------------------------- # * 开始窗口列表選擇指令 #-------------------------------------------------------------------------- def start_party_command_selection if $game_temp.in_battle @status_window.refresh @status_window.index = @actor_index = -1 @active_battler = nil @info_viewport.visible = true @message_window.visible = false @party_command_window.active = true @party_command_window.index = 0 @actor_command_window.active = false $game_party.clear_actions if $game_troop.surprise or not $game_party.inputable? start_main end end end #-------------------------------------------------------------------------- # * 更新战斗初始選擇指令 (只有第一回合可管理队伍) #-------------------------------------------------------------------------- def update_party_command_selection if $game_troop.turn_count == 0 new_party_command_selection else old_party_command_selection end end #-------------------------------------------------------------------------- # * 战斗初始選擇指令 - 不能管理队伍 #-------------------------------------------------------------------------- def old_party_command_selection if Input.trigger?(Input::B) Sound.play_cancel end_actor_selection elsif Input.trigger?(Input::C) case @party_command_window.index when 0 Sound.play_decision @status_window.index = @actor_index = -1 next_actor when 1 start_actor_selection when 2 Sound.play_buzzer return when 3 if $game_troop.can_escape == false Sound.play_buzzer return end Sound.play_decision process_escape end end end #-------------------------------------------------------------------------- # * 战斗初始選擇指令 - 可以管理队伍 #-------------------------------------------------------------------------- def new_party_command_selection if Input.trigger?(Input::B) Sound.play_cancel end_actor_selection elsif Input.trigger?(Input::C) case @party_command_window.index when 0 Sound.play_decision @status_window.index = @actor_index = -1 next_actor when 1 start_actor_selection when 2 party_manage when 3 if $game_troop.can_escape == false Sound.play_buzzer return end Sound.play_decision process_escape end end end #-------------------------------------------------------------------------- # * 更改装备 - 开始选择角色 #-------------------------------------------------------------------------- def start_actor_selection @party_command_window.active = false @status_window.active = true if $game_party.last_actor_index < @status_window.item_max @status_window.index = $game_party.last_actor_index else @status_window.index = 0 end end #-------------------------------------------------------------------------- # * 更改装备 - 角色选择结束 #-------------------------------------------------------------------------- def end_actor_selection @party_command_window.active = true @status_window.active = false @status_window.index = -1 end #-------------------------------------------------------------------------- # * 更改装备 - 更新角色选择指令 #-------------------------------------------------------------------------- def update_actor_selection if Input.trigger?(Input::B) Sound.play_cancel end_actor_selection elsif Input.trigger?(Input::C) $game_party.last_actor_index = @status_window.index Sound.play_decision $scene = Scene_Equip.new(@status_window.index) end end #-------------------------------------------------------------------------- # * 开始道具选择 (创建道具窗口和帮助窗口) #-------------------------------------------------------------------------- def start_item_selection @help_window = Window_Help.new @help_window.y = 238 @help_window.back_opacity = 180 @item_window = Window_Item.new(0, 288, 544, 130) @item_window.back_opacity = 180 @item_window.help_window = @help_window @actor_command_window.active = false end #-------------------------------------------------------------------------- # * 开始技能选择 (创建技能窗口和帮助窗口) #-------------------------------------------------------------------------- def start_skill_selection @help_window = Window_Help.new @help_window.y = 238 @help_window.back_opacity = 180 @skill_window = Window_Skill.new(0, 288, 544, 130, @active_battler) @skill_window.back_opacity = 180 @skill_window.help_window = @help_window @actor_command_window.active = false end #-------------------------------------------------------------------------- # * 调整队伍 (调用PartyRoster类的方法) #-------------------------------------------------------------------------- def party_manage end #-------------------------------------------------------------------------- # * 开始目标角色选择 (使用道具或技能时,选择玩家角色的窗口) #-------------------------------------------------------------------------- def start_target_actor_selection @target_actor_window = Window_BattleStatus.new @info_viewport.rect.x += @target_actor_window.width @info_viewport.ox += @target_actor_window.width @actor_command_window.active = false @target_actor_window.active = true if $game_party.last_actor_index < @target_actor_window.item_max @target_actor_window.index = $game_party.last_actor_index else @target_actor_window.index = 0 end end #-------------------------------------------------------------------------- # *更新目标角色选择 #-------------------------------------------------------------------------- def update_target_actor_selection @target_actor_window.update if Input.trigger?(Input::B) Sound.play_cancel end_target_actor_selection elsif Input.trigger?(Input::C) Sound.play_decision @active_battler.action.target_index = @target_actor_window.index end_target_actor_selection end_skill_selection end_item_selection next_actor end end #-------------------------------------------------------------------------- # * 结束目标角色选择 #-------------------------------------------------------------------------- def end_target_actor_selection @info_viewport.rect.x -= @target_actor_window.width @info_viewport.ox -= @target_actor_window.width @target_actor_window.dispose @target_actor_window = nil end #-------------------------------------------------------------------------- # * 开始目标敌人选择 - 创建选择敌人指令光标 #-------------------------------------------------------------------------- def start_target_enemy_selection @target_enemy_window = Window_TargetEnemy.new @target_enemy_index = 0 # 初始化选择的敌人索引 @info_viewport.rect.x += @target_enemy_window.width @info_viewport.ox += @target_enemy_window.width @actor_command_window.active = false @target_enemies = get_alive_enemies # 获取活着的敌人 update_enemy_cursor # 更新光标位置 end #-------------------------------------------------------------------------- # * 获取活着的敌人实例 #-------------------------------------------------------------------------- def get_alive_enemies alive_enemies = [] $game_troop.members.each do |enemy| alive_enemies.push(enemy) if enemy.exist? && !enemy.dead? end alive_enemies end #-------------------------------------------------------------------------- # * 更新目标敌人选择 #-------------------------------------------------------------------------- def update_target_enemy_selection if Input.trigger?(Input::B) Sound.play_cancel @enemy_name.visible = false end_target_enemy_selection elsif Input.trigger?(Input::C) Sound.play_decision select_enemy(@target_enemies[@target_enemy_index]) if @target_enemies end_target_enemy_selection end_skill_selection end_item_selection next_actor elsif Input.trigger?(Input::RIGHT) || Input.trigger?(Input::DOWN) @target_enemy_index = (@target_enemy_index + 1) % @target_enemies.size if @target_enemies @enemy_name.visible = false update_enemy_cursor elsif Input.trigger?(Input::LEFT) || Input.trigger?(Input::UP) @target_enemy_index = (@target_enemy_index - 1 + @target_enemies.size) % @target_enemies.size if @target_enemies @enemy_name.visible = false update_enemy_cursor end end #-------------------------------------------------------------------------- # * 更新敌人光标的位置和名称窗口 #-------------------------------------------------------------------------- def update_enemy_cursor return unless @target_enemies && @target_enemies[@target_enemy_index] # 确保数组存在且有元素 enemy = @target_enemies[@target_enemy_index] # 获取当前选中的敌人 @target_enemy_window.x = enemy.screen_x - 37 # 更新光标位置到敌人的坐标 @target_enemy_window.y = enemy.screen_y - 70 ememy = get_alive_enemies @target_enemy_window.draw_enemy_state(@target_enemy_index) # 在光标窗口内部显示敌人状态图标 @target_enemy_window.visible = true # 确保光标窗口可见 # 创建敌人名称显示窗口 @enemy_name = Window_Base.new(@target_enemy_window.x - 40, @target_enemy_window.y + 78, 160, 50) @enemy_name.back_opacity = 255 @enemy_name.opacity = 255 @enemy_name.contents.clear @enemy_name.contents.draw_text(0, 0, enemy.name.length * 22, 22, enemy.name) @enemy_name.visible = true # 确保敌人名称可见 end #-------------------------------------------------------------------------- # * 光标选定敌人 #-------------------------------------------------------------------------- def select_enemy(enemy) @active_battler.action.target_index = enemy.index if enemy end #-------------------------------------------------------------------------- # * 结束目标敌人选择 #-------------------------------------------------------------------------- def end_target_enemy_selection @info_viewport.rect.x -= @target_enemy_window.width @info_viewport.ox -= @target_enemy_window.width @target_enemy_window.dispose @target_enemy_window = nil @enemy_name.dispose @enemy_name = nil @actor_command_window.active = true if @actor_command_window.index == 0 end #-------------------------------------------------------------------------- # * 回合结束 重新创建回合显示窗口和作战指令窗口 #-------------------------------------------------------------------------- def turn_end $game_troop.turn_ending = true $game_party.slip_damage_effect $game_troop.slip_damage_effect $game_party.do_auto_recovery $game_troop.preemptive = false $game_troop.surprise = false process_battle_event $game_troop.turn_ending = false @turnCount_window.dispose @turnCount_window = Window_TurnCount.new @turnCount_window.x = 0 @turnCount_window.y = -10 @party_command_window.dispose @party_command_window = Window_PartyCommand.new @party_command_window.x = 0 @party_command_window.y = 38 start_party_command_selection draw_actor_character # 绘制行走图 @draw_count += 1 end #-------------------------------------------------------------------------- # * 开始逃跑 添加“逃跑成功”字样显示 #-------------------------------------------------------------------------- def process_escape # set_runaway # 执行角色逃跑动作 @info_viewport.visible = false @message_window.visible = true text = sprintf(Vocab::EscapeStart, $game_party.name) $game_message.texts.push(text) if $game_troop.preemptive success = true else success = (rand(100) < @escape_ratio) end Sound.play_escape if success wait_for_message $game_message.texts.push("成功的逃脱了。") wait_for_message battle_end(1) else @escape_ratio += 10 $game_message.texts.push('\.' + Vocab::EscapeFailure) wait_for_message $game_party.clear_actions start_main end end #-------------------------------------------------------------------------- # * 战斗事件处理 #-------------------------------------------------------------------------- def process_battle_event loop do draw_actor_character # 绘制角色行走图 @draw_count += 1 @status_window.refresh # 刷新角色状态信息 return if judge_win_loss return if $game_temp.next_scene != nil $game_troop.interpreter.update $game_troop.setup_battle_event wait_for_message process_action if $game_troop.forcing_battler != nil return unless $game_troop.interpreter.running? update_basic end end #-------------------------------------------------------------------------- # * 顯示動畫 # targets : 顯示位置(目标对象实例) # animation_id : 動畫編號(如果為-1則播放普通攻擊動畫) #-------------------------------------------------------------------------- def display_animation(targets, animation_id) if animation_id < 0 display_attack_animation(targets) else display_normal_animation(targets, animation_id) end wait(20) wait_for_animation end #-------------------------------------------------------------------------- # * 顯示攻擊動畫 # targets : 顯示位置(目标对象实例) # 如果是敵人,只播放[敵人攻擊]聲效,然後等待一陣子。 # 如果是主角則同時考慮到貳刀流主角的情況(左手動畫水準翻轉顯示) #-------------------------------------------------------------------------- def display_attack_animation(targets) if @active_battler.is_a?(Game_Enemy) Sound.play_enemy_attack display_normal_animation(targets, 1, false) wait(15, true) else aid1 = @active_battler.atk_animation_id aid2 = @active_battler.atk_animation_id2 display_normal_animation(targets, aid1, false) display_normal_animation(targets, aid2, true) end wait_for_animation end #-------------------------------------------------------------------------- # * 顯示普通動畫 # targets : 顯示位置(目标对象实例) # animation_id : 動畫編號 # mirror : 水準翻轉 #-------------------------------------------------------------------------- def display_normal_animation(targets, animation_id, mirror = false) animation = $data_animations[animation_id] if animation != nil to_screen = (animation.position == 2) # (0:头部,1:中心,2:脚部,3:全屏) for target in targets.uniq target.animation_id = animation_id target.animation_mirror = mirror wait(20, true) unless to_screen # 如果是單體動畫,等待 end wait(20, true) if to_screen # 如果是全體動畫,等待 end end end #============================================================================== # 在窗口中绘制不同身体朝向的角色行走图 # 调用方法·例: @xxxx_window.draw_character(character_name, character_index, x, y) #============================================================================== class Window_Base < Window # 定义原有方法绘制行走图朝向的常量 (0-下,1-左,2-右,3-上) TURN = 0 #-------------------------------------------------------------------------- # * 绘制角色图像 (原有方法,绘制的行走图身体朝下) # character_name : 角色图像文件名 # character_index : 角色图像索引 # x : 绘制点 x-坐标 # y : 绘制点 y-坐标 #-------------------------------------------------------------------------- def draw_character(character_name, character_index, x, y) if character_name == nil # 检测角色位图是否为空 character_name = "!Coffin" character_index = 0 end bitmap = Cache.character(character_name) # 从游戏的缓存中获取角色的位图 sign = character_name[/^[\!\$]./]# 使用正则表达式来匹配角色名称的第一个字符,如果匹配成功,sign 变量将存储该字符。 if sign != nil and sign.include?('$') # 检查 sign 变量是否不为 nil 并且包含字符 $。 cw = bitmap.width / 3 # 半身头像位图的宽度 ch = bitmap.height / 4 # 半身头像位图的高度 else cw = bitmap.width / 12 # 行走图宽度 ch = bitmap.height / 8 # 行走图高度 end n = character_index # 存储角色位图索引 # x 坐标是根据图像索引和每行的图像数量(对于全身图像通常是 4 个)计算的,y 坐标是根据图像索引除以每行的图像数量计算的。cw 和 ch 是源区域的宽度和高度。 src_rect = Rect.new((n%4*3+1)*cw, (n/4*4+TURN)*ch, cw, ch) # 通过Rect定义位图绘制区域 # blt 是 Bitmap 类的方法,将源位图(bitmap)中的一个区域(由 src_rect 定义)绘制到窗口内容位图(self.contents)上的指定位置(由 x 和 y 坐标定义) # x - cw / 2 和 y - ch 是目标位置的坐标,它们确保角色图像居中绘制在指定的 x 和 y 坐标上。 self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect) # 执行实际的绘制操作 end #-------------------------------------------------------------------------- # * 绘制角色行走图 - 朝下-动作1 #-------------------------------------------------------------------------- def draw_character_turnD(character_name, character_index, x, y) if character_name == nil character_name = "!Coffin" character_index = 0 end bitmap = Cache.character(character_name) sign = character_name[/^[\!\$]./] if sign != nil cw = bitmap.width / 12 ch = bitmap.height / 8 end n = character_index src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch) self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect) end #-------------------------------------------------------------------------- # * 绘制角色行走图 - 朝下-动作2 #-------------------------------------------------------------------------- def draw_character_turnD2(character_name, character_index, x, y) if character_name == nil character_name = "!Coffin" character_index = 0 end bitmap = Cache.character(character_name) sign = character_name[/^[\!\$]./] if sign != nil cw = bitmap.width / 12 ch = bitmap.height / 8 end n = character_index src_rect = Rect.new((n%4*3+2)*cw, (n/4*4)*ch, cw, ch) self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect) end #-------------------------------------------------------------------------- # * 绘制角色行走图 - 朝上-动作1 #-------------------------------------------------------------------------- def draw_character_turnU(character_name, character_index, x, y) if character_name == nil character_name = "!Coffin" character_index = 0 else bitmap = Cache.character(character_name) sign = character_name[/^[\!\$]./] if sign != nil cw = bitmap.width / 12 ch = bitmap.height / 8 end n = character_index src_rect = Rect.new((n%4*3+1)*cw, (n/4*4+3)*ch, cw, ch) self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect) end end #-------------------------------------------------------------------------- # * 绘制角色行走图 - 朝上-动作2 #-------------------------------------------------------------------------- def draw_character_turnU2(character_name, character_index, x, y) if character_name == nil character_name = "!Coffin" character_index = 0 else bitmap = Cache.character(character_name) sign = character_name[/^[\!\$]./] if sign != nil cw = bitmap.width / 12 ch = bitmap.height / 8 end n = character_index src_rect = Rect.new((n%4*3+2)*cw, (n/4*4+3)*ch, cw, ch) self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect) end end end #------------------人物死亡时改变角色的行走图-----------------------------# # # # 行走图文件路径:[游戏目录]\Graphics\Characters\!Coffin.png # #-------------------------------------------------------------------------# class Game_Interpreter #-------------------------------------------------------------------------- # * 角色状态变更 @params[2]:状态编号。 # @params[0]:角色 ID,如果是 0,则表示对所有角色执行此命令。 # @params[1]:状态 ID,如果是 0,则表示添加状态,如果是 1,则表示移除状态。 #-------------------------------------------------------------------------- def command_313 iterate_actor_id(@params[0]) do |actor| # 遍历指定的角色,并执行给定的代码块 if @params[1] == 0 # 如果 @params[1] 是 0, actor.add_state(@params[2]) # 那么它将调用 add_state 方法来添加状态 actor.set_death_graphic if @params[2] == 1 # 如果添加的角色状态是1(死亡),调用game_actor的方法变更死亡行走图 actor.perform_collapse else # 如果是 1, actor.remove_state(@params[2]) # 移除角色状态 actor.set_normal_graphic if @params[2] == 1 # 如果移除的角色状态是1(死亡),调用game_actor的方法变更正常行走图 end end return true end #-------------------------------------------------------------------------- # * 全部恢复 #-------------------------------------------------------------------------- def command_314 iterate_actor_id(@params[0]) do |actor| actor.recover_all actor.set_normal_graphic # 调用game_actor的方法变更正常行走图 end return true end end #-------------------------------------------------------------------------- class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # * 角色死亡状态的行走图 #-------------------------------------------------------------------------- def set_death_graphic @character_name = "!Coffin" # 死亡行走图的文件名 @character_index = 0 # 设置 索引为 0 (行走图左上角) $game_player.refresh # 刷新队伍首位角色的行走图 end #-------------------------------------------------------------------------- # * 角色正常状态的行走图 #-------------------------------------------------------------------------- def set_normal_graphic if @actor_id == 1 && $game_switches[1145] == true # 主角设置“宫廷守卫装”时 @character_name = "!Aldain" @character_index = 1 elsif @actor_id == 1 && $game_switches[1146] == true # 主角设置“忍者装”时 @character_name = "!Aldain" @character_index = 0 else @character_name = actor.character_name @character_index = actor.character_index end $game_player.refresh # 刷新队伍首位角色的行走图 end #-------------------------------------------------------------------------- # * 重构父类的hp=(hp)方法 #-------------------------------------------------------------------------- def hp=(hp) super # 继承父类的方法用于判断角色生命值和状态。 if @hp <= 0 && state?(1) set_death_graphic else set_normal_graphic end end #-------------------------------------------------------------------------- # * 定义队伍 X坐标 #-------------------------------------------------------------------------- def screen_x if self.index != nil case index when 3 return 420 if $game_party.members.size == 4 when 2 return 315 if $game_party.members.size == 4 return 380 if $game_party.members.size == 3 when 1 return 215 if $game_party.members.size == 4 return 260 if $game_party.members.size == 3 return 320 if $game_party.members.size == 2 when 0 return 120 if $game_party.members.size == 4 return 160 if $game_party.members.size == 3 return 200 if $game_party.members.size == 2 return 260 if $game_party.members.size == 1 end else return 0 end end #-------------------------------------------------------------------------- # * 定义队伍 Y坐标 #-------------------------------------------------------------------------- def screen_y return 380 end #-------------------------------------------------------------------------- # * 定义队伍 Z坐标 #-------------------------------------------------------------------------- def screen_z if self.index != nil return 4 - self.index else return 0 end end #-------------------------------------------------------------------------- # * 角色精灵开关 #-------------------------------------------------------------------------- def use_sprite? return true end end class Spriteset_Battle #-------------------------------------------------------------------------- # * 創建參戰主角精靈物設 # 預設情況下不顯示主角參戰圖,不過如果需要的話, # 會建立一個虛擬的精靈物設並用相同的方式處理敵人隊伍和我方隊伍。 #-------------------------------------------------------------------------- def create_actors @actor_sprites = [] for actor in $game_party.members.reverse @actor_sprites.push(Sprite_Battler.new(@viewport1, actor)) end end #-------------------------------------------------------------------------- # * 更新參戰主角之精靈物設的顯示資訊 #-------------------------------------------------------------------------- def update_actors for sprite in @actor_sprites sprite.update end end end
局部截取_20241021_145927.png (216.94 KB, 下载次数: 7)
局部截取_20241021_150251.png (206.49 KB, 下载次数: 7)
局部截取_20241021_150323.png (204.04 KB, 下载次数: 6)
局部截取_20241021_150453.png (236.21 KB, 下载次数: 6)
局部截取_20241021_150534.png (217.66 KB, 下载次数: 6)
局部截取_20241021_150636.png (200.87 KB, 下载次数: 6)
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |