Skip to content

Instantly share code, notes, and snippets.

@kl
Created February 22, 2012 17:59
Show Gist options
  • Save kl/1886328 to your computer and use it in GitHub Desktop.
Save kl/1886328 to your computer and use it in GitHub Desktop.
Overkill System -- Victory Aftermath compatibility
#
# Various patches to make Overkill compatiable with Yanfly Aftermath
# v1.1 - by Kal
# - exp bar now displays overkill exp correctly
#
if $imported && $imported["YEA-VictoryAftermath"]
module Kal
module Overkill_Aftermath
# Text used to display bonus exp.
BONUS_EXP = "+%sBONUS"
# Use this to adjust the Y position (up or down) of
# the exp bonus text (the smaller the number the higher
# up on the screen the text will be drawn)
Y_ADJUST = -6
end
end
module BattleManager
#
# Add any eventual overkill items to the list of items that
# are displayed at the end of the battle by Aftermath.
#
def self.gain_drop_items
drops_kal = $game_troop.make_overkill_items_kal
drops_kal ||= []
drops_kal.reject! { |item| item.nil? }
$game_troop.make_drop_items.each do |item|
$game_party.gain_item(item, 1)
drops_kal << item
end
SceneManager.scene.show_victory_spoils($game_troop.gold_total, drops_kal)
set_victory_text(@victory_actor, :drops)
wait_for_message
end
#
# Gains all experience (including overkill exp) before the
# level up logic is handled so that level ups will be displayed
# correctly with overkills.
#
def self.gain_exp
$game_party.all_members.each do |actor|
temp_actor = Marshal.load(Marshal.dump(actor))
$game_troop.members.each do |enemy|
if enemy.ok_info_kal && enemy.ok_info_kal[:killer] == actor
bonus = enemy.exp_bonus_ok_kal
actor.gain_exp(bonus)
gain_params_overkill_kal(actor, enemy)
end
actor.gain_exp($game_troop.exp_total)
end
unless actor.level == temp_actor.level
SceneManager.scene.show_victory_level_up(actor, temp_actor)
set_victory_text(actor, :level)
wait_for_message
end
end
end
#
# Go directly to the aliased version (which will be the method that
# Aftermath defined) because we don't want to display any game message
# text.
#
def self.display_exp
display_exp_overkill_kal
end
end
class Window_VictoryEXP_Back
#
# Calculates and draws the bonus exp the actor gained underneath the
# normal battle experience that everybody gains.
#
def draw_exp_gain(actor, rect)
dw = rect.width - (rect.width - [rect.width, 96].min) / 2
dy = rect.y + line_height * 3 + 96
fmt = YEA::VICTORY_AFTERMATH::VICTORY_EXP
text1 = sprintf(fmt, actor_exp_gain(actor).group)
contents.font.size = YEA::VICTORY_AFTERMATH::FONTSIZE_EXP
change_color(power_up_color)
draw_text(rect.x, dy, dw, line_height, text1, 2)
bonus = get_actor_overkill_exp_kal(actor)
if bonus > 0
bonus_text = Kal::Overkill_Aftermath::BONUS_EXP
text2 = sprintf(bonus_text, bonus.group)
y_adjust = Kal::Overkill_Aftermath::Y_ADJUST
draw_text(rect.x, dy + line_height + y_adjust, dw, line_height, text2, 2)
end
end
#
# Iterates over all enemies and gets the total amount of overkill
# experience a given actor gained.
#
def get_actor_overkill_exp_kal(actor)
bonus = 0
$game_troop.members.each do |enemy|
if enemy.ok_info_kal && enemy.ok_info_kal[:killer] == actor
bonus += enemy.exp_bonus_ok_kal
end
end
bonus
end
#
# This method is used to calculate by how much the EXP bar
# should be increased. Add overkill exp to the result.
#
def actor_exp_gain(actor)
n = @exp_total * actor.final_exp_rate
n.to_i + get_actor_overkill_exp_kal(actor)
end
end
else
puts "Overkill: YEA-VictoryAftermath was not found - using defaults"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment