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.
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
本贴来自国际rpgmaker官方论坛作者:bomblord处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:
https://forums.rpgmakerweb.com/threads/line-of-sight-plugin.69069/