2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 // chase.c -- chase camera code
23 #include "cl_collision.h"
25 cvar_t chase_back = {CVAR_SAVE, "chase_back", "48"};
26 cvar_t chase_up = {CVAR_SAVE, "chase_up", "24"};
27 cvar_t chase_active = {CVAR_SAVE, "chase_active", "0"};
29 cvar_t chase_stevie = {0, "chase_stevie", "0"};
31 void Chase_Init (void)
33 Cvar_RegisterVariable (&chase_back);
34 Cvar_RegisterVariable (&chase_up);
35 Cvar_RegisterVariable (&chase_active);
36 if (gamemode == GAME_GOODVSBAD2)
37 Cvar_RegisterVariable (&chase_stevie);
40 void Chase_Reset (void)
42 // for respawning and teleporting
43 // start position 12 units behind head
46 void Chase_Update (void)
48 vec_t camback, camup, dist, forward[3], stop[3], chase_dest[3], normal[3], projectangles[3];
50 camback = bound(0, chase_back.value, 128);
51 if (chase_back.value != camback)
52 Cvar_SetValueQuick(&chase_back, camback);
53 camup = bound(-48, chase_up.value, 96);
54 if (chase_up.value != camup)
55 Cvar_SetValueQuick(&chase_up, camup);
57 VectorCopy(cl.viewangles, projectangles);
58 if (gamemode == GAME_GOODVSBAD2 && chase_stevie.integer)
60 projectangles[0] = 90;
61 r_refdef.viewangles[0] = 90;
64 AngleVectors (projectangles, forward, NULL, NULL);
66 dist = -chase_back.value - 8;
67 chase_dest[0] = r_refdef.vieworg[0] + forward[0] * dist;
68 chase_dest[1] = r_refdef.vieworg[1] + forward[1] * dist;
69 chase_dest[2] = r_refdef.vieworg[2] + forward[2] * dist + chase_up.value;
71 CL_TraceLine (r_refdef.vieworg, chase_dest, stop, normal, 0, true, NULL);
72 chase_dest[0] = stop[0] + forward[0] * 8 + normal[0] * 4;
73 chase_dest[1] = stop[1] + forward[1] * 8 + normal[1] * 4;
74 chase_dest[2] = stop[2] + forward[2] * 8 + normal[2] * 4;
76 VectorCopy (chase_dest, r_refdef.vieworg);