Update 5 - Meat
One of those days where I spun my wheels a lot and didn't get much done, but the monster is coming along nicely. I'll show the code for the expanded monster AI in this update, and I'll also show off the debug functions I'm running.
The player can now distract it temporarily with a cut of meat. There are 5 cuts of meat found in a chest in the starting area, and once they're gone they're gone. (The game will be short enough that I think I can get away with letting the game become unwinnable. This also saves me writing a lot of sophisticated code to stop the player screwing up.)
I wasted a lot of time implementing a way-too-fancy version of the meat. There was going to be a nondescript pile of meat in the chest, from which the player could take cuts of meat. The cuts of meat were actually stored in an inaccessible room, and individually teleported to the player's inventory when they tried to take some meat. I wanted to try this so that I could just refer to "the meat" rather than individual cuts of meat - I think the vagueness is a little more surreal and hostile. But I got lost and frustrated trying to figure out the code, so I went for something a little blunter and simpler.
Because of this, I now have an unused dummied-out room in my game called Meat Dimension. This is fine.
The monster AI is now governed by a single rule running every turn, which is clumsy but ensures that the monster isn't taking multiple turns of its own every player turn.
Every turn (this is the monster AI rule):
if the monster is feasting: [monster eating meat overrides other behaviour]
decrease the feast time by 1;
if the feast time is 0:
now the monster is chasing;
otherwise if the monster can touch a cut of meat (called the feast) which is not carried by a person: [monster distracted by meat]
move the feast to the monster;
try the monster eating the feast;
now the feast time is 3;
now the monster is feasting;
otherwise if near monster: [monster attacking player]
now the monster is aggressive;
say "The monster [one of]brays.[or]claws at you![purely at random]";
otherwise: [monster searching for player]
now the monster is chasing;
let the way be the best route from the location of the monster to the location of the player;
try the monster going the way.
"Feast time" is just an integer which ticks down. "Near monster" is a truth state (or, as other programming languages might call it, a boolean) which checks whether the monster is in the same room as the player. This was an experiment with factoring my code, but I found the syntax difficult to get right, so I don't want to mess with the code any more for now.
One fun side effect of the monster's behaviour now is that, if it enters the starting campsite which the chest of meat is open, it will just stop and gorge itself like a bear raiding a garbage can. One the one hand, this is frustrating and punishing for the player who forgets to close the chest of meat and then comes back later to find it all unexpectedly gone. On the other hand, it's very funny. So it's impossible to say whether it's bad or not.
The monster AI isn't done yet: I need to implement player health so that the monster can pose a threat, and I need to add more flavour text so that the player can tell whether the monster is eating meat or chasing them. But this was the big hump that I was worried about, so hopefully the worst is behind me. This is good, because productivity is about to be hit by Kentucky Route Zero Act V.
Here are those debug functions I mentioned earlier. They're stored in a part of the source code labelled "Not for release," which means that I don't have to worry about removing these at the end of development - Inform 7 will automatically dummy these out when I make a public version of the game.
VOLUME - DEBUG - Not for release
Book - Run property checks at start of play
[Adapted from Inform Documentation example 2, "Bic"]
When play begins (this is the run property checks at the start of play rule): repeat with item running through rooms: if description of the item is "": say "[item] has no description.";
repeat with item running through things: if description of the item is "": say "[item] has no description."
Every turn (this is the report monster state rule):
say "(Monster location: [location of the monster]; [nearmonstertruth]state: [behaviour of the monster].)[paragraph break]".
To say nearmonstertruth:
if near monster, say "monster considered nearby; ". The report monster state rule is listed after the monster AI rule in the every turn rules.
The second one, the "report monster state" block, is just telling me where the monster is and what it's doing, so I can see if I broke something.
The first one is more interesting. It runs through every room and every object in my game, and warns me at the start of a playthrough if I'm missing a description for any of them. This will be helpful don;t the line as I add objects and start doing some actual writing. But because I haven't described most of my rooms yet, every playthrough currently starts like this:
There's a couple of other neat things here that I haven't talked about yet - listing the exits in the status bar up top, and beginning to fill out the campsite - but I'll get to them in future updates.