c_scan (VECTOR* pos, ANGLE* ang, VECTOR* sector, var mode);
Detects entities or other objects within a
cone or sphere, and triggers their EVENT_SCAN event.
Parameters:
| pos |
scan origin. |
| ang |
scan direction Euler 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 me 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 was found.
Modifies:
| you |
Pointer to the closest detected entity. |
| result |
Distance to the closest detected object. |
| target |
Position of the closest detected object. |
| bounce |
Direction to the closest detected camera position. |
| tex_color |
Color of the closest detected static light. |
Remarks:
- SCAN_ENTS scans for the
object's origin only. If you have a large object,
make sure the origin
still lies within the scan cone.
- 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.
To ignore
a certain entity, set me or you to the entity
pointer.
- 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
{
c_scan(camera.x,camera.pan,vector(120,0,200),SCAN_ENTS | SCAN_LIMIT);
}
...
on_space = operate;
See also:
c_trace, path_scan,
EVENT_DETECT, EVENT_SCAN