I'm having a problem with getting reload -button work with Chaingun. By using eduke32 wiki i was able to code succesfully manual reload for the pistol. However my next plan was to code manual reload for chaingun cannon (weapon nr. 3).
It wont work: Each time i select weapon 3 it starts automatically shooting, making impossible to switch weapon or do anything... it just shoots until there is no ammunition left. The everything related to M4 is actually chaingun cannon on the code that i pasted down there. The pistol and its manual reload function works properly, however, chaingun doesn't.
Here is the code for M4
gamevars:
// M4 RELOAD
gamevar M4AMMO 0 1
gamevar KICKBACK 0 1
gamevar M4WEAPON 0 1
gamevar M4MAGAZINE 0 1
gamevar PERPLAYER2 0 1
gamevar WEAPON3_CLIP 0 GAMEVAR_PERPLAYER
Here is for the GAME.CON:
actor APLAYER MAXPLAYERHEALTH PSTAND 0 0
getplayer[THISACTOR].ammo_amount PWEAPON M4AMMO // the player's pistol ammo
ifvare PWEAPON 3 // if the player has the pistol selected...
{
ifvarl M4MAGAZINE 1 // and his magazine count is at zero...
{
getplayer[THISACTOR].weapon_pos PERPLAYER2
ifvarn PERPLAYER2 0
break // if he has a weapon that's lowering off screen, break
else ifvarl M4AMMO 1
break
else // otherwise, if he has ammo for the pistol, start the reloading anim
{
setplayer[THISACTOR].reloading 1
setplayer[THISACTOR].kickback_pic 4
}
}
ifvare KICKBACK 5 // if the reloading animation is on its second frame...
{
ifvarg M4AMMO 29 // if the player has at least twelve pistol rounds left,
setvar M4MAGAZINE 30 // then set his magazine counter to a full magazine
else
setvarvar M4MAGAZINE M4AMMO // otherwise set the magazine counter equal to his remaining ammo
}
}
onevent EVENT_LOOKLEFT
setvar RETURN -1 // disable the event
ifvare PWEAPON 3 // if the player has the pistol armed
{
ifvare M4MAGAZINE 30 // and his magazine is full, break
break
else ifvarvare M4MAGAZINE M4AMMO // if his magazine is equal to his pistol ammo, break
break
else // otherwise, start the reloading sequence
{
setplayer[THISACTOR].reloading 1
setplayer[THISACTOR].kickback_pic 4
}
}
endevent
onevent EVENT_PRESSEDFIRE // when the player presses the fire button...
ifvare PWEAPON 3 // and he has the pistol armed...
ifvarl M4MAGAZINE 1
setvar RETURN -1 // if his magazine is at zero, disable the firing key
endevent
onevent EVENT_DISPLAYREST
ifvare player[THISACTOR].curr_weapon 3
{
digitalnumberz 2930 280 175 M4MAGAZINE 0 0 0 0 0 xdim ydim 50000 // display the magazine count at a slightly smaller size (50000) next to the ammo
}
endevent
onevent EVENT_DOFIRE
ifvare PWEAPON 3 // if the player has the pistol selected when he fires a projectile...
ifvarg M4MAGAZINE 0
subvar M4MAGAZINE 1 // subtract 1 from the magazine count, unless it's already at zero
endevent
Should i also paste the pistol manual reload -code?