[I7] NPCs gathering objects

Hello,

I’m recreating a public domain text adventure written many years ago into Inform 7, partially because I liked the game, but mostly because I want to learn how Inform 7 works. The game was called “Labyrinth II” and was written for the Amiga by Russell Wallace. It’s going really well so far, I really love the “natural language” feel of Inform 7, and it’s made creation of rooms and objects very easy.

So far I have used the Patrollers extension by Michael Callaghan to make my NPCs move around the map, just like the NPCs did in the original game - this extension is superb. There are objects randomly scattered through the map - some are treasures, some are armour, and some are weapons. Since NPCs start the game in random locations and with nothing in their inventory, they need to be able to arm themselves so that they can fight the player, and they need to pick up and wear armour that will reduce the damage the player inflicts upon them, and they needed to pick up treasure so that the player would be forced to fight them to gain that treasure.

The original game had NPCs picking up all three types of object when they arrived in the same room as it - but I’m not sure how to implement this in Inform 7. Can anyone give me some pointers on how my NPCs should be told to pick things up?

You make the player perform actions by using the “try” command. When defining what actions NPCs should perform, the somewhat cumbersome “try [actor] trying” syntax is used.

[code]A monster is a kind of person.
The orc is a monster.

Home is a room. The orc is in Home.

A thing can be useful. A thing is usually not useful.
A weapon is a kind of thing. A weapon is usually useful.

Definition: A person is suitably armed if it carries a useful weapon.
Definition: A person is unarmed if it is not suitably armed.

The sword and the spear are weapons. The sword and the spear are here.

Every turn:
repeat with evildoer running through unarmed monsters:
if the evildoer can touch a not held useful weapon (called pigsticker), try the evildoer trying taking the pigsticker.[/code]

I apologize if I’m combining multiple techniques here. Hopefully it’s at least clear what the various commands do. Also, I’m thrilled to see someone give the Amiga the honor it deserves.

Thanks, that’s really helpful! My NPCs now grab pretty much everything in the game almost immediately, so I’ll be using a random seed next so that the player has a chance to happen upon a weapon to fight them with.

The original game used to tell you who was carrying what when you were in the same room as them, i.e. “Bill enters the room, carrying a rapier and a gold nugget.” This was so you could decide if you could beat Bill in a fight, or if Bill was carrying a prize object you needed to fight him to obtain. How do I get Inform 7 to announce this?

Long-time Amiga fan, me. Got my first one in 1990 (an A500 with OCS chipset) and I still have my last one (an A1200 in a tower case with 68040 processor, 8 MB Fast RAM, and a 1 GB 5.25in hard drive!)

Heh, I suspected that might be the result. When you’ve grown more comfortable with Inform 7, you may want to use or create some kind of action planning system; that would be useful for making the monsters react at something other than lightning speed. Rulebooks are pretty much ideal in that regard.

The way to do it in I7 is pretty straightforward. The simplest way is to just

say the list of things held by the NPC; although you have to specify exactly what “the NPC” refers to, as in

To say the equipment of (NPC - a person): say the list of things held by the NPC.
Of course, that just to create the text you want. You also want the behavior to kick in when the orc arrives:

After a monster (called the NPC) going when the player can see the NPC: say "[The NPC] enters the room, carrying [a list of things held by the NPC]."
The whole “(called [the something])” construction is particularly useful for making code readable and intuitive, I’ve found.

Awesome machines both. Your A1200 has nice specs. I’ve recently laid hands on something similar, though it’s not towerized and I haven’t quite gotten around to installing the accelerator card. My intention was to finally learn Assembler on it, but I haven’t really found someone to teach me. Yet.

That’s great, thanks again! Any time someone enters the same room as the player, the game tells me what they’re carrying.

Another little roadblock I’ve hit is that when the player kills one of the NPCs, the items the NPC is carrying are not dropped. This means that if an NPC collects a prize, there is no way for the player to get that item.

I can see how to get an NPC to drop a specific object (i.e. “try the NPC dropping the gold nugget”) but remember, the NPCs and items start in random locations - the NPCs will aimlessly wonder the map, and will randomly decide to collect an item or leave it behind when they encounter it - so I can’t hard-code these. Now I know I can produce a list of items that NPC is carrying, since the game now does this any time an NPC enters the room or any time the player enters the room while an NPC is there and not moving - but trying to figure out the commands needed to get the NPC to drop everything once they die seems quite frustrating. Any pointers?

“now everything carried by Steve is in the location of Steve.”

This doesn’t go through the action machinery, so it doesn’t generate visible messages and it won’t hit any custom drop action rules you might write. But that’s probably okay; you’d want to write your own message anyhow.

Knew it’d be a simple command … I was trying all sorts of things, variants of the word “drop” being most prevalent and it just wasn’t having any of it - thanks!