





|
|
Welcome, Hendricks266.
You last visited: Today at 03:32 PM
Private Messages: Unread 0, Total 15.
|
07-04-2006, 06:26 AM
|
#1
|
|
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
|
|
|
07-04-2006, 10:37 AM
|
#3
|
|
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.
|
|
|
07-04-2006, 11:05 AM
|
#5
|
|
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.
|
|
|
07-04-2006, 11:58 AM
|
#7
|
|
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.
|
|
|
Yesterday, 08:05 AM
|
#8
|
|
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.
|
|
|
Yesterday, 11:20 AM
|
#9
|
|
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?
|
|
|
Today, 05:16 PM
|
#12
|
|
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.
|
|
|
Today, 05:42 PM
|
#14
|
|
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.
|
|
|
Posting Rules
|
You may post new threads
You may post replies
You may post attachments
You may edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 08:46 PM.
|
|

 |