Code Editing Tutorials
Adding a Weapon Change sound

Step 1. Open WL_AGENT.C and do a search for "CheckWeaponChange". Rewrite the function as follows:

void CheckWeaponChange (void)
{
int i,buttons;
if (!gamestate.ammo) // must use knife with no ammo
return;
switch (LastScan)
{
case 2:
LastScan=0;
gamestate.weapon = gamestate.chosenweapon = wp_knife;
break;
case 3:
LastScan=0;
SD_PlaySound (YOURSOUND); // insert a sound slot you don't need here
gamestate.weapon = gamestate.chosenweapon = wp_pistol;
break;
case 4:
LastScan=0;
if (gamestate.bestweapon >= wp_machinegun)
{
SD_PlaySound (YOURSOUND); // insert a sound slot you don't need here
gamestate.weapon = gamestate.chosenweapon = wp_machinegun;
}
break;
case 5:
LastScan=0;
if (gamestate.bestweapon >= wp_chaingun)
{SD_PlaySound (YOURSOUND); // insert a sound slot you don't need here
gamestate.weapon = gamestate.chosenweapon = wp_chaingun;
}
break;
}
DrawWeapon();
}

If you use more than 4 weapons, add more "case" statements for each extra weapon. That's it. Compile and link it up. Have fun with your weapon change sound!

Get back to the Dome tutorials
Jump to the top