|
|
1.1.1.2 ! root 1: /* ! 2: Copyright (C) 1997-2001 Id Software, Inc. ! 3: ! 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. ! 8: ! 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. ! 12: ! 13: See the GNU General Public License for more details. ! 14: ! 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. ! 18: ! 19: */ 1.1 root 20: #include "g_local.h" 21: 22: 23: void UpdateChaseCam(edict_t *ent) 24: { 25: vec3_t o, ownerv, goal; 26: edict_t *targ; 27: vec3_t forward, right; 28: trace_t trace; 29: int i; 30: vec3_t oldgoal; 31: vec3_t angles; 32: 33: // is our chase target gone? 34: if (!ent->client->chase_target->inuse) { 35: ent->client->chase_target = NULL; 36: return; 37: } 38: 39: targ = ent->client->chase_target; 40: 41: VectorCopy(targ->s.origin, ownerv); 42: VectorCopy(ent->s.origin, oldgoal); 43: 44: ownerv[2] += targ->viewheight; 45: 46: VectorCopy(targ->client->v_angle, angles); 47: if (angles[PITCH] > 56) 48: angles[PITCH] = 56; 49: AngleVectors (angles, forward, right, NULL); 50: VectorNormalize(forward); 51: VectorMA(ownerv, -30, forward, o); 52: 53: if (o[2] < targ->s.origin[2] + 20) 54: o[2] = targ->s.origin[2] + 20; 55: 56: // jump animation lifts 57: if (!targ->groundentity) 58: o[2] += 16; 59: 60: trace = gi.trace(ownerv, vec3_origin, vec3_origin, o, targ, MASK_SOLID); 61: 62: VectorCopy(trace.endpos, goal); 63: 64: VectorMA(goal, 2, forward, goal); 65: 66: // pad for floors and ceilings 67: VectorCopy(goal, o); 68: o[2] += 6; 69: trace = gi.trace(goal, vec3_origin, vec3_origin, o, targ, MASK_SOLID); 70: if (trace.fraction < 1) { 71: VectorCopy(trace.endpos, goal); 72: goal[2] -= 6; 73: } 74: 75: VectorCopy(goal, o); 76: o[2] -= 6; 77: trace = gi.trace(goal, vec3_origin, vec3_origin, o, targ, MASK_SOLID); 78: if (trace.fraction < 1) { 79: VectorCopy(trace.endpos, goal); 80: goal[2] += 6; 81: } 82: 83: ent->client->ps.pmove.pm_type = PM_FREEZE; 84: 85: VectorCopy(goal, ent->s.origin); 86: for (i=0 ; i<3 ; i++) 87: ent->client->ps.pmove.delta_angles[i] = ANGLE2SHORT(targ->client->v_angle[i] - ent->client->resp.cmd_angles[i]); 88: 89: VectorCopy(targ->client->v_angle, ent->client->ps.viewangles); 90: VectorCopy(targ->client->v_angle, ent->client->v_angle); 91: 92: ent->viewheight = 0; 93: ent->client->ps.pmove.pm_flags |= PMF_NO_PREDICTION; 94: gi.linkentity(ent); 95: 96: if ((!ent->client->showscores && !ent->client->menu && 97: !ent->client->showinventory && !ent->client->showhelp && 98: !(level.framenum & 31)) || ent->client->update_chase) { 99: char s[1024]; 100: 101: ent->client->update_chase = false; 102: sprintf(s, "xv 0 yb -68 string2 \"Chasing %s\"", 103: targ->client->pers.netname); 104: gi.WriteByte (svc_layout); 105: gi.WriteString (s); 106: gi.unicast(ent, false); 107: } 108: 109: } 110: 111: void ChaseNext(edict_t *ent) 112: { 113: int i; 114: edict_t *e; 115: 116: if (!ent->client->chase_target) 117: return; 118: 119: i = ent->client->chase_target - g_edicts; 120: do { 121: i++; 122: if (i > maxclients->value) 123: i = 1; 124: e = g_edicts + i; 125: if (!e->inuse) 126: continue; 127: if (e->solid != SOLID_NOT) 128: break; 129: } while (e != ent->client->chase_target); 130: 131: ent->client->chase_target = e; 132: ent->client->update_chase = true; 133: } 134: 135: void ChasePrev(edict_t *ent) 136: { 137: int i; 138: edict_t *e; 139: 140: if (!ent->client->chase_target) 141: return; 142: 143: i = ent->client->chase_target - g_edicts; 144: do { 145: i--; 146: if (i < 1) 147: i = maxclients->value; 148: e = g_edicts + i; 149: if (!e->inuse) 150: continue; 151: if (e->solid != SOLID_NOT) 152: break; 153: } while (e != ent->client->chase_target); 154: 155: ent->client->chase_target = e; 156: ent->client->update_chase = true; 157: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.