Adding a New Weapon:
Steps - 19
Sections - 4
Files to edit - wl_def.h / wl_draw.c / wl_agent.c / wl_act1.c / wl_game.c / vswap.* / vga*.*
Hello all, here's a nice tutorial for you to add a new weapon! Please post all comments in this topic!
All code in this tutorial was taken from Projekt Vertilgung Phase I; and if you have anyproblems, please post here!
Remember, all text in red should be added to the shown code, and all text in green should be deleted!
Adding the weapon:
Step 1.
Open up your favourite Wolfenstein TC editor, and go to the graphics section where you can add sprites.
Add 5 sprites at the end of the file (after the chaingun images).
These will be the images shown when using the new gun.
Step 2.
Open wl_def.h
Search for "SPR_CHAINATK4"
Quote:
SPR_CHAINREADY,SPR_CHAINATK1,SPR_CHAINATK2,SPR_CHAINATK3,
SPR_CHAINATK4,
SPR_STENREADY,SPR_STENATK1,SPR_STENATK2,SPR_STENATK3,
SPR_STENATK4,
Step 3.
Search for "wp_chaingun"
Quote:
NUMWEAPONS 5
...
wp_knife,
wp_pistol,
wp_machinegun,
wp_chaingun, //<--make sure you add the comma!
wp_stengun //<-- no comma!
} weapontype;
Step 4.
Open wl_draw.c
Search for "SPR_CHAINREADY"
Quote:
SPR_MACHINEGUNREADY,SPR_CHAINREADY,SPR_STENREADY};
Step 5.
Open wl_agent.c
Search for "attackinfo"
Quote:
{ {6,0,1},{6,2,2},{6,0,3}{6,-1,4} },
{ {6,0,1},{6,1,2},{6,0,3}{6,-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} },
{ {6,0,1},{6,1,2},{6,3,3}{6,-1,4} }, //Stengun
};
Step 6.
Search for "wp_chaingun"
Quote:
case wp_chaingun:
SD_PlaySound (ATKGATLINGSND);
break;
case wp_stengun:
//SD_PlaySound(WELLCOMEHERELATERSND);
break;
}
Ok, so now we've added the weapon. You will need an item to pick up for this new weapon...!
Adding the weapon item
Step 7.
Open up your favourite Wolfenstein TC editor, and go to the graphics section where you can add sprites.
Add 1 sprite at the end of the file (after the stengun images you added before).
This will be the image shown as the item before you pick it up!
Step 8.
Open up wl_def.h
Search for "SPR_STENATK"
Quote:
SPR_CHAINREADY,SPR_CHAINATK1,SPR_CHAINATK2,SPR_CHAINATK3,
SPR_CHAINATK4,
SPR_STENREADY,SPR_STENATK1,SPR_STENATK2,SPR_STENATK3,
SPR_STENATK4,
SPR_STENGUN,
Step 9.
Search for "bo_spear"
Quote:
bo_fullheal,
bo_25clip,
bo_stengun,
bo_spear
Step 10.
Open up wl_agent.c
Search for "bo_chaingun:"
Quote:
case bo_chaingun:
....
break;
case bo_stengun:
GiveWeapon (wp_stengun);
//SD_PlaySound(WELLCOMEHERELATERSND);
break;
Step 11.
Open wl_act1.c
Search for "bo_spear:"
Quote:
bo_spear:
bo_stengun:
laststatobj->flags = FL_BONUS;
Step 12.
Go to the top of the file wl_act1.c
Search for "bo_clip2"
Quote:
{SPR_STAT_26,bo_clip2}, // Clip "
{SPR_STENGUN,bo_stengun}, // Stengun "
{-1} // terminator
};
Step 13.
Open wl_game.c
Search for "case 72"
If your using the WOLFENSTEIN code:
Quote:
case 71:
case 72: //Stengun
case 73:
case 74:
case 75:
If your using the SPEAR code:
Quote:
case 71:
case 72:
case 73:
case 74:
case 75:
[color=red]case 76: //Stengun
(In spear, case 72-75 are taken, but in Wolfenstein they aren't defined!)
Now using your favourite wolfenstein editor set a new item called Stengun to id 75. (There will be a tutorial on this soon)
Now we've added the item we need to set the button to change to that weapon! There are many ways of re-writing the 'CheckWeaponChange' function, but if your just adding weapons without complex stuff like sepearate ammo types, this is perfect!
CheckWeaponChange
Step 14.
Open up wl_def.h
Search for "bt_readychaingun"
Quote:
NUMBUTTONS 9
...
bt_readymachinegun,
bt_readychaingun, //<--make sure you add the comma!
bt_readystengun //<-- no comma!
);
That's it for the CheckWeaponChange!
DrawWeapon
Step 15.
Open up your favourite Wolfenstein TC editor, and go to the VGA graphics section where you can add images.
Add 1 image at the end of the file (after the getpsyched image!).
This will be the image shown as the item on the status bar when you've got the gun!
Step 16.
Open up GFXV_WL6 (or GFXV_SOD if using the spear code)
Search for "GETPSYCHEDPIC"
Quote:
GETPSYCHEDPIC, //149
STENGUNPIC, //150
ORDERSCREEN=152,
ERRORSCREEN, //152
Step 17.
Search for "LATCHPICS_LUMP_END"
Quote:
#define LATCHPICS_LUMP_END 150 //Add one for each new image
Step 18.
Search for "NUMPICS"
Quote:
#define NUMPICS 148 //Add one for each new image
Step 19.
Open wl_agent.c
Search for "DrawWeapon"
Quote:
void DrawWeapon (void)
{
if(gamestate.chosenweapon == wp_stengun)
{
StatusDrawPic (32,8,STENGUNPIC);
}
else
{
StatusDrawPic (32,8,KNIFEPIC+gamestate.weapon);
}
}
Adding Sounds Coming later to the tutorial...