Manual:DIL Manual/fighting
Jump to navigation
Jump to search
Contents
fighting
Field (unitptr, read-only; units: characters).
ch.fighting : unitptr
The character this character is hitting in melee: its current opponent. null when it is not fighting.
A character can be fought by several others at once, and can have more opponents than the one it hits; opponentcount and getopponent() list all of them, and opponent() tells whether one character fights another.
Notes
- Players and NPCs. On an object, a room or null the field fails.
- It can't be assigned (vmc: "Illegal lvalue"). Start a fight with set_fighting() and end it with stop_fighting().
- The opponent you get is a plain unitptr: like any other, it becomes null at the next wait unless you secure() it.
Example
dilbegin drain_foe();
var
u : unitptr;
code
{
heartbeat := PULSE_SEC * 6;
:start:
wait(SFB_TICK, TRUE);
if (self.outside.type == UNIT_ST_ROOM)
goto start;
u := self.outside.fighting;
if (u == null)
goto start;
if (u.endurance > 10)
{
u.endurance := u.endurance - 10;
act("Your $2N drains $3n's strength.", A_ALWAYS, self.outside, self, u, TO_CHAR);
}
goto start;
}
dilend
An object that, while its carrier fights, wears down the carrier's opponent, like the items in barbarian.zon that act on self.outside.fighting.