Triggering event touch when player is idle

PresaDePrata

Veteran
Veteran
Joined
Dec 4, 2014
Messages
83
Reaction score
16
First Language
Portuguese
Primarily Uses
RMMV
Hey guys and gals,

I looked in the forum for something similar to this occurrence of mine, but the closest thread i've found was this: https://forums.rpgmakerweb.com/index.php?threads/event-getting-knocked-back.15414/

Which doesn't resolve my issue. So, here it is: how do you trigger an event touch when the event is set to be below player and the player is idle/stationary? The event triggers correctly when the player is moving and the event touches him, but not when he's not moving. Is this the correct behaviour of rpg maker mv event trigger or it's actually an issue?
 

ImaginaryVillain

Now A YouTube Cool Kid! =D
Veteran
Joined
Jun 22, 2019
Messages
421
Reaction score
1,526
First Language
Absurdism
Primarily Uses
RMMV
Create an if statement, and in the script section of it put...
JavaScript:
$gameMap.distance($gamePlayer.x, $gamePlayer.y, $gameMap.event(this._eventId).x, $gameMap.event(this._eventId).y) === 0;
Then put whatever you want it to do when it touches the player inside of the if statement. You'll need to set this event as a parallel, so you'll probably want a wait command in there so the player can respond. If you wish to use another event to do the checking, replace "this._eventId" which the eventId you want to check.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,011
Reaction score
7,023
First Language
German
Primarily Uses
RMMV
Are you sure you have set the event to "event touch"? The behaviour you're describing is the behaviour of the "player touch" trigger, not the "event touch" trigger.
Please show us a screenshot of the event if that is correctly set, because what you describe is not the default "event touch" behaviour.
 

PresaDePrata

Veteran
Veteran
Joined
Dec 4, 2014
Messages
83
Reaction score
16
First Language
Portuguese
Primarily Uses
RMMV
@Andar
Pretty sure. See for yourself in those prints below. You also can create a 2-min project to see this exact behaviour in practice.

(my rmmv is regionalized to Brazil, but the event settings are on the same order and place)




@ImaginaryVillain

Amazing, that actually did the trick and also gave me the opportunity to use event above with touch, which was something i was begin to think i had to create a plugin. Thank you!

As a side note, aren't parallel events "dangerous" to use since it keeps searching for the condition on every tick instead of being an observer that when triggered will execute its code only once? I don't which kind of event listening RMMV has implemented but after some tests of mine with parallel events, i rapidly discarded them since they can be become easily a memory black hole or even freeze the game.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,011
Reaction score
7,023
First Language
German
Primarily Uses
RMMV
As a side note, aren't parallel events "dangerous" to use since it keeps searching for the condition on every tick instead of being an observer that when triggered will execute its code only once? I don't which kind of event listening RMMV has implemented but after some tests of mine with parallel events, i rapidly discarded them since they can be become easily a memory black hole or even freeze the game.
yes, parallel processes can produce lag. But there are ways to reduce the lag, for example adding a wait(5) to it - the wait command tells all events "skip processing for X frames", so it reduces lag in parallel processes by having the parallel check less often per second.

A single badly programmed parallel process can lag any game even on the most powerfull machine, but that is because it is badly designed. With a good logic design even an older computer can handle several parallel processes without problems. You just have to take care on how you design them, and not use them excessively.
But they are needed for a number of mechanics, if they were only bad they would not have been included in the event options.
 

ImaginaryVillain

Now A YouTube Cool Kid! =D
Veteran
Joined
Jun 22, 2019
Messages
421
Reaction score
1,526
First Language
Absurdism
Primarily Uses
RMMV
Pretty much what Andar said, as my video shows parallel events aren't bad at all. There are lots of them going to make all of that happen. Programming them properly is the biggest issue. Personally I advise against the wait method of controlling them unless you absolutely have to always have it running. It is far better to either switch them off when not in use, or to spawn them in so they can be simply despawned when not in use. This keeps resources clear for more events.
 

PresaDePrata

Veteran
Veteran
Joined
Dec 4, 2014
Messages
83
Reaction score
16
First Language
Portuguese
Primarily Uses
RMMV
@Andar

Yes, i agree with you. Actually you explained it all with this line

adding a wait(5) to it - the wait command tells all events "skip processing for X frames"
So wait actually interrupts the parallel event. I thought a ton of call were being made, not getting executed by an If statement. I thought parallel events were a promise like structure from JS.

@ImaginaryVillain

So creating another page then switching to it, is actually performance friendlier than set a wait inside the same event page?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,011
Reaction score
7,023
First Language
German
Primarily Uses
RMMV
So creating another page then switching to it, is actually performance friendlier than set a wait inside the same event page?
depends on what it is used for. If you can have a parallel process work only for part of the time, then switching it off is better than using waits. However there are some functions that need the continuous check for all time, where you can't switch them off (for example if it is triggered by a player action and not by another event). In those cases the wait is the only option you have to reduce lag.
For example an event that should mirror player moves - unless you use plugins (which might cause other problems) you can only check for a change in player coordinates to detect when the player has moved. But in those cases you don't need to check sixty times per second because no player can move that fast, a wait(10) which changes that into six checks per second would be OK.
 

ImaginaryVillain

Now A YouTube Cool Kid! =D
Veteran
Joined
Jun 22, 2019
Messages
421
Reaction score
1,526
First Language
Absurdism
Primarily Uses
RMMV
Yes, the reason is because the event is dormant at that point, sure it is occupying a small amount of resources, but it's not executing any of it's commands. If you go with the wait method, it still occupies the same resources a dormant event would, plus the resources to execute it's commands as well. MV can handle an insane number of dormant events with no noticeable resource hit. Hundreds of them in my testing.

Depending on the complexity of the event, it can often be better to switch it to another page that only runs a check to see if something has changed, then turns the switch off to run the event again if it has. This is of course useful if the event in question is doing a lot of checks. Then you are of course just reducing it to one. You can even combine methods and have your page that checks run a wait as well.

Honestly I rarely do any of that anymore unless absolutely necessary though. The spawn/despawn method is far and away the most resource friendly one. One map can literally work with thousands of events that way.
 

PresaDePrata

Veteran
Veteran
Joined
Dec 4, 2014
Messages
83
Reaction score
16
First Language
Portuguese
Primarily Uses
RMMV
@Andar

But in those cases you don't need to check sixty times per second because no player can move that fast, a wait(10) which changes that into six checks per second would be OK.
Fantastic explanation. That solves a lot of performance problems i thought i'd have. Time to use more parallel events :)

Btw, did you test my example? DId you notice that an idle player will not trigger an event touch when it passes below the player?

@ImaginaryVillain

MV can handle an insane number of dormant events with no noticeable resource hit. Hundreds of them in my testing.
Nice, really nice to know this. Is this due to Node.js non blocking event nature? I'm guessing RMMV was made on Node.js.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,011
Reaction score
7,023
First Language
German
Primarily Uses
RMMV
Btw, did you test my example? DId you notice that an idle player will not trigger an event touch when it passes below the player?
not currently, but I made that test a long time ago to determine the difference between player touch (only triggers on player move into an event) and event touch (triggers when the event moves on the player).
Think about it - there would be no need for two different triggers if they behave the same way.

I don't know why it doesn't work that way for you, and I don't have time to test it again searching which plugin or whatever else caused the change.
Is this due to Node.js non blocking event nature?
no, it is due to the way how all RM's handle the event conditions. If the conditions are not true, the entire data is ignored and not processed at all. That has nothing to do with node.js or javascript, it's the way the engine was designed a long time ago (in the Ruby-Variants RGSS to RGSS3)
 

PresaDePrata

Veteran
Veteran
Joined
Dec 4, 2014
Messages
83
Reaction score
16
First Language
Portuguese
Primarily Uses
RMMV
@Andar

Think about it - there would be no need for two different triggers if they behave the same way.
I concur, no use at all. Which is why i thought it was an error or a bug.

I don't know why it doesn't work that way for you, and I don't have time to test it again searching which plugin or whatever else caused the change.
Actually the prints i gave you were with a new and plain clean project. No third party plugins at all. In my project i use about 50 Yanfly's plugins. But i knew it would blur the cause if it was something with RMMV engine. I asked if you tested because you have way more experience in RMMV than i do. And that this knowledge would be good to others in the future.

My issue is solved, i thank you both for your time. You helped more than you imagine.
 

ImaginaryVillain

Now A YouTube Cool Kid! =D
Veteran
Joined
Jun 22, 2019
Messages
421
Reaction score
1,526
First Language
Absurdism
Primarily Uses
RMMV
Excellent, glad we could help. :LZSexcite:
 

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

Latest Threads

Latest Posts

Latest Profile Posts

I based this on the armor of Actor 1_7 of the RTP. Hair is from Derex and Sythian Bard.
Stream will be live shortly! Going to do another art stream tonight so that I can finish my Fauna Focus piece~ Feel free to drop by!
Humans are fallible creatures, we all know that. It's when we're forced to look at ourselves that we start to disagree. :p
Expectation: Working on boss battle.
Reality: "Look at how awful are these code and database organization. Let me clean this mess", *yet, casually adding more modules that I have no idea if I would use it later*
Trying to learn to read Japanese so I read my manga. I like to buy them without all the edits made during translation.

Forum statistics

Threads
97,862
Messages
947,434
Members
129,086
Latest member
mikeymastermind
Top