Run Nearby Event - a simple way for creating large events and more

1698141427765.png


Each arrow event runs the event it points to when interacted with. Those arrow events can be freely copied and pasted anywhere, allowing for quick creation of large interactables. The arrows sprites themselves won't render in-game.
This, and much more, is possible with this plugin!


Introduction
Run Nearby Event allows you to run regular events the same way you would run common events, in a lot of different ways. It gives you a plugin command to, you guessed it, run a nearby event. It also allows you to run an event with a given id if it's not nearby, an event of a given name or notetag, to run a specific page of that event instead of the currently active one, or to create regions that act as very large events. The included help file should explain exactly how to use it - this post will mostly try to explain why you'd use it, with some examples.

In general, everything this plugin allows you to do would of course be possible without it, albeit with a lot more common events, variables, or copies of events. But with it they become a lot simpler and more pleasant to do.

Spoiler: Large interactables
The most obvious use case for the plugin is of course making larger events to interact with, like in the image above. This is of course possible without it, but rather annoying either way you do it. You could have multiple copies of an event, but this will make it more taxing to modify it, not allow you to use self-switches, and be a pain to debug if you ever forget to copy over some changes. You could use a plugin to extend the hitbox, which is better, but it will require fiddling around with event notetags and won't be visible in the editor, requiring extensive testing to make sure you got those hitboxes right. Or you could click on an arrow event, press Ctrl+C, select the square you want to be the extension of an event and press Ctrl+V 😉

Ok, but how would you make those arrow events? Like so:
1698143991210.png

1698144040960.png


The first page will never become active in-game, and is only there to display the arrow in the editor. You don't have to include it, but it does make it a lot easier to work with.
Also, make sure to set the correct priority on the second page (I kept forgetting about that back when I made this feature) 😉
For the sprites, you can make your own arrows, or use the ones I've made:

$arrows.png

Save this image as $arrows.png in the characters folder and you're good to go. You're free to use this image for any purpose, it's just arrows I made in GIMP in a few minutes 😛

The way I tend to use them is that blue arrows are used in events that have "Same as characters" priority, and run the event that they point to and is right next to them. Those can be freely copied and pasted. Red arrows are for events that are not meant to be copied, because they are somehow different, e.g. they run an even a few tiles away, have a different priority or trigger. Though of course you're free to use them however you want.

Another thing of note is that you can chain such events, as seen in the image on top of the post. An arrow event can run another arrow event, which will run the next arrow event etc. This will all happen on a single frame, so you can have a chain with 200 of them and it shouldn't cause any lag (as to why you'd have a chain 200 long is another question).

Spoiler: Other uses
Wondering what else you can use this plugin for? Here's a bunch of ideas.
Most of those could also be done with common events, if you don't mind having a lot of these. I just think that common events should only be used for things that are actually common throughout the project, and if an event is only used on one map, it should go on that map. You don't have to agree with that opinion, but you'll find this plugin considerably more useful if you do 😉

1. You have a warehouse with a bunch of boxes, and would like the same interaction for all of them, but can't use arrow events because they're all over the place. Just use RunEvent id, and enjoy your single reaction event that you can easily modify.

2. Like the above, but you want one reaction when looking at specific create for the first time, and another if you've already looked at it before. You can can use a self-swich for each crate, and have that determine which event/page to run.
Spoiler: Crate example
The crate event (presumably you'd have a lot of these):
1698149640071.png


The single reaction event:
1698149653164.png

1698149663788.png

No switches, variables, or common events needed 😉

3. A group of 4 NPCs talking to each other. Talking to one of them will get you the reaction from them specifically, and then, regardless of who you talked to, transition to the same conversation involving everyone by just running the event in the middle.

4. Turning any tile into a "counter" tile (allowing you to talk to NPCs across it) with RunEvent facing.

5. A merchant with a complex way of selling you things (e.g. lots of conditionals, or maybe an evented UI), with a fair amount of dialogue the first time you meet him, who will want to jump straight to business afterwards. So the first time you talk to him, there's a long introduction scene, and then the selling you stuff part. The second time there's just the selling you stuff part. It would be nice to have the introduction and selling on separate pages, but then how can you have both happen when you first talk to him? Simple: at the end of the first page (after setting a self-switch activating the second page), use RunEvent this.

6. A magical crystal of randomness, that when interacted with will do something random, either good and bad, and will also cause the party to discuss the outcome. You could set a random variable to 1-10, and then have 10 very long conditional branches with the consequences. But a nicer and more manageable way is to set that variable to 2-11, and run another page of the event depending on the result.
Spoiler: Random crystal example
1698151490962.png

1698154944057.png

1698151151382.png

The event will first ask the player if they want to use the crystal, then the commands on the randomly chosen page will play out, and then the "I hope you enjoyed the randomness crystal" dialogue will play.

As you can see, the other pages don't need to have an image or priority set - only their commands are run.

7. A riddle that tells the player to check a specific tree in a forest. That tree will have a special reaction when interacted with, but it would be nice to create a reaction for every wrong tree as well. Since there might be a lot of them, you can paint them all with a region (let's say region 42). Then create an event with the reaction for investigating the wrong tree, and give it the notetag <Region:42>.

Hopefully these examples will give you an idea of what you can do with this plugin. I've had this feature in my game for a long time, and the idea that events can just freely run other events has become really intuitive for me. I actually struggled a bit with explaining exactly why you'd want this, since I use it for nearly everything 😛

Spoiler: Removing a trigger from events
When using this plugin, you might often want to create an event that's triggered by other events, but never by the player directly. Usually you can put it in an unreachable area, but sometimes on wide open maps that might be difficult. In my game, I've made it so that events that have an action button trigger, are below or above characters and have "through" enabled are not interactable. When making this plugin I've realised that this might be a bit cursed for some people, so while it remains an option (off by default), you can instead make events uninteractable with a <NoTrigger> notetag.

Spoiler: More technical notes
On top of the plugin command, you can also use this plugin's functionality with a script call - details in the help file and the JSDocs comment in code.
This plugin overwrites Game_Player.prototype.startMapEvent, unless the Events with trigger "none" option is set to Disabled.
The events are started as children of existing events, similar to common events. The increase in depth however is prevented, to leave the full amount for potential common event shenanigans. Instead a custom interpreter property chainLength is used to detect infinite loops.

Spoiler: Terms
The plugin is available under the MIT Licence - you're free to use it in your non-commercial or commercial games, or use the code in your own plugins. Credit is appreciated, but not required.

Please let me know if you have any problems with it, have suggestions for new features, or would simply like to share how you're using it. There are probably plenty of uses for it that I haven't thought of, and I'd really like to hear about them 😍
This is amazing. Kudos to you for cooking something this good.
Version 1.1 is now available.

It doesn't change any existing options, so you can safely delete the previous file and replace it with the new one, leaving the settings in Plugin Manager unchanged.

New features:

- You can now run an event with a specified name or notetag. This serves a similar function to running an event with a given ID, but is considerably more readable. Using notetags can also help you remember that an event you're looking at is ran from somewhere else.
- There's a new option to lock events ran with this RunEvent, i.e. stop them from moving and turn towards the player, like they would when interacted with normally. This is off by default to preserve existing plugin behaviour.
- The script call now works even without any active interpreters. So you can type MAC_RunNearbyEvent.run(42) in console to run an event if you really can't be bothered to walk to it 😛
- You can specify the ID of an event to run by using a variable... you could have also done that one in the previous version, but I forgot to mention that feature in the help file 😅

It's probably also worth mentioning that this plugin requires RPG Maker MV 1.6.0 or newer. If you're using an older version, you'd need to update nwjs to use it (or update RM itself, though if you still haven't done that I'm assuming you have a good reason not to).
I like this, and needs some tinkering!
Version 1.2 is now available

It doesn't change any existing options, so you can safely delete the previous file and replace it with the new one, leaving the settings in Plugin Manager unchanged.

Major new features
- Region events! You can now create very large events by marking an area with a region, and simply adding a <Region:id> tag to an event (name of the tag used can be changed) - this event will be ran whenever the player interacts with a tile that's marked with a region of that id. Region events keep their priority and trigger, so you can have an event that runs when the player interacts with any tree in the forest, or when they walk into an ocean.

Bugfixes
- Fixed locked events not unlocking when they ended via the "Exit event processing" command
- Fixed running events with no active pages throwing an error when it shouldn't
- Region events! You can now create very large events by marking an area with a region, and simply adding a <Region:id> tag to an event (name of the tag used can be changed) - this event will be ran whenever the player interacts with a tile that's marked with a region of that id. Region events keep their priority and trigger, so you can have an event that runs when the player interacts with any tree in the forest, or when they walk into an ocean.
Nice. Perfect for fishing events or Pokemon-style surfing. Press ok by water > surf/go fishing.

Could you add a terrain tag option (yeah, I could edit the code to check terrainTag but uh, you know, for other people)
Could you add a terrain tag option
Right, that's a good point. I tend to forget these exist 😛

Version 1.2.1 is now available

New features
- Terrain events. Similarly to region events, you can make an event trigger whenever a tile with a given terrain tag is interacted with by adding a <Terrain:id> notetag. So now you can have an event that runs when the player interacts with a water tile without needing to cover all of those in regions.
Right, that's a good point. I tend to forget these exist
Makes things easier in some ways because you only have to set, for example, all water tiles to a terrain tag once instead of painting the map. Also sometimes you want to use the region for something else.
Version 1.3 is now available
This version includes new plugin parameters - make sure to open it in Plugin Manager and click OK after replacing the plugin file to make sure they generate.

New features
- When using mouse-based movement, the player can now pass through a "Player Touch" event instead of stopping at it, if all that event is doing is running another, inactive event.
- Added a notetag to force the above behaviour on other types of events
Spoiler: Some more details above event passthrough
When using the mouse to move, the player will automatically move to the tile that was clicked on. But if an even is triggered along the way (usually a below player event with player touch trigger), this movement will be interrupted. This is usually what you want (e.g. when that event is a cutscene), but sometimes it is not.

This is occasionally an issue even without this plugin, e.g. when you want to change a switch as the player enters an area. This can be done seamlessly for keyboard controls, but mouse movement will get interrupted by the event setting a switch, slightly annoying the player.

It is however much more of an issue when using Run Nearby Event, where you might have a considerable amount of player touch events that run other events, which may or may not be active.

So in this update, events that only have a single non-comment command, and that command is a "RunEvent" plugin command, will never interrupt player movement (but the events they end up running still can). There's also a notetag to force this behaviour elsewhere, e.g. in an event that sets a switch as the player passes through it and isn't meant to be noticable.

Bugfixes:
- Fixed an error on startup that occurred on certain nwjs versions
when testing it as I place it on top, middle, bottom, the same error pops up.
even with 2 main plugin (TSR_TransferTrigger (modded) and SDJB_DistanceFade
to activate the event/player touch event with the tag <NoStop> to keep walk.
but as soon as I enter the array, it crashes, not sure why.

as that seems useful as I might need that, but I dont get the code of the 2 top ones.
error.png


YEP Core, SDJB has no effect in this as I turn them off as well.
Thanks for the report @ShadowDragon !

Now that was an interesting bug. I always assumed that the event() function of interpreters was a normal MV thing - turns out it's actually added by Ocram Layers xD
I definitely didn't expect keeping that plugin in the testing environment to trip me up like this.

Version 1.3.1 is now available

Bugfixes:
- Fixed an event passthrough-related crash
I re-test it, and no more crashes and seems to work nicely, as it is a bit annoying
that mouse clicks doesn't work while keyboard did.

without <NoStop> and with event through, => still interupting.
with <NoStop> it walks trough event stops.

I tried to fix this issue somehow, but never manage it get it to work,
so I'm happy you did it.

for my distance fade, this function is extremely useful, so huge thanks for fixing
it so quickly and works outstanding ^^
Version 1.3.2 is now available

Bugfixes
:
- Event passthrough will no longer get confused by erased events
Version 1.3.3 is now available

Bugfixes
:
- If you had running non-existent events set to not throw errors, and had automatic event passthrough enabled, and had an event that runs a non-existent event, and that event was inside a wall, and you used the mouse to interact with it, the movement cursor would continue flashing indefinitely until you moved somewhere else.
This is now fixed.
Hey update nice
@Mac15001900 That might be the most specific error scenario I've ever seen.
@Mac15001900 I found a really REALLY weird bug, not sure how.
as if you click on the map for movement, with event touch and <noStop>
tag, when you click on the corner, and the player find its path downwards

it stops its movement.

like player X is on 10 and Y 4, when you click on the bottom corner for example
and it goes downwards, it stops there.

and not exactly sure why or how to fix this, as it doesn't like edges xD
mostly happen on the bottom or top edge of the map, rarely on the sides.
You should consider a career in bug testing!
You should consider a career in bug testing!
I do bug testing on games I like too, but some glitches in plugin, I can solve
and report it, but I also learn, and some things I don't get, as this bug shouldn't
happen as it works everywhere, except edges, and no idea if edge can be checked
with this height/width or possible scrolling maps.

but I keep learning though and this plugin is useful for my distance fade plugin as well.
@Mac15001900 I hope you can find a bug in post #17, but also a new bug
when testing on command115 for unlock when I set a moveroute, it works,
but if the condition is false on that condition, it throws the error when using
HIME_EventLabelTrigger.
etl.png

I hope you can fix this one when the player is ON the event on triggering it?
the moveroute I use is very specific and works, but not with this one,
not sure if I can rule it out or what it exactly does with event.unlock()?

Original thread: https://forums.rpgmakerweb.com/threads/run-nearby-event-a-simple-way-for-creating-large-events-and-more.162345/