+ if (v_dmg_time > 0)
+ {
+ r_refdef.viewangles[ROLL] += v_dmg_time/v_kicktime.value*v_dmg_roll;
+ r_refdef.viewangles[PITCH] += v_dmg_time/v_kicktime.value*v_dmg_pitch;
+ v_dmg_time -= cl.frametime;
+ }
+
+ if (cl.stats[STAT_HEALTH] <= 0)
+ r_refdef.viewangles[ROLL] = 80; // dead view angle
+
+ V_AddIdle (v_idlescale.value);
+
+ // offsets
+ angles[PITCH] = -ent->render.angles[PITCH]; // because entity pitches are actually backward
+ angles[YAW] = ent->render.angles[YAW];
+ angles[ROLL] = ent->render.angles[ROLL];
+
+ AngleVectors (angles, forward, NULL, NULL);
+
+ bob = V_CalcBob ();
+
+ r_refdef.vieworg[2] += cl.viewheight + bob;
+
+ // set up gun
+ view->state_current.modelindex = cl.stats[STAT_WEAPON];
+ view->state_current.frame = cl.stats[STAT_WEAPONFRAME];
+ VectorCopy(r_refdef.vieworg, view->render.origin);
+ //view->render.origin[0] = ent->render.origin[0] + bob * 0.4 * forward[0];
+ //view->render.origin[1] = ent->render.origin[1] + bob * 0.4 * forward[1];
+ //view->render.origin[2] = ent->render.origin[2] + bob * 0.4 * forward[2] + cl.viewheight + bob;
+ view->render.angles[PITCH] = -r_refdef.viewangles[PITCH] - v_idlescale.value * sin(cl.time*v_iyaw_cycle.value) * v_iyaw_level.value;
+ view->render.angles[YAW] = r_refdef.viewangles[YAW] - v_idlescale.value * sin(cl.time*v_ipitch_cycle.value) * v_ipitch_level.value;
+ view->render.angles[ROLL] = r_refdef.viewangles[ROLL] - v_idlescale.value * sin(cl.time*v_iroll_cycle.value) * v_iroll_level.value;
+ // FIXME: this setup code is somewhat evil (CL_LerpUpdate should be private?)
+ CL_LerpUpdate(view);
+ view->render.colormap = -1; // no special coloring
+ view->render.alpha = ent->render.alpha; // LordHavoc: if the player is transparent, so is the gun
+ view->render.effects = ent->render.effects;
+ view->render.scale = 1.0 / 3.0;
+
+ // LordHavoc: origin view kick added
+ if (!intimerefresh)
+ {
+ VectorAdd(r_refdef.viewangles, cl.punchangle, r_refdef.viewangles);
+ VectorAdd(r_refdef.vieworg, cl.punchvector, r_refdef.vieworg);
+ }
+
+ // copy to refdef
+ r_refdef.viewent = view->render;
+ }