What you do with the hotheaded cop is pretty much basic. You don't give them any more ammunition to mess with you.
BTW, you are carrying a digital recorder and it is turned on? And you have practiced with it, finding out just how well it picks up everyday conversation and where is the best place to carry it so that it records everything? Good for you.
The basic suggestion to find out f you are being detained leads you to the next step. If you are not being detained you want to remove yourself from the cop and the situation. You can go make your formal written complaint after you get out of hs AO - it's just not possible to do it standing there arguing with him. If you are in fact detained you need to remember that anything you say can and will be used against you - and that applys to things you say before they read you your Miranda/Edwards rights as well as afterwards.
Not arguing with the cop is a good idea. Not resisting (at least physically) is an even better idea, as all that will do is make them want to use compliance techniques, most of which are painful. Since you are recording this (see above) you can and should say that you do not consent to being searched or to having your handgun seized. It probably will not be worth much later on, but it often makes you feel better at the moment. (If the detention/search/seizure as unconstitutional it does not matter if you verbally objected to it or not - it was still unconstitutional.)
If you are detained/arrested it is usually a good idea to give them your basic ID info - usually (but your state laws may differ) this involves merely stating your name and where you live (name of city/county or your actual residential address) if for no other reason than to avoid sitting in a jail cell waiting (either hours or days) for the FBI to get back to the cops with whatever information they have on you based on your fingerprints. If you are detained/arrested you should state in no uncetain terms that you want to consult with an attorney - whether or not the cops ask you any questions. Then shut up unless it is necessary to seek medical attention or request to use the facilities to poop/pee.
I know it hurts emotionally and intellectually to have a cop tell you things that are not true, but I still cannot fathom why folks want to stand on the sidewalk arguing law with them. I can understand trying to explain what happened before they arrived so they might understand that you do not need to be detained/arrested. My experience (yes, anecdotal, not data) is that cops have pretty much made up their mind to issue a ticket/arrest by the time they step out of their car. It's not always right and it is always a pain to have to deal with, but arguing the law with a cop rarely ever improves your situation. It's probably better in the long run to suffer initially and then sue them.
stay safe.