/* ============= CG_SetModel_f ============= */ void CG_SetModel_f( int localPlayerNum ) { const char *arg; char name[256]; #ifdef IOQ3ZTM // BLANK_HEADMODEL char head[256]; #else char cvarName[32]; Q_strncpyz( cvarName, Com_LocalPlayerCvarName( localPlayerNum, "model"), sizeof (cvarName) ); #endif arg = CG_Argv( 1 ); if ( arg[0] ) { #ifdef IOQ3ZTM // BLANK_HEADMODEL trap_Cvar_Set( Com_LocalPlayerCvarName( localPlayerNum, "model"), arg ); arg = CG_Argv( 2 ); #else trap_Cvar_Set( cvarName, arg ); #endif trap_Cvar_Set( Com_LocalPlayerCvarName( localPlayerNum, "headmodel"), arg ); } else { #ifdef IOQ3ZTM // BLANK_HEADMODEL trap_Cvar_VariableStringBuffer( Com_LocalPlayerCvarName( localPlayerNum, "model"), name, sizeof(name) ); trap_Cvar_VariableStringBuffer( Com_LocalPlayerCvarName( localPlayerNum, "headmodel"), head, sizeof(head) ); if (Q_stricmp(name, head) == 0) { Com_Printf("player model is set to %s\n", name); } else { Com_Printf("player model is set to %s, player head model is set to %s\n", name, head); } #else trap_Cvar_VariableStringBuffer( cvarName, name, sizeof(name) ); Com_Printf("%s is set to %s\n", cvarName, name); #endif } }
/* ================= PlayerModel_SaveChanges ================= */ static void PlayerModel_SaveChanges( void ) { trap_Cvar_Set( Com_LocalPlayerCvarName(s_playermodel.localPlayerNum, "model"), s_playermodel.modelskin ); trap_Cvar_Set( Com_LocalPlayerCvarName(s_playermodel.localPlayerNum, "headmodel"), s_playermodel.headmodelskin ); trap_Cvar_Set( Com_LocalPlayerCvarName(s_playermodel.localPlayerNum, "team_model"), s_playermodel.modelskin ); trap_Cvar_Set( Com_LocalPlayerCvarName(s_playermodel.localPlayerNum, "team_headmodel"), s_playermodel.headmodelskin ); }
static void CG_TaskOffense_f( int localPlayerNum ) { if (cgs.gametype == GT_CTF || cgs.gametype == GT_1FCTF) { trap_Cmd_ExecuteText(EXEC_NOW, va("cmd %s %s\n", Com_LocalPlayerCvarName(localPlayerNum, "vsay_team"), VOICECHAT_ONGETFLAG)); } else { trap_Cmd_ExecuteText(EXEC_NOW, va("cmd %s %s\n", Com_LocalPlayerCvarName(localPlayerNum, "vsay_team"), VOICECHAT_ONOFFENSE)); } trap_SendClientCommand(va("%s %d\n", Com_LocalPlayerCvarName(localPlayerNum, "teamtask"), TEAMTASK_OFFENSE)); }
/* ================= PlayerModel_SetMenuItems ================= */ static void PlayerModel_SetMenuItems( void ) { int i; int maxlen; char modelskin[64]; char* buffptr; char* pdest; // name trap_Cvar_VariableStringBuffer( Com_LocalPlayerCvarName(s_playermodel.localPlayerNum, "name"), s_playermodel.playername.string, 16 ); Q_CleanStr( s_playermodel.playername.string ); // model trap_Cvar_VariableStringBuffer( Com_LocalPlayerCvarName(s_playermodel.localPlayerNum, "model"), s_playermodel.modelskin, sizeof ( s_playermodel.modelskin ) ); trap_Cvar_VariableStringBuffer( Com_LocalPlayerCvarName(s_playermodel.localPlayerNum, "headmodel"), s_playermodel.headmodelskin, sizeof ( s_playermodel.headmodelskin ) ); // use default skin if none is set if (!strchr(s_playermodel.modelskin, '/')) { Q_strcat(s_playermodel.modelskin, 64, "/default"); } // find model in our list for (i=0; i<s_playermodel.nummodels; i++) { // strip icon_ buffptr = s_playermodel.modelnames[i] + strlen("models/players/"); pdest = strstr(buffptr,"icon_"); if (pdest) { Q_strncpyz( modelskin, buffptr, pdest - buffptr + 1 ); Q_strcat( modelskin, sizeof (modelskin), pdest + 5); } else continue; if (!Q_stricmp( s_playermodel.modelskin, modelskin )) { // found pic, set selection here s_playermodel.selectedmodel = i; s_playermodel.modelpage = i/MAX_MODELSPERPAGE; // seperate the model name maxlen = pdest-buffptr; if (maxlen > 16) maxlen = 16; Q_strncpyz( s_playermodel.modelname.string, buffptr, maxlen ); Q_strupr( s_playermodel.modelname.string ); // seperate the skin name maxlen = strlen(pdest+5)+1; if (maxlen > 16) maxlen = 16; Q_strncpyz( s_playermodel.skinname.string, pdest+5, maxlen ); Q_strupr( s_playermodel.skinname.string ); break; } } }
static void CG_CameraOrbit( int speed, int delay ) { int i; trap_Cvar_SetValue( "cg_cameraOrbit", speed ); if ( delay > 0 ) { trap_Cvar_SetValue( "cg_cameraOrbitDelay", delay ); } for ( i = 0; i < CG_MaxSplitView(); i++ ) { trap_Cvar_SetValue(Com_LocalPlayerCvarName( i, "cg_thirdPerson" ), speed == 0 ? 0 : 1 ); trap_Cvar_SetValue(Com_LocalPlayerCvarName( i, "cg_thirdPersonAngle" ), 0 ); trap_Cvar_SetValue(Com_LocalPlayerCvarName( i, "cg_thirdPersonRange" ), 100 ); } }
static void CG_DenyOrder_f( int localPlayerNum ) { localPlayer_t *player; player = &cg.localPlayers[ localPlayerNum ]; if ( player->playerNum == -1 ) { return; } trap_Cmd_ExecuteText(EXEC_NOW, va("cmd %s %d %s\n", Com_LocalPlayerCvarName(localPlayerNum, "vtell"), player->acceptLeader, VOICECHAT_NO)); trap_Cmd_ExecuteText(EXEC_NOW, va("%s; wait; %s", Com_LocalPlayerCvarName(localPlayerNum, "+button6"), Com_LocalPlayerCvarName(localPlayerNum, "-button6"))); if (cg.time < player->acceptOrderTime) { player->acceptOrderTime = 0; } }
/* ============= CG_SetModel_f ============= */ void CG_SetModel_f( int localPlayerNum ) { const char *arg; char name[256]; char cvarName[32]; Q_strncpyz( cvarName, Com_LocalPlayerCvarName( localPlayerNum, "model"), sizeof (cvarName) ); arg = CG_Argv( 1 ); if ( arg[0] ) { trap_Cvar_Set( cvarName, arg ); trap_Cvar_Set( Com_LocalPlayerCvarName( localPlayerNum, "headmodel"), arg ); } else { trap_Cvar_VariableStringBuffer( cvarName, name, sizeof(name) ); Com_Printf("%s is set to %s\n", cvarName, name); } }
/* =================== CL_InitJoyRemapCommands =================== */ void CL_InitJoyRemapCommands( void ) { int i; Com_Memset( &joyDevice, 0, sizeof ( joyDevice ) ); // register our functions for ( i = 0; i < CL_MAX_SPLITVIEW; i++ ) { playerJoyRemapIndex[i] = -1; Cmd_AddCommand( Com_LocalPlayerCvarName( i, "joyremap" ),Cmd_JoyRemap_f ); Cmd_SetCommandCompletionFunc( Com_LocalPlayerCvarName( i, "joyremap" ), Cmd_CompleteJoyRemap ); Cmd_AddCommand( Com_LocalPlayerCvarName( i, "joyunmap" ), Cmd_JoyUnmap_f ); //Cmd_SetCommandCompletionFunc( Com_LocalPlayerCvarName( i, "joyunmap" ), Cmd_CompleteJoyUnmap ); Cmd_AddCommand( Com_LocalPlayerCvarName( i, "joyunmapall" ), Cmd_JoyUnmapAll_f ); Cmd_AddCommand( Com_LocalPlayerCvarName( i, "joyremaplist" ), Cmd_JoyRemapList_f); } }
static void CG_TaskSuicide_f( int localPlayerNum ) { int playerNum; char command[128]; playerNum = CG_CrosshairPlayer(0); if ( playerNum == -1 ) { return; } Com_sprintf( command, 128, "%s %i suicide", Com_LocalPlayerCvarName( localPlayerNum, "tell" ), playerNum ); trap_SendClientCommand( command ); }
void CG_TargetCommand_f( int localPlayerNum ) { int targetNum; char test[4]; targetNum = CG_CrosshairPlayer( localPlayerNum ); if ( targetNum == -1 ) { return; } trap_Argv( 1, test, 4 ); trap_SendClientCommand( va( "%s %i %i", Com_LocalPlayerCvarName( localPlayerNum, "gc" ), targetNum, atoi( test ) ) ); }
static void CG_CameraOrbit( int speed, int delay ) { int i; trap_Cvar_SetValue( "cg_cameraOrbit", speed ); #ifndef IOQ3ZTM // NEW_CAM if ( delay > 0 ) { trap_Cvar_SetValue( "cg_cameraOrbitDelay", delay ); } #endif for ( i = 0; i < CG_MaxSplitView(); i++ ) { #ifdef TURTLEARENA // THIRD_PERSON trap_Cvar_SetValue(Com_LocalPlayerCvarName( i, "cg_thirdPerson" ), 1 ); #else trap_Cvar_SetValue(Com_LocalPlayerCvarName( i, "cg_thirdPerson" ), speed == 0 ? 0 : 1 ); #endif trap_Cvar_SetValue(Com_LocalPlayerCvarName( i, "cg_thirdPersonAngle" ), 0 ); #ifndef TURTLEARENA // THIRD_PERSON trap_Cvar_SetValue(Com_LocalPlayerCvarName( i, "cg_thirdPersonRange" ), 100 ); #endif } }
static void CG_VoiceTellAttacker_f( int localPlayerNum ) { int playerNum; char command[128]; char message[128]; playerNum = CG_LastAttacker( localPlayerNum ); if ( playerNum == -1 ) { return; } trap_Args( message, 128 ); Com_sprintf( command, 128, "%s %i %s", Com_LocalPlayerCvarName( localPlayerNum, "vtell" ), playerNum, message ); trap_SendClientCommand( command ); }
static void CG_TellTarget_f( int localPlayerNum ) { int playerNum; char command[128]; char message[128]; playerNum = CG_CrosshairPlayer( localPlayerNum ); if ( playerNum == -1 ) { return; } trap_Args( message, 128 ); Com_sprintf( command, 128, "%s %i %s", Com_LocalPlayerCvarName( localPlayerNum, "tell" ), playerNum, message ); trap_SendClientCommand( command ); }
static void CG_ConfirmOrder_f( int localPlayerNum ) { localPlayer_t *player; player = &cg.localPlayers[ localPlayerNum ]; if ( player->playerNum == -1 ) { return; } trap_Cmd_ExecuteText(EXEC_NOW, va("cmd %s %d %s\n", Com_LocalPlayerCvarName(localPlayerNum, "vtell"), player->acceptLeader, VOICECHAT_YES)); trap_Cmd_ExecuteText(EXEC_NOW, "+button5; wait; -button5"); if (cg.time < player->acceptOrderTime) { trap_SendClientCommand(va("teamtask %d\n", player->acceptTask)); player->acceptOrderTime = 0; } }
/* ================= CG_RegisterInputCvars ================= */ void CG_RegisterInputCvars( void ) { int i; trap_Cvar_Register( &cg_freelook, "cl_freelook", "1", CVAR_ARCHIVE ); // ZTM: NOTE: changing name breaks team arena menu scripts trap_Cvar_Register( &m_pitch, "m_pitch", "0.022", CVAR_ARCHIVE ); trap_Cvar_Register( &m_yaw, "m_yaw", "0.022", CVAR_ARCHIVE ); trap_Cvar_Register( &m_forward, "m_forward", "0.25", CVAR_ARCHIVE ); trap_Cvar_Register( &m_side, "m_side", "0.25", CVAR_ARCHIVE ); for (i = 0; i < CG_MaxSplitView(); i++) { trap_Cvar_Register( &cg_yawspeed[i], Com_LocalPlayerCvarName(i, "cg_yawspeed"), "140", CVAR_ARCHIVE ); trap_Cvar_Register( &cg_pitchspeed[i], Com_LocalPlayerCvarName(i, "cg_pitchspeed"), "140", CVAR_ARCHIVE ); trap_Cvar_Register( &cg_yawspeedanalog[i], Com_LocalPlayerCvarName(i, "cg_yawspeedanalog"), "200", CVAR_ARCHIVE ); trap_Cvar_Register( &cg_pitchspeedanalog[i], Com_LocalPlayerCvarName(i, "cg_pitchspeedanalog"), "200", CVAR_ARCHIVE ); trap_Cvar_Register( &cg_anglespeedkey[i], Com_LocalPlayerCvarName(i, "cg_anglespeedkey"), "1.5", 0 ); trap_Cvar_Register( &cg_run[i], Com_LocalPlayerCvarName(i, "cl_run"), "1", CVAR_ARCHIVE ); // ZTM: NOTE: changing name breaks team arena menu scripts trap_Cvar_Register( &cg_joystickUseAnalog[i], Com_LocalPlayerCvarName(i, "in_joystickUseAnalog"), "1", CVAR_ARCHIVE ); trap_Cvar_Register( &cg_joystickThreshold[i], Com_LocalPlayerCvarName(i, "in_joystickThreshold"), "0.15", CVAR_ARCHIVE ); } }
static void CG_TaskRetrieve_f( int localPlayerNum ) { trap_Cmd_ExecuteText(EXEC_NOW, va("cmd %s %s\n", Com_LocalPlayerCvarName(localPlayerNum, "vsay_team"), VOICECHAT_ONRETURNFLAG)); trap_SendClientCommand(va("%s %d\n", Com_LocalPlayerCvarName(localPlayerNum, "teamtask"), TEAMTASK_RETRIEVE)); }
static void CG_TauntGauntlet_f( int localPlayerNum ) { trap_Cmd_ExecuteText(EXEC_NOW, va("cmd %s %s\n", Com_LocalPlayerCvarName(localPlayerNum, "vsay"), VOICECHAT_KILLGAUNTLET)); }
/* ================= CG_InitConsoleCommands Let the client system know about all of our commands so it can perform tab completion ================= */ void CG_InitConsoleCommands( void ) { int i, j; for ( i = 0 ; i < cg_numCommands ; i++ ) { trap_AddCommand( cg_commands[i].cmd ); } for ( i = 0 ; i < ui_numCommands ; i++ ) { trap_AddCommand( ui_commands[i].cmd ); } for ( i = 0 ; i < numPlayerCommands ; i++ ) { for ( j = 0; j < CG_MaxSplitView(); j++ ) { trap_AddCommand( Com_LocalPlayerCvarName( j, playerCommands[i].cmd ) ); } } if ( !cg.connected ) { return; } // // the game server will interpret these commands, which will be automatically // forwarded to the server after they are not recognized locally // for (i = 0; i < CG_MaxSplitView(); i++) { trap_AddCommand(Com_LocalPlayerCvarName(i, "say")); trap_AddCommand(Com_LocalPlayerCvarName(i, "say_team")); trap_AddCommand(Com_LocalPlayerCvarName(i, "tell")); trap_AddCommand(Com_LocalPlayerCvarName(i, "vsay")); trap_AddCommand(Com_LocalPlayerCvarName(i, "vsay_team")); trap_AddCommand(Com_LocalPlayerCvarName(i, "vtell")); trap_AddCommand(Com_LocalPlayerCvarName(i, "vosay")); trap_AddCommand(Com_LocalPlayerCvarName(i, "vosay_team")); trap_AddCommand(Com_LocalPlayerCvarName(i, "votell")); trap_AddCommand(Com_LocalPlayerCvarName(i, "vtaunt")); trap_AddCommand(Com_LocalPlayerCvarName(i, "give")); trap_AddCommand(Com_LocalPlayerCvarName(i, "god")); trap_AddCommand(Com_LocalPlayerCvarName(i, "notarget")); trap_AddCommand(Com_LocalPlayerCvarName(i, "noclip")); trap_AddCommand(Com_LocalPlayerCvarName(i, "where")); trap_AddCommand(Com_LocalPlayerCvarName(i, "kill")); trap_AddCommand(Com_LocalPlayerCvarName(i, "teamtask")); trap_AddCommand(Com_LocalPlayerCvarName(i, "levelshot")); trap_AddCommand(Com_LocalPlayerCvarName(i, "follow")); trap_AddCommand(Com_LocalPlayerCvarName(i, "follownext")); trap_AddCommand(Com_LocalPlayerCvarName(i, "followprev")); trap_AddCommand(Com_LocalPlayerCvarName(i, "team")); trap_AddCommand(Com_LocalPlayerCvarName(i, "callvote")); trap_AddCommand(Com_LocalPlayerCvarName(i, "vote")); trap_AddCommand(Com_LocalPlayerCvarName(i, "callteamvote")); trap_AddCommand(Com_LocalPlayerCvarName(i, "teamvote")); trap_AddCommand(Com_LocalPlayerCvarName(i, "setviewpos")); trap_AddCommand(Com_LocalPlayerCvarName(i, "stats")); } }
static void CG_TauntTaunt_f( int localPlayerNum ) { trap_Cmd_ExecuteText(EXEC_NOW, va("cmd %s\n", Com_LocalPlayerCvarName(localPlayerNum, "vtaunt"))); }
static void CG_TauntDeathInsult_f( int localPlayerNum ) { trap_Cmd_ExecuteText(EXEC_NOW, va("cmd %s %s\n", Com_LocalPlayerCvarName(localPlayerNum, "vsay"), VOICECHAT_DEATHINSULT)); }
static void CG_TauntPraise_f( int localPlayerNum ) { trap_Cmd_ExecuteText(EXEC_NOW, va("cmd %s %s\n", Com_LocalPlayerCvarName(localPlayerNum, "vsay"), VOICECHAT_PRAISE)); }
static void CG_TaskOwnFlag_f( int localPlayerNum ) { trap_Cmd_ExecuteText(EXEC_NOW, va("cmd %s %s\n", Com_LocalPlayerCvarName(localPlayerNum, "vsay_team"), VOICECHAT_IHAVEFLAG)); }
static void CG_TaskEscort_f( int localPlayerNum ) { trap_Cmd_ExecuteText(EXEC_NOW, va("cmd %s %s\n", Com_LocalPlayerCvarName(localPlayerNum, "vsay_team"), VOICECHAT_ONFOLLOWCARRIER)); trap_SendClientCommand(va("%s %d\n", Com_LocalPlayerCvarName(localPlayerNum, "teamtask"), TEAMTASK_ESCORT)); }
static void CG_TaskDefense_f( int localPlayerNum ) { trap_Cmd_ExecuteText(EXEC_NOW, va("cmd %s %s\n", Com_LocalPlayerCvarName(localPlayerNum, "vsay_team"), VOICECHAT_ONDEFENSE)); trap_SendClientCommand(va("teamtask %d\n", TEAMTASK_DEFENSE)); }
static void CG_TaskCamp_f( int localPlayerNum ) { trap_Cmd_ExecuteText(EXEC_NOW, va("cmd %s %s\n", Com_LocalPlayerCvarName(localPlayerNum, "vsay_team"), VOICECHAT_ONCAMPING)); trap_SendClientCommand(va("%s %d\n", Com_LocalPlayerCvarName(localPlayerNum, "teamtask"), TEAMTASK_CAMP)); }