Standard Shotgun using 2 shells when firing

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

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
SoundOfDarkness
Posts: 114
Joined: Tue Feb 28, 2017 5:53 pm
Location: at home

Standard Shotgun using 2 shells when firing

Post by SoundOfDarkness »

So, again I'm just editing someone else work. Don't worry, I'm not planning to release my edited version, it's just for me. Of course I would ask for permission, if I should change my mind.

I'm not a fan of weapons shooting projectiles so I changed

Code: Select all

Fire:
    TNT1 A 0 A_JumpIfNoAmmo("Dryfire")
	TNT1 A 0 A_PlayWeaponSound("SHTGFIR")
    TNT1 A 0 A_AlertMonsters
	TNT1 A 0 A_TakeInventory("ShotgunLoaded", 1, TIF_NOTAKEINFINITE)
	TNT1 A 0 Radius_Quake (1, 2, 0, 1, 0)
	ATSG A 1
    TNT1 AAAAAAA 0 BRIGHT A_FireCustomMissile("ShotgunTracer", random(-2, 2), 0, 10, -1, 0, random(-2, 2))
	ATSG B 1 Bright A_Light(5)
	TNT1 A 0 A_GunFlash
	ATSG BC 2
	ATSG A 6
    Goto Ready
to

Code: Select all

Fire:
    TNT1 A 0 A_JumpIfNoAmmo("Dryfire")
	TNT1 A 0 A_PlayWeaponSound("SHTGFIR")
    TNT1 A 0 A_AlertMonsters
	TNT1 A 0 A_TakeInventory("ShotgunLoaded", 1, TIF_NOTAKEINFINITE)
	TNT1 A 0 Radius_Quake (1, 2, 0, 1, 0)
	ATSG A 1
    TNT1 A 0 BRIGHT A_FireBullets(4, 4, 7, 10, "CustomPuff1")
	ATSG B 1 Bright A_Light(5)
	TNT1 A 0 A_GunFlash
	ATSG BC 2
	ATSG A 6
    Goto Ready
But for some reason the shotgun now uses 2 shells when shooting. Any help?
User avatar
Mikk-
Posts: 2274
Joined: Tue Jun 30, 2009 1:31 pm
Location: Somewhere off Kanagawa

Re: Standard Shotgun using 2 shells when firing

Post by Mikk- »

Your error lies with this line:

Code: Select all

TNT1 A 0 BRIGHT A_FireBullets(4, 4, 7, 10, "CustomPuff1")
you have set the useammo field to 10, meaning it's gonna consume ammo. Change it to

Code: Select all

TNT1 A 0 BRIGHT A_FireBullets(4, 4, 7, 0, "CustomPuff1")
and you should be golden.
User avatar
SoundOfDarkness
Posts: 114
Joined: Tue Feb 28, 2017 5:53 pm
Location: at home

Re: Standard Shotgun using 2 shells when firing

Post by SoundOfDarkness »

Uhm, nope, that's the damage and 7 is the amount of pellets from the shotgun shell. Changing 10 to 0 just gives me a shotgun that uses 2 shells per shot without hurting anyone.
User avatar
Mikk-
Posts: 2274
Joined: Tue Jun 30, 2009 1:31 pm
Location: Somewhere off Kanagawa

Re: Standard Shotgun using 2 shells when firing

Post by Mikk- »

Wait, sorry I somehow confused A_FireBullets and A_FireProjectile - you need to disable the FBF_USEAMMO flag like so

Code: Select all

TNT1 A 0 BRIGHT A_FireBullets(4, 4, 7, 0, "CustomPuff1", 0)
My apologies.
User avatar
SoundOfDarkness
Posts: 114
Joined: Tue Feb 28, 2017 5:53 pm
Location: at home

Re: Standard Shotgun using 2 shells when firing

Post by SoundOfDarkness »

Yep, that worked. Thanks.

Return to “Scripting”