I was wondering exactly how easy it would be to reimplement the q3-style "weapon #" commands in q4 so I downloaded the SDK and spent a few hours screwing around with it. I found out it's insanely easy. Here's the code, enjoy.
Update: ESR annihilates whitespace, you're going to have to indent this yourself kiddies.
in source/game/gamesys/SysCmds.cpp:
add this function
--snip--
void Cmd_Weapon_f( const idCmdArgs &args ) {
idPlayer *player;
int weapon;
player = gameLocal.GetLocalPlayer();
if ( args.Argc() > 1 && player ) {
weapon = atoi( args.Argv( 1 ) );
}
else {
gameLocal.Printf( "weapon <weapon number>\n" );
return;
}
if ( weapon >= 0 && weapon <= 12 ) {
player->PerformImpulse( weapon );
return;
}
else {
gameLocal.Printf( "weapon <weapon number>\n" );
return;
}
}
--snip--
in source/game/gamesys/SysCmds.cpp:
add this line to idGameLocal::InitConsoleCommands
--snip--
cmdSystem->AddCommand( "weapon", Cmd_Weapon_f, CMD_FL_GAME, "Switches weapons");
--snip--
Update: ESR annihilates whitespace, you're going to have to indent this yourself kiddies.
in source/game/gamesys/SysCmds.cpp:
add this function
--snip--
void Cmd_Weapon_f( const idCmdArgs &args ) {
idPlayer *player;
int weapon;
player = gameLocal.GetLocalPlayer();
if ( args.Argc() > 1 && player ) {
weapon = atoi( args.Argv( 1 ) );
}
else {
gameLocal.Printf( "weapon <weapon number>\n" );
return;
}
if ( weapon >= 0 && weapon <= 12 ) {
player->PerformImpulse( weapon );
return;
}
else {
gameLocal.Printf( "weapon <weapon number>\n" );
return;
}
}
--snip--
in source/game/gamesys/SysCmds.cpp:
add this line to idGameLocal::InitConsoleCommands
--snip--
cmdSystem->AddCommand( "weapon", Cmd_Weapon_f, CMD_FL_GAME, "Switches weapons");
--snip--
Edited by Keymaster at 01:18 GMT, 5th Feb 2006 - 1517 Hits