the hp should go up gradually as it's built and canceling it should give a proportional refund.
actually, some discussion to be had about how building refunds should work. in aoe2, if you build something halfway and then cancel it, you only get a half refund, even if it was never attacked, whereas in aoe4, you can get a full refund except for damage it's taken. i kinda like the aoe2 mode because it makes things like forward castles riskier. but actually, isn't it weird how you can cancel a unit at 99% and get a full refund but not a building? so maybe aoe4's way makes more sense.
actually, do we really want buildings foundations to disappear if they run out of hp? in i think both games, you can start building a castle/keep and if the enemy hits it with high damage as soon as it starts, like a trebuchet, it can be completely destroyed and you lose the entire cost. i think that's really tilting when it happens and not necessary and not logical. the point of building costs being upfront is that you're reserving the necessary materials, not that you've already used them. so if it gets destroyed at 10% shouldn't you only lose 10% of the cost? and maybe the foundation shouldn't disappear because you still want to build it when you take back the area. maybe foundations taking damage should actually just reduce their building progress. and proportionally increase the cost of finishing them. hm, but then when is the cost of that damage paid?
I definitely think that if a building gets destroyed, you should lose only the resources proportional to its building progress. what i hate is losing 3600 resources because i tried to build Berkshire Palace and it got hit with one bombard immediately after i started. but i'd still like to consider the possibility of damage not destroying foundations but instead reducing their progress. what effects would this have on the game?
denying buildings would be a lot easier. that's the main one i can think of. i'm not sure if that's a good thing. it might make it too easy, denying even defensive buildings; you might not be able to build a castle in your base while being attacked because the enemy could prevent it from ever completing by attacking the foundation.
if we want it to work that way anyway, we need to decide how the cost is paid. the initial cost is paid in full up front. so to be consistent, one might think it should interrupt construction and cost resources to resume it, or maybe just auto-deduct the cost by default. but i don't really like the implication that just doing a little bit of damage could completely stall a building's construction progress if the player doesn't have the right resource.
on second thought, i think that since a bulding that's been completed can be damaged down to 1% and still be fully functional, it makes sense that you can still make progress toward building something while it's under attack, and just have it have low hp when finished. if you agree, i'm content to implement this plan now (aoe4 style refund).
just had another thought about why aoe4 style refund bugs me. it's this discontinuity: cancel a building at 99% progress and you get full refund, cancel it at 100% and you get no refund.
well, i implemented aoe4 refunds for now.
We can always support multiple, given that we're trying to make a usable engine and we can decide which one later :)