Default experience calculation in RPGM VXA...

Regda

Villager
Member
Joined
Jul 30, 2022
Messages
5
Reaction score
1
First Language
German
Primarily Uses
Other
Hi,

i am searching for a way to modify the exp curves (in my case the curves are defined using the default formular) dynamically ingame, so e.g. i want to be able to move the curve vertically by using a game_variable.
rpgmakervxace_expcurve.png

i also read the following to find out that the inbuilt method which contains the exp curve calculation is encapsulated in Game_Actors class which can be found in the Script Editor: https://forums.rpgmakerweb.com/index.php?threads/himes-custom-exp-curves.80340/post-748097
but for some reason if i modify Game_Actor.exp_for_level(level) the game crashes on some random point later, so what i did was adding a game_variable (containing a number) to the result of self.class.exp_for_level(level).
no_round_for_complex_crash.png

How can i actually modify the inbuilt methods ?rpg_class_exp_for_level.png
i only wanna alter the curve by adding an integer from an game_variable to it.

EDIT:
i found out why it crashes, see answers below.
 
Last edited:

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
16,700
Reaction score
9,252
First Language
English
Primarily Uses
RMMV
@Regda Hi and welcome. I've split your question into it's own post. We prefer members start a new thread for their own questions, particularly in old threads. If any relevant information has been left out, please go back and edit your original post to include that. Thanks.
 

AkiraKotatsuhime

炬燵姫
Veteran
Joined
Jan 2, 2013
Messages
227
Reaction score
162
First Language
DE / ドイツ語
Primarily Uses
N/A
Don't know what you've exactly changed from the default or where and how you at least plan to implement the variable to take effect inside it, so it's not that easy to help you with the formula.

But according to the error some part is (I assume accidentally) generating "0.0i" which is not a regular number, so the interpreter creates an object-instance of Complex-class there (still based on Numeric which is needed as parent class to use #round in a calculation, though Complex doesn't support it).

~炬燵あ
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
37,033
Reaction score
10,029
First Language
German
Primarily Uses
RMMV
or in other words, most likely you have a type in your modified formula, and we need to see what you tried to enter there instead of the original default values.
 

Regda

Villager
Member
Joined
Jul 30, 2022
Messages
5
Reaction score
1
First Language
German
Primarily Uses
Other
the modified formular was the following:
Ruby:
# $game_variables[127] = 22
# class Game_Actor
def exp_for_level(level)
  self.class.exp_for_level(level) + $game_variables[127]
end

the game actually crashed because at the end 0 (or smaller) has been passed to Change EXP (increase), so i solved the crash by just not calling it if the argument is 0 or below.

My main question is still there, how can i overwrite the inbuilt method exp_for_level of this RPG::Class class?
(Ofc. i could change the Game_Actor.exp_for_level(level) method but then i have to make sure that everywhere else the exp_for_level of Game_Actor is used instead of the inbuilt exp_for_level)
 
Last edited:

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,092
Reaction score
4,720
First Language
English
Primarily Uses
RMMZ
the modified formular was the following:
Ruby:
# $game_variables[127] = 22
# class Game_Actor
def exp_for_level(level)
  self.class.exp_for_level(level) + $game_variables[127]
end

the game actually crashed because at the end 0 (or smaller) has been passed to Change EXP (increase), so i solved the crash by just not calling it if the argument is 0 or below.

My main question is still there, how can i overwrite the inbuilt method exp_for_level of this RPG::Class class?
(Ofc. i could change the Game_Actor.exp_for_level(level) method but then i have to make sure that everywhere else the exp_for_level of Game_Actor is used instead of the inbuilt exp_for_level)
JavaScript:
class RPG::Class < RPG::BaseItem
  alias :tlb_exp_for_level :exp_for_level
  def exp_for_level(level)
    return tlb_exp_for_level(level) + $game_variables[127]
  end
end
 

Regda

Villager
Member
Joined
Jul 30, 2022
Messages
5
Reaction score
1
First Language
German
Primarily Uses
Other
i assume i have to put this code at the very top of the script editor ? (just to go sure)

This time the game crashes at Change EXP (increase) if the value passed to it is less then $game_variables[127].

So e.g. if i hardcode the variable to 20:
Ruby:
class RPG::Class < RPG::BaseItem
  alias :tlb_exp_for_level :exp_for_level
  def exp_for_level(level)
    return tlb_exp_for_level(level) + 20
  end
end
The first time Change EXP (increase) is called with a value lower then 20 it crashes:
changeexp.png
(i also unticked "Show Level Up Message" to get sure it's not because of printing something)

EDIT:
ok, on an clean project it seems like to work... looks like the problem lies on my side (or better in one of all these scripts im using... ). :kaoswt2:
What bothers me atm is that on the clean project it shows "Current Exp: 20; To Next Level: 90", where on my actual project it shows "Current Exp: 0; To Next Level: 110"...
so based on the code above i was expecting the result on my actual project, maybe i still missunderstand how exp is calculated.
(the affected hero uses [50, 40, 50, 50] as Exp Curve so Lvl 1 should start with 90exp to Lvl 2)
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
37,033
Reaction score
10,029
First Language
German
Primarily Uses
RMMV
i assume i have to put this code at the very top of the script editor ? (just to go sure)
no, usually all scripts should be added to the materials section of the script editor.
there are very few exceptions to that rule.
 

Another Fen

Veteran
Veteran
Joined
Jan 23, 2013
Messages
658
Reaction score
368
First Language
German
Primarily Uses
Not sure if this is the issue, but the method determines the breakpoint for total exp needed to reach a certain level, not the increase from one level to the next.
You can get a complex result if you take a negative number to the power of a non-integer (often taking the square root).
 
Last edited:

Regda

Villager
Member
Joined
Jul 30, 2022
Messages
5
Reaction score
1
First Language
German
Primarily Uses
Other
no, usually all scripts should be added to the materials section of the script editor.
there are very few exceptions to that rule.
Ok, i moved the Code to the bottom of the materials section.

Not sure if this is the issue, but the method determines the breakpoint for total exp needed to reach a certain level, not the increase from one level to the next.
You mean exp_for_level? Hm then i missunderstood the method (see spoiler below), the only thing that comes to my mind atm is multiplying it with the actual level befor adding.
As i undstood it, the idea is to have a pool of exp which then is divided into 100 Levels where the divisions are defined by the exp curve... so i was thinking i could just add something on top of the results from exp_for_level to move the curve upwards (which would be always e.g. 20 more whatever level is given) :|

I tested it again with my actual Project but this time with a new savegame, could it be that savegames interfere with it if so how do i update the loaded values?
With an old save i get "Current Exp: 0; To Next Level: 110" and the game crashes if the exp is below the value that has been added to exp_for_level.
With an new save i get "Current Exp: 20; To Next Level: 90" and the game doesn't crash.
(im not sure yet if this behavior comes from an script or not)
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
4,385
Reaction score
1,214
First Language
English
Primarily Uses
RMVXA
I tested it again with my actual Project but this time with a new savegame, could it be that savegames interfere with it if so how do i update the loaded values?
With an old save i get "Current Exp: 0; To Next Level: 110" and the game crashes if the exp is below the value that has been added to exp_for_level.
With an new save i get "Current Exp: 20; To Next Level: 90" and the game doesn't crash.
(im not sure yet if this behavior comes from an script or not)
100%
Any data that is saved in the save game (actor data and more) will cause problems when you change code that reads and uses the save game data.
 

Regda

Villager
Member
Joined
Jul 30, 2022
Messages
5
Reaction score
1
First Language
German
Primarily Uses
Other
I can only repeat my question. :LZSsad:
If an Savegame is loaded, which data (exactly) do i have to adjust?
(so how do i find out what is affected from changing exp_for_level so that i can write update routines for it? )
 

Another Fen

Veteran
Veteran
Joined
Jan 23, 2013
Messages
658
Reaction score
368
First Language
German
Primarily Uses
The savestate saves both the actors level and exp separately. If both are no longer consistent, you'd have to make a choice:

If you want to keep an actors level intact, you could use something like
actor.change_exp(actor.current_level_exp) if actor.exp < actor.current_level_exp
actor.change_exp(actor.next_level_exp - 1) if actor.exp >= actor.next_level_exp
to update their exp to match it.

If you want to keep the exp intact, you could use
actor.change_exp(actor.exp)
to update their level.

That said, your error seems to originate from the fact that the original exp formula was not designed to work for levels below 1 (and you only reach level 1 at 20 exp right now).
 
Last edited:

Latest Threads

Latest Profile Posts

Sometimes I wonder why I still try and recruit others to help with my games. It never works.
ScreenShot_10_3_2022_4_27_17.png
welp, thanks to Luna MV, I was able to add the Balloon as a window... thus allowing me to edit the font color and outline... so now it looks like comic bubbles above characters. I have NO idea why I couldn't get this to work through more conventional means, but here we are.
CUTE CUTE CUTE.gif
I cannot cease doing cute art
War and Wonder is a 100% choice-based open-world visual novel.
1664821313732.png
1664821466359.png
1664821547746.png
Going live soon on Twitch, and will continue Fortunastreet's game "Verloren". For those who are curious, you are welcome to join ;)

-> Franz' Twitch channel

Forum statistics

Threads
125,749
Messages
1,173,222
Members
164,911
Latest member
KyzerKiba
Top