Manual:DIL Manual/act()

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 23:22, 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

act()

Procedure. Shows a message to the characters around someone, worded for each of them.

act(text : string, show : integer, char : unitptr, medium : unitptr or string,
    victim : unitptr or string, to : integer)

Sends text to the characters that to picks, around char. Codes such as $1n in the text are filled in for each reader: a name, or "someone" when they can't see who it is, "he" or "she", and so on. The usual way to tell what happens is one act for the one who does it (TO_CHAR), one for the victim (TO_VICT) and one for the others (TO_NOTVICT or TO_REST).

Parameters

Name Type Meaning
text string The message, with $-codes (below). No <br/> at the end: act adds it.
show integer A_SOMEONE, A_HIDEINV, A_ALWAYS or A_RAW (below).
char unitptr The one who acts: $1, and the place the message goes out from.
medium unitptr or string $2: a unit, a string for $2t, or null.
victim unitptr or string $3: a unit, a string for $3t, or null.
to integer Who gets it: a TO_ constant (below).

The constants are in vme.h.

to Who gets it
TO_CHAR char only.
TO_VICT victim only.
TO_ROOM Everyone around char, but not char.
TO_NOTVICT Everyone around char, but not char and not victim.
TO_ALL Everyone around char, char too.
TO_REST As TO_ROOM, and not those inside char either.

"Around char" is the room char is in, including those inside transparent units there; when char is inside a transparent unit (a wagon, a boat), also the room around that unit.

show Meaning
A_SOMEONE Not shown to those asleep. A unit a reader can't see is "someone" or "something".
A_HIDEINV Not shown to those who can't see char, nor to those asleep. For things that are only seen, like a smile.
A_ALWAYS Shown also to those asleep. A unit a reader can't see is "someone" or "something".
A_RAW Shown to everyone, and $n and $N give the real names even of units the reader can't see.

A code is $, a digit for the argument (1 char, 2 medium, 3 victim) and a letter:

Code Becomes
$1n A player's name, or the title of an NPC or object ("the town guard"); "someone" or "something" to those who can't see it.
$1N The unit's first name ("guard"); "someone" or "something" to those who can't see it.
$1e, $1m, $1s he/she/it, him/her/it, his/her/its.
$1p The character's position (standing, sleeping, ...); "lying" for anything else.
$1a "a" or "an" to go before the unit's name (or before a string argument).
$2t The string given as that argument.
$$ A single $.

Notes

  • Only characters with a connection see it. NPCs, and the programs on them, never see act() text: to tell a program something, use send() or sendto().
  • With char null, or victim null for TO_VICT and TO_NOTVICT, nothing is sent. A string as char compiles but sends nothing.
  • A to outside TO_ROOM ... TO_REST (0 to 5) sends nothing. A show below 10 or above 14 is logged and taken as A_ALWAYS.
  • A code whose argument is null shows "NULL", and an unknown code cuts the message there; both are logged.
  • The first letter is made a capital (after any HTML tags at the start).
  • Numbers can't be passed: give itoa(n) as the medium or victim and write $2t or $3t.
  • Used in an expression, s := act(...) sends nothing and gives the text as the one it is about would see it, with the <br/>, or "" when there is nobody or they wouldn't see it; see sact().

Example

dilbegin block_flee();
var
   pc : unitptr;
code
{
   :start:
   wait(SFB_CMD, command("flee") and (activator.type == UNIT_ST_PC));
   pc := activator;
   block;
   act("You panic and try to flee, but something prevents you from escaping!",
       A_SOMEONE, pc, null, self, TO_CHAR);
   act("$1n panics and tries to flee, but can not!",
       A_SOMEONE, pc, null, self, TO_REST);
   goto start;
}
dilend

dilbegin hand_over(item : unitptr, pc : unitptr);
code
{
   act("You hand $2n to $3n.", A_SOMEONE, self, item, pc, TO_CHAR);
   act("$1n hands you $2n.", A_SOMEONE, self, item, pc, TO_VICT);
   act("$1n hands $2n to $3n.", A_SOMEONE, self, item, pc, TO_NOTVICT);
   return;
}
dilend

Fleeing fails where this program is, with one message for the player and one for the others (adapted from clans.zon), and the three messages of handing something over.

See also