Referencing specifics from general 'kinds of'

I have a group of items that are all Armor. Leather armor is armor. Robe is armor (albeit not much), etc. The player wears one piece of armor. How can I identify a specific piece without knowing what it is? I would like to say something like:

 say "The player is wearing [armor worn by player]."

but the parser says it is not specific enough.

Armor is a kind of equipment. Armor is wearable. Armor has a number called AC.

Robe is armor. AC of robe is always 1.
Description of robe is "A padded garment with many pockets. It has no defensive properties. (AC=[AC of robe])". 

leather armor is armor. AC of leather armor is always 13.
Description of leather armor is "A light-weight and flexible vest made of boiled leather. It will protect against most attacks. It's scarred surface records the history of your battles. (AC=[AC of leather armor])".
Understand "vest/leather" as leather armor. 
1 Like

This is particularly confusing because if I

> examine armor,

the parser gives the description of a specific piece of armor. How does it know, and how can I do the same thing?

1 Like

Does subbing in “[random armor worn by the player]” work? Inform doesn’t know that the player can only wear one armor at a time (at least I assume you have that restriction somewhere), so just saying “armor worn by the player” is too vague - but if there can only ever be one picking at random is fine.

(The reason the parser allows you to just type X ARMOR is that it’s able to guess what the player might mean, and ask for clarification if the command is ambiguous - that obviously doesn’t work in code!)

2 Likes

You should be able to:

Say "The player is wearing [list of armour worn by the player]."


 which will give a suitable message even if that list only contains one thing (and I believe will say “nothing” if the player isn’t wearing any armour).

4 Likes

They feel intimidating, but I’m warming up to relations for their readability.

some code

equipment is a kind of thing.
armor is a kind of equipment.
armor is wearable.

the plate mail is armor in lab.
the robe is armor in lab.

protection relates one armor to one person.
the verb to be equipped by implies the protection relation.

check wearing armor:
	if something (called the current armor) is equipped by the player:
		say "(first removing [the current armor])[command clarification break]";
		try silently taking off the current armor.
		
after wearing armor (called the new armor):
	now the new armor is equipped by the player;
	continue the action.
	
after taking off armor (called the old armor):
	now the old armor is not equipped by the player;
	continue the action.
		
instead of jumping:
	if something (called the current armor) is equipped by the player:
		say "You are currently wearing [the current armor].";
	otherwise:
		say "You are currently unprotected!".
3 Likes

Yes, that’s how I proceed on my end for objects in general, because I find that it works well for all scenarios, as you explain it very well.

Just a little feedback : for needs related to RPG game mechanics (which seems to be the case here), one can also decide that each protected body area uses only one type of armor (just a helmet; just a pair of boots; just a pair of gauntlets; etc.) and reserve the term ‘armor’ for what protects the torso or the body in general. This simplifies the code a lot, provided that the technical complexity of combat is not essential to the narrative design. In which case:

Check wearing an armor when the player is wearing an armor (called the current armor): 
say 'You are already wearing [the current armor]. You need to take it off first. [run paragraph on]' instead;

And so the (unique) armor worn by the player can then be designated both by the list of worn armors (tout post) and by what is proposed by @DeusIrae.

EDIT : typo correction.

3 Likes

I like Brian Cook’s relationship example, but I don’t think I’m there yet. I’ll use that later.
I found that I could use the “called” option for specificity:

	if player is wearing armor (called MyArmor):
		now AC of player is AC of MyArmor + ACMod of player;
		say "AC = [AC of player] ([printed name of MyArmor] ([AC of MyArmor]) + [ACMod of player] (ACMod))";

I’m not sure if this is any better than the alternatives above, but it works. Any advice?

1 Like

That’s my favorite way to do it. “Called” is very elegant.

1 Like

Well, that’s also what I’m using in the little example I posted here, and for now, I haven’t found anything more effective (but I’m still a beginner).

1 Like

I owe you thanks; what you posted prompted me to use a relation for managing the connections between a given room and the objects that usually illuminate it. Something like:

a room has a thing called usual-lighting-tool

shows some limitations when you want to take full advantage of Inform’s native functions. Not only has the use of this relation significantly simplified my code (the statements are lighter and more readable), but it also allows writing, for example:

Extinguishing a lighting-tool which lightrooms a tavern is reprehensible behaviour

1 Like