Game Development Reference
In-Depth Information
mWeapons[Type].SetAccDecayDiv( AccDecayDiv );
mWeapons[Type].SetAccDecayShift( AccDecayShift );
mWeapons[Type].SetName( Name );
}
In the function
InitWeapons()
, we call
InitOneWeapon()
once for each of our
four weapons.
void CWeaponCollection::InitWeapons()
{
InitOneWeapon( WEAPON_PISTOL, “Pistol�, 137,
10, 2.2, 5000, 0, // Damage
0.7, 1.5, 3000, 0 ); // Accuracy
InitOneWeapon( WEAPON_SHOTGUN, “Shotgun�, 57,
50, 2.1, 100, 0, // Damage
0.95, 2.2, 15000, 0 ); // Accuracy
InitOneWeapon( WEAPON_MACHINEGUN, “M/G�, 300,
30, 2.0, 5000, 0, // Damage
0.8, 1.8, 50000, 0 ); // Accuracy
InitOneWeapon( WEAPON_ROCKETS, “R/L�, 300,
100, 2.0, 1500, 50, // Damage
0.5, 2.0, 30000, 50 ); // Accuracy
}
In each call to
InitOneWeapon()
, we are passing in the numbers from the char-
acteristics table that we laid out earlier. Once we have defined the weapon parame-
ters, the damage and accuracy functions have all the information that they need to
do their magic. If we want to change the characteristics of one weapon, we simply
change the initialization parameters that we pass in when we create the
CWeapon
object. The formula does the rest. (In a production environment, we would store
these values in a configuration file so that we can tweak them without touching
the code.)