Making custom weapons deplete ammo and make bullet hole decals
Posted: Sun Sep 24, 2023 3:35 pm
EDIT: After using the solution in the replies, I was still having the decal issue. I've solved it now, so here's the fix for future Googlers:
Create a file in the root of your mod called "decaldef.txt". In there you can add a definition that looks like this:
Replace "TestWeapon" with the name of your weapon class name. "BulletChip" is the default bullet hole texture, but if you unpack gzdoom.pk3 you can view the whole list of decals and choose a different one.
ORIGINAL POST:
Hi there. I've been learning ZScript for a bit, and this is the first problem I've come across that I couldn't solve by looking in the docs or tutorials.
I'm trying to define a custom weapon that inherits from the Pistol class and mimics it precisely, so I can modify it. But I think I may be putting it in the player's inventory the wrong way. When I run the script below, the gun that I get doesn't deplete ammo when I fire it. It also doesn't make bullet hole decals or smoke particles. It does still damage enemies.
The TestWeapon definition:
Create a file in the root of your mod called "decaldef.txt". In there you can add a definition that looks like this:
Code: Select all
generator TestWeapon BulletChip
ORIGINAL POST:
Hi there. I've been learning ZScript for a bit, and this is the first problem I've come across that I couldn't solve by looking in the docs or tutorials.
I'm trying to define a custom weapon that inherits from the Pistol class and mimics it precisely, so I can modify it. But I think I may be putting it in the player's inventory the wrong way. When I run the script below, the gun that I get doesn't deplete ammo when I fire it. It also doesn't make bullet hole decals or smoke particles. It does still damage enemies.
The TestWeapon definition:
Spoiler:The way I'm giving it to the player (ItemTestHandler is registered in mapinfo.txt):
Spoiler:Other things I've noticed: even if I change the owner.GiveInventory line to give the player "Pistol" instead of "TestWeapon", it causes the weapon to not deplete ammo. I'm guessing this is just entirely the wrong way to give a player a weapon. Any idea what's causing the ammo depletion and bullet decal problems?