News: SMF - Just Installed!
 
Welcome, Guest. Please login or register.
+  AnthraxBio
|-+  Return to Castle Wolfenstein
| |-+  Coding Tutorials
| | |-+  Adding a Second Clip
« previous next »
Pages: [1] Print
Author Topic: Adding a Second Clip  (Read 263 times)
SkreamerVirii
Administrator
Full Member
*****
Posts: 133


View Profile
« on: September 03, 2008, 11:20:07 PM »

Making weapons reloadable by adding a 2nd clip
i will be using the the venom for demonstration purposes
and because it has the best reload animation
and i will be using the engineer for the class


we will be working in g_client.c
Scroll down to line 797 if you have done the adding weapons basic tutorial then you should have code like this
// Engineer gets dynamite
if ( pc == PC_ENGINEER ) {
client->ps.stats[STAT_KEYS] |= ( 1 << INV_BINOCS );
COM_BitSet( client->ps.weapons, WP_DYNAMITE );
client->ps.ammo[BG_FindAmmoForWeapon(WP_DYNAMITE)] = 0;
client->ps.ammoclip[BG_FindClipForWeapon(WP_DYNAMITE)] = 1;
// NERVE - SMF
COM_BitSet( client->ps.weapons, WP_PLIERS);
client->ps.ammoclip[BG_FindClipForWeapon(WP_PLIERS)] = 1;
client->ps.ammo[WP_PLIERS] = 1;
COM_BitSet(client->ps.weapons, WP_AMMO);
client->ps.ammo[BG_FindAmmoForWeapon(WP_AMMO)] = 0;
client->ps.ammoclip[BG_FindClipForWeapon(WP_AMMO)] = 1;
//Venom with 2 clips and a reload animation
COM_BitSet( client->ps.weapons, WP_VENOM );
client->ps.ammoclip[BG_FindClipForWeapon(WP_VENOM)] = 120;
client->ps.ammo[BG_FindAmmoForWeapon(WP_VENOM)] = 120;
client->ps.weapon = WP_VENOM;
if you look at the

//Venom with 2 clips and a reload animation
COM_BitSet( client->ps.weapons, WP_VENOM );
client->ps.ammoclip[BG_FindClipForWeapon(WP_VENOM)] = 120;
client->ps.ammo[BG_FindAmmoForWeapon(WP_VENOM)] = 120;
client->ps.weapon = WP_VENOM;
you will see this
client->ps.ammoclip[BG_FindClipForWeapon(WP_VENOM)] = 120;
this allows the player to carry an extra clip to reload with
if you take this code code away from the weapon block
then you will have only one clip
because if you look at the flamethrower code
COM_BitSet( client->ps.weapons, WP_FLAMETHROWER );
client->ps.ammoclip[BG_FindAmmoForWeapon(WP_FLAMETHROWER)] = 100;
client->ps.weapon = WP_FLAMETHROWER;

so i added
client->ps.ammoclip[BG_FindClipForWeapon(WP_VENOM)] = 120;
to this
COM_BitSet( client->ps.weapons, WP_FLAMETHROWER );
client->ps.ammoclip[BG_FindAmmoForWeapon(WP_FLAMETHROWER)] = 100;
client->ps.weapon = WP_FLAMETHROWER;

to get this
COM_BitSet( client->ps.weapons, WP_FLAMETHROWER );
client->ps.ammoclip[BG_FindAmmoForWeapon(WP_FLAMETHROWER)] = 100;
client->ps.ammoclip[BG_FindClipForWeapon(WP_VENOM)] = 120;
client->ps.weapon = WP_FLAMETHROWER;
but didnt really like it so i added a second clip to the venom instead and to my surprise it had a kick butt reload animation
well compile that and see what you think
like always you can email post in the forums and and ask me for help if you need it

 
« Last Edit: September 03, 2008, 11:23:21 PM by SkreamerVirii » Logged
Pages: [1] Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.6 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Free SMF 1.1.5 Forum Theme by Tamuril. © 2008.