Members of the militia ordered into active service of the state by any proper authority shall not be liable civilly or criminally for any act or acts done by them while on such duty nor shall any action lie against any officer or enlisted person for any acts done by the officer or enlisted person in line of duty by virtue of any order which may thereafter be held invalid by any civil court. When a suit or proceeding shall be commenced in any court by any person against any officer or enlisted person of the militia for any act done by such officer or enlisted person in his or her official capacity or in the discharge of any duty, or against any person acting under the authority or order of such officer or by virtue of any warrant issued pursuant to law, the defendant may require the person prosecuting or instituting the proceeding to give security for the payment of all costs that may be awarded to the defendant, and the defendant in all cases may make a general denial and, under such general denial, give all other or any special defense matter in evidence. In case the plaintiff shall be nonsuited or the verdict or judgment be in favor of the defendant, treble costs shall be assessed against the plaintiff. The defendant in such action shall be defended by the attorney general at the expense of the state, but private counsel may also be employed by the defendant. The venue of all such actions shall be Thurston county and the state of Washington shall be in all cases a necessary party defendant.