Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float TILT_RATE = 80;
- float WALL_DISTANCE = 6;
- float CAMERA_OFFSET = 12;
- float PRED_TIME = 1;
- float DUAL_BLEND_RATE = 2;
- float CLIP_TIME = 0.05;
- float MAX_SLACK = 360;
- float WATER_TILT = 2;
- float VIEWING_PITCH = 16;
- float FAST_TURN_RATE = 180;
- float SLOW_TURN_RATE = 60;
- float TRACE_TEST = 240;
- float TRACE_BUFFER = 0.2;
- float TRACE_MINIMUM = 0.5;
- float TRACE_RATE = 0.4;
- float TRACE_PAUSE = 0.5;
- float STAIR_BLEND_RATE = 140;
- float FILM_HI_LIP = 15;
- float FILM_LO_LIP = -23;
- float TURNING_INTOVIEW = 1;
- float TILTING_INTOVIEW = 2;
- float DUAL_BLEND_INTOVIEW = 4;
- float VIEW_FIXED_POINT = 8;
- float FIRST_GUY_KILLED = 16;
- float SECOND_GUY_KILLED = 32;
- float EITHER_GUY_KILLED = 48;
- float NOT_EITHER_GUY_KILLED = 16777167;
- float FIND_DIFFERENT_GUY = 64;
- float CF_RESET_FILTER = 16;
- float CF_DOINGLONGMESSAGE = 256;
- entity freecamlist;
- .vector filmpos;
- .vector predpos;
- .float filmlip;
- .vector slack1;
- .vector slack2;
- .vector cangles;
- .float vangle;
- .float view_pitch;
- .float oldstate;
- .entity oldmovetarget;
- .float msgtime;
- .float view_offset;
- .vector view_angle;
- .vector view_origin;
- .float lefty;
- .entity oldenemy;
- .string deathtype_;
- float (float v) cc_anglemod;
- void (entity e) CC_DisplayCreepView;
- void (entity cam) CC_DisplayNames;
- void (entity c) CC_ChangeToAnyCam;
- entity (entity first_in_list) AddToList =
- {
- self.next = first_in_list;
- self.previous = first_in_list.previous;
- if (first_in_list)
- {
- if (first_in_list.previous)
- {
- first_in_list.previous.next = self;
- }
- first_in_list.previous = self;
- }
- return (self);
- };
- void () Add_takedamage =
- {
- self.takedamage = DAMAGE_YES;
- first_takedamage = AddToList (first_takedamage);
- takedamage_exists = TRUE;
- };
- void () UpdateRadiusDamage =
- {
- if (takedamage_exists)
- {
- if (numberofclients)
- {
- return;
- }
- test_enemy = first_takedamage;
- while (test_enemy.next)
- {
- test_enemy = test_enemy.next;
- }
- test_enemy.next = first_client;
- first_client.previous = test_enemy;
- }
- else
- {
- first_takedamage = first_client;
- }
- };
- void () SetViewPort =
- {
- WriteByte (MSG_ONE, SVC_SETVIEWPORT);
- WriteEntity (MSG_ONE, viewport);
- };
- void () SetViewPortClient =
- {
- if (non_viewport.modelindex)
- {
- non_viewport.modelindex = 0;
- if (msg_entity.player_)
- {
- SetViewPort ();
- }
- msg_entity = msg_entity.clink;
- while (msg_entity.clink)
- {
- if ((msg_entity.pflags & PF_FIRSTPERSON))
- {
- SetViewPort ();
- }
- }
- }
- };
- void () SetViewPlayer =
- {
- msg_entity = self;
- if (self.player_)
- {
- viewport = self;
- non_viewport = self.aiment;
- }
- else
- {
- viewport = self.aiment;
- non_viewport = self;
- }
- SetViewPortClient ();
- viewport.modelindex = modelindex_player;
- };
- void (entity e, entity f) CopyName =
- {
- e.block0 = f.block0;
- e.block1 = f.block1;
- e.block2 = f.block2;
- e.block3 = f.block3;
- e.block4 = f.block4;
- };
- float (entity e, entity f) NamesEqual =
- {
- if ((e.block0 == f.block0))
- {
- if ((e.block1 == f.block1))
- {
- if ((e.block2 == f.block2))
- {
- if ((e.block3 == f.block3))
- {
- if ((e.block4 == f.block4))
- {
- return (TRUE);
- }
- }
- }
- }
- }
- return (FALSE);
- };
- float (float block, float insert_character) insert_block =
- {
- character = (block & 255);
- if (character)
- {
- character = (floor ((block / 256)) & 255);
- if (character)
- {
- character = floor ((block / 65536));
- if (character)
- {
- return (0);
- }
- else
- {
- return ((block + (insert_character * 65536)));
- }
- }
- else
- {
- return ((block + (insert_character * 256)));
- }
- }
- else
- {
- return (insert_character);
- }
- };
- void (entity client, float insert_character) insert_netname =
- {
- block_ = insert_block (client.block0, insert_character);
- if (block_)
- {
- client.block0 = block_;
- }
- else
- {
- block_ = insert_block (client.block1, insert_character);
- if (block_)
- {
- client.block1 = block_;
- }
- else
- {
- block_ = insert_block (client.block2, insert_character);
- if (block_)
- {
- client.block2 = block_;
- }
- else
- {
- block_ = insert_block (client.block3, insert_character);
- if (block_)
- {
- client.block3 = block_;
- }
- else
- {
- block_ = insert_block (client.block4, insert_character);
- if (block_)
- {
- client.block4 = block_;
- }
- }
- }
- }
- }
- };
- float (float to, float block) print_block =
- {
- character = (block & 255);
- if (character)
- {
- WriteByte (to, character);
- character = (floor ((block / 256)) & 255);
- if (character)
- {
- WriteByte (to, character);
- character = floor ((block / 65536));
- if (character)
- {
- WriteByte (to, character);
- return (TRUE);
- }
- }
- }
- };
- void (float to, entity client) WriteName_apply =
- {
- if (print_block (to, client.block0))
- {
- if (print_block (to, client.block1))
- {
- if (print_block (to, client.block2))
- {
- if (print_block (to, client.block3))
- {
- print_block (to, client.block4);
- }
- }
- }
- }
- };
- entity (entity first_in_list) RemoveFromList =
- {
- if ((first_in_list == self))
- {
- first_in_list = first_in_list.next;
- }
- if (self.previous)
- {
- self.previous.next = self.next;
- }
- if (self.next)
- {
- self.next.previous = self.previous;
- }
- return (first_in_list);
- };
- void () Add_client =
- {
- if (self.client_)
- {
- return;
- }
- self.client_ = TRUE;
- first_client = AddToList (first_client);
- UpdateRadiusDamage ();
- numberofclients = (numberofclients + 1);
- /*
- if (teamplay)
- {
- //self.realteam = self.team;
- //team_index = (self.team - 1);
- self.teamflag = 1;
- while (team_index)
- {
- team_index = (team_index - 1);
- self.teamflag = (self.teamflag * 2);
- }
- }
- else
- {
- current_team = (current_team + 1);
- self.realteam = current_team;
- }
- */
- self.movetarget = world;
- self.enemy = world;
- self.goalentity = world;
- };
- void (entity c) CC_RemoveFromCreepList =
- {
- local entity l;
- l = c.owner;
- if (l)
- {
- if ((c.pflags & PF_FIRSTPERSON))
- {
- CC_DisplayCreepView (c);
- }
- if (c.clink)
- {
- if ((l.clink == c))
- {
- other = c.clink;
- other.cangles = c.cangles;
- other.lefty = c.lefty;
- other.filmpos = c.filmpos;
- other.predpos = c.predpos;
- other.movetarget = c.movetarget;
- other.oldenemy = c.oldenemy;
- other.state = c.state;
- other.style = c.style;
- other.dest = c.dest;
- other.slack1 = c.slack1;
- other.slack2 = c.slack2;
- other.think = c.think;
- other.nextthink = c.nextthink;
- other.search_time = c.search_time;
- other.light_lev = c.light_lev;
- other.vangle = c.vangle;
- other.view_angle = c.view_angle;
- other.view_origin = c.view_origin;
- other.view_pitch = c.view_pitch;
- }
- }
- }
- else
- {
- if ((freecamlist == c))
- {
- freecamlist = c.clink;
- return;
- }
- else
- {
- l = freecamlist;
- }
- }
- while (l.clink)
- {
- if ((l.clink == c))
- {
- l.clink = c.clink;
- c.clink = world;
- c.owner = world;
- return;
- }
- l = l.clink;
- }
- };
- void () RemoveFromAllLists =
- {
- if (self.client_)
- {
- self.client_ = FALSE;
- //self.frogbot = FALSE;
- first_client = RemoveFromList (first_client);
- UpdateRadiusDamage ();
- numberofclients = (numberofclients - 1);
- other = self.clink;
- while (other)
- {
- CC_ChangeToAnyCam (other);
- other = other.clink;
- }
- }
- if ((self.flags & FL_CREEPCAM))
- {
- CC_RemoveFromCreepList (self);
- self.flags = (self.flags - FL_CREEPCAM);
- first_creepcam = RemoveFromList (first_creepcam);
- }
- };
- vector (vector delta, float watercam, entity cam) CC_GetDualAngles =
- {
- delta = vectoangles (delta);
- if (watercam)
- {
- if ((delta_x > 180))
- {
- delta_x = ((360 + (VIEWING_PITCH * cam.view_pitch)) - ((delta_x - 360) / 2));
- }
- else
- {
- delta_x = ((360 + (VIEWING_PITCH * cam.view_pitch)) - (delta_x / 3));
- }
- }
- else
- {
- if ((delta_x > 180))
- {
- delta_x = ((VIEWING_PITCH * cam.view_pitch) - ((delta_x - 360) / 2.5));
- }
- else
- {
- delta_x = ((VIEWING_PITCH * cam.view_pitch) - (delta_x / 2));
- }
- }
- if ((delta_x < 0))
- {
- delta_x = (delta_x + 360);
- }
- return (delta);
- };
- void (entity cam) CC_StartCamTransition =
- {
- local vector dualangles;
- if ((cam.state != 0))
- {
- if ((cam.style & VIEW_FIXED_POINT))
- {
- dualangles = CC_GetDualAngles ((cam.movetarget.filmpos - cam.dest), (cam.owner.waterlevel > 0), cam);
- }
- else
- {
- dualangles = CC_GetDualAngles ((cam.movetarget.filmpos - cam.owner.filmpos), (cam.owner.waterlevel > 0), cam);
- }
- dualangles_z = cc_anglemod (((cam.cangles_y - dualangles_y) + 60));
- if ((dualangles_z > 120))
- {
- cam.style = (cam.style | TURNING_INTOVIEW);
- }
- }
- cam.predpos = cam.filmpos;
- cam.lefty = 0;
- cam.style = ((cam.style | DUAL_BLEND_INTOVIEW) | TILTING_INTOVIEW);
- };
- void (entity cam, float goal) CC_ControlCamFocalLength =
- {
- local float frac;
- if ((goal > TRACE_MINIMUM))
- {
- frac = (goal - TRACE_BUFFER);
- if ((frac < TRACE_MINIMUM))
- {
- goal = TRACE_MINIMUM;
- }
- }
- else
- {
- frac = goal;
- }
- if ((frac > cam.light_lev))
- {
- if ((frac < TRACE_MINIMUM))
- {
- cam.light_lev = (cam.light_lev + (TRACE_RATE * frametime));
- if ((cam.light_lev > frac))
- {
- cam.light_lev = frac;
- }
- }
- else
- {
- if ((cam.search_time == -1))
- {
- cam.search_time = (time + TRACE_PAUSE);
- }
- else
- {
- if (((time >= cam.search_time) || (frac < TRACE_MINIMUM)))
- {
- cam.light_lev = (cam.light_lev + (TRACE_RATE * frametime));
- if ((cam.light_lev > frac))
- {
- cam.light_lev = frac;
- }
- }
- }
- }
- }
- else
- {
- cam.search_time = -1;
- if ((frac < cam.light_lev))
- {
- cam.light_lev = (cam.light_lev - (TRACE_RATE * frametime));
- if ((cam.light_lev > goal))
- {
- cam.light_lev = goal;
- }
- else
- {
- if ((cam.light_lev < frac))
- {
- cam.light_lev = frac;
- }
- }
- }
- }
- };
- float (entity guy, entity rel, entity prevguy) CC_InterestLevel =
- {
- local float lev;
- local float dist1;
- local float dist2;
- lev = 0;
- if (guy.client_)
- {
- if (!guy.deadflag)
- {
- lev = 256;
- }
- }
- if (teamplay)
- {
- if ((guy.team != rel.team))
- {
- lev = (lev + 128);
- }
- }
- if ((((guy.items & IT_ROCKET_LAUNCHER) && (guy.ammo_rockets >= 1)) || ((guy.items & IT_LIGHTNING) && (guy.ammo_cells >= 5))))
- {
- lev = (lev + 64);
- }
- if ((guy.items & IT_QUAD))
- {
- lev = (lev + 32);
- }
- if ((guy.items & IT_INVULNERABILITY))
- {
- lev = (lev + 16);
- }
- dist1 = vlen ((guy.origin - rel.origin));
- dist2 = vlen ((prevguy.origin - rel.origin));
- if ((dist1 < (dist2 * 0.5)))
- {
- lev = (lev + 8);
- }
- if ((dist1 < (dist2 * 0.25)))
- {
- lev = (lev + 4);
- }
- if ((dist1 < (dist2 * 0.125)))
- {
- lev = (lev + 2);
- }
- return (lev);
- };
- void (entity cam) CC_CheckForBetterTarget =
- {
- local entity targ1;
- local entity targ2;
- local float tangle;
- local float worthit;
- local entity prevguy;
- local entity oldtarget;
- local float lev1;
- local float lev2;
- if ((cam.style & EITHER_GUY_KILLED))
- {
- return;
- }
- if (!first_client)
- {
- return;
- }
- targ1 = cam.owner;
- targ2 = cam.oldenemy;
- if (((targ2.flags & FL_CREEPCAM) || !targ2))
- {
- cam.oldenemy = world;
- targ2 = world;
- }
- while (1)
- {
- if (!targ2)
- {
- targ2 = first_client;
- }
- else
- {
- targ2 = targ2.next;
- if (!targ2)
- {
- if (cam.oldenemy)
- {
- cam.oldenemy = world;
- targ2 = first_client;
- }
- else
- {
- return;
- }
- }
- }
- if (!targ2.deadflag)
- {
- if ((targ2 != targ1))
- {
- cam.oldenemy = targ2;
- if ((cam.state == 0))
- {
- traceline (targ1.predpos, targ2.predpos, 1, targ1);
- if (!trace_startsolid)
- {
- if ((trace_endpos == targ2.predpos))
- {
- if ((targ2.deadflag == DEAD_NO))
- {
- cam.movetarget = targ2;
- cam.state = 1;
- cam.slack1 = targ1.predpos;
- cam.slack2 = targ2.predpos;
- CC_StartCamTransition (cam);
- }
- }
- }
- }
- else
- {
- traceline (targ1.filmpos, targ2.filmpos, 1, targ1);
- if (!trace_startsolid)
- {
- if ((trace_endpos == targ2.filmpos))
- {
- prevguy = cam.movetarget;
- if ((prevguy == targ2))
- {
- cam.state = 2;
- }
- else
- {
- lev1 = CC_InterestLevel (targ2, targ1, prevguy);
- lev2 = CC_InterestLevel (prevguy, targ1, prevguy);
- if ((lev1 > lev2))
- {
- cam.state = 2;
- cam.movetarget = targ2;
- CC_StartCamTransition (cam);
- }
- }
- }
- }
- }
- return;
- }
- }
- }
- };
- void (entity cam) CC_UpdateViewingPitch =
- {
- if ((cam.owner.waterlevel >= 3))
- {
- cam.view_pitch = (cam.view_pitch - (frametime * WATER_TILT));
- if ((cam.view_pitch < -1))
- {
- cam.view_pitch = -1;
- }
- }
- else
- {
- cam.view_pitch = (cam.view_pitch + (frametime * WATER_TILT));
- if ((cam.view_pitch > 1))
- {
- cam.view_pitch = 1;
- }
- }
- };
- void (entity cam) CC_UpdateViewOffset =
- {
- local vector trace_dest;
- if ((cam.view_pitch > 0))
- {
- trace_dest = cam.owner.origin;
- trace_dest_z = (trace_dest_z + (4 * CAMERA_OFFSET));
- traceline (cam.owner.origin, trace_dest, 1, cam.owner);
- if ((trace_fraction < 1))
- {
- cam.view_offset = (CAMERA_OFFSET - (((1 - trace_fraction) * 4) * CAMERA_OFFSET));
- }
- else
- {
- cam.view_offset = CAMERA_OFFSET;
- }
- }
- else
- {
- cam.view_offset = CAMERA_OFFSET;
- }
- };
- void (entity cam) CC_MoveSingleCamera =
- {
- local vector newvec;
- local float voffset;
- local float tangle;
- local float dangle;
- local float frac;
- local float trace1;
- local float trace2;
- local float trace3;
- local vector angle;
- newvec = cam.owner.velocity;
- newvec_z = 0;
- tangle = cam.owner.v_angle_y;
- dangle = cc_anglemod ((tangle - cam.cangles_y));
- frac = (vlen (newvec) / 320);
- if ((frac < 0.7))
- {
- frac = 0.7;
- }
- if (((cam.style & VIEW_FIXED_POINT) == 0))
- {
- if ((dangle < 180))
- {
- if ((dangle > 15))
- {
- if ((cam.style & DUAL_BLEND_INTOVIEW))
- {
- dangle = (dangle - ((frametime * frac) * SLOW_TURN_RATE));
- }
- else
- {
- if ((dangle < 90))
- {
- angle_y = dangle;
- makevectors (angle);
- dangle = (dangle - (((frametime * frac) * FAST_TURN_RATE) * v_forward_y));
- }
- else
- {
- dangle = (dangle - ((frametime * frac) * FAST_TURN_RATE));
- }
- }
- if ((dangle < 15))
- {
- dangle = 15;
- }
- }
- else
- {
- if ((frac < 0.8))
- {
- dangle = (dangle + (frametime * 30));
- if ((dangle > 15))
- {
- dangle = 15;
- }
- }
- }
- }
- else
- {
- if ((dangle < 345))
- {
- if ((cam.style & DUAL_BLEND_INTOVIEW))
- {
- dangle = (dangle + ((frametime * frac) * SLOW_TURN_RATE));
- }
- else
- {
- if ((dangle > 270))
- {
- angle_y = (360 - dangle);
- makevectors (angle);
- dangle = (dangle + (((frametime * frac) * FAST_TURN_RATE) * v_forward_y));
- }
- else
- {
- dangle = (dangle + ((frametime * frac) * FAST_TURN_RATE));
- }
- }
- if ((dangle > 345))
- {
- dangle = 345;
- }
- }
- else
- {
- if ((frac < 0.8))
- {
- dangle = (dangle - (frametime * 30));
- if ((dangle < 345))
- {
- dangle = 345;
- }
- }
- }
- }
- cam.cangles_y = cc_anglemod ((tangle - dangle));
- }
- voffset = 0;
- if ((cam.owner.v_angle_x < (cam.vangle - (frametime * TILT_RATE))))
- {
- cam.vangle = (cam.vangle - (frametime * TILT_RATE));
- }
- else
- {
- if ((cam.owner.v_angle_x > (cam.vangle + (frametime * TILT_RATE))))
- {
- cam.vangle = (cam.vangle + (frametime * TILT_RATE));
- }
- else
- {
- cam.vangle = cam.owner.v_angle_x;
- }
- }
- if ((cam.vangle < -55))
- {
- cam.vangle = -55;
- }
- if ((cam.vangle > 20))
- {
- voffset = ((cam.vangle - 20) * (1.125 - (cam.view_pitch * 0.375)));
- }
- else
- {
- if ((cam.vangle < -20))
- {
- voffset = ((cam.vangle + 20) * (1.125 + (cam.view_pitch * 0.375)));
- }
- }
- tangle = ((VIEWING_PITCH * cam.view_pitch) + voffset);
- if (((cam.style & TILTING_INTOVIEW) == 0))
- {
- cam.cangles_x = tangle;
- }
- else
- {
- dangle = cc_anglemod ((cam.cangles_x - tangle));
- if ((dangle < 180))
- {
- dangle = (dangle - (SLOW_TURN_RATE * frametime));
- if ((dangle <= 0))
- {
- dangle = 0;
- cam.style = (cam.style - TILTING_INTOVIEW);
- }
- }
- else
- {
- dangle = (dangle + (SLOW_TURN_RATE * frametime));
- if ((dangle >= 360))
- {
- dangle = 0;
- cam.style = (cam.style - TILTING_INTOVIEW);
- }
- }
- cam.cangles_x = cc_anglemod ((tangle + dangle));
- }
- cam.cangles_z = 0;
- makevectors (cam.cangles);
- if ((cam.style & DUAL_BLEND_INTOVIEW))
- {
- cam.lefty = (cam.lefty + (DUAL_BLEND_RATE * frametime));
- if ((cam.lefty > 1))
- {
- cam.lefty = 1;
- cam.style = (cam.style - DUAL_BLEND_INTOVIEW);
- }
- cam.filmpos_x = ((cam.lefty * v_forward_x) + ((1 - cam.lefty) * cam.predpos_x));
- cam.filmpos_y = ((cam.lefty * v_forward_y) + ((1 - cam.lefty) * cam.predpos_y));
- cam.filmpos_z = ((cam.lefty * v_forward_z) + ((1 - cam.lefty) * cam.predpos_z));
- cam.view_angle = vectoangles (cam.filmpos);
- cam.view_angle_x = (0 - cam.view_angle_x);
- }
- else
- {
- cam.filmpos = v_forward;
- cam.view_angle = cam.cangles;
- }
- if ((cam.style & VIEW_FIXED_POINT))
- {
- newvec = cam.dest;
- }
- else
- {
- newvec = cam.owner.filmpos;
- }
- newvec_z = (newvec_z + cam.view_offset);
- traceline (newvec, (newvec - (v_forward * TRACE_TEST)), 1, cam);
- trace1 = (trace_fraction * TRACE_TEST);
- start = (newvec + (v_right * WALL_DISTANCE));
- traceline (start, (start - (v_forward * TRACE_TEST)), 1, cam);
- trace2 = ((trace_fraction * TRACE_TEST) + WALL_DISTANCE);
- start = (newvec - (v_right * WALL_DISTANCE));
- traceline (start, (start - (v_forward * TRACE_TEST)), 1, cam);
- trace3 = ((trace_fraction * TRACE_TEST) + WALL_DISTANCE);
- trace_fraction = trace1;
- if ((trace2 < trace_fraction))
- {
- trace_fraction = trace2;
- }
- if ((trace3 < trace_fraction))
- {
- trace_fraction = trace3;
- }
- trace_fraction = (trace_fraction / TRACE_TEST);
- CC_ControlCamFocalLength (cam, trace_fraction);
- cam.view_origin = (newvec - (v_forward * ((TRACE_TEST * cam.light_lev) - WALL_DISTANCE)));
- };
- void (entity cam) CC_UpdateDualCamState =
- {
- local entity targ1;
- local entity targ2;
- local float slack;
- if ((cam.state > 0))
- {
- if (cam.movetarget.deadflag)
- {
- cam.state = 0;
- CC_StartCamTransition (cam);
- return;
- }
- }
- if ((cam.state == 2))
- {
- targ2 = cam.movetarget;
- if ((targ2.flags & FL_CREEPCAM))
- {
- cam.style = (cam.style - (cam.style & SECOND_GUY_KILLED));
- cam.state = 0;
- CC_StartCamTransition (cam);
- }
- else
- {
- targ1 = cam.owner;
- traceline (targ1.filmpos, targ2.filmpos, 1, targ1);
- if ((trace_startsolid || (trace_endpos != targ2.filmpos)))
- {
- cam.state = 1;
- }
- else
- {
- cam.slack1 = targ1.filmpos;
- cam.slack2 = targ2.filmpos;
- }
- }
- }
- if ((cam.state == 1))
- {
- if (((vlen ((cam.owner.filmpos - cam.slack1)) > MAX_SLACK) || (vlen ((cam.movetarget.filmpos - cam.slack2)) > MAX_SLACK)))
- {
- cam.state = 0;
- CC_StartCamTransition (cam);
- }
- }
- };
- void (entity cam) CC_MoveDualCamera =
- {
- local vector newvec;
- local vector dualangles;
- local float tangle;
- local float dangle;
- local float frac;
- local vector v1;
- local vector v2;
- local float vl1;
- local float vl2;
- local vector vnet;
- local vector angle;
- local float trace1;
- local float trace2;
- local float trace3;
- if ((cam.style & VIEW_FIXED_POINT))
- {
- dualangles = CC_GetDualAngles ((cam.movetarget.filmpos - cam.dest), (cam.owner.waterlevel > 0), cam);
- }
- else
- {
- dualangles = CC_GetDualAngles ((cam.movetarget.filmpos - cam.owner.filmpos), (cam.owner.waterlevel > 0), cam);
- }
- if (((cam.style & TURNING_INTOVIEW) == 0))
- {
- newvec = cam.owner.velocity;
- newvec_z = 0;
- tangle = vectoyaw (newvec);
- dangle = cc_anglemod ((tangle - cam.cangles_y));
- frac = (vlen (newvec) / 400);
- if ((cc_anglemod (((cam.cangles_y - dualangles_y) + 60)) > 120))
- {
- if ((cc_anglemod ((cam.cangles_y - dualangles_y)) < 180))
- {
- cam.cangles_y = (cam.cangles_y - ((frametime * 2) * FAST_TURN_RATE));
- if ((cam.cangles_y < cc_anglemod ((dualangles_y + 60))))
- {
- cam.cangles_y = cc_anglemod ((dualangles_y + 60));
- }
- }
- else
- {
- cam.cangles_y = (cam.cangles_y + ((frametime * 2) * FAST_TURN_RATE));
- if ((cam.cangles_y > cc_anglemod ((dualangles_y - 60))))
- {
- cam.cangles_y = cc_anglemod ((dualangles_y - 60));
- }
- }
- }
- else
- {
- if ((frac > 0.1))
- {
- if (!(cam.style & VIEW_FIXED_POINT))
- {
- if ((dangle < 180))
- {
- if ((dangle > 15))
- {
- dangle = (dangle - ((frametime * frac) * FAST_TURN_RATE));
- if ((dangle < 15))
- {
- dangle = 15;
- }
- }
- }
- else
- {
- if ((dangle < 345))
- {
- dangle = (dangle + ((frametime * frac) * FAST_TURN_RATE));
- if ((dangle > 345))
- {
- dangle = 345;
- }
- }
- }
- cam.cangles_y = cc_anglemod ((tangle - dangle));
- }
- }
- if ((cc_anglemod (((cam.cangles_y - dualangles_y) + 60)) > 120))
- {
- if ((cc_anglemod ((cam.cangles_y - dualangles_y)) < 180))
- {
- cam.cangles_y = cc_anglemod ((dualangles_y + 60));
- }
- else
- {
- cam.cangles_y = cc_anglemod ((dualangles_y - 60));
- }
- }
- }
- }
- else
- {
- dangle = cc_anglemod ((cam.cangles_y - dualangles_y));
- if ((dangle < 180))
- {
- dangle = (dangle - (FAST_TURN_RATE * frametime));
- if ((dangle <= 60))
- {
- dangle = 60;
- cam.style = (cam.style - (cam.style & TURNING_INTOVIEW));
- }
- }
- else
- {
- dangle = (dangle + (FAST_TURN_RATE * frametime));
- if ((dangle >= 300))
- {
- dangle = 300;
- cam.style = (cam.style - (cam.style & TURNING_INTOVIEW));
- }
- }
- cam.cangles_y = cc_anglemod ((dualangles_y + dangle));
- }
- if (((cam.style & TILTING_INTOVIEW) == 0))
- {
- cam.cangles_x = dualangles_x;
- }
- else
- {
- dangle = cc_anglemod ((cam.cangles_x - dualangles_x));
- if ((dangle < 180))
- {
- dangle = (dangle - (FAST_TURN_RATE * frametime));
- if ((dangle <= 0))
- {
- dangle = 0;
- cam.style = (cam.style - TILTING_INTOVIEW);
- }
- }
- else
- {
- dangle = (dangle + (FAST_TURN_RATE * frametime));
- if ((dangle >= 360))
- {
- dangle = 0;
- cam.style = (cam.style - TILTING_INTOVIEW);
- }
- }
- cam.cangles_x = cc_anglemod ((dualangles_x + dangle));
- }
- cam.cangles_z = 0;
- makevectors (cam.cangles);
- if ((cam.style & VIEW_FIXED_POINT))
- {
- newvec = cam.dest;
- }
- else
- {
- newvec = cam.owner.filmpos;
- }
- newvec_z = (newvec_z + cam.view_offset);
- traceline (newvec, (newvec - (v_forward * TRACE_TEST)), 1, cam);
- trace1 = (trace_fraction * TRACE_TEST);
- start = (newvec + (v_right * WALL_DISTANCE));
- traceline (start, (start - (v_forward * TRACE_TEST)), 1, cam);
- trace2 = ((trace_fraction * TRACE_TEST) + WALL_DISTANCE);
- start = (newvec - (v_right * WALL_DISTANCE));
- traceline (start, (start - (v_forward * TRACE_TEST)), 1, cam);
- trace3 = ((trace_fraction * TRACE_TEST) + WALL_DISTANCE);
- trace_fraction = trace1;
- if ((trace2 < trace_fraction))
- {
- trace_fraction = trace2;
- }
- if ((trace3 < trace_fraction))
- {
- trace_fraction = trace3;
- }
- trace_fraction = (trace_fraction / TRACE_TEST);
- CC_ControlCamFocalLength (cam, trace_fraction);
- cam.view_origin = (newvec - (v_forward * ((TRACE_TEST * cam.light_lev) - WALL_DISTANCE)));
- v1 = (newvec - cam.view_origin);
- v2 = (cam.movetarget.filmpos - cam.view_origin);
- vl1 = vlen (v1);
- vl2 = vlen (v2);
- vnet_x = ((v1_x / vl1) + (v2_x / vl2));
- vnet_y = ((v1_y / vl1) + (v2_y / vl2));
- vnet_z = ((v1_z / vl1) + (v2_z / vl2));
- if ((cam.style & DUAL_BLEND_INTOVIEW))
- {
- cam.lefty = (cam.lefty + (DUAL_BLEND_RATE * frametime));
- if ((cam.lefty > 1))
- {
- cam.lefty = 1;
- cam.style = (cam.style - DUAL_BLEND_INTOVIEW);
- }
- vnet_x = ((cam.lefty * vnet_x) + ((1 - cam.lefty) * cam.predpos_x));
- vnet_y = ((cam.lefty * vnet_y) + ((1 - cam.lefty) * cam.predpos_y));
- vnet_z = ((cam.lefty * vnet_z) + ((1 - cam.lefty) * cam.predpos_z));
- }
- cam.filmpos = vnet;
- cam.view_angle = vectoangles (vnet);
- cam.view_angle_x = (0 - cam.view_angle_x);
- };
- void (entity cam) CC_DoCamAlgorithm =
- {
- CC_UpdateDualCamState (cam);
- CC_CheckForBetterTarget (cam);
- CC_UpdateViewingPitch (cam);
- CC_UpdateViewOffset (cam);
- if ((cam.state == 0))
- {
- CC_MoveSingleCamera (cam);
- }
- else
- {
- CC_MoveDualCamera (cam);
- }
- };
- void () PrepareToObserve =
- {
- if (self.client_)
- {
- TeamCaptureDropFlagOfPlayer (self);
- //ResetItems ();
- }
- RemoveFromAllLists ();
- SetViewPlayer ();
- self.model = "";
- self.weaponmodel = "";
- self.attack_finished = 0;
- self.nextthink = 0;
- self.solid = 0;
- self.deadflag = 0;
- self.takedamage = 0;
- //self.frags = -99;
- setorigin (self, (self.origin + self.view_ofs));
- self.velocity = '0 0 0';
- self.view_ofs_z = 0;
- //self.fChasing = 0;
- //self.observer = 1;
- //self.do_observer = 0;
- self.lastteam = -50;
- self.team = -50;
- self.frags = 0;
- DropRune ();
- };
- void (entity e) CC_DisplayCreepView =
- {
- e.view_ofs_z = 0;
- e.velocity = '0 0 0';
- e.weaponmodel = "";
- msg_entity = e;
- viewport = e;
- SetViewPort ();
- e.modelindex = modelindex_player;
- };
- void (entity e) CC_DisplayFirstView =
- {
- e.view_ofs = viewport.view_ofs;
- msg_entity = e;
- viewport = e.owner;
- if (!viewport.modelindex)
- {
- viewport = viewport.aiment;
- }
- SetViewPort ();
- e.modelindex = 0;
- };
- void (entity c) CC_ChangeToWorldCam =
- {
- CC_RemoveFromCreepList (c);
- c.owner = world;
- c.clink = freecamlist;
- freecamlist = c;
- };
- void (entity c, entity targ_) CC_ChangeToFollowCam =
- {
- local entity l;
- CC_RemoveFromCreepList (c);
- c.owner = targ_;
- if ((c.pflags & PF_FIRSTPERSON))
- {
- CC_DisplayFirstView (c);
- }
- if (!targ_.clink)
- {
- targ_.clink = c;
- c.movetarget = world;
- c.oldenemy = world;
- c.state = 0;
- c.style = 0;
- if ((c.owner.waterlevel >= 3))
- {
- c.view_pitch = -1;
- }
- else
- {
- c.view_pitch = 1;
- }
- c.cangles_x = (VIEWING_PITCH * c.view_pitch);
- c.cangles_z = 0;
- c.vangle = 0;
- c.cangles_y = targ_.v_angle_y;
- makevectors (c.cangles);
- c.filmpos = v_forward;
- c.predpos = c.filmpos;
- c.search_time = CONTENT_EMPTY;
- c.light_lev = 1;
- }
- else
- {
- l = targ_.clink;
- while (l.clink)
- {
- l = l.clink;
- }
- l.clink = c;
- }
- CC_CheckForBetterTarget (c);
- if (!(c.creepflags & CF_DOINGLONGMESSAGE))
- {
- CC_DisplayNames (c);
- }
- };
- void () CC_WaitingCamThink;
- void (entity c) CC_ChangeToAnyCam =
- {
- if (!first_client)
- {
- CC_ChangeToWorldCam (c);
- c.state = 0;
- c.think = CC_WaitingCamThink;
- c.nextthink = 0.001;
- }
- else
- {
- CC_ChangeToFollowCam (c, first_client);
- }
- };
- void () CC_WaitingCamThink =
- {
- local entity pos;
- if (first_client)
- {
- CC_ChangeToFollowCam (self, first_client);
- return;
- }
- if ((self.state == 10))
- {
- self.state = 0;
- }
- self.state = (self.state + 1);
- if ((self.state == 1))
- {
- pos = find (self.movetarget, classname, "info_intermission");
- if ((pos.classname != "info_intermission"))
- {
- pos = find (world, classname, "info_intermission");
- }
- setorigin (self, pos.origin);
- self.filmpos = pos.origin;
- self.cangles = pos.mangle;
- self.movetarget = pos;
- self.nextthink = (time + 1.5);
- self.v_angle = self.cangles;
- self.angles = self.cangles;
- self.fixangle = 1;
- }
- else
- {
- if ((self.state <= 3))
- {
- if (!(self.creepflags & CF_DOINGLONGMESSAGE))
- {
- centerprint (self, "\n\n\n\n\n\n\n\n\n\n\nWaiting for players...");
- }
- }
- self.nextthink = (time + 1);
- }
- };
- void () CC_IntroCamThink =
- {
- local entity pos;
- self.state = (self.state + 1);
- if ((self.state == 1))
- {
- pos = find (world, classname, "info_intermission");
- self.movetarget = pos;
- setorigin (self, pos.origin);
- self.filmpos = pos.origin;
- self.cangles = pos.mangle;
- self.v_angle = self.cangles;
- self.angles = self.cangles;
- self.fixangle = 1;
- self.nextthink = (time + 0.8);
- }
- else
- {
- if ((self.state == 2))
- {
- msg_entity = self;
- //bf ();
- if (!(self.creepflags & CF_DOINGLONGMESSAGE))
- {
- centerprint (self, "ÄiMeÂ’XŸ CreepCam\n\n… activated …");
- }
- self.nextthink = (time + 3);
- }
- else
- {
- CC_ChangeToAnyCam (self);
- }
- }
- };
- void () CC_RequestCam =
- {
- if ((self.flags & FL_CREEPCAM))
- return;
- PrepareToObserve ();
- self.flags = (self.flags | FL_CREEPCAM);
- first_creepcam = AddToList (first_creepcam);
- self.owner = world;
- self.clink = freecamlist;
- freecamlist = self;
- bprint (self.netname);
- bprint (" became a spectator\n");
- //spawn_tfog (self.origin, world);
- self.movetype = MOVETYPE_NONE;
- self.currentammo = 0;
- self.items = 0;
- self.health = 100;
- self.armorvalue = 0;
- self.ammo_shells = 0;
- self.ammo_nails = 0;
- self.ammo_rockets = 0;
- self.ammo_cells = 0;
- self.cangles = self.angles;
- self.state = 0;
- self.style = 0;
- self.think = CC_IntroCamThink;
- self.nextthink = 0.001;
- };
- void () CC_SwitchToNextPlayer =
- {
- local entity next_;
- if (self.owner)
- {
- next_ = self.owner.next;
- if (!next_)
- {
- next_ = first_client;
- if ((next_ == self.owner))
- {
- return;
- }
- }
- CC_ChangeToFollowCam (self, next_);
- }
- };
- void (entity cam) CC_DisplayNames =
- {
- local entity e;
- local float timeleft;
- local float teammate;
- local string tempstring;
- if ((((cam.owner.clink.state > 0) && (cam.owner.team == cam.owner.clink.movetarget.team)) && teamplay))
- {
- teammate = TRUE;
- }
- else
- {
- teammate = FALSE;
- }
- if (cam.owner.player_)
- {
- if ((cam.pflags & PF_FIRSTPERSON))
- {
- centerprint2 (cam, "\n\n\n\n\n\n\n\n\n\nviewing ", cam.owner.netname);
- }
- else
- {
- if ((!cam.owner.clink.state || (cam.pflags & PF_NONAMES)))
- {
- centerprint2 (cam, "\n\n\n\n\n\n\n\n\n\nfollowing ", cam.owner.netname);
- }
- else
- {
- if (teammate)
- {
- centerprint4 (cam, "\n\n\n\n\n\n\n\n\n\nfollowing ", cam.owner.netname, "\ntracking ", cam.owner.clink.movetarget.netname);
- }
- else
- {
- centerprint4 (cam, "\n\n\n\n\n\n\n\n\n\nfollowing ", cam.owner.netname, "\nôòáãëéîç ", cam.owner.clink.movetarget.netname);
- }
- }
- }
- }
- else
- {
- msg_entity = cam;
- WriteByte (MSG_ONE, SVC_CENTERPRINT);
- WriteByte (MSG_ONE, enter);
- WriteByte (MSG_ONE, enter);
- WriteByte (MSG_ONE, enter);
- WriteByte (MSG_ONE, enter);
- WriteByte (MSG_ONE, enter);
- WriteByte (MSG_ONE, enter);
- WriteByte (MSG_ONE, enter);
- WriteByte (MSG_ONE, enter);
- WriteByte (MSG_ONE, enter);
- WriteByte (MSG_ONE, enter);
- if ((cam.pflags & PF_FIRSTPERSON))
- {
- WriteByte (MSG_ONE, _v);
- WriteByte (MSG_ONE, _i);
- WriteByte (MSG_ONE, _e);
- WriteByte (MSG_ONE, _w);
- WriteByte (MSG_ONE, _i);
- WriteByte (MSG_ONE, _n);
- WriteByte (MSG_ONE, _g);
- WriteByte (MSG_ONE, space);
- WriteByte (MSG_ONE, 29);
- WriteByte (MSG_ONE, 31);
- WriteByte (MSG_ONE, space);
- WriteName_apply (MSG_ONE, cam.owner);
- WriteByte (MSG_ONE, 0);
- }
- else
- {
- WriteByte (MSG_ONE, _f);
- WriteByte (MSG_ONE, _o);
- WriteByte (MSG_ONE, _l);
- WriteByte (MSG_ONE, _l);
- WriteByte (MSG_ONE, _o);
- WriteByte (MSG_ONE, _w);
- WriteByte (MSG_ONE, _i);
- WriteByte (MSG_ONE, _n);
- WriteByte (MSG_ONE, _g);
- WriteByte (MSG_ONE, space);
- WriteByte (MSG_ONE, 29);
- WriteByte (MSG_ONE, 31);
- WriteByte (MSG_ONE, space);
- WriteName_apply (MSG_ONE, cam.owner);
- if ((!cam.owner.clink.state || (cam.pflags & PF_NONAMES)))
- {
- WriteByte (MSG_ONE, 0);
- }
- else
- {
- WriteByte (MSG_ONE, enter);
- if (teammate)
- {
- WriteByte (MSG_ONE, _t);
- WriteByte (MSG_ONE, _r);
- WriteByte (MSG_ONE, _a);
- WriteByte (MSG_ONE, _c);
- WriteByte (MSG_ONE, _k);
- WriteByte (MSG_ONE, _i);
- WriteByte (MSG_ONE, _n);
- WriteByte (MSG_ONE, _g);
- WriteByte (MSG_ONE, space);
- WriteByte (MSG_ONE, 29);
- WriteByte (MSG_ONE, 31);
- WriteByte (MSG_ONE, space);
- }
- else
- {
- WriteByte (MSG_ONE, 244);
- WriteByte (MSG_ONE, 242);
- WriteByte (MSG_ONE, 225);
- WriteByte (MSG_ONE, 227);
- WriteByte (MSG_ONE, 235);
- WriteByte (MSG_ONE, 233);
- WriteByte (MSG_ONE, 238);
- WriteByte (MSG_ONE, 231);
- WriteByte (MSG_ONE, space);
- WriteByte (MSG_ONE, 29);
- WriteByte (MSG_ONE, 31);
- WriteByte (MSG_ONE, space);
- }
- if (cam.owner.clink.movetarget.player_)
- {
- WriteString (MSG_ONE, cam.owner.clink.movetarget.netname);
- }
- else
- {
- WriteName_apply (MSG_ONE, cam.owner.clink.movetarget);
- WriteByte (MSG_ONE, 0);
- }
- }
- }
- }
- cam.msgtime = (time + 1);
- };
- void (entity cam) CC_RefreshNames =
- {
- local float update;
- update = FALSE;
- if (!(cam.pflags & PF_NONAMES))
- {
- if (((!cam.owner.clink.state && (cam.oldstate > 0)) || ((cam.owner.clink.state > 0) && !cam.oldstate)))
- {
- update = TRUE;
- }
- if (((cam.owner.clink.state > 0) && (cam.owner.clink.movetarget != cam.oldmovetarget)))
- {
- update = TRUE;
- }
- if ((time > cam.msgtime))
- {
- CC_DisplayNames (cam);
- }
- else
- {
- if (!(cam.pflags & PF_FIRSTPERSON))
- {
- if ((update == TRUE))
- {
- CC_DisplayNames (cam);
- }
- }
- }
- }
- cam.oldstate = cam.owner.clink.state;
- cam.oldmovetarget = cam.owner.clink.movetarget;
- };
- void () CC_NoNames =
- {
- msg_entity = self;
- if ((self.pflags & PF_NONAMES))
- {
- //sprint ("constant name display åîáâìåä.\n");
- self.pflags = (self.pflags - (self.pflags & PF_NONAMES));
- }
- else
- {
- // sprint ("constant name display äéóáâìåä.\n");
- self.pflags = (self.pflags | PF_NONAMES);
- }
- };
- float (float v) newanglemod;
- float (float v) FixedAngle2;
- void () CC_PlayerPostThink =
- {
- local vector d;
- if ((self.flags & FL_ONGROUND))
- {
- if (((self.origin_z - self.oldorigin_z) > ((self.velocity_z * frametime) + 1)))
- {
- d = (self.origin - self.oldorigin);
- d_z = 0;
- if ((vlen (d) < 300))
- {
- self.filmlip = ((self.filmlip - self.origin_z) + self.oldorigin_z);
- if ((self.filmlip < FILM_LO_LIP))
- {
- self.filmlip = FILM_LO_LIP;
- }
- }
- }
- }
- if ((self.filmlip < FILM_HI_LIP))
- {
- self.filmlip = (self.filmlip + (STAIR_BLEND_RATE * frametime));
- if ((self.filmlip > FILM_HI_LIP))
- {
- self.filmlip = FILM_HI_LIP;
- }
- }
- self.filmpos = self.origin;
- self.filmpos_z = (self.filmpos_z + self.filmlip);
- traceline (self.filmpos, (self.filmpos + (PRED_TIME * self.velocity)), TRUE, self);
- self.predpos = (trace_endpos - (CLIP_TIME * self.velocity));
- };
- void () CC_CamPostThink_has_owner1 =
- {
- if (((self.owner.health > 0) || (self.pflags & PF_FIRSTPERSON)))
- {
- self.health = self.owner.health;
- }
- else
- {
- self.health = 1;
- }
- self.weapon = self.owner.weapon;
- self.currentammo = self.owner.currentammo;
- self.ammo_shells = self.owner.ammo_shells;
- self.ammo_nails = self.owner.ammo_nails;
- self.ammo_rockets = self.owner.ammo_rockets;
- self.ammo_cells = self.owner.ammo_cells;
- self.items = self.owner.items;
- self.armortype = self.owner.armortype;
- self.armorvalue = self.owner.armorvalue;
- };
- void () CC_CamPostThink_no_owner =
- {
- self.health = 100;
- self.weapon = IT_AXE;
- self.currentammo = 0;
- self.ammo_shells = 0;
- self.ammo_nails = 0;
- self.ammo_rockets = 0;
- self.ammo_cells = 0;
- self.items = 0;
- self.armortype = 0;
- self.armorvalue = 0;
- };
- void () CC_CamPostThink =
- {
- if (self.button0)
- {
- if (!(self.attack_finished & BUTTON0))
- {
- self.attack_finished = (self.attack_finished | BUTTON0);
- if (self.owner)
- {
- if ((self.pflags & PF_FIRSTPERSON))
- {
- self.pflags = (self.pflags - PF_FIRSTPERSON);
- CC_DisplayCreepView (self);
- }
- else
- {
- self.pflags = (self.pflags | PF_FIRSTPERSON);
- CC_DisplayFirstView (self);
- }
- CC_DisplayNames (self);
- }
- }
- }
- else
- {
- self.attack_finished = (self.attack_finished & NOT_BUTTON0);
- }
- if (self.button2)
- {
- if (!(self.attack_finished & BUTTON2))
- {
- self.attack_finished = (self.attack_finished | BUTTON2);
- CC_SwitchToNextPlayer ();
- }
- }
- else
- {
- self.attack_finished = (self.attack_finished & NOT_BUTTON2);
- }
- };
- void () CC_CamPostThink_has_owner2 =
- {
- if ((self.pflags & PF_FIRSTPERSON))
- {
- setorigin (self, self.owner.origin);
- self.weaponmodel = self.owner.weaponmodel;
- self.weaponframe = self.owner.weaponframe;
- self.view_ofs = self.owner.view_ofs;
- if ((self.owner.v_angle_x < 0))
- {
- self.angles_x = (self.owner.v_angle_x - 2.8125);
- }
- else
- {
- self.angles_x = self.owner.v_angle_x;
- }
- self.angles_y = self.owner.v_angle_y;
- self.velocity = self.owner.velocity;
- }
- else
- {
- setorigin (self, self.owner.clink.view_origin);
- self.angles_x = self.owner.clink.view_angle_x;
- self.angles_y = self.owner.clink.view_angle_y;
- }
- self.angles_z = 0;
- self.angles_x = FixedAngle2 (self.angles_x);
- self.angles_y = FixedAngle2 (self.angles_y);
- self.fixangle = TRUE;
- CC_RefreshNames (self);
- };
- void () CC_CamThink =
- {
- if (self.owner)
- {
- if ((self.owner.clink == self))
- {
- creep_self = self;
- CC_CamPostThink_has_owner1 ();
- CC_CamPostThink ();
- CC_DoCamAlgorithm (self);
- CC_CamPostThink_has_owner2 ();
- self = self.clink;
- while (self.clink)
- {
- CC_CamPostThink_has_owner1 ();
- CC_CamPostThink ();
- CC_CamPostThink_has_owner2 ();
- }
- self = creep_self;
- }
- }
- else
- {
- CC_CamPostThink_no_owner ();
- CC_CamPostThink ();
- }
- };
- float (float v) cc_anglemod =
- {
- while ((v >= 360))
- {
- v = (v - 360);
- }
- while ((v < 0))
- {
- v = (v + 360);
- }
- return (v);
- };
- float (float v) newanglemod =
- {
- while ((v >= 180))
- {
- v = (v - 360);
- }
- while ((v < -180))
- {
- v = (v + 360);
- }
- return (v);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement