#==============================================================================
# ■ 全动画战斗
#------------------------------------------------------------------------------
# By whbm
# 应用脚本 彩虹神剑 By 66
#==============================================================================
#==============================================================================
#简要介绍:
# 本脚本实现了战斗的动态效果,其中包含了待机、攻击、防御、挨打、胜利、死亡。类似于超级横版、超级战斗。但是本系统特色在于所有效果的实现并不是靠庞大的战斗图,而是使用了数据库中的动画。这样不仅突破了不同人不同祯数量的限制,并且方便了单动画单祯的修改。
#使用方法:
# 个人觉得还是比较简单,但是大量的怪物还是会令人头痛。
# 1.数据库的设置
# 敌人必要的动画有待机、挨打、死亡三个必要的动画
# 角色必要的动画有待机、挨打、防御、死亡动态、胜利动态、死亡静态、胜利静态
#
# 死亡静态与胜利静态:动画中只有1祯,为相应动态动画的最后一祯
#
# 剩下的就是人物攻击的动画,和正常的动画是一样设置
# 如图中的攻击等待动画只是为了在播放攻击动画的同时消除人物本身(素材原因,人物攻击的时候离开了原位,如果是在原位置放魔法是用不上的)
# 2.战斗图的设置
# 战斗图其实只是一个透明的图片,它只是用来描述一个敌人或者角色的大小,并与相应的战斗动画编号相衔接。
# 战斗图的文件名格式如下:
# 名字★待机★防御★挨打★死亡动态★死亡静态★胜利动态★胜利静态.png
# (其中“名字”一项与动画无关)
# 例如:
# 紫烟★140★141★148★149★150★144★145.png
# 对于敌人无胜利动画或者防御动画,请保持该位置为空,例如:
# 蓝若冰★124★★126★127★★★.png
# 综上,设置就这么完成了。
#注意事项:
# 1.由于系统中待机由动画实现,所以无法使用状态附带动画的功能。
# 2.可以在脚本中使用Ctrl+Shift+F通篇搜索“小改动”,可以修改某些窗口的Z值。
# 3.当您将此系统向您的工程中移植的时候也要注意事项2中的“小改动”。
# 4.系统是从游戏“石焚刃暖”中提取出来的,或许会有疏漏与多余的东西,BUG也是不免的。大家尽管提便是。
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
# ● 初始化变量
#--------------------------------------------------------------------------
def initialize
# 生成显示端口
@viewport1 = Viewport.new(0, 0, 640, 480)
@viewport2 = Viewport.new(0, 0, 640, 480)
@viewport3 = Viewport.new(0, 0, 640, 480)
@viewport4 = Viewport.new(0, 0, 640, 480)
@viewport2.z = 101
@viewport3.z = 200
@viewport4.z = 5000
# 生成战斗背景活动块
@battleback_sprite = Sprite.new(@viewport1)
# 生成敌人活动块
@enemy_sprites = []
for enemy in $game_troop.enemies.reverse
@enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
end
# 生成敌人活动块
@actor_sprites = []
@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))
# 生成天候
@weather = RPG::Weather.new(@viewport1)
# 生成图片活动块
@picture_sprites = []
for i in 51..100
@picture_sprites.push(Sprite_Picture.new(@viewport3,
$game_screen.pictures[i]))
end
# 生成计时器块
@timer_sprite = Sprite_Timer.new
# 刷新画面
update
end
#..........................................................................
#--------------------------------------------------------------------------
# ● 胜利图
#--------------------------------------------------------------------------
def win
for sprite in @actor_sprites
sprite.win
end
end
#..........................................................................
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新角色的活动块 (对应角色的替换)
@actor_sprites[0].battler = $game_party.actors[0]
@actor_sprites[1].battler = $game_party.actors[1]
@actor_sprites[2].battler = $game_party.actors[2]
@actor_sprites[3].battler = $game_party.actors[3]
# 战斗背景的文件名与现在情况有差异的情况下
if @battleback_name != $game_temp.battleback_name
@battleback_name = $game_temp.battleback_name
if @battleback_sprite.bitmap != nil
@battleback_sprite.bitmap.dispose
end
@battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
@battleback_sprite.src_rect.set(0, 0, 640, 480)
end
# 刷新战斗者的活动块
for sprite in @enemy_sprites + @actor_sprites
sprite.update
end
# 刷新天气图形
@weather.type = $game_screen.weather_type
@weather.max = $game_screen.weather_max
@weather.update
# 刷新图片活动块
for sprite in @picture_sprites
sprite.update
end
# 刷新计时器活动块
@timer_sprite.update
# 设置画面的色调与震动位置
@viewport1.tone = $game_screen.tone
@viewport1.ox = $game_screen.shake
# 设置画面的闪烁色
@viewport4.color = $game_screen.flash_color
# 刷新显示端口
@viewport1.update
@viewport2.update
@viewport4.update
end
end
class Arrow_Enemy < Arrow_Base
#--------------------------------------------------------------------------
# ● 获取光标指向的敌人
#--------------------------------------------------------------------------
def enemy
return $game_troop.enemies[@index]
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
# 如果指向不存在的敌人就离开
$game_troop.enemies.size.times do
break if self.enemy.exist?
@index += 1
@index %= $game_troop.enemies.size
end
# 光标右
if Input.repeat?(Input::RIGHT)
$game_system.se_play($data_system.cursor_se)
$game_troop.enemies.size.times do
@index += 1
@index %= $game_troop.enemies.size
break if self.enemy.exist?
end
end
# 光标左
if Input.repeat?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
$game_troop.enemies.size.times do
@index += $game_troop.enemies.size - 1
@index %= $game_troop.enemies.size
break if self.enemy.exist?
end
end
# 设置活动块坐标
if self.enemy != nil
self.x = self.enemy.screen_x + self.ox
self.y = self.enemy.screen_y + self.oy
end
end
end
class Arrow_Actor < Arrow_Base
#--------------------------------------------------------------------------
# ● 获取光标指向的角色
#--------------------------------------------------------------------------
def actor
return $game_party.actors[@index]
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
# 光标右
if Input.repeat?(Input::RIGHT)
$game_system.se_play($data_system.cursor_se)
@index += 1
@index %= $game_party.actors.size
end
# 光标左
if Input.repeat?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
@index += $game_party.actors.size - 1
@index %= $game_party.actors.size
end
# 设置活动块坐标
if self.actor != nil
self.x = self.actor.screen_x + self.ox
self.y = self.actor.screen_y + self.oy
end
end
end
class Scene_Battle
#--------------------------------------------------------------------------
# ● 刷新画面 (主回合步骤 3 : 行动方动画)
#--------------------------------------------------------------------------
def update_phase4_step3
# 行动方动画 (ID 为 0 的情况下是白色闪烁)
if @animation1_id == 0
@active_battler.white_flash = true
else
@active_battler.animation_id = @animation1_id
@active_battler.animation_hit = true
end
# 对像方动画
for target in @target_battlers
target.animation_id = @animation2_id
target.animation_hit = (target.damage != "Miss")
#.......................................................................
if target.is_a?(Game_Actor)
if target.current_action.kind == 0 and target.current_action.basic == 1
target.setup_battler_ani(target.battler_name.split(/★/)[2])
else
target.setup_battler_hurt_ani(0)
end
end
if target.is_a?(Game_Enemy)
if target.current_action.kind == 0 and target.current_action.basic == 1
target.setup_battler_ani(target.battler_name.split(/★/)[1])
else
target.setup_battler_hurt_ani(0)
end
end
#.......................................................................
end
# 对像方动画
for target in @target_battlers
target.animation_id = @animation2_id
target.animation_hit = (target.damage != "Miss")
#......................................................................
end
# 限制动画长度、最低 8 帧
@wait_count = 8
# 移至步骤 5
@phase4_step = 5
end
#--------------------------------------------------------------------------
# ● 刷新画面 (主回合步骤 4 : 对像方动画) ★
#--------------------------------------------------------------------------
def update_phase4_step4
# 限制动画长度、最低 8 帧
@wait_count = 8
# 移至步骤 5
@phase4_step = 5
end
end
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● 取得战斗画面的 X 坐标
#--------------------------------------------------------------------------
def screen_x
# 返回计算后的队伍 X 坐标的排列顺序
if self.index != nil
#......................................................................
return self.index * 90 + 500
#......................................................................
else
return 0
end
end
#--------------------------------------------------------------------------
# ● 取得战斗画面的 Y 坐标
#--------------------------------------------------------------------------
def screen_y
#........................................................................
return 300 - self.index * 110
#return 464 - self.index * 110
#........................................................................
end
#--------------------------------------------------------------------------
# ● 取得战斗画面的 Z 坐标
#--------------------------------------------------------------------------
def screen_z
# 返回计算后的队伍 Z 坐标的排列顺序
if self.index != nil
return 4 - self.index
else
return 0
end
end
end
class Scene_Battle
#..........................................................................
#--------------------------------------------------------------------------
# ● 返回phase
#--------------------------------------------------------------------------
def phase
return @phase
end
#--------------------------------------------------------------------------
# ● 返回phase4_step
#--------------------------------------------------------------------------
def phase4_step
return @phase4_step
end
#--------------------------------------------------------------------------
# ● 返回phase4_step
#--------------------------------------------------------------------------
def actor_command_active?
return @actor_command_window.active
end
#..........................................................................
end
class Game_Battler
#..........................................................................
#--------------------------------------------------------------------------
# ● 获取循环的动画 ID
#--------------------------------------------------------------------------
def show_damage(value)
@show_damage_value = value
end
#--------------------------------------------------------------------------
# ● 获取循环的动画 ID
#--------------------------------------------------------------------------
def show_damage_value
return @show_damage_value
end
#--------------------------------------------------------------------------
# ● 获取循环的动画 ID
#--------------------------------------------------------------------------
def battler_ani
return @battler_ani
end
#--------------------------------------------------------------------------
# ● 获取循环的动画 ID
#--------------------------------------------------------------------------
def setup_battler_ani(battler_ani, once = 0)
@battler_ani = battler_ani
@once = once
end
#--------------------------------------------------------------------------
# ● 获取循环的动画 ID
#--------------------------------------------------------------------------
def setup_battler_hurt_ani(hurt)
@hurt = hurt
end
#--------------------------------------------------------------------------
# ● 获取循环的动画 ID
#--------------------------------------------------------------------------
def setup_battler_dead_ani(over)
@over = over
end
#--------------------------------------------------------------------------
# ● 获取循环的动画 ID
#--------------------------------------------------------------------------
def battler_dead_ani
return @over
end
#--------------------------------------------------------------------------
# ● 获取循环的动画 ID
#--------------------------------------------------------------------------
def battler_ani_once
return @once
end
#--------------------------------------------------------------------------
# ● 获取循环的动画 ID
#--------------------------------------------------------------------------
def battler_hurt_ani
return @hurt
end
#..........................................................................
end
class Sprite_Battler < RPG::Sprite
#..........................................................................
#--------------------------------------------------------------------------
# ● 胜利图
#--------------------------------------------------------------------------
def win
if @battler_name != nil and not @battler.hidden and not @battler.dead?
@battler.setup_battler_ani(@battler_name.split(/★/)[6], 1)
end
end
#..........................................................................
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
if self.bitmap != nil
self.bitmap.dispose
end
super
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
# 战斗者为 nil 的情况下
if [url=home.php?mod=space&uid=133701]@battler[/url] == nil
self.bitmap = nil
loop_animation(nil)
return
end
# 文件名和色相与当前情况有差异的情况下
if @battler.battler_name != @battler_name or
@battler.battler_hue != @battler_hue
@battler_hue = @battler.battler_hue
# 获取、设置位图
@battler_name = @battler.battler_name
self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
#.......................................................................
@battler.setup_battler_ani(@battler.battler_name.split(/★/)[1])
#.......................................................................
@width = bitmap.width
[url=home.php?mod=space&uid=291977]@height[/url] = bitmap.height
self.ox = @width / 2
self.oy = @height
# 如果是战斗不能或者是隐藏状态就把透明度设置成 0
if @battler.is_a?(Game_Enemy)
if @battler.dead? or @battler.hidden
self.opacity = 0
end
end
end
# 动画 ID 与当前的情况有差异的情况下
#.........................................................................
if @battler.battler_ani != @battler_ani
@battler_ani = @battler.battler_ani
loop_animation($data_animations[@battler_ani.to_i])
end
#.........................................................................
# 应该被显示的角色的情况下
if @battler.is_a?(Game_Actor) and @battler_visible
# 不是主状态的时候稍稍降低点透明度
if $game_temp.battle_main_phase
self.opacity += 3 if self.opacity < 255
else
self.opacity -= 3 if self.opacity > 207
end
end
# 明灭
if @battler.blink
blink_on
else
blink_off
end
# 不可见的情况下
unless @battler_visible
# 出现 ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
if not @battler.hidden and not @battler.dead? and
(@battler.damage == nil or @battler.damage_pop)
if @battler.is_a?(Game_Enemy)
appear
else
@battler.setup_battler_ani(@battler.battler_name.split(/★/)[1])
end
@battler_visible = true
end
end
# 可见的情况下
if @battler_visible
# 逃跑
if @battler.hidden
$game_system.se_play($data_system.escape_se)
escape
@battler_visible = false
end
# 白色闪烁
if @battler.white_flash
whiten
@battler.white_flash = false
end
# 动画
if @battler.animation_id != 0
animation = $data_animations[@battler.animation_id]
animation(animation, @battler.animation_hit)
@battler.animation_id = 0
end
# 伤害
if @battler.damage_pop
damage(@battler.damage, @battler.critical)
@battler.damage = nil
@battler.critical = false
@battler.damage_pop = false
end
# korapusu
if @battler.damage == nil and @battler.dead?
#....................................................................
if @battler.is_a?(Game_Enemy)
$game_system.se_play($data_system.enemy_collapse_se)
#collapse
else
$game_system.se_play($data_system.actor_collapse_se)
end
#....................................................................
@battler_visible = false
end
end
# 设置活动块的坐标
self.x = @battler.screen_x
self.y = @battler.screen_y
self.z = @battler.screen_z
end
end
module RPG
class Sprite < ::Sprite
def damage(value, critical)
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 = "Arial Black"
bitmap.font.size = 32
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
bitmap.font.color.set(176, 255, 144)
else
bitmap.font.color.set(255, 255, 255)
end
bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
if critical
bitmap.font.size = 20
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.x -= self.bitmap.width/2 if @battler.is_a?(Game_Actor)
@_damage_sprite.y = self.y - self.oy / 2
@_damage_sprite.z = 3000
@_damage_duration = 40
end
end
end
module RPG
#--------------------------------------------------------------------------
# ● 常量设定
#--------------------------------------------------------------------------
# 是否显示总伤害
SHOW_TOTAL_DAMAGE = true
# 角色受攻击时是否跳一下
BATTLER_JUMP = false
class Sprite < ::Sprite
#==========================================
# 修改说明:
# @flash_shake用来制作挨打时候跳跃
# @_damage 用来记录每次打击之后弹出数字
# @_total_damage 记录总伤害
# @_total_damage_duration 总伤害持续帧
#==========================================
#alias 66RPG_rainbow_initialize : initialize
def initialize(viewport = nil)
#66RPG_rainbow_initialize(viewport)
super(viewport)
@_whiten_duration = 0
@_appear_duration = 0
@_escape_duration = 0
@_collapse_duration = 0
@_damage_duration = 0
@_animation_duration = 0
@_blink = false
# 挨打时候跳跃
@flash_shake = 0
# 伤害记录数组
@_damage = []
# 总伤害数字
@_total_damage = 0
# 总伤害持续帧
@_total_damage_duration = 0
#.........................................................................
@hits = 0
#.........................................................................
end
def damage(value, critical)
#.........................................................................
#清除hit数
dispose_hit
#.........................................................................
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 = "Arial Black"
bitmap.font.size = 32
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
bitmap.font.color.set(176, 255, 144)
else
bitmap.font.color.set(255, 55, 55)
end
bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
if critical
bitmap.font.size = 20
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
#=======================================
# 修改:推入新的伤害
#=======================================
@_damage.push([@_damage_sprite,@_damage_duration-10,0, rand(30) - 15, rand(3)])
# 总伤害处理
make_total_damage(value)
end
#--------------------------------------------------------------------------
# ● 返回 @hits
#--------------------------------------------------------------------------
def get_hit
return @hits
end
#--------------------------------------------------------------------------
# ● hit数的美化描绘
#--------------------------------------------------------------------------
#..........................................................................
def hit
# 如果伤害值是数值
# 转为字符串
value=@hits
hits_string = value.to_s
# 初始化位图
bitmap = Bitmap.new(320, 64)
bitmap.font.name = "Arial Black"
bitmap.font.size = 32
# 分割伤害值字符串
hits_array = hits_string.scan(/./)
hits_x = - 36.2#hits_string.size * 18.1 # 81 - hits_string.size * 18.1
rect_y = 0
# 循环伤害值字符串
for char in hits_array
# 后移一位
hits_x += 36.2
number = char.to_i
# 显示伤害数字
bitmap.blt(hits_x, 0, RPG::Cache.picture("Number"),
Rect.new(number * 36.2, rect_y, 36.2, 50))
end
hits_x += 18.1
bitmap.blt(hits_x, 0, RPG::Cache.picture("HITS"),
Rect.new(0, -21, 90, 50))
# 伤害值定位
@_hits_sprite = ::Sprite.new(self.viewport)
@_hits_sprite.bitmap = bitmap
@_hits_sprite.x = 560 - hits_string.size * 36.2
@_hits_sprite.y = 70
@_hits_sprite.z = 3000
@_hits_duration = 40
end
#..........................................................................
#--------------------------------------------------------------------------
# ● 总伤害处理
#--------------------------------------------------------------------------
def make_total_damage(value)
if value.is_a?(Numeric) and SHOW_TOTAL_DAMAGE
@_total_damage += value
else
return
end
bitmap = Bitmap.new(300, 150)
bitmap.font.name = "Arial Black"
bitmap.font.size = 48
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(+2, 12+2, 160, 36, @_total_damage.abs.to_s, 1)
if @_total_damage < 0
bitmap.font.color.set(80, 255, 00)
else
bitmap.font.color.set(255, 140, 0)
end
bitmap.draw_text(0, 12, 160, 36, @_total_damage.abs.to_s, 1)
if @_total_damage_sprite.nil?
@_total_damage_sprite = ::Sprite.new#(self.viewport)
@_total_damage_sprite.ox = 80
@_total_damage_sprite.oy = 20
@_total_damage_sprite.z = 3000
end
@_total_damage_sprite.bitmap = bitmap
@_total_damage_sprite.zoom_x = 1.5
@_total_damage_sprite.zoom_y = 1.5
@_total_damage_sprite.x = self.x
@_total_damage_sprite.y = self.y - self.oy / 2 - 64
@_total_damage_sprite.z = 3001
#.........................................................................
@_total_damage_duration = 40
#.........................................................................
#.........................................................................
#hit数描绘
@hits+=1
hit
#.........................................................................
end
def animation(animation, hit, battler_damage="", battler_critical=false)
dispose_animation
#=======================================
# 修改:记录伤害和critical
#=======================================
@battler_damage = battler_damage
@battler_critical = battler_critical
@_animation = animation
return if @_animation == nil
@_animation_hit = hit
@_animation_duration = @_animation.frame_max
animation_name = @_animation.animation_name
animation_hue = @_animation.animation_hue
bitmap = RPG::Cache.animation(animation_name, animation_hue)
#=======================================
# 修改:计算总闪光权限值
#=======================================
for timing in @_animation.timings
quanzhong = animation_process_timing(timing, @_animation_hit,true)
@all_quanzhong += quanzhong
# 记录最后一次闪光
@_last_frame = timing.frame if quanzhong != 0
end
#.........................................................................
@last_frame = @_last_frame
#.........................................................................
if @@_reference_count.include?(bitmap)
@@_reference_count[bitmap] += 1
else
@@_reference_count[bitmap] = 1
end
#=======================================
# 修改:行动方动画不显示伤害
#=======================================
if $scene.is_a?(Scene_Battle)
if $scene.animation1_id == @battler.animation_id
@battler_damage = ""
end
end
@_animation_sprites = []
if @_animation.position != 3 or not @@_animations.include?(animation)
for i in 0..15
sprite = ::Sprite.new(self.viewport)
sprite.bitmap = bitmap
sprite.visible = false
@_animation_sprites.push(sprite)
end
unless @@_animations.include?(animation)
@@_animations.push(animation)
end
end
update_animation
end
#=======================================
# 修改:更换清除伤害的算法,以防万一
# 本内容在脚本中没有使用过
#=======================================
def dispose_damage
for damage in @_damage.reverse
damage[0].bitmap.dispose
damage[0].dispose
@_damage.delete(damage)
end
@_total_damage = 0
@_last_frame = -1
if @_total_damage_sprite != nil
@_total_damage_duration = 0
@_total_damage_sprite.bitmap.dispose
@_total_damage_sprite.dispose
@_total_damage_sprite = nil
end
end
#=======================================
# 清除hit数
#=======================================
#...........................................................................
def dispose_hit
if @_hits_sprite != nil
@_hits_sprite.bitmap.dispose
@_hits_sprite.dispose
@_hits_sprite = nil
end
end
#...........................................................................
def dispose_animation
#=======================================
# 修改:清除记录的伤害,清除权重记录
#=======================================
@battler_damage = nil
@battler_critical = nil
@all_quanzhong = 1
@_total_damage = 0
@_last_frame = -1
#.........................................................................
@hits = 0
#.........................................................................
if @_animation_sprites != nil
sprite = @_animation_sprites[0]
if sprite != nil
@@_reference_count[sprite.bitmap] -= 1
if @@_reference_count[sprite.bitmap] == 0
sprite.bitmap.dispose
end
end
for sprite in @_animation_sprites
sprite.dispose
end
@_animation_sprites = nil
@_animation = nil
end
end
def update
super
if @_whiten_duration > 0
@_whiten_duration -= 1
self.color.alpha = 128 - (16 - @_whiten_duration) * 10
end
if @_appear_duration > 0
@_appear_duration -= 1
self.opacity = (16 - @_appear_duration) * 16
end
if @_escape_duration > 0
@_escape_duration -= 1
self.opacity = 256 - (32 - @_escape_duration) * 10
end
if @_collapse_duration > 0
@_collapse_duration -= 1
self.opacity = 256 - (48 - @_collapse_duration) * 6
end
#=======================================
# 修改:更新算法,更新弹出
#=======================================
if @_damage_duration > 0
@_damage_duration -= 1
for damage in @_damage
damage[0].x = self.x + self.viewport.rect.x -
self.ox + self.src_rect.width / 2 +
(40 - damage[1]) * damage[3] / 10
damage[0].y -= damage[4]+damage[1]/10
damage[0].opacity = damage[1]*20
damage[1] -= 1
if damage[1]==0
damage[0].bitmap.dispose
damage[0].dispose
@_damage.delete(damage)
next
end
end
end
#=======================================
# 添加:弹出总伤害
#=======================================
if @_total_damage_duration > 0
@_total_damage_duration -= 1
@_total_damage_sprite.y -= 1 if @_total_damage_duration % 2 == 0
if @_total_damage_sprite.zoom_x > 1.0
@_total_damage_sprite.zoom_x -= 0.05
end
if @_total_damage_sprite.zoom_y > 1.0
@_total_damage_sprite.zoom_y -= 0.05
end
@_total_damage_sprite.opacity = 256 - (24 - @_total_damage_duration) * 16
#......................................................................
if @_total_damage_duration <= 7 and @_total_damage_duration > 0
@_hits_sprite.opacity -= 32
@_hits_sprite.x += 1
end
#......................................................................
if @_total_damage_duration <= 0
#.....................................................................
dispose_hit
#.....................................................................
@_total_damage = 0
@_total_damage_duration = 0
@_total_damage_sprite.bitmap.dispose
@_total_damage_sprite.dispose
@_total_damage_sprite = nil
end
end
#=======================================
if @_animation != nil and (Graphics.frame_count % 2 == 0)
@_animation_duration -= 1
update_animation
end
if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
update_loop_animation
@_loop_animation_index += 1
#......................................................................
@loop_animation_once = 0
@loop_animation_once = 1 if @once == 1 and @_loop_animation_index == @_loop_animation.frame_max
#......................................................................
@_loop_animation_index %= @_loop_animation.frame_max
end
if @_blink
@_blink_count = (@_blink_count + 1) % 32
if @_blink_count < 16
alpha = (16 - @_blink_count) * 6
else
alpha = (@_blink_count - 16) * 6
end
self.color.set(255, 255, 255, alpha)
end
@@_animations.clear
end
#..........................................................................
def loop_animation_once
return @_loop_animation_once
end
#..........................................................................
def update_animation
if @_animation_duration > 0
frame_index = @_animation.frame_max - @_animation_duration
@frame_index = frame_index
cell_data = @_animation.frames[frame_index].cell_data
position = @_animation.position
animation_set_sprites(@_animation_sprites, cell_data, position)
#=======================================
# 修改:弹出伤害,权重计算
#=======================================
for timing in @_animation.timings
if timing.frame == frame_index
t = 1.0 * animation_process_timing(timing, @_animation_hit)
#p t,"当前权重", @all_quanzhong,"总权重"
if @battler_damage.is_a?(Numeric) and t != 0
t *= @battler_damage
t /= @all_quanzhong
#p t,"当前伤害",@battler_damage,"总伤害"
t = t.to_i
# 最后一次闪光的话,伤害修正
if frame_index == @_last_frame
@_total_damage = @battler_damage - t
end
#p t,@battler_damage,@all_quanzhong
damage(t,@battler_critical)
# 防止重复播放miss
elsif !@battler_damage.is_a?(Numeric) and timing.flash_scope != 0
damage(@battler_damage,@battler_critical)
end
end
end
else
dispose_animation
end
end
#=======================================
# 修改:敌人跳跃的功能 + 添加返回数值
#=======================================
def update_loop_animation
frame_index = @_loop_animation_index
cell_data = @_loop_animation.frames[frame_index].cell_data
position = @_loop_animation.position
#·改·
if @wait_count.to_i <= 0
@wait_count = 0
animation_set_sprites(@_loop_animation_sprites, cell_data, position)
else
@wait_count -= 1
for sprite in @_loop_animation_sprites
sprite.visible = false
end
end
if @wait_flash.to_i <= 0
@wait_flash = 0
else
@wait_flash -= 1
for sprite in @_loop_animation_sprites
sprite.blend_type = 1
end
end
#·改·
for timing in @_loop_animation.timings
if timing.frame == frame_index
animation_process_timing(timing, true)
end
end
end
#=======================================
# 修改:敌人跳跃的功能 + 添加返回数值
#=======================================
def loop_animation(animation)
return if animation == @_loop_animation
dispose_loop_animation
@_loop_animation = animation
return if @_loop_animation == nil
@_loop_animation_index = 0
animation_name = @_loop_animation.animation_name
animation_hue = @_loop_animation.animation_hue
bitmap = RPG::Cache.animation(animation_name, animation_hue)
if @@_reference_count.include?(bitmap)
@@_reference_count[bitmap] += 1
else
@@_reference_count[bitmap] = 1
end
@_loop_animation_sprites = []
for i in 0..15
sprite = ::Sprite.new
sprite.bitmap = bitmap
sprite.visible = false
@_loop_animation_sprites.push(sprite)
end
update_loop_animation
end
#=======================================
# 修改:敌人跳跃的功能 + 添加返回数值
#=======================================
def animation_process_timing(timing, hit,dontflash=false)
if (timing.condition == 0) or
(timing.condition == 1 and hit == true) or
(timing.condition == 2 and hit == false)
unless dontflash
if timing.se.name != ""
se = timing.se
Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
end
end
case timing.flash_scope
when 1
unless dontflash
self.flash(timing.flash_color, timing.flash_duration * 2)
#....................................................................
@wait_flash = timing.flash_duration
#....................................................................
if @_total_damage >0
@flash_shake_switch = true
@flash_shake = 10
end
end
return timing.flash_color.alpha * timing.flash_duration
when 2
unless dontflash
if self.viewport != nil
self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
return timing.flash_color.alpha * timing.flash_duration
end
end
when 3
unless dontflash
self.flash(nil, timing.flash_duration * 2)
#@_loop_animation_count = 1
#·改·
@wait_count = timing.flash_duration
#·改·
end
return timing.flash_color.alpha * timing.flash_duration
end
end
return 0
end
end
end
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < RPG::Sprite
#--------------------------------------------------------------------------
# ● 初始化对像
# 添加跳跃记录
#--------------------------------------------------------------------------
def initialize(viewport, battler = nil)
super(viewport)
@battler = battler
@battler_visible = false
@flash_shake_switch = true
#........................................................................
@once = 0
@frame_index = -1
@last_frame = 0
#........................................................................
end
#--------------------------------------------------------------------------
# ● 刷新画面
# 增添跳跃功能
#--------------------------------------------------------------------------
def update
super
# 战斗者为 nil 的情况下
if @battler == nil
self.bitmap = nil
loop_animation(nil)
return
end
# 文件名和色相与当前情况有差异的情况下
if @battler.battler_name != @battler_name or
@battler.battler_hue != @battler_hue
# 获取、设置位图
@battler_name = @battler.battler_name
@battler_hue = @battler.battler_hue
self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
#.......................................................................
if not @battler.hidden and not @battler.dead?
@battler.setup_battler_ani(@battler.battler_name.split(/★/)[1])
end
#.......................................................................
@width = bitmap.width
[url=home.php?mod=space&uid=291977]@height[/url] = bitmap.height
self.ox = @width / 2
self.oy = @height
end
#.......................................................................
update_actor_animation
update_enemy_animation
#.......................................................................
# 动画 ID 与当前的情况有差异的情况下
#.........................................................................
if @battler.is_a?(Game_Enemy)
if @once == 1 and @loop_animation_once == 1 and
@battler.battler_dead_ani == 1
@battler.setup_battler_ani(@battler.battler_name.split(/★/)[5])
elsif @once == 1 and @loop_animation_once == 1 and $scene.phase != 5
@battler.setup_battler_ani(@battler.battler_name.split(/★/)[1])
end
end
if @battler.is_a?(Game_Actor)
if @once == 1 and @loop_animation_once == 1 and $scene.phase != 5 and
@battler.battler_dead_ani == 1
@battler.setup_battler_ani(@battler.battler_name.split(/★/)[5])
elsif @once == 1 and @loop_animation_once == 1 and $scene.phase != 5
@battler.setup_battler_ani(@battler.battler_name.split(/★/)[1])
elsif @once == 1 and @loop_animation_once == 1 and $scene.phase == 5 and
not @battler.dead?
@battler.setup_battler_ani(@battler.battler_name.split(/★/)[7])
end
end
if @battler.battler_ani != @battler_ani
@battler_ani = @battler.battler_ani
@once = @battler.battler_ani_once
loop_animation($data_animations[@battler_ani.to_i])
end
#.........................................................................
# 应该被显示的角色的情况下
if @battler.is_a?(Game_Actor) and @battler_visible
# 不是主状态的时候稍稍降低点透明度
if $game_temp.battle_main_phase
self.opacity += 3 if self.opacity < 255
else
self.opacity -= 3 if self.opacity > 207
end
end
# 明灭
if @battler.blink
blink_on
else
blink_off
end
# 不可见的情况下
unless @battler_visible
# 出现
if not @battler.hidden and not @battler.dead? and
(@battler.damage == nil or @battler.damage_pop)
#.......................................................................
if @battler.is_a?(Game_Enemy)
@battler.setup_battler_ani(@battler.battler_name.split(/★/)[1])
#appear
else
@battler.setup_battler_ani(@battler.battler_name.split(/★/)[1])
end
#.......................................................................
@battler_visible = true
end
end
# 可见的情况下
if @battler_visible
# 逃跑
if @battler.hidden
$game_system.se_play($data_system.escape_se)
escape
@battler_visible = false
end
# 白色闪烁
if @battler.white_flash
whiten
@battler.white_flash = false
end
# 动画
if @battler.animation_id != 0
animation = $data_animations[@battler.animation_id]
animation(animation, @battler.animation_hit,@battler.damage, @battler.critical)
@battler.animation_id = 0
end
# 伤害
if @battler.damage_pop
@battler.damage = nil
@battler.critical = false
@battler.damage_pop = false
end
# korapusu
if @battler.damage == nil and @battler.dead?
if @battler.is_a?(Game_Enemy)
if @battler.battler_dead_ani != 1
#p "Battler Death Error"
$game_system.se_play($data_system.enemy_collapse_se)
@battler.setup_battler_ani(@battler.battler_name.split(/★/)[4], 1)
@battler.setup_battler_dead_ani(1)
end
#.....................................................................
collapse
#.....................................................................
else
#.....................................................................
if @battler.battler_dead_ani != 1
#p "Battler Death Error"
$game_system.se_play($data_system.enemy_collapse_se)
@battler.setup_battler_ani(@battler.battler_name.split(/★/)[4], 1)
@battler.setup_battler_dead_ani(1)
end
#.....................................................................
end
@battler_visible = false
end
end
# 设置活动块的坐标
if @flash_shake_switch == true
self.x = @battler.screen_x
self.y = @battler.screen_y
self.z = @battler.screen_z
@flash_shake_switch = false
end
if @flash_shake != 0 and @battler.damage != nil and RPG::BATTLER_JUMP
if @battler.is_a?(Game_Enemy)
case @flash_shake
when 9..10
self.x -=4
self.y -=4
self.z = @battler.screen_z
when 6..8
self.x -=2
self.y -=2
self.z = @battler.screen_z
when 3..5
self.x +=2
self.y +=2
self.z = @battler.screen_z
when 1..2
self.x +=4
self.y +=4
self.z = @battler.screen_z
end
end
if @battler.is_a?(Game_Actor)
case @flash_shake
when 9..10
self.x +=4
self.y +=4
self.z = @battler.screen_z
when 6..8
self.x +=2
self.y +=2
self.z = @battler.screen_z
when 3..5
self.x -=2
self.y -=2
self.z = @battler.screen_z
when 1..2
self.x -=4
self.y -=4
self.z = @battler.screen_z
end
end
@flash_shake -= 1
end
end
end
#==============================================================================
# ■ Scene_Battle
#------------------------------------------------------------------------------
# 处理战斗画面的类。
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :animation1_id # 行动方动画ID
end
class Sprite_Battler < RPG::Sprite
#--------------------------------------------------------------------------
# ● 处理角色动作
#--------------------------------------------------------------------------
def update_actor_animation
if @battler.is_a?(Game_Actor)
if @battler.show_damage_value != nil
self.damage(@battler.show_damage_value, false)
@battler.show_damage(nil)
@battler.setup_battler_ani(@battler.battler_name.split(/★/)[3], 1)
@battler.setup_battler_hurt_ani(1)
end
if @battler.current_action.kind == 0 and @battler.current_action.basic == 1
else
if @hits == 1 and not @battler.dead? and @battler.battler_hurt_ani != 1 and @battler.damage.is_a?(Numeric) and @battler.damage > 0
@battler.setup_battler_ani(@battler.battler_name.split(/★/)[3], 1)
@battler.setup_battler_hurt_ani(1)
elsif @frame_index == @last_frame and @battler.dead? and @battler.battler_dead_ani != 1
for actor in $game_party.actors
if @battler != actor
actor.add_state(6)
end
end
@battler.setup_battler_ani(@battler.battler_name.split(/★/)[4], 1)
@battler.setup_battler_dead_ani(1)
end
end
end
end
#--------------------------------------------------------------------------
# ● 处理敌人动作
#--------------------------------------------------------------------------
def update_enemy_animation
if @battler.is_a?(Game_Enemy)
if @battler.show_damage_value != nil
self.damage(@battler.show_damage_value, false)
@battler.show_damage(nil)
@battler.setup_battler_ani(@battler.battler_name.split(/★/)[3], 1)
@battler.setup_battler_hurt_ani(1)
end
if @battler.current_action.kind == 0 and @battler.current_action.basic == 1
else
if @hits == 1 and not @battler.dead? and @battler.battler_hurt_ani != 1 and @battler.damage.is_a?(Numeric) and @battler.damage > 0
@battler.setup_battler_ani(@battler.battler_name.split(/★/)[3], 1)
@battler.setup_battler_hurt_ani(1)
elsif @frame_index == @last_frame and @battler.dead? and @battler.battler_dead_ani != 1
@battler.setup_battler_ani(@battler.battler_name.split(/★/)[4], 1)
@battler.setup_battler_dead_ani(1)
collapse
end
end
end
end
end