fighting

fighting <creature>

A creature's current combatants, as an iterable of the living creatures it is fighting.

Arguments

Returns

An iterable whose elements are creatures. A creature not in combat yields an empty iterable. An unresolved argument yields null. Consume it with each, count, first, select, or another iterable consumer.

Examples

after command (say) {
  do "say I am fighting [count [fighting $self]] foe(s)."
}

[fighting $self] lists the owner's living opponents. Out of combat in the debug world this evaluates to 0, so the mob says "I am fighting 0 foe(s)."

combat {
  each [fighting $self] { <foe>
    do "say I will not yield to [name $foe]!"
  }
}

In a combat handler the mob addresses each of its living opponents in turn. The block parameter <foe> is declared inside the braces, right after {.

See also