[XP] Level Difference Based Exp... Misc Add-on

Started by Satoh, October 23, 2008, 09:10:37 pm

Previous topic - Next topic

Satoh

October 23, 2008, 09:10:37 pm Last Edit: March 23, 2019, 11:35:05 am by Blizzard
Fluctuating Experience
Authors: Satoh, Blizzard
Version: 1.01
Type: Experience and Level-up system modification
Key Term: Misc Add-on



Introduction

This script mimics the .hack//Infection-Quarantine leveling system.



Features


  • Level up every 1000 EXP
  • EXP gain is determined by the difference in your level versus that of your enemy



Screenshots

I can't imagine a way to take a screenshot of EXP gaining... O.o


Demo

Basic Demo of a .hack game I'm making which utilizes my script
http://www.megaupload.com/?d=VS42HB7G



Script

Spoiler: ShowHide
  #==========================================================================
  #--------------------------------------------------------------------------
  # * Fluctuating Experience
  #--------------------------------------------------------------------------
  #   BlizzABS Compatible!!
  #==========================================================================

=begin

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
    # 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
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



Instructions

Instructions are in the script


Compatibility

Put it Between BlizzABS and Main somewhere.

Might not work with CBS's but is compatible with BlizzABS and Standard Battle System.


Credits and Thanks


  • Satoh
  • Boris "Blizzard" Mikić



Author's Notes

At this time, I have not found any current errors, and it should be fine...
If you find any errors, please document them here, and I will attempt to get them fixed.
Requesting Rule #1: BE SPECIFIC!!

Light a man a fire and he'll be warm for a night...
Light a man afire and he'll be warm for the rest of his life... ¬ ¬;

My Resources

Blizzard

Seems like you did something wrong. *points at script title* ^_^ Also, only one key term works. I suggest Misc Add-on since Misc System is for rather bigger and more complicated stuff. I'll move it into the database already. You will know that you did it right when it appears here properly. ^_^
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.

winkio

Good job on making this script.  I actually already implemented this concept into my game, but just in the enemies' events, since it uses blizz-abs.  nice work.

Blizzard

You should also put into "Compatibility" that this script goes BELOW Blizz-ABS if it is being used.
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.

Satoh

October 23, 2008, 09:27:29 pm #4 Last Edit: October 23, 2008, 09:31:42 pm by Satoh
Thanks for the compliment, but as I've said in the script, Blizzard deserves a hefty bit of the credit for the initial error solving...
Perhaps it'll help if you decide to expand your game some then.

I hope it serves anyone who uses it well... It's certainly fulfilling the task I needed it for.

EDIT: @ Blizzard, I thought I did that... perhaps I only mentioned it in the script.... I'll fix it...

EDIT2: ok... it looks like I got everything this time XD... checking one last time....
Requesting Rule #1: BE SPECIFIC!!

Light a man a fire and he'll be warm for a night...
Light a man afire and he'll be warm for the rest of his life... ¬ ¬;

My Resources

ozoke

this is a great script, just the kind of thing ive been looking for.

i was wondering that instead of comparing against the enemies exp, is it possible to setup a seperate database where the user can assign the enemy id a level and compare against that instead?

just wanted to know if that was possible so that instead of set amounts of xp the player gets a bonus on top of the normal xp they would get. eg you kill a lvl 20 mob, ur lvl 15 so u get base exp + bonus of 30.

thanks.

Satoh

I'm sure it's possible, I'll keep it in mind....

But it'll likely involve reworking a large part of the script... Maybe I'll do it as a separate script... (but don't get your hopes up too much, I'm still kinda new at scripting... I had a lot of help)
Requesting Rule #1: BE SPECIFIC!!

Light a man a fire and he'll be warm for a night...
Light a man afire and he'll be warm for the rest of his life... ¬ ¬;

My Resources

ozoke

np, i worked out how to get it to give you a bonus instead of just a set amount, but im new to the whole RMXP let alone RGSS, havent got a clue even how to start making an enemy level database. if i knew how to to do that then i would probably be able to do it.


Kagutsuchi

Could you please update it to be compatible with the newest version of blizz-abs?

Jragyn

So I looked at the script, and perhaps because I'm still rather n00b-esque when it comes to scripting, but I don't understand why this -doesn't- work with blizzABS?

This script in and of itself is pretty amazing, completely re-defines the leveling system AND gives the impression of levels for enemies. I was aiming to create something along these lines sometime soon myself, at least if anything I can use this for reference :D


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

Landith

Wow necropost...

Ok one thing, it says it's compatible with Blizz-ABS and unless Blizzard overwrote any of the methods above recently(use a ctrl/shift/F to search for the class) then it is still compatible. Make sure your scripts are in the right order.

Next time check the date of the last post and if it's a long time go ahead and make a new topic. (at least I think that's how it works :^_^':)

G_G

QuoteNext time check the date of the last post and if it's a long time go ahead and make a new topic. (at least I think that's how it works :^_^'

If it has to do with the topic in general like if you need help its okay. Dont necropost if you're only going to say nice script or good job. But he needed help and asked a simple question about it. So I think its fine xD

Jragyn

Aye, well, either way, even in a naked project with just blizzABS and the exp modifier script Satoh presents here, above or below the ABS, it will correctly modify the amount of XP to next level, but completely ignores the comparison of enemy.exp to actor.level, and thus ignores the idea of gaining varied exp by the "level" of the monster.

Anyone have any thought? I haven't seen Satoh been very active lately...
A bright light can either illuminate or blind, but how will you know which until you open your eyes?

Jragyn

Tadaa!
Fixed!

May everyone know and hopefully utilize it as needed. :D
(at least, I know it was working with the version of 2.6 blizzABS,
and so long as the exp_result doesn't change, this should stay functional.)
A bright light can either illuminate or blind, but how will you know which until you open your eyes?

Taiine

Sorry for the necropost. But as if the latest version of BABS, (2.80) it's again ignoring the comparison of enemy.exp to actor.level, and is just giving you the 'exp' as per normal.
Hoping someone can update this, as my game has been using this and having it broke is a bit of a set back. Either gong to an older BABS or taking this out fully and enjoying the fun of re-balancing -everythying- :D

Blizzard

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.

Taiine

Yes I did, that is where it has been this whole time. But as soon as I updated the battle system I noted I wasn't gaining levels as I normally did.. taking track of the exp gain.. mobs set at 2exp (a.k.a lv 2) were indeed.. just giving 2 exp.

I just recopied and pasted it in, thinking perhaps there was an update to this that I failed to notice, and now  I get a NameError.
Line 220
undefined method 'setup' for class: 'Scene_Battle::Game_Actor'

That being
  alias setup_satoh_expmod_aliased setup
under calculate.

also have to add an extra 'end' to the bottom or it throws out a syntax error for the very last end of the script.

Blizzard

"Scene_Battle::Game_Actor"? I don't think you copy-pasted the script properly.
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.

Taiine

Yeah I have. I even set up a fresh game, popped in the BABS and then this right below, even checked to be sure that yes, the whole script is c&ped right, and get the same error.
Spoiler: ShowHide
Script as a whole:


Adding an extra 'end' to the script.

Jragyn

October 04, 2010, 01:16:11 pm #19 Last Edit: October 04, 2010, 01:18:44 pm by jragyn00
It looks like it has something to do with 'end' placement.
I put an end after scene_battle, and it worked just dandy in my 2.8 BABS.

Try this:
#==========================================================================
 #--------------------------------------------------------------------------
 # * Fluctuating Experience
 #--------------------------------------------------------------------------
 #   BlizzABS Compatible!!
 #==========================================================================

=begin

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

PS_ If you want to edit the actual amounts of experience gained,
jump down to "XP::Setup" for the layout.

=end
 #--------------------------------------------------------------------------
 # * Start After Battle Phase
 #--------------------------------------------------------------------------
class Scene_Battle
 def start_phase5
   if !$BlizzABS
   # 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
end   # The new end that shoulda been there all along :P
 #--------------------------------------------------------------------------
 # * 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.
 #
 #    XP::Setup
 #
 #--------------------------------------------------------------------------
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


I probably never got that error because I editted my version of it and omitted that section entirely.
It doesn't seem to be necessary in regards to BABS.
A bright light can either illuminate or blind, but how will you know which until you open your eyes?

Taiine


Jragyn

Bwahaha, glad I could help,
and glad it wasn't more complicated than that X_X


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

Taiine

This may sound more like a "No DUHHHHHHH" post. But a friend/tester of the alpha to my game was wondering how with a system like this I am still able to have a good idea as to what level a player will be by the time they hit an area.

So I thought I'd post this cheat sheet for those who don't want to spend 2 minutes to do basic division   ;)
(This is with default settings)

    when 10+ levels above player = 1.9  kills to level
    when 9 levels above player = 2.3 kills to level
    when 8 levels above player = 2.8  kills to level
    when 7 levels above player = 3.5 kills to level
    when 6 levels above player = 4.5 kills to level
    when 5 levels above player = 5 kills to level
    when 4 levels above player = 7 kills to level
    when 3 levels above player = 10 kills to level
    when 2  levels above player = 12.5 kills to level
    when 1  level above player = 14 kills to level
when at same level   =  16 kills to level
    when -1  level below player = 20 kills to level
    when -2  levels below player = 25 kills to level
    when -3  levels below player = 35.7 kills to level
    when -4  levels below player = 76 kills to level
    when -5  levels below player = 125 kills to level
    when -6  levels below player = 166 kills to level
    when -7  levels below player = 250 kills to level
    when -8  levels below player = 333 kills to level
    when -9  levels below player = 500 kills to level
    when -10+  levels below player = 1000 kills to level


My only real issue with this script, is I wish if you set exp/level of a enemy to 0, it still granted no exp (or a fixed amount, like 1exp?). My critters in my game with player lv 1 are granting exp as though there one level below player xD

Jragyn

Hmm, doing only minimal testing, I produced this adjustment to the script:

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
    return 0 if exp == 0   #  <-----------------------------------   THE NEW LINE
   
        case lvl
    when 10..100000 # The instance where enemies are 10+ levels higher than you.
      sexp = 520
    when 9
      sexp = 430


It just returns 0 xp regardless of level as long as the enemy's experience is set to 0.
The number can be changed to 1 or whatever number you need it to be, but its zero for now.
Level 0 enemies give 0exp. :]

Hopefully there are no issues, its just 1 additional line.


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

Blizzard

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.

Jragyn

the sexp=0 bit that you put there is erm, what I slapped in the script when redoing the level difference part, cuz uhmm...when I was reading about programming in other languages, they said it was good to define a variable before you use it...? so I put sexp=0 to make sure it didn't pop an error...though I'm not certain what error could stem from it, I figured better safe than sorry.

the additional line I added just skips over the level difference portion and returns zero if the enemy.exp=0.

is there a better way to do it?


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

Blizzard

I was referring to the "sex" in "sexp" such as "sex points", not the code.
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.

Jragyn

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

Taiine

*snickersnort* I was about to point that out but blizz beat me to it. (that's what I get for being called away mid type)
ANYWAY that little added line seems to have done the trick.

Jragyn

Well good.
I'm glad.

I like this script and its concept, thus I try to fixxxxxxxxx what I can.
I also have a modified version that instead of using fixed XP gain and 1000toNext,
it multiplies experience gain based on level difference.
Same idea, different flavor.
Because I cannot figure out how to add an additional parameter of "level" to enemies though,
it uses the Gold slot for level instead and XP for...XP. >.<


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

Taiine

Okay, I just noticed an odd quirk with this... I thought it was something else causing this but it's been narrowed down to this script...

It plays havoc with EXP bar displays.

Like with the EXP bar in BABS, the bar when you first start, will fill normally, but once you level, it never empties, but remains full. The numbers and value change fine, but the bar it's self will just remain full.
Think it has to do with the exp reset to 0 each time you level, it tells the value to change, but not the bar.

candi.horror

Quote from: Taiine on October 04, 2010, 01:40:35 am
Yeah I have. I even set up a fresh game, popped in the BABS and then this right below, even checked to be sure that yes, the whole script is c&ped right, and get the same error.
Spoiler: ShowHide
Script as a whole:


Adding an extra 'end' to the script.



I'm getting these same errors, even if this script is the only one I add. The script Jragyn posted throws an error with the default battle system, as their script appears to have been edited for use with BABS.I'm a total n00b when it comes to scripting so I'm unsure what to look at to fix this issue @_@

KK20

It was a missing 'end'. I fixed it in the first post.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Apathy Man

November 01, 2012, 04:39:26 pm #33 Last Edit: November 01, 2012, 04:41:08 pm by Apathy Man
Switched back from using RM-VXA to RMXP to use this script, as nothing like it exists for VX/VXA. Unfortunately, it does not seem to work when using vanilla RMXP with no BABS or anything.

Since I'm not savvy with the coding aspect of things, could someone help direct me how to fix it? The error message I'm getting is at Line 89, pointing to an invalid method that has to do with the Blizz mod. I will not be using BABS and nor do I have it installed. The whole concept of the game I am working on completely revolves around the experience/leveling scheme detailed originally with this script.

Any help would be appreciated greatly. Thanks!

KK20


Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Apathy Man

Gave it a spin and deleted the line you suggested. Battle went through to the end then another error on the same line 89.

undefined methoed 'exp_factor' for nil:NilClass

KK20

mmmm...Yeah, this script needs some help. I'll look into revising it.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Apathy Man

lol alrighty. Thanks so much for looking into it!

KK20

Spoiler: ShowHide
#==========================================================================
#--------------------------------------------------------------------------
# * Fluctuating Experience
#--------------------------------------------------------------------------
#   BlizzABS Compatible!!
#==========================================================================

=begin

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
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Gets how much EXP should be given based on player's and enemy's levels
  #--------------------------------------------------------------------------
  def exp_factor(exp)
lvl = exp - @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
  #--------------------------------------------------------------------------
  # * Makes an exp list that goes by 1000's
  #--------------------------------------------------------------------------
  def make_exp_list
@exp_list[1] = 0
for i in 2..100
@exp_list[i] = 1000 * (i-1)
end
end
  #--------------------------------------------------------------------------
  # * Get EXP String
  #--------------------------------------------------------------------------
  def exp_s
    return @exp_list[@level+1] > 0 ? (@exp%1000).to_s : "-------"
  end
  #--------------------------------------------------------------------------
  # * Get Next Level EXP String
  #--------------------------------------------------------------------------
  def next_exp_s
    return @exp_list[@level+1] > 0 ? "1000" : "-------"
  end
  #--------------------------------------------------------------------------
  # * Get Until Next Level EXP String
  #--------------------------------------------------------------------------
  def next_rest_exp_s
    return @exp_list[@level+1] > 0 ? (@exp_list[@level+1] - @exp).to_s : "-------"
  end
  #--------------------------------------------------------------------------
  # * Change EXP
  #     exp : new EXP
  #--------------------------------------------------------------------------
  def exp=(exp)
    @exp = [[exp, 9999999].min, 0].max
    # Level up
    while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
      @level += 1
      # Learn skill
      for j in $data_classes[@class_id].learnings
        if j.level == @level
          learn_skill(j.skill_id)
        end
      end
    end
    # Level down
    while @exp < @exp_list[@level]
      @level -= 1
    end
    # Correction if exceeding current max HP and max SP
    @hp = [@hp, self.maxhp].min
    @sp = [@sp, self.maxsp].min
  end
  #--------------------------------------------------------------------------
  # * Alias the EXP set method to call upon 'exp_factor'
  #--------------------------------------------------------------------------
  alias call_orig_exp_set exp=
  def exp=(exp)
    if $game_temp.enemy_levels != []
      new_exp = 0
      $game_temp.enemy_levels.each{|lvl|
        new_exp += exp_factor(lvl)
      }
      call_orig_exp_set(@exp + new_exp)
    else
      call_orig_exp_set(exp)
    end
  end
end

class Game_Temp
  attr_accessor :enemy_levels
  alias init_enemy_levels initialize
  def initialize
    init_enemy_levels
    @enemy_levels = []
  end
end

class Game_System
  alias reupdate_after_reseting update
  def update
    $game_temp.enemy_levels = []
    reupdate_after_reseting
  end
end

if !$BlizzABS
class Game_Enemy < Game_Battler
  alias get_exp_really exp
  def exp
    $game_temp.enemy_levels.push($data_enemies[@enemy_id].exp)
    return get_exp_really
  end
end
end

if $BlizzABS
module BlizzABS
  class Processor
    #--------------------------------------------------------------------------
    # exp_result
    #  enemy - the killed enemy event
    #  Processes EXP gain after the death of an enemy.
    #--------------------------------------------------------------------------
    def exp_result(enemy)
      # stop if enemy gives no EXP
      return 0 if enemy.exp == 0
      # get EXP
      exp = enemy.exp
      $game_temp.enemy_levels.push(exp)
      # if Tons is there
      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
        exp = 1 if exp < 1
      end
      # bonus exp if bonus or unshared and last attacked battler exists
      if Config::EXP_MODE > 0 && enemy.last_hit_by != nil
        bat = enemy.last_hit_by
        bat.exp += exp if !bat.cant_get_exp?
      end
      # shared exp if bonus or shared, but exp is split evenly among party
      if Config::EXP_MODE < 2
        ind_exp = exp - 5
        # iterate through all actors and pets
        ($BlizzABS.actors + $BlizzABS.pets).each {|b|
            # increase EXP if actor is valid and actor can get EXP
            b.battler.exp += ind_exp if b.valid? && !b.battler.cant_get_exp?}
      end
      # return exp value for further processing
      $game_temp.enemy_levels = []
      return exp
    end
  end
end
$BlizzABS = BlizzABS::Processor.new
end
Alright, this is pretty much a quick, editted version of the original. There's still a lot of things that I don't agree with to call this my "own" script (for example, the Battle Results window will display wrong EXP amounts nor is it compatible with a number of scripts). But I'm pretty sure this should work in a new project.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Apathy Man

Great job, KK. Tested it with a variety of different actor levels and the script is devoid of errors. The one thing that I did find is that it seems to be taking the enemy level and doubling the experience output from what it should have been (ie. actors that should have gotten 70 are getting 140, 50 are getting 100). Other than that it looks to be solid. I don't know what I'll be able to do about the wrong experience message part, but you've done enough for helping me to resolve this script. Thanks a bunch!

KK20

It's getting it twice? Weird, it's not doing that for me. You're not using other scripts, right?

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Apathy Man

November 02, 2012, 12:40:39 pm #41 Last Edit: November 02, 2012, 01:01:04 pm by Apathy Man
None at all. Testing it on a test project which is completely vanilla with the exception of this script. I could simply work around it by modifying the variables for each level difference by half in the script, but felt it best to point it out at least.

I guess without having to correct the experience message after battle, would you or anyone else happen to know a bit of code to stop the message from being shown altogether? Or is there an easier means to fix it?

KK20

Did a new project with just my code snippet. It's giving the correct amount--it's not doing the process twice. If I kill two ghosts, which give 2 exp each (thus, they are Level 2), a level 1 character gets 140 EXP, level 2 gets 120 EXP, and so on. What are the exact steps you are doing?

For the results window, if you want just a Victory message displayed:
Spoiler: ShowHide
class Window_BattleResult < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     exp       : EXP
  #     gold      : amount of gold
  #     treasures : treasures
  #--------------------------------------------------------------------------
  def initialize(exp, gold, treasures)
    @exp = exp
    @gold = gold
    @treasures = treasures
    super(160, 0, 320, @treasures.size * 32 + 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.y = 160 - height / 2
    self.back_opacity = 160
    self.visible = false
    self.contents.draw_text(0, 0, self.contents.width, 32, "VICTORY!", 1)
  end
end

Or if you want to remove it entirely:
Spoiler: ShowHide
class Window_BattleResult < Window_Base
  def visible=(bool)
    super(false)
  end
end
Place either one in my edit all the way at the bottom of the script itself.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Apathy Man

Sorry for the misunderstanding KK. Performed by tests in the same manner, and your results are the same as mine. However, from looking at the code, my assumption was that anything of equal level was to be 60 exp, one level above, 70, etc. My eyes may be deceiving me though. You're obviously far better with coding than I am.

KK20

Well your assumption is correct: according to the code, if you are the same level as the monster, you earn 60 EXP.
So if I'm level 2, and fight two ghosts which are level 2, then that's 120 EXP (60 EXP for each ghost).

This was more of a mathematical problem than programming, but glad to see it's working  ;)

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Apathy Man

 :shy: My fail. Completely overlooked the fact there were two mobs factoring into it. Ugh, embarassing. Thanks so much!