Go Back   3D Realms Forums > 3D Realms Topics > Duke Nukem > Duke Nukem 3D Source Code
Welcome, Hendricks266.
You last visited: Today at 03:32 PM
Private Messages: Unread 0, Total 15.
User CP FAQ Members List Calendar New Posts Quick Links Log Out

Reply
Thread Tools Search this Thread
Old 07-04-2006, 06:26 AM   #1
Chip

Chip's Avatar
EDuke32 making a second weapon to an existing number key
I asked this question years ago....OK, maybe a year ago
It never got properly sorted out and I havn't been modding for quite a while and when I do I shortly stop again.

Basically I'm trying to make a second weapon available to an existing number key so when I press "3" on the Keyboard I get shotgun, but if I press it again I get my new second weapon for that number (Just like how Shrinker and expander works)

I was told that to do this I also need to re-make the existing weapon for that number so in this case I need to re-make the shotgun.

So far this is what I got done:
My second weapon for the number is called "SHOTGUN2"


Code:
state DISPLAYSHOTGUN2 setvar x 180 setvar y 240 addvarvar x weapon_xoffset ifvare weaponcount 3 { subvar x 3 } subvarvar x looking_angSR1 addvarvar y looking_arc subvarvar y gun_pos getsector[THISACTOR].floorshade SHADE getsector[THISACTOR].floorpal PAL setvar MASK 0 switch WEAPON_COUNT case 0: setvar SHOTGUN2 2620 break case 5: setvar SHOTGUN2 2621 break case 8: setvar SHOTGUN2 2622 break case 12: setvar SHOTGUN2 2623 break case 16: setvar SHOTGUN2 2624 break case 20: setvar SHOTGUN2 2625 break case 24: setvar SHOTGUN2 2626 break case 28: setvar SHOTGUN2 2627 break case 32: setvar SHOTGUN2 2628 break case 36: setvar SHOTGUN2 2629 break case 40: setvar SHOTGUN2 2630 break endswitch myospal x y SHOTGUN2 SHADE MASK PAL ends state DISPLAYSHOTGUN setvar x 160 setvar y 200 addvarvar x weapon_xoffset ifvare weaponcount 3 { subvar x 3 } subvarvar x looking_angSR1 addvarvar y looking_arc subvarvar y gun_pos getsector[THISACTOR].floorshade SHADE getsector[THISACTOR].floorpal PAL setvar MASK 0 switch WEAPON_COUNT case 0: setvar SHOTGUN 2613 break case 3: setvar SHOTGUN 2614 break case 6: setvar SHOTGUN 2615 break case 9: setvar SHOTGUN 2616 break case 12: setvar SHOTGUN 2617 break case 15: setvar SHOTGUN 2618 break case 18: setvar SHOTGUN 2619 break case 21: setvar SHOTGUN 2618 break case 24: setvar SHOTGUN 2617 break case 27: setvar SHOTGUN 2616 break endswitch myospal x y SHOTGUN SHADE MASK PAL ends onevent EVENT_DRAWWEAPON ifvare CURRENT_WEAPON 8 { setvar RETURN -1 state DISPLAYSHOCKCANNON } else ifvare CURRENT_WEAPON 2 ifvare WEAPONMODE 0 { setvar RETURN -1 state DISPLAYSHOTGUN } else ifvare CURRENT_WEAPON 2 ifvare WEAPONMODE 1 state DISPLAYSHOTGUN2 endevent


and then in the player code I had this done:

Code:
getplayer[THISACTOR].last_weapon TEMP ifvarg TEMP -1 setvarvar CURRENT_WEAPON TEMP else getplayer[THISACTOR].curr_weapon CURRENT_WEAPON getplayer[THISACTOR].kickback_pic WEAPON_COUNT ifvare CURRENT_WEAPON 2 { ifvare WEAPONMODE 0 { setvar WEAPON2_CLIP 0 setvar WEAPON2_RELOAD 13 setvar WEAPON2_FIREDELAY 4 setvar WEAPON2_TOTALTIME 31 setvar WEAPON2_HOLDDELAY 0 setvar WEAPON2_FLAGS 1024 setvar WEAPON2_SHOOTS 2613 setvar WEAPON2_SPAWNTIME 24 setvar WEAPON2_SPAWN 2535 setvar WEAPON2_SHOTSPERBURST 7 setvar WEAPON2_INITIALSOUND 0 setvar WEAPON2_FIRESOUND 109 setvar WEAPON2_SOUND2TIME 15 setvar WEAPON2_SOUND2SOUND 169 setvar WEAPON2_RENDERSIZE 0 } ifvare WEAPONMODE 1 { setvar WEAPON2_CLIP 0 setvar WEAPON2_RELOAD 28 setvar WEAPON2_FIREDELAY 4 setvar WEAPON2_TOTALTIME 40 setvar WEAPON2_HOLDDELAY 0 setvar WEAPON2_FLAGS 1024 setvar WEAPON2_SHOOTS 2613 setvar WEAPON2_SPAWNTIME 24 setvar WEAPON2_SPAWN 2535 setvar WEAPON2_SHOTSPERBURST 18 setvar WEAPON2_INITIALSOUND 0 setvar WEAPON2_FIRESOUND 109 setvar WEAPON2_SOUND2TIME 15 setvar WEAPON2_SOUND2SOUND 169 setvar WEAPON2_RENDERSIZE 0 } }


All that did was allow the original shotgun to work (slightly different to the original but I'm not complainging)

I still can't select my second weapon,
What do I need to do next in order for my weapon to be selected, oh and I want it so I can't select my second shotgun till I pick it up. (Like Doom2 with Shotgun and Super shotgun)

Thanks
Chip is offline Report Bad Post   Reply With Quote Quick reply to this message
Old 07-04-2006, 10:35 AM   #2
Mblackwell

Mblackwell's Avatar
Re: EDuke32 making a second weapon to an existing number key
Um, why do you use the weapon's key event and toggle the var, but only if another var is set to 1.
__________________
Visit the Alien TC website.
Listen to the Rejected Applications.
Blong:The place for all your latest gaming industry info. Lively debate abounds.


I don't wanna be like other people are
Don't wanna own a key, don't wanna wash my car
Don't wanna have to work like other people do
I want it to be free, I want it to be true

Eduke32.com
Mblackwell is offline Report Bad Post   Reply With Quote Quick reply to this message
Old 07-04-2006, 10:37 AM   #3
DeeperThought

DeeperThought's Avatar
Re: EDuke32 making a second weapon to an existing number key
Quote:
Originally Posted by Chip

and then in the player code I had this done:

Code:
getplayer[THISACTOR].last_weapon TEMP ifvarg TEMP -1 setvarvar CURRENT_WEAPON TEMP else getplayer[THISACTOR].curr_weapon CURRENT_WEAPON


I don't understand why you are doing that.

Assuming that your state for displaying the new shotgun works correctly, it looks like you have already done most of the hard work. The main thing you need to do next is add code to the appropriate weapon key event which causes the weapon mode variable to toggle. I have to admit I'm a little perplexed as to how you could have written all the code that you currently have without already knowing this. It's as if someone else wrote the code and you're trying to figure out how to integrate it into your mod.
DeeperThought is offline Report Bad Post   Reply With Quote Quick reply to this message
Old 07-04-2006, 10:57 AM   #4
Mblackwell

Mblackwell's Avatar
Re: EDuke32 making a second weapon to an existing number key
That's to keep the code from displaying the weapon before the weapon is actually pulled out.
__________________
Visit the Alien TC website.
Listen to the Rejected Applications.
Blong:The place for all your latest gaming industry info. Lively debate abounds.


I don't wanna be like other people are
Don't wanna own a key, don't wanna wash my car
Don't wanna have to work like other people do
I want it to be free, I want it to be true

Eduke32.com
Mblackwell is offline Report Bad Post   Reply With Quote Quick reply to this message
Old 07-04-2006, 11:05 AM   #5
DeeperThought

DeeperThought's Avatar
Re: EDuke32 making a second weapon to an existing number key
Quote:
Originally Posted by Mblackwell
That's to keep the code from displaying the weapon before the weapon is actually pulled out.

I can sort of see that now. However, the pre-defined gamevar is currentweapon, not CURRENT_WEAPON. As it stands, the code doesn't actually do anything.
DeeperThought is offline Report Bad Post   Reply With Quote Quick reply to this message
Old 07-04-2006, 11:51 AM   #6
Mblackwell

Mblackwell's Avatar
Re: EDuke32 making a second weapon to an existing number key
Yes it does, he's setting his var CURRENT_WEAPON and checking it to find out which weapon to display .
__________________
Visit the Alien TC website.
Listen to the Rejected Applications.
Blong:The place for all your latest gaming industry info. Lively debate abounds.


I don't wanna be like other people are
Don't wanna own a key, don't wanna wash my car
Don't wanna have to work like other people do
I want it to be free, I want it to be true

Eduke32.com
Mblackwell is offline Report Bad Post   Reply With Quote Quick reply to this message
Old 07-04-2006, 11:58 AM   #7
DeeperThought

DeeperThought's Avatar
Re: EDuke32 making a second weapon to an existing number key
... I'm not much good when it comes to looking at other people's code.

I've been a bit of an ass, so here's some code that might be useful:


Code:
state normalshotgun setvar WEAPONMODE 0 setvar WEAPON2_CLIP 0 setvar WEAPON2_RELOAD 13 setvar WEAPON2_FIREDELAY 4 setvar WEAPON2_TOTALTIME 31 setvar WEAPON2_HOLDDELAY 0 setvar WEAPON2_FLAGS 1024 setvar WEAPON2_SHOOTS 2613 setvar WEAPON2_SPAWNTIME 24 setvar WEAPON2_SPAWN 2535 setvar WEAPON2_SHOTSPERBURST 7 setvar WEAPON2_INITIALSOUND 0 setvar WEAPON2_FIRESOUND 109 setvar WEAPON2_SOUND2TIME 15 setvar WEAPON2_SOUND2SOUND 169 setvar WEAPON2_RENDERSIZE 0 ends state supershotgun setvar WEAPONMODE 1 setvar WEAPON2_CLIP 0 setvar WEAPON2_RELOAD 28 setvar WEAPON2_FIREDELAY 4 setvar WEAPON2_TOTALTIME 40 setvar WEAPON2_HOLDDELAY 0 setvar WEAPON2_FLAGS 1024 setvar WEAPON2_SHOOTS 2613 setvar WEAPON2_SPAWNTIME 24 setvar WEAPON2_SPAWN 2535 setvar WEAPON2_SHOTSPERBURST 18 setvar WEAPON2_INITIALSOUND 0 setvar WEAPON2_FIRESOUND 109 setvar WEAPON2_SOUND2TIME 15 setvar WEAPON2_SOUND2SOUND 169 setvar WEAPON2_RENDERSIZE 0 ends onevent EVENT_WEAPKEY3 getplayer[THISACTOR].curr_weapon CURRENT_WEAPON ifvare CURRENT_WEAPON 2 { ifvare WEAPONMODE 1 state normalshotgun else { ifvare gotsupershotgun 1 // this per-player var is set when supershotgun acquired state supershotgun } } endevent

The states get called when the weapon mode is switched, so you don't have to set the weapon vars in the player code.

Last edited by DeeperThought : 07-04-2006 at 12:17 PM.
DeeperThought is offline Report Bad Post   Reply With Quote Quick reply to this message
Old Yesterday, 08:05 AM   #8
Chip

Chip's Avatar
Re: EDuke32 making a second weapon to an existing number key
How I got my code in the first place was from past help (over a years worth of gathering)

Later on I'll try out your code for the states then,

Oh and how can I make it so I can't select my second weapon till I pick it up from a weapon sprite? So NOT like how shrinker and expander works but more of how Doom2 worked with the 2 shotguns, You couldn't select the Super shotgun till you actually picked it up.
Chip is offline Report Bad Post   Reply With Quote Quick reply to this message
Old Yesterday, 11:20 AM   #9
DeeperThought

DeeperThought's Avatar
Re: EDuke32 making a second weapon to an existing number key
Quote:
Originally Posted by Chip
How I got my code in the first place was from past help (over a years worth of gathering)

Yes that explains a lot.


Quote:
Originally Posted by Chip
Later on I'll try out your code for the states then,

Oh and how can I make it so I can't select my second weapon till I pick it up from a weapon sprite? So NOT like how shrinker and expander works but more of how Doom2 worked with the 2 shotguns, You couldn't select the Super shotgun till you actually picked it up.

Did you notice that the code I gave you already checks whether the gotsupershotgun var is set?
DeeperThought is offline Report Bad Post   Reply With Quote Quick reply to this message
Old Today, 09:57 AM   #10
Chip

Chip's Avatar
Re: EDuke32 making a second weapon to an existing number key
I havn't done anything yet with your code, I'll be doing that right now.
I'll post back after doing so.
Chip is offline Report Bad Post   Reply With Quote Quick reply to this message
Unread Today, 04:56 PM   #11
Chip

Chip's Avatar
Re: EDuke32 making a second weapon to an existing number key
Finally after 2 years of time wasting I finally have a second weapon opperating on the same number key as another weapon.

Thanks you.



Just 3 qustions though:

1. When I try selecting the second shotgun it just instantly appears, how can I make it so the previous shotgun lowers away then the next shotgun rises up - just like with every other weapon in Duke history?

2. At the moment I can only have the second shotgun if I allready have the existing shotgun. Can it be made so If I obtain the second shotgun before the first shotgun then I have the second shotgun only?

In case thats not too clear here it is again:
I would like this to happen:
I pick up shotgun 1 sprite - I get shotgun 1
I pick up shotgun 2 sprite - I get shotgun 2

At the moment it's like this:
I pick up shotgun 1 sprite - I get shotgun 1
I pick up shotgun 2 sprite - I get shotgun 2 but can only select it if I have shotgun 1 as well.

3. This weapon opperate on a gamevar, I havn't tried this out yet but if I was to obtain shotgun2 then complete the level - would I still have shotgun2 or would the gamevar re-set meaning I loose the shotgun2?

There are some other questions as well but I can solve them myself such as auto selecting the shotgun 2 weapon when first picks it up and number of ammo it uses.
Chip is offline Report Bad Post   Reply With Quote Quick reply to this message
Unread Today, 05:16 PM   #12
Manson
Re: EDuke32 making a second weapon to an existing number key
Quote:
Originally Posted by DeeperThought
I can sort of see that now. However, the pre-defined gamevar is currentweapon, not CURRENT_WEAPON. As it stands, the code doesn't actually do anything.

Well, Matt hated me for that one variable, trying to keep the vars at as low a count as possible - it goes back to early 2001 if I'm not mistaking.

Regarding weaponshifting, I did some coding for a similar project, by simply having the weaponscounter (I can't recall the right var -just count maybe? maybe even framecount?) count up till the max of frames on the current gun, before changing to the next gun, a change made by setting the currentweapon to the desired next weapon, and setting the framecounter of the gun to the initial first frame of the next weapon.

This initial value might obviously very well be 0, but sometimes you could have hardcoded stuff happening there, which is good to keep in mind that it is you who decide the boundaries.

This is all like 5 years ago, so please do excuse any deviation from the straight route I might have commited - also I havn't keept myself updated, TX might just have done some lazycommandno54547 command to fastpass through the actual coding

BTW, some of the vars were hardcoded back then, and had to be either controlled or disabled - that still may remain, this unfortunatly will kill MP without prober considerations.
__________________
The NightStrike... >>
www.nightstrike.tk a working EDuke 2.1 mulitiplayer MOD - finaly

Last edited by Manson : Today at 05:22 PM.
Manson is offline Report Bad Post   Reply With Quote Quick reply to this message
Unread Today, 05:21 PM   #13
DeeperThought

DeeperThought's Avatar
Re: EDuke32 making a second weapon to an existing number key
1. I've never actually done this myself, but I think you need to use rotatesprite in a sequence that makes the current shotgun gradually move down, then put the other one on the screen and move it up, and keep the player from firing during this time.

2. The game will not let you switch to weapon 2 unless you have weapon 2. So unless the supershotgun sprite gives the player weapon 2, there is no way you can use the supershotgun if you don't already have the shotgun. Therefore, the solution is to have the supershotgun sprite give the player weapon 2, but don't let them switch to the regular shotgun unless the have picked up the regular shotgun. You can do this by having the switching state check another gamevar that is set only when the regular shotgun is picked up. I'm not going to write the code for this, but it is fairly simple and should be good practice for you.

3. User gamevars do not reset when you complete a level.
DeeperThought is offline Report Bad Post   Reply With Quote Quick reply to this message
Unread Today, 05:42 PM   #14
Manson
Re: EDuke32 making a second weapon to an existing number key
The animations on the screen is less a problem

Trouble is, that your weapon changing must becoded somewhere - as in, you need to control that time is beeing counted etc. and in some cases keep those counters in sync.

Otherwise your code will happily change the weapon instantly when you press the button.

I kinda think there were some work on a variable for weaponshifting time at some point, during Saettlers time - but it might have been in a beta.
__________________
The NightStrike... >>
www.nightstrike.tk a working EDuke 2.1 mulitiplayer MOD - finaly

Last edited by Manson : Today at 05:48 PM.
Manson is offline Report Bad Post   Reply With Quote Quick reply to this message
Reply


Quick Reply
Message:
Remove Text Formatting
Bold
Italic
Underline

Insert Image
Wrap [QUOTE] tags around selected text
 
Decrease Size
Increase Size
Options


Posting Rules
You may post new threads
You may post replies
You may post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 08:46 PM.


Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2006, Jelsoft Enterprises Ltd.

Website is ©1987-2006 Apogee Software, Ltd.
Ideas and messages posted here become property of Apogee Software Ltd.
image
image
image
image
image image image