Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

How to handle dark rooms and light sources

A topic by Garry Francis created Sep 01, 2019 Views: 156 Replies: 4
Viewing posts 1 to 5
Submitted

I can't find any references to properties to indicate that a room is dark. Nor can I find anything to indicate that an object emits light (for lighting up a dark room), yet there are some system messages related to this. How do I handle darkness? Please don't tell me I have to do it all manually. What a pain!

And in case you're wondering, the title is 'The Cave of Magic' and caves are dark, so obviously there's going to be a dark cave at some point.

You might need Chris for this one... I don't think I've ever really coded a dark/light routine in any game on any system! :)

I can think of ways to do it manually, but better to see if Chris has something baked in, I think. I'm guessing he may do, as he probably needed it to implement Cloak of Darkness? 

(1 edit)

Hmmm.... Seems he used a dynamic boolean in his Cloak of Darkness port. https://adventuron.blogspot.com/2018/11/cloak-of-darkness-1999.html Not sure how much the system has changed since then. The dark_expression in the setup, seems to correspond to the dark/light conditions.

Yep... I'd wait for Chris to respond! (And explain)

Submitted

The old doco at https://eeyo.io/adv/docs/ makes many references to darkness in the context of screen colours. It also makes reference to zones, but this isn't mentioned in the Reference Guide. I was thinking of having a dark zone and allocating dark rooms to the dark zone. Then I can test if a room is in the dark zone. However, I don't know if this is still supported or how exactly it works.

If you have to do it manually, you need to somehow allocate a property to a room to indicate that it's dark by default. Then in the room's on_describe handler, test if the player is carrying a light source that is lit. If they are, give the normal description and graphic. If they're not, give a message saying "It's too dark to see." and a blank graphic. There are other issues to handle regarding movement in the dark, picking up objects in the dark and so on, but let's see what Chris has to say. In the meantime, I'll check out the Cloak of Darkness code.

Host (1 edit)

ADVANCED BEHAVIOUR WARNING

I'm putting together a cookbook, which may take a day or two to publish, in the meantime, this is the pattern for dark regions.

Essentially

  1. Define a 'zone' that contains one or more locations (comma separate locations between the [ ] characters, control + space will work in here.
  2. Define a dynamic boolean that contains an expression that tests if the protagonist is in the zone, if so return true. This syntax is beyond the scope of "classroom", so I won't explain it too much here.
  3. In the settings section, reference the name of the boolean that contains the darkness expression.
  4. (optional) In the system_messagages section. Change your dark message.



EDIT

If you want it to be not dark when something is held, then just add in additional conditions for darkness as such: