Line of Sight/Auras are easy to do and you don't require a plugin to do so. The tutorial contained are in the videos below. Let me know what you think :)
NEW! Circle Line of Sight / Aura Below
Line of Sight / Auras (No Circles)
VIDEO
Copy & Paste Code:
Spotted in Facing Direction (Copy Pasted as 1-Line)
$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
Triangle Vision (Copy Pasted as 1-Line)
Math.abs($gameMap.event(this._eventId).x - $gamePlayer.x) + Math.abs($gameMap.event(this._eventId).y - $gamePlayer.y) <= 3
Line Vision (Copy Pasted as 1-Line)
Math.abs($gameMap.event(this._eventId).y - $gamePlayer.y) <= 3 && $gameMap.event(this._eventId).x == $gamePlayer.x || Math.abs($gameMap.event(this._eventId).x - $gamePlayer.x) <= 3 && $gameMap.event(this._eventId).y == $gamePlayer.y
Box Vision (Copy Pasted as 1-Line)
Math.abs($gameMap.event(this._eventId).y - $gamePlayer.y) <= 3 && Math.abs($gameMap.event(this._eventId).x - $gamePlayer.x) <= 1 || Math.abs($gameMap.event(this._eventId).x - $gamePlayer.x) <= 3 && Math.abs($gameMap.event(this._eventId).y - $gamePlayer.y) <= 1
Easy to read Code (Click to Enlarge):
*Note: Do not copy the code below. Copy the Copy & Paste Code above.
Line of Sight / Auras (Circles)
VIDEO
Use this key image to understand the copy-paste code (Click to enlarge)
A1 & A2 - Aura radius and test in aura respectively
B - Test whether difference in X or Y is smaller. Smaller X goes to Cs, Larger X goes to Ds.
C1 - Test difference in X is less than/equal to radius (A1)
C2 - Pythagorean theorem to solve for Y and test if the difference in Y is less than/equal to radius.
D1 - Test difference in Y is less than/equal to radius (A1)
D2 - Pythagorean theorem to solve for X and test if the difference in X is less than/equal to radius.
E1 & E2 - Tells the event that player is within aura, otherwise the switch remains OFF as in A2.
E3 - When player is in aura, do the following.
Copy & Paste Code
B:
Math.abs($gamePlayer.x-$gameMap.event(this._eventId).x) < Math.abs($gamePlayer.y-$gameMap.event(this._eventId).y)
C1 (Note change [$gameVariables.value(2)] as appropriately):
Math.abs($gamePlayer.x - $gameMap.event(this._eventId).x) <= $gameVariables.value(2)
C2:
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)) )
D1 (Note change [$gameVariables.value(2)] as appropriately):
Math.abs($gamePlayer.y - $gameMap.event(this._eventId).y) <= $gameVariables.value(2)
D2:
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)) )
Easy to read Code (Click to Enlarge):
*Note: Do not copy the code below. Copy the Copy & Paste Code above.
Awesome. As always! Man that's going to make my game CRAZY! <3 Thanks for the tips!
ReplyDelete