[VX Ace] Damage Popup

[VX Ace] Damage Popup
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
  1. #==============================================================================
  2. # ** Damage Popup
  3. #------------------------------------------------------------------------------
  4. #   © Dargor, 2011
  5. #  01/12/11
  6. #  Version 1.0
  7. #------------------------------------------------------------------------------
  8. #  VERSION HISTORY:
  9. #   - 1.0 (01/12/11), Initial release
  10. #------------------------------------------------------------------------------
  11. #  INSTRUCTIONS:
  12. #   - Paste this above main
  13. #   - Edit the constants in Damage_Popup module
  14. #==============================================================================
  15.  
  16. #==============================================================================
  17. # ** Damage Popup Customization Module
  18. #==============================================================================
  19.  
  20. module Damage_Popup
  21.   HP_Damage_Color = Color.new(255,255,255)
  22.   MP_Damage_Color = Color.new(172,0,234)
  23.   TP_Damage_Color = Color.new(253,157,62)
  24.   HP_Recover_Color = Color.new(0,255,0)
  25.   MP_Recover_Color = Color.new(48,192,255)
  26.   TP_Recover_Color = Color.new(255,242,0)
  27. end  
  28.  
  29. #==============================================================================
  30. # ** Sprite_Battler
  31. #------------------------------------------------------------------------------
  32. #  This sprite is used to display battlers. It observes a instance of the
  33. # Game_Battler class and automatically changes sprite conditions.
  34. #==============================================================================
  35.  
  36. class Sprite_Battler < Sprite_Base
  37.   #--------------------------------------------------------------------------
  38.   # * Alias Listing
  39.   #--------------------------------------------------------------------------
  40.   alias dargor_ace_dmgpopup_sprite_battler_initialize initialize
  41.   alias dargor_ace_dmgpopup_sprite_battler_setup_new_effect setup_new_effect
  42.   alias dargor_ace_dmgpopup_sprite_battler_start_effect start_effect
  43.   alias dargor_ace_dmgpopup_sprite_battler_update_effect update_effect
  44.   #--------------------------------------------------------------------------
  45.   # * Object Initialization
  46.   #--------------------------------------------------------------------------
  47.   def initialize(viewport, battler = nil)
  48.     # The Usual
  49.     dargor_ace_dmgpopup_sprite_battler_initialize(viewport, battler)
  50.     # Create damage sprite
  51.     @damage_sprite = Sprite_Base.new(viewport)
  52.     @damage_sprite.bitmap = Bitmap.new(160,48)
  53.     @damage_sprite.bitmap.font.bold = true
  54.     @damage_sprite.bitmap.font.outline = true
  55.     @damage_sprite.bitmap.font.size = 32
  56.     @damage_sprite.visible = false
  57.     @damage_duration = 0
  58.     @damage_effect = nil
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # * Setup New Effect
  62.   #--------------------------------------------------------------------------
  63.   def setup_new_effect
  64.     # The Usual
  65.     dargor_ace_dmgpopup_sprite_battler_setup_new_effect
  66.      # Check for HP Damage
  67.     if display_damage_sprite?        && @battler.result.hp_damage > 0
  68.       start_damage(:hp_damage)
  69.      # Check for MP Damage
  70.     elsif display_damage_sprite? && @battler.result.mp_damage > 0
  71.       start_damage(:mp_damage)
  72.     # Check for TP Damage
  73.     elsif display_damage_sprite? && @battler.result.tp_damage > 0
  74.       start_damage(:tp_damage)
  75.      # Check for HP Recover
  76.     elsif display_damage_sprite? && @battler.result.hp_damage < 0
  77.       start_damage(:hp_recover)
  78.      # Check for MP Recover
  79.     elsif display_damage_sprite? && @battler.result.mp_damage < 0
  80.       start_damage(:mp_recover)
  81.     # Check for TP Recover
  82.     elsif display_damage_sprite? && @battler.result.tp_damage < 0
  83.       start_damage(:tp_recover)
  84.     end
  85.   end
  86.   #--------------------------------------------------------------------------
  87.   # * Damage Display Test
  88.   #--------------------------------------------------------------------------
  89.   def display_damage_sprite?
  90.     return (@battler.result.success && @damage_duration == 0)
  91.   end
  92.   #--------------------------------------------------------------------------
  93.   # * Start Damage Effect
  94.   #--------------------------------------------------------------------------
  95.   def start_damage(effect_type)
  96.     @damage_effect = effect_type
  97.     @damage_duration = 60
  98.     case @damage_effect
  99.     when :hp_damage
  100.       @damage_sprite.bitmap.font.color = Damage_Popup::HP_Damage_Color
  101.     when :mp_damage
  102.       @damage_sprite.bitmap.font.color = Damage_Popup::MP_Damage_Color
  103.     when :tp_damage
  104.       @damage_sprite.bitmap.font.color = Damage_Popup::TP_Damage_Color
  105.     when :hp_recover
  106.       @damage_sprite.bitmap.font.color = Damage_Popup::HP_Recover_Color
  107.     when :mp_recover
  108.       @damage_sprite.bitmap.font.color = Damage_Popup::MP_Recover_Color
  109.     when :tp_recover
  110.       @damage_sprite.bitmap.font.color = Damage_Popup::TP_Recover_Color
  111.     end
  112.     update_damage_popup_position
  113.     update_damage_popup_text
  114.     @damage_sprite.visible = true
  115.     @damage_sprite.opacity = 255
  116.   end
  117.   #--------------------------------------------------------------------------
  118.   # * Update Effects
  119.   #--------------------------------------------------------------------------
  120.   def update_effect
  121.     # Update effects
  122.     if @damage_duration > 0
  123.       @damage_duration -= 1
  124.       update_damage
  125.       if @damage_duration == 0
  126.         @damage_sprite.visible = false
  127.         @damage_type = nil
  128.         @battler.result.clear_hit_flags
  129.       end  
  130.     end
  131.     # The Usual
  132.     dargor_ace_dmgpopup_sprite_battler_update_effect
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   # * Update Damage Sprite Potision
  136.   #--------------------------------------------------------------------------
  137.   def update_damage_popup_position
  138.     if @battler && @battler.use_sprite?
  139.       @damage_sprite.x = @battler.screen_x
  140.       @damage_sprite.y = @battler.screen_y - 48
  141.       @damage_sprite.z = @battler.screen_z + 10
  142.     end
  143.   end
  144.   #--------------------------------------------------------------------------
  145.   # * Update Damage Sprite Text
  146.   #--------------------------------------------------------------------------
  147.   def update_damage_popup_text
  148.     case @damage_effect
  149.     when :hp_damage, :hp_recover
  150.       string = @battler.result.hp_damage.abs.to_s
  151.     when :mp_damage, :mp_recover
  152.       string = @battler.result.mp_damage.abs.to_s
  153.     when :tp_damage, :tp_recover
  154.       string = @battler.result.tp_damage.abs.to_s
  155.     end
  156.     rect = @damage_sprite.bitmap.text_size(string)
  157.     @damage_sprite.bitmap.clear
  158.     @damage_sprite.bitmap.draw_text(rect, string, 1)
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # * Update Damage
  162.   #--------------------------------------------------------------------------
  163.   def update_damage
  164.     case @damage_duration
  165.     when 58..59
  166.       @damage_sprite.y -= 4
  167.     when 56..57
  168.       @damage_sprite.y -= 2
  169.     when 54..55
  170.       @damage_sprite.y += 2
  171.     when 48..53
  172.       @damage_sprite.y += 4
  173.     end
  174.     if @damage_duration <= 20
  175.       @damage_sprite.opacity = @damage_duration * 11
  176.     end
  177.   end
  178. end
  179.  
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.
YES. Cool stuff man!

Ace is great so far, even the trial shows its superiority over normal VX.

Congrats, you're one of the first people IN THE WORLD to make a script for Ace.
haha, nice. Good work as always Dargor
Wow! When RPG VX Ace out, I will save this script to my Folder 😀

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=75877