Weapon altfire not working

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
JtoTheB
Posts: 55
Joined: Sat Aug 09, 2025 9:46 am
Operating System Version (Optional): Windows 11
Location: New Jersey

Weapon altfire not working

Post by JtoTheB »

Basically, I'm working on a replacement for the Plasma Rifle that has an altfire that fires a railgun beam. Testing it with sv_infiniteammo works but for some reason without infinite ammo it just does not work. Tried obtaining the maximum amount of ammo (600 cells) and it still didnt work. Any fix for this? The code will be provided below.

Code: Select all

ACTOR UltraPlasmaRifle : PlasmaRifle Replaces PlasmaRifle
{
Inventory.PickupSound "misc/yoink"
Inventory.PickupMessage "You got the Ultra Plasma Rifle!"
Weapon.AmmoType "Cell"
Weapon.UpSound "misc/plasmaraise"
Weapon.AmmoUse1 1
Weapon.AmmoUse2 15
Tag "Ultra Plasma Rifle"
 States
  {
  Ready:
	RLRW A 0 A_PlaySound("weapons/plasmaidle",7,0.5,true)
    PLSG A 1 A_WeaponReady
    Loop
  Deselect:
	PLSG A 1 A_StopSound(7)
    PLSG A 1 A_Lower
    NULL AA 0 A_Lower
    Loop
  Select:
    PLSG A 1 A_Raise
    NULL AA 0 A_RAISE
    Loop
  Fire:
    PLSG A 2 A_FirePlasma
    PLSG B 9 A_ReFire
    Goto Ready
 AltFire:
	PLSG A 2 A_GUNFLASH
	PLSG A 2 A_RECOIL(7)
	PLSG A 15 A_RailAttack(60, 0, true, "8A2BE2", "8A2BE2", 0, 0, "none")
	PLSG B 28 A_REFIRE
	Goto Ready
  Flash:
    PLSF A 4 Bright A_Light1
    Goto LightDone
    PLSF B 4 Bright A_Light1
    Goto LightDone
  Spawn:
    PLAS A -1
    Stop
  }
}
User avatar
JtoTheB
Posts: 55
Joined: Sat Aug 09, 2025 9:46 am
Operating System Version (Optional): Windows 11
Location: New Jersey

Re: Weapon altfire not working

Post by JtoTheB »

Update, I managed to fix the issue by defining two ammo types.

Return to “Scripting”