There have been many lawsuits over the definition of 'taking'.  Most of the time the government wins.  Remember the Supreme Court said that it was legal for a City to take a lady's house so that they could give it to a developer.  The government's interest in that one was that now they would get more taxes.

Sprinklers in common areas are something of a waste because the fires start inside the units.  If you don't do the whole thing, don't bother.

Government can require upgrades thru legislation.  Look up the mandatory seismic upgrade laws in California.