Have you had any problems with it? I've not had anyone report bugs which is quite strange.
I know they sometimes try and fire through closed doors if the nearest enemy is behind (they don't yet check for buildings on a tile) but I want to know if I should make the make the pathing function parameter dynamic, so as to be more reliable in choosing a clear path (at the expense of more overhead).
Has it worked well enough for you?
I agree with your thoughts, seems very feasible! Were you thinking of making it fire item_ammo (item_ammos?), or use a different method of stopping trapcomp fire altogether?
A static organ gun is a rad idea, much better than the affront to native balance I posted above.
I'd like to do something similar but with a lower fire rate than an organ gun firing weak rockets that veer away and oscillate at random to make a katyusha/nebelwerfer/hwacha thingy as a more sane version of the rocket launcher.
I said it before, but I look forward to seeing the fruits of your tinkering.
The cannon so far worked without outright bugs (I hadn't come across any situation where buildings were in the way yet). The only oddity I had was my gunner persistently shooting to the bottom right with nothing there for some time but I suspect that was due to me sabotaging the hostility check (I didn't feel like waiting for a nicely grouped bunch of goblins to show up, so my own dwarves and some bards volunteered for projectile testing) perhaps causing it to target something it shouldn't be.
Some features I do miss is targeting being restricted to cannon orientation. My planning was to make a heavier, fixed bombard on a 3x3 building plot that would only rotate on manual command (using a building transform script), and a light 1x1 swivel-mounted gun that could fire in any direction. Having large guns be mostly fixed, defensive things you would generally place along a
shooting gallery welcoming entrance, the building collision issue might only be problematic with raised bridges.
I'd say that if targeting being blocked by buildings and orientation-restriction are both impossible with the current targeting implementation, it might be worth going with something with more overhead. Its not like the targeting script it run that frequently.
One other feature I would appreciate is a separate load and fire command, which I could probably implement myself once I figure out how to make very short-duration reactions. Being able to have accurate commands at when and where guns fire would help a lot in keeping down the number of hilarious friendly fire incidents.
Also yes, I was planning on using the ammo item time for projectiles, mostly for storage sake and to make cannonballs and grapeshot cartridges not show up in the item list for trap construction. From what I've tested they behave mostly the same as projectiles and while firing sawblades is inarguably cool, the mod I'm working with has a historic accuracy/realism premise to it so I can't exactly do that. I will have to console myself with adding edged damage to cannonballs to make sure they get the proper amount of dismemberment going.
Speaking of historic accuracy, shotguns are actually contemporary to vanilla DFs time period (late 1300/early 1400), if we interpret 'shotgun' to mean any gun loaded with shot instead of ball ammunition. Loading handcannons and artillery with a bunch of small projectiles instead of one big one was apparently not a huge leap in logic.
Edit: I'm not sure what to make of these two lines in the cannon script:
output_items[0].skill_used = input_items[0].mat_type
output_items[0].sharpness = input_items[0].mat_index