[FROG] Trigger Distance - Fire touch events at a distance

Frogboy

I'm not weak to fire
Veteran
Joined
Apr 19, 2016
Messages
1,691
Reaction score
2,188
First Language
English
Primarily Uses
RMMV
TriggerDistance 1.21
by Frogboy

Introduction

This plugin allows you to set up Player Touch activation that covers an area or line of tiles around it. It is mainly used to avoid duplicating the same Event multiple times in order to cover more than one square. By specifying your parameters in a comment on an Event page, the Player Touch Trigger can be fired when your Player is at a specified distance from the Event and/or on a certain axis. I've also added functionality to list specific modes of travel that will trigger an event. Now you can fly your airship to a floating island but not walk or sail into it from the ground. Yay!

This plugin now also supports Event Touch triggers at a distance. A moving event with an Event Touch trigger will activate if it steps within range of the Player.

Features
  • Adds the ability to specify which modes of travel will activate a Player Touch Trigger.
  • Saves a ton of time. Who hasn't copied events and pasted them on multiple nearby squares and then need to change something which forces you to delete them all and re-paste the change back in? Now you just have one event to deal with.
  • Easily do an edge transfer with a single event.
  • Easily span an Event across a wide hallway that starts a cut scene.
  • Make an NPC talk to you when you get near them without forcing the player to walk all the way to them and initiate the conversation.
  • Makes your project leaner by reducing the amount of events that need to be tracked and processed.
  • Can save on switches when you have lots of copied events that need to turn off together when activated.

How to Use

On an Event page that has a Player Touch trigger, create a Comment and enter it in this format: <TriggerDistance: parameters>
Parameters are separated by a space.

The following parameters are supported. Each one is immediately followed by a number to specify the distance in squares/tiles that the Event should fire.
  • r# - Radius (Any square within # of Event)
  • x# - X-Axis (Any square within # of Event on the X-Axis [left/right])
  • y# - Y-Axis (Any square within # of Event on the Y-Axis [up/down])
  • s# - Switch Binding (Will turn ON the specified Switch ID and not fire again while the Switch is on)
  • combo - This tells the event to look for both Player and Event Touch conditions.
If both x# and y# are specified, the trigger range will form a square or rectangular area as opposed to just covering the two axis.

These can also be specified in the parameters to indicate which modes of travel this event will fire for. If you specify none then the Player Touch will always trigger.
  • walk - Player Touch will trigger if you are walking
  • boat - Player Touch will trigger if you are on your boat
  • ship - Player Touch will trigger if you are on your ship
  • airship - Player Touch will trigger if you are on your airship

Examples

X-Axis: <TriggerDistance: walk x5>
Will cover the Event square and 5 tiles to the left and right of it. Great for spanning a large hallway or exit. Only fires when walking.

tdsnap1.png

Y-Axis: <TriggerDistance: boat y2>
Will cover the Event square and 2 tiles above and below of it. Only fires when in your boat.

tdsnap2.png

Radius: <TriggerDistance: walk r3>
Will cover the Event square and 3 tiles in all directions. Only fires when walking.

tdsnap3.png
Rectangle: <TriggerDistance: x4 y2>
Will cover an area that spans 4 tiles along the x-axis and 2 tiles along the y-axis.

snap4.png

Edge Transfer: <TriggerDistance: x999>
Will cover the the entire edge of the top or bottom of a map. It doesn't have to be the top or bottom edge but that's what it is typically used for. The number is set purposely large to cover any size map. Fires for all modes of travel.

Edge Transfer: <TriggerDistance: y999>
Will cover the the entire edge of the left or right of a map. It doesn't have to be the left or right edge but that's what it is typically used for. The number is set purposely large to cover any size map. Fires for all modes of travel.

Radius with Switch: <TriggerDistance: r2 s12>
Will cover the Event square and 2 tiles in all directions, will turn on Switch ID 12 and not fire an Event Touch again while Switch 12 is ON. Fires for all modes of travel.

Player Touch only fires when you are in your airship: <TriggerDistance: airship>
No radius, x or y specified so this only covers the event tile.


Terms of Use

This plugin can be used in commercial or non-commercial projects.
Credit Frogboy in your work.


Changelog

Version 1.1 - Initial Release
Version 1.2
  • Added support for ranged Event Touch Triggers.
  • Rectangular cover when specifying both x# and y#.
  • Bug fix - Wasn't respecting 4-direction passage.
  • More Aliasing. This plugin isn't nearly as greedy as version 1.1
Version 1.21 - Bug fixes

Download

My Plugins Page - https://frogboymv.github.io/
Trigger Distance Plugin - https://github.com/FrogboyMV/TriggerDistance
 
Last edited:

Lorenze

Veteran
Veteran
Joined
Mar 17, 2012
Messages
825
Reaction score
540
First Language
English
Primarily Uses
RMMV
SO helpful, this should save a bunch of time. Great work, thank you so much!
 

Solarphantom

A badass
Member
Joined
Dec 31, 2012
Messages
19
Reaction score
9
First Language
English
Primarily Uses
N/A
So just a quick question about it with transfer events.
Lets say I have two maps that are 30 x 30. The transfer event on the first map is on x29 y29 (bottom right corner). That transfer event puts you on x0 y29 on the second map (bottom left corner). If I extended the event to cover the entire Y line, would it only transfer to x0 y29?
 

Frogboy

I'm not weak to fire
Veteran
Joined
Apr 19, 2016
Messages
1,691
Reaction score
2,188
First Language
English
Primarily Uses
RMMV
If you hard-code it to transfer you to that exact spot, yes. What I do is store the players X and Y coordinates. If I'm transferring on the right border like in your example, I will overwrite the X position variable with 0 and then transfer the player to the stored X and Y positions. In this case, it would be X = 0 with the same Y that you're on. If you triggered this event at X15 Y20, you'd end up at X0 Y20.

In short, you still have to tell the event what to do. But if you have a grid of maps that are all the same size, you can easily create 4 Common Events, one for each edge, that will set the transfer variables to place you where you want to go. Then all you need to do is manually set the Map ID where you are travelling to and call the appropriate Common Event.

Three event commands for each edge and you can connect any number of maps together to make as large a map as you want and even your airship will be able to traverse through it which isn't something that can normally be done.


For a 30x30 map, this is what your events would look like without Common Events. "New Map ID" is a hard-coded value of the Map ID that you are transferring to.

Top Edge

* Comment: <TriggerDistance: x99>
* Control Variables: #0001 Map ID = New Map ID
* Control Variables: #0002 Map X = Map X of Player
* Control Variables: #0003 Map Y = 29
* Transfer Player: {Map ID} ({Map X}, {Map Y})

Bottom Edge

* Comment: <TriggerDistance: x99>
* Control Variables: #0001 Map ID = New Map ID
* Control Variables: #0002 Map X = Map X of Player
* Control Variables: #0003 Map Y = 0
* Transfer Player: {Map ID} ({Map X}, {Map Y})

Left Edge

* Comment: <TriggerDistance: y99>
* Control Variables: #0001 Map ID = New Map ID
* Control Variables: #0002 Map X = 29
* Control Variables: #0003 Map Y = Map Y of Player
* Transfer Player: {Map ID} ({Map X}, {Map Y})

Right Edge

* Comment: <TriggerDistance: y99>
* Control Variables: #0001 Map ID = New Map ID
* Control Variables: #0002 Map X = 0
* Control Variables: #0003 Map Y = Map Y of Player
* Transfer Player: {Map ID} ({Map X}, {Map Y})

Like I said earlier, these calls could be condensed with Common Events for each of the four transfers. Then all you'd need is to store the New Map ID where you want to go and the Common Event for that edge could do the rest. Here is an example of the top transfer common event you could use. The others would look very similar like the examples above for the different edges.

Common Event: Top Transfer
* Control Variables: #0002 Map X = Map X of Player
* Control Variables: #0003 Map Y = 29
* Transfer Player: {Map ID} ({Map X}, {Map Y})

Then your event at the top of the page would look like this.

* Comment: <TriggerDistance: x99>
* Control Variables: #0001 Map ID = New Map ID
* Common Event: Top Transfer


Two warnings, though. You can transfer to the edge of the next map like I have in the example but if the player takes a step along the edge after they arrive, they'll transfer back (assuming that map is set up the same way). You might want to place them one step in from the edge to avoid this as it may be a tad confusing. The other is that I don't really know what will happen if you trigger overlapping events. The corners, which you would only be able to get to with diagonal movement, will have two transfer events. I don't know where those will take you since you'd have two transfers trying to execute.

Let me know if I didn't explain this well enough. It's pretty simple really. I hope I didn't make it sound more confusing than it is.
 
Last edited:

Draciel

Black Turtle
Veteran
Joined
Nov 30, 2017
Messages
34
Reaction score
27
First Language
Slovak
Primarily Uses
RMMV
Hi, I have problem... I will try to explain somehow, hope it makes sense!
So, if I add for example ladder down tile and I want it accesible only from left side, there are rails from other sides and direction movement is allowed only from the left.. All is cool and working...
But when I turn your plugin on and DO NOT add any comment, when I try to go to ladder from right side it will teleport me down...
Soooo, your plugin somehow enable player touch from forbidden direction or something... Hmhm somehow system thinks you touch the event by attempting to enter tile, even if you can't...
I tried Yanfly region restriction and it still teleport -> event, player touch, below characters -> then I place restricted region on top, so there should be no way how to activate it, but attempting to enter this tile will activate it anyway..

OK, did my best, hope it makes sense atleast little :)
 

Frogboy

I'm not weak to fire
Veteran
Joined
Apr 19, 2016
Messages
1,691
Reaction score
2,188
First Language
English
Primarily Uses
RMMV
I'm not quite understanding you. Can you show me some screen snapshots of your map and event so that I can try to replicate your issue? And are there any other plugins you are using that may alter the way player touch triggers work?

Edit: Never mind. I see what you mean. It appears that you are triggering a touch of a solid object because the walkability is turned off for that direction. I will have to investigate how the engine handles this and update the plugin accordingly. There is likely a check happening that covers this situation that I didn't notice when I developed this plugin and never even thought to test for this. Thanks for bringing this to my attention. I will post an update to the plugin once I have a fix.
 
Last edited:

Draciel

Black Turtle
Veteran
Joined
Nov 30, 2017
Messages
34
Reaction score
27
First Language
Slovak
Primarily Uses
RMMV
Thanks, glad it makes sense after all :)
Few questions - I should probably test it myself, but its simple, so why not...
1. will this work? <TriggerDistance: walk x5 y2> create 11x5 area with main event at the middle
2. are moving events OK?
3. what will happen if 2 events collide? this is mostly for moving events, like people moving around with r2 parameter or something...
4. can dummy events copy Notetags? I'm thinking about moving line of fire with only 1 event, long graphic and x(y) tag. And player cant jump over it, so I will need notetag (yanfly smart jump).

ok thats it, no problem if it isnt possible, I just think about some crazy stuff and have to ask :)
 

Frogboy

I'm not weak to fire
Veteran
Joined
Apr 19, 2016
Messages
1,691
Reaction score
2,188
First Language
English
Primarily Uses
RMMV
1. This won't work the way you're thinking. The X and Y conditions go in straight lines so if you include both, it should apply them both but you'll get a cross as opposed to a square. The radius option was intended to be the one used as a "distance from". This isn't a square, though, as the corners would be farther away than the sides. It's something that I could likely add if it's something that would be useful to people.

Edit: Version 1.2 changes the behavior of including both X and Y. Now it covers square or rectangle which is probably more intuitive.

2. Moving events should work just fine. Every time a step is taken, the plugin code runs and calculates the distance from where the event is currently at so the range will move with the event even if you transfer the event to new location.
3. That's a good question. I haven't really tested it out yet. I'm assuming that it'll work the same as if you had two player touch events on the same square (which can only be done by transferring one on top of another). I think it'll fire both but depending on what's in those events, everything much not work perfectly. You can only reserve one common event per frame so there's a chance that it may only fire one one common event off even if there's more. It might not, though. I'll do some testing when I get a chance.
4. If I understand you correctly, no. The comment that makes these events a ranged trigger touch has to be on the event that fires it as the plugin uses the event it's attached to determine it's location and distance away from the player. It can be an invisible event but it can't be an event sitting elsewhere that triggers other events. You might be able to get creative and have the triggered event flip some switches and/or set some variables and then run a common event that does whatever you're doing in a more dynamic way.

Just keep in mind that this only works for player touch triggers. It's not set up for Event touch triggers. That's something I plan to look into adding in a future update.

Edit: Version 1.2 now supports Event Touch Triggers.
 
Last edited:

LeeAceSan

Veteran
Veteran
Joined
Jan 8, 2018
Messages
54
Reaction score
31
First Language
French
Primarily Uses
RMMV
Great plugin ! Thank you :)

I need it for

Just keep in mind that this only works for player touch triggers. It's not set up for Event touch triggers. That's something I plan to look into adding in a future update.
In fact, I need this option to make enemy die if they touch the radius event, so I will wait for your next update :D

:popcorn:
 

Frogboy

I'm not weak to fire
Veteran
Joined
Apr 19, 2016
Messages
1,691
Reaction score
2,188
First Language
English
Primarily Uses
RMMV
Thanks! I'm trying to finish up a new plugin at the moment but I do need to come back to this one to fix a small issue. I'll look deeper into making Event Touch work. It runs through completely different code for that but it might still be pretty easy to implement.
 

Canini

Veteran
Veteran
Joined
Mar 29, 2016
Messages
1,025
Reaction score
685
First Language
Swedish
Primarily Uses
RMVXA
Great plugin, saves me so much time. I am working with another system that creates a 3D effect. If works really well, but there is a looooot of copy-pasting events evolved. If it could be combined with this event that would save so much time. Going to try it out immediately!
 

Frogboy

I'm not weak to fire
Veteran
Joined
Apr 19, 2016
Messages
1,691
Reaction score
2,188
First Language
English
Primarily Uses
RMMV
I hope it works out for you. It sounds like your need for this functionality is similar to mine when I developed it (sick of wasting time copying and pasting events everywhere). Let me know if there's anything it needs. I'll be doing a little work on it once I'm finished up with the new plugin I'm working on.

Thanks and good luck with your game!
 

Frogboy

I'm not weak to fire
Veteran
Joined
Apr 19, 2016
Messages
1,691
Reaction score
2,188
First Language
English
Primarily Uses
RMMV
@Draciel @LeeAceSan

TriggerDistance has been updated to version 1.2. The bug you found, Draciel, has been fixed. Event Touch Triggers are now supported. And now specifying both the X and Y coordinates will cover a square or rectangular area as opposed to just the two axis (which has very little usefulness). Oh, you can now add in the new parameter combo if you want the Trigger Distance to work for both Player Touch and Event Touch.
 

Draciel

Black Turtle
Veteran
Joined
Nov 30, 2017
Messages
34
Reaction score
27
First Language
Slovak
Primarily Uses
RMMV
Hi, thanks for update! Awesome work. Moving rectangles can become reality now! :LZSevil:

Suggestion... Well, what about 'same priority as player' + 'action triggered'? i have no idea how it works, but it should be very useful, too. Like I want my hero to have some comment about his big house when you press action button facing it... Putting events all around the house and then updating/erasing them all for one comment seems little stupid.. :)
 

Frogboy

I'm not weak to fire
Veteran
Joined
Apr 19, 2016
Messages
1,691
Reaction score
2,188
First Language
English
Primarily Uses
RMMV
That might be trickier than it sounds. It's something I can look into. You could achieve something similar right now with the Player Touch either by placing it so that the area covers one step around the house and the player steps on it or it could just cover the house and it'll fire if the player bumps into it.

Just know that this stuff is pretty tricky to get to work correctly without unwanted side effects. There's actually still two minor glitches that I haven't been able to fix and probably can't without re-writing how the engine handles a thing or two. I'm trying to avoid that because it raises the chances that it would cause conflicts with other plugins.
 

ItsAlterity

Mirroraculous Developer
Veteran
Joined
Feb 13, 2018
Messages
65
Reaction score
132
First Language
English
Primarily Uses
RMMV
Alright, this is pretty amazing! Literally this actually got me an idea of a mechanic to implement for my own game, and I already know multiple other ways this could be used otherwise. Question though, what's the difference between x1 y1 and say r1, I don't really understand the difference these options bring
 

Draciel

Black Turtle
Veteran
Joined
Nov 30, 2017
Messages
34
Reaction score
27
First Language
Slovak
Primarily Uses
RMMV
x1 y1 and say r1
if E is event and O is operational field, then x1 y1:
O O O
O E O
O O O
aaaand r1:
__O
O E O
__O

(i know it looks stupid.) but probably make sense :)
 

Frogboy

I'm not weak to fire
Veteran
Joined
Apr 19, 2016
Messages
1,691
Reaction score
2,188
First Language
English
Primarily Uses
RMMV
The difference is Radius (r) vs Rectangle (xy). See the initial post for a graphical representation. Make sure the images load. Sometimes they don't.

Edit: Ninjaed. Thanks @Draciel. You're description was better than mine. :p

@ItsAlterity Thanks for the support. This was my first plugin release and in my opinion, probably the most useful one in everyday development. It didn't take long for me to realize that duplicating events was terrible.
 
Last edited:

LeeAceSan

Veteran
Veteran
Joined
Jan 8, 2018
Messages
54
Reaction score
31
First Language
French
Primarily Uses
RMMV
What ? You did it !? Oh my gosh, thank you so much Frogboy :o:thumbsup-right:

I will try this, thanks again dude ! :D

Edit : I'm not able to do what I want ^^
I want to make my enemy die if he enter in the radius.
Please :D I will be so happy if it's work.
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

--Turn Based Battles--

Hero:
Look, it is Minotaur!
M. Knight: Let's go attack it!
Hero: Wait, no, it is just standing there!!
HUD Display: It is M. Knight's turn.
(M. Knight attacks Minotaur)
HUD Display: It is Minotaur's turn.
Hero: (Facepalms) Now look what you did! You made the Minotaur attack us!
Randomly deciding to create some tombs/sarcophagi last minute is probably not the best choice in a timed game jam...
There are only a few days left in our Spooktober Spooktacular Game Jam! Hope you are working hard to get your game in!
Where do i have to play Heisei Pistol Show the same creator that made Re: Kinder Parun
I really get the feeling I should be doing regular YouTube videos whenever I make something cool in my game, instead of waiting for massive changes. But not going to lie... I always feel like it's never quite enough to merit an update, until it's a drastic change. :kaoswt:

Forum statistics

Threads
104,558
Messages
1,007,132
Members
136,040
Latest member
Nicoh
Top