Variable activates event after accumulating an X value

Okuro

Warper
Member
Joined
Jun 18, 2019
Messages
4
Reaction score
0
First Language
Portuguese
Primarily Uses
RMMV
I'm doing a project and I want the player to receive an item whenever the variable based on his XP reaches a certain value, in this case, the value 5,000
So, when the player reachs 5,000 XP he will get the item, and when he reachs 10,000 XP he will get the same item again, and the same thing will happen when he reaches 15,000, 20,000, 25,000, creating this loop.
I tried to do a event with this concept, but it didn't work the way I wanted it, whenever the player reached any value above 5,000 he won the item.
I would like to know if it is possible to make the variable only activate the event when it accumulates a value that in this case would be 5,000 to 5,000.
 

poorrabbit

Veteran
Veteran
Joined
Mar 15, 2014
Messages
113
Reaction score
71
First Language
english
Primarily Uses
RMMZ
You could do it with multiple events, one for each level. Then when the event for 5k runs, have it self-switch to a blank page and do nothing ever again...

If you're using a common event - you can't do that. You could create a second variable which tracks the rewards given. 1 for 5k, 2 for 10k, and have it check the second variable as well.

Something like :
Conditional: if XP>=5k Conditional: if XPRewards < 1 then do 5k reward XPReward +1 End Conditional Conditional: if XP >= 10k Conditional: if XPRewards < 2 then do 10k reward XPReward + 1 End Condtional

etc...and so on for the rest of the reward tiers.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
32,382
Reaction score
8,099
First Language
German
Primarily Uses
RMMV
several ways, depending on what exactly you want.

the main problem is that the event condition that you are most likely using is var >= value - there is no equal condition in the event page. If you want to continue using event page condition, you would have to make pages for the between - >5000, >5001, >10000, >10001 and so on.

better solutions would be to not use page conditions but conditional branches on one page, but that would require constant checking.

another alternative is using two variables for comparion, or the modulo operation in control variable and a few more variabts.

If you can show us a screenshot of your current event, it would help deciding which way is best for you as your current description is a bit small.
 

Drakkonis

Veteran
Veteran
Joined
Mar 5, 2021
Messages
117
Reaction score
68
First Language
English
Primarily Uses
RMMZ
Depends on when you want it ran. On the world map outside a battle, I'd have a parallel event running to check the XP levels, when it hits a threshold, run the commands you're wanting, and set a variable for the number of times it's ran (so that it doesn't run all the time), or a switch for each threshold.

For example, since you want it ran every 5k, I'd have the variable for your threshold count set at 1 at the beginning of the game, and checking to see if the actor's XP is over 5k * the variable, if it is, run the event, and at the end of the event, increase the variable by 1.

Haven't tested any of that and I'm fairly new to this myself, but that's how I would first attempt it.
 

Latest Threads

Latest Posts

Latest Profile Posts

Whenever I start on a new chapter, it doesn't feel like the next episodes, but more like sequels :)
It can be frustrating that so many commercial games have used up titles that might otherwise be great for a project.
Light up explosions with QABS and Community Lighting.
qcPQHt9.gif

Forum statistics

Threads
110,655
Messages
1,054,984
Members
143,778
Latest member
dsdgdsfa
Top