Need help blocking event line of sight!

Hi there, first post here.

I'm working on a project featuring a line of sight-function for events. I tried going about this with switches and variables and ended up with lots of parallel processes containing lengths upon lengths of conditional branches, causing lag as well as general madness on my part.

So I stumbled upon this: http://forums.rpgmakerweb.com/index.php?/topic/3452-direction-based-line-of-sight-events/ , and applied 2) Basic Line of Sight Event to the monsters roaming my maps. It's so simple and it works like a charm, kudos to The Infamous Bon Bon!

This is my Event (script is written out in comments): 

HelpTopic1 - 3.jpg

Self Switch A activates pg.2, the event's chase mode.

I'm looking for a similarly intuitive way to block the line of sight of an event if there's a certain region ID assigned to one of the tiles in between the player and the event.

Explanatory graphics: 

HelpTopic1 - 1.jpg HelpTopic1 - 2.jpg

I've tried rifling through some advanced stealth scripts available online, but I can't seem to make sense out of the relevant parts of them.

Grateful for any tips or pointers toward older topics regarding this problem, or corrections if I'm somehow misbehaving in accordance to the forum rules.

Peace out!

EDIT: swapped the first image (event page) for a better one.
Progressive check:

For an event with a line of sight of 4 tiles long, facing to the left:

  • Store your event's position😛 = (5,3)
[*]Loop four times:
  • Move P's coordinates in the corresponding direction (since it's facing left, subtract 1 from X)😛.x -= 1
[*]Check for the region ID of the tile at position P
  • If it's an obstacle region ID, then break the loop and report no findings.
[*]Check if the player is at position P
  • If yes, break the loop and report a find.
I'm getting the gist of what you're saying, but since I know squat about how to formulate scripts I'm getting nowhere with this. But I've been trying:

 

I added 4 conditional branches within the ones I already had (as seen in my previous post) dependent on which direction the event is facing. Within each of them I'm trying my best to add yet another conditional branch, containing a script. This is what I've come up with so far:

 

 

I.e. The conditional branch for "This Event is Facing Left" holds a conditional branch with the following "script"...

 

P = ($game_map.events[@event_id].x, game_map.events[@event_id].y) && 3_loop.times {P.x -= 1 && $region_id(P.x, P.y) == !1}

 

...containing a "Self Switch A = ON" command.

 

 

You might have noticed I haven't really got a clue what I'm doing here.

 

Anyway, what I'm attempting is for the event to scan each tile in between the player and the event (which = a maximum of 3 if the event's sight range = 4), and, if none of them are marked as Region ID 11, Self Switch A flips, initiating the event's chase mode. Another problem I'm suspecting is that, if it actually worked, my line of script would be scanning x amount of tiles behind the event, whenever the player was less than 4 tiles away. Wouldn't want that either.

 

EDIT: Typos

Original thread: https://forums.rpgmakerweb.com/threads/need-help-blocking-event-line-of-sight.24061/