06-28-2006, 01:00 PM
Obtain Experience as You Battle
Tsunokiette
Jun 28 2006
Every face an opponent so unreasonably hard, that you end up running away? Ever think of how unrealistic it is that you did all that hard work and got no reward?
This allows you to obtain experience as you battle, realisticly, so that people who don't do damage wont get experience, and you don't have to run away without gaining any experience at all.
Only works with default Battle System, but can be easily edited to work with any battle system.
Just place this above main -
Sorry for the large ammount of code, this just makes it easier than explaining all the little edits that have to be made and answering one billion questions.
The offset to this system, is that you obtain exp more realisticly. IE: those who do more damage get more exp, and you end up getting less exp overall, because more than one charcter is doing damage to the monster. To give more exp, simply give the monsters higher exp rates.
EDIT: Forgot to include, but easy enough to do, go into Window_BattleResult, and in the initialization, remove the "exp," from the arguments, and @exp = exp needs to be removed as well.
Tsunokiette
Jun 28 2006
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
No support is given. If you are the owner of the thread, please contact administration.
Every face an opponent so unreasonably hard, that you end up running away? Ever think of how unrealistic it is that you did all that hard work and got no reward?
This allows you to obtain experience as you battle, realisticly, so that people who don't do damage wont get experience, and you don't have to run away without gaining any experience at all.
Only works with default Battle System, but can be easily edited to work with any battle system.
Just place this above main -
Code
Code:
class Scene_Battle
attr_accessor :exp_per_hit
attr_accessor :monsters
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
@exp_per_hit = []
@monsters = []
# Initialize each kind of temporary battle data
$game_temp.in_battle = true
$game_temp.battle_turn = 0
$game_temp.battle_event_flags.clear
$game_temp.battle_abort = false
$game_temp.battle_main_phase = false
$game_temp.battleback_name = $game_map.battleback_name
$game_temp.forcing_battler = nil
# Initialize battle event interpreter
$game_system.battle_interpreter.setup(nil, 0)
# Prepare troop
@troop_id = $game_temp.battle_troop_id
$game_troop.setup(@troop_id)
i = 0
for enemy in $game_troop.enemies
@exp_per_hit[i] = ((enemy.exp * 1.0) / enemy.hp)
@monsters[i] = enemy
i += 1
end
# Make actor command window
s1 = $data_system.words.attack
s2 = $data_system.words.skill
s3 = $data_system.words.guard
s4 = $data_system.words.item
@actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
@actor_command_window.y = 160
@actor_command_window.back_opacity = 160
@actor_command_window.active = false
@actor_command_window.visible = false
# Make other windows
@party_command_window = Window_PartyCommand.new
@help_window = Window_Help.new
@help_window.back_opacity = 160
@help_window.visible = false
@status_window = Window_BattleStatus.new
@message_window = Window_Message.new
# Make sprite set
@spriteset = Spriteset_Battle.new
# Initialize wait count
@wait_count = 0
# Execute transition
if $data_system.battle_transition == ""
Graphics.transition(20)
else
Graphics.transition(40, "Graphics/Transitions/" +
$data_system.battle_transition)
end
# Start pre-battle phase
start_phase1
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Refresh map
$game_map.refresh
# Prepare for transition
Graphics.freeze
# Dispose of windows
@actor_command_window.dispose
@party_command_window.dispose
@help_window.dispose
@status_window.dispose
@message_window.dispose
if @skill_window != nil
@skill_window.dispose
end
if @item_window != nil
@item_window.dispose
end
if @result_window != nil
@result_window.dispose
end
# Dispose of sprite set
@spriteset.dispose
# If switching to title screen
if $scene.is_a?(Scene_Title)
# Fade out screen
Graphics.transition
Graphics.freeze
end
# If switching from battle test to any screen other than game over screen
if $BTEST and not $scene.is_a?(Scene_Gameover)
$scene = nil
end
end
#--------------------------------------------------------------------------
# * Start After Battle Phase
#--------------------------------------------------------------------------
def start_phase5
# Shift to phase 5
@phase = 5
# Play battle end ME
$game_system.me_play($game_system.battle_end_me)
# Return to BGM before battle started
$game_system.bgm_play($game_temp.map_bgm)
# Initialize Amount of gold, and treasure
gold = 0
treasures = []
# Loop
for enemy in $game_troop.enemies
# If enemy is not hidden
unless enemy.hidden
# Add Amount of gold obtained
gold += enemy.gold
# Determine if treasure appears
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
# Treasure is limited to a maximum of 6 items
treasures = treasures[0..5]
# Obtaining gold
$game_party.gain_gold(gold)
# Obtaining treasure
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
# Make battle result window
@result_window = Window_BattleResult.new(gold, treasures)
# Set wait count
@phase5_wait_count = 100
end
#--------------------------------------------------------------------------
# * Go to Command Input for Next Actor
#--------------------------------------------------------------------------
def phase3_next_actor
# Loop
begin
# Actor blink effect OFF
if @active_battler != nil
@active_battler.blink = false
end
# If last actor
if @actor_index == $game_party.actors.size-1
# Start main phase
start_phase4
return
end
# Advance actor index
@actor_index += 1
if @status_window.level_up_flag[@actor_index] == true
@status_window.level_up_flag[@actor_index] = false
end
@active_battler = $game_party.actors[@actor_index]
@active_battler.blink = true
# Once more if actor refuses command input
end until @active_battler.inputable?
# Set up actor command window
phase3_setup_command_window
end
#--------------------------------------------------------------------------
# * Go to Command Input of Previous Actor
#--------------------------------------------------------------------------
def phase3_prior_actor
# Loop
begin
# Actor blink effect OFF
if @active_battler != nil
@active_battler.blink = false
end
# If first actor
if @actor_index == 0
# Start party command phase
start_phase2
return
end
# Return to actor index
@actor_index -= 1
if @status_window.level_up_flag[@actor_index] == true
@status_window.level_up_flag[@actor_index] = false
end
@active_battler = $game_party.actors[@actor_index]
@active_battler.blink = true
# Once more if actor refuses command input
end until @active_battler.inputable?
# Set up actor command window
phase3_setup_command_window
end
#--------------------------------------------------------------------------
# * Frame Update (main phase step 5 : damage display)
#--------------------------------------------------------------------------
def update_phase4_step5
# Hide help window
@help_window.visible = false
# Refresh status window
@status_window.refresh
# Display damage
for target in @target_battlers
if target.damage != nil
# Obtain EXP
for i in 0..(@monsters.size - 1)
if @monsters[i] == target
if @active_battler.cant_get_exp? == false
last_level = @active_battler.level
@active_battler.exp += (@exp_per_hit[i] * target.damage)
if @active_battler.level > last_level
@status_window.level_up(@active_battler.id - 1)
end
end
end
end
target.damage_pop = true
end
end
# Shift to step 6
@phase4_step = 6
end
end
class Window_Base < Window
#--------------------------------------------------------------------------
# * Draw EXP
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
#--------------------------------------------------------------------------
def draw_actor_exp(actor, x, y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 24, 32, "E")
self.contents.font.color = normal_color
self.contents.draw_text(x + 24, y, 84, 32, "#{actor.exp.round}", 2)
self.contents.draw_text(x + 108, y, 12, 32, "/", 1)
self.contents.draw_text(x + 120, y, 84, 32, actor.next_exp_s)
end
end
class Window_BattleStatus < Window_Base
def level_up_flag
return @level_up_flags
end
end
Sorry for the large ammount of code, this just makes it easier than explaining all the little edits that have to be made and answering one billion questions.
The offset to this system, is that you obtain exp more realisticly. IE: those who do more damage get more exp, and you end up getting less exp overall, because more than one charcter is doing damage to the monster. To give more exp, simply give the monsters higher exp rates.
Minor Bug
Code:
Since the exp value is rounded to the closest number so as to remove the decimal values, it is possible to have exp shown as 26/26 and not level up yet. I have been told a way to round down the value so it shows correctly, but I havn't been able to test it yet.
EDIT: Forgot to include, but easy enough to do, go into Window_BattleResult, and in the initialization, remove the "exp," from the arguments, and @exp = exp needs to be removed as well.