Quake II RTX doxygen  1.0 dev
g_chase.c File Reference
#include "g_local.h"

Go to the source code of this file.

Functions

void UpdateChaseCam (edict_t *ent)
 
void ChaseNext (edict_t *ent)
 
void ChasePrev (edict_t *ent)
 
void GetChaseTarget (edict_t *ent)
 

Function Documentation

◆ ChaseNext()

void ChaseNext ( edict_t *  ent)

Definition at line 107 of file g_chase.c.

108 {
109  int i;
110  edict_t *e;
111 
112  if (!ent->client->chase_target)
113  return;
114 
115  i = ent->client->chase_target - g_edicts;
116  do {
117  i++;
118  if (i > maxclients->value)
119  i = 1;
120  e = g_edicts + i;
121  if (!e->inuse)
122  continue;
123  if (!e->client->resp.spectator)
124  break;
125  } while (e != ent->client->chase_target);
126 
127  ent->client->chase_target = e;
128  ent->client->update_chase = qtrue;
129 }

Referenced by ClientThink(), SelectNextItem(), and UpdateChaseCam().

◆ ChasePrev()

void ChasePrev ( edict_t *  ent)

Definition at line 131 of file g_chase.c.

132 {
133  int i;
134  edict_t *e;
135 
136  if (!ent->client->chase_target)
137  return;
138 
139  i = ent->client->chase_target - g_edicts;
140  do {
141  i--;
142  if (i < 1)
143  i = maxclients->value;
144  e = g_edicts + i;
145  if (!e->inuse)
146  continue;
147  if (!e->client->resp.spectator)
148  break;
149  } while (e != ent->client->chase_target);
150 
151  ent->client->chase_target = e;
152  ent->client->update_chase = qtrue;
153 }

Referenced by SelectPrevItem().

◆ GetChaseTarget()

void GetChaseTarget ( edict_t *  ent)

Definition at line 155 of file g_chase.c.

156 {
157  int i;
158  edict_t *other;
159 
160  for (i = 1; i <= maxclients->value; i++) {
161  other = g_edicts + i;
162  if (other->inuse && !other->client->resp.spectator) {
163  ent->client->chase_target = other;
164  ent->client->update_chase = qtrue;
165  UpdateChaseCam(ent);
166  return;
167  }
168  }
169  gi.centerprintf(ent, "No other players to chase.");
170 }

Referenced by ClientThink().

◆ UpdateChaseCam()

void UpdateChaseCam ( edict_t *  ent)

Definition at line 20 of file g_chase.c.

21 {
22  vec3_t o, ownerv, goal;
23  edict_t *targ;
24  vec3_t forward, right;
25  trace_t trace;
26  int i;
27  vec3_t angles;
28 
29  // is our chase target gone?
30  if (!ent->client->chase_target->inuse
31  || ent->client->chase_target->client->resp.spectator) {
32  edict_t *old = ent->client->chase_target;
33  ChaseNext(ent);
34  if (ent->client->chase_target == old) {
35  ent->client->chase_target = NULL;
36  ent->client->ps.pmove.pm_flags &= ~PMF_NO_PREDICTION;
37  return;
38  }
39  }
40 
41  targ = ent->client->chase_target;
42 
43  VectorCopy(targ->s.origin, ownerv);
44 
45  ownerv[2] += targ->viewheight;
46 
47  VectorCopy(targ->client->v_angle, angles);
48  if (angles[PITCH] > 56)
49  angles[PITCH] = 56;
50  AngleVectors(angles, forward, right, NULL);
52  VectorMA(ownerv, -30, forward, o);
53 
54  if (o[2] < targ->s.origin[2] + 20)
55  o[2] = targ->s.origin[2] + 20;
56 
57  // jump animation lifts
58  if (!targ->groundentity)
59  o[2] += 16;
60 
61  trace = gi.trace(ownerv, vec3_origin, vec3_origin, o, targ, MASK_SOLID);
62 
63  VectorCopy(trace.endpos, goal);
64 
65  VectorMA(goal, 2, forward, goal);
66 
67  // pad for floors and ceilings
68  VectorCopy(goal, o);
69  o[2] += 6;
70  trace = gi.trace(goal, vec3_origin, vec3_origin, o, targ, MASK_SOLID);
71  if (trace.fraction < 1) {
72  VectorCopy(trace.endpos, goal);
73  goal[2] -= 6;
74  }
75 
76  VectorCopy(goal, o);
77  o[2] -= 6;
78  trace = gi.trace(goal, vec3_origin, vec3_origin, o, targ, MASK_SOLID);
79  if (trace.fraction < 1) {
80  VectorCopy(trace.endpos, goal);
81  goal[2] += 6;
82  }
83 
84  if (targ->deadflag)
85  ent->client->ps.pmove.pm_type = PM_DEAD;
86  else
87  ent->client->ps.pmove.pm_type = PM_FREEZE;
88 
89  VectorCopy(goal, ent->s.origin);
90  for (i = 0 ; i < 3 ; i++)
91  ent->client->ps.pmove.delta_angles[i] = ANGLE2SHORT(targ->client->v_angle[i] - ent->client->resp.cmd_angles[i]);
92 
93  if (targ->deadflag) {
94  ent->client->ps.viewangles[ROLL] = 40;
95  ent->client->ps.viewangles[PITCH] = -15;
96  ent->client->ps.viewangles[YAW] = targ->client->killer_yaw;
97  } else {
98  VectorCopy(targ->client->v_angle, ent->client->ps.viewangles);
99  VectorCopy(targ->client->v_angle, ent->client->v_angle);
100  }
101 
102  ent->viewheight = 0;
103  ent->client->ps.pmove.pm_flags |= PMF_NO_PREDICTION;
104  gi.linkentity(ent);
105 }

Referenced by ClientThink(), and GetChaseTarget().

gi
game_import_t gi
Definition: g_main.c:23
UpdateChaseCam
void UpdateChaseCam(edict_t *ent)
Definition: g_chase.c:20
maxclients
cvar_t * maxclients
Definition: g_main.c:42
g_edicts
edict_t * g_edicts
Definition: g_main.c:31
other
@ other
Definition: ogg.c:63
vec3_origin
vec3_t vec3_origin
Definition: shared.c:21
forward
static vec3_t forward
Definition: p_view.c:27
AngleVectors
void AngleVectors(vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
Definition: shared.c:23
right
static vec3_t right
Definition: p_view.c:27
ChaseNext
void ChaseNext(edict_t *ent)
Definition: g_chase.c:107
VectorNormalize
vec_t VectorNormalize(vec3_t v)
Definition: shared.c:55