"Line Of Sight" plugin

After some googling I couldn't find an existing one of these for my project so I built one myself. After getting a lot of help on this forum I decided to share it. It's a fairly simple plugin but it works.

I've attached the plugin and will provide some basic instructions on use. I'm hoping to fix any bugs that crop up as I use it more extensively.



What it does


Allows any event to react if the player walks with their "line of sight" this also is obscured by impassable objects making it possible to do stealth sections.

capturewfsq5.png


The line of sight is 1 block wide and extends in all 4 directions around the set event. I allow you to set a limit on length and direction (ex you only want it be able to see 5 tiles out to the right you can do that)

How to use

To use simply load the file in the plugin manager and then put the following line of code in your event (and set the event to parallel process). To attach the code use the "script" button on the bottom right of the third page.


lineOfSight(5, this._eventId, this._mapId, "auto");


The first variable is the number of tiles away you want the event to be able to see the player (I arbitrarily have it set to 5) any positive number will work though.
The second variable is the event Id. this._eventId will automatically set it to the event it is being called from.
The third variable is the mapId of the event this._mapId will auto set it to the correct map
Last is the direction you want the line of sight to work in possibilities are "up" "down" "left" "right", "all", and "auto"


Auto will set it to whatever direction the event is currently facing


All will set to check every direction.

When the player is seen it sets event self switch A to on. So create your logic around that.

To Do
Potentially fix bugs

Terms Of Use


I'm not fond of legal mumbo jumbo if you want to use this in any project be it free, commercial, or anything else I don't require anything in return in any capacity. No need to credit either (but if you want to that is fine as well).

If you use it please let me know how it works!
 


View attachment lineofsight.js
Seeing as you have a finished version, I'm going to move this to Plugin Releases. You can still continue to improve/debug it there.
Seeing as you have a finished version, I'm going to move this to Plugin Releases. You can still continue to improve/debug it there.


Thanks, guess I should add a terms of use.
it didnt work to me , i am not sure what problem is . feel sad  ;_;
it didnt work to me , i am not sure what problem is . feel sad  ;_;

Sure just a few things to help you troubleshoot



How are you calling it?
What is happening?
What did you expect to happen?

Screenshots of the event screen would help.
tt works fine, but once the enemy event "see" the player it wont stop chasing, and because of that they get stuck in map. and if you could make the line of sight more of a cone it would be awesome.


but then again i've been using RMMV just for a week so my knowhow is limited at best and i may be doing it all wrong
how can i put a timer so after the enemy wants to chase me will stop after 10 seconds
everything works great but I have a new problem that I would love if someone here how to handle.
I set the line of sight as lineOfSight(3, this._eventId, this._mapId, "auto"); and it works perfectly but after the event walks up to me and teleports me (everything works as intended), I set a script call to bring him back that looks like this: $gameMap._events[12].moveStraight($gameMap._events[12].findDirectionTo(18, 15))
BUT, here's the problem. When the event goes back to that position, he only goes back by 1 tile, 1TILE! If anyone knows how to expand the amount of tiles I would be so grateful.
I know this is probably necro, but not sure where else to post.
everything works great but I have a new problem that I would love if someone here how to handle.
I set the line of sight as lineOfSight(3, this._eventId, this._mapId, "auto"); and it works perfectly but after the event walks up to me and teleports me (everything works as intended), I set a script call to bring him back that looks like this: $gameMap._events[12].moveStraight($gameMap._events[12].findDirectionTo(18, 15))
BUT, here's the problem. When the event goes back to that position, he only goes back by 1 tile, 1TILE! If anyone knows how to expand the amount of tiles I would be so grateful.
I know this is probably necro, but not sure where else to post.

ALREADY FOUND THE ANSWER I'M AN IDIOT THERE'S A SET EVENT LOCATION OPTION...
Oh gosh, there is a plugin for every thing I might need in my game!
Thank you 🙂
I've tried it but nothing is happening for mine. Not usre what I did wrong. I have it set like it is in the example. Except instead of 5 I did 6 and I'm using the script to call upon it. Using Parallel process too.
i'm pretty sure the plugin is working fine, but how to i get an event to move after it's seen me?
Thanks for sharing

It work great on one of my npc, I copy the exact set up and paste it in the same map as second npc.

the script stop working on my npc 2 but still working on my npc 1.

is there a way to make both npc work? or am I missing something?

thanks
Is there a way to increase the width of the line of sight? I want to have the event look down a hallway that's 3 tiles wide.
After some googling I couldn't find an existing one of these for my project so I built one myself. After getting a lot of help on this forum I decided to share it. It's a fairly simple plugin but it works.

I've attached the plugin and will provide some basic instructions on use. I'm hoping to fix any bugs that crop up as I use it more extensively.



What it does


Allows any event to react if the player walks with their "line of sight" this also is obscured by impassable objects making it possible to do stealth sections.

capturewfsq5.png


The line of sight is 1 block wide and extends in all 4 directions around the set event. I allow you to set a limit on length and direction (ex you only want it be able to see 5 tiles out to the right you can do that)

How to use

To use simply load the file in the plugin manager and then put the following line of code in your event (and set the event to parallel process). To attach the code use the "script" button on the bottom right of the third page.


lineOfSight(5, this._eventId, this._mapId, "auto");


The first variable is the number of tiles away you want the event to be able to see the player (I arbitrarily have it set to 5) any positive number will work though.
The second variable is the event Id. this._eventId will automatically set it to the event it is being called from.
The third variable is the mapId of the event this._mapId will auto set it to the correct map
Last is the direction you want the line of sight to work in possibilities are "up" "down" "left" "right", "all", and "auto"


Auto will set it to whatever direction the event is currently facing


All will set to check every direction.

When the player is seen it sets event self switch A to on. So create your logic around that.

To Do

Potentially fix bugs

Terms Of Use


I'm not fond of legal mumbo jumbo if you want to use this in any project be it free, commercial, or anything else I don't require anything in return in any capacity. No need to credit either (but if you want to that is fine as well).

If you use it please let me know how it works!



View attachment 48888
I don't suppose there's anyway to stop the enemy from chasing you after a certain point

Original thread: https://forums.rpgmakerweb.com/threads/line-of-sight-plugin.69069/