Valid mods for a pistol crossbow?

So my new NPC has Pistols 8. Fine, I say, I have skills, I’ll make and mod a pistol crossbow.

I try putting a rail laser sight on it. Nope, mod too big for the gun.
I try putting a underbarrel laser sight on it. Nope, mod too big for the gun.
I try putting a combat knife on it. Nope, “cannot have a combat knife.”
I try an old makeshift bayonet. Nope, “cannot have a makeshift bayonet.”
out of desperation,I try some iron sights. “Nope, isn’t big enough for that mod.”

A pistol crossbow has a rail slot, an underbarrel slot, a grip slot, a sights slot, and a stock slot. I went back and checked the json: it has the exact same “valid_mod_locations” as a normal crossbow.

So what mods are you supposed to mount on a pistol crossbow?

Never mind, realized my character has Pistol 0 and doesn’t know how to mount them. Annoying but I can deal with it.^U^U

Nope, debugged myself a higher handguns skill, still can’t do it. Increased the volume of the pistol crossbow to 1.5L, weight to 4 lbs, still can’t.

$ git grep -C 1 hand_crossbow src

src/item.cpp-
src/item.cpp:    } else if( typeId() == "hand_crossbow" && !!mod.type->gunmod->usable.count( pistol_gun_type ) ) {
src/item.cpp-        return ret_val<bool>::make_failure( _("isn't big enough to use that mod") );

Nice double negation there. Okay, that explains it.

1 Like

Well now that’s pretty weird. I guess I kinda get it, but it seems silly considering all the other shit we can put mods on.

No, it’s a bug.
It’s supposed to read
if( typeId() == “hand_crossbow” && !mod.type->gunmod->usable.count( pistol_gun_type ) ) {

ie, if it’s a hand crossbow and you’re trying to use a gunmod that isn’t a pistol mod, then it’s too big.
The double !! is the equivalent of
if( typeId() == “hand_crossbow” && mod.type->gunmod->usable.count( pistol_gun_type ) ) {

ie, if its’ a hand crossbow and you’re trying to use a gunmod that is a pistol mod, then it’s too big.

Obvious bug because someone typo’d the negation. These things happen. I’ve submitted a PR to fix it: https://github.com/CleverRaven/Cataclysm-DDA/pull/24314

Ah I see, I didn’t look that closely. That definitely looks like an oops.