New account registration is temporarily disabled.

LINE OF SIGHT

Posts

Pages: 1
I think this came up a while ago, but I feel the need to post it anyways.

I have been thinking for the last little while about making a game with stealth aspects (that's all I am saying for now) however I have been having trouble deciding how to do line of sight. There will be moving guards, and I need them to have a way of seeing you, and also a way of determining if there is a wall in front of them before you. As a quick example of what I mean: X = enemy Y = You # = objects

X Y - Sees you
X # Y - Needs to not see you

Any ideas how I could do this? I have thought of certain ways, such as making event grids, so for instance, when the player steps on certain parts of the guards route, it will change a variable, and then when a guard makes it to a certain corner, and turns, it will check to see if that variable equals a certain value. Hopefully that made some sense.

But with that out of the way, any ideas?
If this in XP, I can't help you.
2k3, however:

You're on the right track with variables.
In my example, X is what needs to not be checked.

X and Y are set to the enemy's coordinates.
Hero X and Hero Y set to hero coordinates
If enemy sprite is facing up,
-Y-1
-Store terrain command referenced by X and Y. In the database, set tiles that should be see-through able to a different terrain number.
-If terrain ID is that which is not see-through-able, end loop; move on with life.
--If it is,
---If Hero X and Y match X and Y, Enemy can see hero
----If not, repeat from Y-1

To be modified for each facing. Does this help, or should I be more explicit?
I think I See what you are saying, but if you could be more specific that would be helpful. What has basically happened here is you have put a concept in my head, but I don't really know EXACTLY how to put it in to an rpg maker. Also, this sounds like it would still work in vx or xp.
I simply don't know if they have that Store Terrain ID command. If they do, it should be fine.

So the first thing you want to do, is go in to the terrain tab of the database, and make 2 types of terrain. Call them whatever you like, make their properties whatever you like. Let's assume it's the first two in there, so their IDs are 1 and 2.

Next is go into whatever chipset is utilized for a stealth mission in the database, and set the terrain of any tile that you want to block the enemy's vision to be Terrain 2. Any tile that they should see through/over/under/around/whatever should be anything besides 2. 1 is probably the safest.

That way you can distinguish between objects that should block and not block the enemy sight by using the Store Terrain ID command, which will store the ID (in this case, 1 or 2) of the terrain of the tile at coordinates Variable X and Variable Y (each being the enemy's coordinates originally) in a variable, that can then be used for a conditional branch.

Does this make sense so far?
Okay, moving on, next we're going to make a demo enemy event.
Mr.Enemy is named... Let's name him Ted.
You're probably going to want Ted to have a custom movement pattern, showing him slowly pacing or something. I'm going to assume you want him to stop and look when he gets to the end of his pace, and before he turns around to pace back.

So, his Event Commands:

-Move Event This Event: (however you want him to pace one way)
************************************
-Wait for it to move completely
-HeroXVariable set equal to sprite Hero's X coordinates
-HeroYVariable set equal to sprite Hero's Y coordinates
-XVariable set equal to sprite This Event's X coordinates
-YVariable set equal to sprite This Event's Y coordinates
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-FacingVariable set equal to sprite This Event's facing
-Loop!
--Conditional- Facing is 1 (up)
--- YVariable - 1
--Conditional- Facing is 2 (right)
--- XVariable + 1
--Conditional- Facing is 3 (down)
--- YVariable + 1
--Conditional- Facing is 4 (left)
----XVariable - 1
--Store Terrain ID of tile referenced by XVariable, YVariable in TerrainVariable
--Conditional- TerrainVariable is 2 (cannot see through)
---Break Loop
--Else
---Conditional- HeroXVariable is equal to XVariable
----Conditional- HeroYVariable is equal to YVariable
-----(whatever you want to happen if the hero is seen)
-End Loop
-Wait just a little bit
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(if you want Ted to face a different direction, and check to see if the hero is that way,
-Move This Event: Face ____ direction
-Copy/Paste everything between the ~~~s here
or if you don't, ignore that)
***************************************
-Move Event This Event: (however you want him to pace, back to where he started originally
-Copy.Paste everything between the ***s here

Then just set that to Parallel process and it should work.
Cool, thanks euphorian. I am at school right now, so I can't try it, but I will see how it goes when I get home.
I know this was to help Myersguy but this is very helpful for me as well. I've wanted to build upon a stealth puzzle I had for quite some time now. Thank you very much for sharing that!
Pages: 1