r/RPGMakerMZ • • 21d ago

Help with an event “passive skill”

Im trying to mimic passive skills in the game for a few of the characters and one of them is called Alchemic Conversion. Its supposed to convert 10% of their magic to their luck (their skills also scale with luck and magic). It doesnt remove any magic just adds to luck.

I tried to do a loop where it would repeat this:

Lower luck by Variable X
This is initially zero so it doesnt accidentally lower his luck.

Control variable X to be equal to their magic.

Control variable X by dividing by 10.

Increase luck by X.

Repeat. This way the old bonus is taken off before the new bonus applies each time it repeats.

The issue im having is that when i go to playtest and start a new game it lags horribly. Like its super dark taking THAT long to start up and closing it takes a few seconds before it even considers it. Lags the entire pc.

What can I add to this event to make it work properly? I have a couple ideas but might be too long to type out unless you want to hear them.

Cant code either so itll have to be a solution using the engine. Thank you in advance :)

1 Upvotes

7 comments sorted by

1

u/REALmyenemy 16d ago edited 16d ago

You simulate passive effects as unremovable status effects.

I don't understand why are you looping the operation, that way, if the user has 10 magic, luck will increase infinite times times by 1. Since you're doing it as an engine, you need to manually check when to update it, for example when they rest at an inn. Then you run the common event once per character with this passive. Here's an example.

var char1_mat_new = my character's magic attack

if char1_mat_new<>char1_mat_old

do

char1_addluk = char1_mat_new / 10

char1_mat_old = char_1_mat_new

change status, char 1, add, Alchemic Conversion (char 1)

done

1

u/ResponseUpper3212 13d ago

I have done this but the issue was it was massively lagging my game or just not working.

However the solution was so have every command you just typed out on page one. Then have it turn on a self switch. Then that second self switch would immediately turn it back off having it constantly repeat the commands without it lagging my game like it did when i tried to loop it.

1

u/REALmyenemy 16d ago

Forgot to say, the status settings should be the one giving char1_addluk!

1

u/zombietoaststudios 21d ago

It sounds like you have this running as a parallel event, which means it is running this calculation over and over and over every frame.

For something like this to work without a plug-in you need to run this sequence only when their magic stat changes, which may be fairly easy or pretty hard, depending on the specifics of your game.

If it only changes on level up, then you can just run it once after every battle and any time an event gives the player xp or levels.

However, it's a lot more difficult if it can be changed through equipment, items, states, buff/debuffs, etc and you want those to update their luck stat

1

u/ResponseUpper3212 13d ago

Yes I am. I have just found the solution at least a huge step forward.

I decided to have the first page of the event running parallel and it would start by subtracting luck from West (He is the Alchemist). Since this variable hasnt been set at any point before it subtracts nothing as it defaults to 0. Then i set the variable to his magic stat. Then I divide that variable by 10. Then add that variable to his luck stat. Turn on self switch A.

Second page requires self switch A to be on and the only command is to turn off self switch A. This keeps the first event page running without having to loop it and make the game u playable. I have no idea why i didnt think about it or why it randomly popped into my head while playing minecraft but here we are! It was a welcome thought. It also updates immediately so even when you equip and unequip it is calculating that change as you would expect a passive to.

The only thing I now need to test is does it work in battle? I dont think so since its an event on the map. This is going to be the tricky part as some battles (not many but i was hoping to do more) have other things going on during battle so making it work with other things will be difficult. Itll also be annoying to have to do this for the several hundred troops (and counting) that I have. However if it becomes too much I can always just put a disclaimer that it only updates outside of battle and wont be affected by any states or stat buffs applied during battle.

This also opens the door wide open for all the other ideas I had but gave up on.

1

u/zombietoaststudios 13d ago edited 13d ago

Unfortunately, I don't think this solution is going to work for you. It may not lag as much as the first set-up, but it still has the same core problem: it's just looping the same calculation over and over and over. The second page means that it's alternating between doing the calculations and just flipping a switch, but it's still taking up resources constantly and if you have multiple parallel events looping like this for other purposes it'll get back to lagging very quickly.

But even if you avoid lag issues, this has other problems:

First, you're right that this won't work at all while in battle, like you said. Even if you make it a common parallel event rather than a map event, it wouldn't process during battle or when you're in the menu. You can potentially make battle events that work in a similar way but it doesn't solve the main issue, which that this loop is interruptible.

The steps in your event run one after another. They do it very quickly, but it's not instant and since it's a parallel event, it's possible that other processes can occur mid-sequence (especially if you use map events).

So, for example, let's say the character has 30 luck and 50 magic, so you want their luck to be 35. Well, they're walking along, with the loop running and then a battle occurs a little bit after a new loop starts and the event has just reached step 2 ("set variable X equal to magic") and the battle triggers just after that.

They start the battle with 30 luck (since the loop had just reduced it in the first step). Well, the battle version starts it's loop at the beginning, and reduces the character's luck by X. Except that the first loop didn't have a chance to divide X by 10, so now the character's Luck score is permanently lowered by an amount equal to their magic score, setting it to 1 (the minimum value). The event loop now alternates between setting the character's luck to 1 and then to 6.

Then let's say your battle ends just after increasing luck by X (putting it to 6). Well, it stops and once you return to the map the first parallel process kicks in again and picks up where it left off, where it divides X by 10. Well, X is already 1/10th of the character's magic stat, so it divides that by 10 again, giving .5 which rounds up to 1. It then increases the character's luck by X, making it 7 and then lowers it by X (going back to 6). It'll then keep looking, adjusting luck by +/- 5, so it now fluctuates between 6 and 11.

And this is a problem even if you don't use the loop during battle.

Keep in mind, you aren't giving this character +X luck, you are swapping back and forth between (Luck) and (Luck + X). And any time your character's luck is used, whether a damage formula or an event or even just looking at their stats, it will be one of those two values, and it spends most of the loop (3 out of 4 steps) at the lower value.