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

Difference between revisions of "pointcontents"

From Quake Wiki

(Initial draft.)
 
 
Line 1: Line 1:
====Syntax:====
+
''float'' '''pointcontents'''(''vector'' pos)
<code>float pointcontents(vector pos)</code>
 
  
Checks the given point to see what is there. Just because a point is empty does not mean that the player can stand there due to the size of the player - use [[tracebox]] for such tests.
+
== Usage ==
 +
Gets what kind of contents exist at the given point. Only the world is taken into account for this, entities like monsters are ignored.
  
====Parameters:====
+
=== Parameters ===
:<code>pos</code> - The position to test.
+
*''pos''
====Returns:====
+
:The position to get the contents from.
:Returns one of the CONTENT_* constants. See [[QuakeC_Globals|QuakeC Globals]] for examples.
 
  
 +
=== Return ===
 +
One of the following:
 +
*<code>CONTENT_EMPTY</code>
 +
:Not inside anything.
 +
*<code>CONTENT_SOLID</code>
 +
:Inside of solid level geometry.
 +
*<code>CONTENT_WATER</code>
 +
:Inside of water.
 +
*<code>CONTENT_SLIME</code>
 +
:Inside of slime.
 +
*<code>CONTENT_LAVA</code>
 +
:Inside of lava.
 +
*<code>CONTENT_SKY</code>
 +
:Inside the sky.
 +
 +
== Example ==
 +
// If there's something at the given location, this function won't place the entity there
 +
float CheckMove(vector pos)
 +
{
 +
    float contents = pointcontents(pos);
 +
    if (contents != CONTENT_EMPTY)
 +
        return FALSE;
 +
 +
    setorigin(self, pos);
 +
    return TRUE;
 +
}
  
 
[[Category:QuakeC Function]]
 
[[Category:QuakeC Function]]

Latest revision as of 13:01, 1 August 2023

float pointcontents(vector pos)

Usage[edit]

Gets what kind of contents exist at the given point. Only the world is taken into account for this, entities like monsters are ignored.

Parameters[edit]

  • pos
The position to get the contents from.

Return[edit]

One of the following:

  • CONTENT_EMPTY
Not inside anything.
  • CONTENT_SOLID
Inside of solid level geometry.
  • CONTENT_WATER
Inside of water.
  • CONTENT_SLIME
Inside of slime.
  • CONTENT_LAVA
Inside of lava.
  • CONTENT_SKY
Inside the sky.

Example[edit]

// If there's something at the given location, this function won't place the entity there
float CheckMove(vector pos)
{
    float contents = pointcontents(pos);
    if (contents != CONTENT_EMPTY)
        return FALSE;

    setorigin(self, pos);
    return TRUE;
}