vkQuake2 doxygen  1.0 dev
p_trail.c File Reference
#include "g_local.h"

Go to the source code of this file.

Macros

#define TRAIL_LENGTH   8
 
#define NEXT(n)   (((n) + 1) & (TRAIL_LENGTH - 1))
 
#define PREV(n)   (((n) - 1) & (TRAIL_LENGTH - 1))
 

Functions

void PlayerTrail_Init (void)
 
void PlayerTrail_Add (vec3_t spot)
 
void PlayerTrail_New (vec3_t spot)
 
edict_tPlayerTrail_PickFirst (edict_t *self)
 
edict_tPlayerTrail_PickNext (edict_t *self)
 
edict_tPlayerTrail_LastSpot (void)
 

Variables

edict_ttrail [TRAIL_LENGTH]
 
int trail_head
 
qboolean trail_active = false
 

Macro Definition Documentation

◆ NEXT

#define NEXT (   n)    (((n) + 1) & (TRAIL_LENGTH - 1))

Definition at line 45 of file p_trail.c.

◆ PREV

#define PREV (   n)    (((n) - 1) & (TRAIL_LENGTH - 1))

Definition at line 46 of file p_trail.c.

◆ TRAIL_LENGTH

#define TRAIL_LENGTH   8

Definition at line 39 of file p_trail.c.

Function Documentation

◆ PlayerTrail_Add()

void PlayerTrail_Add ( vec3_t  spot)

Definition at line 67 of file p_trail.c.

68 {
69  vec3_t temp;
70 
71  if (!trail_active)
72  return;
73 
74  VectorCopy (spot, trail[trail_head]->s.origin);
75 
77 
78  VectorSubtract (spot, trail[PREV(trail_head)]->s.origin, temp);
79  trail[trail_head]->s.angles[1] = vectoyaw (temp);
80 
82 }

Referenced by ClientBeginServerFrame(), and PlayerTrail_New().

◆ PlayerTrail_Init()

void PlayerTrail_Init ( void  )

Definition at line 49 of file p_trail.c.

50 {
51  int n;
52 
53  if (deathmatch->value /* FIXME || coop */)
54  return;
55 
56  for (n = 0; n < TRAIL_LENGTH; n++)
57  {
58  trail[n] = G_Spawn();
59  trail[n]->classname = "player_trail";
60  }
61 
62  trail_head = 0;
63  trail_active = true;
64 }

Referenced by PlayerTrail_New(), and SpawnEntities().

◆ PlayerTrail_LastSpot()

edict_t* PlayerTrail_LastSpot ( void  )

Definition at line 143 of file p_trail.c.

144 {
145  return trail[PREV(trail_head)];
146 }

Referenced by ClientBeginServerFrame().

◆ PlayerTrail_New()

void PlayerTrail_New ( vec3_t  spot)

Definition at line 85 of file p_trail.c.

86 {
87  if (!trail_active)
88  return;
89 
91  PlayerTrail_Add (spot);
92 }

◆ PlayerTrail_PickFirst()

edict_t* PlayerTrail_PickFirst ( edict_t self)

Definition at line 95 of file p_trail.c.

96 {
97  int marker;
98  int n;
99 
100  if (!trail_active)
101  return NULL;
102 
103  for (marker = trail_head, n = TRAIL_LENGTH; n; n--)
104  {
105  if(trail[marker]->timestamp <= self->monsterinfo.trail_time)
106  marker = NEXT(marker);
107  else
108  break;
109  }
110 
111  if (visible(self, trail[marker]))
112  {
113  return trail[marker];
114  }
115 
116  if (visible(self, trail[PREV(marker)]))
117  {
118  return trail[PREV(marker)];
119  }
120 
121  return trail[marker];
122 }

Referenced by ai_run().

◆ PlayerTrail_PickNext()

edict_t* PlayerTrail_PickNext ( edict_t self)

Definition at line 124 of file p_trail.c.

125 {
126  int marker;
127  int n;
128 
129  if (!trail_active)
130  return NULL;
131 
132  for (marker = trail_head, n = TRAIL_LENGTH; n; n--)
133  {
134  if(trail[marker]->timestamp <= self->monsterinfo.trail_time)
135  marker = NEXT(marker);
136  else
137  break;
138  }
139 
140  return trail[marker];
141 }

Referenced by ai_run().

Variable Documentation

◆ trail

◆ trail_active

◆ trail_head

edict_s::s
entity_state_t s
Definition: g_local.h:970
deathmatch
cvar_t * deathmatch
Definition: g_main.c:35
edict_s::timestamp
float timestamp
Definition: g_local.h:1014
G_Spawn
edict_t * G_Spawn(void)
Definition: g_utils.c:420
VectorSubtract
#define VectorSubtract(a, b, c)
Definition: q_shared.h:163
PlayerTrail_Add
void PlayerTrail_Add(vec3_t spot)
Definition: p_trail.c:67
vectoyaw
float vectoyaw(vec3_t vec)
Definition: g_utils.c:333
edict_s::classname
char * classname
Definition: g_local.h:1011
TRAIL_LENGTH
#define TRAIL_LENGTH
Definition: p_trail.c:39
cvar_s::value
float value
Definition: q_shared.h:331
NULL
#define NULL
Definition: q_shared.h:67
trail
edict_t * trail[TRAIL_LENGTH]
Definition: p_trail.c:41
s
static fixed16_t s
Definition: r_scan.c:30
PREV
#define PREV(n)
Definition: p_trail.c:46
VectorCopy
#define VectorCopy(a, b)
Definition: q_shared.h:165
visible
qboolean visible(edict_t *self, edict_t *other)
Definition: g_ai.c:287
level
GLint level
Definition: qgl_win.c:116
trail_head
int trail_head
Definition: p_trail.c:42
NEXT
#define NEXT(n)
Definition: p_trail.c:45
trail_active
qboolean trail_active
Definition: p_trail.c:43
entity_state_s::angles
vec3_t angles
Definition: q_shared.h:1150
PlayerTrail_Init
void PlayerTrail_Init(void)
Definition: p_trail.c:49
vec3_t
vec_t vec3_t[3]
Definition: q_shared.h:134