Extra EXP based on levels

Status
Not open for further replies.

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Obviously I can use the Sp.Param EXR as a Feature on an accessory, but that gives the same amount of additional exp to all characters when they equip it.

What I would like to do is have the additional exp calculated according to the actor's level and ideally have that slightly random.  I can play around with the exact numbers to get what I want, but it would be something like this for each actor.



However, I cannot see how to apply this at the end of each battle.  I can't use a troop event as far as I know, because I don't see a 'Battle End' option.

Can anyone advise me on how to go about this?

Thanks.
 

Oddball

Veteran
Veteran
Joined
Sep 4, 2014
Messages
1,923
Reaction score
534
First Language
English
Primarily Uses
N/A
I just used Vlue's stat script that adds extra effects to stats and tacted EXR onto MDF.

I know, different actors will have different EXR, but it fits, sense magical defense has been associated with processing speed and such. I assumed that it represented the ability to learn from experince
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@warpmind

With the good fortune that is such a constant feature of my life, Yanfly's script says 

"This script does not provide any default stat bonuses that alter EXR"

I personally am not sufficiently competent to tweak things around the way you suggest, nor can I see how to apply it to an accessory.  Could you describe your idea in a bit more detail?

@Oddball

That's an interesting possibility.  What holds me back from going quickly down that route is that my characters have significantly different MDF, plus there is no obvious logical reason why having a high defense against magic should mean that you learn more (gain more experience) from an enemy which uses physical attacks.  Also I may be mis-remembering that script, but I don't think it applies to armor, though I haven't checked yet.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
@warpmind

With the good fortune that is such a constant feature of my life, Yanfly's script says 

"This script does not provide any default stat bonuses that alter EXR"
What Yanfly means it is not there by default, but if you go to line 187 (in my copy), there is a line for :exr_formula. Edit that line to make it change how EXP is done.

However, I have no idea how to make it only apply when a certain item is equipped. Maybe make the item apply a passive state (via Yanfly's passive state script), then have the script check to see if that state is applied, use the new formula? That should work if done like this:

if state?(100) :exr_formula => "your formula here", else :exr_formula => "base_exr",endReplace 100 with the passive state that you assign to the item.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@bgillisp

Yes, I can see how the passive state thing might work.

Unfortunately you are crediting me with far more scripting knowledge than I possess (think 5 year old).  How would that line be edited?  In the copy on the GitHub site, line #187 is where yanfly starts his standard "editing anything past this point", so I'm not even sure I know which line you are referring to.  Maybe line 178?
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Its the line that says :exr_formula, 187 on mine. Though that is probably because I did edit a couple lines above it, so probably 178 on yours. I'd comment out the original line (Put a # in front if it), then try my code.

The only bad news is I'm not sure how to edit the line where I wrote 'your formula here' to make it work as you want, as I have a poor understanding of how the eval line works.

Plus, I did also realize, this would be a percentage change to the EXP formula that I suggested. Do you want the formula to increase by x% semi-randomly, or do you want it to just add a fixed EXP to the character? As I look at your original post I seem to think you want it to add a fixed EXP instead, am I right?
 

Warpmind

Twisted Genius
Veteran
Joined
Mar 13, 2012
Messages
936
Reaction score
578
First Language
Norwegian
Primarily Uses
@warpmind

With the good fortune that is such a constant feature of my life, Yanfly's script says 

"This script does not provide any default stat bonuses that alter EXR"

I personally am not sufficiently competent to tweak things around the way you suggest, nor can I see how to apply it to an accessory.  Could you describe your idea in a bit more detail?

@Oddball

That's an interesting possibility.  What holds me back from going quickly down that route is that my characters have significantly different MDF, plus there is no obvious logical reason why having a high defense against magic should mean that you learn more (gain more experience) from an enemy which uses physical attacks.  Also I may be mis-remembering that script, but I don't think it applies to armor, though I haven't checked yet.
Oh, yeah, it doesn't come with a formula that mucks about with it...

Um, what was I thinking again... Oh, yeah, try something like changing that last block to, oh...

# This adjusts the formula for EXR. EXR is the Experience Gain Rate.

# This script does not provide any default stat bonuses that alter EXR.

:exr_n_value => "0",

:exr_formula => "base_exr" ,

if items.any? {|item| item.id == item_id } : :exr_formula += actor.level,

Unless I've missed my mark COMPLETELY here (not an entirely implausible scenario), swapping in the number of the equippable trinket in question in place of item_id *should* make the formula add the actor's level to the EXR... probably.

It's been a long week, and my cross-referencing skills are not what they used to be. But then, even Entropy isn't what it used to be. ;)

But seriously, I'm pretty sure I've seen a more elegant answer than this one, but this is all I can come up with right now. :p
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@bgillisp

You might have a "poor understanding" I have no understanding.  However, perhaps we can cobble something together.

What I want is neither a semi-random percentage, nor a fixed amount either because it is the level times a slightly random number.

@warpmind

That looks like it's sort of on the way, but as I've just said, what I'm looking for is the level multiplied by a slightly random number, and you are just giving the level, which will be significantly lower than what I had in mind.
 

Warpmind

Twisted Genius
Veteran
Joined
Mar 13, 2012
Messages
936
Reaction score
578
First Language
Norwegian
Primarily Uses
@bgillisp

You might have a "poor understanding" I have no understanding.  However, perhaps we can cobble something together.

What I want is neither a semi-random percentage, nor a fixed amount either because it is the level times a slightly random number.

@warpmind

That looks like it's sort of on the way, but as I've just said, what I'm looking for is the level multiplied by a slightly random number, and you are just giving the level, which will be significantly lower than what I had in mind.
Oh, yeah, sorry... The last line should be

if items.any? {|item| item.id == item_id } : :exr_formula += actor.level*(rand(4)+2),

This should give the level a multiplier of 2-5 - I think.
 
  • Like
Reactions: Kes

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
I think I have it now. I wrote a code snippet, and set it so that when state 25 (you can edit it in the editable region) is on the character, any time EXP is gained via a gain EXP command, then they gain the bonus EXP.

#Editable regionmodule BonusEXPonState #Set the State for when the bonus EXP is awarded here. BonusEXPState = 25 #Set the minimum number to be multiplied to the level here. MutiplierMin = 3 #Set this to the range + 1. For instance, if you want it so that the level #is mulitplied by a number between 3 and 5, the range would be 5 - 3 = 2, #then add 1 to that to get 3. MutiplierRange = 3 end#End of Editable Region#Class Game_Actorclass Game_Actor < Game_Battler #Overwritten method, gain_exp def gain_exp(exp) if state?(BonusEXPonState::BonusEXPState) change_exp(self.exp + (exp * final_exp_rate + self.level * (rand(3) + BonusEXPonState::MutiplierMin)).to_i, true) else change_exp(self.exp + (exp * final_exp_rate).to_i, true) end end #End overwritten methodend #End class Game_Actor
The numbers I put in the editable region are for the numbers you showed in the example, but you can play with them. Just please don't enter any negative numbers, I put no error checking into this snippet.

Terms of use are do whatever you want with it. I know this is probably for a commercial game, and that is fine by me.

Edit: Warpmind's solution should work too. Now you have two ways to approach it.
 
Last edited by a moderator:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Wow, now I've got a choice.

I think I'll try bgillisp's suggestion first, as it is much simpler than bringing in Yanfly's script where I would have to configure all the sections above the one I want (I think) so that they don't run with Yanfly's suggested formulas.

@warpmind

having you explain all that has, however, notched up my minuscule understanding of scripts, so you have given an invaluable service.  Thank you.

@bgillisp

I'll try this now and see what happens, though I am so tired if there is a problem I shall wait until the morning to try and sort it out.  I might well find that a night's sleep will bring enlightenment.

Thank you both very much.
 

Warpmind

Twisted Genius
Veteran
Joined
Mar 13, 2012
Messages
936
Reaction score
578
First Language
Norwegian
Primarily Uses
Wow, now I've got a choice.

I think I'll try bgillisp's suggestion first, as it is much simpler than bringing in Yanfly's script where I would have to configure all the sections above the one I want (I think) so that they don't run with Yanfly's suggested formulas.

@warpmind

having you explain all that has, however, notched up my minuscule understanding of scripts, so you have given an invaluable service.  Thank you.

@bgillisp

I'll try this now and see what happens, though I am so tired if there is a problem I shall wait until the morning to try and sort it out.  I might well find that a night's sleep will bring enlightenment.

Thank you both very much.
Trying to teach is a learning experience as well. Glad to help. :)
 
  • Like
Reactions: Kes

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Same here, I got to improve my scripting knowledge a little with it.

BTW, if you do use my method, use this updated snippet. The version I posted there I forgot to make it so that the last variable in the editable region really works.

#Editable regionmodule BonusEXPonState #Set the State for when the bonus EXP is awarded here. BonusEXPState = 25 #Set the minimum number to be multiplied to the level here. MutiplierMin = 3 #Set this to the range + 1. For instance, if you want it so that the level #is mulitplied by a number between 3 and 5, the range would be 5 - 3 = 2, #then add 1 to that to get 3. MutiplierRange = 3 end#End of Editable Region#Class Game_Actorclass Game_Actor < Game_Battler #Overwritten method, gain_exp def gain_exp(exp) if state?(BonusEXPonState::BonusEXPState) change_exp(self.exp + (exp * final_exp_rate + self.level * (rand(BonusEXPonState::MutiplierRange) + BonusEXPonState::MutiplierMin)).to_i, true) else change_exp(self.exp + (exp * final_exp_rate).to_i, true) end end #End overwritten methodend #End class Game_Actor
Tested it in a blank project with no scripts and Eric at level 5, Natalie at level 1 and the bonuses were working fine, Eric was getting more bonus EXP than Natalie in all tests. Just make sure to add a passive state script and a passive state to the item so it works right.
 
  • Like
Reactions: Kes

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
The scripting solutions might work fine for you (and if so, and you're comfortable using them, they're probably the cleaner way to do this), but it's possible to do so with events too.

Just have a Switch turn ON using a "Turn 0" event page in each battle, and then put your eventing into an Autorun (or Parallel Process) Common Event (and make sure to add a line at the end that turns its own Switch OFF so it only runs once per battle).

If you're using evented encounters, you can even forget the Switch and the Common Event, and instead just put your code into the If Win branch so that this will only run if the player actually defeats the troop.
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
It seems to be working just fine, and as I am already using Yanfly's Passive States script, that was no extra work for that aspect.

@Wavelength

Thank you for the info.  I shall store that away, because there may be another project where it would be better to event it rather than script it.  So a useful addition to my store cupboard.

Thank you everyone for all your help.  It is much appreciated.
 

Sharm

Pixel Tile Artist
Veteran
Joined
Nov 15, 2012
Messages
12,760
Reaction score
10,884
First Language
English
Primarily Uses
N/A
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,981
Members
137,563
Latest member
cexojow
Top