end
n = battler.character_index
rect = Rect.new((n%4*3+1)*cw, (n/4*4+2)*ch, cw, ch)
@cp_battler[battler].bitmap = Bitmap.new(cw,ch)
end
@cp_battler[battler].bitmap.blt(0, 0,bitmap,rect)
else
name = battler.original_name + "_敌人cp"
if FileTest.exist?("Graphics/system/#{name}.jpg") or FileTest.exist?("Graphics/system/#{name}.png") or FileTest.exist?("Graphics/system/#{name}.bmp")
@cp_battler[battler].bitmap = Bitmap.new("Graphics/system/#{name}")
else
@cp_battler[battler].bitmap = Bitmap.new("Graphics/system/敌人cp")
end
@cp_battler[battler].bitmap.blt(80,60, @cp_battler[battler].bitmap, @cp_battler[battler].bitmap.rect)
end
@cp_battler[battler].z = 101
@cp_battler[battler].visible = false
end
end
#===========================================
#===========================================
def update
return if @stop
for battler in $game_party.members + $game_troop.members
if (@cp_battler[battler].disposed? or @cp_battler[battler].opacity == 0) and battler.dead?
@cp_battler.delete(@cp_battler[battler])
next
end
if battler.dead?
if @cp_battler.include?(battler)
@cp_battler[battler].collapse = true
end
battler.cp = 0
next
end
battler.cp = [[battler.cp + BATTLE_SPEED*10*battler.agi / @all_agi,0].max,battler.maxcp].min if battler.movable?
battler.cp_turn = [[battler.cp_turn+BATTLE_SPEED*10*battler.agi / @all_agi, 0].max,battler.maxcp].min
if battler.cp == battler.maxcp
if battler.is_a?(Game_Actor)
name = battler.id.to_s + "_a_cp"
if FileTest.exist?("Graphics/system/#{name}.jpg") or FileTest.exist?("Graphics/system/#{name}.png") or FileTest.exist?("Graphics/system/#{name}.bmp")
bitmap = Bitmap.new("Graphics/system/#{name}")
rect = bitmap.rect
@cp_battler[battler].bitmap = bitmap
else
bitmap = Bitmap.new("Graphics/Characters/#{battler.character_name}")
sign = battler.character_name[/^[\!\$]./]
if sign != nil and sign.include?('$')
cw = bitmap.width / 3
ch = bitmap.height / 4
else
cw = bitmap.width / 12
ch = bitmap.height / 8
end
n = battler.character_index
rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
@cp_battler[battler].bitmap = Bitmap.new(cw,ch)
end
@cp_battler[battler].bitmap.blt(0,0,bitmap,rect)
else
name = battler.original_name + "_a_cp"
if FileTest.exist?("Graphics/system/#{name}.jpg") or FileTest.exist?("Graphics/system/#{name}.png") or FileTest.exist?("Graphics/system/#{name}.bmp")
@cp_battler[battler].bitmap = Bitmap.new("Graphics/system/#{name}")
else
@cp_battler[battler].bitmap = Bitmap.new("Graphics/system/a_敌人cp")
end
@cp_battler[battler].bitmap.blt(80,60, @cp_battler[battler].bitmap, @cp_battler[battler].bitmap.rect)
end
@cp_battler[battler].z = 101
battler.cp_total = true
elsif battler.cp_total == true
if battler.is_a?(Game_Actor)
name = battler.id.to_s + "_cp"
if FileTest.exist?("Graphics/system/#{name}.jpg") or FileTest.exist?("Graphics/system/#{name}.png") or FileTest.exist?("Graphics/system/#{name}.bmp")
bitmap = Bitmap.new("Graphics/system/#{name}")
rect = bitmap.rect
@cp_battler[battler].bitmap = bitmap
else
bitmap = Bitmap.new("Graphics/Characters/#{battler.character_name}")
sign = battler.character_name[/^[\!\$]./]
if sign != nil and sign.include?('$')
cw = bitmap.width / 3
ch = bitmap.height / 4
else
cw = bitmap.width / 12
ch = bitmap.height / 8
end
n = battler.character_index
rect = Rect.new((n%4*3+1)*cw, (n/4*4+2)*ch, cw, ch)
@cp_battler[battler].bitmap = Bitmap.new(cw,ch)
end
@cp_battler[battler].bitmap.blt(0,0,bitmap,rect)
else
name = battler.original_name + "_敌人cp"
if FileTest.exist?("Graphics/system/#{name}.jpg") or FileTest.exist?("Graphics/system/#{name}.png") or FileTest.exist?("Graphics/system/#{name}.bmp")
@cp_battler[battler].bitmap = Bitmap.new("Graphics/system/#{name}")
@cp_battler[battler].bitmap.blt(80,60, @cp_battler[battler].bitmap, @cp_battler[battler].bitmap.rect)
end
battler.cp_total = false
@cp_battler[battler].z = 105
end
@cp_battler[battler].visible = true if @cp_battler[battler].visible == false
@cp_battler[battler].opacity = 255
@cp_battler[battler].y = 30
@cp_battler[battler].x = 95+300*battler.cp/battler.maxcp
if battler.cp_turn == battler.maxcp
#=================================
last_st = battler.states
#=================================
battler.remove_states_auto unless battler.movable?
battler.slip_damage_effect
battler.do_auto_recovery if battler.is_a?(Game_Actor)
#====================================
if battler.states != last_st
$scene.display_state_changes(battler)
end
#====================================
battler.cp_turn = 0
end
if battler.cp == battler.maxcp
if battler.is_a?(Game_Actor)
$game_party.actor_battler.push(battler)
else
battler.make_action
$game_troop.enemy_battler.push(battler)
battler.make_action
end
else
next
end
end
end
def dispose
for j in 0..25
@cpline.opacity -= 10
for i in @cp_battler.values
unless i.disposed?
i.opacity -= 10
end
end
Graphics.update
end
@v.dispose
@cpline.dispose
for i in @cp_battler.values
i.dispose
end
end
end
class Sprite_cpbattler < Sprite
attr_accessor :collapse
def initialize (viewport = nil)
super (viewport)
@effect_duration = 0
@collapse = false
end
def update
super
if self.collapse == true and self.opacity != 0
@effect_type = 5
@effect_duration = 48
self.color.set(255, 128, 128, 128)
for i in 0..48
self.opacity = 256 - (48 - @effect_duration) * 6
if self.opacity == 0
break
end
Graphics.update
@effect_duration -= 1
end
self.collapse = false
self.color.set(255,255,255,5)
end
end
def dispose
if self.bitmap != nil
self.bitmap.dispose
end
end
#=====================================================
#--------------------------------------------------------------------------
# ● 更新同伴战斗指令
#--------------------------------------------------------------------------
def update_party_command_selection
if Input.trigger?(Input::C)
case @party_command_window.index
when 0 # 战斗
Sound.play_decision
start_actor_command_selection
when 1 # 逃跑
if $game_troop.can_escape == false
Sound.play_buzzer
return
end
Sound.play_decision
process_escape
end
end
end
#--------------------------------------------------------------------------
# ● 开始选择角色指令
#--------------------------------------------------------------------------
def start_actor_command_selection
@party_command_window.active = false
@actor_command_window.setup(@active_battler)
@actor_command_window.active = true
@actor_command_window.index = 0
end
#==============================================
#★指令窗口刷新
#==============================================
def update_actor_command_selection
if Input.trigger?(Input::B)
Sound.play_cancel
start_party_command
elsif Input.trigger?(Input::C)
case @actor_command_window.index
when 0 # 攻击
Sound.play_decision
@active_battler.action.set_attack
start_target_enemy_selection
when 1 # 特技
Sound.play_decision
start_skill_selection
when 2 # 防御
Sound.play_decision
@active_battler.action.set_guard
@active_battler.cp = 0
next_actor
when 3 # 物品
Sound.play_decision
start_item_selection
when 4 #逃跑
if $game_troop.can_escape == false
Sound.play_buzzer
return
end
Sound.play_decision
process_escape
end
end
end
#========================================================
#--------------------------------------------------------------------------
# ● 更新选择对象敌方角色
#--------------------------------------------------------------------------
def update_target_enemy_selection
@target_enemy_window.update
if Input.trigger?(Input::B)
Sound.play_cancel
end_target_enemy_selection
elsif Input.trigger?(Input::C)
Sound.play_decision
@active_battler.action.target_index = @target_enemy_window.enemy.index
end_target_enemy_selection
end_skill_selection
end_item_selection
#============================
@active_battler.cp = 0
#============================
next_actor
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
#=========================
@active_battler.cp = 0
#=========================
next_actor
end
end
#--------------------------------------------------------------------------
# ● 确定特技
#--------------------------------------------------------------------------
def determine_skill
@active_battler.action.set_skill(@skill.id)
@skill_window.active = false
if @skill.need_selection?
if @skill.for_opponent?
start_target_enemy_selection
else
start_target_actor_selection
end
else
end_skill_selection
#=========================
@active_battler.cp = 0
#=========================
@party_command_window.active = false
next_actor
end
end
#=========================================
#★物品使用决定 处理
#=========================================
def determine_item
@active_battler.action.set_item(@item.id)
@item_window.active = false
if @item.need_selection?
if @item.for_opponent?
start_target_enemy_selection
else
start_target_actor_selection
end
else
end_item_selection
@active_battler.cp = 0
next_actor
end
end
#--------------------------------------------------------------------------
# ● 开始处理战斗
#--------------------------------------------------------------------------
def process_battle_start
@message_window.clear
wait(10)
for name in $game_troop.enemy_names
text = sprintf(Vocab::Emerge, name)
$game_message.texts.push(text)
end
if $game_troop.preemptive
text = sprintf(Vocab::Preemptive, $game_party.name)
$game_message.texts.push(text)
for battler in $game_party.members
battler.cp = battler.maxcp
end
$game_troop.preemptive = false
elsif $game_troop.surprise
text = sprintf(Vocab::Surprise, $game_party.name)
$game_message.texts.push(text)
for battler in $game_troop.members
battler.cp = battler.maxcp
end
$game_troop.surprise = false
end
wait_for_message
@message_window.clear
@message_window.visible = false
make_escape_ratio
process_battle_event
#=====================
@status_window.index = @actor_index = -1
@cp_battle.stop = false
#=====================
end
#--------------------------------------------------------------------------
# ● 处理逃跑
#--------------------------------------------------------------------------
def process_escape
@info_viewport.visible = false
@party_command_window.active = 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
#=============================
@cp_battle.dispose
#=============================
for battler in $game_party.members
battler.cp = 0
end
wait_for_message
battle_end(1)
else
@escape_ratio += 10
@active_battler.cp = 0
$game_message.texts.push('\.' + Vocab::EscapeFailure)
wait_for_message
@active_battler.action.clear
@message_window.visible = false
next_actor
end
end
#--------------------------------------------------------------------------
# ● 处理胜利
#--------------------------------------------------------------------------
def process_victory
@info_viewport.visible = false
@message_window.visible = true
RPG::BGM.stop
$game_system.battle_end_me.play
for battler in $game_troop.members
if battler.dead?
if @cp_battle.cp_battler.include?(battler)
@cp_battle.cp_battler[battler].collapse = true
next
end
end
end
@cp_battle.cp_battler.each{|key,value|
if value.disposed?
@cp_battler.delete(key)
next
end
value.update}
#=============================
@cp_battle.dispose
#=============================
for battler in $game_party.members
battler.cp = 0
end
unless $BTEST
$game_temp.map_bgm.play
$game_temp.map_bgs.play
end
display_exp_and_gold
display_drop_items
display_level_up
battle_end(0)
end
#--------------------------------------------------------------------------
# ● 失败处理
#--------------------------------------------------------------------------
def process_defeat
@info_viewport.visible = false
@message_window.visible = true
@cp_battle.dispose
for battler in $game_party.members + $game_troop.members
battler.cp = 0
end
text = sprintf(Vocab::Defeat, $game_party.name)
$game_message.texts.push(text)
wait_for_message
battle_end(2)
end
#=============================================================================
#★CP战斗的主要刷新★
#=============================================================================
while @action_battlers.size != 0 and judge_win_loss == false
process_action
process_battle_event
end
@cp_battle.stop = false
#=============================
end
#=====================================
#★行动顺序生成
#=====================================
def make_action_orders
@action_battlers = []
unless $game_troop.surprise
@action_battlers += @actor_battler if @actor_battler.size != 0
end
unless $game_troop.preemptive
@action_battlers += @enemy_battler if @enemy_battler.size != 0
end
for battler in @action_battlers
battler.action.make_speed
end
@action_battlers.sort! do |a,b|
b.action.speed - a.action.speed
end
end
#--------------------------------------------------------------------------
# ● 处理战斗行动
#--------------------------------------------------------------------------
def process_action
return if judge_win_loss
return if $game_temp.next_scene != nil
set_next_active_battler
return if @active_battler == nil
return if @active_battler.dead?
@message_window.clear
wait(5)
@active_battler.white_flash = true
unless @active_battler.action.forcing
@active_battler.action.prepare
end
if @active_battler.action.valid?
execute_action
end
unless @active_battler.action.forcing
@message_window.clear
remove_states_auto
display_current_state
end
@active_battler.white_flash = false
@message_window.clear
end
#--------------------------------------------------------------------------
# ● 执行战斗行动: 攻击
#--------------------------------------------------------------------------
def execute_action_attack
text = sprintf(Vocab::DoAttack, @active_battler.name)
@message_window.add_instant_text(text)
targets = @active_battler.action.make_targets
display_attack_animation(targets)
wait(20)
for target in targets
target.attack_effect(@active_battler)
display_action_effects(target)
end
#=====================
@active_battler.cp = 0
#=====================