I am creating a “dungeon crawl” system using Inform7. I have created a new “wielding” relationship which sets which weapon the actor is going to use for attacking. This works great, allowing the player to “wield sword” and it does the usual checks and tweaks to take if not carried, ‘unwield’ if dropping, etc.
However when it comes to setting up the other characters, if I say “the skeleton is wielding the sword” then the item does not appear in the showme list, I have to first write “the skeleton carries the sword” otherwise the sword is nowhere.
It is important that the wielded item is carried as when an actor dies there is a corpse dropped with all the items they carried for looting fun.
Sure I could write out the carried and wielded relationship for every character, but surely there is an easier way?!
After all I can say “the skeleton wears boots” and the boots are carried as well as worn. How does the wearing relationship imply the carried by relationship?
If all you need to do is to make sure that you can write “The skeleton wields the sword” in your code and the game will have the skeleton carry the sword as well, you could try something like this:
When play begins:
repeat with item running through weapons:
if a person (called the bearer) wields the item:
now the bearer carries the item.
This will move every weapon into the right person’s inventory at the beginning of the game. (Make sure you aren’t doing any checks before that When Play Begins rule runs that depend on the weapon being in the right place.) If you want to make sure that a weapon can only be wielded when it’s in the inventory, and gets unwielded whenever it’s removed from the inventory, you need to write more rules to make it happen; but it sounds like you’ve already done that.
Here’s my whole test code:
[code]Cavern is a room.
A weapon is a kind of thing.
The skeleton is a person in the cavern.
The sword is a weapon. The mace is a weapon.
Wielding relates one person to one weapon. The verb to wield means the wielding relation.
The skeleton wields the sword. The player wields the mace.
When play begins:
repeat with item running through weapons:
if a person (called the bearer) wields the item:
now the bearer carries the item.[/code]
This is actually a very interesting question. How is the special nature of built-in relations like wearing implemented such that specifying something is worn also automatically makes it carried? Does this happen at the I6T level, or even deeper in the guts of the compiler?
More generally: Is that sort of “dual assignment” of relations based on a given verb something that could be replicated for your own relations, as Stephen Blake might do here? Would it be an interesting feature request to be able to specify, for example, “The verb to wield means the wielding relation. The wielding relation implies the carrying relation.” or something similar?
We can see that the hat is declared to be contained within Bob (-> ->) and that it has the clothing and worn attributes set.
The preceding applies to things that are worn initially. Containment for things that later become worn is handled by the “can’t wear what’s not held” and “standard taking off” rules in the standard rules.
Is that the whole story, though? We can declare “now Bob wears the hat” and that should get the hat to be contained by Bob even though it doesn’t invoke any action rules.
Yes, this is exactly the kind of feature I was thinking would logically exist in the I7 side of things to allow us to define behaviors for relationships.
However digging through the Standard Rules file I found nothing.
I think this would be a useful feature in certain situations. “mother” implies “parent” implies “family”, “glued together” implies “same containment”, etc.