Here's where I'm at with my own efforts with the handheld firearms, which kind of sprawled into a script to modify any projectile: https://pastebin.com/j07S30Nb
Right now it modifies accuracy, velocity, firing rate, hit rate (to account for shot weapons that should be harder to dodge), chance of breaking on impact (needed that for a thrown weapon), whether it pierces through stuff or not and how many extra projectiles it spawns of which item subtype.
Very impressed after a cursory reading. As a fellow noob to lua, I did not know you could set table keys like that.
I did notice you set multiProjectile.distance_flown to 6 to avoid smoke, I initially did something similar on the blunderbuss before I noticed it seemed to be teleporting the projectiles forward. It's not a problem really unless the target is nearly adjacent.
Making a general purpose projectile script is a brilliant idea.
A few lingering issues I'm still having and could use some advice on are that I can't quite think of a way around: I'm trying to have it do stuff based on the weapon used, so that I can slow down firing rate for heavier crossbow (using the same ammunition). The projectile data structure has a 'bow_id' value, which is a number starting at 0 and increasing as more items are spawned in the map. It clearly corresponds to the specific ranged weapon used, but its not an item ID and I can't get any of the item functions to do anything useful with it. I suspect there's some obvious way of using that that I'm missing.
I've had this issue too and just sidestepped it by giving the weapon a new ammo, the only way I could think of using the same ammo was iterating through the firers inventory on distance_flown == 0, getting projectile.firer.inventory[indx].item.subtype.id and checking against the weapon name (or checking subtype.subtype, but I like strings for readability), but it was for the automusket and I was worried about the overhead and so didn't go any further with it. Hope that works for you.
Also I've been trying to change the item type of projectiles, which is easy enough for the subtype (using item.setSubtype), but setType doesn't exist. Is there some other way of doing this or do I just have to delete the original and spawn a new projectile?
I don't know of any other way of doing it, I don't think I was even aware of setSubtype until just now (will come in handy, thanks).
The next best thing would be creating a new item and changing the original projectiles .item to the new item, but my experience with trying to do stuff like that is it crashes the game. I've tried changing the general/specific_refs too but it just doesn't like it. I don't think I was trying to do that specifically though, maybe you would have better luck than myself.
And as an aside, I've noticed that the 'piercing' flag behaves weirdly and causes a single projectile to hit the same target numerous times, sometimes killing them dead instantly, before passing through. Might be useful to simulate explosives? Change the material to something with huge shear value and give the projectile plenty of contact area/surface and it should make giblets easily enough.
Edit: Just found that the shot projectiles can only hit one target one time, even though a single shot can hit multiple enemies at once. Even at close range the a single enemy only gets hit by one projectile while the rest merrily goes on its way.
Interesting stuff. I'll need have to have more of a mess around with the projectile flags, I have no idea what I'm doing with them. I just copied them in from Roses projectile script and I keep getting a weird bug on the cannon where it only causes light bruising, setting the piercing flag seemed to fix it but now I'm not so sure it did what I thought given what you've said. Maybe I should just make the cannonball use an edge attack. Has anything like that happened to you?
Could I include the rocket launchers in the dune mod I'm creating? They really are amazing, and proper credit would obviously be given.
It's lovely of you to ask, of course you can! I've been messing about with a lasgun that makes an instant beam of 'laser' and one that has a more simple 'blaster' trail as well, but I'm not happy with the results are so far (fire rate is just to make testing easier):

Your thread seems to indicate you also have a preliminary version of it as well, I'd love to see it. I want to try my hand at the beam-shield interaction.