Make your own free website on Tripod.com
Add A New Ammo Type

Before starting for an example I used extraammo.
 
Open up Wl_def.h and goto around line 141.
You should see this: #define STARTAMMO         8
Below that add this:
#define STARTEXTRAAMMO         8
 
 Now search for this: gamestate structure.
 
Once there under int ammo add this:
int   extraammo;
 
Then scroll down to till you see this: Wl_agent.c Defenitions.
 
When there look for this: void GiveAmmo (int ammo);
 
Add this below that:
void DrawExtraAmmo (void); 
void GiveExtraAmmo (int extraammo);
 
Now open up Wl_agent.c
 
Look for this:
 
void DrawWeapon (void);
void GiveWeapon (int weapon);
void GiveAmmo (int ammo);
It is around line 80 to 90.
 
Below that add this:
void GiveExtraAmmo (int extraammo); 
 
Now scroll down till you see this:
void DrawAmmo (void)
{
 LatchNumber (27,16,2,gamestate.ammo);
}
Below that add this:
void DrawExtraAmmo (void)
{
 LatchNumber (27,16,3,gamestate.extraammo);
}
Also above change the 2 to a 3 on the first ammo type otherwise there will be a glitch.
 
Now keep scrolling down till you see this:
void GiveAmmo (int ammo)
{
 if (!gamestate.ammo)    // knife was out
 {
  if (!gamestate.attackframe)
  {
   gamestate.weapon = gamestate.chosenweapon;
   DrawWeapon ();
  }
 }
 gamestate.ammo += ammo;
 if (gamestate.ammo > 99)
  gamestate.ammo = 99;
  if (gamestate.chosenweapon <=wp_chaingun)
 DrawAmmo ();
}
Below that add this:
void GiveExtraAmmo (int extraammo)
{
 if (!gamestate.extraammo)    // knife was out
 {
  if (!gamestate.attackframe)
  {
   gamestate.weapon = gamestate.chosenweapon;
   DrawWeapon ();
  }
 }
 gamestate.extraammo += extraammo;
 if (gamestate.extraammo > 150)
  gamestate.extraammo = 150;
 if (gamestate.chosenweapon <=wp_new1)
 DrawExtraAmmo ();
}
Also if didn't notice this:  if (gamestate.chosenweapon <=wp_new1)
This is just an example wp_new1.  You can use the machine gun or which ever weapon you want. 
 
Now Search for this: change frame and fire.
 
Now under case-1 modify the whole thing to this:
ob->state = &s_player;
   if (!gamestate.ammo && gamestate.weapon < wp_new1
   || !gamestate.extraammo && gamestate.weapon >= wp_new1)
   {
    gamestate.weapon = wp_knife;
    gamestate.chosenweapon = wp_knife;
    DrawWeapon ();
   }
   else
   {
    if (gamestate.weapon != gamestate.chosenweapon)
    {
     gamestate.weapon = gamestate.chosenweapon;
     DrawWeapon ();
    }
   };
   gamestate.attackframe = gamestate.weaponframe = 0;
   return;

Not far below it is case1:
 
Modify the whole thing to this:
if (!gamestate.ammo && gamestate.weapon <= wp_chaingun
   || !gamestate.extraammo && gamestate.weapon == wp_new1)
     {
   gamestate.attackframe++;
   break;
   }
   GunAttack (ob);
   if (gamestate.chosenweapon <= wp_chaingun)
   {
   gamestate.ammo--;
   DrawAmmo();
   }
   if (gamestate.chosenweapon == wp_new1)
   {
   gamestate.extraammo--;
   DrawExtraAmmo();
   break;
 
Now open up Wl_main.c
 
Search for this: gamestate.ammo = STARTAMMO;
Add this below that: gamestate.extraammo = STARTEXTRAAMMO;
 
Well thats it for this tutorial big enough for ya?