How to make self-repairing weapons?

Ever since I played Cerulean Crescent, I’ve been enamoured with the self-repairing prf weapons in that hack. It really opens up a massive amount of design space for making interesting units.

I would love to play around with it myself. So of course, I tried to reverse engineer it in febuilder, but as a layperson I unsurprisingly came out empty handed.

I would greatly appreciate any help with this!

(Also, bonus points if anyone knows who originated this mechanic, so I can credit them in the off chance I ever finish a hack.)

Thank you