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.
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