MP restore potion for magic users only = headache central >.<

Okay, through research and reading, I came up with a way for my non-mage characters to refuse an MP restore potion.
I found a thread suggest that the item inflicts an unnamed state and launches a common event which checks the characters for that state. If the non-mage has the state, they will refuse is and the item is given back to inventory, then the state is removed.
It actually works surprisingly well.

So, here's my problem.. it only works in battle using action sequences, for the full effect (character does item use pose, animation appears with the popup value of the MP restored). I'm well aware this problem would go away if I didn't have to do it my way and emulate what the engine would do if you were to just simply use the item with built in effects. But I'm not making a low-effort game here lol

What I'm getting at is the item can't do anything for a magic user from the menu screen. The refusal for a non-magic user works fine, since that is just a buzzer sound followed by a refusal dialogue from them. Is it possible to check if the item has been used from the menu screen?

If I can't make this work, I'm afraid my last resort will be to have the MP restore potion wasted if the player accidentally (or intentionally) gives it to a non-mage.
"So, here's my problem.. it only works in battle using action sequences, for the full effect (character does item use pose, animation appears with the popup value of the MP restored). I'm well aware this problem would go away if I didn't have to do it my way and emulate what the engine would do if you were to just simply use the item with built in effects. But I'm not making a low-effort game here lol

What I'm getting at is the item can't do anything for a magic user from the menu screen. "


Are you trying to play a battle animation sequence from the menu screen? I've never seen anything like that.

"The refusal for a non-magic user works fine, since that is just a buzzer sound followed by a refusal dialogue from them. Is it possible to check if the item has been used from the menu screen?"

From this I assume that the common event is being called by using the potion from the menu screen. If you mean the Magic user isn't recieving MP, maybe, apply the effects of the potion in the common event? If your unsure, can't it be checked by play testing?

I'm sorry if this doesn't help much, but I'm pretty new here, and I didn't clearly understand the problem.
Gus
What I'm getting at is the item can't do anything for a magic user from the menu screen. The refusal for a non-magic user works fine, since that is just a buzzer sound followed by a refusal dialogue from them. Is it possible to check if the item has been used from the menu screen?

If I can't make this work, I'm afraid my last resort will be to have the MP restore potion wasted if the player accidentally (or intentionally) gives it to a non-mage.
It could just be due to my current state of sleep deprivation, but I'm a little confused about exactly what you're asking.

The first sentence makes it sound like your concern is that the item is wasted on magic users from the menu screen, since the action sequence is (presumably) unable to activate--which leads me to think that you're asking how to stop magic users from using it from the menu screen.

And then the second sentence makes it sound like you already have some working solution to stop NON-magic users from using the item from the menu screen, which then supports the earlier assumption that it's magic users that you're concerned about.

Not quite sure how the third sentence ties into the first two.

But then the fourth sentence makes it sound like you, in fact, *don't* have a working solution to stop NON-magic users from using the potion from the menu screen. So at this point, I don't really know if it's magic or non-magic users that you're concerned about, or both?

For those of us who lack first-hand knowledge of the context of the situation, and/or for those of us who have dysfunctional sleep-deprived brains, could you please try to rephrase exactly what the issue is and what type of solution you're hoping for?
@Arthra I was quite sleep deprived myself when I posted, and I'm already a huge failure of a writer. But let me try to break it down...

[In Battle]

Using the potion inflicts an unnamed state on the user and calls a common event.

975SqGD.png


Well... you can see what it does. I didn't need to show the whole thing, since the rest is just the wrapping up of the action sequence. It adds 50mp to the user who is under that branch. And this works very well, as long as the potion is used in battle.

[From Items Menu, Field]

It carries out the CE properly if you attempt to use the potion on Ashlyn. It will close the field menu and denial message will show. But if you try to give the potion to ????, since it is not being used in battle, the action sequence commands that carry out the function of the potion will not do anything.

What I know I CAN'T do: Use the editor's 'Change MP' command to add 50MP to her. This will add up with the MP being given by the action sequence command. I'm trying to give her 50MP, not 100.
Also, the Change MP command will not trigger the display of the text popup over the character in battle, unless there is a script I can write to make that happen. I'll investigate that as soon as I send this post XD

Solutions I'm hoping to get: 1) A way to check if the player is in battle, or on the field menu screen. or 2) The script to display the MP gain popup in battle. That way I could avoid the action sequence command that performs that and just use the default Change MP command.
Do you really need the plugin commands in your common event? If you use a different potion, do the animations and such play? I'm assuming that when you use the MP potion that the animations don't play twice, so your common event plays before the battlecore is called. This is just from general programming experience, not RPGMaker.
Gus
@GusF - Yes, they are necessary when handling magic potions in my game. Any other potion (health, skill, antidote) is usable by any character, so I just use the built-in item system to handle those.
@Kanori24

I believe I understand your problem now. Probably the easiest solution (if you don't want to have to do away with the action sequence thing altogether), is to add a conditional into the action sequence event, and make it only execute the action-sequence-specific portion of the event if the party is in battle.

Right below Else, and above If: ???? is affected by #0071, add a new conditional statement, and tick the script button, and type this in the box next to it:
JavaScript:
!$gameParty.inBattle()

Don't worry about creating an Else branch. Click Ok, and now you will have a conditional that only executes if the party is *not* in battle. Within that new conditional:
  1. Control Variables -> (Make a variable named Target, or something) -> Set -> Game Data -> Last -> Last Target Actor ID
  2. Use the Change MP command to add 50 MP to the target, using the Target variable to specify the actor.
  3. Use the Change State command to remove that state from the target, using the Target variable to specify the actor.
  4. Exit Event Processing.
So then if the party is not in battle, it'll run those commands, and then exit the event before it can run the action sequence commands. If the party is in battle, it will skip over those commands, and run the action sequence commands.

Here is the general structure, just in case I didn't describe it well:
Code:
If: Ashlyn is affected by #0071
   // Your ashlyn stuff
Else:
   If: Party is not in battle
       // The commands I just mentioned (don't forget Exit Event Processing)
   :End
   If: ???? is affected by #0071
     // Your action sequence stuff
   :End
:End

Just as a side note, you actually could have done the whole thing without using a State, since you have access to the Last Target Actor ID. The State hack is something that MV users have to do a lot, but in MZ, we have access to a bit more game data. But no need to change it now, since you've already done it, and it works. I'm just letting you know so you can potentially save yourself some effort and State slots in the future.

*edit* Fixed a small mistake I accidentally made in the structure breakdown.
Thank you Arthran, I'm also trying to learn these things. It's good to know about that variable call in the future. Do you know of any documentation that includes these things? All I have is an outdated MV tutorial called "Beginning RPG Maker MV"
Gus
Thank you Arthran, I'm also trying to learn these things. It's good to know about that variable call in the future. Do you know of any documentation that includes these things? All I have is an outdated MV tutorial called "Beginning RPG Maker MV"
Gus
You're welcome. Actually, the help documentation that comes with RPG Maker is pretty handy. You can find it by pressing F1 while you have RPG Maker open, or you can go to Help -> Contents from the menu bar. There is a section that explains every event command.

When it comes to tutorials, most anything you find for MV will work for MZ as well--though MZ does have a few extra little things that won't be mentioned. There are also some MZ-specific tutorial series out there, but even then, those little extra things might not be mentioned, because even a lot of MZ users don't seem to realize that they exist.
Thank you.
@Arthran - Thanks a bunch! I'll give it a shot ASAP. Yes, a condition that checks if that party is in battle is exactly what I was looking for. 8)
Alright! That worked without any problems. I just had add a few commands to show the animation on her field sprite, and display a message that she recovered MP.

So... there is a new problem. Now I need a condition to that will check if her MP is at max, and if it is, to deny the use of the potion. Otherwise, it will be wasted.
New problem solved. I created two variables. One sets to her current MP, the other sets to her max MP.
If CurrentMP=MaxMP, use of the potion is denied and it is restored into inventory.

Since the engine isn't running the common event that sets those variables in battle, I just had it set them ahead of the action sequence.
In the games I've played, that was automatic.
Gus
@GusF Yes but this is game making, and what we've accomplished is automation. All the player has to do is pick the potion, pick the character, and let the game do the rest of the work.
It would be even more automated if it weren't for my story.

See, my protagonist not only despises magic. She hates it. She doesn't even have an MP pool (nor does she want one) Thus, the player should not be able to give her an MP potion. By default, the RPG Maker MZ doesn't really have a basic method of setting which actors can use which items. We have to do a bit of manual work so that the player doesn't have to worry about this.
You already solved the problem about your protagonist before. If she doesn't have MP, how are you going to check to see if it is at max before taking an MP potion that she can't take to begin with?

I believe MZ has a way of limiting items by CLASSES and potions are just consumable items. If your protagonist is the only member of her class, wouldn't that solve it?
Gus
Using the potion on her gives her an unnamed, ineffective state that is caught in a conditional check. It then displays a message box of her saying "What the? I don't need that!" and returns the item to the party's inventory so it doesn't get wasted.

I'm not sure about your classes idea... but I'll investigate it. Any help is still help 🙂

Original thread: https://forums.rpgmakerweb.com/threads/mp-restore-potion-for-magic-users-only-headache-central.149325/