Manual:DIL Manual/set fighting()
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, and t fight u. 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
uist, 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.