A Better Line of Sight

Hey Folks! Today was a bit more productive, as I was able to spend most of it working directly on prototyping instead of fixing broken things. And today's highlight is this:

IMAGE(http://bluebottlegames.com/img/screenshots/screenshot-2015-09-15.jpg) Actual Line of Sight!

I happened to find a very cool line of sight algorithm intended for roguelikes this morning. What particularly attracted me to it was:

  • It was more realistic than a simple room-based system.
  • It was more efficient than my initial brute-force raycasting system.
  • It revealed walls along the edges of sight lines, unlike either of the above.
  • It was relatively simple to code.
  • It was guaranteed to have "symmetry," which is something I didn't consider when writing the first two systems. (E.g. if creature A can see creature B, then the reverse is always true)

What we see above is "Simon" walking through a room with a pillar, a fridge, and a bed with someone in it. He can see most of the room except behind the pillar, and a bit of the next room through the bulkhead. The yellow icons below each crew member are a debug icon I use to see their biggest concerns. The sleeping dude is worried about their level of achievement, while Simon is having trust issues.

After getting it running, it was actually a bit mesmerizing to watch. I could switch points of view by clicking other crew, and I set it up such that other crew and furniture disappear if they're standing on invisible tiles.

I think a system like this would offer many opportunities for gameplay features. Ship designs could take advantage of lines of sight to make observation deliberately easy or hard (smuggling? sneaking?). Firefights could use this system for better hit checks. Even systems that involve electromagnetic radiation (e.g. gamma and cosmic rays) could piggyback on this to see if a creature is exposed to a source. Or just plain lighting effects, for that matter. Handy!

Where to go from here will depend. I'd like to dig into the item system a bit more, and maybe model things like containers so the fridge can have limited food. I'd also need to model items that aren't fixed to the floor, such as a sandwich. Somehow the code to check if an item could fit in a space is being skipped, so I'll need to look into that. And items don't yet have any way of rotating to fit alternate layouts.

And that's just items! Still a lot left to explore, and we'll have to see tomorrow what's next. For now, have a good night!