In making its determination of the issue raised by the special answer, the court shall consider any undue hardship on the defendant that would result from an issuance of the warrant. If the court finds for the defendant, the judge presiding shall tax the defendant's costs of such trial and an order shall be entered dismissing the writ or that the property attached be delivered to the defendant. The jury or the court shall, on the trial of the action or thereafter, assess the damages sustained by the defendant by reason of the taking and detention or sale of the property attached or by reason of any injury thereto. The same, together with the costs so taxed, shall be a setoff to the plaintiff's demand, and if in excess of it, or the plaintiff fails to recover, the defendant shall have judgment for the amount due. If the court on the trial of such special issue finds for the plaintiff, the presiding judge shall tax the plaintiff's costs of such trial, and the amount so taxed shall, if the plaintiff recovers, be taxed by the clerk as disbursement in the action. If the defendant or the defendant's assignee recovers judgment in the action, said costs and the judgment shall be offset.
N.D.C.C. § 32-08.1-18