Stalking NPC


I’m working on creating an NPC who will follow the PC around and eventually kill her after a certain amount of turns. Can anyone recommend a thread or a good code example that would help me get started with this type of scenario? I also want to change his printed description as he gets progressively closer to making a kill.


(matt w) #2

For following code, try the “Van Helsing” example in the Inform documentation.

For the other stuff, you could try giving the character a number property that decreases by one every relevant turn and make the description vary with the value of the property.



Indeed, Van Helsing is the example you need to see, combined with the phrase “let D be the number of moves from [room 1] to [room 2].”

You can try this:

"High Stakes"

The Egyptian Collection is a room. The Hellenistic Collection is east of the Egyptian. The Roman Collection is east of the Hellenistic. The Modern Collection is east of the Roman.

Doctor Van Helsing is in the Modern Collection. [Don't ask why.]

Every turn:
	if the location of Van Helsing is not the location of the player:
		let the way be the best route from the location of Van Helsing to the location of the player, using doors;
		try Van Helsing going the way;
	let the distance be the number of moves from the location of Van Helsing to the location;
	if distance is:
		-- 0:
			say "The Doctor stares at you, while pulling a wooden stake from under his cloak.";
			end the story;
		-- 1:
			say "You can hear the Doctor's footsteps approaching.";
		-- 2:
			say "You wonder where the Doctor is. Then, you hear a distant voice shouting your name. It is his."

Test me with "showme helsing / z / showme helsing / z / showme helsing / z"