Wolf Planet Forum Index Wolf Planet
We want you here!
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[Code] Adding A New Weapon

 
Post new topic   Reply to topic    Wolf Planet Forum Index -> Coding Alliance
View previous topic :: View next topic  
Author Message
Conner94
Moderator


Joined: 15 Jan 2005
Posts: 249
Location: ???

PostPosted: Sun Aug 14, 2005 11:51 am    Post subject: [Code] Adding A New Weapon Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
Deathshead
Corporal


Joined: 18 Feb 2005
Posts: 87

PostPosted: Sun Oct 16, 2005 8:05 am    Post subject: Reply with quote

Very Incomplete. You missed the WL_DRAW.C changes, the DrawWeapon stuff, and pickup stuff. By the way, you need to explain that NUMWEAPONS needs to be changed for each new weapon. Also, the code gets much easier if you change:

Code:

} attackinfo[4][14] =


To read:

Code:

} attackinfo[NUMWEAPONS][14] =


Since the attackinfo is always the same as the number of weapons, it makes it much easier to do it like this.[/code]
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Conner94
Moderator


Joined: 15 Jan 2005
Posts: 249
Location: ???

PostPosted: Thu Oct 27, 2005 2:52 am    Post subject: Reply with quote

Hmm...I wrote this awhile back. I think I said I needed to add things, so, ya. I just never got around to finishing.
_________________
My Wolfenstein Website:
http://www.wolf94.cjb.net

Status: Falling apart over a product I ordered that is taking forever to arrive.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Wolf Planet Forum Index -> Coding Alliance All times are GMT
Page 1 of 1

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001 phpBB Group

Chronicles phpBB2 theme by Jakob Persson (http://www.eddingschronicles.com). Stone textures by Patty Herford.