ID:171746
 
I am trying to figure out a way to make it so you can only see in front of you...like...

X=Black(Can't see)
O=You
!=Can See
XXXX!
XXX!!
XXO!!
XXX!!
XXXX!


Something like that... Anyways, I'm not sure how I should do this..HUDs...Client Eyes...I was wondering if anyone could put me in the right direction. Thanks.
FireEmblem wrote:
I am trying to figure out a way to make it so you can only see in front of you...like...

X=Black(Can't see)
O=You
!=Can See
<font face = fixedsys>XXXX!
XXX!!
XXO!!
XXX!!
XXXX!</font>

Something like that... Anyways, I'm not sure how I should do this..HUDs...Client Eyes...I was wondering if anyone could put me in the right direction. Thanks.

Dont Double post please you posted here: ID:279940 all you had to do was bump it.

--Goz
In response to Goz
but that's double posting too...and I thought you couldn't bump?
In response to FireEmblem
In response to Goz
oh..sorry.
In response to FireEmblem
It's ok to bump after 24 hours have passed without a response and your post has passed off that first page (in default forum view).

If you only want to make it appear that you can't see behind you, you can get away with a HUD display that obscures the hidden places.

However, if you want to limit players and critters actions affect what is in front of them, it's a bit trickier. First you'll need a proc that returns a list of things in front of the mob. You could loop through everything in view and compare directions, but that's pretty slow. The fastest method I've found is complex, but fast and reliable:
  1. Find the dirs 45 degrees left and right of the mob's dir.
  2. Start with the turf directly behind the mob, and shoot a ray in each of the dirs you found in step 1 to a range of view + 2.
  3. Add each turf in the ray to a list, I call it "blockers". You'll see what it's for later.
    For each non-opaque turf in the ray, do the following:
    1. Turn the turf's opacity on
    2. Add the turf to another list, I call it "clear".
  4. If the mob's dir is not a diagonal, repeat the ray process with the turf one step further back from the mob (two steps back from the mob.) This is required to prevent some wierd opacity/view issues.
  5. Get view(world.view,the mob) - blockers and store it. This is the list of atoms the mob can see in front of it.
  6. Loop through the clear list and toggle each turf's opacity off again.
  7. Return the list found in step 5.


You're still not done yet though. You have a list of atoms in view, now you have to obscure the ones you can't see.
  1. You need a mob list var to track currently obscured turfs. I call it "obscured".
  2. You also need a turf var for a black image set at a high layer on each turf. I call it "obscure_image". That way you only need to create one image per turf, no matter how many people see it.
  3. Each time a player (NPC's don't have to do this) changes loc or direction, you need to do the following:
    1. Before the loc/dir changes, make a copy of the mob's obscured list. "old_obs = obscured.Copy()", not "old_obs = obscured". The former copies the obscured list, the latter just gives you two references pointing to the same list. What you do to one would happen to the other too!
    2. change the loc and/or direction.
    3. Store range(world.view+1,src) in a list var. I call this list "blocked".
    4. Store the list of atoms in front of you (gathered by the method listed above) in another list var. Call this list "viewahead".
    5. Subtract viewahead from blocked.
    6. Clear the obscured list.
    7. Loop through the turfs in blocked.
      1. If the turf has no obscure_image, make it.
      2. Add the turf's obscure_image to the mob's obscured list.
    8. Remove the images to the mob's client that are in the old_obs list, but aren't in the new obscured list. (client.images -= old_obs - obscured)
    9. Add the images to the mob's client are in the new obscured list, but aren't in the old one. (client.images += obscured - old_obs)


The obscure and old_obs lists may seem to complicate matters needlessly, but it's important. I implemented a version of this without old_obs and connected clients got flickers of areas that they should not have been able to see.