Need help with line of sight

In the game I'm making, I wanted to have a stealth mechanic. Enemies would have a line of sight they could see the player in, and most importantly. Not see through walls or other specific objects. I have been unable to find a plug in or resource that does this effectively. They all either don't work, or can only see a single line. I used the line of sight by TheOdie link here for the first part of just having an area of detection. But, I've been unable to find anything on how that line of sight could be blocked by certain objects.

Something that has certainly held me back is my lack of knowledge on javascript. However, I wouldn't know what I need to learn to make this work. And learning javascript from scratch sounds very tedious.

I'm hoping someone can help me to get this all working as I've tried everything else I can think of. Below is my current code.
JavaScript:
◆Control Variables:#0002 Goon1 = 3
◆Control Switches:#0002 InGoonAura1 = OFF
◆If:Script:$gameMap.event(this._eventId).direction() == 2 && $gameMap.event(this._eventId).y < $gamePlayer.y || $gameMap.event(this._eventId).direction() == 8 && $gameMap.event(this._eventId).y > $gamePlayer.y || $gameMap.event(this._eventId).direction() == 4 && $gameMap.event(this._eventId).x > $gamePlayer.x || $gameMap.event(this._eventId).direction() == 6 && $gameMap.event(this._eventId).x < $gamePlayer.x
  ◆If:Script:Math.abs($gamePlayer.x-$gameMap.event(this._eventId).x) < Math.abs($gamePlayer.y-$gameMap.event(this._eventId).y)
    ◆If:Script:Math.abs($gamePlayer.x - $gameMap.event(this._eventId).x) <= $gameVariables.value(2)
      ◆If:Script:Math.abs($gamePlayer.y-$gameMap.event(this._eventId).y) <= Math.round( Math.sqrt(Math.pow($gameVariables.value(2),2) - Math.pow($gamePlayer.x - $gameMap.event(this._eventId).x, 2)) )
        ◆Control Switches:#0002 InGoonAura1 = ON
        ◆
      :End
      ◆
    :End
    ◆
  :Else
    ◆If:Script:Math.abs($gamePlayer.y - $gameMap.event(this._eventId).y) <= $gameVariables.value(2)
      ◆If:Script:Math.abs($gamePlayer.x-$gameMap.event(this._eventId).x) <= Math.round( Math.sqrt(Math.pow($gameVariables.value(2),2) - Math.pow($gamePlayer.y - $gameMap.event(this._eventId).y, 2)) )
        ◆Control Switches:#0002 InGoonAura1 = ON
        ◆
      :End
      ◆
    :End
    ◆
  :End
  ◆If:InGoonAura1 is ON
    ◆Show Balloon Icon:This Event, Exclamation (Wait)
    ◆
  :End
  ◆
:End
1745702115265.png

1745702153222.png

Sounds exactly like what you need. (unless your events somehow have 360 degrees line of sight.)
View attachment 338756
View attachment 338757
Sounds exactly like what you need. (unless your events somehow have 360 degrees line of sight.)
Thank you for recommending this too me! However, I managed to find something else that worked. The yanfly event chase player plug in plus Caethyril's line of sight plug in. But, I have another question. You wouldn't happen to know how one would make an event trigger another event to chase the player would you?
Not sure why you would prefer to use 2 separately made plugins, when there's one that does both. And I'm not sure why I'd know the answer to your question when you're not using the solution I provided, but I guess you could just use your event to turn on a switch in the chasing event.

Original thread: https://forums.rpgmakerweb.com/threads/need-help-with-line-of-sight.177246/