/* * CG_Cmd_PrevWeapon_f */ static void CG_Cmd_PrevWeapon_f( void ) { gsitem_t *item; if( !cg.frame.valid ) return; if( cgs.demoPlaying || cg.predictedPlayerState.pmove.pm_type == PM_CHASECAM ) { CG_ChaseStep( -1 ); return; } item = GS_Cmd_PrevWeapon_f( &cg.frame.playerState, cg.predictedWeaponSwitch ); if( item ) { CG_Predict_ChangeWeapon( item->tag ); trap_Cmd_ExecuteText( EXEC_NOW, va( "cmd use %i", item->tag ) ); cg.lastWeapon = cg.predictedPlayerState.stats[STAT_PENDING_WEAPON]; } }
/* * CG_ChaseCamButtons */ static void CG_ChaseCamButtons( void ) { #define CHASECAMBUTTONSDELAY ( cg.time + 250 ) usercmd_t cmd; bool chasecam = ( cg.frame.playerState.pmove.pm_type == PM_CHASECAM ) && ( cg.frame.playerState.POVnum != (unsigned)( cgs.playerNum + 1 ) ); bool realSpec = cgs.demoPlaying || ISREALSPECTATOR(); if( (cg.frame.multipov || chasecam) && !CG_DemoCam_IsFree() ) { if( cg.time <= chaseCam.cmd_mode_delay ) return; trap_NET_GetUserCmd( trap_NET_GetCurrentUserCmdNum() - 1, &cmd ); if( ( cmd.buttons & BUTTON_ATTACK ) ) { if( chasecam ) { if( realSpec ) { if( ++chaseCam.mode >= CAM_MODES ) { // if exceeds the cycle, start free fly trap_Cmd_ExecuteText( EXEC_NOW, "camswitch" ); chaseCam.mode = 0; // smallest, to start the new cycle } chaseCam.cmd_mode_delay = CHASECAMBUTTONSDELAY; } } else { chaseCam.mode = ( chaseCam.mode != CAM_THIRDPERSON ); chaseCam.cmd_mode_delay = CHASECAMBUTTONSDELAY; } } if( cg.frame.multipov || chasecam ) { int step = 0; if( cmd.upmove > 0 || cmd.buttons & BUTTON_SPECIAL ) step = 1; else if( cmd.upmove < 0 ) step = -1; if( step ) { CG_ChaseStep( step ); chaseCam.cmd_mode_delay = CHASECAMBUTTONSDELAY; } } } else if( CG_DemoCam_IsFree() || cg.frame.playerState.pmove.pm_type == PM_SPECTATOR ) { chaseCam.mode = CAM_INEYES; if( realSpec ) { trap_NET_GetUserCmd( trap_NET_GetCurrentUserCmdNum() - 1, &cmd ); if( ( cmd.buttons & BUTTON_ATTACK ) && cg.time > chaseCam.cmd_mode_delay ) { trap_Cmd_ExecuteText( EXEC_NOW, "camswitch" ); chaseCam.cmd_mode_delay = CHASECAMBUTTONSDELAY; } } } else { chaseCam.mode = CAM_INEYES; } #undef CHASECAMBUTTONSDELAY }