Experience with Water & Fluids in Dialog

Interesting thing I wanted to share.

The game I’m working on involves getting water from a well. There’s water in the well but there’s also water in the container. So I had to implement two water quantities. But I didn’t want to disambiguate between them every time the player wants to get some water. So I made the container’s water only be in scope when the player is not near the well, or any other room with a water source.

#containerWater
(name *)    water
($Room attracts *)
    (player has water)
    ~(water source $Room)

So I don’t literally fill the container with water, I just flip the (player has water) predicate.

The downsides to this are:

  • I need to blacklist the #containerWater if I make a list of all objects in the room, because the water would be nested under the room itself. Luckily I haven’t found the need yet.

I haven’t tried implementing pour water on thing. The main mechanic of the game is bathing anyway, and I would only need the pour verb as a synonym for washing.

3 Likes

Isn’t problem solving just lovely?

Liquids are more of a chore than they seem to, as I found out trying my hand at making a generic fluid library for Dialog :wink:

It’s interesting that you made the container of water a floating object. Is there any reason to doing this rather than letting the player actually hold the container in their inventory? Perhaps you could have instead defined ($ is empty) and applied it to the container. Then, for the logic of what to use as water, first check if the room has a water source, and if not, then check if the player has a filled container of water. That might work better, and you wouldn’t need to blacklist anything, as the standard library wouldn’t show items in a player’s inventory.

If you still need a (player has water) predicate for some reason, you could just simply define two rules, and if both the rules fail, it means the player doesn’t have water:

(player has water)
     (current room $Room)
     *($Item is #in $Room)
     (water source $Item)

(player has water)
     (current player $Player)
     (#containerWater is #heldby $Player)
     ~(#containerWater is empty)

Then, whenever you want to check if a player has water, you can just simply go (player has water). And it’ll work as an assertion that the player has water. That’s the magic of Dialog!

2 Likes