Run an item's common event during another event?

Hi there. I'm trying to make an event run like this:

NPC Speaking Event:
1. Event begins and an NPC begins speaking with the Player.
2. NPC speaks and asks Player to show them that they know how to use an item that increases their HP by 1.
3. Menu opens up automatically and Player selects the item that increases their HP by 1.
4. Item increases the Player's HP by 1.
5. Dialogue box appears saying "Player's HP was restored!"
5. NPC says some more stuff and the event continues

This seems simple enough, except for that the item uses a Common Event, not the simple "Recover HP" function in the effects box, in order to also have the dialogue box appear. Because of this, when the Player uses the item, the HP does not increase until after the "NPC Speaking Event" and more importantly, the dialogue box doesn't pop up until AFTER the NPC is done speaking.

How can I make it so that the game runs the item's Common Event in between the current NPC Speaking Event?

Any and all help much appreciated!
You could split up the NPC's event into 2 pages.

Page 1: Conversation up to the point of asking player to use the item --> Exit event processing

Spoiler: Optional
Make a script call to open the item menu while exiting the NPC event.

SceneManager.push(Scene_Item);


After you use the item, turn on a switch in the common event of the item that activates page 2.

Page 2: (Autorun when the switch is on) Second part of conversation, etc.
This is happening inside an event, right?

.... I recommend NOT using a common event at all. It's a waste for a thing that (I assumed) only be called once for the entire game.

You didn't mention, but I assume the event will repeat if the player rebel and not using the item.
So here's the solution:
1597721897125.png


The item may have no effect so you can do whatever you're supposed to do (dialog box, HP increase, whatever) after the loop.

Points to be noted:
- Make sure the player has only one of such item in their inventory, and it's consumable. Else you will have to use a variable to check the number of the item instead.
- Actual recovery items can only be consumed if the target player is not in full HP / MP.
- The only difference of using this and using a common event is that the player did not immediately escape from the menu.
Thanks both of you for your help, but this is on me for not being clear about what should be happening. Also, I'm not sure why I used a hypothetical situation when I could just explain EXACTLY what I'm trying to do. So in others words, ignore what I wrote above, and below is what I'm ACTUALLY trying to do.

In my game you can participate in races. The mechanics of the races are all set and basically based on your Player's speed (used to be attack). When the race begins the "Racing Event" begins and asks you if you'd like to use an item and then the Item Menu opens. One of the items is a healing item that runs on a common event. It runs on this because in certain races you can't use it and it knows this because of a variable that different "Racing Events" set. So that's why it is a common event instead of just a simple heal effect.

However, when using the heal item, the race begins but the heal item doesn't actually take effect until the Racing Event is all the way over. When the event is over the dialogue box pops up saying "PLAYER is healed!" and then they are actually healed.

What I need to figure out is how to get this item's common event to run within the event.

Hopefully this makes much more sense!
Maybe this?
Seems to work OK for me! 😤

Spoiler: Full plugin code
JavaScript:
/*:
 * @plugindesc Runs a common event immediately when a tagged item is used.
 * @author Caethyril
 * @help Item/skill notetag:
 *    <CE: 1>
 *     - common event 1 will play when used.
 * 
 *    If the map interpreter is currently busy, the common event will run
 *      before the rest of the current event.
 *    Otherwise it will run just like normal.
 * 
 * Note:
 *    This is only designed for items used from the menu, not in battle.
 * 
 * Terms of use:
 *    Free to use and modify.
 */

(function() {
'use strict';
    
    const TAG_NAME = 'CE';

    let shouldGo = false;

    let isSceneOk = function() { return SceneManager._scene instanceof Scene_Item; };

    (function(alias) {
        Game_Action.prototype.applyGlobal = function() {
            let id = parseInt(this.item().meta[TAG_NAME], 10);
            if (id && isSceneOk()) {
                let pt = $gameMap._interpreter;
                if (pt.isRunning()) {
                    let ev = $dataCommonEvents[id];
                    pt.setupChild(ev.list, pt.isOnCurrentMap() ? pt.eventId() : 0);
                    shouldGo = true;
                } else {
                    $gameTemp.reserveCommonEvent(id);
                }
            }
            alias.call(this);
        };
    })(Game_Action.prototype.applyGlobal);

    (function(alias) {
        Scene_ItemBase.prototype.checkCommonEvent = function() {
            if (shouldGo) {
                shouldGo = false;
                SceneManager.goto(Scene_Map);
            }
            alias.call(this);
        };
    })(Scene_ItemBase.prototype.checkCommonEvent);

})();
Alternatively you could use a Select Item command and put all the item effects etc in the race event itself, rather than on common events attached to the items. That may be a bit cumbersome, though. Plus you might want to restrict which items of a category can be selected... 😴
Maybe this?

Alternatively you could use a Select Item command and put all the item effects etc in the race event itself, rather than on common events attached to the items. That may be a bit cumbersome, though. Plus you might want to restrict which items of a category can be selected... 😴

I've been playing with this and it appears to not work exactly, although it's definitely close! Maybe there's something I can do different?

Right now it's going

>Event Begins
>Open Menu Screen
>Player can choose to use an Item (with Effect being a Common Event)
>Use Item
>Item is used
>Item works!
>Nothing happens and the Player can now move around freely

What is should be is all of this except the last point should be
>Original Event continues after item Common Event ends.
Just use Select Item and check if the variable contains the item id of the correct item. If it does, do a Common Event command to call the thing yourself.

Original thread: https://forums.rpgmakerweb.com/threads/run-an-items-common-event-during-another-event.125394/