Need Help with a Mechanic

So I'm working on a small, simple horror game, and the main mechanic is that the monsters only appear when you're pointing your flashlight at them, so you'll have to always keep an eye out. You can see the walls and trees and stuff in the shadows, but no monsters.


I'm using the Khas Awesome Lightning script, where the flashlight beam is an image. Would it be possible to make the enemy events appear while the image is touching them? Is there another way to make the monsters appear only in the flashlight beam? I think it's an interesting mechanic, but I'm not sure how to do this.
I guess you could do a conditional branch to see if the player is facing that direction, and if the switch activated by turning on the flashlight is on. Like, set it so that when you turn on the flashlight, it activates a switch, and then do "player is facing ___" in conditional branches. 
How many blocks does your flashlight cover? We'll assume 2 in front of the player.


Parallel process. Take the players X/Y. If the X or Y is equal to the X/Y of an enemy, check the facing of the player. Then, compare the X/Y value of player to enemy. If the axis that is equal is within +2/-2 (depending on the facing), then show the enemy via a switch, variable, whatever floats your boat.
How many blocks does your flashlight cover? We'll assume 2 in front of the player.


Parallel process. Take the players X/Y. If the X or Y is equal to the X/Y of an enemy, check the facing of the player. Then, compare the X/Y value of player to enemy. If the axis that is equal is within +2/-2 (depending on the facing), then show the enemy via a switch, variable, whatever floats your boat.



I'm not the best at scripting/variables/whatever you'd use for this, how exactly would I go about doing this?
Create an event as a parallel process, that means that it's going to check this events parameters repeatedly.


Then, you'd want to store the players X and Y values as variables, which can be done from control variables. Afterwards, you'd store the variables for the Enemy events in the same way, but using different variables.


The key thing here, is that if the player isn't near an enemy, you don't wanna be doing all these various math checks, because it could slow down the game (hypothetically). So, you can quickly tell if the player is near an enemy by seeing if they share any common axis. If they both have a Y axis of 4, for example, then you know that the player could hypothetically be "within range." But if they share no common axis, then they aren't going to be able to see them, obviously.


BuJXlTr.png



So, to recap: If Player X is = to Enemy_Event X, check which direction the player is facing. If they're facing Left, you'd subtract PlayerX from EnemyX and want it to be within a certain range (within -2, or +2, can't remember which facing it is). Do the same with the Y, and for every enemy. Short of building a demo this is as clear as I can be, unfortunately.

Original thread: https://forums.rpgmakerweb.com/threads/need-help-with-a-mechanic.68993/