I6: Commands for NPCs

This is probably awfully simple, but I didn’t find it in the DM4: How can I get an NPC to execute a command? Like, when <> will have the player do it, how can I apply this to an NPC?

The I6 library doesn’t support NPC actions, really. “Robot, examine lamp” invokes the robot’s orders or life routine, not the library examine action.

Hrmpf. And the Life;[ routine can’t be called from outside with parameters? sigh

Oh, sure it can. It’s just a property. Set the actor, action, noun, and second variables, and then do RunLife(actor, ##Order).

Am I doing something wrong when I can get the following code to work then?

Code:

Object Messenger "windows messenger"
   with
   	name 'messenger',
		before[;
			Attack:
				switch(actor) {
					attacker:	
						"~don't kill the messenger!~";
					default:
						"hey hey hey!";
				}		
				
   ];
   
Object attacker "the attacker"
	with
		name 'attacker',
   orders[;
         Open: "~I don't like to open ", (the) noun, ". ";
   	 default:
   	 	<<(action) noun second>>;
   ],
  has animate;

Then invoke with either:

Attacker, kill messenger
“don’t kill the messenger!”

or:

Kill messenger
“hey hey hey!”

The attacker will obey any command but open. But then of course, the library messages are written for the player only so you’ll still get “you can’t do x…” sometimes.

That will cause a lot of unexpected results because the verb routines are set up for the player, not any other actor.

Right. The <<(action) noun second>> statement is still a legal statement, but there’s nothing in the library action routines that pays attention to the actor variable (as far as I know). So “attacker, take lamp” will wind up with the player carrying the lamp, and fail if the lamp isn’t in the same room as the player, etc.

(I haven’t tested any of this; I’m just looking at the library code.)