agrip/nav.mqc File Reference

Go to the source code of this file.

Functions

void snap_nav_constructor ()
void snap_nav_main ()
void snap_nav_struct_main ()
float snap_nav_struct_detect (float dir, vector v_start, vector v_out, vector v_out_up)
void snap_nav_struct_soundout (float dir, float objtype)
void snap_nav_haz_main ()
float snap_nav_haz_detect (float fwd, vector v_start, vector v_dir, float reverse, float snd)
float snap_nav_z_main ()
void snap_nav_corners_main ()
float snap_nav_corners_check (vector v_cmid, vector v_coff)


Function Documentation

void snap_nav_constructor (  ) 

This is the ``constructor'' of the nav object. It sets up the device with all the user-defined settings and sets it off scanning.

Constructors, unlike other object functions, are run from the perspective of the player.

Definition at line 58 of file nav.mqc.

References entity(), and snap_nav_main().

Referenced by agh_client_startdevs(), and agh_weapons_impulsecommands().

float snap_nav_corners_check ( vector  v_cmid,
vector  v_coff 
)

Find corners - check that a corner point really is one.

We check that...

Parameters:
v_cmid the corner point to be examined
v_coff the v_corner_fwd already found.
Returns:
(true/false)

Definition at line 1047 of file nav.mqc.

References vector().

Referenced by snap_nav_corners_main().

void snap_nav_corners_main (  ) 

Find corners in front of the player. It will find left/right corners, and is designed with 90-degree angles in mind, but does also work for many of the other type of corner found in the game.

Like searching for drops, we need to search for corners and lock onto them.

Corners are searched for like this:

  1. Project forward and out.
  2. If we can, go left/right for, like, say, 400.
  3. If we could do that, trace from player to that out-side point.
  4. If that trace was blocked, there must have been a wall in the way -- corner!

When finished scanning...

There are a number of outcomes:

The scheme for sounding out is this:

  1. Sound out the middle forward point, followed by the left corner.
  2. Same as above for right corner.
  3. If there was no left and no right corner, just sound out the middle.

JUST PASSED A CORNER INDICATION May also need to be provided, so this function does that too.

Definition at line 796 of file nav.mqc.

References entity(), snap_nav_corners_check(), snap_se_cornersound(), and vector().

Referenced by snap_nav_main().

float snap_nav_haz_detect ( float  fwd,
vector  v_start,
vector  v_dir,
float  reverse,
float  snd 
)

Detect ledges/drops near the player. Make a sound based on how large the drop is and also work out what is contained within it (i.e. water, slime or lava). The calling function can do whatever it wants with this information. Read on for a detailed description of how this is all done.

Parameters:
fwd - are we doing this in the forward direction? (because only in fwd direction do we care about the hazard marker's position)
v_start - origin of trace
v_dir - direction vector projected from origin (just horizontal)
reverse - flag that specifies if the direction vector is to be used in reverse (for left/backwards scanning)
snd - make a sound?
Returns:
- the type of hazard we detected (if any) (used by the calling function to tell the player) this is always negative (a CONTENT_ value)
  • it returns 255 if there was no valid drop.
  • it returns 10 if the drop wasn't big enough.
  • it returns 0 if there was a drop but we aren't close enough to examine the contents of it.
GENERAL NOTES

FINDING A POTENTIAL DROP

We need to search out in front of us for a ledge. The hazard detection range is half of the nav detection range.

CHECKING THE POTENTIAL DROP IS VISIBLE

Check that we've not found a gap that is through the side of a corridor (by looking for a wall above it)... NB: This behaviour means that low walls (such as those on bridges) don't obscure our sight of drops (wouldn't for sighteds) but we also have to be fair and not let AGRIP players know about drops they shouldn't be able to see yet.

CHECKING IT IS A VALID DROP

If it is a valid drop...

There are drops that you would/wouldn't notice and drops that would hurt you -- we need to distinguish between them.

What we need to do:

  1. Trace down from the spot in front of us for, say, 400 units.
  2. See if the trace got interupted...
    1. If it didn't, the drop is a HUGE drop.
    2. If it did...
      1. The end point is either empty, water, slime or lava.
      2. Work out, based on the vlen from the trace, if the drop is a SMALL, BIG or HUGE drop and sound accordingly.
  3. If the player pressed the ``drop description'' key, tell them what lies in the pit.

SOUNDING OUT THE DROP or LETTING THE ESR DO IT

Work out how loud to make the sound that warns the player of the drop. The volume is based on how close the player is to the ledge.

RETURNING DROP INFORMATION

What lies beneath? :-) Return the contents of the pit, if the player is close enough to it. NB: The calling funtion should sort out whether or not it makes this information available to external objects/code.

If we are returning some kind of success (0 or >0), we should let the nav object know where to put the hazard marker entity...

Definition at line 562 of file nav.mqc.

References vector().

Referenced by snap_nav_haz_main().

void snap_nav_haz_main (  ) 

Work out the vectors involved in detecting drops, water, slime, lava and jumps around the player and call the functions that do the detection and ``sounding'' of such objects. This also stores the information returned by the detection function regarding what's in the drop pit and if the player can jump over the hazard in front of them.

The following properties of the D5k are used to store information: self.weapon - stores the type of pit filling in front of the player. self.takedamage - stores the jump flag.

DROP DESCRIPTIONS The player can request a description of what is in the pit. The detect function above has told us (if the player was close enough to the drop). However, we only want to tell the player about the drop in front of them (hence that is the only function we collect a haztype for).

JUMP DESCRIPTIONS We need to be able to say if the player could make the jump in front of them, in a similar way to drop types above.

Definition at line 480 of file nav.mqc.

References snap_misc_jumptest(), snap_nav_haz_detect(), and vector().

Referenced by snap_nav_main().

void snap_nav_main (  ) 

Main navigation aid function. Calls all the other ones.

Definition at line 128 of file nav.mqc.

References snap_nav_corners_main(), snap_nav_haz_main(), snap_nav_struct_main(), and snap_nav_z_main().

Referenced by snap_nav_constructor().

float snap_nav_struct_detect ( float  dir,
vector  v_start,
vector  v_out,
vector  v_out_up 
)

Do a trace between two vectors and detect the type of obj/surface present. It then returns a value indicating what it found.

Parameters:
dir direction we're scanning in relative to player
v_start origin of trace
v_out first vector projected from origin (just horizontal)
v_out_up 2nd vector projected from origin (has upward component)

Definition at line 219 of file nav.mqc.

References SNAP_NAV_STRUCT_DOOR, SNAP_NAV_STRUCT_SLOPE, SNAP_NAV_STRUCT_SLOPE_DOWN, SNAP_NAV_STRUCT_WALL, and vector().

Referenced by snap_nav_struct_main().

void snap_nav_struct_main (  ) 

Work out the vectors involved in detecting walls, slopes and doors around the player and call the functions that do the detection and ``sounding'' of such objects.

Definition at line 159 of file nav.mqc.

References SNAP_NAV_DIR_BCK, SNAP_NAV_DIR_FWD, SNAP_NAV_DIR_LFT, SNAP_NAV_DIR_RGT, snap_nav_struct_detect(), snap_nav_struct_soundout(), and vector().

Referenced by snap_nav_main().

void snap_nav_struct_soundout ( float  direction,
float  objtype 
)

Sound out a detected object/surface.

Parameters:
objtype tells it the type of object that was detected
direction tells it which direction we're scanning in
The property that controls the volume of the nav object is ``.ammo_rockets''. This operation knows which sounds we are allowed to make in certain directions (i.e. only play wall-hit sound behind the player.)

Definition at line 368 of file nav.mqc.

References SNAP_NAV_DIR_BCK, SNAP_NAV_DIR_FWD, SNAP_NAV_DIR_LFT, SNAP_NAV_DIR_RGT, SNAP_NAV_STRUCT_DOOR, SNAP_NAV_STRUCT_SLOPE, SNAP_NAV_STRUCT_SLOPE_DOWN, and SNAP_NAV_STRUCT_WALL.

Referenced by snap_nav_struct_main().

float snap_nav_z_main (  ) 

Keep track of where the player is, Z-wise, and inform them when they are going up/down.

The property that stores our owner's previous Z location is self.frame.

How this works is that we see what height we were at last time the D5k ran and compare it to where we are now...

Note: We have a tolerance of +/- 5 game units to avoid it being too verbose about Z changes.

Definition at line 746 of file nav.mqc.

Referenced by snap_nav_main().


Generated on Tue Jan 1 17:55:54 2008 for AudioQuake QuakeC by  doxygen 1.5.4