标题: VX显伤害脚本没效果 [打印本页] 作者: DARK萌萌 时间: 2011-11-2 09:45 标题: VX显伤害脚本没效果 #伤害值美化脚本 Beside--------------------------------------------------------
#66RPG 转载请保留此信息--------------------------------------------------------
class Game_Battler
attr_accessor :hp_damage
attr_accessor :mp_damage
attr_accessor :damage_pop
attr_accessor :critical
alias ini initialize
def initialize
ini
@damage_pop = false
end
end
class Sprite_Base
def initialize(viewport = nil)
super(viewport)
@use_sprite = true # 活动块使用的标志
@animation_duration = 0 # 动画剩余时间
@_damage_duration = 0
end
def update
super
if @animation != nil
@animation_duration -= 1
if @animation_duration % 4 == 0
update_animation
end
end
@@animations.clear
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
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(162, 64) # 初始化位图
bitmap.font.name = "Arial Black"
bitmap.font.size = 23
if value.is_a?(Numeric)
damage_array = damage_string.scan(/./) # 分割伤害值字符串
damage_x = 81 - damage_string.size * 9
if value < 0 # 伤害值为负的情况下
rect_y = 32 # 调用回复数字表
else
rect_y = 0 # 调用伤害数字表
end
for char in damage_array # 循环伤害值字符串
number = char.to_i
bitmap.blt(damage_x, 32, Cache.picture("Damage1"), Rect.new(number * 18, rect_y, 18, 32))
damage_x += 18 # 后移一位
end
else
if value == "Evaded"
bitmap.blt(36, 28, Cache.picture("Damage1"), Rect.new(0, 96, 84, 32))
else
# 显示未击中图画
bitmap.blt(36, 28, Cache.picture("Damage1"), Rect.new(90, 64, 90, 32))
end
end
if critical # 会心一击标志打开的情况
# 显示会心一击图画
bitmap.blt(36, 0, Cache.picture("Damage1"), Rect.new(0, 64, 90, 32))
end
# 伤害值定位
@_damage_sprite = Sprite_Base.new(self.viewport)
@_damage_sprite.bitmap = bitmap
@_damage_sprite.ox = 81
@_damage_sprite.oy = 20
@_damage_sprite.x = self.x
@_damage_sprite.y = self.y - self.oy
@_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
end
class Sprite_Battler
alias setup_new_effect_66RPG setup_new_effect
def setup_new_effect
setup_new_effect_66RPG
if @battler.damage_pop
if @battler.hp_damage != 0 and @battler.hp_damage != nil
damage(@battler.hp_damage, @battler.critical)
end
if @battler.mp_damage != 0 and @battler.mp_damage != nil
damage(@battler.mp_damage, @battler.critical)
end
if @battler.missed
damage("Miss", @battler.critical)
end
if @battler.evaded
damage("Evaded", @battler.critical)
end
@battler.damage_pop = false
end
end
end
class Scene_Battle
def display_action_effects(target, obj = nil)
unless target.skipped
line_number = @message_window.line_number
wait(10)
target.damage_pop = true if target.is_a?(Game_Enemy)
display_critical(target, obj)
display_damage(target, obj)
display_state_changes(target, obj)
@status_window.refresh
if line_number == @message_window.line_number
display_failure(target, obj) unless target.states_active?
end
if line_number != @message_window.line_number
wait(30)
end
@message_window.back_to(line_number)
end
end
end