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!)
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.
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?
Last edited by genospizza on Sun Sep 24, 2023 10:34 pm, edited 1 time in total.
It should deplete ammo, however every tic the player is given another copy that gives them 20 more bullets from the ItemTest item.
Why not just give the player the weapon directly in the event handler instead?
Or you could create a new player class as well.
Yeah, I just realized I was woefully misusing that inventory class. I adapted that from a similar example, but I think that was removing and not adding a weapon. The ammo immediately maxing out should have tipped me off. Thanks for the help!