Conner94 Moderator

Joined: 15 Jan 2005 Posts: 249 Location: ???
|
Posted: Sun Aug 14, 2005 11:51 am Post subject: [Code] Adding A New Weapon |
|
|
There are several tutorials out there, but not all work and some are confusing. This tutorail will be good and clean.
First off, open up WL_Def.c
Now, search for "SPR_CHAIN". You should see this:
| Code: |
//
// player attack frames
//
SPR_KNIFEREADY,SPR_KNIFEATK1,SPR_KNIFEATK2,
SPR_KNIFEATK3,SPR_KNIFEATK4,
SPR_PISTOLREADY,SPR_PISTOLATK1,SPR_PISTOLATK2,
SPR_PISTOLATK3,SPR_PISTOLATK4,
SPR_MACHINEGUNREADY,SPR_MACHINEGUNATK1,
SPR_MACHINEGUNATK2,MACHINEGUNATK3,SPR_MACHINEGUNATK4,
SPR_CHAINREADY,SPR_CHAINATK1,SPR_CHAINATK2,
SPR_CHAINATK3,SPR_CHAINATK4,
|
Add this after SPR_CHAINATK4, (Or the last sprite you added):
| Code: |
SPR_NEWREADY,SPR_NEWATK1,SPR_NEWATK2,
SPR_NEWATK3,SPR_NEWATK4,
|
Those are are sprites. For more frames, add extra NEWATK* sprites, though I would advise looking into my tutorial about that first.
Now, scroll down until you find this:
| Code: |
#define NUMWEAPONS 5
typedef enum {
wp_knife,
wp_pistol,
wp_machinegun,
wp_chaingun
} weapontype; |
Notice how NUMWeapons is already 5. So, all we have to do is change it to this:
| Code: |
#define NUMWEAPONS 5
typedef enum {
wp_knife,
wp_pistol,
wp_machinegun,
wp_chaingun,
wp_newgun
} weapontype; |
Now it knows that there is a wp_newgun. That is all in this file, you can close it now.
Now, open WL_DRAW. Search for this:
| Code: |
int weaponscale[NUMWEAPONS] = {SPR_KNIFEREADY,SPR_PISTOLREADY
,SPR_MACHINEGUNREADY,SPR_CHAINREADY};
|
Now, change it to this:
| Code: |
int weaponscale[NUMWEAPONS] = {SPR_KNIFEREADY,SPR_PISTOLREADY
,SPR_MACHINEGUNREADY,SPR_CHAINREADY
,SPR_NEWREADY};
|
Now it knows where to start the new weapon's sprites. Spr_Newready is its ready to fire frame. That is all in this file, now open WL_Agent.c and look for this:
| Code: |
} attackinfo[4][14] =
{
{ {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} },
}; |
Now, change it to this:
| Code: |
} attackinfo[5][14] =
{
{ {6,0,1},{6,2,2},{6,0,3},{6,-1,4} }, // knife
{ {6,0,1},{6,1,2},{6,0,3},{6,-1,4} }, // pistol
{ {6,0,1},{6,1,2},{6,3,3},{6,-1,4} }, // machinegun
{ {6,0,1},{6,1,2},{6,4,3},{6,-1,4} }, // chaingun
{ {6,0,1},{6,1,2},{6,0,3},{6,-1,4} }, // new weapon
}; |
The 5 could probally also be changed to NUMWEAPONS. Now, to select your weapon, go down to the check weapon change. Now, I am not going to write another one of these, so I recomend BT's. You can find it here: http://diehardwolfers.areyep.com/viewtopic.php?t=93
Hope this helps someone.
Temp Warning! I haven't worked much with this, it may not work yet. I also need to add some extra things. _________________ My Wolfenstein Website:
http://www.wolf94.cjb.net
Status: Falling apart over a product I ordered that is taking forever to arrive. |
|