ID:927085
 
Keywords: cone, lummoxjr, opacity, view
(See the best response by DarkCampainger.)
Problem description:

I'm working on a small stealth game and have it set up so that guard mobs wander the map looking for players. They're set up to look for players in a cone (using this snippet). It works for the most part, except for an issue involving opacity.

cone view

In this image the blue square represents the player. The grey blocks are walls (which are both dense and opaque) and the red represents the field of view from the cone. The yellow X's mark spots in which it makes no sense that the player should be able to see them. Is this a bug or just how opacity works?
Best response
I think it's just the way BYOND's opacity works.

If your only interest is in giving your AI guard a more accurate sight-line, you could combine that cone with a custom line-of-sight calculation. Here's a demo of one:
http://www.byond.com/developer/DarkCampainger/LineofSight

(it's hard-coded for an icon_size of 32 still, but that looks like what you're using anyway. I also just noticed I misspelled "thief", heh)

If you want to fix the opacity itself, I thought someone had a library that implemented a custom version. Maybe it was D4RK3 54B3R. Not sure how it performs compared to the built-in algorithm.
In response to DarkCampainger (#1)
I took a look at the demo you posted and it's very nice and definitely improves upon what I have. The fact that it's hardcoded to only work with an icon_size of 32 is a problem though since I always work with an icon_size of 16 and scale the graphics up.

I did a bit of looking and I wasn't able to find any sort of libraries pertaining to opacity though.
It's just how opacity works. There's a limited capacity to look around corners this way. Proper shadowcasting would be very interesting to have, but actually most if not all of those X's would be visible regardless in a shadowcasting algorithm (which typically counts a square as visible if any of it is visible).
A pixel-perfect view with opacity support that works like bounds() would be excellent.
In response to LordAndrew (#2)
LordAndrew wrote:
I took a look at the demo you posted and it's very nice and definitely improves upon what I have. The fact that it's hardcoded to only work with an icon_size of 32 is a problem though since I always work with an icon_size of 16 and scale the graphics up.

I released a new version of it as a library that can handle any icon_size setting:
Line Of Sight Library

It also has built-in support now for step_x/y and bounds. All you have to do is pass it two atoms.

I did a bit of looking and I wasn't able to find any sort of libraries pertaining to opacity though.

It may not have ever been released. I would suggest asking around Chatters if you haven't already done so.
In response to Albro1 (#4)
Albro1 wrote:
A pixel-perfect view with opacity support that works like bounds() would be excellent.

Also likely impossible. To operate on a pixel-perfect basis it would have to cast shadows around non-square objects like pillars, whose actual "footprint" might be smaller than their visible icon and might also not be infinitely tall.

Plus, for consistency this would also have to be accounted for in view(), which has an all-or-nothing approach based on turfs and would probably not yield correct info.