Re: Inform: Following the player


06 Dec 1995 19:09:50 GMT

JJF <J.J.Farmer-CSSE94@cs.bham.ac.uk> wrote:
> Does anyone know how we should go about programming a creature that
> follows the player?

The easiest way to do this is:

Object Rover "rover"
has animate
with name "dog" "rover",
...
daemon [;
if (parent(self) ~= parent(player))
move self to parent(player);
];

If at the end of a turn, the dog is not in the same room/container as
the player, move it there!

This has the problem that the dog doesn't appear in the room description
when the player arrives (because it hasn't followed yet). So you might
want to add a message like "Rover arrives" after the dog moves.

Alternatively, use the `NewRoom' entry point, so that the dog ends up in
the new room before it is described:

[ NewRoom;
if (FollowingFlag == 1 && parent(Rover) ~= parent(player))
move Rover to parent(player);
];

-- 
Gareth Rees