Welcome back! Today im going to show you how to start with every weapon! Nice aren't I?
This will be short and sweet, and straight to the point. More firepower!
OK lets load up g_client.c and head to line number 1179...
You should see this :
client->ps.stats[STAT_WEAPONS] = ( 1 << WP_MACHINEGUN );
See it? Good, lets add this below it:
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_SHOTGUN );
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_GRENADE_LAUNCHER );
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_ROCKET_LAUNCHER );
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_LIGHTNING );
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_RAILGUN );
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_PLASMAGUN );
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_BFG );
What We Did
We have made sure that each weapon is in our inventory, and that they arent seleted by default.
If you wanted for example, the rocket launcher as default weapon, just
remove the | infront of the = for the rocket launcher, and add a | to the machinegun. Like so..
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_MACHINEGUN );
client->ps.stats[STAT_WEAPONS] = ( 1 << WP_ROCKET_LAUNCHER )
Now we need to make sure we have ammo for the weapons! What good are weapons with no ammo?
Directly below what we just added should be :
if ( g_gametype.integer == GT_TEAM ) {
client->ps.ammo[WP_MACHINEGUN] = 50;
} else {
client->ps.ammo[WP_MACHINEGUN] = 100;
}
Paste this new code below it:
client->ps.ammo[WP_SHOTGUN] = 50;
client->ps.ammo[WP_GRENADE_LAUNCHER] = 25;
client->ps.ammo[WP_ROCKET_LAUNCHER] = 25;
client->ps.ammo[WP_LIGHTNING] = 100;
client->ps.ammo[WP_RAILGUN] = 50;
client->ps.ammo[WP_PLASMAGUN] = 100;
client->ps.ammo[WP_BFG] = 10;
What We Did
We made sure that the player ( client ) has a specified amount of ammo ( ps.ammo ) for each weapon.
Feel free to change the values here, I just used these values as an example.
Stay tuned, next tutorial we will be adding a nice new HUD element so we can see all our ammo, all the time. And i will also be introducing you to cvar's ( console variables ).
Happy fragging!
