I made a little event that calculates a triangle field of vision for npcs, but its kinda long and unefficent. So i was hoping to get some help making my code more efficient, shorter, or learning alternative methods of handling this problem(I prefer not to use plugins).
This is how the code looks, it basically checks, when the event is looking to the right, if the player is on the specific tiles:
Code:
◆If:Script:$gameMap.event(this._eventId).direction() === 6
◆If:Script:[$gameMap.event(this._eventId).x+1, $gameMap.event(this._eventId).x+2, $gameMap.event(this._eventId).x+3, $gameMap.event(this._eventId).x+4, $gameMap.event(this._eventId).x+5, $gameMap.event(this._eventId).x+6].contains($gamePlayer.x) && [$gameMap.event(this._eventId).y-1, $gameMap.event(this._eventId).y, $gameMap.event(this._eventId).y+1].contains($gamePlayer.y)
◆Jump to Label:jump
◆
:End
◆If:Script:[$gameMap.event(this._eventId).x+3, $gameMap.event(this._eventId).x+4, $gameMap.event(this._eventId).x+5, $gameMap.event(this._eventId).x+6].contains($gamePlayer.x) && [$gameMap.event(this._eventId).y-2, $gameMap.event(this._eventId).y+2].contains($gamePlayer.y)
◆Jump to Label:jump
◆
:End
◆If:Script:[$gameMap.event(this._eventId).x+5, $gameMap.event(this._eventId).x+6].contains($gamePlayer.x) && [$gameMap.event(this._eventId).y-3, $gameMap.event(this._eventId).y+3].contains($gamePlayer.y)
◆Label:jump
◆Play SE:Bell3 (15, 150, 0)
◆
:End
◆
:End