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

First open wl_def.h and search for SPR_CHAINREADY you should see something like this:
 
SPR_CHAINREADY,SPR_CHAINATK1,SPR_CHAINATK2,SPR_CHAINATK3,
  SPR_CHAINATK4,
for the sake of the arugment i called it Plasma for a new weapon: below this add:
 
SPR_PLASMAREADY,SPR_PLASMA1ATK1,SPR_PLASMAATK2,SPR_PLASMAATK3,
  SPR_PLASMAATK4,
 
Then scroll down and look for this:
#define NUMWEAPONS 5
typedef enum {
 wp_knife,
 wp_pistol,
 wp_machinegun,
 wp_chaingun
} weapontype;
modify it to this:

#define NUMWEAPONS 6
typedef enum {
 wp_knife,
 wp_pistol,
 wp_machinegun,
 wp_chaingun,
        wp_plasma
} weapontype;
Now open up wl_draw.c and look for this:
int weaponscale[NUMWEAPONS] ={SPR_KNIFEREADY,SPR_PISTOLREADY
 ,SPR_MACHINEGUNREADY,SPR_CHAINREADY};
modify it to this:
int weaponscale[NUMWEAPONS] = {SPR_KNIFEREADY,SPR_PISTOLREADY
 ,SPR_MACHINEGUNREADY,SPR_CHAINREADY,SPR_PLASMAREADY};
Now open up wl_agent.c and look for this
struct atkinf
{
 char tics,attack,frame;  // attack is 1 for gun, 2 for knife
} attackinfo[4][14] =
{
{ {6,0,1},{6,2,2},{6,0,3},{6,-1,4} },
{ {8,0,1},{8,1,2},{8,0,3},{8,-1,4} },
{ {6,0,1},{6,1,2},{6,3,3},{6,-1,4} },
{ {6,0,1},{6,1,2},{6,4,3},{6,-1,4} },
};
modify it to this

{
 char tics,attack,frame;  // attack is 1 for gun, 2 for knife
} attackinfo[5][14] =
{
{ {6,0,1},{6,2,2},{6,0,3},{6,-1,4} },
{ {8,0,1},{8,1,2},{8,0,3},{8,-1,4} },
{ {6,0,1},{6,1,2},{6,3,3},{6,-1,4} },
{ {6,0,1},{6,1,2},{6,4,3},{6,-1,4} },
{ {8,0,1},{8,1,2},{8,0,3},{8,-1,4} },
};
keep scrolling down till u get to this:
void CheckWeaponChange (void)
{
 int i,buttons;
 if (!gamestate.ammo)  // must use knife with no ammo
  return;
 for (i=wp_knife ; i<=gamestate.bestweapon ; i++)
  if (buttonstate[bt_readyknife+i-wp_knife])
  {
   gamestate.weapon = gamestate.chosenweapon = i;
   DrawWeapon ();
   return;
  }
}              
remove this entire code it is pointless... add this
void CheckWeaponChange (void)
{
 int i,buttons;
 switch (LastScan)
  {
  case 2:
   LastScan=0;
   if (gamestate.bestweapon >= wp_knife)
   gamestate.weapon = gamestate.chosenweapon = wp_knife;
   break;
  case 3:
   LastScan=0;
   if (gamestate.bestweapon >= wp_pistol)
   {
   gamestate.weapon = gamestate.chosenweapon = wp_pistol;
   DrawAmmo ();
   }
   break;
  case 4:
   LastScan=0;
   if (gamestate.bestweapon >= wp_machinegun)
   {
   gamestate.weapon = gamestate.chosenweapon = wp_machinegun;
   DrawAmmo ();
   }
   break;
  case 5:
   LastScan=0;
   if (gamestate.bestweapon >= wp_chaingun)
   {
   gamestate.weapon = gamestate.chosenweapon = wp_chaingun;
   DrawAmmo ();
   }
   break;
  case 6:
   LastScan=0;
   if (gamestate.bestweapon >= wp_plasma)
   {
   gamestate.weapon = gamestate.chosenweapon = wp_plasma;
   DrawAmmo ();
   }
   break;
  }
DrawWeapon();
    }
Now that we have a new weapon it would be good if we could pick it up.  So open wl_def.h again
 
Search for bo_spear you should see this:
bo_spear
add this
bo_spear,
bo_plasmagun
 
Now open up wl_act1.c
Scroll down till you see this:
{SPR_STAT_0}   // puddle/water
 
Modify it to this:
{SPR_STAT_0,bo_plasmagun}  //new weapon   
 
Keeping scrolling down till you get to this bo_spear again.
You should see this:
  case bo_spear:
add this below:
case bo_spear:
case bo_plasmagun:
 
Now in wl_agent.c search for bo_spear you should see this:
 
case bo_spear:
  spearflag = true;
  spearx = player->x;
  speary = player->y;
  spearangle = player->angle;
  playstate = ex_completed;
 
 Below that add this:
 case bo_plasmagun:
  SD_PlaySound (GETMACHINESND);
  GiveWeapon (wp_plasmagun);
  break;
 
Thats all pretty big huh *lol*