npc stalking player

I have basic code, which lets them move through doors, and thats fine, however is there away to have door stop them if it’s locked? my little evil mind is a buzz tonight = )

Thank you.

1 Like

Are you using Inform’s route-finding to decide which direction to go?

1 Like
I found this on the forum
"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"

not wording it like this but the basic stalking is what i was after

1 Like

What was the code you tried, and what were the results?

It’s automatically the case that attempts to go through a locked door fail. If your code is like:

let the way be the best route from the location of Van Helsing to the location of the player, using even locked doors;
try Van Helsing going the way;

you should see results consistent with that.

I switched using doors to using even locked doors because if there is a locked door blocking the route and you didn’t specify using even locked doors, then the way would be nothing and try Van Helsing going the way would result in:

You’ll have to say which compass direction to go in.

You may find the actions debugging command helpful: it will let you see what actions are being attempted by whom.

1 Like

thank for for reply, but i’m stepping away for a bit. My game needs combat and i just can’t get any sort other than a knife to work. and then its player attacking and no enemy. just flustered but thanks for you reply.

1 Like