Would PrimaryWeapon return null if he had none? Try null and objnull pharhaps. That way it should work with any weapon. But I'm just talking what I'm thinking, so don't call me a liar if it doesn't work.
#loopadoo
? (primaryWeapon loon1) != "null": loon1 setCaptive true
~1
goto "loopadoo"