(on checking HG in used 2.5) WHEN ENGINE COLD, check the coolant reservoir and under the radiator cap. Should be little/no black stuff on the walls, should be no oil smell, should be no oily sheen on top. I read this check on forum somewhere a couple years ago before I bought my '99 OBW with EJ25D (dual overhead cam).
Mine had black stuff around the water line in reservoir, oily smell from coolant in reservoir, and oily sheen on top of fluid under radiator cap, and eventually it needed a HG. However, from my research before buying, in a used '99 EJ25D I EXPECTED to have to replace the HGs eventually. So I bought it at 132k miles (obviously well maintained), drove it 20,000+ miles, engine NEVER overheated, other than signs I described above there was no indication of HG failure. It ran great, but eventually I noticed a decrease in power (poor compression). And it was leaking oil from the rear mainseal (and probably all the other seals too) down onto the exhaust manifold, which produced a nice burning oil smell. So, I got underneath on a lift and could see evidence of the driver side HG failure underneath (coolant seeping) on the block where the HG is (as well as extensive oil leaks).
Anyway, point of the story is on that generation, that engine, with high miles, check to make sure no real damage is done before buying, but I'd still expect to eventually replace (a) timing belt, water pump, idler pully, etc. ( both HGs, © engine oil seals, (d) possibly valve job (I did because of the 20,000+ miles I drove on failed HG). I had all these things done by a mechanic and a new clutch while the engine was out.
I also replaced leaking, corroded exhaust pipes (from years of MD's salty winter roads and salty summer air), muffler, and rear catalytic converter. I also proactively did other maintenance that I assumed needed to be done because of the age and high mileage of vehicle (tune up, new tires, new pads/rotors all around, replaced a failed front caliper, replaced a slightly noisy front bearing, just replaced the clutch slave cylinder).
That said, including price of vehicle, all the work I had mechanic do, all the maintenance and work I did myself, I've got about $8,000 in the car and expect to hit 300k miles. All in all, $8,000 for 150,000+ miles is not a bad price to pay. Would spend twice that much for a new sub-compact car, which will need some similar maintenance along the way to 150,000 miles (incl. expensive timing belt, water pump). And my OBW is MUCH more fun to drive! So when buying used gen 1 OBW with EJ25D, factor the inevitable and possibly extensive (and expensive) maintenance into the price before you buy, but in my opinion, it's still a better buy than new.