[VX Ace] Damage Popup
Version: 1.0
By: Dargor
Version: 1.0
By: Dargor
Introduction
Mouahahahaa. So yeah, the RPG Maker VX Ace trial is out today. ;)
This is nothing special, just a script to display a damage popup on enemies when they take damage or recover.
This script covers damage/recovery of HP, MP and TP. It is also customizable!
Mouahahaha, you could say I'm back. :P
Features
- Displays damage/recovery popup on enemies
- Color of the popup types are customizable
Screenshots
Imagine colored numbers on enemies! I'm too lazy to make a screenshot.
Demo
None.
Script
script
Show
- #==============================================================================
- # ** Damage Popup
- #------------------------------------------------------------------------------
- # © Dargor, 2011
- # 01/12/11
- # Version 1.0
- #------------------------------------------------------------------------------
- # VERSION HISTORY:
- # - 1.0 (01/12/11), Initial release
- #------------------------------------------------------------------------------
- # INSTRUCTIONS:
- # - Paste this above main
- # - Edit the constants in Damage_Popup module
- #==============================================================================
- #==============================================================================
- # ** Damage Popup Customization Module
- #==============================================================================
- module Damage_Popup
- HP_Damage_Color = Color.new(255,255,255)
- MP_Damage_Color = Color.new(172,0,234)
- TP_Damage_Color = Color.new(253,157,62)
- HP_Recover_Color = Color.new(0,255,0)
- MP_Recover_Color = Color.new(48,192,255)
- TP_Recover_Color = Color.new(255,242,0)
- end
- #==============================================================================
- # ** Sprite_Battler
- #------------------------------------------------------------------------------
- # This sprite is used to display battlers. It observes a instance of the
- # Game_Battler class and automatically changes sprite conditions.
- #==============================================================================
- class Sprite_Battler < Sprite_Base
- #--------------------------------------------------------------------------
- # * Alias Listing
- #--------------------------------------------------------------------------
- alias dargor_ace_dmgpopup_sprite_battler_initialize initialize
- alias dargor_ace_dmgpopup_sprite_battler_setup_new_effect setup_new_effect
- alias dargor_ace_dmgpopup_sprite_battler_start_effect start_effect
- alias dargor_ace_dmgpopup_sprite_battler_update_effect update_effect
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(viewport, battler = nil)
- # The Usual
- dargor_ace_dmgpopup_sprite_battler_initialize(viewport, battler)
- # Create damage sprite
- @damage_sprite = Sprite_Base.new(viewport)
- @damage_sprite.bitmap = Bitmap.new(160,48)
- @damage_sprite.bitmap.font.bold = true
- @damage_sprite.bitmap.font.outline = true
- @damage_sprite.bitmap.font.size = 32
- @damage_sprite.visible = false
- @damage_duration = 0
- @damage_effect = nil
- end
- #--------------------------------------------------------------------------
- # * Setup New Effect
- #--------------------------------------------------------------------------
- def setup_new_effect
- # The Usual
- dargor_ace_dmgpopup_sprite_battler_setup_new_effect
- # Check for HP Damage
- if display_damage_sprite? && @battler.result.hp_damage > 0
- start_damage(:hp_damage)
- # Check for MP Damage
- elsif display_damage_sprite? && @battler.result.mp_damage > 0
- start_damage(:mp_damage)
- # Check for TP Damage
- elsif display_damage_sprite? && @battler.result.tp_damage > 0
- start_damage(:tp_damage)
- # Check for HP Recover
- elsif display_damage_sprite? && @battler.result.hp_damage < 0
- start_damage(:hp_recover)
- # Check for MP Recover
- elsif display_damage_sprite? && @battler.result.mp_damage < 0
- start_damage(:mp_recover)
- # Check for TP Recover
- elsif display_damage_sprite? && @battler.result.tp_damage < 0
- start_damage(:tp_recover)
- end
- end
- #--------------------------------------------------------------------------
- # * Damage Display Test
- #--------------------------------------------------------------------------
- def display_damage_sprite?
- return (@battler.result.success && @damage_duration == 0)
- end
- #--------------------------------------------------------------------------
- # * Start Damage Effect
- #--------------------------------------------------------------------------
- def start_damage(effect_type)
- @damage_effect = effect_type
- @damage_duration = 60
- case @damage_effect
- when :hp_damage
- @damage_sprite.bitmap.font.color = Damage_Popup::HP_Damage_Color
- when :mp_damage
- @damage_sprite.bitmap.font.color = Damage_Popup::MP_Damage_Color
- when :tp_damage
- @damage_sprite.bitmap.font.color = Damage_Popup::TP_Damage_Color
- when :hp_recover
- @damage_sprite.bitmap.font.color = Damage_Popup::HP_Recover_Color
- when :mp_recover
- @damage_sprite.bitmap.font.color = Damage_Popup::MP_Recover_Color
- when :tp_recover
- @damage_sprite.bitmap.font.color = Damage_Popup::TP_Recover_Color
- end
- update_damage_popup_position
- update_damage_popup_text
- @damage_sprite.visible = true
- @damage_sprite.opacity = 255
- end
- #--------------------------------------------------------------------------
- # * Update Effects
- #--------------------------------------------------------------------------
- def update_effect
- # Update effects
- if @damage_duration > 0
- @damage_duration -= 1
- update_damage
- if @damage_duration == 0
- @damage_sprite.visible = false
- @damage_type = nil
- @battler.result.clear_hit_flags
- end
- end
- # The Usual
- dargor_ace_dmgpopup_sprite_battler_update_effect
- end
- #--------------------------------------------------------------------------
- # * Update Damage Sprite Potision
- #--------------------------------------------------------------------------
- def update_damage_popup_position
- if @battler && @battler.use_sprite?
- @damage_sprite.x = @battler.screen_x
- @damage_sprite.y = @battler.screen_y - 48
- @damage_sprite.z = @battler.screen_z + 10
- end
- end
- #--------------------------------------------------------------------------
- # * Update Damage Sprite Text
- #--------------------------------------------------------------------------
- def update_damage_popup_text
- case @damage_effect
- when :hp_damage, :hp_recover
- string = @battler.result.hp_damage.abs.to_s
- when :mp_damage, :mp_recover
- string = @battler.result.mp_damage.abs.to_s
- when :tp_damage, :tp_recover
- string = @battler.result.tp_damage.abs.to_s
- end
- rect = @damage_sprite.bitmap.text_size(string)
- @damage_sprite.bitmap.clear
- @damage_sprite.bitmap.draw_text(rect, string, 1)
- end
- #--------------------------------------------------------------------------
- # * Update Damage
- #--------------------------------------------------------------------------
- def update_damage
- case @damage_duration
- when 58..59
- @damage_sprite.y -= 4
- when 56..57
- @damage_sprite.y -= 2
- when 54..55
- @damage_sprite.y += 2
- when 48..53
- @damage_sprite.y += 4
- end
- if @damage_duration <= 20
- @damage_sprite.opacity = @damage_duration * 11
- end
- end
- end
Expand to see the code.
Instructions
As usual, place this script above Main and under Materials.
Since the trial version of Ace doesn't allow to modify, here's a little trick to insert the script.
1 - Create a new project in Ace.
2 - Go in your game folder and copy Scripts.rvdata2
3 - Go in a VX project folder and replace Scripts.rvdata by Script.rvdata2 you just copied. Rename it Scripts.rvdata.
4 - Open this VX project, paste the script, save the project.
5 - In the VX project folder, copy Scripts.rvdata, and paste it in the Ace folder and rename it Scripts.rvdata2.
6 - Press play in Ace and
And you're done!
Simple isn't it? :P
Credits and Thanks
Don't forget to give me credits!
Author's Notes
This was done using the Trial version of Ace.