With this script, you can make weapons and items cost HP to use.
It is important to notice that if the unit doesn't have enought HP to use a weapon that costs life, it can't initiate an attack. The unit also won't be able to counterattack. On the other hand, if the unit had another weapon available in its inventory, it will use that second weapon to counterattack.
If the unit can make two attacks during a round of combat, but doesn't have enough HP to make the second attack, it won't do it, even if it has other available weapons. This also applies to counterattacks: if the unit has enough HP to wield the weapon, but receives too much damage before being able to counterattack, it won't counterattack.
This script does not work for items with the Custom type. For those items, you need to find the script that created that specific custom item type modify it to make it work. Because this requires modifying another script, it is not possible to give precise instructions to solve the problem
You need to use the custom parameter "lifeCost" on the weapons/items and write as value the HP cost of each attack of that weapon.
For example, a weapon with {lifeCost:5} costs 5 HP for every attack, even if the unit misses.