class Scene_CP
attr_accessor :stop
attr_accessor :in_battler
attr_accessor :cp_battler
BATTLE_SPEED = 0.8
def initialize
@stop = false
@all_agi = 0
@v = Viewport.new(0, 0, 544, 90)
@count = 0
@cpline = Sprite.new(@v)
@cpline.bitmap = Bitmap.new(544,416)
bitmap = Bitmap.new("Graphics/system/cp条")
@cpline.bitmap.blt(105,8,bitmap,bitmap.rect)
@cp_battler = {}
for battler in $game_party.members + $game_troop.members
@all_agi += battler.agi
@cp_battler[battler] = Sprite_cpbattler.new
if battler.is_a?(Game_Actor)
@cp_battler[battler].bitmap = Bitmap.new("Graphics/system/#{battler.id.to_s}_cp")
@cp_battler[battler].bitmap.blt(80,60,@cp_battler[battler].bitmap,@cp_battler[battler].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
#@cp_battler.each{|key,value|
#if value.disposed? or value.opacity == 0
# @cp_battler.delete(key)
# next
#end
#value.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)
@cp_battler[battler].bitmap = Bitmap.new("Graphics/system/#{battler.id.to_s}_a_cp")
@cp_battler[battler].bitmap.blt(80,60,@cp_battler[battler].bitmap,@cp_battler[battler].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)
@cp_battler[battler].bitmap = Bitmap.new("Graphics/system/#{battler.id.to_s}_cp")
@cp_battler[battler].bitmap.blt(80,60,@cp_battler[battler].bitmap,@cp_battler[battler].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
battler.remove_states_auto unless battler.movable?
battler.slip_damage_effect
battler.do_auto_recovery if battler.is_a?(Game_Actor)
battler.damage_pop = true if battler.slip_damage != 0 or battler.auto_damage != 0
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
super
end
end
#==========================================================================
#
#==========================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ● 開始処理
#--------------------------------------------------------------------------
def start
super
#======================
@select_input = true
#======================
$game_temp.in_battle = true
#=============================================
unless $BTEST
@battleback = nil
for area in $data_areas.values
if $game_player.in_area?(area)
name = area.name
@battleback = Cache.battleback("#{name}")if FileTest.exist?("Graphics/Battlebacks/#{name}.jpg") or FileTest.exist?("Graphics/Battlebacks/#{name}.jpg") or FileTest.exist?("Graphics/Battlebacks/#{name}.bmp")
break
end
end
if @battleback == nil
name = $game_map.name
@battleback = Cache.battleback("#{name}")
end
$game_temp.background_bitmap = @battleback
end
#==================================================
@spriteset = Spriteset_Battle.new
@message_window = Window_BattleMessage.new
@message_window.visible = false
@action_battlers = []
@cp_battle = Scene_CP.new
@cp_battle.stop = false
create_info_viewport
end
@actor_index += 1
index = 0
for battler in $game_party.members
if battler == @actor_battler[@actor_index]
break
else
index += 1
end
end
@status_window.index = index
if @active_battler != nil and @active_battler != @actor_battler[@actor_index] and @active_battler.is_a?(Game_Actor)
@active_battler.act_status = -1
end
@active_battler = @actor_battler[@actor_index]
@active_battler.act_status = 1
if @active_battler.auto_battle
@active_battler.make_action
next
end
break if @active_battler.inputable?
end
start_actor_command_selection
end
if @actor_command_window.index == 0
@actor_command_window.active = true
end
end
#=======================================================
#★敌人选择刷新
#=======================================================
def update_target_enemy_selection
@target_enemy_window.update
select_icon_update(true)
if Input.trigger?(Input::B)
Sound.play_cancel
if @skill_window != nil
@skill_window.visible = true
end
if @item_window != nil
@item_window.visible = true
end
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
next_actor
@active_battler.cp = 0
end
end
end_target_actor_selection
end_skill_selection
end_item_selection
next_actor
@active_battler.cp = 0
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
next_actor
@active_battler.cp = 0
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
next_actor
@active_battler.cp = 0
end
end
end
#================================================
#★视口释放
#================================================
def dispose_info_viewport
@status_window.dispose
@actor_command_window.dispose
@info_viewport.dispose
#========================
#☆减少头像刷新用
#========================
@now_face = -1
if @window_egi != nil
@window_egi.dispose
end
end
#======================================================
#★视口刷新
#======================================================
def update_info_viewport
@actor_command_window.update
if @active_battler != nil and @active_battler.is_a?(Game_Actor) and @active_battler.id != @now_face
@status_window.draw_actorface(@active_battler)
@now_face = @active_battler.id
end
@status_window.update
if @actor_command_window.active and @actor_command_window.y > 0
@actor_command_window.y -= 8
@status_window.y -= 8
end
#==========================================
#★逃走处理
#==========================================
def process_escape
@info_viewport.visible = false
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
battle_end(1)
else
@escape_ratio += 10
@active_battler.cp = 0
@active_battler.action.clear
next_actor
end
end
#========================================
#★胜利处理
#========================================
def process_victory
@info_viewport.visible = false
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
@cp_battle.dispose
for battler in $game_party.members + $game_troop.members
battler.cp = 0
end
@info_viewport.visible = false
while @action_battlers.size != 0 and judge_win_loss == false
process_action
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?
@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
remove_states_auto
display_current_state
end
@active_battler.white_flash = false
user = @active_battler.action.skill_user
if skill.animation2_id != 0
display_animation(user,skill.animation2_id)
end
display_animation(targets, skill.animation_id)
wait_for_animation
@active_battler.mp -= @active_battler.calc_mp_cost(skill)
$game_temp.common_event_id = skill.common_event_id
for target in targets
target.skill_effect(@active_battler, skill)
display_action_effects(target, skill)
end
#=====================
@active_battler.cp = 0
#=====================
end
end
alias oldstart_item_selection start_item_selection
def start_item_selection
oldstart_item_selection
@item_window.z=3000
@item_window.help_window.z = 3000
end
#=================================
#★刷新
#=================================
def update
super
if @battler == nil
self.bitmap = nil
else
@use_sprite = @battler.use_sprite?
if @use_sprite
self.x = @battler.screen_x
self.y = @battler.screen_y
self.z = @battler.screen_z
update_battler_bitmap
if @battler.act_status == 1
if self.opacity <280
self.opacity += 20
end
elsif @battler.act_status == -1
if self.opacity > 125
self.opacity -= 20
end
elsif (@battler.dead? or @battler.hidden) and @battler.collapse == false
else
self.opacity = 255
end
end
setup_new_effect
update_effect
end
end
#===============================
#
#===============================
def update_battler_bitmap
if @battler.battler_name != @battler_name or
@battler.battler_hue != @battler_hue
@battler_name = @battler.battler_name
@battler_hue = @battler.battler_hue
self.bitmap = Cache.battler(@battler_name, @battler_hue)
@width = bitmap.width
@height = bitmap.height
self.ox = @width / 2
self.oy = @height
if (@battler.dead? or @battler.hidden) and @battler.collapse == false
end
end
if @battler.is_a?(Game_Actor)
count = 40
else
count = 44
end
if Graphics.frame_count%count <= 19
self.bitmap = Cache.battler(@battler_name,@battler_hue)
@width = bitmap.width
@height = bitmap.height
self.ox = @width / 2
self.oy = @height
else
b_name = @battler_name + "待"
if FileTest.exist?("Graphics/Battlers/#{b_name}.png") or FileTest.exist?("Graphics/Battlers/#{b_name}.jpg") or FileTest.exist?("Graphics/Battlers/#{b_name}.bmp")
self.bitmap = Cache.battler(b_name,@battler_hue)
@width = bitmap.width
@height = bitmap.height
self.ox = @width/2
self.oy = @height
end
end
end
#==================================
#
#==================================
def setup_new_effect
if @battler.white_flash
@effect_type = WHITEN
@effect_duration = 16
@battler.white_flash = false
end
if @battler.blink
@effect_type = BLINK
@effect_duration = 20
@battler.blink = false
end
if not @battler_visible and @battler.exist?
@effect_type = APPEAR
@effect_duration = 16
@battler_visible = true
end
if @battler.damage_pop and not (@battler.collapse or @battler.hidden)
if @battler.damage != nil
s_1 = @battler.damage > 0 ? 0 : 1
@battler.damage = @battler.damage > 0 ? [email protected] : @battler.damage
end
damage(@battler.damage,@battler.critical,s_1) if @battler.damage != 0 and @battler.damage != nil
damage(@battler.hp_damage,@battler.critical,0) if @battler.hp_damage != 0
damage(@battler.mp_damage,@battler.critical,1) if @battler.mp_damage != 0
damage("失误",@battler.critical) if @battler.missed
damage("MISS",@battler.critical) if @battler.evaded
damage(@battler.slip_damage - @battler.auto_damage,@battler.critical) if @battler.slip_damage != 0 or @battler.auto_damage != 0
@battler.slip_damage = 0
@battler.auto_damage = 0
@battler.damage = nil
@battler.damage_pop = false
end
if @battler_visible and @battler.hidden
@effect_type = DISAPPEAR
@effect_duration = 32
@battler_visible = false
end
if @battler.collapse and self.opacity != 0
@effect_type = COLLAPSE
@effect_duration = 48
@battler.collapse = false
@battler_visible = false
end
if @battler.animation_id != 0 and @battler.collapse == false
self.opacity = 255
animation = $data_animations[@battler.animation_id]
mirror = @battler.animation_mirror
start_animation(animation, mirror)
@battler.animation_id = 0
end
end
#=========================================
#
#=========================================
end #class
#=================================================
#★处理战斗行动的类
#=================================================
class Game_BattleAction
#==========================================================================
#==========================================================================
#==========================================================================
#★定义角色战斗图 X 坐标
#==========================================================================
def screen_x
if self.index != nil
case index
when 0
return 460
when 1
return 440
when 2
return 420
when 3
return 400
end
else
return 0
end
end
#========================================================================
#★定义角色战斗图 Y 坐标
#========================================================================
def screen_y
if self.index != nil
case index
when 0
return 245
when 1
return 215
when 2
return 185
when 3
return 155
end
else
return 230
end
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
#==========================================================
#★模块定义
#==========================================================
module RPG
class BaseItem
def animation2_id
return @note != nil ? @note.to_i : 0
end
end
class Enemy
def animation1_id
animation1_id = @note.split(/,/)[0]
return animation1_id != nil ? animation1_id.to_i : 0
end
def animation2_id
animation2_id = @note.split(/,/)[1]
return animation2_id != nil ? animation2_id.to_i : 0
end
end
@exp=exp
@gold=gold
@item=item
@item_name = {}
n=0
m=0
if @item != nil
for itn in @item
if @item_name[itn.name]==nil
@item_name[itn.name]=0
m+=1
end
end
end
if @gold>0
m+=1
end
super(200,100, 160,32*m+112 )
self.opacity = 150
end
if @gold>0
self.contents.font.color = Color.new(255,255,0,255)
self.contents.draw_text(6,40,64,32,"获得金钱:")
self.contents.font.color = Color.new(255,255,255,255)
self.contents.draw_text(80,40,32,32,sprintf("%4s",@gold)+Vocab::gold)
end
if @item_name.size != 0
self.contents.font.size = 20
self.contents.font.color = Color.new(255,255,0)
self.contents.draw_text(25,72,64,32,"获得物品")
i=0
for itn in @item
if @item_name[itn.name] == 0
draw_icon(itn.icon_index ,6 ,106+i*32 , true)
i+=1
end
@item_name[itn.name]+=1
end
i=0
self.contents.font.size = 18
self.contents.font.color = Color.new(255,255,255,255)
for itn in @item_name
self.contents.draw_text(30,106+i*32,64,32,itn[0].to_s + " × "+itn[1].to_s)
i+=1
end
end
end
end#class
module Cache
def self.battleback(filename)
load_bitmap("Graphics/Battlebacks/", filename)
end
end