Quake II RTX 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_t * PlayerTrail_PickFirst (edict_t *self)
 
edict_t * PlayerTrail_PickNext (edict_t *self)
 
edict_t * PlayerTrail_LastSpot (void)
 

Variables

edict_t * trail [TRAIL_LENGTH]
 
int trail_head
 
qboolean trail_active = qfalse
 

Macro Definition Documentation

◆ NEXT

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

Definition at line 43 of file p_trail.c.

◆ PREV

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

Definition at line 44 of file p_trail.c.

◆ TRAIL_LENGTH

#define TRAIL_LENGTH   8

Definition at line 37 of file p_trail.c.

Function Documentation

◆ PlayerTrail_Add()

void PlayerTrail_Add ( vec3_t  spot)

Definition at line 64 of file p_trail.c.

65 {
66  vec3_t temp;
67 
68  if (!trail_active)
69  return;
70 
71  VectorCopy(spot, trail[trail_head]->s.origin);
72 
73  trail[trail_head]->timestamp = level.time;
74 
75  VectorSubtract(spot, trail[PREV(trail_head)]->s.origin, temp);
76  trail[trail_head]->s.angles[1] = vectoyaw(temp);
77 
79 }

Referenced by ClientBeginServerFrame(), and PlayerTrail_New().

◆ PlayerTrail_Init()

void PlayerTrail_Init ( void  )

Definition at line 47 of file p_trail.c.

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

Referenced by PlayerTrail_New(), and SpawnEntities().

◆ PlayerTrail_LastSpot()

edict_t* PlayerTrail_LastSpot ( void  )

Definition at line 136 of file p_trail.c.

137 {
138  return trail[PREV(trail_head)];
139 }

Referenced by ClientBeginServerFrame().

◆ PlayerTrail_New()

void PlayerTrail_New ( vec3_t  spot)

Definition at line 82 of file p_trail.c.

83 {
84  if (!trail_active)
85  return;
86 
88  PlayerTrail_Add(spot);
89 }

◆ PlayerTrail_PickFirst()

edict_t* PlayerTrail_PickFirst ( edict_t *  self)

Definition at line 92 of file p_trail.c.

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

Referenced by ai_run().

◆ PlayerTrail_PickNext()

edict_t* PlayerTrail_PickNext ( edict_t *  self)

Definition at line 118 of file p_trail.c.

119 {
120  int marker;
121  int n;
122 
123  if (!trail_active)
124  return NULL;
125 
126  for (marker = trail_head, n = TRAIL_LENGTH; n; n--) {
127  if (trail[marker]->timestamp <= self->monsterinfo.trail_time)
128  marker = NEXT(marker);
129  else
130  break;
131  }
132 
133  return trail[marker];
134 }

Referenced by ai_run().

Variable Documentation

◆ trail

◆ trail_active

qboolean trail_active = qfalse

◆ trail_head

deathmatch
cvar_t * deathmatch
Definition: g_main.c:33
G_Spawn
edict_t * G_Spawn(void)
Definition: g_utils.c:391
PlayerTrail_Add
void PlayerTrail_Add(vec3_t spot)
Definition: p_trail.c:64
vectoyaw
float vectoyaw(vec3_t vec)
Definition: g_utils.c:310
TRAIL_LENGTH
#define TRAIL_LENGTH
Definition: p_trail.c:37
trail
edict_t * trail[TRAIL_LENGTH]
Definition: p_trail.c:39
PREV
#define PREV(n)
Definition: p_trail.c:44
level_locals_t::time
float time
Definition: g_local.h:299
visible
qboolean visible(edict_t *self, edict_t *other)
Definition: g_ai.c:268
trail_head
int trail_head
Definition: p_trail.c:40
NEXT
#define NEXT(n)
Definition: p_trail.c:43
level
level_locals_t level
Definition: g_main.c:22
trail_active
qboolean trail_active
Definition: p_trail.c:41
PlayerTrail_Init
void PlayerTrail_Init(void)
Definition: p_trail.c:47