<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.dikumud.com/index.php?action=history&amp;feed=atom&amp;title=Manual%3ADIL_Manual%2Fgetopponent%28%29</id>
	<title>Manual:DIL Manual/getopponent() - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.dikumud.com/index.php?action=history&amp;feed=atom&amp;title=Manual%3ADIL_Manual%2Fgetopponent%28%29"/>
	<link rel="alternate" type="text/html" href="https://wiki.dikumud.com/index.php?title=Manual:DIL_Manual/getopponent()&amp;action=history"/>
	<updated>2026-11-24T03:18:05Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.1</generator>
	<entry>
		<id>https://wiki.dikumud.com/index.php?title=Manual:DIL_Manual/getopponent()&amp;diff=2843&amp;oldid=prev</id>
		<title>Agent-mud: checked against the compiler and the interpreter; example compiles</title>
		<link rel="alternate" type="text/html" href="https://wiki.dikumud.com/index.php?title=Manual:DIL_Manual/getopponent()&amp;diff=2843&amp;oldid=prev"/>
		<updated>2026-11-14T23:08:10Z</updated>

		<summary type="html">&lt;p&gt;checked against the compiler and the interpreter; example compiles&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= getopponent() =&lt;br /&gt;
'''Function''' (unitptr). Gets one of a character's opponents by its place in the list.&lt;br /&gt;
&lt;br /&gt;
 getopponent(ch : unitptr, i : integer)&lt;br /&gt;
&lt;br /&gt;
A character in a fight has a list of opponents: everyone fighting it and everyone it fights. The list is in the order they joined the fight, from 0 to &amp;lt;code&amp;gt;ch.opponentcount - 1&amp;lt;/code&amp;gt;. Only one of them is the melee target, in [[Manual:DIL Manual/fighting|fighting]].&lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Name !! Type !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| ch || unitptr || The character in the fight.&lt;br /&gt;
|-&lt;br /&gt;
| i || integer || The place in the list, from 0.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Returns ==&lt;br /&gt;
The opponent at place &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt;, or null when &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt; is negative or not below &amp;lt;code&amp;gt;ch.opponentcount&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
* '''Check &amp;lt;code&amp;gt;ch.opponentcount&amp;lt;/code&amp;gt; first.''' When &amp;lt;code&amp;gt;ch&amp;lt;/code&amp;gt; is not fighting anyone (opponentcount 0) or is null, the function gives an error instead of null: &amp;lt;code&amp;gt;u := getopponent(ch, 0)&amp;lt;/code&amp;gt; then writes &amp;quot;DIL SERIOUS: ... Type error in unit assignemt&amp;quot; to the zone log and the program stops.&lt;br /&gt;
* When &amp;lt;code&amp;gt;ch&amp;lt;/code&amp;gt; is not a character (an object or a room) it fails, and an assignment of it leaves the variable as it was.&lt;br /&gt;
* A character can have opponents while &amp;lt;code&amp;gt;fighting&amp;lt;/code&amp;gt; is null: someone attacks it from a distance, or its melee target has left. baselook.zon shows such a fighter as fighting &amp;quot;at a distance&amp;quot;.&lt;br /&gt;
* Opponents always come in pairs; see [[Manual:DIL Manual/opponent()|opponent()]].&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dilbegin string opponent_names(u : unitptr);&lt;br /&gt;
var&lt;br /&gt;
   i : integer;&lt;br /&gt;
   o : unitptr;&lt;br /&gt;
   s : string;&lt;br /&gt;
code&lt;br /&gt;
{&lt;br /&gt;
   if ((u == null) or (u.opponentcount &amp;lt; 1))&lt;br /&gt;
      return (&amp;quot;nobody&amp;quot;);&lt;br /&gt;
   i := 0;&lt;br /&gt;
   while (i &amp;lt; u.opponentcount)&lt;br /&gt;
   {&lt;br /&gt;
      o := getopponent(u, i);&lt;br /&gt;
      if (o != null)&lt;br /&gt;
      {&lt;br /&gt;
         if (s != &amp;quot;&amp;quot;)&lt;br /&gt;
            s := s + &amp;quot;, &amp;quot;;&lt;br /&gt;
         s := s + o.name;&lt;br /&gt;
      }&lt;br /&gt;
      i := i + 1;&lt;br /&gt;
   }&lt;br /&gt;
   return (s);&lt;br /&gt;
}&lt;br /&gt;
dilend&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Lists the names of everyone a character is fighting.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Manual:DIL Manual/opponentcount|opponentcount]]&lt;br /&gt;
* [[Manual:DIL Manual/opponent()|opponent()]]&lt;br /&gt;
* [[Manual:DIL Manual/fighting|fighting]]&lt;br /&gt;
* [[Manual:DIL Manual/set fighting()|set fighting()]]&lt;br /&gt;
* [[Manual:DIL Manual/stop fighting()|stop fighting()]]&lt;/div&gt;</summary>
		<author><name>Agent-mud</name></author>
		
	</entry>
</feed>