Request: Specific event trigger event?

Hello 😀

I'm making a fire projectile, and it needs to be stopped when boulder blocks the way. Sounds simple, but that boulder will be in a random location. I could store his position in 2 variables (X and Y), but the thing is, I have about 30+ boulders that needs to work the same way and all appears at different locations each time. I think that making a trigger when hit by the flame would be way easier. So I ask you guys to help me 😛

If you need more info, please say so! I will explain other details if needed.
Thank you! 😀
you can still do it with events. Is your fire projectile an event? After each move, do a conditional branch to see if $gameMap.eventsXyNt(x, y).length > 1. Pass in the event's x and y positions. That will return an array containing all the events at that location. One will be the projectile. If there are more than 1, the other will be a boulder. Or if you have more than just the boulder events, you can give all the boulders the same name, then look through the array to see if any of the events at that location are called 'boulder'.
@Shaz Where should I put the array? There are other events and would need to use the name "Boulder" to execute the commands. Thanks for the tip
I'm at work and don't have MV with me, but I'll give you a script call to try, and HOPEFULLY it'll work. I'll check when I get home this afternoon to see how you went.

Let's assume you have switch 20 spare, and we'll turn that on if the projectile is on the same tile as an event with the name Boulder. Put the following into a script call:

Code:
var evt = $gameMap.event(this._eventId);
var evts = $gameMap.eventsXy(evt.x, evt.y);
var boulder = evts.length > 1 && evts.filter(function(e) { return e.event().name === 'Boulder'; }).length > 0;
$gameSwitches.setValue(20, boulder);

I think that'll work. It's getting the current event, then getting a list of events at the same location as the current event, then it's checking to see if there's more than one event in that list and if any of them are called 'Boulder'.

If you get an error, hit F8 and take a look at the console log (screenshot & post it here if you can't figure it out). If it doesn't like the function called filter, replace it with select. I still get those two confused between JS and Ruby.

The whole thing could be compressed into a single line that you could put into a conditional branch, but I figured a script call with the logic separated might make it easier to follow/debug.


Edit: changed eventsXyNt to eventsXy as the Nt version ignores events with a Through flag, and we want to know about ALL events.
@Shaz Did some testing. it works as planned, but the fact that the flame opens up a switch is kind of a problem (realized it during testings). From the way I set that up, when the flame touches a `boulder, it would open up the switch 6. When that switch is up, the targeted boulder is supposed to blow up, then turn the switch off...

As you might've guessed, when the switch is ON, it destroys all boulders on the map, since they are all binded to that switch
Maybe I did wrong, but would give me some more tips please 😛
Thank you for that help 🙂
A switch affects all events. A self switch only selects the current event.

Change it to this (again, sorry - I'm at work so don't have MV, and I'm not quite as familiar with this ... so there might be issues):

Code:
var evt = $gameMap.event(this._eventId);
var evts = $gameMap.eventsXy(evt.x, evt.y);
var boulder = evts.length > 1 && evts.filter(function(e) { return e.event().name === 'Boulder'; }).length > 0 ? evts[0]._eventId : 0;
if (boulder > 0) {
  $gameSelfSwitches.setValue([this._mapId, boulder, 'A'], true);
}

Now, change all events so the "blow up" page is conditioned by Self Switch A rather than switch 6. This means only that particular event will go to that page. On that page, do the "blow up" but don't turn the self switch back off - unless you want to make it reappear. Or you could turn it back off and do an Erase Event, if you wanted it to reappear next time the player comes to the map.
@Shaz Did some testings. It works as intended! Thank you! Good work and have a good day! 😛

Original thread: https://forums.rpgmakerweb.com/threads/request-specific-event-trigger-event.74662/