you can do that by eventing with mathematics and control variable - just have a control variable load the available gold when it changes, calculate how much it changed and apply a change HP command for the difference. And the other way for damage (or using damage coding to reduce the gold in the damage formula directly).