The Exp_Factor fix

Started by Jragyn, May 16, 2010, 01:52:57 am

Previous topic - Next topic

Jragyn

May 16, 2010, 01:52:57 am Last Edit: December 05, 2010, 05:15:41 am by Blizzard
So I'm not really sure if I should post this as a new script or not, so I'll just plop it up and if someone says it should be its own script, or pasted inside the current topic of "Satoh's Fluctuating Experience" then I will do that::

=begin

   The Exp_Factor
 
 

Author: Satoh
with massive support from Blizzard
Fixed: J & G_G

So the manner of which this script works, is that Experience-to-next-level
is fixed at 1000. Similer to the Dot.Hack games if you've ever played them.
The experience gained is factored against the difference in level between
you and the foe.

What?
You can't set the level of the enemies?
Well now you can!
All ya gotta do is put the desired level of the foe into the enemies' EXP field.
Seeing as XP-to-next is fixed, XP gained is also somewhat fixed. Therefor, the
EXP field of foes is now used for levels instead.

So fixed XP gain goes as one might guess:
The higher level of a monster you fight over yourself, the greater the XP you
gain. If you really like, you can edit these exact numbers a bit below, but I
suggest you don't bother unless you really know what your doing.


It seems this script was originally written by Mr. Satoh~san, however, when
Blizz-ABS took several steps further, this script did not.

So with G_G as my reference, I took it upon myself to repair its functionality.
Now, it seems to work.
Hurray!


--J


=end
 #--------------------------------------------------------------------------
 # * Start After Battle Phase
 #--------------------------------------------------------------------------
class Scene_Battle
 def start_phase5
   if $BlizzABS
     #nothing
   else
   # 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 EXP, amount of gold, and treasure
   exp = 0
   gold = 0
   treasures = []
   # Loop
   for enemy in $game_troop.enemies
     # If enemy is not hidden
     unless enemy.hidden
       # Add EXP and amount of gold obtained
       exp += enemy.exp
       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 EXP
       for i in 0...$game_party.actors.size
     actor = $game_party.actors[i]
     if actor.cant_get_exp? == false
       last_level = actor.level
       for enemy in $game_troop.enemies
         actor.exp += $BlizzABS.Processor.exp_factor(actor, enemy.exp)
       end
     end
   end
   # 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(exp, gold, treasures)
   # Set wait count
   @phase5_wait_count = 100
   end
   end

 #--------------------------------------------------------------------------
 # * Determine the EXP gained from foes.
 #     renamed method to "exp_factor"
 #     This entire method is merely the difference in level between you
 #     and the foe. The greater the difference, the greater the xp mod.
 #--------------------------------------------------------------------------
if $BlizzABS
class BlizzABS::Processor
 def exp_factor(actor, exp)
   lvl = exp - actor.level #compare the Enemy Level(EXP field)
                             #with the actor's current level
   sexp = 0
       case lvl
   when 10..100000 # The instance where enemies are 10+ levels higher than you.
     sexp = 520
   when 9
     sexp = 430
   when 8
     sexp = 350
   when 7
     sexp = 280
   when 6
     sexp = 220
   when 5
     sexp = 170
   when 4
     sexp = 130  # enemy levels are higher than yours.
   when 3
     sexp = 100  #^
   when 2        #|
     sexp = 80   #|
   when 1        #|
     sexp = 70
   when 0         # The instance where enemeis and yourself are the same level.
     sexp = 60
   when -1       #|
     sexp = 50   #|
   when -2       #|
     sexp = 40   #V
   when -3
     sexp = 28   #enemy levels are lower than yours.
   when -4
     sexp = 13
   when -5
     sexp = 8
   when -6
     sexp = 6
   when -7
     sexp = 4
   when -8
     sexp = 3
   when -9
     sexp = 2
   when -100000..-10 # The instance where you are 10+ levels higher than the foe.
     sexp = 1
   end
 return sexp
end
 #----------------------------------------------------------------------------
 # exp_result
 #  enemy - the killed enemy event
 #  Processes EXP gain after the death of an enemy.
 #----------------------------------------------------------------------------
 def exp_result(enemy)
     # get EXP
     exp = enemy.exp if enemy.exp != nil
       # All the stuff dealing with TONs
       if $tons_version != nil
         # if version is correct and using Different Difficulties
         if $tons_version >= 6.4 && TONS_OF_ADDONS::DIFFICULTY
           # multiply gained gold
           exp = exp * $game_system.exp_rate / 100
         end
         # if version is correct and using Passive Skills
         if $tons_version >= 6.5 && $game_system.PASSIVE_SKILLS
           # multiply gained gold with each actor's rate
           $game_party.actors.each {|actor| exp *= actor.exp_rate}
           exp = exp.to_i
         end
       end

     # iterate through all party members
     $game_party.actors.each {|actor|
         # increase EXP except if actor can't get EXP
         actor.exp += exp_factor(actor, exp) unless actor.cant_get_exp?}
   # return exp value for further processing
   return exp
 end#def
end#class
$BlizzABS = BlizzABS::Processor.new
end#if
 #--------------------------------------------------------------------------
 # * Calculate EXP
 #--------------------------------------------------------------------------
=begin

This is to prevent character not starting at Lvl 1 from having an EXP boost.

=end
class Game_Actor < Game_Battler
 def make_exp_list
   @exp_list[1] = 0
   for i in 2..100
     @exp_list[i] = 1000
   end
 end
 
 alias setup_satoh_expmod_aliased setup
 def setup(actor_id)
   setup_satoh_expmod_aliased(actor_id)
   @exp = 0
 end
 #--------------------------------------------------------------------------
 # * Change EXP
 #     exp : new EXP
 #--------------------------------------------------------------------------
=begin

Ok, this portion of the script rewrites the Level-up process. Now, anytime you
gain 1000 or more exp you gain a level. Then 1000 exp is subtracted from that
and any leftover exp is saved for your next level.
EXAMPLE:
Markus gains 1040 exp.
Markus levels up once and 1000 is subtracted.
Markus has 40 saved, and only needs 960 for his next level.

=end
 def exp=(exp)
   @exp = [[exp, 9999999].min, 0].max
   # Level up
   if @level <= ($data_actors[@actor_id].final_level - 1)
     while @exp >= 1000
       @level += 1 #unless @level >= $data_actors[@actor_id].final_level
       @exp -= 1000
       # Learn skill
       for j in $data_classes[@class_id].learnings
         if j.level == @level
         learn_skill(j.skill_id)
         end
       end
     end
   else
   @exp = 0
   end
 end
 #--------------------------------------------------------------------------
 # * Get EXP String
 #--------------------------------------------------------------------------
 def exp_s
   if @level != $data_actors[@actor_id].final_level
   return @exp_list[@level+1] > 0 ? @exp.to_s : "-------"
   else
   return "0"
   end
 end
 #--------------------------------------------------------------------------
 # * Get Next Level EXP String
 #--------------------------------------------------------------------------
 def next_exp_s
   if @level != $data_actors[@actor_id].final_level
   return @exp_list[@level+1] > 0 ? @exp_list[@level+1].to_s : "-------"
   else
   return "1000"
   end
 end
 #--------------------------------------------------------------------------
 # * Get Until Next Level EXP String
 #--------------------------------------------------------------------------
 def next_rest_exp_s
   if @level != $data_actors[@actor_id].final_level
   return @exp_list[@level+1] > 0 ?
     (@exp_list[@level+1] - @exp).to_s : "-------"
   else
   return "1000"
   end
 end
end

A bright light can either illuminate or blind, but how will you know which until you open your eyes?

Blizzard

So this is a version that works with newer versions of Blizz-ABS?
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G


Blizzard

Ok, I put it in the original thread.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.