Randomly spawn type of creature and carried item(s)

I was wondering if it was possible to make random creatures (from a list of possibilities) appear, and if it were to make those creatures kill-able, but instead of getting removed from play it leaves behind a lootable body. And if that is possible to make the dead body to carry random items, from a list of possibilities. I was unable to find any information on how to do this. I would greatly appreciate help.

First, a word of warning: I7 is really not a CRPG platform, and trying to make it behave like one can mean a lot of extra work!

It’s pretty easy to make a random monster appear:

A monster is a kind of animal. A monster can be alive or dead. A monster is usually alive.

Eborian squickbeast is a monster. Humpalong sackwaddy is a monster. Nefarious sturge is a monster.

This is the random encounter rule:
if there is an alive monster begin;
let N be a random alive monster;
say "Suddenly [a N] appears!";
move N to the location;
end if.

(This assumes that only one monster can appear at any one time, of course, and that everything will be tidied up before you get a new one.) Then when you want a monster to appear, use the command ‘follow the random encounter rule’.

Next, killing the monster: my guess is that you want something more complicated than just killing the monster – a combat system, rather than entering >KILL MONSTER and having it die. This is a big topic all on its own, that I’m not going to get into; you might want to take a look at Victor Gijsbers’ ATTACK extension, for instance. Bear in mind, however, that making a combat system in IF that is balanced, fair to the player, and not drop-dead boring is a pretty challenging task.

Now you need a corpse. Actually, let’s go and look in the Recipe Book portion of the I7 manual for a minute: under Other Characters there’s a heading called Combat and Death. (The Recipe Book is a great place to look when you have a ‘how do I do this particular thing?’ kind of question.) The example Puff of Orange Smoke seems to be exactly what you want, and is pretty thorough.

Finally, for looting,

[code]Understand “loot [something]” as searching.

The can’t search unless container or supporter rule is not listed in the check searching rulebook.

A body can be looted or unlooted. A body is usually unlooted.

Check searching:
if the noun is a monster and the noun is not dead:
say “You aren’t brave enough to frisk a ferocious [noun] while it’s alive.”

Check searching a looted body: say “Further searches fail to produce anything of value.” instead.
[/code]
(You’ll need a rule to deal with searching non-monstery things, but I’ll leave that to your discretion.)

For the treasure, I’m going to use an technique from section 15.16, although you could define things individually as well.

The Secret Treasure Hoard is a room. A treasure is a kind of thing. Some treasures in Secret Treasure Hoard are defined by the Table of Unimagined Riches. The description of a treasure is "[explanation]".

Table of Unimagined Riches
treasure            explanation
Diadem of Nine Lives    "A priceless crown-type thing. A bit frou-frou for your tastes, but easy to find a buyer for."
Caciocavallo Podolico       "One of the world's most expensive cheeses, this cheese is produced in Campania from rare Podolica cows, fed on wild upland plants and only producing milk for two months a year. It runs at about $650 a pound, and looks a bit like an unwashed turnip."
Kopi Luwak beans    ''These are [italic type]those[roman type] coffee beans -- you know, the ones that have been shat out by a palm civet. This somehow makes them immensely valuable."



Carry out searching an unlooted body:
if there is a treasure in Secret Treasure Hoard begin;
let X be a random treasure in Secret Treasure Hoard;
move X to the player;
say "Rummaging through [the noun]'s possessions, you discover [X]!";
otherwise;
say "You find nothing of value.";
end if;
now the noun is looted;

It’s important to recognise that this system won’t allow you to spawn infinite monsters and infinite treasures: once they run out, no more creatures or treasures will appear. A system for generating an indefinite number of things is rather more complicated; it can be done, but I7 isn’t an ideal platform for that kind of approach.

awesome! this helps alot. thank you very much

I don’t particularly enjoy combat games, and yet I desperately want to play this.

I think Savoir-Faire already staked out a claim on the whole Rogue of the Foodieverse concept.

It might be easier from a programming standpoint to simply change the printed name and description of the monster randomly. The player would be none the wiser, but it would be a lot less work to define 1 monster that pretends to be 20 different types of monsters. The random seed could be defined at the beginning of the game, or at any point thereafter.

Yeah, but for all its undeniable charms, it lacked squickbeasts.

If you want an indefinite number of monsters, this is the way to do it – or, more likely, have a dozen or so unnamed monsters and rotate them in and out, in case you want to deal with more than one at once. (This is obviously what I did to generate orphans in Orphanorium.)

The trick with that approach, though, is that you need to do a bit more preparation and cleanup, and take more care to avoid clashes. Unless you’re writing a fairly large game, it’s simpler to just define all your monsters individually. And if you’re a first-time author, a large CRPG IF is probably not the best kind of project to tackle.

Okay, okay. I’m tempted, I’ll admit. I’ll revise my excuse to ‘but I can’t actually think of a combat system that’d integrate well with this.’

True, this approach would require a lot more work with tables and variables. But if you wanted to have say, 10 monsters that were picked randomly from a selection of 30 possibilities, it wouldn’t be that hard to manage given some planning.

The issue I see with defining individual monsters is how he plans on dealing with the inventory of them. This would require some clever scripting. I think it would be a lot easier to do that on a limited basis by defining few monsters that are changed in appearance.

I don’t know, maybe I am wrong. Maybe theres some inform trick I am not thinking of that would make it easy to deal with the inventories of a group of theoretical npcs.

I’m not quite sure what you mean here; where’s the complication?

How would I go about doing this?

How precisely you’d change it would depend on what attributes you wanted your monsters to have, but the general pattern is something like this:

A monster can be alive or unclaimed. A monster is usually unclaimed.

There are twenty unclaimed monsters.

Inform cannot normally create entirely new things at runtime. (New objects can be generated, to some extent, with the extension Dynamic Objects.)

Inside the code that brings a monster into play:

let N be a random unclaimed monster;
now N is claimed;
understand "squickbeast" as N;
understand "Eborian" as N;
now the printed name of N is "Eborian squickbeast";
now the description of N is "A creature which shall not be described here, lest the more delicate reader be taken by a swoon.";

In your actual code, you’d probably want to refer to a table to get the various bits of text.

awesome thanks much

See, I would have done this differently. I would have made a table of monster types, then I would have picked a number randomly, then I would have taken that random number and taken the name and description of the specified monster from the table. That way by using a random number in a variable, I could refer to the monster again later.

I’ll write up a sample and get back to you.