[DECORATE] Weapon reload glitched

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
HellBlade64
Posts: 48
Joined: Tue May 13, 2014 3:00 pm

[DECORATE] Weapon reload glitched

Post by HellBlade64 »

RC-50 (sniper rifle) in a mod I'm maintaining on and off has a bug where it acts like it has no ammo and deselect despite the player clearly still having ammo to use. Tried to fix it myself with no luck.

Code: Select all

actor RC50 : Weapon
{
  tag "RC-50"
  obituary "%o was PIERCED by Assassin, %k's Robar RC-50!"
  inventory.pickupmessage "Robar RC-50"  
  attacksound "rc50/fire"
  weapon.selectionorder 7
  weapon.kickback 50
  weapon.ammotype1 "RobarClip"
  weapon.ammouse1 1
  weapon.ammogive1 0
  weapon.ammotype2 "RCAmmo"
  weapon.ammouse2 0
  weapon.ammogive2 30
  decal BulletChip
  scale 0.35
  +NOAUTOFIRE
  states
  {
  Ready:
    ROBF A 0 A_JumpIfInventory("PSGZoom",1,3)
    ROBF A 1 A_WeaponReady
    ROBF A 0 A_JumpIfNoAmmo("ReloadStart")
    loop
    ASNS A 1 A_WeaponReady
    ASNS A 0 A_JumpIfNoAmmo("ReloadStart")
    goto Ready+3
  Deselect:
    ROBF A 0 A_JumpIfInventory("PSGZoom",1,3)
    ROBF A 0 A_TakeInventory("PSGZoom",2)
    ROBF A 0 A_Lower
    ROBF A 1 A_Lower
    loop
    ASNS A 1 A_TakeInventory("PSGZoom",2)
    ASNS A 7 
    ROBF A 3
    loop
  Select:
    ROBF A 0 A_PlaySound("rc50/select")
    ROBF A 1 A_Raise
    goto Select+1
  Fire:
    ROBF A 0 A_JumpIfInventory("PSGZoom",1,"FireZoom")
    ROBF A 0 A_JumpIfNoAmmo("ReloadStart")
	ROBF A 0 A_TakeInventory("RobarClip",1)
	ASNS A 0 BRIGHT A_FireBullets (0.0, 0.0, 1, 1, "HHBulletPuff", 1, 25000)
    ROBA A 2 BRIGHT A_RailAttack(random(400,800), 4, 0, none, FFFFFF, 0, 0, "HHBulletPuff")
    ROBA A 0 BRIGHT 
    ROBA B 2 BRIGHT A_GunFlash
    ROBA CDEFG 2
    ROBF A 3
    ROBA A 0 A_JumpIfInventory("RCAmmo",5,1)
    goto Ready
    ROBA A 0 A_JumpIfNoAmmo("ReloadStart")
    ROBA A 0
    goto Ready
  FireZoom:
    ASNS A 0 A_JumpIfNoAmmo("AltFire")
    ASNS A 0 BRIGHT A_FireBullets (0.0, 0.0, 1, 1, "HHBulletPuff", 1, 25000)
    ASNS A 2 BRIGHT A_RailAttack(random(400,800), 0, 0, none, FFFFFF, 0, 0, "HHBulletPuff")
    ASNS A 0 BRIGHT 
    ASNS A 2 BRIGHT A_GunFlash
    ASNS AAAA 2
    ASNS A 2
    ASNS A 0 A_JumpIfInventory("RCAmmo",5,1)
    goto Ready
    ASNS A 0 A_JumpIfNoAmmo("ReloadStart")
    ASNS A 0
    goto Ready
  AltFire:
    //ROBA A 0 ACS_ExecuteAlways(596,0,0,0,0)
    ROBA A 0 A_JumpIfInventory("PSGZoom",1,"ZoomOut")
    ASNS A 0 A_GiveInventory("PSGZoom")
	ASNS A 0 A_PlaySound("ScopeIn")
	ROBA A 0 A_ZoomFactor(5.0,0)
    ASNS A 8 
    ASNS A 1 A_Refire
    goto Ready
  /*AltHold:
    ROBA A 1 A_JumpIfInventory("PSGZoom",1,2)
    ROBA A 1 A_ReFire
    goto Ready
    ASNS A 1 
    ASNS A 1 A_ReFire
    goto Ready*/
  ZoomOut:
    //ASNS A 0 ACS_ExecuteAlways(597,0,0,0,0)
    ASNS A 1 A_TakeInventory("PSGZoom",1)
	ASNS A 0 A_PlaySound("ScopeOut")
	ROBA A 0 A_ZoomFactor(1.0,0)
    ASNS A 7 
    ROBF A 2
    ROBF A 1 A_Refire
    goto Ready
  ReloadStart:    
    ROBA A 0 A_JumpIfInventory("PSGZoom",1,"ReloadStartZoom")
    ROBA A 0 A_JumpIfInventory("RCAmmo",5,2)
    ROBA A 0
    goto NoAmmo
    ROBA HIJKLMNPQR 2
    goto ReloadAmmo
  ReloadAmmo:
    ROBA M 0 A_GiveInventory("RobarClip",1)
    ROBA M 0 A_TakeInventory("RCAmmo",1)
    ROBA M 0 A_JumpIfInventory("RobarClip",1,"ReloadEnd")
    ROBA M 0 A_JumpIfInventory("RCAmmo",1,"ReloadAmmo")
    goto ReloadEnd
  ReloadEnd:
    ROBA S 2 A_PlaySound("rc50/boltopen")
    ROBA T 4 
    ROBA RQ 2
    ROBA P 2 A_PlaySound("rc50/boltclose")
    ROBA NMLKJIH 2
    ROBA A 0
    goto Ready
  Flash:
    TNT1 A 2 bright A_Light2
    TNT1 A 2 bright A_Light1
    TNT1 A 0 bright A_Light0
    stop
  ReloadStartZoom:
    ROBA A 0 A_PlaySound("ScopeOut")
    ROBA A 0 A_ZoomFactor(1.0,0)
    ROBA A 0 A_JumpIfInventory("RCAmmo",5,2)
    goto Ready
    ROBA A 0
    goto NoAmmo
    ASNS A 1 A_TakeInventory("PSGZoom",2)
    ASNS A 7 
    ROBF A 2
    ROBA HIJKLMNPQR 2
    goto ReloadAmmoZoom
  ReloadAmmoZoom:
    ROBA M 0 A_GiveInventory("RobarClip",1)
    ROBA M 0 A_TakeInventory("RCAmmo",1)
    ROBA M 0 A_JumpIfInventory("RobarClip",1,"ReloadEndZoom")
    ROBA M 0 A_JumpIfInventory("RCAmmo",5,"ReloadAmmoZoom")
    goto ReloadEndZoom
  ReloadEndZoom:
    ROBA S 2 A_PlaySound("rc50/boltopen")
    ROBA T 4 
    ROBA RQ 2
    ROBA P 2 A_PlaySound("rc50/boltclose")
    ROBA NMLKJIH 2
	ROBA A 0 A_ZoomFactor(5.0,0)
    //ROBA A 0 A_ReFire
    goto AltFire
  NoAmmo:
    ROBF A 1
    ROBF A 0 A_SelectWeapon("M9")
    ROBF A 0 A_SelectWeapon("M90")
    ROBF A 0 A_SelectWeapon("MP5")
    ROBF A 0 A_SelectWeapon("P90")
    ROBF A 0 A_SelectWeapon("M16")
    ROBF A 10 A_SelectWeapon("HK69")
    goto Deselect
  Spawn:
    ROBP ABCDEFGHIJKL 3
    loop
  }
}

actor RobarClip : Ammo
{
    inventory.icon "AMM2A0"
    inventory.amount 0
    inventory.maxamount 1
    ammo.backpackamount 0
    ammo.backpackmaxamount 1
}

actor PSGZoom : Inventory
{
    inventory.amount 0
    inventory.maxamount 2
}
User avatar
Hungarian Lincoln
Posts: 23
Joined: Tue Aug 26, 2025 3:24 am
Preferred Pronouns: He/Him

Re: [DECORATE] Weapon reload glitched

Post by Hungarian Lincoln »

I used the code to my mod of ZBloody Hell what coded by LordOZ_98:

Code: Select all

//Weapons: Sawedoff 

ACTOR Sawedoff : SuperShotgun replaces SuperShotgun
{
  Spawnid 33
  Inventory.PickupSound "misc/pickswof"
  Weapon.AmmoGive 12
  Weapon.AmmoType "Shells"
  Weapon.Sisterweapon "FastSawedoff"
  Inventory.PickupMessage "$GOTSHOTGUN2"
  States
  {
  Spawn:
    SGN2 A -1
    Loop  
  Ready:
    SHT2 A 1 A_WeaponReady
    Loop
  Deselect:
    SHT2 A 1 A_Lower
	TNT1 AA 0 A_Lower
    Loop
  Select:
    SHT2 A 1 A_Raise
	TNT1 AA 0 A_Raise
    Loop
  Fire:
    TNT1 A 0 A_Gunflash
    DSHT AABBC 1 Bright A_WeaponReady(14)
    TNT1 A 22 A_WeaponReady(14)
    Goto Ready
  Flash:
	TNT1 A 0 A_PlayWeaponSound("weapons/sshotf")
	TNT1 A 0 A_FireBullets(7.2, 6.4, 10, 5, "BulletPuff", 1)
	SHT2 E 1 Bright A_WeaponReady(14)
	SHT2 F 1 Bright A_WeaponReady(14)
	SHT2 G 1 A_WeaponReady(14)
	SHT2 H 1 Bright A_WeaponReady(14)
	SHT2 H 1 A_WeaponReady(14)
	SHT2 G 1 A_WeaponReady(14)
	SHT2 I 1 A_WeaponReady(14) 
	SHT2 J 1 A_WeaponReady(14)
	SHT2 D 1 A_WeaponReady(14)
    SHT2 CBB 1 A_WeaponReady(14)
	TNT1 A 0 A_JumpIfNoAmmo("NoAmmo")
	TNT1 A 0 A_PlaySound("weapons/sshotl")
	SH2R DEFGHIJKLMNOPP 1 A_WeaponReady(14)
	Stop
   NoAmmo:
	SHT2 A 19 A_WeaponReady(14)
	Stop	
  }
}

Return to “Scripting”