Hendricks266, on 17 October 2017 - 12:15 PM, said:
Yeah, currentweapon was a mistake, it should only be used in HUD drawing events.
You're going to need to get comfortable with global scratch variables. While you're at it, take the time to indent your code correctly. (8 spaces per tab stop is unnecessary, use 4 at the max.)
definegamefuncname 36 Switch_Weapon_Function
gamevar temp 0 0
gamevar subweapon_choice 0 1
onevent EVENT_TURNAROUND
setvar RETURN -1
getplayer[THISACTOR].curr_weapon temp
ifvare temp 2
{
ifvare subweapon_choice 0
{
ifvarl SHOTGUNAMMO 10
{
quote 36
break
}
setvar subweapon_choice 1
sound SELECT_WEAPON
setvar WEAPON2_SHOOTS 1092
setvar WEAPON2_SHOTSPERBURST 10
setvar WEAPON2_FIRESOUND PISTOL_RICOCHET
setvar WEAPON2_FLAGS 17472
quote 34
}
else
{
setvar subweapon_choice 0
sound SHOTGUN_COCK
setvar WEAPON2_SHOOTS SHOTGUN
setvar WEAPON2_SHOTSPERBURST 7
setvar WEAPON2_FIRESOUND SHOTGUN_FIRE
setvar WEAPON2_FLAGS 1024
quote 35
}
}
endevent
onevent EVENT_DOFIRE
getplayer[THISACTOR].curr_weapon temp
ifvare temp 2
{
ifvare subweapon_choice 1
{
getplayer[THISACTOR].ammo_amount SHOTGUN_WEAPON temp
ifvarl temp 10
{
setvar subweapon_choice 0
sound SHOTGUN_COCK
setvar WEAPON2_SHOOTS SHOTGUN
setvar WEAPON2_SHOTSPERBURST 7
setvar WEAPON2_FIRESOUND SHOTGUN_FIRE
setvar WEAPON2_FLAGS 1024
quote 40
}
}
}
endeventHe's using OldMP, which doesn't support quick structure access. Also, use SHOTGUN_WEAPON instead of the magic constant '2'.
It makes sense that you can do it like this, without declaring a new var. Regarding indentation: Yeah, it happens when I copy paste into duke4net, it's good in sublime text
If I don't use my SHOTGUNAMMO like I coded, and instead like in your code, It doesn't work - It's like it doesn't register the current ammo at all, maybe I'm missing some declaration?
- Is there a way to change the color of the crosshair together with weapon-switches?? Can't seem to find anything about it online.

Help
Duke4.net
DNF #1
Duke 3D #1


