Problem when trying to activate events by clicking on them when being next to them

Hello, everyone! My problem is the following:

I want the player to be able to use the mouse to activate events if clicking on them (that is, the player moves to the location of the event and activates it). The engine allows to do this by default, but if the player is immediately right next to the event that is clicked on, the event is not activated. Instead, the player moves to the position of the event and nothing else happens. By default, it seems that there needs to be at least 1 tile between the event and the player. This is particularly anoying when I click on an event that is located diagonally to the player because the pathfinding would sometimes make the player walk in a way that makes the event not be activated.

I would like this to be changed so the player can activate events by clicking on them without the need of the spaces I mentioned before. Can you please help me? Thanks a lot for reading!!!
Hi there!

If that is really that way, I believe I never noticed...
Just to make sure, did you try this on a project without any plugins and also on a clean map(like only the player and the event)?
Hi there!

If that is really that way, I believe I never noticed...
Just to make sure, did you try this on a project without any plugins and also on a clean map(like only the player and the event)?
Yeah, forgot to say how these events are set up. The activation is done by the action button (in this case a click), the priority is set to "same as characters" and in option "through" is enabled. It needs to be this way because I want these events to be enabled without the player actually touching them (just by standing next to them and clicking on them), but I need these events to let the player go through them. This particular set up produces the problem mentioned before because I tested them in a blank project and the same thing happens.

Thanks for answering!!!
Bump
Oh dear. The event activation code really didn't want to be modified. But I think I've figured out more or less how it works, so here's a fresh new plugin for you 🙂

JavaScript:
Game_Player.prototype.triggerTouchActionD1 = function (x1, y1) {
    if ($gameMap.airship().pos(x1, y1)) {
        if (TouchInput.isTriggered() && this.getOnOffVehicle()) {
            return true;
        }
    }
    this.checkEventTriggerHere([0]);
    if(!$gameMap.isAnyEventStarting()) this.startMapEvent(x1, y1, [0], true);
    return $gameMap.setupStartingEvent();
};

This is a bit hacky, but I'm not sure if a non-hacky solution is at all possible here.
What this code doesn't change at all is where you character will walk to, so you'll still sometimes end up in front of the event, and sometimes on it, but at least it should always activate.
Oh dear. The event activation code really didn't want to be modified. But I think I've figured out more or less how it works, so here's a fresh new plugin for you 🙂

JavaScript:
Game_Player.prototype.triggerTouchActionD1 = function (x1, y1) {
    if ($gameMap.airship().pos(x1, y1)) {
        if (TouchInput.isTriggered() && this.getOnOffVehicle()) {
            return true;
        }
    }
    this.checkEventTriggerHere([0]);
    if(!$gameMap.isAnyEventStarting()) this.startMapEvent(x1, y1, [0], true);
    return $gameMap.setupStartingEvent();
};

This is a bit hacky, but I'm not sure if a non-hacky solution is at all possible here.
What this code doesn't change at all is where you character will walk to, so you'll still sometimes end up in front of the event, and sometimes on it, but at least it should always activate.
Yeah, I imagined changing that would be something tricky. Thanks a lot for taking the time to do this. It means a lot for.mr and my project. I'll test it as soon as I get home and I'll let you know how it goes.

Also, is it possible to correct the behaviour of the player when interacting with events in that way? I wish the player would stop its movement when interacting. If it doesn't always stop then it'd be somewhat confusing for the people playing it. I ask if it's possible so I can look for help on how to do it.

Thanks again for doing this
Also, is it possible to correct the behaviour of the player when interacting with events in that way?
Do you mean to always stop in front of it instead of on it? I'm afraid not, or at least I don't see a reasonable way to do it without rewriting a lot of things.

The whole pathfinding code it really weird. Like, you'd expect that when you click somewhere, it would run the pathfinding algorithm, create a path, and then follow it. What actually happens is it runs the entire pathfinding, only to return the... direction the player should face. It then takes one step, and runs the whole thing again xD. And it only check for events after turning and making that step, so there's no way to know if there's an event there until you're already standing on it.

To fix that you'd probably have to delve into the whole pathfinding algorithm and somehow wrestle the path out of it, then shorten the path by one if there's an event at the end of it. Alternatively manually scan around the walking player for these events, though you could run into plenty of weird issues with different passability settings.

Original thread: https://forums.rpgmakerweb.com/threads/problem-when-trying-to-activate-events-by-clicking-on-them-when-being-next-to-them.154265/