Line of sight

I am having a system in my game where the player can do repeatable stealing quests, where you have to sneak into an area and steal something. But I want there to be guards who can see you and attack you. I need a plugin for this, right? Or can I event it? Can someone help me with making all of this work?
I'm wanting to know this too...
Somebody please respond!

EDIT: Sorry for the impatience...
listen. when asking for assistance, have some sort of direction. help us so we can help you; no one wants to take the time and effort to walk you through a method for accomplishing this (or any feature), when you do not have a clear vision of what you are trying to accomplish. if it is obvious that you created this thread with minimal effort (which is it), then why should other people respond with anything more than their minimal effort?

make it convenient for people to respond and you may just be surprised to see how many people help you; tell us exactly what you want so the right people respond, and they can respond with relevant information.

i.e. how do you imagine this system working from start to finish?
listen. when asking for assistance, have some sort of direction. help us so we can help you; no one wants to take the time and effort to walk you through a method for accomplishing this (or any feature), when you do not have a clear vision of what you are trying to accomplish. if it is obvious that you created this thread with minimal effort (which is it), then why should other people respond with anything more than their minimal effort?

make it convenient for people to respond and you may just be surprised to see how many people help you; tell us exactly what you want so the right people respond, and they can respond with relevant information.

i.e. how do you imagine this system working from start to finish?
The player is walking through the area. There are guards walking around. What I want is for a certain line of sight for them - maybe 5 squares - and when the player steps on one of those squares, the guard walks up to you - actually that bit about walking up is not necessary, but I would like that - and he says something like "Trespassers do not go unpunished!" or "Surrender, criminal!". Then a battle occurs. If the player loses, game over. Otherwise, the guard dies (so the event disappears) and the player can continue walking. It is somewhat like Pokémon, where the trainers walk around (not all of them walk around, but some do) and when one sees you, a battle occurs.

How would I go about doing that?
By default, this cannot be done. The only way to even come close is Yanfly's Event chase player script, and the line of sight does go through walls. But if you design your areas with that in mind, you can make it work.

Also keep in mind it is a weekend, there are usually not many on here then. Waiting 48 - 72 hours for an answer is not unusual.

I've moved this thread to RGSSx Script Requests. Thank you.

By default, this cannot be done. The only way to even come close is Yanfly's Event chase player script, and the line of sight does go through walls. But if you design your areas with that in mind, you can make it work.

Also keep in mind it is a weekend, there are usually not many on here then. Waiting 48 - 72 hours for an answer is not unusual.

Moved to: RGSSx Script Requests
Okay. I will try that script.
By default, this cannot be done.
Maybe I am wrong, but can't you get the x:y position of the player? If so, the guard can check if the player is in a block in relation to the guard.
In this case this turns into a math problem with a "while" loop or a timer.
Maybe I am wrong, but can't you get the x:y position of the player? If so, the guard can check if the player is in a block in relation to the guard.
In this case this turns into a math problem with a "while" loop or a timer.
That might work.
You do not need a full plug-in for this. A little bit of ingenuity with scripts calls can get you the result you want without needing to install a plug-in, but a plug-in would be more user friendly.

I could demonstrate how I would approach this in RMMV but I do not remember much about VXACE and RGSS3. I can not give you exact instructions.
on the guards' move route, enter
Code:
move_toward_player if ((self.x - $game_player.x).abs + (self.y - $game_player.y).abs) <= distance
as a script entry
where distance is the minimum range they can spot you at, in grid squares.
set the move route to repeat and skip.

if you want a more complex solution, you'll need a dedicated script... but that should do for the most part
on the guards' move route, enter
Code:
move_toward_player if ((self.x - $game_player.x).abs + (self.y - $game_player.y).abs) <= distance
as a script entry
where distance is the minimum range they can spot you at, in grid squares.
set the move route to repeat and skip.

if you want a more complex solution, you'll need a dedicated script... but that should do for the most part
Hey, that will do it! This thread can be closed now.
@Thomas Smith When you want a thread closed, please Report your opening post and ask for it to be closed. Mods may not see an individual post but will see a Report.
Thanks.
Thread closed IgnoreMe

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