checking if events are in front of an event conditional..

hello, im a little unsure if this is better off in plugins or not.

my situation is that i have enemies wandering around in a puzzle room with multiple events pushed around by the player to complete the puzzle etc. when one is has been moved in front of the enemy and it cannot progress its normal path, i want its behavior to change when the player then interacts with it (basically, it will get mad at you for putting something in the way)

i havent quite been able to figure it out esp as i have multiple events i want to be able to trigger it. i want it to still be able to have its usual behavior when it touches the player normally too.

i tried a few things but couldnt get them to work in my specific situation. sorry if this is an obtuse question ^^;;
This could get a little complicated. You would have to put a conditional in the event's move route where every time it moves, check if a <block> event is in the tile in front of it. If so, toggle a self switch to a different event page where if you interact with the event, it shows the angry message.

This plugin will let you put conditional statements in a move route, but the statement would be a little complex.
It depends on what blocking it does. If it just stops the boss in its tracks so it's stuck facing the blocking tile, then you can do it with one Script event command.

Code:
let event = $gameMap.event(this.eventId());
let x = $gameMap.roundXWithDirection(event.x, event.direction());
let y = $gameMap.roundYWithDirection(event.y, event.direction());
$gameSwitches.setValue(69, $gameMap.eventsXy(x, y).some(block => block.event().meta.block));

That will make game switch 69 be ON if the boss is facing a tile that has an event with the notetag <block>

You could do without the game switch and just shove it all into the Script field of Conditional Branch:
Code:
let event = $gameMap.events(this.eventId()); let x = $gameMap.roundXWithDirection(event.x, event.direction()); let y = $gameMap.roundYWithDirection(event.y, event.direction()); $gameMap.eventsXy(x, y).some(block => block.event().meta.block);
It depends on what blocking it does. If it just stops the boss in its tracks so it's stuck facing the blocking tile, then you can do it with one Script event command.

Code:
let event = $gameMap.events(this.eventId());
let x = $gameMap.roundXWithDirection(event.x, event.direction());
let y = $gameMap.roundYWithDirection(event.y, event.direction());
$gameSwitches.setValue(69, $gameMap.eventsXy(x, y).some(block => block.event().meta.block));

That will make game switch 69 be ON if the boss is facing a tile that has an event with the notetag <block>

You could do without the game switch and just shove it all into the Script field of Conditional Branch:
Code:
let event = $gameMap.events(this.eventId()); let x = $gameMap.roundXWithDirection(event.x, event.direction()); let y = $gameMap.roundYWithDirection(event.y, event.direction()); $gameMap.eventsXy(x, y).some(block => block.event().meta.block);
this code gives error "event.direction is not a function" for me, dont know if im missing something.

i am a little hesitant to try out the previous suggestion if it can be done in a less compelx manner ^^;;
Please show how you actually entered this code, because event.direction() absolutely is a function 😛
ahh, i fixed it!
it just had to be $gameMap.event on the first line rather than $gameMap.events LOL
now i believe it works, thank you 😊

Original thread: https://forums.rpgmakerweb.com/threads/checking-if-events-are-in-front-of-an-event-conditional.167614/