Could you try this in a parallel common event
JavaScript:
$gameMap.events().forEach(event => {if (event.meta.enemy)
$gameMap.eventsXy(event.x, event.y).forEach(shared => {if (shared.meta.trap) $gameSelfSwitches.setValue([$gameMap._mapId, shared._eventId, 'A'],true);})});
And put Wait: 5 frames at the end
Put <enemy> tags in your enemy event noteboxes and <trap> tags in your traps.
Thank you for this!
This script call didn't work for me to be fair but it helped me with the use of ChatGPT to find the solution for it after some tries.
This is the script that worked for me but it change the self switch of only 1 of the 2 events:
// Script for handling events with the <trap> tag
$gameMap.events().forEach(event => {
if (event.event().meta.trap) {
$gameMap.eventsXy(event.x, event.y).forEach(shared => {
if (shared.event() && shared.event().meta.enemy) {
$gameSelfSwitches.setValue([$gameMap._mapId, shared._eventId, 'A'], true);
}
});
}
});
So to change the enemy self switch in the common event I added another script with the same formula but with different stracture:
// Script for handling events with the <enemy> tag
$gameMap.events().forEach(event => {
if (event.event().meta.enemy) {
$gameMap.eventsXy(event.x, event.y).forEach(shared => {
if (shared.event() && shared.event().meta.trap) {
$gameSelfSwitches.setValue([$gameMap._mapId, shared._eventId, 'A'], true);
}
});
}
});
If there is a way to do it in 1 script that will be better but this way worked for me.
This can open for me and many other game maker a sea of ways to create events, game mechanics and puzzels.
I didn't try it yet with spawn event plugin, I will try that and give updates if it work or didn't.
Edit: Spawned event didn't work but I remember when I showed your script to chatGPT and tell it it didn't work they suggested some possible reasons of the problem, one of them is this.
"Event Initialization Order: Make sure that the common event with the script call runs after the events are initialized on the map. If the common event runs before events are placed on the map, it won't find any events to check."
So because spawned events are for sure spawned on the map after the paralell common event with the script it didn't work, this could be also the same reason why the plugin didn't work?