赞 | 2 |
VIP | 0 |
好人卡 | 7 |
积分 | 0 |
经验 | 31248 |
最后登录 | 2016-11-22 |
在线时间 | 175 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 47
- 在线时间
- 175 小时
- 注册时间
- 2012-1-10
- 帖子
- 889
|
可以用这个脚本:
#=============================================================================
#★Zhong RMVX 半即时战斗系统 1.02a版★
#-----------------------------------------------------------------------------
#★Scene_CP核心部分参考自 : 神思 《战斗真位移》战斗系统
#★作者: Zhong_zw
#★联系方式: 66rpg.com论坛短信 或 [email protected]
#★游戏中如若引用本脚本,请保留以上信息,并作相关说明.
#☆如若转载本脚本请联系本人☆
#=============================================================================
#=============================================================================
#☆1.01版修正问题:
#1、物品、特技窗口选择我方人物时,头像重叠
#2、连续伤害及自动回复效果无效。
#☆1.02版修正问题:
#1、减少刷新次数,提高速度
#2、修正被打击时有可能退到cp槽外
#☆1.02a版修正问题:
#1、复活问题.
#2、头像刷新问题.
#☆使用方法说明☆
#☆使用方法基本与我之前发的朴素横版战斗相同
#☆动画设置:
#1、武器、特技、物品的施展动画直接在其备注填入动画id即可。如果为空即不显示施展动画。
#2、敌人普通攻击动画,在其备注里填写格式如下:
# a1=XX #施展动画id
# a2=XX #对方动画id
#如果为空即使用默认普通动画(画面震动).
#☆战斗图设置:
#3、角色战斗图的的命名方式是角色id后面加上_z,如1_z.存放在Battlers文件夹。
#4、默认待机图为两帧,只要在Battlers文件夹里放一个“战斗图名+待“的文件,就会自动循环播放
#这两个战斗图,如1_b待,没有则没待机动作。
#☆战斗背景设置:
#5、在Graphics目录下新建Battlebacks文件夹。
#6、战斗时先搜索文件夹内是否有与角色所在区域同名的战斗图,如果没有则搜索文件夹里是否
#存在与地图同名的图片。
#7、简而言之,你须储存与你地图同名的战斗背景在Battlebacks,如果想在同一幅地图实现不同地域
#战斗背景不同,就在Battlebacks文件夹里储存与这个地域同名的战斗背景.至少保证战斗的地图
#都有一幅该地图同名的战斗背景,不然战斗时会提示找不到地图.(可参考《拉尔夫战记》或朴素横版的范例)
#☆CP条设置:
#8、CP条:在system文件夹里储存一个命名为"cp条"的图片,默认长度为327,如果需要可在Scene_CP类里调整相
#关参数.
#9、角色cp图命名方式是"角色id+_cp",如:1_cp,角色活跃cp图命名方式是"角色id+_a_cp",如1_a_cp,
#敌人cp图命名方式是"敌人名 + _敌人cp",如史莱姆_敌人cp,敌人活跃cp图是"敌人名+_a_cp".
#亦可在system文件夹里储存名为"敌人cp"的图片,作为敌人的统一cp图,活跃图名为"a_敌人cp",默认如果找不到敌人相关cp图就直接
#用这张图片.
#☆选择光标设置
#10、在system文件夹里储存名为"光标"的图片作为选择光标.
#=============================================================================
#================================================
#★战斗者类
#================================================
class Game_Battler
attr_accessor :cp
attr_accessor :cp_total
attr_accessor :cp_turn #角色能不行动时,计算角色实际cp爆满次数,用以代替回合,计算状态解除时机
#=======================================
attr_accessor :animation2_id
attr_accessor :act_status
attr_accessor :damage
attr_accessor :damage_pop
attr_accessor :slip_damage
attr_accessor :auto_damage
#=========================================
alias oldinitialize initialize
def initialize
@cp = 0
@cp_total = false
@cp_turn = 0
@damage = nil
@damage_pop = false
@act_status = 0
@slip_damage = 0
@auto_damage = 0
oldinitialize
end
def maxcp
return 100
end
#--------------------------------------------------------------------------
# ● 应用连续伤害效果
#--------------------------------------------------------------------------
def slip_damage_effect
if slip_damage? and @hp > 0
@hp_damage = apply_variance(maxhp / 10, 10)
@hp_damage = @hp - 1 if @hp_damage >= @hp
@slip_damage = @hp_damage
self.hp -= @hp_damage
end
end
end #class
#===============================================
#★角色队伍类
#===============================================
class Game_Party < Game_Unit
attr_accessor :actor_battler
alias oldinitialize initialize
def initialize
oldinitialize
@actor_battler = []
end
end #class
#================================================
#★敌人队伍类
#================================================
class Game_Troop < Game_Unit
attr_accessor :enemy_battler
alias oldinitialize initialize
def initialize
oldinitialize
@enemy_battler = []
end
end#class
#================================================
#★cp条处理类
#================================================
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}")
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
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
@select_icon = Sprite.new
@select_icon.z = 148
@select_icon.bitmap = Bitmap.new("Graphics/system/光标")
@select_icon.opacity = 240
@select_icon.visible = false
@c_c = 0
end
#==============================================================
#★ 定义光标刷新
#==============================================================
def select_icon_update(s_sw = false)
if s_sw == false
@select_icon.visible = false
else
@select_icon.visible = true
@select_icon.x = $game_troop.members[@target_enemy_window.enemy.index].screen_x
@select_icon.y = $game_troop.members[@target_enemy_window.enemy.index].screen_y - 30
if @c_c%2 == 0
@select_icon.opacity += 30
else
@select_icon.opacity -= 30
end
end
end
#=================================================
#★主刷新部分
#=================================================
def update
super
@c_c += 1
update_basic(true)
update_info_viewport
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 @actor_command_window.active
update_actor_command_selection
#=================================
elsif @cp_battle.stop == false
active_battler_update
#=================================
else
process_battle_event
process_action
process_battle_event
end
#end
end
#================================================
#★战斗初始化
#===============================================
def start_party_command_selection
if $game_temp.in_battle
@status_window.refresh
@status_window.index = @actor_index = -1
@active_battler = nil
@actor_command_window.active = false
$game_party.clear_actions
for i in 0..$game_party.members.size-1
if $game_party.members.act_status != -1
$game_party.members.act_status = -1
end
end
if $game_troop.surprise or not $game_party.inputable?
start_main
end
end
end
#=============================================
#★角色回合的处理函数
#=============================================
def next_actor
for i in 0..$game_party.members.size-1
if $game_party.members.act_status != -1
$game_party.members.act_status = -1
end
end
@info_viewport.visible = true
@status_window.refresh
@now_face = -1
@actor_command_window.update
@status_window.update
loop do
if @actor_index == @actor_battler.size - 1
start_main
return
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
#===================================================
#★激活角色指令窗口
#===================================================
def start_actor_command_selection
@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::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
next_actor
@active_battler.cp = 0
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 start_target_enemy_selection
if @skill_window != nil
@skill_window.visible = false
end
if @item_window != nil
@item_window.visible = false
end
@target_enemy_window = Window_TargetEnemy.new
@target_enemy_window.opacity = 0
@target_enemy_window.contents_opacity = 0
#@target_enemy_window.y = @info_viewport.rect.y
#@info_viewport.rect.x += @target_enemy_window.width
#@info_viewport.ox += @target_enemy_window.width
@actor_command_window.active = false
select_icon_update(true)
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
select_icon_update
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
#======================================================
#★己方选择
#======================================================
def start_target_actor_selection
@target_actor_window = Window_BattleStatus.new
@target_actor_window.index = 0
@target_actor_window.active = true
@target_actor_window.y = @info_viewport.rect.y
@target_actor_window.draw_actorface($game_party.members[@target_actor_window.index])
@info_viewport.rect.x += @target_actor_window.width
@info_viewport.ox += @target_actor_window.width
@actor_command_window.active = false
#=====================
#☆减少刷新次数
#=====================
@last_index = -1
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
#=====================
#☆减少刷新次数
#=====================
@last_index = -1
end
#===================================================
#★己方选择刷新
#===================================================
def update_target_actor_selection
if @last_index != @target_actor_window.index
@target_actor_window.refresh
@target_actor_window.draw_actorface($game_party.members[@target_actor_window.index])
@last_index = @target_actor_window.index
end
@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
@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
#===============================================
#★各窗口视口生成
#===============================================
def create_info_viewport
@info_viewport = Viewport.new(0, 288, 544, 256)
@info_viewport.z = 100
@status_window = Window_BattleStatus.new
@actor_command_window = Window_ActorCommand.new
@status_window.viewport = @info_viewport
@actor_command_window.viewport = @info_viewport
@status_window.x = 0
@actor_command_window.x = 416
@status_window.y = 128
@actor_command_window.y = 128
@info_viewport.visible = false
#========================
#☆减少头像刷新用
#========================
@now_face = -1
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
end
#================================================
#★战斗开始 处理
#================================================
def process_battle_start
if $game_troop.preemptive
for battler in $game_party.members
battler.cp = battler.maxcp
end
$game_troop.preemptive = false
elsif $game_troop.surprise
for battler in $game_troop.members
battler.cp = battler.maxcp
end
$game_troop.surprise = false
end
make_escape_ratio
process_battle_event
#===========================================
@status_window.refresh
@status_window.index = @actor_index = -1
#=====================
@cp_battle.stop = false
#=====================
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
battle_end(2)
end
#=============================================================================
#★CP战斗的主要刷新★
#=============================================================================
def active_battler_update
#===================================
@actor_battler = []
@enemy_battler = []
$game_party.actor_battler = []
$game_troop.enemy_battler = []
#===================================
@cp_battle.update
@actor_battler = $game_party.actor_battler
@enemy_battler = $game_troop.enemy_battler
#for battler in $game_party.members + $game_troop.members
#end
if @actor_battler.size != 0
@cp_battle.stop = true
next_actor
Audio.se_play("Audio/SE/Jump2",100,100)
elsif @enemy_battler.size != 0
#================
@cp_battle.stop = true
start_main
#================
end
end
#=============================================================
#=============================================================
#====================================================
#★战斗主处理
#====================================================
def start_main
for i in 0..$game_party.members.size-1
if $game_party.members.act_status != 0
$game_party.members.act_status = 0
end
end
if @info_viewport.visible
@info_viewport.visible = false
@status_window.y = 128
@actor_command_window.y = 128
end
@actor_command_window.active = false
@status_window.index = @actor_index = -1
@active_battler = nil
make_action_orders
wait(20)
#=============================
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
end
#=================================
#★攻击行动 执行
#=================================
def execute_action_attack
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
#=====================
end
#===============================
#★防御行动 执行
#===============================
def execute_action_guard
wait(45)
#=====================
@active_battler.cp = 0
#=====================
end
#===============================
#★逃走 执行
#===============================
def execute_action_escape
@active_battler.escape
Sound.play_escape
wait(45)
#=====================
@active_battler.cp = 0
#=====================
end
#====================================
#★待机 执行
#====================================
def execute_action_wait
wait(45)
#=====================
@active_battler.cp = 0
#=====================
end
#============================
#★特技 执行
#============================
def execute_action_skill
skill = @active_battler.action.skill
targets = @active_battler.action.make_targets
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
#==============================
#★物品行动 执行
#==============================
def execute_action_item
item = @active_battler.action.item
user = @active_battler.action.skill_user
if item.animation2_id != 0
display_animation(user,item.animation2_id)
end
targets = @active_battler.action.make_targets
display_animation(targets, item.animation_id)
wait_for_animation
$game_party.consume_item(item)
$game_temp.common_event_id = item.common_event_id
for target in targets
target.item_effect(@active_battler, item)
display_action_effects(target, item)
end
#=====================
@active_battler.cp = 0
#=====================
end
#===========================
#★行动动画显示
#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)
end
#====================================
#★普通攻击的动画显示
#====================================
def display_attack_animation(targets)
if @active_battler.is_a?(Game_Enemy)
user = @active_battler.action.skill_user
if @select_input == true
a1 = 0
a2 = 0
eval(@active_battler.note)
display_normal_animation(user,a1)if a1 != 0
display_normal_animation(targets,a2)if a2 !=0
Sound.play_enemy_attack if a1 == 0 and a2 == 0
wait(15, true) if a1 == 0 and a2 == 0
elsif @active_battler.animation1_id != 0 or @active_battler.animation2_id != 0
display_normal_animation(user,@active_battler.animation1_id)if @active_battler.animation1_id != 0
display_normal_animation(targets,@active_battler.animation2_id)if @active_battler.animation2_id != 0
Sound.play_enemy_attack if @active_battler.animation1_id == 0 and @active_battler.animation2_id == 0
wait(15, true) if @active_battler.animation1_id == 0 and @active_battler.animation2_id == 0
end
else
aid1 = @active_battler.atk_animation_id
aid2 = @active_battler.atk_animation_id2
user = @active_battler.action.skill_user
if @active_battler.act_animation_id != 0
display_normal_animation(user,@active_battler.act_animation_id)
end
display_normal_animation(targets, aid1, false)
display_normal_animation(targets, aid2, true)
end
wait_for_animation
end
#========================================
#★显示行动结果
#========================================
def display_action_effects(target, obj = nil)
unless target.skipped
wait(5)
#=======================
target.damage_pop = true
#=======================
display_critical(target, obj)
display_damage(target, obj)
display_state_changes(target, obj)
end
end
#======================================
#★显示HP伤害
#======================================
def display_hp_damage(target, obj = nil)
if target.hp_damage == 0
return if obj != nil and obj.damage_to_mp
return if obj != nil and obj.base_damage == 0
elsif target.absorbed # 吸収
#=====================================
@active_battler.damage_pop = true
@active_battler.damage = target.hp_damage
target.cp -= target.hp_damage/100
@cp_battle.cp_battler[target].x = [95+300*target.cp/target.maxcp,95].max
if target.dead?
@cp_battle.cp_battler[target].collapse = true
target.cp = 0
@cp_battle.cp_battler[target].update
end
#=====================================
elsif target.hp_damage > 0
if target.actor?
Sound.play_actor_damage
$game_troop.screen.start_shake(5, 5, 10)
else
Sound.play_enemy_damage
target.blink = true
end
#=====================================
target.cp -= target.hp_damage/100
@cp_battle.cp_battler[target].x = [95 + 300*target.cp/target.maxcp,95].max
if target.dead?
@cp_battle.cp_battler[target].collapse = true
target.cp = 0
@cp_battle.cp_battler[target].update
end
#wait(10)
#=====================================
else
Sound.play_recovery
end
end
#--------------------------------------------------------------------------
# ● MP 伤害表示
#--------------------------------------------------------------------------
def display_mp_damage(target, obj = nil)
return if target.dead?
return if target.mp_damage == 0
if target.absorbed # 吸收
#=====================================
@active_battler.damage_pop = true
@active_battler.damage = - target.mp_damage
target.cp -= target.mp_damage/100
@cp_battle.cp_battler[target].x = [95+300*target.cp/target.maxcp,95].max
#=====================================
elsif target.mp_damage > 0
#=====================================
target.cp -= target.mp_damage/100
@cp_battle.cp_battler[target].x = [95+300*target.cp/target.maxcp,95].max
#=====================================
else
Sound.play_recovery
end
end
#=======================================
#★重定义对话窗口刷新
#=======================================
def wait_for_message
wait(45)
end
#================================================
#★经验金钱获得物品提示窗口(原方法重定义)
#================================================
def display_exp_and_gold
exp=$game_troop.exp_total
gold=$game_troop.gold_total
$game_party.gain_gold(gold)
drop_items = $game_troop.make_drop_items
@window_egi = Window_egi.new(exp,gold,drop_items)
@window_egi.openness=0
wait(15)
loop do
if @window_egi.openness <= 255
@window_egi.openness+=48
end
if Input.trigger?(Input::C) or Input.trigger?(Input::B)
break
end
Graphics.update
Input.update
end
loop do
@window_egi.openness -= 48 if @window_egi.openness >= 0
Graphics.update
if @window_egi.openness <= 0
break
end
end #loop
end
alias oldstart_skill_selection start_skill_selection
def start_skill_selection
oldstart_skill_selection
@skill_window.z = 3000
@skill_window.help_window.z = 3000
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
end #class
#=====================================================
#★战斗状态窗口类
#=====================================================
class Window_BattleStatus < Window_Selectable
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, 96, rect.y)
draw_actor_state(actor, 114+48, rect.y, 48)
draw_actor_hp(actor, 174, rect.y, 120)
draw_actor_mp(actor, 310, rect.y, 70)
end
#=======================================================================
#★定义角色头像的描绘
#=======================================================================
def draw_actorface(actor)
draw_face(actor.face_name, actor.face_index, 5, 5, size = 80)
end
#=========================================================================
def update_cursor
super
self.cursor_rect.width = self.width - 120
self.cursor_rect.x = 90
end
#========================================================================
end #class
#=================================================
#★战斗图处理的类
#=================================================
class Sprite_Battler < Sprite_Base
#=================================
#★刷新
#=================================
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
def skill_user
targets = []
targets.push(battler)
return targets.compact
end
end#class
#=======================================================
#★处理敌人的类
#
#=======================================================
class Game_Enemy < Game_Battler
def note
return $data_enemies[@enemy_id].note
end
end#class
#======================================================
#★角色处理类
#======================================================
class Game_Actor < Game_Battler
def setup(actor_id)
actor = $data_actors[actor_id]
@actor_id = actor_id
@name = actor.name
#--------------------------------------------
#★添加战斗图名称,以便战斗中获取战斗图
#--------------------------------------------
@battler_name = actor_id.to_s + "_z"
@battler_hue = 0
@flash = false
@character_name = actor.character_name
@character_index = actor.character_index
@face_name = actor.face_name
@face_index = actor.face_index
@class_id = actor.class_id
@weapon_id = actor.weapon_id
@armor1_id = actor.armor1_id
@armor2_id = actor.armor2_id
@armor3_id = actor.armor3_id
@armor4_id = actor.armor4_id
@level = actor.initial_level
@exp_list = Array.new(101)
make_exp_list
@exp = @exp_list[@level]
@skills = []
for i in self.class.learnings
learn_skill(i.skill_id) if i.level <= @level
end
clear_extra_values
recover_all
end
#--------------------------------------------------------------------------
# ● 执行自动回复 (回合结束时调用)
#--------------------------------------------------------------------------
def do_auto_recovery
if auto_hp_recover and not dead?
self.hp += maxhp / 20
@auto_damage = maxhp / 20
end
end
#==========================================================================
#★ 定义武器的行动方动画id,默认为第一武器的id
#==========================================================================
def act_animation_id
return weapons[0] == nil ? 0 : weapons[0].animation2_id
end
#==========================================================================
#==========================================================================
#==========================================================================
#★定义角色战斗图 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
end
#======================================================
#★精灵类主模块_伤害部分的添加
#======================================================
class Sprite_Base < Sprite
def initialize(viewport = nil)
super(viewport)
@use_sprite = true
@animation_duration = 0
#=============
@_damage_duration = 0
#=============
end
alias oldupdate update
def update
oldupdate
#================
damge_update
#================
end
alias olddispose dispose
def dispose
olddispose
#===============
dispose_damage
#===============
end
#==========================================================================
#★定义伤害处理
#==========================================================================
def damage(value, critical,type = 0)
dispose_damage
if value.is_a?(Numeric)
damage_string = value.abs.to_s
else
damage_string = value.to_s
end
bitmap = Bitmap.new(160, 48)
bitmap.font.name = "黑体"
bitmap.font.size = 25
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
if value.is_a?(Numeric) and value < 0
case type
when 0
bitmap.font.color.set(176, 255, 144)
when 1
bitmap.font.color.set(0,100,255)
end
else
case type
when 0
bitmap.font.color.set(255, 255, 255)
when 1
bitmap.font.color.set(200,0,185)
end
end
bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
if critical and type == 0
bitmap.font.size = 18
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
bitmap.font.color.set(255, 255, 255)
bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
end
@_damage_sprite = ::Sprite.new(self.viewport)
@_damage_sprite.bitmap = bitmap
@_damage_sprite.ox = 80
@_damage_sprite.oy = 20
@_damage_sprite.x = self.x
@_damage_sprite.y = self.y - self.oy / 2
@_damage_sprite.z = 3000
@_damage_duration = 40
end
#===================================================
#
#===================================================
def dispose_damage
if @_damage_sprite != nil
@_damage_sprite.bitmap.dispose
@_damage_sprite.dispose
@_damage_sprite = nil
@_damage_duration = 0
end
end
#=============================================
#
#=============================================
def damge_update
if @_damage_duration > 0
@_damage_duration -= 1
case @_damage_duration
when 38..39
@_damage_sprite.y -= 4
when 36..37
@_damage_sprite.y -= 2
when 34..35
@_damage_sprite.y += 2
when 28..33
@_damage_sprite.y += 4
end
@_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
if @_damage_duration == 0
dispose_damage
end
end
end
end#class
#=======================================================
#★战斗经验、金钱、物品提示窗口
#=======================================================
class Window_egi<Window_Base
#====================================
#●初始化
#====================================
def initialize(exp, gold,item)
@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
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.size=19
if @exp > 0
self.contents.font.color = Color.new(255,255,0,255)
self.contents.draw_text(6,8,64,32,"获得经验:")
self.contents.font.color = Color.new(255,255,255,255)
self.contents.draw_text(80,8,32,32,sprintf("%4s",@exp))
elsif @exp == 0
self.contents.font.color = Color.new(255,0,0,0)
self.contents.draw_text(6,8,32,32,"没有获得经验!")
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
#=====================================================
#添加战斗背景的相关定义
#=====================================================
class Game_Map
attr_accessor :name
def setup(map_id)
@map_id = map_id
@map = load_data(sprintf("Data/Map%03d.rvdata", @map_id))
@mapinfo = load_data("Data/MapInfos.rvdata")
#============================
@name = @mapinfo[@map_id].name
#============================
@display_x = 0
@display_y = 0
@passages = $data_system.passages
referesh_vehicles
setup_events
setup_scroll
setup_parallax
@need_refresh = false
end #class
def area(old_name,new_name)
for area in $data_areas.values
if area.name == old_name and area.map_id == @map_id
area.name == new_name
end
end
end
end #class
class Spriteset_Battle
def create_battleback
source = $game_temp.background_bitmap
bitmap = Bitmap.new(640, 480)
bitmap.blt(0,0,source,source.rect)
@battleback_sprite = Sprite.new(@viewport1)
@battleback_sprite.bitmap = bitmap
@battleback_sprite.ox = 272
@battleback_sprite.oy = 208
@battleback_sprite.x = 260
@battleback_sprite.y = 208
end
alias oldcreate_battlefloor create_battlefloor
def create_battlefloor
oldcreate_battlefloor
@battlefloor_sprite.opacity = 0
end
end#class
给你范例:
VX半即时范例1.02a.rar
(714.71 KB, 下载次数: 750)
|
|