Detect Cone in front of Player

Accidentally posted this over in VX, yesterday. Whoops! Just gonna copypaste. I'm a klutz. This is an MV issue.

I'm creating a game where the player carries a flashlight. I want to have things react to the flashlight being shined on them, but I'm not sure how to do that. I assume it would involve using JavaScript, detecting a cone (at least, the squares necessary to make something cone-like) in front of the player, and... something happens. Certain actors will take damage (moving enemies in the overworld), items may appear, etc.

I know I managed something of the sort on VX Ace years ago, but that was a completely different language. Any help on figuring this out would be appreciated.
You could have just asked a moderator to move the original post and explain why you want to move it.
Not sure if this is what you want, but you can use parallel event to detect player position and check if it's infront of the object, while condition is that the flashlight must be on. It's a trick to achieve what you want... but not exactly dynamic.
I'm currently using a system like that. I have it set up to detect two spaces in front of the player. It... works, but I'm worried it may have issues down the line.
To make it more flexible, you can do this:
Make common events about what to do when light shines upon specific objects.
Then on the map, make one event so that many events don't occupy the map and reduce chances of having events there. On that event make conditional branches, like if player position is x,y then check player position. If player is facing the object, then call common event. You can set wait option so that it doesnt happen again and again.

Original thread: https://forums.rpgmakerweb.com/threads/detect-cone-in-front-of-player.103394/