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

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

Previous topic - Next topic

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!