Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!

Difference between revisions of "checkclient"

From Quake Wiki

(Created page with "====Syntax:==== <code>entity checkclient()</code> This function returns a potentially visible player for the current self entity. Mainly used by monsters to detect players n...")
 
 
Line 1: Line 1:
====Syntax:====
+
''entity'' '''checkclient'''()
<code>entity checkclient()</code>
 
  
This function returns a potentially visible player for the current self entity. Mainly used by monsters to detect players nearby.  Note that this only uses the PVS to determine 'visibility', but actual line of sight is checked afterwards in QC.
+
== Usage ==
====Parameters:====
+
When a monster is searching for a valid enemy, this function will handle grabbing a potential target. This uses the PVS to check visible players meaning an actual line of sight won't be guaranteed and should be tested against.
:None
 
====Returns:====
 
:Returns a player entity that might be able to be seen by the current self entity.
 
  
 +
'''Warning:''' The function assumes that '''self''' is the current entity that's looking for a valid enemy.
 +
 +
=== Return ===
 +
A potentially visible player.
 +
 +
== Example ==
 +
// This function tries to find a new enemy for the monster
 +
void FindNewEnemy()
 +
{
 +
    entity newEnemy = checkclient();
 +
 +
    // Check to make sure it's a valid enemy
 +
    if (!newEnemy || newEnemy == self.enemy)
 +
        return;
 +
    if (!visible(newEnemy))
 +
        return;
 +
 +
    // ...
 +
}
  
 
[[Category:QuakeC Function]]
 
[[Category:QuakeC Function]]

Latest revision as of 14:21, 31 July 2023

entity checkclient()

Usage[edit]

When a monster is searching for a valid enemy, this function will handle grabbing a potential target. This uses the PVS to check visible players meaning an actual line of sight won't be guaranteed and should be tested against.

Warning: The function assumes that self is the current entity that's looking for a valid enemy.

Return[edit]

A potentially visible player.

Example[edit]

// This function tries to find a new enemy for the monster
void FindNewEnemy()
{
    entity newEnemy = checkclient();

    // Check to make sure it's a valid enemy
    if (!newEnemy || newEnemy == self.enemy)
        return;
    if (!visible(newEnemy))
        return;

    // ...
}