📄 qc-enty.htm
字号:
<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-ENTY">Quake-C Entity Definition</A></FONT></H1>
<p><i>Part of this information is derived from the DEM file specs 1.0.2
by <b>Uwe Girlich</b>.</i>
</p>
<p>In Quake, monsters, players, items, and the level itself are all entities.
There are three kind of entities, and you will all encounter them
in Quake-C code.
</p>
<h2>Types of entities</h2>
<h3><A NAME="qkc_static">Static entities</A></h3>
<p>A static entity doesn't interact with the rest of the game. These are
flames (progs/flame.mdl), lights, illusionary objects, and the like.
It is never be necessary to reference such an entity, so they don't get an
entity reference number.
</p>
<p>A static entity will be created by the function:
<pre>
<a href="qc-built.htm#makestatic" target="content">makestatic</a>()
</pre>
(it causes a spawnstatic message to be sent to every client).<br>
A static entity cannot be removed, once created.
</p>
<p> The <b>maximum</b> number of static entities is <b>127</b>.
</p>
<h3><A NAME="qkc_temporary">Temporary entities</A></h3>
<p>A temporary entity is a short life time entity. For instance, Quake
uses these entities for hits on the wall (point-like entities)
or for the Thunderbolt flash (line-like entities), gun shots,
and anything that is not supposed to last more than one frame.
</p>
<p>A temporary entity will be created by sending a valid
<a href="qc-net.htm#msg_temporary" target="content">temporary</a> entity message.<br>
A temporary entity need not be removed, it disapears by itself.
</p>
<h3><A NAME="qkc_dynamic">Dynamic entities</A></h3>
<p>A dynamic entity is anything which changes its behaviour or its
appearance. These are ammunition boxes, spinning armors, player
models and the like.
</p>
<p>A dynamic entity will be created by the sequence:
<pre>
<b>entity</b> = <a href="qc-built.htm#spawn" target="content">spawn</a>();
<a href="qc-built.htm#setmodel" target="content">setmodel</a>( <b>entity</b>, "progs/entity.mdl" );
<a href="qc-built.htm#setsize" target="content">setsize</a>( <b>entity</b>, <i>vector_min</i>, <i>vector_max</i>);
<a href="qc-built.htm#setorigin" target="content">setorigin</a>( <b>entity</b>, <i>position</i> );
</pre>
It will have to be removed by the function:
<pre>
<a href="qc-built.htm#remove" target="content">remove</a>( <b>entity</b> );
</pre>
</p>
<p> The maximum number of dynamic entities is <b>449</b>.
</p>
<hr>
<h2>Definition of entity fields</h2>
<p>These are the fields that are available in the entity objects
(like self, other). Beware that this is not true object oriented
programming: there is no protection when accessing those fields,
and no guaranty on the validity of values. So if you put garbage
there you will probably crash the game.
</p>
<p>You can add custom fields (for instance, to store
the ammo count of a new weapon you created) but those fields
must <b>not</b> be situated among thoses that are common between
Quake-C and Quake.exe. Otherwise, Quake.exe would have to be
re-compiled. So those fields must be situated after the fake
variable called <b>end_sys_fields</b>, in the field definitions.
</p>
<h3>Fields shared between Quake.exe and Quake-C</h3>
<p>These fields describe the most common entity fields. They are shared
between the C code of Quake.exe, and the Quake-C code of <b>PROGS.DAT</b>.
</p>
<p>Some of the fields are managed by the C code: you can read their value, but
<b>YOU SHOULD NEVER MODIFY THEIR VALUE DIRECTLY</b> (there are special
built-in functions for that).
</p>
<p>Please <b>only</b> modify those fields that are indicated in <b>boldface</b>.
</p>
<h5>Technical data</h5>
<p><pre>
entity <b><a name="dot_chain">chain</a></b>; // next entity, in a chain list of entities
float <b><a name="dot_ltime">ltime</a></b>; // local time for entity
float <b><a name="dot_teleport_time">teleport_time</a></b>; // to avoid backing up
float <a name="dot_spawnflags">spawnflags</a>; // see <a href="qc-defs.htm#d_spawnflags" target="content">possible values</a>.
</pre>
</p>
<h5>Appearance of entity</h5>
<p><pre>
float <a name="dot_modelindex">modelindex</a>; // index of model, in the precached list
string <b><a name="dot_classname">classname</a></b>; // spawn function
</pre>
</p>
<p><pre>
string <b><a name="dot_model">model</a></b>;
</pre>
The name of the file that contains the entity model.
</p>
<p><pre>
float <b><a name="dot_frame">frame</a></b>;
</pre>
This is the index of the currently displayed model frame.
Frames must be defined by a <a href="qc-mdl.htm#s_frame" target="content">$frame</a> construct in the model file,
and manipulated in the code as <b>$xxx</b> (where xxx is the name of the frame).
</p>
<p><pre>
float <b><a name="dot_skin">skin</a></b>;
</pre>
This is the index of the model skin currently displayed.
If your model has more than one skin defined, then this value indicates the
skin in use. You can change it freely, as long as it remains in a valid range.
For instance, it's used by the armor model to show the yellow, red or green skin.
</p>
<p><pre>
float <b><a name="dot_effects">effects</a></b>;
</pre>
This is a flag that defines the special light <a href="qc-defs.htm#d_effects" target="content">effects</a> that
the entity is subject to. This can supposedly be used to make an entity
glow, or to create a glowing field of dots around it.</p>
<h5>Position in 3D</h5>
<p><pre>
vector <a name="dot_origin">origin</a>; // position of model
// <a name="dot_origin_x">origin_x</a>, <a name="dot_origin_y">origin_y</a>, <a name="dot_origin_z">origin_z</a>
vector <a name="dot_mins">mins</a>; // bounding box extents reletive to origin
// mins_x, mins_y, mins_z
vector <a name="dot_maxs">maxs</a>; // bounding box extents reletive to origin
// maxs_x, maxs_y, maxs_z
vector <a name="dot_size">size</a>; // maxs - mins
// <a name="dot_size_x">size_x</a>,<a name="dot_size_y">size_y</a>,<a name="dot_size_z">size_z</a>
vector <a name="dot_absmin">absmin</a>; // origin + mins and maxs
// absmin_x absmin_y absmin_z
vector <a name="dot_absmax">absmax</a>; // origin + mins and maxs
// absmax_x absmax_y absmax_z
vector <a name="dot_oldorigin">oldorigin</a>; // old position
vector <b><a name="dot_angles">angles</a></b>; // = 'pitch_angle yaw_angle flip_angle'
</pre>
</p>
<p>Quirks: setting the angles on a player entity doesn't work.</p>
<h5>Situation of the entity</h5>
<p><pre>
float <b><a name="dot_waterlevel">waterlevel</a></b>; // 0 = not in water, 1 = feet, 2 = waist, 3 = eyes
float <b><a name="dot_watertype">watertype</a></b>; // a <a href="qc-defs.htm#d_contents" target="content">content</a> value
entity <b><a name="dot_groundentity">groundentity</a></b>; // indicates that the entity moves on the ground
</pre>
</p>
<p>Since groundentity is used nowhere in progs, it's meaning is just a wild guess
from a similar field in messages.</p>
<h5>Movement in 3D</h5>
<p><pre>
vector <b><a name="dot_velocity">velocity</a></b>; // = 'speed_x speed_y speed_z'
vector <b><a name="dot_avelocity">avelocity</a></b>; // = 'pitch_speed yaw_speed 0', angle velocity
vector <b><a name="dot_punchangle">punchangle</a></b>; // temp angle adjust from damage or recoil
float <b><a name="dot_movetype">movetype</a></b>; // <a href="qc-defs.htm#d_movetype" target="content">type</a> of movement
float <b><a name="dot_yawspeed">yaw_speed</a></b>; // rotation speed
float <b><a name="dot_solid">solid</a></b>; // tell if entity <a href="qc-defs.htm#d_solid" target="content">can block</a> the movements.
</pre>
</p>
<h5>Monster's Behavior</h5>
<pre>
entity <b><a name="dot_goalentity">goalentity</a></b>; // Monster's movetarget or enemy
float <b><a name="dot_ideal_yaw">ideal_yaw</a></b>; // Monster's ideal direction, on paths
float <b><a name="dot_yaw_speed">yaw_speed</a></b>; // Monster's yaw speed.
string <b><a name="dot_target">target</a></b>; // Target of a monster
string <b><a name="dot_targetname">targetname</a></b>; // name of the target
</pre>
<h5>Automatic Behavior</h5>
<p><pre>
float <b><a name="dot_nextthink">nextthink</a></b>; // next time when entity must act
void() <b><a name="dot_think">think</a></b>; // function invoked when entity must act
void() <b><a name="dot_touch">touch</a></b>; // function invoked if entity is touched
void() <b><a name="dot_use">use</a></b>; // function invoked if entity is used
void() <b><a name="dot_blocked">blocked</a></b>; // function for doors or plats, called when can't push other
vector <b><a name="dot_movedir">movedir</a></b>; // mostly for doors, but also used for waterjump
string <b><a name="dot_message">message</a></b>; // trigger messages
float <b><a name="dot_sounds">sounds</a></b>; // either a cd track number or sound number
string <b><a name="dot_noise">noise</a></b>; // soudn played on entity noise channel 1
string <b><a name="dot_noise1">noise1</a></b>;
string <b><a name="dot_noise2">noise2</a></b>;
string <b><a name="dot_noise3">noise3</a></b>;
</pre>
</p>
<p><i>Information by <a href="http://www.znet.com/~abducted/quake.html">Abducted</a>:</i><br>
When you want an entity to do something specific, after a certain delay
(exploding, disapearing, or the like...), you set <b>nextthink</b> to that delay
(in seconds), and set <b>think</b> to the function to execute.
</p>
<p><i>Information by Greg Lewis:</i><br>
It seems that the touch function is called before the <a href="qc-enty.htm#dot_movetype" target="content">field</a> is checked,
so you can set this type in the touch function, and it will immediatly
be taken into account.
</p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -