So I'm working on this text adventure game thing. Or rather, a new one, as I got an idea that I could fit all in my head at once; while it's going to be pretty complicated in the implementation, the actual plot is a one-sentence thing.
I think this one is going to need to be written in several pass-throughs -- one to get the basic implementation of the location and the skeletons of the NPCs sketched in, then layers of complexity for each of the ways of approaching that one central problem. But I've got the skeleton bit of my first wandering NPC done. He's a guard. He has the key to the castle gate. He wanders around outside the castle walls on patrol. He worked with only one debug.
At some point I will assemble code that will make it possible to neutralise the guard in various ways (and thus get the gate key). And possibly ways of interacting with him usefully, which this code doesn't have yet. He will also, if wandering about, at some point prevent one from climbing the wall (a solution to the problem of the wall that doesn't involve banging on the guard at all), and that's still uncoded, but so is climbing the wall so I'm none too worried about that.
gateguard: Actor
;
Incidentally, he's carrying:
gatekey: keyItem
;
I think this one is going to need to be written in several pass-throughs -- one to get the basic implementation of the location and the skeletons of the NPCs sketched in, then layers of complexity for each of the ways of approaching that one central problem. But I've got the skeleton bit of my first wandering NPC done. He's a guard. He has the key to the castle gate. He wanders around outside the castle walls on patrol. He worked with only one debug.
At some point I will assemble code that will make it possible to neutralise the guard in various ways (and thus get the gate key). And possibly ways of interacting with him usefully, which this code doesn't have yet. He will also, if wandering about, at some point prevent one from climbing the wall (a solution to the problem of the wall that doesn't involve banging on the guard at all), and that's still uncoded, but so is climbing the wall so I'm none too worried about that.
gateguard: Actor
- location = castleeastV
noun = 'guard'
adjective = 'gate'
sdesc = "gate guard"
isHim = true
isinactive = nil
trackpos = 1
moveCounter = 0
tracklist = [ 'southwest' startroom 'northwest' castlewestV 'northeast' castlenorthV 'southeast' castleeastV ]
actorDaemon =
{
if ( isinactive ) return; /* Does nothing if neutralised */
self.moveCounter++;
if ( self.moveCounter = 5 )
- {
self.moveCounter := 0;
if ( self.location = Me.location )
- "The guard continues his patrol around the castle to the <<self.tracklist[self.trackpos]>>.";
self.moveInto( self.tracklist[ self.trackpos + 1 ] );
if ( self.location = Me.location )
- "A castle guard becomes visible as he walks around the wall. He starts to patrol this area.";
/* adjust tracking */
self.trackpos += 2;
if (self.trackpos > length(self.tracklist)) self.trackpos := 1;
}
else
- {
if ( self.location <> Me.location ) return;
switch ( rand(5) )
- {
case 1:
"\bThe guard taps the wall, as if testing to be certain that it is there."; break;
case 2:
"\bThe guard looks around suspiciously."; break;
case 3:
"\bThe guard adjusts his grip on his shortsword."; break;
case 4:
"\bThe guard whistles tunelessly."; break;
case 5:
"\bThe guard stomps his feet."; break;
}
}
}
;
Incidentally, he's carrying:
gatekey: keyItem
- sdesc = "gate key"
noun = 'key'
adjective = 'gate'
location = gateguard
bulk = 0
weight = 0
;