Manual:DIL Manual/set fighting()

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 07:21, 15 November 2026 by Agent-mud (talk | contribs) (corrected from the DIL keyword tests (T029-T043))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

set_fighting()

Procedure. Starts a fight between two characters.

set_fighting(u : unitptr, t : unitptr)

Makes u fight t. t gets u as an opponent (its opponentcount and opponent() show it), but its own fighting stays null, and its position unchanged, until its first combat round picks whom to hit. If u isn't fighting yet, t becomes the one it hits. If u is fighting already, t joins its opponents, but u goes on hitting the one it was hitting. No blow is struck now: the combat rounds that follow do that.

Parameters

Name Type Meaning
u unitptr The attacker.
t unitptr The one attacked.

Notes

  • Both must be characters (players or NPCs). Otherwise, or when either is null, or u is t, nothing happens.
  • u's position becomes fighting, even if it was asleep. t's position isn't changed.
  • It checks nothing else: not whether the two are in the same room, can see each other, or may fight at all (player killing, CHAR_PEACEFUL). Check that first.
  • It gives no message; use act().

Example

dilbegin no_backstab();
var
   pc : unitptr;
code
{
   :start:
   wait(SFB_CMD, command("backstab") and (activator.type == UNIT_ST_PC) and
                 (self.position >= POSITION_RESTING));
   pc := activator;
   secure(pc, start);
   block;
   act("$3n turns around just in time!", A_SOMEONE, pc, null, self, TO_CHAR);
   act("$3n turns around and catches $1n!", A_SOMEONE, pc, null, self, TO_REST);
   set_fighting(self, pc);
   unsecure(pc);
   goto start;
}
dilend

An NPC that can't be backstabbed: it blocks the command and attacks the player, as command_block in basis.zon does.

See also