Spatial Sensing

gi.trace(point1, vector1, vector2, point2, ignore, mask)

Traces a box from point1 to point2, ignoring entity ignore, stoping if it hits an object of type specified in mask. Vector1 and vector2 set the box, which will do the tracing - if NULL, then a line is used instead

Returns value of type trace_t with one of these attributes:

  • allsolid

boolean - if true, entire trace was in a wall

  • startsolid

boolean - if true, trace started in a wall

  • fraction

fraction of trace completed (1.0 if totally completed)

  • endpos

point where trace ended

  • plane

surface normal at hitpoint (type cplane_t)

  • surface

surface hit (type csurface_t)

  • contents

contents of point at end of trace (see gi.pointcontents for values)

  • ent

entity hit by trace

Mask can be one (or more) of contents values (see gi.pointcontents) or can be one of :

  • MASK_ALL

stop on anything

  • MASK_SOLID

solid wall

  • MASK_PLAYERSOLID

solid wall or player or non-solid monster?

  • MASK_DEADSOLID

solid wall or player

  • MASK_MONSTERSOLID

solid wall or monster

  • MASK_WATER

any liquid

  • MASK_OPAQUE

walls and liquid except water (see thru)

  • MASK_SHOT

anything hit by weapons

  • MASK_CURRENT

current contents?

gi.AreasConnected (int areanum1, int areanum2)

Checks if two areas are connected - used to check whether a monster can hear a sound or not

Returns 1 or 0

gi.pointcontents (point)

Returns the content of the given point, will be one of:

  • CONTENTS_SOLID

solid wall (not windows)

  • CONTENTS_WINDOW

windows

  • CONTENTS_AUX

?

  • CONTENTS_LAVA

err.. lava

  • CONTENTS_SLIME

slime

  • CONTENTS_WATER

water

  • CONTENTS_MIST

Unused!!

  • LAST_VISIBLE_CONTENTS

?

  • CONTENTS_AREAPORTAL

portals to conserve memory used in map designing, also dont allow sounds to pass //kami0

  • CONTENTS_PLAYERCLIP

brush which player may not pass through //kami0

  • CONTENTS_MONSTERCLIP

brush where monsters may not pass through //kami0

  • CONTENTS_CURRENT_0

flowing current moving at angle 0 //kami0

  • CONTENTS_CURRENT_90

flowing current moving at angle 90 //kami0

  • CONTENTS_CURRENT_180

flowing current moving at angle 180 //kami0

  • CONTENTS_CURRENT_270

flowing current moving at angle 270 //kami0

  • CONTENTS_CURRENT_UP

flowing current moving up //kami0

  • CONTENTS_CURRENT_DOWN

flowing current moving down //kami0

  • CONTENTS_ORIGIN

used for rotation, invisible //kami0

  • CONTENTS_MONSTER

non-solid monster?

  • CONTENTS_DEADMONSTER

dead monster

  • CONTENTS_DETAIL

brush that is not passed to vis - not in final BSP ?

  • CONTENTS_TRANSLUCENT

see through

  • CONTENTS_LADDER

ladder

gi.BoxEdicts (mins, maxs, entity_list, maxcount, areatype)

Generates a list of all the entities in a certain box. Mins and maxs define the box (relative to level origin). entity_list (type edict_t *varname[])

maxcount - number of entities to give

areatype - type of entity, can be :

AREA_SOLID

find solids

AREA_TRIGGERS

find triggers

Returns number of entities found

gi.SetAreaPortalState (poral_num, open)

Set when a door opens or closes (to prevent sound detection through closed doors?)

gi.inPVS (point1, point2)

Checks to see if point2 is in the Potentially Visible Set of point1. The potentially visible set (PVS) is a data structure used by Quake2 to determine visibility and lines of sight. Note that if point2 is in the PVS of point1, then point1 will also be in the PVS of point2, hence the first law of optics: if I can see you, then you can see me.

gi.inPHS (point1, point2)

Checks to see if point2 is in the Potentially Hearable Set of point1. The PHS is the same concept as a PVS, except it tracks sound instead of sight.