⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qc-built.htm

📁 Quake 的 各 种 文 档 格 式 说 明
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<HTML><HEAD>
<TITLE>Quake-C Specificacions  v1.0</TITLE>
<LINK REV="MADE" HREF="mailto:100625.2622@compuserve.com">
</HEAD>  
<BODY BGCOLOR="#FFFFFF">

<H1><FONT COLOR="#007F00"><A NAME="QC-BUILT">Quake-C Built-in functions</A></FONT></H1>
 

<p>These are the built-in functions of Quake C. Since they are hard-coded
in C, they cannot be redefined, but they are very fast.
</p>

<h3>Basic math functions</h3>

<h4>Function: <a name="anglemod">anglemod</a></h4>
<p><pre>
float <b>anglemod</b> (float <i>angle</i>)
</pre>
returns <i>angle</i> in degree, module 360.
</p>    
<h4>Function: <a name="rint">rint</a></h4>
<p><pre> 
 float <b>rint</b>(float <i>val</i>)
</pre>
Returns <i>val</i>, rounded up to the closest integer value.
</p> 
<h4>Function: <a name="floor">floor</a></h4>
<p><pre> 
 float <b>floor</b>(float <i>val</i>)
</pre>
Returns <i>val</i>, rounded up to the integer below (like the equivalent function in C).
</p> 
<h4>Function: <a name="ceil">ceil</a></h4>
<p><pre> 
 float <b>ceil</b>(float <i>val</i>)
</pre>
Returns <i>val</i>, rounded up to the integer above
(like the equivalent function in C).
</p>
<h4>Function: <a name="fabs">fabs</a></h4>
<p><pre> 
 float <b>fabs</b>(float <i>val</i>)
</pre>
Returns absolute value of <i>val</i>
(like the equivalent function in C).
</p>

<h4>Function: <a name="random"></a>random</h4>
<p>Returns a random floating point number between 0.0 and 1.0.</p>


<h4>Function: <a name="ftos">ftos</a></h4>
<p><pre>
string <b>ftos</b>(float <i>value</i>)
</pre>
Float to string: converts <i>value</i> to string.
</p>
    


<h3>Basic vector maths</h3>

<h4>Function: <a name="normalize">normalize</a></h4>
<p><pre>
vector <b>normalize</b>(vector v)
   returns a vector of length 1
</pre>
Gives the vector colinear to <i>v</i>, but of length 1.
This can be useful for calculation of distance along an axis.
</p>
<h4>Function: <a name="vlen">vlen</a></h4>
<p><pre>
float <b>vlen</b>(vector v)
</pre>
Returns the length of vector <i>v</i> (never &lt; 0).
</p>

<h4>Function: <a name="vectoyaw">vectoyaw</a></h4>
<p><pre>
float vectoyaw(vector <i>v</i>)
   returns and angle in degree
</pre>
Vector to yaw: calculates the yaw angle (bearing) corresponding
to a given 3D direction <i>v</i>.
</p>
<h4>Function: <a name="vectoangles">vectoangles</a></h4>
<p><pre>
vector vectoangles(vector <i>v</i>)
   returns vector 'pitch  yaw  0 '
</pre>
Vector to angles: calculates the pitch angle (aiming) and 
yaw angle (bearing) corresponding to a given 3D direction <i>v</i>.
</p>
<h4>Function: <a name)"vtos">vtos</a></h4>
<p><pre>
string <b>vtos</b>(vector <i>v</i>)
</pre>
Vector to String: print a vector, as a string.
</p>
<h4>Function: <a name="makevectors">makevectors</a></h4>
<p><pre>
void <b>makevectors</b>(vector <i>angles</i>)
  <i>angle</i> = 'pitch yaw 0' 
</pre>
Calculate the vectors pointing forward, right and 
up, according to the provided angles.<br>
Returns result in the global variables:
<pre>	
vector	<a name="v_forward">v_forward</a>;  // points forward
vector  <a name="v_up">v_up</a>;       // points up
vector  <a name="v_right">v_right</a>;    // points toward the right
</pre>
</p>

<hr>

<h3>Sound emission</h3>

<h4>Function: <a name="sound">sound</a></h4>
<pre>
void <b>sound</b> (entity <i>source</i>, float <i>channel</i>, string <i>sample</i>, float <i>volume</i>, float <i>attenuation</i>)
  <i>source</i> = entity emiting the sound (ex: self)
  <i>channel</i> = <a href="qc-defs.htm#d_channel" target="content">channel</a> to use for sound 
  <i>sample</i> = name of the sample WAV file (ex: "ogre/ogdrag.wav")
  <i>volume</i> = 0.0 for low volume, 1.0 for maximum volume
  <i>attenuation</i>= <a href="qc-defs.htm#d_attenuate" target="content">attenuation</a> of sound 
</pre>
The entity emits a sound, on one of it's 8 channels.

<h4>Function: <a name="ambientsound">ambientsound</a></h4>

<pre>
void <b>ambientsound</b>(vector <i>position</i>, string <i>sample</i>, float <i>volume</i>, float <i>attenuation</i>)
  <i>position</i> = position, in 3D space, inside the level
  <i>sample</i> = name of the sample WAV file (ex: "ogre/ogdrag.wav")
  <i>volume</i> = 0.0 for low volume, 1.0 for maximum volume
  <i>attenuation</i>= <a href="qc-defs.htm#d_attenuate" target="content">attenuation</a> of sound 
</pre>
An ambient sound is emited, from the given position.

<hr>

<h3>Entity management</h3>

<h4>Function: <a name="spawn">spawn</a></h4>
<pre>
entity <b>spawn</b> ()
       returns an empty entity.
</pre>
Create a new entity, totally empty. You can manually set 
every field, or just set the origin and call one of the 
existing entity setup functions.

<h4>Function: <a name="remove">remove</a></h4>
<pre>
void <b>remove</b> (entity <i>e</i>)
</pre>
Removes entity <i>e</i> from the world (R.I.P.).

<h4>Function: <a name="makestatic">makestatic</a></h4>
<pre>
void <b>makestatic</b> (entity <i>e</i>)
</pre>
Make an entity <a href="qc-enty.htm#qkc_static" target="content">static</a> to the world, by sending a 
broadcast message to the network.
<br>
The entity is then removed from the list of <a href="qc-enty.htm#qkc_dynamic" target="content">dynamic</a>
entities in the world, and it cannot be deleted (until the level ends).

<h4>Function: <a name="nextent">nextent</a></h4>
<pre>
entity <b>nextent</b>(entity <i>e</i>)
</pre>
Returns entity that is just after <i>e</i> in the entity list.
<br>
Useful to browse the list of entities, because it skips the 
undefined ones.

<h4>Function: <a name="find">find</a></h4>
<p><pre>
entity <b>find</b> (entity <i>start</i>, .string <i>field</i>, string <i>match</i>)
	<i>start</i> = begining of list to search (<a href="qc-glob.htm#world" target="content">world</a>, for the begining of list)
	<i>field</i> = entity field that must be examined (ex: </b>targetname<b>)
	<i>match</i> = value that must be matched (ex: <b>other.target</b>)
	returns the entity found, or <a href="qc-glob.htm#world" target="content">world</a> if no entity was found.
</pre>
Searches the server entity list beginning at start, looking 
for an entity that has entity.field = match.</p>  
<p>Example: find the first player entity
<pre>
 e = <b>find</b>( <a href="qc-glob.htm#world" target="content">world</a>, <a href="qc-enty.htm#dot_classname" target="content">classname</a>, "player");
</pre>
Take care that field is a name of an entity field, without dot, and without quotes.
</p>

<h4>Function: <a name="findradius">findradius</a></h4>

<pre>
entity <b>findradius</b> (vector <i>origin</i>, float <i>radius</i>)
        <i>origin</i> = origin of sphere
        <i>radius</i> = radius of sphere
</pre>
Returns a chain of entities that have their origins within a spherical area.
<br>
The entity returned is <i>e</i>, and the next in the chain is
<i>e</i>.<a href="qc-enty.htm#dot_chain" target="content">chain</a>, until <i>e</i>==FALSE.
<br>
Typical usage: find and harm the victims of an explosion.
<pre>
  e = findradius( origin, radius)
  while(e)
  {
    T_Damage(e, ... ) // Let God sort his ones!
    e = e.<a href="qc-enty.htm#dot_chain" target="content">chain</a>
  }
</pre>

<h4>Function: <a name="setmodel">setmodel</a></h4>
<pre>
void <b>setmodel</b> (entity <i>e</i>, string <i>model</i>)
  <i>e</i> = entity whose model is to be set
  <i>model</i> = name of the model (ex: "progs/soldier.mdl")
</pre>
Changes the model associated to an entity. This model should 
also be declared by <a href="qc-built.htm#precache_model" target="content">precache_model</a>.
Please set <i>e</i>.<a href="qc-enty.htm#dot_movetype" target="content">movetype</a> and 
<i>e</i>.<a href="qc-enty.htm#dot_solid" target="content">solid</a> first.
  
<h4>Function: <a name="lightstyle">lightstyle</a></h4>
<pre>
void lightstyle(float <i>style</i>, string <i>value</i>)
        <i>style</i> = index of the light style, from 0 to 63.
        <i>value</i> = (ex: "abcdefghijklmlkjihgfedcb")
</pre>
Modifies a given light style. The light style is used to create
cyclic lighting effects, like torches or teleporter lighting.
<br>
There are 64 light styles, from 0 to 63. If <i>style</i> is 
not strictly comprised in these values, the game may crash.
<br>
styles 32-62 are assigned by the light program for switchable 
lights.
<br>
<i>value</i> is a set of characters, whose ascii value 
indicates a light level, from "a" (0) to "z" (30).


<hr>

<h3>Move Entities</h3>

<h4>Function: <a name="ChangeYaw">ChangeYaw</a></h4>
<pre>
void ChangeYaw()
</pre>
Change the horizontal orientation of <a href="qc-glob.htm#self" target="content">self</a>.
Turns towards self.<a href="qc-enty.htm#dot_ideal_yaw" target="content">ideal_yaw</a> at 
self.<a href="qc-enty.htm#dot_yaw_speed" target="content">yaw_speed</a>, and sets the
global variable current_yaw.
<br>
Called every 0.1 sec by monsters  

<h4>Function: <a name="walkmove">walkmove</a></h4>
<pre>
float walkmove(float <i>yaw</i>, float <i>dist</i>)
       returns TRUE or FALSE 
</pre>
Moves <a href="qc-glob.htm#self" target="content">self</a> in the given direction.
<br>
Returns FALSE if could not move (used to detect blocked monsters).

<h4>Function: <a name="droptofloor">droptofloor</a></h4>
<pre>
float droptofloor()
       returns TRUE or FALSE 
</pre>
Drops <a href="qc-glob.htm#self" target="content">self</a> to the floor, if the floor is
less than <b>-256</b> coordinates below.
<br>
Returns TRUE if landed on floor.
<br>
Mainly used to spawn items or walking monsters on the floor.


<h4>Function: <a name="setorigin">setorigin</a></h4>
<pre>
void <b>setorigin</b> (entity <i>e</i>, vector <i>position</i>)
  <i>e</i> = entity to be moved
  <i>position</i> = new position for the entity
</pre>
Move an entity to a given location. That function is to be used
when spawning an entity or when teleporting it.
<br>
This is the only valid way to move an object without using 
the physics of the world (setting velocity and waiting).
<br>
<b>DO NOT</b> change directly <i>e</i>.origin, otherwise internal
links would be screwed, and entity clipping would be messed up.


<h4>Function: <a name="setsize">setsize</a></h4>
<pre>
void <b>setsize</b> (entity <i>e</i>, vector <i>min</i>, vector <i>max</i>)
  <i>e</i> = entity whose bounding box is to be set  
  <i>min</i> = minimum, for bounding box (ex: VEC_HULL2_MIN)
  <i>max</i> = maximum, for bounding box (ex: VEC_HULL2_MAX)
</pre>
Set the size of the entity bounding box, relative to the
entity origin. The size box is rotated by the current angle.


<h4>Function: <a name="movetogoal">movetogoal</a></h4>
<pre>
void <b>movetogoal</b> (float <i>step</i>)
</pre>
Move <a href="qc-glob.htm#self" target="content">self</a> toward it's goal.
<br>
Used for monsters.


<hr>

<h3>Fights and Shots</h3>

<h4>Function: <a name="aim">aim</a></h4>
<pre>
vector <b>aim</b>(entity <i>e</i>, float <i>missilespeed</i>)
</pre>
Returns a vector along which the entity <i>e</i> can shoot.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -