#==============================================================================
# Divisão Justa de EXP
# por Renan Tsuneo Hangai Junior
#===============================================================================
# Divide a experiência conforme o desempenho de cada herói
# na batalha
#===============================================================================
#==============================================================================
# Game_Party
#==============================================================================
class Game_Party
#--------------------------------------------------------------------------
def total_hit_count
tt = 0
for actor in @actors
tt += actor.hit_count
end
return tt
end
#--------------------------------------------------------------------------
def clear_hit_count
for actor in @actors
actor.clear_hit_count
end
end
#--------------------------------------------------------------------------
end
#==============================================================================
# Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
attr_accessor :hit_count
#--------------------------------------------------------------------------
alias rth_divide_exp_gactor_setup setup
alias rth_divide_exp_gactor_exp= exp=
#--------------------------------------------------------------------------
def setup(*args)
rth_divide_exp_gactor_setup(*args)
clear_hit_count
end
#--------------------------------------------------------------------------
def clear_hit_count
@hit_count = 0
end
#--------------------------------------------------------------------------
end
#==============================================================================
# Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
alias rth_divide_exp_genemy_attack_effect attack_effect
alias rth_divide_exp_genemy_skill_effect skill_effect
#--------------------------------------------------------------------------
def attack_effect(attacker)
pre_hp = @hp
valor = rth_divide_exp_genemy_attack_effect(attacker)
if attacker.is_a?(Game_Actor)
attacker.hit_count += [[self.damage, 0].max, pre_hp].min if self.damage.is_a?(Numeric)
end
return valor
end
#--------------------------------------------------------------------------
def skill_effect(user, skill)
pre_hp = @hp
valor = rth_divide_exp_genemy_skill_effect(user, skill)
if user.is_a?(Game_Actor)
user.hit_count += [[self.damage, 0].max, pre_hp].min if self.damage.is_a?(Numeric)
end
return valor
end
#--------------------------------------------------------------------------
end
#==============================================================================
# Window_BattleResult
#==============================================================================
class Window_BattleResult < Window_Base
#--------------------------------------------------------------------------
def initialize(exp, gold, treasures)
@exp = exp
@gold = gold
@treasures = treasures
super(160, 0, 320, @treasures.size * 32 + 64 + ($game_party.actors.size * 32))
self.contents = Bitmap.new(width - 32, height - 32)
self.y = 160 - height / 2
self.back_opacity = 160
self.visible = false
refresh
end
#--------------------------------------------------------------------------
def refresh
self.contents.clear
x = 4
total_damage = 0
for actor in $game_party.actors
total_damage += actor.hit_count
end
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
gexp = @exp.to_f * actor.hit_count.to_f / total_damage.to_f
txt = "#{actor.name} ganhou #{gexp.ceil} "
self.contents.font.color = normal_color
cx = contents.text_size(txt).width
self.contents.draw_text(x, i * 32, cx, 32, txt)
x += cx
self.contents.font.color = system_color
cx = contents.text_size("EXP").width
self.contents.draw_text(x, i * 32, cx, 32, "EXP")
x = 4
end
y = ($game_party.actors.size * 32)
self.contents.font.color = normal_color
cx = contents.text_size(@gold.to_s).width
self.contents.draw_text(x, y, cx, 32, @gold.to_s)
x += cx + 4
self.contents.font.color = system_color
self.contents.draw_text(x, y, 128, 32, $data_system.words.gold)
for item in @treasures
y += 32
draw_item_name(item, 4, y)
end
end
#--------------------------------------------------------------------------
end
#==============================================================================
# Scene_Battle
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
alias rth_divide_exp_scbattle_main main
#--------------------------------------------------------------------------
def main
rth_divide_exp_scbattle_main
$game_party.clear_hit_count
end
#--------------------------------------------------------------------------
def start_phase5
@phase = 5
$game_system.me_play($game_system.battle_end_me)
$game_system.bgm_play($game_temp.map_bgm)
exp = 0
gold = 0
treasures = []
for enemy in $game_troop.enemies
unless enemy.hidden
exp += enemy.exp
gold += enemy.gold
if rand(100) < enemy.treasure_prob
if enemy.item_id > 0
treasures.push($data_items[enemy.item_id])
end
if enemy.weapon_id > 0
treasures.push($data_weapons[enemy.weapon_id])
end
if enemy.armor_id > 0
treasures.push($data_armors[enemy.armor_id])
end
end
end
end
treasures = treasures[0..5]
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
if actor.cant_get_exp? == false
last_level = actor.level
actor.exp += (actor.hit_count.to_f * exp.to_f / $game_party.total_hit_count.to_f).ceil
if actor.level > last_level
@status_window.level_up(i)
end
end
end
$game_party.gain_gold(gold)
for item in treasures
case item
when RPG::Item
$game_party.gain_item(item.id, 1)
when RPG::Weapon
$game_party.gain_weapon(item.id, 1)
when RPG::Armor
$game_party.gain_armor(item.id, 1)
end
end
@result_window = Window_BattleResult.new(exp, gold, treasures)
@phase5_wait_count = 100
end
#--------------------------------------------------------------------------
end