#-------------------------------------------------------------------------- # ● 取得戰鬥畫面的 X 座標 #-------------------------------------------------------------------------- def screen_x if self.index != nil return self.index * 30 + 450 else return 0 end end #-------------------------------------------------------------------------- # ● 取得戰鬥畫面的 Y 座標 #-------------------------------------------------------------------------- def screen_y return self.index * 30 + 230 end #--------------------------------------------------------------------- # ● 取得戰鬥畫面的 Z 座標 #-------------------------------------------------------------------------- def screen_z if self.index != nil return self.index else return 0 end end |
@skill_window (技能視窗) @item_window (道具視窗) @help_window (說明視窗) @actor_command_window (角色命令窗) @status_window (狀態視窗) @message_window (對話視窗) @result_window (戰果結算視窗) |
# 把狀態窗的z改為9999、不透明度為0(即看不到視窗) @status_window.z = 9999 @status_window.opacity = 0 |
@viewport1 = Viewport.new(0, 0, 640, 320) |
@viewport1 = Viewport.new(0, 0, 640, 480) |
@battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name) @battleback_sprite.src_rect.set(0, 0, 640, 320) |
@battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name) @battleback_sprite.src_rect.set(0, 0, 640, 480) |
for enemy in $game_troop.enemies.reverse @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy)) end |
@actor_sprites.push(Sprite_Battler.new(@viewport2)) @actor_sprites.push(Sprite_Battler.new(@viewport2)) @actor_sprites.push(Sprite_Battler.new(@viewport2)) @actor_sprites.push(Sprite_Battler.new(@viewport2)) |
@actor_sprites.push(Sprite_Battler.new(@viewport1)) @actor_sprites.push(Sprite_Battler.new(@viewport1)) @actor_sprites.push(Sprite_Battler.new(@viewport1)) @actor_sprites.push(Sprite_Battler.new(@viewport1)) |
module RPG class Sprite < ::Sprite def animation_set_sprites(sprites, cell_data, position) for i in 0..15 sprite = sprites[i] pattern = cell_data[i, 0] if sprite == nil or pattern == nil or pattern == -1 sprite.visible = false if sprite != nil next end sprite.visible = true sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192) if position == 3 if self.viewport != nil sprite.x = self.viewport.rect.width / 2 sprite.y = self.viewport.rect.height - 160 else sprite.x = 320 sprite.y = 240 end else sprite.x = self.x - self.ox + self.src_rect.width / 2 sprite.y = self.y - self.oy + self.src_rect.height / 2 sprite.y -= self.src_rect.height / 4 if position == 0 sprite.y += self.src_rect.height / 4 if position == 2 end sprite.x += cell_data[i, 1] sprite.y += cell_data[i, 2] sprite.z = 2000 sprite.ox = 96 sprite.oy = 96 sprite.zoom_x = cell_data[i, 3] / 100.0 sprite.zoom_y = cell_data[i, 3] / 100.0 sprite.angle = cell_data[i, 4] sprite.mirror = (cell_data[i, 5] == 1) sprite.opacity = cell_data[i, 6] * self.opacity / 255.0 sprite.blend_type = cell_data[i, 7] end end end end |
module RPG class Sprite < ::Sprite def animation_set_sprites(sprites, cell_data, position) for i in 0..15 sprite = sprites[i] pattern = cell_data[i, 0] if sprite == nil or pattern == nil or pattern == -1 sprite.visible = false if sprite != nil next end sprite.visible = true sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192) # 全螢幕動畫的情況 if position == 3 if self.viewport != nil sprite.x = self.viewport.rect.width / 2 sprite.y = self.viewport.rect.height - 320 else sprite.x = 320 sprite.y = 240 end else sprite.x = self.x - self.ox + self.src_rect.width / 2 sprite.y = self.y - self.oy + self.src_rect.height / 2 sprite.y -= self.src_rect.height / 4 if position == 0 sprite.y += self.src_rect.height / 4 if position == 2 end sprite.x += cell_data[i, 1] sprite.y += cell_data[i, 2] sprite.z = 2000 sprite.ox = 96 sprite.oy = 96 sprite.zoom_x = cell_data[i, 3] / 100.0 sprite.zoom_y = cell_data[i, 3] / 100.0 sprite.angle = cell_data[i, 4] sprite.mirror = (cell_data[i, 5] == 1) sprite.opacity = cell_data[i, 6] * self.opacity / 255.0 sprite.blend_type = cell_data[i, 7] end end end end |
class Game_Temp #-------------------------------------------------------------------------- # ● 公開變數 #-------------------------------------------------------------------------- attr_accessor :animation_turn #動畫反轉判定 #-------------------------------------------------------------------------- # ● 初始化物件 #-------------------------------------------------------------------------- alias :svb_animeturn :initialize def initialize svb_animeturn @animation_turn = false end end |
class Scene_Battle #-------------------------------------------------------------------------- # ● 更新畫面 (主回合步驟 3 : 行動方動畫) #-------------------------------------------------------------------------- alias :svb_update_phase4_step3 :update_phase4_step3 def update_phase4_step3 $game_temp.animation_turn = @active_battler.is_a?(Game_Enemy) svb_update_phase4_step3 end #-------------------------------------------------------------------------- # ● 更新畫面 (主回合步驟 5 : 顯示傷害) #-------------------------------------------------------------------------- alias :svb_update_phase4_step5 :update_phase4_step5 def update_phase4_step5 svb_update_phase4_step5 $game_temp.animation_turn = false end end |
module RPG class Sprite < ::Sprite #-------------------------------------------------------------------------- # ● 處理動畫分割 #-------------------------------------------------------------------------- def animation_set_sprites(sprites, cell_data, position) for i in 0..15 sprite = sprites[i] pattern = cell_data[i, 0] if sprite == nil or pattern == nil or pattern == -1 sprite.visible = false if sprite != nil next end sprite.visible = true sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192) if position == 3 if self.viewport != nil sprite.x = self.viewport.rect.width / 2 sprite.y = self.viewport.rect.height - 320 else sprite.x = 320 sprite.y = 240 end else sprite.x = self.x - self.ox + self.src_rect.width / 2 sprite.y = self.y - self.oy + self.src_rect.height / 2 sprite.y -= self.src_rect.height / 4 if position == 0 sprite.y += self.src_rect.height / 4 if position == 2 end # 反轉處理(x軸) if $game_temp.animation_turn sprite.x -= cell_data[i, 1] else sprite.x += cell_data[i, 1] end sprite.y += cell_data[i, 2] # 戰鬥中、而且非全畫面動畫時,動畫的Z軸等於作用對象的Z軸 if position == 3 or !$game_temp.in_battle sprite.z = 2000 else sprite.z = self.battler.screen_z end sprite.ox = 96 sprite.oy = 96 sprite.zoom_x = cell_data[i, 3] / 100.0 sprite.zoom_y = cell_data[i, 3] / 100.0 # 反轉處理(角度、動畫本身的左右反轉) if $game_temp.animation_turn sprite.angle = (360 - cell_data[i, 4]) sprite.mirror = (cell_data[i, 5] == 0) else sprite.angle = cell_data[i, 4] sprite.mirror = (cell_data[i, 5] == 1) end # 如果旋轉角度在360度以上就減少360度避免多花處理時間 sprite.angle -= 360 if sprite.angle >= 360 sprite.opacity = cell_data[i, 6] * self.opacity / 255.0 sprite.blend_type = cell_data[i, 7] end end end end |
module RPG class Sprite < ::Sprite # 設定別名給原本的狀態動畫用 alias :old_animation_set_sprites :animation_set_sprites unless method_defined?(:old_animation_set_sprites) #-------------------------------------------------------------------------- # ● 處理動畫分割 #-------------------------------------------------------------------------- def animation_set_sprites(sprites, cell_data, position) for i in 0..15 sprite = sprites[i] pattern = cell_data[i, 0] if sprite == nil or pattern == nil or pattern == -1 sprite.visible = false if sprite != nil next end sprite.visible = true sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192) if position == 3 if self.viewport != nil sprite.x = self.viewport.rect.width / 2 sprite.y = self.viewport.rect.height - 320 else sprite.x = 320 sprite.y = 240 end else sprite.x = self.x - self.ox + self.src_rect.width / 2 sprite.y = self.y - self.oy + self.src_rect.height / 2 sprite.y -= self.src_rect.height / 4 if position == 0 sprite.y += self.src_rect.height / 4 if position == 2 end # 反轉處理(x軸) if $game_temp.animation_turn sprite.x -= cell_data[i, 1] else sprite.x += cell_data[i, 1] end sprite.y += cell_data[i, 2] # 戰鬥中、而且非全畫面動畫時,動畫的Z軸等於作用對象的Z軸 if position == 3 or !$game_temp.in_battle sprite.z = 2000 else sprite.z = self.battler.screen_z end sprite.ox = 96 sprite.oy = 96 sprite.zoom_x = cell_data[i, 3] / 100.0 sprite.zoom_y = cell_data[i, 3] / 100.0 # 反轉處理(角度、動畫本身的左右反轉) if $game_temp.animation_turn sprite.angle = (360 - cell_data[i, 4]) sprite.mirror = (cell_data[i, 5] == 0) else sprite.angle = cell_data[i, 4] sprite.mirror = (cell_data[i, 5] == 1) end # 如果旋轉角度在360度以上就減少360度避免多花處理時間 sprite.angle -= 360 if sprite.angle >= 360 sprite.opacity = cell_data[i, 6] * self.opacity / 255.0 sprite.blend_type = cell_data[i, 7] end end end end |
#-------------------------------------------------------------------------- # ● 更新狀態動畫 #-------------------------------------------------------------------------- def update_loop_animation frame_index = @_loop_animation_index cell_data = @_loop_animation.frames[frame_index].cell_data position = @_loop_animation.position old_animation_set_sprites(@_loop_animation_sprites, cell_data, position) ######## for timing in @_loop_animation.timings if timing.frame == frame_index animation_process_timing(timing, true) end end end |
class Sprite_Battler < RPG::Sprite #-------------------------------------------------------------------------- # ● 初始化物件 #-------------------------------------------------------------------------- alias :svb_initialize :initialize def initialize(viewport, battler = nil) svb_initialize(viewport, battler) self.mirror = battler.is_a?(Game_Enemy) end end |
class Game_Battler #-------------------------------------------------------------------------- # ● 定義實例變數 #-------------------------------------------------------------------------- attr_accessor :phase # 戰鬥者回合 #-------------------------------------------------------------------------- # ● 初始化物件 #-------------------------------------------------------------------------- alias :svb_initialize :initialize def initialize svb_initialize @phase = 1 end end |
class Scene_Battle #-------------------------------------------------------------------------- # ● 更新畫面 (主回合步驟 1 : 準備行動) #-------------------------------------------------------------------------- alias :svb_update_phase4_step1 :update_phase4_step1 def update_phase4_step1 svb_update_phase4_step1 @active_battler.phase = 2 if @active_battler ######## end #-------------------------------------------------------------------------- # ● 更新畫面 (主回合步驟 2 : 開始行動) #-------------------------------------------------------------------------- def update_phase4_step2 # 如果不是強制行動 unless @active_battler.current_action.forcing # 限制為 [敵人為普通攻擊] 或 [我方為普通攻擊] 的情況下 if @active_battler.restriction == 2 or @active_battler.restriction == 3 # 設定行動為攻擊 @active_battler.current_action.kind = 0 @active_battler.current_action.basic = 0 end # 限制為 [不能行動] 的情況下 if @active_battler.restriction == 4 # 清除行動強制目標的戰鬥者 $game_temp.forcing_battler = nil # 移至步驟 1 @phase4_step = 1 @active_battler.phase = 1 ######## return end end # 清除目標戰鬥者 @target_battlers = [] # 行動種類分歧 case @active_battler.current_action.kind when 0 # 基本 make_basic_action_result when 1 # 技能 make_skill_action_result when 2 # 物品 make_item_action_result end # 移至步驟 3 if @phase4_step == 2 @phase4_step = 3 @active_battler.phase = 3 ######## end end #-------------------------------------------------------------------------- # ● 產生基本行動結果 #-------------------------------------------------------------------------- def make_basic_action_result # 攻擊的情況下 if @active_battler.current_action.basic == 0 # 設定攻擊 ID @animation1_id = @active_battler.animation1_id @animation2_id = @active_battler.animation2_id # 行動方的戰鬥者是敵人的情況下 if @active_battler.is_a?(Game_Enemy) if @active_battler.restriction == 3 target = $game_troop.random_target_enemy elsif @active_battler.restriction == 2 target = $game_party.random_target_actor else index = @active_battler.current_action.target_index target = $game_party.smooth_target_actor(index) end end # 行動方的戰鬥者是角色的情況下 if @active_battler.is_a?(Game_Actor) if @active_battler.restriction == 3 target = $game_party.random_target_actor elsif @active_battler.restriction == 2 target = $game_troop.random_target_enemy else index = @active_battler.current_action.target_index target = $game_troop.smooth_target_enemy(index) end end # 設定對像方的戰鬥者序列 @target_battlers = [target] # 套用通常攻擊效果 (移至phase5) # for target in @target_battlers # target.attack_effect(@active_battler) # end return end # 防禦的情況下 if @active_battler.current_action.basic == 1 # 說明視窗顯示"防禦" @help_window.set_text($data_system.words.guard, 1) return end # 逃跑的情況下 if @active_battler.is_a?(Game_Enemy) and @active_battler.current_action.basic == 2 # 說明視窗顯示"逃跑" @help_window.set_text("逃跑", 1) # 逃跑 @active_battler.escape return end # 什麼也不做的情況下 if @active_battler.current_action.basic == 3 # 清除強制行動目標的戰鬥者 $game_temp.forcing_battler = nil # 移至步驟 1 @phase4_step = 1 @active_battler.phase = 1 ######## return end end #-------------------------------------------------------------------------- # ● 產生技能行動結果 #-------------------------------------------------------------------------- def make_skill_action_result # 獲取技能 @skill = $data_skills[@active_battler.current_action.skill_id] # 如果不是強制行動 unless @active_battler.current_action.forcing # 因為 SP 耗盡而無法使用的情況下 unless @active_battler.skill_can_use?(@skill.id) # 清除強制行動對像的戰鬥者 $game_temp.forcing_battler = nil # 移至步驟 1 @phase4_step = 1 @active_battler.phase = 1 ######### return end end # 消耗 SP @active_battler.sp -= @skill.sp_cost # 更新狀態視窗 @status_window.refresh # 在說明視窗顯示技能名稱 @help_window.set_text(@skill.name, 1) # 設定動畫 ID @animation1_id = @skill.animation1_id @animation2_id = @skill.animation2_id # 設定公共事件 ID @common_event_id = @skill.common_event_id # 設定對像方戰鬥者 set_target_battlers(@skill.scope) # 套用技能效果 (移至phase5) # for target in @target_battlers # target.skill_effect(@active_battler, @skill) # end end #-------------------------------------------------------------------------- # ● 產生物品行動結果 #-------------------------------------------------------------------------- def make_item_action_result # 獲取物品 @item = $data_items[@active_battler.current_action.item_id] # 因為物品耗盡而無法使用的情況下 unless $game_party.item_can_use?(@item.id) # 移至步驟 1 @phase4_step = 1 @active_battler.phase = 1 ######### return end # 消耗品的情況下 if @item.consumable # 使用的物品減 1 $game_party.lose_item(@item.id, 1) end # 在說明視窗顯示物品名稱 @help_window.set_text(@item.name, 1) # 設定動畫 ID @animation1_id = @item.animation1_id @animation2_id = @item.animation2_id # 設定公共事件 ID @common_event_id = @item.common_event_id # 確定對像 index = @active_battler.current_action.target_index target = $game_party.smooth_target_actor(index) # 設定對像方戰鬥者 set_target_battlers(@item.scope) # 套用物品效果(移至phase5) # for target in @target_battlers # target.item_effect(@item) # end end #-------------------------------------------------------------------------- # ● 更新畫面 (主回合步驟 3 : 行動方動畫) #-------------------------------------------------------------------------- alias :svb_update_phase4_step3 :update_phase4_step3 def update_phase4_step3 $game_temp.animation_turn = @active_battler.is_a?(Game_Enemy) svb_update_phase4_step3 @active_battler.phase = 4 end #-------------------------------------------------------------------------- # ● 更新畫面 (主回合步驟 4 : 對像方動畫) #-------------------------------------------------------------------------- alias :svb_update_phase4_step4 :update_phase4_step4 def update_phase4_step4 svb_update_phase4_step4 @active_battler.phase = 5 end #-------------------------------------------------------------------------- # ● 更新畫面 (主回合步驟 5 : 顯示傷害) #-------------------------------------------------------------------------- alias :svb_update_phase4_step5 :update_phase4_step5 def update_phase4_step5 case @active_battler.current_action.kind when 0 # 套用基本攻擊效果 if @active_battler.current_action.basic == 0 for target in @target_battlers target.attack_effect(@active_battler) end end when 1 # 套用技能效果 for target in @target_battlers target.skill_effect(@active_battler, @skill) end when 2 # 套用物品效果 for target in @target_battlers target.item_effect(@item) end end svb_update_phase4_step5 @active_battler.phase = 6 $game_temp.animation_turn = false end #-------------------------------------------------------------------------- # ● 更新畫面 (主回合步驟 6 : 更新) #-------------------------------------------------------------------------- alias :svb_update_phase4_step6 :update_phase4_step6 def update_phase4_step6 #這兩個內容設為無 @skill = nil @item = nil @active_battler.phase = 1 svb_update_phase4_step6 end end |