Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[XP] Script to alter EXP Curve of Actor

So if you want to alter the Exp curve of an Actor mid-game, obviously you'd have to write a statement using exp_basis and exp_inflation, but I can't figure out two things: (1) What those statements would be and (2) Would it actually work? My plan is to do it at the start of the game, before any XP can be gained, through choices the player makes, but still. Is dynamic assignment of the EXP Curve possible in XP?
 

Atoa

Member

@MayorAnime
It shouldn't be hard, you can create an public instance variable for Game_Actor class and add it to the make_exp_list method.

The actor.exp_basis and actor.exp_inflation is the values set on the database when you set actor exp growth.
The exp_basis is the first value that, sets the initial exp.
The exp_inflation is the second value, that sets the growth

something like this shoud do the trick:
Code:
#==============================================================================

# ** Game_Actor

#------------------------------------------------------------------------------

#  This class handles the actor. It's used within the Game_Actors class

#  ($game_actors) and refers to the Game_Party class ($game_party).

#==============================================================================

 

class Game_Actor < Game_Battler

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_accessor   :exp_growth

  #--------------------------------------------------------------------------

  # * Setup

  #     actor_id : actor ID

  #--------------------------------------------------------------------------

  alias exp_change_steup setup

  def setup(actor_id)

    exp_change_steup(actor_id)

    @exp_growth = 0

  end

  #--------------------------------------------------------------------------

  # * Calculate EXP

  #--------------------------------------------------------------------------

  def make_exp_list

    actor = $data_actors[@actor_id]

    @exp_list[1] = 0

    pow_i = 2.4 + (actor.exp_inflation + exp_growth) / 100.0

    for i in 2..100

      if i > actor.final_level

        @exp_list[i] = 0

      else

        n = actor.exp_basis * ((i + 3) ** pow_i) / (5 ** pow_i)

        @exp_list[i] = @exp_list[i-1] + Integer(n)

      end

    end

  end

end
then you can call $game_actors[ID].exp_growth = X
 
Thanks Atoa!

But this will really do the trick? Such as turn a curve from Basis 25/Inflation 35 to Basis 10/Inflation 50? I guess I'm not following how the numbers would be entered.

I'll noodle with it some, though!
 

Atoa

Member

@MayorAnime
Yes it will, you just need to set one instance variable for each value, and make the changes via script call.

The example i posted just change the inflation, but i think you know how to add the change for basis too.
 
Okay, I've been fighting with this for almost a day now, I can't seem to get it to work. My knowledge of functions aren't good enough, and when I try and implement it, I either get a syntax error (meaning I'm not doing something correctly) or the EXP curve doesn't change (verified by going into Status to see the NEXT value change).

In this case, can someone write the code, or modify Atoa's code, and then tell me what's happening? I'd like to understand what I'm doing wrong. Here is what I changed Atoa's code to:

Code:
 

  def make_exp_list

    actor = $data_actors[@actor_id]

    @exp_list[1] = 0

    pow_i = 2.4 + (actor.exp_inflation + exp_growth2) / 100.0

    for i in 2..100

      if i > actor.final_level

        @exp_list[i] = 0

      else

        n = (actor.exp_basis + exp_growth1)  * ((i + 3) ** pow_i) / (5 ** pow_i)

        @exp_list[i] = @exp_list[i-1] + Integer(n)

      end

    end

  end

 

Both exp_growth1 and 2 are declared at the start of the module. I don't want things to modify the basis and inflation values, I want to replace them. So if a character has Basis 25/Inflation 35 in the database, I want to change it, via script call, to Basis 10/Inflation 50. For example.

Thanks in advance!
 
make a 2nd copy of the method, and replace the inflation & basis variables with your own.
Here's how you would do it to pass the variables when you call the method

Code:
  #--------------------------------------------------------------------------

  # * Calculate EXP

  #--------------------------------------------------------------------------

  def make_new_exp_list(my_basis, my_inflation)

    actor = $data_actors[@actor_id]

    @exp_list[1] = 0

    pow_i = 2.4 + my_inflation / 100.0

    for i in 2..100

      if i > actor.final_level

        @exp_list[i] = 0

      else

        n = my_basis * ((i + 3) ** pow_i) / (5 ** pow_i)

        @exp_list[i] = @exp_list[i-1] + Integer(n)

      end

    end

  end

 

then call it with make_new_exp_list(10, 50)
 

Atoa

Member

@MayorAnime
I forget to tell one thing:
You mus call $game_actors[ID].make_exp_list to effectively change the exp list, because it's only called during the def setup(actor_id)
 
I hate to necro this, but I'm having an issue with building a custom EXP curve as well. However, I don't want to change the actors' inflation or basis. I'm simply looking to change the base formula. I replaced the "2.4" with a "1.1", because this is the calculation I want and creates the proper curve, but it has no effect in game:
Code:
  #--------------------------------------------------------------------------

  # * Calculate EXP

  #--------------------------------------------------------------------------

  def make_exp_list

    actor = $data_actors[@actor_id]

    @exp_list[1] = 0

    pow_i = 1.1 + actor.exp_inflation / 100.0

    for i in 2..100

      if i > actor.final_level

        @exp_list[i] = 0

      else

        n = actor.exp_basis * ((i + 3) ** pow_i) / (5 ** pow_i)

        @exp_list[i] = @exp_list[i-1] + Integer(n)

      end

    end

  end
Why does this not change the base experience tables? When I start up the game, it still has the default calculations (as if 2.4 were still there). I even tried to call $game_actors[ID].make_exp_list to try and generate a new list, but it didn't do anything. Please help, as this is frustrating me incredibly... :mad:

EDIT: Never mind, I figured it out. Another :facepalm: moment for me...as Brew told me: "This is how we learn." Sorry for the necro!
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top