c_scan
(VECTOR* pos, ANGLE* dir, VECTOR* sector, var mode);
Detects entities or other objects within a level segment.
Parameters:
| pos |
scan
origin. |
| dir |
scan
direction angle. |
| sector.x |
horizontal
scan sector, or
scan cone
width in degrees (360 for a full sphere) |
| sector.y |
vertical
scan sector in degrees, or 0 for a circular
scan
cone. |
| sector.z |
scan
range in quants. |
| mode |
scan
mode (see below). |
The following mode values can be set:
| IGNORE_ME |
Ignores the my entity; can be combined with
SCAN_ENTS. |
| IGNORE_YOU |
Ignores the you entity; can be combined with
SCAN_ENTS. |
| SCAN_ENTS |
Scans for entities within the cone, and triggers their EVENT_SCAN
event.
|
| SCAN_POS |
Scans for
camera positions placed in the level. |
| SCAN_PATHS |
Scans for path start positions. |
| SCAN_NODES |
Scans for path node positions. |
| SCAN_LIGHTS |
Scans for static lights. |
| SCAN_LIMIT |
Finds only entities with
ENABLE_SCAN
set, or only static lights whose range can reach the
scan
origin. Can be combined with
SCAN_ENTS
and SCAN_LIGHTS. |
Returns:
Distance to closest object found, or 0 if no object found.
Modifies:
| you |
Pointer to the closest detected entity. |
| result |
Distance to the closest detected object. |
| target |
Position of the closest detected object. |
| bounce |
Angle of the closest detected level camera position. |
| tex_color |
Color of the closest detected static light. |
Remarks:
SCAN_ENT
scans for the object's origin only. If you have a large object, you will
probably need to increase the
scan range or add
additional triggers around the object's circumference.
If any entity with ENABLE_SCAN
set is found with it's center within the
scan segment,
it's event function is triggered with
event_type set to EVENT_SCAN,
result set to the distance and you set to the
scanning entity, if any.
If the my entity has ENABLE_DETECT set, it's
event function is triggered once for every detected entity. During the
event, event_type is set to
EVENT_DETECT and you is set to the detected entity. This way all
detected entities can be enumerated.
To prevent that a scanning entity triggers itself, set IGNORE_ME.
The function scans through walls - so don't use it for gunshots (use c_trace
for that). However it is very useful to open doors, set switches, detect or
alert enemies, apply explosion damage and so on.
Speed:
Slow
Example:
function operate() // scan nearby doors or switches for operating them
{
me = player;
c_scan(camera.x,camera.pan,vector(120,0,200),SCAN_ENT | SCAN_LIMIT | IGNORE_ME);
}
See also:
c_trace,
path_scan