#==============================================================================#
# By Xiderowg / 桜雅 在土 # #
#==============================================================================# #
#==============================================================================#
# 描述 #
#==============================================================================#
#这个脚本最初是由Xiderowg(桜雅 在土)创造的,但是这个脚本为了XAS中主角的编辑,#
#而被Moghunter改动了很多。这个特点是动态的现实伤害值和主角获得的经验和金币。 #
#==============================================================================#
module XRXS_DAMAGE
def damage_x_init_velocity
return 0.2 * (rand(5) - 2)
end
def damage_y_init_velocity
return 9
end
GRAVITY = 0.58
TRANCEPARENT_START = 30
TRANCEPARENT_X_SLIDE = 0
end
$xrxs_damage_pop = true
module XRXS_DamageSettings
DURATION = 40
CRITICAL_STRING = "CRITICAL"
CRITICAL_FONT_SIZE = 16
CRITICAL_FONT_COLOR = Color.new(255, 155, 50)
STATE_STRING = "____State____"
STATE_FONT_SIZE = 18
STATE_FONT_COLOR = Color.new(255, 255, 255)
ITEM_STRING = "____ITEM____"
ITEM_FONT_SIZE = 18
ITEM_FONT_COLOR = Color.new(255, 255, 255)
DEFAULT_COLOR = Color.new(255, 255, 255)
DEFAULT_MINUS = Color.new(176, 255, 144)
SPDAMAGE_COLOR = Color.new(255, 176, 144)
SPDAMAGE_MINUS = Color.new(128, 255, 255)
STATES_COLOR = Color.new(0, 150, 200)
STATES_MINUS = Color.new(170, 170, 170)
SPECIAL_ACTION_COLOR_A = Color.new(250, 100, 100)
SPECIAL_ACTION_COLOR_B = Color.new(150, 150, 250)
ITEM_COLOR = Color.new(128, 200, 255)
SPECIAL_COLOR_SETS =
{"EXP"=>Color.new(155, 255, 64),
"G"=>Color.new(255, 255, 32),
"Level up!"=>Color.new(255, 255, 0)
}
def self.font
font = Font.new
font.name = "黑体"
font.size = 20
font.bold = true
font.italic = false
return font
end
end
module XRXS_ResultPop
EXP = 50
GOLD = 30
end
#_______________________________________________________________________________
module XRXS_DAMAGE
def update
super
@damage_sprites = [] if @damage_sprites.nil?
@damage_durations = [] if @damage_durations.nil?
if @_damage_sprite != nil and @_damage_sprite.visible
x = damage_x_init_velocity
y = damage_y_init_velocity
d = @_damage_duration
@damage_sprites.push(Sprite_Damage.new(@_damage_sprite, x, y, d))
@_damage_sprite.visible = false
end
for damage_sprite in @damage_sprites
damage_sprite.update
end
for i in [email]0...@damage_sprites.size[/email]
@damage_sprites[i] = nil if @damage_sprites[i].disposed?
end
@damage_sprites.compact!
end
def dispose
super
if @damage_sprites != nil
for damage_sprite in @damage_sprites
damage_sprite.dispose
end
end
end
end
class RPG::Sprite < Sprite
include XRXS_DAMAGE
end
class Sprite_Damage < Sprite
def initialize(sprite, init_x_speed, init_y_speed, duration)
super(nil)
self.bitmap = sprite.bitmap.dup unless sprite.bitmap.nil?
self.opacity = sprite.opacity
self.x = sprite.x
self.y = sprite.y
self.z = sprite.z
self.ox = sprite.ox
self.oy = sprite.oy
@now_x_speed = init_x_speed
@now_y_speed = init_y_speed
@potential_x_energy = 0.0
@potential_y_energy = 0.0
@duration = duration
end
def update
if @duration <= XRXS_DAMAGE::TRANCEPARENT_START
self.opacity -= (256 / XRXS_DAMAGE::TRANCEPARENT_START)
self.x += XRXS_DAMAGE::TRANCEPARENT_X_SLIDE
end
super
n = self.oy + @now_y_speed
if n <= 0
@now_y_speed *= -1
@now_y_speed /= 2
@now_x_speed /= 2
end
self.oy = [n, 0].max
@potential_y_energy += XRXS_DAMAGE::GRAVITY
speed = @potential_y_energy.floor
@now_y_speed -= speed
@potential_y_energy -= speed
@potential_x_energy += @now_x_speed
speed = @potential_x_energy.floor
self.ox += speed
@potential_x_energy -= speed
@duration -= 1
if @duration == 0
self.dispose
end
end
end
module XRXS_DamageSettings
def self.color(value_string)
for key in SPECIAL_COLOR_SETS.keys.sort!
return SPECIAL_COLOR_SETS[key] unless value_string.scan(key).empty?
end
unless value_string.scan($data_system.words.sp).empty?
value = (value_string.sub($data_system.words.sp){""}).to_i
color = (value >= 0 ? SPDAMAGE_COLOR : SPDAMAGE_MINUS)
value_string.gsub!("-") {""}
return color
end
unless value_string.scan("+ ").empty?
color = STATES_COLOR
return color
end
unless value_string.scan("- ").empty?
color = STATES_MINUS
return color
end
unless value_string.scan(XAS_BA_ENEMY::COUNTER_TEXT.to_s).empty?
color = SPECIAL_ACTION_COLOR_A
return color
end
unless value_string.scan(XAS_BA_ENEMY::FINAL_ATTACK_TEXT.to_s).empty?
color = SPECIAL_ACTION_COLOR_A
return color
end
unless value_string.scan(XAS_SKILL::ONE_HP_TEXT.to_s).empty?
color = SPECIAL_ACTION_COLOR_A
return color
end
unless value_string.scan(XAS::DEATHCOUNT_TEXT_COUNT.to_s).empty?
color = SPECIAL_ACTION_COLOR_A
return color
end
unless value_string.scan(XAS::DEATHCOUNT_TEXT_DEATH.to_s).empty?
color = SPECIAL_ACTION_COLOR_A
return color
end
if $data_states[XAS::INVINCIBLE_ID] != nil
unless value_string.scan($data_states[XAS::INVINCIBLE_ID].name.to_s).empty?
color = SPECIAL_ACTION_COLOR_B
return color
end
end
if $data_states[XAS::REFLECT_ID] != nil
unless value_string.scan($data_states[XAS::REFLECT_ID].name.to_s).empty?
color = SPECIAL_ACTION_COLOR_B
return color
end
end
unless value_string.scan(XAS_ABS_SETUP::DEFENSE_TEXT.to_s).empty?
color = SPECIAL_ACTION_COLOR_B
return color
end
unless value_string.scan(XAS_ABS_SETUP::ESCAPE_TEXT.to_s).empty?
color = SPECIAL_ACTION_COLOR_B
return color
end
unless value_string.scan(XAS_SKILL::STEAL_TEXT.to_s).empty?
color = ITEM_COLOR
return color
end
if $mog_rgss_ap_parameter != nil
unless value_string.scan(MOG::AP_NAME.to_s).empty?
color = ITEM_COLOR
return color
end
end
unless value_string.scan(" x ").empty?
color = ITEM_COLOR
return color
end
if $mog_rgss_xas_overdrive != nil
unless value_string.scan(MOG::OVDTEXT.to_s).empty?
color = SPECIAL_ACTION_COLOR_B
return color
end
end
value = (value_string).to_i
color = (value >= 0 ? DEFAULT_COLOR : DEFAULT_MINUS)
return color
end
end
module RPG
class Sprite < ::Sprite
def damage(value, critical, state, item)
dispose_damage
font = XRXS_DamageSettings.font
color = XRXS_DamageSettings.color(value.to_s)
if value.is_a?(Numeric)
damage_string = value.abs.to_s
else
damage_string = value.to_s
end
#-------------------------------------------------------------------------
if value.is_a?(Numeric)
bitmap_number_image = RPG::Cache.windowskin("Damage_Number")
bitmap = Bitmap.new(bitmap_number_image.width,bitmap_number_image.height)
bitmap_im_cw = bitmap_number_image.width / 10
bitmap_im_ch = bitmap_number_image.height / 3
bitmap_number_text = value.to_s.split(//)
if value >= 0
for r in 0..bitmap_number_text.size - 1
bitmap_number_abs = bitmap_number_text[r].to_i
if critical == false
bitmap_src_rect = Rect.new(bitmap_im_cw * bitmap_number_abs,0 , bitmap_im_cw, bitmap_im_ch)
else
bitmap_src_rect = Rect.new(bitmap_im_cw * bitmap_number_abs, bitmap_im_ch * 2, bitmap_im_cw, bitmap_im_ch)
end
bitmap.blt(60 + ((bitmap_im_cw - 7) * r), 0, bitmap_number_image, bitmap_src_rect)
end
else
for r in 1..bitmap_number_text.size - 1
bitmap_number_abs = bitmap_number_text[r].to_i
bitmap_src_rect = Rect.new(bitmap_im_cw * bitmap_number_abs, bitmap_im_ch, bitmap_im_cw, bitmap_im_ch)
bitmap.blt(50 + ((bitmap_im_cw - 7) * r), 0, bitmap_number_image, bitmap_src_rect)
end
end
elsif damage_string == "Miss"
bitmap_number_image = RPG::Cache.windowskin("Miss")
bitmap = Bitmap.new(bitmap_number_image.width,bitmap_number_image.height)
bitmap_im_cw = bitmap_number_image.width
bitmap_im_ch = bitmap_number_image.height / 6
bitmap_src_rect = Rect.new(0, 0, bitmap_im_cw, bitmap_im_ch)
bitmap.blt(-25 , 0, bitmap_number_image, bitmap_src_rect)
elsif damage_string == XAS_ABS_SETUP::GUARD_BREAK_TEXT
bitmap_number_image = RPG::Cache.windowskin("Miss")
bitmap = Bitmap.new(bitmap_number_image.width,bitmap_number_image.height)
bitmap_im_cw = bitmap_number_image.width
bitmap_im_ch = bitmap_number_image.height / 6
bitmap_src_rect = Rect.new(0, bitmap_im_ch, bitmap_im_cw, bitmap_im_ch)
bitmap.blt(-25 , 0, bitmap_number_image, bitmap_src_rect)
elsif damage_string == XAS_ABS_SETUP::SHIELD_TEXT
bitmap_number_image = RPG::Cache.windowskin("Miss")
bitmap = Bitmap.new(bitmap_number_image.width,bitmap_number_image.height)
bitmap_im_cw = bitmap_number_image.width
bitmap_im_ch = bitmap_number_image.height / 6
bitmap_src_rect = Rect.new(0, bitmap_im_ch * 2, bitmap_im_cw, bitmap_im_ch)
bitmap.blt(-25 , 0, bitmap_number_image, bitmap_src_rect)
elsif damage_string == XAS_BA::LEVEL_UP_TEXT
bitmap_number_image = RPG::Cache.windowskin("Miss")
bitmap = Bitmap.new(bitmap_number_image.width,bitmap_number_image.height)
bitmap_im_cw = bitmap_number_image.width
bitmap_im_ch = bitmap_number_image.height / 6
bitmap_src_rect = Rect.new(0, bitmap_im_ch * 3, bitmap_im_cw, bitmap_im_ch)
bitmap.blt(-25 , 0, bitmap_number_image, bitmap_src_rect)
elsif damage_string == "No Mp"
bitmap_number_image = RPG::Cache.windowskin("Miss")
bitmap = Bitmap.new(bitmap_number_image.width,bitmap_number_image.height)
bitmap_im_cw = bitmap_number_image.width
bitmap_im_ch = bitmap_number_image.height / 6
bitmap_src_rect = Rect.new(0, bitmap_im_ch * 4, bitmap_im_cw, bitmap_im_ch)
bitmap.blt(-25 , 0, bitmap_number_image, bitmap_src_rect)
elsif damage_string == "Dodge"
bitmap_number_image = RPG::Cache.windowskin("Miss")
bitmap = Bitmap.new(bitmap_number_image.width,bitmap_number_image.height)
bitmap_im_cw = bitmap_number_image.width
bitmap_im_ch = bitmap_number_image.height / 6
bitmap_src_rect = Rect.new(0, bitmap_im_ch * 5, bitmap_im_cw, bitmap_im_ch)
bitmap.blt(-25 , 0, bitmap_number_image, bitmap_src_rect)
else
#-------------------------------------------------------------------------
#=begin
bitmap = Bitmap.new(160, 48)
bitmap.font = font
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)
bitmap.font.color = color
bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
if critical
critical_string = XRXS_DamageSettings::CRITICAL_STRING
bitmap.font.size = XRXS_DamageSettings::CRITICAL_FONT_SIZE
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, -1, 160, 20, critical_string, 1)
bitmap.draw_text(+1, -1, 160, 20, critical_string, 1)
bitmap.draw_text(-1, +1, 160, 20, critical_string, 1)
bitmap.draw_text(+1, +1, 160, 20, critical_string, 1)
bitmap.font.color = XRXS_DamageSettings::CRITICAL_FONT_COLOR
bitmap.draw_text(0, 0, 160, 20, critical_string, 1)
elsif state
critical_string = XRXS_DamageSettings::STATE_STRING
bitmap.font.size = XRXS_DamageSettings::STATE_FONT_SIZE
bitmap.font.italic = true
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, -1, 160, 20, critical_string, 1)
bitmap.draw_text(+1, -1, 160, 20, critical_string, 1)
bitmap.draw_text(-1, +1, 160, 20, critical_string, 1)
bitmap.draw_text(+1, +1, 160, 20, critical_string, 1)
bitmap.font.color = XRXS_DamageSettings::STATE_FONT_COLOR
bitmap.draw_text(0, 0, 160, 20, critical_string, 1)
elsif item
critical_string = XRXS_DamageSettings::ITEM_STRING
bitmap.font.size = XRXS_DamageSettings::ITEM_FONT_SIZE
bitmap.font.italic = true
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, -1, 160, 20, critical_string, 1)
bitmap.draw_text(+1, -1, 160, 20, critical_string, 1)
bitmap.draw_text(-1, +1, 160, 20, critical_string, 1)
bitmap.draw_text(+1, +1, 160, 20, critical_string, 1)
bitmap.font.color = XRXS_DamageSettings::ITEM_FONT_COLOR
bitmap.draw_text(0, 0, 160, 20, critical_string, 1)
end
end
#=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
if critical == true
@_damage_sprite.zoom_x = 2
@_damage_sprite.zoom_y = 2
end
@_damage_sprite.z = 3000
@_damage_duration = XRXS_DamageSettings::DURATION
end
end
end
class Game_Battler
attr_accessor :damage_sp
end
class Sprite_Battler < RPG::Sprite
alias xrxs62_update update
def update
if @battler != nil and @battler_visible and
@battler.damage_pop and @battler.damage_sp != nil and
(@battler.damage == nil or @battler.damage == "")
value = @battler.damage_sp
dispose_damage
damage_string = $data_system.words.sp + " " + value.to_s
damage(damage_string, @battler.critical,@battler.state,@battler.item)
@battler.damage_sp = nil
@battler.critical = false
@battler.state = false
@battler.item = false
@battler.damage_pop = false
end
xrxs62_update
end
end
module XRXS_ResultPop
def update
super
unless @xrxs_resultpop_done
if @battler == nil or not @battler.is_a?(Game_Enemy)
@xrxs_resultpop_done = true
return
end
if @_collapse_duration > 0 and @battler.gain_exp_act == true
if @_collapse_duration == EXP
if @battler.exp != 0
result = "EXP " + @battler.exp.to_s
damage(result, false,false,false)
end
elsif @_collapse_duration == GOLD and @battler.gain_exp_act == true
if @battler.gold != 0
result = @battler.gold.to_s + " " + $data_system.words.gold
damage(result, false,false,false)
end
@xrxs_resultpop_done = true if $mog_rgss_ap_parameter == nil
elsif $mog_rgss_ap_parameter != nil and @_collapse_duration == (GOLD / 2) and @battler.gain_exp_act == true
if @battler.ap != 0
result = @battler.ap.to_s + " " + MOG::AP_NAME
damage(result, false,false,false)
end
@xrxs_resultpop_done = true
end
end
end
end
end
class RPG::Sprite < Sprite
include XRXS_ResultPop
end