Gray96

Veteran
Veteran
Joined
Jan 4, 2018
Messages
33
Reaction score
5
First Language
English
Primarily Uses
RMMV
Alright, so first some background. The game I'm making has a level cap of 10, and level ups are gained exclusively through items called "level orbs" that essentially work like rare candies from the Pokémon series. The game is fuctionally a rogue-lite with a classic RPG style, so in order to make it so that the player couldn't over-level on an early floor in my game's main dungeon I decided to award 0 experience from random encounters, and instead award a certain number of level orbs after boss fights (this also forces the player to choose which actors they value levels on most with each run, rather than just giving the whole party flat exp from the boss fights). Here's the level orb item:

upload_2018-8-3_14-25-28.png

If you look in the item's effect box, you'll see that it runs a common event called "Max Level Checker". This is where my problems come in... Currently, the event is as follows:

upload_2018-8-3_14-27-4.png

In its current state, I'm only testing this common event with one character so that is why the control variable only checks the "Level of Celia".

What I'm trying to get the event to do is check for if the actor is already level 10 (the maximum level), and if they are, refund the level orb rather than consume it, while relaying the information to the player that the actor is already at their max level. The problem is that the event currently also runs when the actor REACHES level 10 (i.e. when a level up orb is used on the actor when they're level 9 to get them to level 10). This creates the following situation... Here's Celia at level 9:

upload_2018-8-3_14-34-8.png

and there's 2 level orbs left to use:

upload_2018-8-3_14-34-43.png

But when I use one to get her to 10...

upload_2018-8-3_14-35-28.png

The common event plays telling the player that she's already at maximum level, and the level orb is refunded, still leaving 2 in the inventory when it should have dropped to 1:

upload_2018-8-3_14-36-19.png

tldr; I'm currently not versed enough in eventing to make this work as I intend to... Any help would be greatly appreciated, and thanks in advance!
 

Neo Soul Gamer

Veteran
Veteran
Joined
Aug 10, 2012
Messages
676
Reaction score
441
First Language
English
Primarily Uses
N/A
There are probably some things I'm not understanding about what you're trying to do, but I'm going to try and help out anyway.

First, I'll ask... Do you have any plugins installed? Like Yanfly's Item Core or Skill Core?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
38,468
Reaction score
10,891
First Language
German
Primarily Uses
RMMV
has nothing to do with plugins, that is simply because the common event is executed after all effects of the item - and you can't easily change that.

however, a better solution is to move the exp into the common event.

remove the exp gain in the damage formula (remove the damage completely)
have the common event check if the level is 9 or less, if it is then add one level by event command
if the level is already 10, then refund the item without adding the level
 

Gray96

Veteran
Veteran
Joined
Jan 4, 2018
Messages
33
Reaction score
5
First Language
English
Primarily Uses
RMMV
has nothing to do with plugins, that is simply because the common event is executed after all effects of the item - and you can't easily change that.

however, a better solution is to move the exp into the common event.

remove the exp gain in the damage formula (remove the damage completely)
have the common event check if the level is 9 or less, if it is then add one level by event command
if the level is already 10, then refund the item without adding the level

This should do the trick, thank you :)
 

Neo Soul Gamer

Veteran
Veteran
Joined
Aug 10, 2012
Messages
676
Reaction score
441
First Language
English
Primarily Uses
N/A
The reason why I was asking is because, with a plugin, a few lines of code thrown into that item's notetag would save a bunch of time. It's probably better than eventing different effects for each of your actors. Was trying to kill two birds with one stone. lol
 

Gray96

Veteran
Veteran
Joined
Jan 4, 2018
Messages
33
Reaction score
5
First Language
English
Primarily Uses
RMMV
has nothing to do with plugins, that is simply because the common event is executed after all effects of the item - and you can't easily change that.

however, a better solution is to move the exp into the common event.

remove the exp gain in the damage formula (remove the damage completely)
have the common event check if the level is 9 or less, if it is then add one level by event command
if the level is already 10, then refund the item without adding the level

So I removed the damage formula from the item and changed the common event to be as follows:

upload_2018-8-3_15-56-33.png

Good news is that it now works as intended for Celia. Unfortunately, I do not know how to make this work for every actor in the game... Do you know if there's a way for the event to return the actor ID of the actor that the item is being used on? If so, I imagine I could make separate control variables for the "Max Level Checker" on each individual character, and then have the event only change the variable for the actor that the item is being used on. I'm also open to suggestions if there's a better or more streamlined way of making this work. Hopefully asking this second question isn't too much of a bother :)
 

Gray96

Veteran
Veteran
Joined
Jan 4, 2018
Messages
33
Reaction score
5
First Language
English
Primarily Uses
RMMV
The reason why I was asking is because, with a plugin, a few lines of code thrown into that item's notetag would save a bunch of time. It's probably better than eventing different effects for each of your actors. Was trying to kill two birds with one stone. lol

I do use various Yanfly plugins including both Item Core and Skill Core and am willing to get more if they will streamline things, so if you know of some simple solutions I would certainly take the input :) If you look at my second reply to Andar about my progress so far, I did ask another question about making the item work for each individual actor and you mentioned that you knew of a way to kill two birds with one stone, so if that can be done as well then that's even better!
 
Last edited:

Neo Soul Gamer

Veteran
Veteran
Joined
Aug 10, 2012
Messages
676
Reaction score
441
First Language
English
Primarily Uses
N/A
Great! So with Yanfly's Skill Core, there's a notetag that allows you to run code during different phases of the skill or item use. So with the tag below, we can reference current actor that the item is being used on. This allows us to create a simple check before we raise the EXP. I'll also be using a couple of comments to explain each line of code, so disregard what follows after the "//". Here's how it would look:

Code:
<Before Eval>
// Check if the target's level is less than 10.
if (target.level < 10) {
// Raise EXP
target.gainExp(100);
// If level is not less than 10...
} else {
// Run common event
$gameTemp.reserveCommonEvent(x);
}
</Before Eval>
Replace "x" with the id of the comment event you'd like to run. With this common event, you can give the item back, play a sound effect, or even display a message.

Now, if I can make a suggestion... I would use the Item Core addon called "Item Requirements". That way, you'd only really need one line of code that checks the actor's level. And if it doesn't meet the requirements, the item is greyed out and will play a buzzer sound if you try to use it. The only thing is, you'd have to set the item's scope to "user only". The code would look like this:

Code:
<Custom Enable Requirement>
condition = user.level < 10;
</Custom Enable Requirement>

I'm not able to test these at the moment, so you may run into some errors. But it SHOULD work. :)
 

Gray96

Veteran
Veteran
Joined
Jan 4, 2018
Messages
33
Reaction score
5
First Language
English
Primarily Uses
RMMV
Great! So with Yanfly's Skill Core, there's a notetag that allows you to run code during different phases of the skill or item use. So with the tag below, we can reference current actor that the item is being used on. This allows us to create a simple check before we raise the EXP. I'll also be using a couple of comments to explain each line of code, so disregard what follows after the "//". Here's how it would look:

Code:
<Before Eval>
// Check if the target's level is less than 10.
if (target.level < 10) {
// Raise EXP
target.gainExp(100);
// If level is not less than 10...
} else {
// Run common event
$gameTemp.reserveCommonEvent(x);
}
</Before Eval>
Replace "x" with the id of the comment event you'd like to run. With this common event, you can give the item back, play a sound effect, or even display a message.

Now, if I can make a suggestion... I would use the Item Core addon called "Item Requirements". That way, you'd only really need one line of code that checks the actor's level. And if it doesn't meet the requirements, the item is greyed out and will play a buzzer sound if you try to use it. The only thing is, you'd have to set the item's scope to "user only". The code would look like this:

Code:
<Custom Enable Requirement>
condition = user.level < 10;
</Custom Enable Requirement>

I'm not able to test these at the moment, so you may run into some errors. But it SHOULD work. :)


Cool, so here's the new progress update. The item notebox is now as follows:

upload_2018-8-3_19-18-47.png

Note that the level up state added in the effects box is just a dummy state that allows the item to successfully have its effect out of combat, and also that I added the "damage formula" that gives 100 exp back in. With the notetag you suggested in the box as shown, it is ALMOST working with this setup. Whenever an actor is level 10 and I try to use the Level Orb on them, it is not deducted from the inventory, as intended. However, a new problem arises with this setup... The issue now is that when any actor reaches level 10, additional level orbs suddenly cannot be used on any other actors.

I also tried the other recommendation, but the problem with that version of the item seems to be that the item must be used in combat. In any case, progress has been made, but I'm still open to more suggestions!

Edit: Never mind! I think I got it to work now. Your first recommendation using the <Before Eval> notetag works out of combat when I set the item to deal "HP damage" with a formula of 0. Thanks for all your help, and I'll let you know if any other issues arise!

Thanks again for your help, and I'll let you know if anything else comes up!
 
Last edited:

Latest Threads

Latest Posts

Latest Profile Posts

oneOfUs.jpg
Streaming more Poppet Quest game even in about 12 minutes.
Some dog owners really impress me. I'm pushing 2-3 metric tons of garbage containers that destroy everything they hit. What do you think is going to happen to your tiny dog when I run it over? And why are you crossing my path to argue with me? Have you never been hit by 200kgs of garbage?

Lesson for you folks. Never mess with an angry garbage container. Or its driver.
I didn't dispose of a file properly and now my whole game won't start: I get a script error in the Scene Manager stage of game launch. What to do? Transfer it all to a new project? That's going to be tedious. Fortunately I am only nine workdays into it.
>< IMGUR!!!! *clenches fist*
I swear it looked better in my head. But this ain't bad. Had to experiment to make the characters stand out and not blend too much with the background.

Also, before anyone say this. Yes, she is holding a winrar.

Forum statistics

Threads
131,680
Messages
1,222,156
Members
173,424
Latest member
filfes
Top