I want something to happen to a monster event on the map when it's next to events named trap. Event ID's are out of the question as these will be spawned in randomly. So like, if an event with a parallel process running the script is within radius 1 of trap then flick a self switch or set a variable or something. This is what the code looks like right now.
I put variable 13 so it's easy to check. But when the monster event is next to events named trap, nothing changes.
Code:
var trapEvents = $gameMap.events().filter(function(event) { return event.event().name === 'trap'; });
var monster = $gameMap.event(this.eventId());
trapEvents.forEach(function(trap) {
if (monster.x < trap.x + 1 && monster.x > trap.x - 1 && monster.y < trap.y + 1 && monster.y > trap.y - 1) {
$gameVariables.setValue(13, 1);
}
});
I put variable 13 so it's easy to check. But when the monster event is next to events named trap, nothing changes.