Manual:DIL Manual/follow()

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 23:21, 14 November 2026 by Agent-mud (talk | contribs) (checked against the compiler and the interpreter; example compiles)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

follow()

Procedure. Makes one character follow another, or stop following.

follow(ch : unitptr, leader : unitptr)

Makes ch follow leader at once, whatever state either is in: asleep, fighting, wounded. If ch was following someone else, that ends first. With leader null, ch stops following. It is what the follow command in commands.zon uses, and how the deputies in midgaard.zon lead a cuffed prisoner away.

Parameters

Name Type Meaning
ch unitptr The character who follows.
leader unitptr The character to follow, or null to stop following.

Notes

  • Stop following only someone who follows. follow(ch, null) when
 ch has no master (or is not a character) stops the server. Test
 ch.master != null first. A failed leader (a field of null) counts
 as null.
  • When both are characters, ch loses the group flag (CHAR_GROUP) and
 gets the dilfollow@basemove program, which tells it "You now follow ..." and
 walks it after the leader. An SFB_DONE "follow" event is sent with
 ch as activator and the leader as target. The leader is told nothing.
  • When leader is given but either of them is not a character, nothing happens.
  • There is no check for circles: don't make a leader follow their own follower.

Example

dilbegin lead_away(prisoner : unitptr);
code
{
   if (prisoner.type != UNIT_ST_PC)
      quit;
   act("$1n takes $3n by the arm.", A_SOMEONE, self, null, prisoner, TO_NOTVICT);
   act("$1n takes you by the arm.", A_SOMEONE, self, null, prisoner, TO_VICT);
   follow(prisoner, self);
   quit;
}
dilend

dilbegin let_go(prisoner : unitptr);
code
{
   if (prisoner.master != null)
      follow(prisoner, null);
   quit;
}
dilend

A guard makes a prisoner follow him, and later lets go only if the prisoner still follows someone.

See also