Back in the days of loading flintlock pistols and rifles, the hammer had to be cocked halfway back in order to load the weapon and put in a new fuse. Sometimes a person would make a mistake and the hammer would come down after loading the powder and the gun would go off. That is how we get the saying to "not go off half cocked."