Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Battler : OverKill (w/ Exp & Gold Bonus)

Battler : OverKill (w/ Exp & Gold Bonus)
Version: 3.5
By: Kain Nobel

Introduction

What is "OverKill" ? Basically, if a battler kills its target with a critical strike, then it'll display an OverKill damage pop. Alongside this, I made an optional plugin which increases EXP and Gold gained with each battler killed with an overkill strike.

Features

  • Displayes "OverKill!!!" instead of Critical when target killed with critical strike
  • Easily customize the display, font and color options of the overkill damage
  • Plugin to give you an Exp and Gold bonus when striking an OverKill
  • Exp & Gold plugin can use variables, or constants values

Screenshots

OverKillDamage.png


Script

Code:
#===============================================================================

# ** Battler : OverKill

#===============================================================================

 

#-------------------------------------------------------------------------------

# * SDK Log

#-------------------------------------------------------------------------------

if Object.const_defined?(:SDK)

  SDK.log('Battler.OverKill', 'Kain Nobel ©', 3.5, '2009.09.09')

end

 

#===============================================================================

# ** OverKill

#===============================================================================

 

module OverKill

  #-----------------------------------------------------------------------------

  # * String for Damage Pop when killing hit was a critical hit

  #-----------------------------------------------------------------------------

  Critical_String = "OverKill!!!"

  #-----------------------------------------------------------------------------

  # * Color for Overkill Damage Pop (Background)

  #-----------------------------------------------------------------------------

  Critical_ColorA  = Color.new(96, 64, 0)

  #-----------------------------------------------------------------------------

  # * Color for Overkill Damage Pop (Main)

  #-----------------------------------------------------------------------------

  Critical_ColorB  = Color.new(255, 64, 64)

  #-----------------------------------------------------------------------------

  # * Color for Overkill Damage Value (Background)

  #-----------------------------------------------------------------------------

  Damage_ColorA    = Color.new(128, 128, 128)

  #-----------------------------------------------------------------------------

  # * Color for Overkill Damage Value (Main)

  #-----------------------------------------------------------------------------

  Damage_ColorB    = Color.new(255, 32, 32)

  #-----------------------------------------------------------------------------

  # * Font Name for Overkill Damage

  #-----------------------------------------------------------------------------

  Font_Name        = "Arial Black"

  #-----------------------------------------------------------------------------

  # * Font Size for Overkill Damage

  #-----------------------------------------------------------------------------

  Font_Size        = 32

end

 

#===============================================================================

# ** Game_Battler

#===============================================================================

 

class Game_Battler

  #-----------------------------------------------------------------------------

  # * Alias Listings

  #-----------------------------------------------------------------------------

  alias_method :overkill_gmbattler_attackeffect,:attack_effect

  #-----------------------------------------------------------------------------

  # * Attack Effect Critical Correction

  #-----------------------------------------------------------------------------

  def attack_effect(attacker)

    # Get old attack effect result

    result = overkill_gmbattler_attackeffect(attacker)

    # If damage is critical and fatal

    if self.critical && @hp < self.damage

      # Double the damage just for kicks

      self.damage *= 2

      # Set critical flag for overkill damage pop

      self.critical = OverKill::Critical_String

    end

    # Return attack effect's origional result

    result

  end

end

 

#===============================================================================

# ** RPG::Sprite

#===============================================================================

 

class RPG::Sprite < ::Sprite

  #-----------------------------------------------------------------------------

  # * Alias Listings

  #-----------------------------------------------------------------------------

  alias_method :overkill_rpgsprite_damage, :damage

  #-----------------------------------------------------------------------------

  # * Damage

  #-----------------------------------------------------------------------------

  def damage(value, critical)

    # If critical is not set to overkill flag

    if critical != OverKill::Critical_String

      # The usual

      overkill_rpgsprite_damage(value, critical)

      # End the method

      return

    end

    # Dispose of current damage

    dispose_damage

    # Create bitmap to fit overkill damage display

    bitmap = Bitmap.new(160, 96)

    # Convert damage value to string

    damage_string = (value.is_a?(Numeric) ? value.abs.to_s : value.to_s)

    # Set custom overkill font name and size

    bitmap.font.name = OverKill::Font_Name

    bitmap.font.size = OverKill::Font_Size

    # Set overkill critical back color

    bitmap.font.color = OverKill::Critical_ColorA

    # Draw overkill critical background

    bitmap.draw_text(-1, 12-1, 160, 36, OverKill::Critical_String, 1)

    bitmap.draw_text(-1, 12-1, 160, 36, OverKill::Critical_String, 1)

    bitmap.draw_text(+1, 12+1, 160, 36, OverKill::Critical_String, 1)

    bitmap.draw_text(+1, 12+1, 160, 36, OverKill::Critical_String, 1)

    # Set overkill damage back color

    bitmap.font.color = OverKill::Damage_ColorA

    # Draw overkill damage background

    bitmap.draw_text(-1, 32-1, 160, 36, damage_string, 1)

    bitmap.draw_text(+1, 32-1, 160, 36, damage_string, 1)

    bitmap.draw_text(-1, 32+1, 160, 36, damage_string, 1)

    bitmap.draw_text(+1, 32+1, 160, 36, damage_string, 1)

    # Set overkill damage front color

    bitmap.font.color = OverKill::Critical_ColorB

    # Draw overkill damage foreground

    bitmap.draw_text(0, 12, 160, 36, OverKill::Critical_String, 1)

    # Set overkill damage forground

    bitmap.font.color = OverKill::Damage_ColorB

    # Draw overkill damage

    bitmap.draw_text(0, 32, 160, 36, damage_string, 1)

    # Create damage sprites

    @_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 

    @_damage_sprite.z = 10000

    @_damage_duration = 40 

  end

end
Code:
#===============================================================================

# ** Battler : OverKill Experience & Gold

#===============================================================================

 

#-------------------------------------------------------------------------------

# * SDK Log

#-------------------------------------------------------------------------------

if Object.const_defined?(:SDK)

  SDK.log('Battler.OverKillExp&Gold', 'Kain Nobel ©', 3.5, '2009.09.09')

end

#-------------------------------------------------------------------------------

# * OverKill Enabled Test : Begin

#-------------------------------------------------------------------------------

if Object.const_defined?(:OverKill)

 

#===============================================================================

# ** OverKill

#===============================================================================

 

module OverKill

  #-----------------------------------------------------------------------------

  # * Use Variables

  #-----------------------------------------------------------------------------

  Use_Variables = false

  #-----------------------------------------------------------------------------

  # * Modifier for Overkill Gold      (0.25 or 25 would both denote 25% bonus)

  #-----------------------------------------------------------------------------

  Gold_Modifier = 0.25

  #-----------------------------------------------------------------------------

  # * Modifier for Overkill Exp       (0.25 or 25 would both denote 25% bonus)

  #-----------------------------------------------------------------------------

  Exp_Modifier  = 0.25

end

 

#===============================================================================

# ** Game_Battler

#===============================================================================

 

class Game_Battler

  #-----------------------------------------------------------------------------

  # * Alias Listings

  #-----------------------------------------------------------------------------

  alias_method :overkillexpgold_gmbattler_attackeffect, :attack_effect

  #-----------------------------------------------------------------------------

  # * Attack Effect Critical Correction

  #-----------------------------------------------------------------------------

  def attack_effect(attacker)

    # Get origional attack effect result

    result = overkillexpgold_gmbattler_attackeffect(attacker)

    # If critical flag is set for overkill

    if self.critical == OverKill::Critical_String

      # If battler being attacked is an enemy

      if self.is_a?(Game_Enemy)

        # Save in overkilled array

        $game_temp.overkilled << self

      end

    end

    # Return origional attack effect result

    result

  end

end

 

#===============================================================================

# ** Game_Temp

#===============================================================================

 

class Game_Temp

  #-----------------------------------------------------------------------------

  # * Public Instance Variables

  #-----------------------------------------------------------------------------

  attr_accessor :overkilled   # Array of enemies that were 'overkilled'

  #-----------------------------------------------------------------------------

  # * Alias Listings

  #-----------------------------------------------------------------------------

  alias_method :overkillexpgold_gmtemp_initialize, :initialize

  #-----------------------------------------------------------------------------

  # * Object Initialization

  #-----------------------------------------------------------------------------

  def initialize

    # The usual

    overkillexpgold_gmtemp_initialize

    # Create array for 'overkilled' battlers

    @overkilled = []

  end

  #-----------------------------------------------------------------------------

  # * OverKill Gold

  #-----------------------------------------------------------------------------

  def overkill_gold

    # Default gold to 0

    gold = 0

    # Iterate through all 'overkilled' battlers and get gold bonus

    @overkilled.each {|enemy| gold += enemy.overkill_gold}

    # Return gold bonus (as integer)

    Integer(gold)

  end

  #-----------------------------------------------------------------------------

  # * Overkill Exp

  #-----------------------------------------------------------------------------

  def overkill_exp

    # Default exp to 0

    exp = 0

    # Iterate though all 'overkilled' battlers and get exp bonus

    @overkilled.each {|enemy| exp += enemy.overkill_exp}

    # Return exp bonus (as integer)

    Integer(exp)

  end

end

 

#===============================================================================

# ** Game_Enemy

#===============================================================================

 

class Game_Enemy < Game_Battler

  #-----------------------------------------------------------------------------

  # * Overkill Gold

  #-----------------------------------------------------------------------------

  def overkill_gold

    # Get modifier, check if using variables for modifer

    mod = case OverKill::Use_Variables

    # If using variables, get variable gold modifier

    when true  then $game_variables[OverKill::Gold_Modifier]

    # Not using variables, get constant gold modifier

    when false then OverKill::Gold_Modifier

    end

    # Check if modifier is integer or float

    case mod

    # Get gold with percent modifier (25 denotes 25%)

    when Integer then return (self.gold * (mod * 0.01))

    # Get gold with percent modifier (0.25 denotes 25%)

    when Float   then return (self.gold * mod)

    end

  end

  #-----------------------------------------------------------------------------

  # * Overkill Exp

  #-----------------------------------------------------------------------------

  def overkill_exp

    # Get modifier, check if using variables for modifer

    mod = case OverKill::Use_Variables

    # If using variables, get variable exp modifier

    when true  then $game_variables[OverKill::Exp_Modifier]

    # Not using variables, get constant exp modifier

    when false then OverKill::Exp_Modifier

    end

    # Check if modifier is integer or float

    case mod

    # Get exp with percent modifier (25 denotes 25%)

    when Integer then return (self.exp * (mod * 0.01))

    # Get exp with percent modifier (0.25 denotes 25%)

    when Float   then return (self.exp * mod)

    end

  end

end

 

#===============================================================================

# ** Window_BattleResult

#===============================================================================

 

class Window_BattleResult < Window_Base

  #-----------------------------------------------------------------------------

  # * Alias Methods

  #-----------------------------------------------------------------------------

  alias_method :overkill_win_battleresult_initialize,   :initialize

  #-----------------------------------------------------------------------------

  # * Intialize

  #-----------------------------------------------------------------------------

  def initialize(exp, gold, treasures)

    # Add overkilled gold to origional gold

    gold += $game_troop.overkill_gold

    # Add overkilled exp to origional exp

    exp  += $game_troop.overkill_exp

    # The usual

    overkill_win_battleresult_initialize(exp, gold, treasures)

  end

end

 

#===============================================================================

# ** Scene_Battle

#===============================================================================

 

class Scene_Battle

  #-----------------------------------------------------------------------------

  # * Alias Listings

  #-----------------------------------------------------------------------------

  alias_method :overkill_snbattle_main, :main

  alias_method :overkill_snbattle_stp5, :start_phase5

  #-----------------------------------------------------------------------------

  # * Main

  #-----------------------------------------------------------------------------

  def main

    # The usual

    overkill_snbattle_main

    # Clear 'overkilled' battlers

    $game_temp.overkilled.clear

  end

  #-----------------------------------------------------------------------------

  # * Start Phase 5

  #-----------------------------------------------------------------------------

  def start_phase5

    # Get overkilled gold & exp

    gold = $game_troop.overkill_gold

    exp  = $game_troop.overkill_exp

    # Distribute exp to actors

    $game_party.actors.each {|a| a.exp += exp unless a.cant_get_exp?}

    # Get extra gold from overkilled enemies

    $game_party.gain_gold(gold)

    # The usual

    overkill_snbattle_stp5

  end

end

 

#-------------------------------------------------------------------------------

# * OverKill Enabled Test : Missing Requirement Message

#-------------------------------------------------------------------------------

else

  p 'Unable to find \'Battler.OverKill\' script, which is required for '+

    '\'Battler.OverKillExp&Gold\'. This script has been disabled.'

#-------------------------------------------------------------------------------

# * OverKill Enabled Test : End

#-------------------------------------------------------------------------------

end

Instructions

Place Above Main, Below SDK (Only if Using)

If using both scripts, they should be placed in this order (for obvious reasons)

Battler.OverKill
Battler.OverKillExp&Gold


If using my Weapons : Critical Bonus script, make sure that these two are above that one, or it won't work correctly.

The rest of the setup instructions are pretty obvious, just look at the constants in the script.

Compatibility

Place below anything that modifies Game_Battler.attack_effect, place above Weapons : Critical Bonus if you happen to be using it.

Credits and Thanks

Final Fantasy X, which I got the idea from.

Terms and Conditions

Another "Free to use in commercial and non-commercial games" script, please credit of course and thanks :thumb:
 
Woah, I've been wanting a script like this forever! Except...I use VX. Do you think you could make it work with VX too? Otherwise, great script! :D
 
Some of you probably got a NoMethodError from the second script, it was because I changed Game_Troop additions to Game_Temp right before I posted it (to prevent save file corruption). No worries now, script has been updated.

I really have to get acquainted with VX because I don't use it that much and don't know how it works, looking at it though there is alot different with the way battle system and damage pop and everything is handled so I'd have to write the script mostly/entirely from scratch. Shouldn't be too hard though, when I find some time I'll definately look into making a version for VX.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top