Navigation

 Two Bullets Per Shot Feature Type: Coding Tutorials     Added: 05/01  
  Author: Corven 

How to have your machinegun fire two bullets when you click your mouse once. Basically it adds an extra fire command to when you fire a weapon, here we will be modifying the machinegun, but you could use the same principle to any weapon.

Hit Me Twice

Code to be Added or Changed

g_weapon.c

This can all be done in g_weapon.c, located in the game folder of your source. Open up the file and you should see this:

/*
===================
MACHINEGUN
===================
*/

Near the bottom of this call you should see:

if ( traceEnt->takedamage) {
G_Damage( traceEnt, ent, ent, forward, tr.endpos,
damage, 0, MOD_MACHINEGUN);
}
}

Now add another part to it underneath like this:

if ( traceEnt->takedamage) {
G_Damage( traceEnt, ent, ent, forward, tr.endpos,
damage, 0, MOD_MACHINEGUN);
G_Damage( traceEnt, ent, ent, forward, tr.endpos,
damage, 0, MOD_MACHINEGUN);

}
}

What this does is it makes the second bullet we are creating per shot actually hurt the target. Next we will add the bit which actually draws the second bullet. Scroll down till you see this: (it’s near the bottom)

/*
===============
FireWeapon
===============
*/

Then in this function find this:


case WP_MACHINEGUN:
if ( g_gametype.integer != GT_TEAM ) {
Bullet_Fire( ent, MACHINEGUN_SPREAD, MACHINEGUN_DAMAGE );
} else {
Bullet_Fire( ent, MACHINEGUN_SPREAD, MACHINEGUN_TEAM_DAMAGE );
}
break;

And replace it with this:

case WP_MACHINEGUN:
if ( g_gametype.integer != GT_TEAM ) {
Bullet_Fire( ent, MACHINEGUN_SPREAD, MACHINEGUN_DAMAGE );
Bullet_Fire( ent, MACHINEGUN_SPREAD, MACHINEGUN_DAMAGE );
} else {
Bullet_Fire( ent, MACHINEGUN_SPREAD, MACHINEGUN_TEAM_DAMAGE );
Bullet_Fire( ent, MACHINEGUN_SPREAD, MACHINEGUN_TEAM_DAMAGE );
}
break;

Tah dah! Compile it and you’re ready to go.

Comments »



  Page 1

  Comments ( 0 )


  Features Index

  Home

Copyright © 2001 MGON International AB - Privacy statement