Easy, if he/she says you are being detained, ask on what grounds you are being detained.
+1 exactly. the point is to continuously deflect their attempts at violating your rights, without giving them what they are illegally trying to obtain. i will give an example.
officer "is that a gun?"
reply: is it illegal to carry a gun?
Officer: can i see your id
Reply: am i being detained?
this can go either way. no is the easiest but if not....
officer: yes you are for officer safety, suspicion *some other horse doo reason*
Reply : can you give me a valid legal reason of why you are holding me against my will?
Officer: i need to know if your a felon or not
Reply: do you have reasonable cause to believe im a felon?
see how that works. the best reply is to question the question with intelligence and facts.
if the officer states "do you think your cool carrying that" reply with "do you have a reason to be violating my 4th amendment rights?"
not TOO combative but it also kind of hardens the point of "im not a pushover, try again"
the second they take you into custody, or arrest you. shut up. tell them you are invoking your 5th amendment rights. and lawyer up.
also make sure to have a voice recorder running. it can save your butt because without it. officer vs you in court. he will win usually.
happy hunting ! :-D