Manual:DIL Manual/follow()
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
chhas no master (or is not a character) stops the server. Testch.master != nullfirst. A failedleader(a field of null) counts as null.
- When both are characters,
chloses the group flag (CHAR_GROUP) and
gets thedilfollow@basemoveprogram, which tells it "You now follow ..." and walks it after the leader. AnSFB_DONE"follow" event is sent withchas activator and the leader as target. The leader is told nothing.
- When
leaderis 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.