I absolutely love dumping firearms into a setting. The possibilities of artillery, more engaging ship to ship battles, wars of large-scale, etc. all have my attention from the get-go.
There is just one little problem and it's the same question that literally everyone who breaches this topic asks.
"How do I explain firearms not being used for all combat?" If you've explored any forum in D&D you've probably seen this question yourself. If you like world building, you've probably asked this question yourself to begin with.
I have two answers for you; one is more of a stock answer that applies to just about anybody's campaign setting or campaign world, the other applies to my personal setting.
So, first one. Firearms did not immediately become the best option for combatants upon their invention. The methods of assembling, maintaining, loading, and even firing guns went through many iterations before they could be efficiently deployed en masse.
That particular gap between invention and usefulness was about 2 to 3 centuries, by the way. Now, your player characters probably don't have 2 to 3 centuries to advance firearms from matchlocks to wheellocks to flintlocks (and that's by no means a comprehensive history of firearms). That's okay, you can give your players a head start. Bump your players up to match or wheel locks. "But wait!" you cry out, "wasn't the point of this to say they shouldn't be that common or useful to begin with?" Well don't you worry, I'm not done yet.
There's one thing we have to worry about in the world of D&D that makes common and useful diverge on occasion; that's called magic. This goes across any D&D world in which magic exists; the best and brightest minds who know anything about the existence of magic will want to replicate the power and freedom it offers. That's the baseline assumption of most D&D worlds. No such roadmap exists for firearms in the world D&D; their utility primarily depends on their deployment en masse. Do the cities geniuses want to spend their time on weapon slightly better than crossbows? Or do they want to learn how to cast fireball?
Seems like a pretty obvious answer.
You have to be a special sort of insane, superstitious, genius, or maybe a combination of the three to want something like puckle guns or magazine-fed weapons. Maybe the character has religious or simply superstitious beliefs concerning magic. Maybe they don't like the idea of having to depend on something like the Weave, something not of their own making.
Maybe (and this is where genius comes in) they simply want to be the first to make something new, make a dent in the world. Or at the very least, make a nice hole in the city wall if no one tells the stable boy to keep torches out of the laboratory.
You get the idea.
Sounds like a perfect character to be an adventure, and for one of your players to enjoy. Let them! To boil down my first point, most of the smart and creative people would be advancing firearms in the real world would be advancing magic in the world of D&D. You can still have tinkerers and inventors who made the schematics for some of these firearms, even more advanced ones! But that doesn't mean they're in use or in circulation (see the steam engine, which apparently even the Romans knew of). So go nuts.
Onto the second explanation, something original, something by myself.
My favorite subject.
In the world of Brackas, firearms have gone past muskets. Way past. Schematics for things like levering bolt action rifles are widely distributed, and the sort of artillery you might've seen during World War I have their place on a number of battlefields.
All the same most battles still end with people hacking each other apart. The fight starts with artillery and muskets, and finishes with short swords and shields.
So how do I place these things side-by-side? Turns out, it's pretty easy. In my setting, gunpowder when stored for too long a time in too great a quantity inevitably detonates. The powder is simply more volatile than it is in the real world (and I apply this theme to a number of other materials). How does this play out within the setting? Well, muskets are the easiest firearms to mass-produce, they're the most disposable, and all-around bring the most bang for your buck when it comes to your average combatant. They take a pretty long time to reload, so a squad will let a volley loose before ditching their muskets for crossbows and swords.
A similar principle applies to siege weaponry; the ammunition often has to be manufactured on site and on demand (and it is expensive).
More advanced personal firearms like a lever or bolt action rifles and nock guns are too expensive to manufacture and too difficult for the average combatant to maintain. They are however ideal for more specialized combatants; people who can reliably maintain, supply, and kill using these weapons. Obviously, adventurers fall into this category. They are more skilled than the average soldier, engaged in combat far more often (meaning the expend the ammunition, and thus the gunpowder frequently), and have the capital to finance it all.
What’s the short of it? Players get to use firearms, they’re reasonably advanced, and they’re “special” to boot. Elite enemies and military factions also get to make use of them. They’re otherwise uncommon and simplistic. Ditto for artillery.