I took a shot at an implementation of nethack magic items. It involved a level of dynamism that I don’t think played to Inform’s strengths.
[spoiler][code]
“rogue” by “Zed Lopez”.
Include Dynamic Objects by Jesse McGrew.
A thing can be either actual or prototypical. A thing is usually actual.
After cloning a new object from a thing:
now new object is actual.
A magic-effect-value is a kind of value. Some magic-effect-values are defined by the Table of Magic Effects.
Table of Magic Effects
magic-effect-value
scroll-teleportation
scroll-identify
scroll-confuse-monster
scroll-punishment
scroll-amnesia
wand-wishing
wand-striking
no-effect
Having-knowledge-of relates one person to various magic-effect-values. The verb to have-knowledge-of (it has-knowledge-of, they have-knowledge-of, it had-knowledge-of, it was-known, it is having-knowledge-of) implies the having-knowledge-of relation.
A magic-item is a kind of thing. A magic-item is usually prototypical. A magic-item has a magic-effect-value called magic-effect. A magic-item has a truth state called true-name. A magic-item is usually improper-named.
Having-magic-effect relates a magic-item (called item) to a magic-effect-value (called effect) when effect is the magic-effect of item. The verb to have-magic-effect (it has-magic-effect, they have-magic-effect, it had-magic-effect, it was magic-effect-had-by, it is having-magic-effect) implies the having-magic-effect relation.
Definition: a magic-item (called item) is plain rather than obfuscated if the true-name of item is true.
A scroll is a kind of magic-item. Some scrolls are defined by the Table of Magic Scrolls.
Table of Magic Scrolls
scroll magic-effect true-name
scroll of teleportation scroll-teleportation true
scroll of identify scroll-identify true
scroll of confuse monster scroll-confuse-monster true
scroll of punishment scroll-punishment true
scroll of amnesia scroll-amnesia true
scroll of DAUM SKNAHT no-effect false
scroll of FOO no-effect false
scroll of PLUGH no-effect false
scroll of XYZZY no-effect false
scroll of BTON no-effect false
Reading is an action applying to one thing.
Understand the command “read” as something new.
Understand “read [something]” as reading.
Check reading something when noun is not a scroll:
say “You can’t read that” instead.
To magic-effect-identify (effect - a magic-effect-value):
let realitem be a random prototypical plain magic-item which has-magic-effect effect;
now player has-knowledge-of effect;
repeat with item running through every actual on-stage obfuscated magic-item which has-magic-effect effect begin;
let itemholder be holder of item;
let newobject be a new object cloned from realitem;
remove item from play;
now newobject is in itemholder;
end repeat;
To magic-effect-amnesia:
repeat with effect running through magic-effect-values begin;
if player has-knowledge-of effect begin;
let obfuscateditem be a random prototypical obfuscated magic-item which has-magic-effect effect;
now player does not have-knowledge-of effect;
repeat with item running through every actual plain on-stage magic-item which has-magic-effect effect begin;
let itemholder be holder of item;
let newobject be a new object cloned from obfuscateditem;
remove item from play;
now newobject is in itemholder;
end repeat;
end if;
end repeat;
Carry out reading something (called thescroll):
Let effect be magic-effect of thescroll;
Remove thescroll from play;
if player does not have-knowledge-of effect:
magic-effect-identify effect;
if magic-effect of thescroll is:
– scroll-teleportation: say "There’s nowhere to teleport to. ";
– scroll-confuse-monster: say "There are no monsters to confuse. ";
– scroll-punishment: say "You are being punished. ";
– scroll-identify:
repeat with eachitem running through visible obfuscated magic-items:
let effect be the magic-effect of eachitem;
magic-effect-identify effect;
say "You feel knowledgeable. ";
– scroll-amnesia:
magic-effect-amnesia;
say “Thinking of Maud, you forget all else.”.
Report reading something:
say “The scroll crumbles to dust.”
When play begins:
Let l be a list of magic-effect-values;
repeat with eachscroll running through every plain scroll begin;
add magic-effect of eachscroll to l;
end repeat;
sort l in random order;
let i be 1;
repeat with eachscroll running through every obfuscated scroll begin;
now magic-effect of eachscroll is entry i of l;
increase i by 1;
end repeat;
repeat with item running through prototypical obfuscated magic-items begin;
Let newitem be a new object cloned from item;
now newitem is in the Dungeons of Doom;
end repeat;
magic-effect-identify scroll-identify;
The Dungeons of Doom is a room.
[/code][/spoiler]
Here’s a transcript.
[spoiler]Dungeons of Doom
You can see scroll of identify, scroll of BTON, scroll of PLUGH, scroll of FOO
and scroll of DAUM SKNAHT here.
get all
scroll of identify: Taken.
scroll of BTON: Taken.
scroll of PLUGH: Taken.
scroll of FOO: Taken.
scroll of DAUM SKNAHT: Taken.
drop teleportation
You can’t see any such thing.
read identify
You feel knowledgeable.
The scroll crumbles to dust.
i
You are carrying:
scroll of confuse monster
scroll of amnesia
scroll of punishment
scroll of teleportation
l
Dungeons of Doom
drop foo
You can’t see any such thing.
read amnesia
Thinking of Maud, you forget all else.
The scroll crumbles to dust.
l
Dungeons of Doom
i
You are carrying:
scroll of FOO
scroll of BTON
scroll of DAUM SKNAHT
drop foo
Dropped.
[/spoiler]
I implemented the scroll of identify as something like a super-blessed Nethack scroll, identifying everything in the location, and amnesia as forgetting all the identifications (though I don’t recall that you ever really forget identifications in Nethack, or, I presume, Rogue.)
There are still difficulties to surmount – the wand of wishing would need to admit even unidentified things to scope.