Code:
#------------------------------------------------------------------------------
# This modification is so that you can spawn new events mainly for animations in
# the battle system. Miss and summons will not work if this is not here.
#------------------------------------------------------------------------------
class Anim_Miss < Game_Event
def initialize(type = 0, anim_id = 0)
@type = type
@anim_id = anim_id
@played = false
anim = RPG::Event.new(0,0)
super($game_map.map_id, anim)
end
def animated?
return false
end
def start_anim
case @type
when 0
@animation_id = GTBS::MISS_ANIMATION #Animation ID of MISS!.. for spells that miss
when 1
@animation_id = GTBS::SUMMON_ANIM_ID #Animation ID of SPAWN.. for summons (RAISE)
else
@animation_id = @anim_id
end
@played = true
end
def place(x,y)
moveto(x,y)
@id = $game_map.events.size + 1
$game_system.battle_events[@id] = self
$scene.spriteset.event_sprites.push(Sprite_Character.new($scene.spriteset.viewport1,self))
@sprite = $scene.spriteset.event_sprites.last
end
#alias anim_miss_update update
def update
super()
if @played == true and !@sprite.animation?
$scene.spriteset.event_sprites.delete(@sprite)
$game_map.events.delete(self)
end
end
end
class Turn_Sprite < Sprite_Base
def initialize(viewport)
@_damage_duration = 0
super(viewport)
end
def dispose_damage
if @_damage_sprite != nil
@_damage_sprite.bitmap.dispose
@_damage_sprite.dispose
@_damage_sprite = nil
@_damage_duration = 0
end
end
def update
update_damage
super
end
def update_damage
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(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.y = self.y - (self.oy/1.5)
@_damage_sprite.z = 3000
@_damage_duration = 60
end
def doom_pop(value) #Used only for doom right now.
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 = GTBS.font
bitmap.font.size = 20
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)
@_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 / 1.5)
@_damage_sprite.z = 3000
@_damage_duration = 40
end
def start_animation(animation, mirror = false, direction = 8)
@direction = direction
@turnable = animation.name.downcase.include?("[turn]")
@updated = false
super(animation, mirror)
end
def animation_set_sprites(frame)
super(frame)
for i in 0..15
sprite = @animation_sprites[i]
if @turnable
d = @direction
sprite.angle += (d == 8 ? 0 : d == 6 ? 270 : d == 4 ? 90 : 180)
end
end
end
end
class Bitmap
def draw_outline_text(x,y,w,h,text,align=0,clear = 1)
color = self.font.color.clone
if clear == 1
self.font.color = Color.new(50,50,50,200)
elsif clear == 0
self.font.color = Color.new(0,0,0)
end
self.draw_text(x+1,y+1,w,h,text,align)
self.draw_text(x+1,y-1,w,h,text,align)
self.draw_text(x-1,y-1,w,h,text,align)
self.draw_text(x-1,y+1,w,h,text,align)
self.draw_text(x-1,y,w,h,text,align)
self.draw_text(x+1,y,w,h,text,align)
self.draw_text(x,y+1,w,h,text,align)
self.draw_text(x,y-1,w,h,text,align)
self.font.color = color
self.draw_text(x,y,w,h,text,align)
end
def gradation_rect(x, y, width, height, color1, color2, align = 0)
if align == 0
for i in x...x + width
red = color1.red + (color2.red - color1.red) * (i - x) / (width - 1)
green = color1.green +
(color2.green - color1.green) * (i - x) / (width - 1)
blue = color1.blue +
(color2.blue - color1.blue) * (i - x) / (width - 1)
alpha = color1.alpha +
(color2.alpha - color1.alpha) * (i - x) / (width - 1)
color = Color.new(red, green, blue, alpha)
fill_rect(i, y, 1, height, color)
end
elsif align == 1
for i in y...y + height
red = color1.red +
(color2.red - color1.red) * (i - y) / (height - 1)
green = color1.green +
(color2.green - color1.green) * (i - y) / (height - 1)
blue = color1.blue +
(color2.blue - color1.blue) * (i - y) / (height - 1)
alpha = color1.alpha +
(color2.alpha - color1.alpha) * (i - y) / (height - 1)
color = Color.new(red, green, blue, alpha)
fill_rect(x, i, width, 1, color)
end
elsif align == 2
for i in x...x + width
for j in y...y + height
red = color1.red + (color2.red - color1.red) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
green = color1.green + (color2.green - color1.green) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
blue = color1.blue + (color2.blue - color1.blue) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
alpha = color1.alpha + (color2.alpha - color1.alpha) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
color = Color.new(red, green, blue, alpha)
set_pixel(i, j, color)
end
end
elsif align == 3
for i in x...x + width
for j in y...y + height
red = color1.red + (color2.red - color1.red) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
green = color1.green + (color2.green - color1.green) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
blue = color1.blue + (color2.blue - color1.blue) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
alpha = color1.alpha + (color2.alpha - color1.alpha) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
color = Color.new(red, green, blue, alpha)
set_pixel(i, j, color)
end
end
end
end
end