Looking for a script that divides XP after battle between party members rather than giving each one the same amount regardless of party size.
[RMXP] XP from battle split evenly between party members so smaller parties gain more XP?
RGSS Script RequestsInside Scene_Battle 2, at definition of Scene_Battle#start_phase5, add this after the experience is collected from all defeated enemies (at default, this is right before "treasures = treasures[0..5]",
somewhat around line 160~170).
Or this if the party-size divider has to depend on how many battle-actors are still able to fight.
The place where to put the code may be different when additional battle-scripts were added.
~炬燵あ
somewhat around line 160~170).
Ruby:
exp /= $game_party.actors.size rescue 0
Or this if the party-size divider has to depend on how many battle-actors are still able to fight.
Ruby:
sn = 0
$game_party.actors.each {|sa| sn += 1 unless sa.cant_get_exp? }
exp /= sn rescue 0
The place where to put the code may be different when additional battle-scripts were added.
~炬燵あ
That worked perfectly, thank you!
Moved to: RGSS Script Requests
I know I'm getting kind of late here, but I wanted to offer @level2janitor another script that offers a lot more options for the customization at the end of the battle than the previous one.
Ruby:
# * BattleEnd XP * #
# Scripter : Kyonides Arkanthes
# 2023-06-16
# - Values for VAR_FULL_EXP Game Variable:
# 0 - EXP divided by Total Heroes
# 1 - EXP divided by Total Heroes * 2 (Punishment)
# 2 - Full EXP (Reward)
# - SWITCH_ALL_TREASURES Game Switch allows you to let the party get all of
# the treasures they have earned instead of just 5 of them.
module BattleEnd
VAR_FULL_EXP = 1
SWITCH_ALL_TREASURES = 1
end
class Scene_Battle
def start_phase5
@phase = 5
$game_system.me_play($game_system.battle_end_me)
$game_system.bgm_play($game_temp.map_bgm)
process_exp_gold_treasures
limit_treasures
distribute_treasures
distribute_exp_gold
end
def process_exp_gold_treasures
@exp = 0
@gold = 0
@treasures = []
for enemy in $game_troop.enemies
next if enemy.hidden
@exp += enemy.exp
@gold += enemy.gold
if rand(100) < enemy.treasure_prob
if enemy.item_id > 0
@treasures << $data_items[enemy.item_id]
elsif enemy.weapon_id > 0
@treasures << $data_weapons[enemy.weapon_id]
elsif enemy.armor_id > 0
@treasures << $data_armors[enemy.armor_id]
end
end
end
end
def limit_treasures
return if $game_variables[BattleEnd::SWITCH_ALL_TREASURES]
@treasures = @treasures[0..5]
end
def gain_treasure(item_id)
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
def distribute_treasures
@treasures.each {|treasure| gain_treasure(treasure.id) }
end
def distribute_exp(actor)
case $game_variables[BattleEnd::VAR_FULL_EXP]
when 0
@final_exp = @exp / $game_party.actors.size
actor.exp += @final_exp
when 1
@final_exp = @exp / $game_party.actors.size / 2
actor.exp += @final_exp
when 2
@final_exp = @exp
actor.exp += @exp
end
end
def distribute_exp_gold
$game_party.actors.each_with_index do |actor, i|
next if actor.cant_get_exp?
last_level = actor.level
distribute_exp(actor)
@status_window.level_up(i) if actor.level > last_level
end
$game_party.gain_gold(@gold)
@result_window = Window_BattleResult.new(@final_exp, @gold, @treasures)
@phase5_wait_count = 100
end
end
Original thread: https://forums.rpgmakerweb.com/threads/rmxp-xp-from-battle-split-evenly-between-party-members-so-smaller-parties-gain-more-xp.156526/