RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Overkill!

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 83
プログラマです
Overkill
Version: 1.0
Author: SeMcDun
Date: 2014.09.10

Version History


  • <Version 1.0> 2014.09.10 - Original Release

Planned Future Versions

  • <Version 2.0> Possibly add in a % chance to gain overkill items instead of guaranteed.

Description


For those of you who know Final Fantasy 10, it's very similar to their Overkill system.
An enemy is given an overkill value. If the killing blow dealt to that enemy is greater than or equal to the overkill value
the player is rewarded with bonus loot/exp (usually better than they'd get for normally killing an enemy).

I also added in an overkill level. This stops the player from receiving overkill rewards if their average party level is greater
than the specified overkill level.

Screenshots

No Overkill :[



OVERKILL!




Instructions

<In the script>

Script


Code: [Select]
#=begin

#===============================================================================
# SeM's Overkill VXA
#
# - v1.0
# By SeMcDun
# Last Update: 2014.09.10
#===============================================================================
# Description;
# -- Adds an "Overkill" stat. When a player delivers a killing blow to the
#    enemy that is higher than the overkill stat, the player can receive better
#    drops, more gold and higher experience.
#
# -- You can set an overkill level which stops players from overkilling an
#    enemy if the average party level is too high.
#   
# Compatibility;
# -- Added compatibility with YEA Battle Engine
#    ( Set SHOW_OVERKILL_TEXT to false and use the nice icon popup.)
# -- Added compatibility with YEA Victory Aftermath
#
#===============================================================================
# Version History;
#
# v1.0
# 2014.09.10 - Completed
#
#===============================================================================
# Enemy Notetags
#------------------------------------------------------------------------------
# <overkill x>
# x - integer (damage that needs to be done)
#
# <overkill_level x>
# x - level
# The tag above makes it so if the average level of the party is greater than
# or equal to x, they cannot overkill the enemy.
# I guess this could stop people abusing overkilling enemies later in the game?
#
# <overkill_item xy: z>      eg. <overkill_item A5: 2> (Drops 2 of Armor ID 5)
# x - substitute for;
#     w - weapon
#     a - armour
#     i - item
# y - item index
# z - quantity
#
# (For gold, use <overkill_item G: 100> for 100 gold)
#
# <overkill_exp x>
# x - EXP gained instead
#
#===============================================================================
# Script Calls
#-------------------------------------------------------------------------------
#
#===============================================================================
$imported = {} if $imported.nil?
$imported["SEM-Overkill"] = true
#===============================================================================
# SEM::
#===============================================================================
module SEM
  module OVERKILL
   
    # ID of the Overkill KO state - Good when used with YEA Battle Engine
    OVERKILL_STATE = 26
   
    # Only give overkill items
    # When set to false, players will receive monster drops AND the overkill items
    ONLY_OVERKILL = false
   
    SHOW_OVERKILL_MESSAGE = true
   
    OVERKILL_TEXT = "Overkill!"
   
  end
  module REGEXP
    module ENEMY
      OVERKILL = /<(?:OVERKILL|overkill)[ ](\d+)>/i
     
      OVERKILL_LEVEL = /<(?:OVERKILL_LEVEL|overkill_level)[ ](\d+)>/i
     
      OVERKILL_ITEM = /<(?:OVERKILL_ITEM|overkill_item)[ ]([IWA])(\d+):[ ](\d+)>/i
      OVERKILL_GOLD = /<(?:OVERKILL_GOLD|overkill_gold)[ ](\d+)>/i
     
      OVERKILL_EXP = /<(?:OVERKILL_EXP|overkill_exp)[ ](\d+)>/i
     
      OVERKILL_WEXP = /<(?:OVERKILL_WEXP|overkill_wexp)[ ](\d+)>/i
    end # ENEMY
   
   
  end
  module VOCAB
   
    # Money gained
    COINS = "Coins"
   
  end
end
#==============================================================================
# ¦ DataManager
#==============================================================================
module DataManager
 
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_sok load_database; end
  def self.load_database
    load_database_sok
    load_notetags_sok
  end
 
  #--------------------------------------------------------------------------
  # new method: load_notetags_sok
  #--------------------------------------------------------------------------
  def self.load_notetags_sok
    for enemy in $data_enemies
      next if enemy.nil?
      enemy.load_enemy_notetags_sok
    end
  end
 
end # DataManager
#==============================================================================
# ¦ RPG::Enemy
#==============================================================================
class RPG::Enemy < RPG::BaseItem

  attr_accessor :overkill_value
  attr_accessor :overkill_items
  attr_accessor :overkill_exp
  attr_accessor :overkill_wexp
  attr_accessor :enemy_id
  attr_accessor :overkill_lvl
 
  def load_enemy_notetags_sok
    @overkill_value = 999999999   # By Default, if no Overkill value is set
    @overkill_items = []          # a player should never be able to overkill
    @overkill_exp = 0
    @overkill_wexp = 0
    @overkill_lvl = 999999      # By default, any enemy can be overkilled at
                                  # any level
   
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when SEM::REGEXP::ENEMY::OVERKILL
        @overkill_value = $1.to_i
      when SEM::REGEXP::ENEMY::OVERKILL_LEVEL
        @overkill_lvl = $1.to_i
      when SEM::REGEXP::ENEMY::OVERKILL_ITEM
        case $1.upcase
        when "I"; item_type = 1
        when "W"; item_type = 2
        when "A"; item_type = 3
        else; next
        end
        item_index = $2.to_i
        item_quantity = $3.to_i
        @overkill_items.push(RPG::Enemy::OverkillItems.new(item_type,item_index,item_quantity))
      when SEM::REGEXP::ENEMY::OVERKILL_GOLD
        item_type = 4
        item_index = 0
        item_quantity = $1.to_i
        @overkill_items.push(RPG::Enemy::OverkillItems.new(item_type,item_index,item_quantity))
      when SEM::REGEXP::ENEMY::OVERKILL_EXP
        @overkill_exp = $1.to_i
      when SEM::REGEXP::ENEMY::OVERKILL_WEXP
        @overkill_wexp = $1.to_i
      end

    }
  end

end # RPG::Enemy
#==============================================================================
# ¦ RPG::Enemy::OverkillItems
#==============================================================================

class RPG::Enemy::OverkillItems
 
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :item_type
  attr_accessor :item_index
  attr_accessor :item_quantity
 
  #--------------------------------------------------------------------------
  # initialize
  #--------------------------------------------------------------------------
  def initialize(item_type, item_index, item_quantity)
    @item_type = item_type
    @item_index = item_index
    @item_quantity = item_quantity
  end
 
end # RPG::Enemy::OverkillItems

#===============================================================================
# module BattleManager
#===============================================================================
module BattleManager
 
  #--------------------------------------------------------------------------
  # overwrite method: self.gain_drop_items
  #--------------------------------------------------------------------------
  def self.gain_drop_items
    drops = []

      $game_troop.make_drop_items.each do |item|
        #
        $game_party.gain_item(item, 1)
        drops.push(item)
      end
     
      @overkill_list = []
     
      $game_troop.dead_members.each do |member|
        @overkill_list += member.make_overkill_items
      end
     
      @overkill_list.each do |item|
        $game_party.gain_item(item[0], item[1])
        for i in 1..item[1]
          drops.push(item[0])
        end # for each qty
       
        if $imported["YEA-VictoryAftermath"] != true
          if item[0] != nil
            for i in 1..item[1]
              # for each qty - print a message.
              $game_message.add(sprintf(Vocab::ObtainItem, item[0].name))
            end
          end
        end # if YEA victory aftermath is not imported - spit out item message
      end
   
    if $imported["YEA-VictoryAftermath"] == true
      SceneManager.scene.show_victory_spoils($game_troop.gold_total, drops)
      set_victory_text(@victory_actor, :drops)
    end # if victory aftermath is imported
   
    wait_for_message
  end
 
 
end
#==============================================================================
# ** Game_Troop
#------------------------------------------------------------------------------
#  This class handles enemy groups and battle-related data. Also performs
# battle events. The instance of this class is referenced by $game_troop.
#==============================================================================

class Game_Troop < Game_Unit
 
    def total_wexp
      @total_wexp = 0
      $game_troop.dead_members.each do |member|
        @total_wexp += member.get_wexp
      end
     
      return @total_wexp
    end

end
#==============================================================================
# ** Game_Enemy
#------------------------------------------------------------------------------
#  This class handles enemies. It used within the Game_Troop class
# ($game_troop).
#==============================================================================

class Game_Enemy < Game_Battler
 
  attr_accessor :death_damage
  attr_accessor :overkill_flagged
  attr_reader   :overkill_level
 
  alias game_enemy_init_sok initialize
  def initialize(index, enemy_id)
    game_enemy_init_sok(index, enemy_id)
    @death_damage = 0
    @overkill_flagged = false
    @overkill_level = $data_enemies[enemy_id].overkill_lvl
  end
 
  #--------------------------------------------------------------------------
  # * Overwrite Get Experience
  #--------------------------------------------------------------------------
  def exp
    if self.death_damage >= enemy.overkill_value && $game_party.average_party_level < self.overkill_level
      if SEM::OVERKILL::ONLY_OVERKILL == true
        enemy.overkill_exp
      else
        enemy.overkill_exp + enemy.exp
      end
    else
      enemy.exp
    end
  end
 
  #--------------------------------------------------------------------------
  # * Get Gold
  #--------------------------------------------------------------------------
  def gold
    @give_gold = 0
    enemy.overkill_items.each do |en|
      if en.item_type == 4
        if self.death_damage >= enemy.overkill_value && $game_party.average_party_level < self.overkill_level
          if SEM::OVERKILL::ONLY_OVERKILL == true
            return en.item_quantity
          else
            return en.item_quantity + enemy.gold
          end
        end
      end
    end
   
    return enemy.gold
   
  end
 
 
  #-----------------------------------------------------------------------
  # * Create Array of Dropped Items
  #-----------------------------------------------------------------------
  def make_overkill_items
   
    @r = []
   
    if self.death_damage >= $data_enemies[self.enemy_id].overkill_value  && $game_party.average_party_level < self.overkill_level
      $data_enemies[self.enemy_id].overkill_items.each do |item|
        @r.push([item_object(item.item_type, item.item_index), item.item_quantity])
      end
    end
   
    return @r
   
  end
 
 
  alias game_battler_die_sok die
  def die
    if self.actor? == false
      self.death_damage = @result.hp_damage
      if self.death_damage >= $data_enemies[self.enemy_id].overkill_value && $game_party.average_party_level < self.overkill_level
        # Show overkill message
        if SEM::OVERKILL::SHOW_OVERKILL_MESSAGE
          if @overkill_flagged != true
            #SceneManager.scene.log_window.add_text("Overkill!")
            #$game_message.add("Overkill!")
            @overkill_flagged = true
          end # @overkill_flagged
        end # show message?
      end # if overkilled
    end # if enemy
   
    game_battler_die_sok
  end
 
  def make_drop_items
   
    if SEM::OVERKILL::ONLY_OVERKILL == true
      # Only give overkill items
      # Check if it was overkilled
      if self.death_damage >= $data_enemies[self.enemy_id].overkill_value && $game_party.average_party_level < self.overkill_level
        # It was overkilled, don't give items
        enemy.drop_items.inject([]) do |r, di|
            r
        end
       
      else
        # It was NOT overkilled, give items
        enemy.drop_items.inject([]) do |r, di|
          if di.kind > 0 && rand * di.denominator < drop_item_rate
            r.push(item_object(di.kind, di.data_id))
          else
            r
          end
        end
      end
     
    else
      # Give all items
      enemy.drop_items.inject([]) do |r, di|
        if di.kind > 0 && rand * di.denominator < drop_item_rate
          r.push(item_object(di.kind, di.data_id))
        else
          r
        end
      end
    end
     
  end
 
  #--------------------------------------------------------------------------
  # * Get State ID of K.O.
  #--------------------------------------------------------------------------
  def death_state_id
    if self.death_damage >= $data_enemies[self.enemy_id].overkill_value && $game_party.average_party_level < self.overkill_level
      return SEM::OVERKILL::OVERKILL_STATE
    else
      return 1
    end
  end
 
end

#==============================================================================
# ** Window_BattleLog
#------------------------------------------------------------------------------
#  This window is for displaying battle progress. No frame is displayed, but it
# is handled as a window for convenience.
#==============================================================================

class Window_BattleLog < Window_Selectable
 
  #--------------------------------------------------------------------------
  # * Display HP Damage
  #--------------------------------------------------------------------------
  def display_hp_damage(target, item)
    return if target.result.hp_damage == 0 && item && !item.damage.to_hp?
    if target.result.hp_damage > 0 && target.result.hp_drain == 0
      target.perform_damage_effect
    end
    Sound.play_recovery if target.result.hp_damage < 0
    if !target.actor?
      if target.overkill_flagged == true
        overkill_text = SEM::OVERKILL::OVERKILL_TEXT
      else
        overkill_text = ""
      end # if flagged for overkill
    else
      overkill_text = ""
    end # if actor is an enemy
    add_text(target.result.hp_damage_text + " " + overkill_text)
    wait
  end
 
end # Window_BattleLog

#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  This class handles parties. Information such as gold and items is included.
# Instances of this class are referenced by $game_party.
#==============================================================================

class Game_Party < Game_Unit
 
  def average_party_level
    total_level = 0
    members.each do |member|
      total_level += member.level
    end # for each party member
   
    # Now divide the total level by the # of actors
    average_level = (total_level / members.count)
    return average_level
  end # average_party_level
 
end # Game_Party

#=end

Credit


  • SeMcDun

Thanks

  • Final Fantasy X, I guess.

Support


Post any bugs here and I'll try fix them quickly.

Known Compatibility Issues

Could conflict with other scripts which edit battle rewards and stuff.
Note: This script is compatible with YEA Battle Engine and Victory Aftermath.

Demo


See attachment.

Terms of Use


Same terms as staple post really.
Fine for non-commercial use (with creds ^_^).