intfiction.org

The Interactive Fiction Community Forum
It is currently Sat Feb 23, 2019 4:54 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Stalking NPC
PostPosted: Sun Feb 03, 2019 11:20 am 
Offline

Joined: Fri Oct 02, 2015 8:05 pm
Posts: 18
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.


Top
 Profile Send private message  
Reply with quote  
 Post subject: Re: Stalking NPC
PostPosted: Sun Feb 03, 2019 12:30 pm 
Offline

Joined: Tue Mar 09, 2010 2:34 pm
Posts: 5568
Location: Burlington, VT
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.


Top
 Profile Send private message  
Reply with quote  
 Post subject: Re: Stalking NPC
PostPosted: Mon Feb 04, 2019 7:57 am 
Offline

Joined: Sat Feb 13, 2016 6:26 pm
Posts: 168
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:

Code:
"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"


Top
 Profile Send private message  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group