Accelerometer offset correction

Hello, I am using an accelerometer with the arduino that will be attached to a free floating buoy to measure wave height and period. The problem i have is that when the accelerometer is placed at rest its acceleration reads x=0, y=0 and z=1g or if placed at an angle then I get some combination of xy and z values. I need the sensor to read real accelerations so at rest it would read x=0, y=0 and z=0. I know that i can offset the z axis by 1 g but that will only solve the problem if the sensor remains level. Because the sensor will be floating in water the sensor will tilt and the offset will not correct the x and y axis. So how can I correct this so when the sensor is at rest or constant velocity regardless of orientation all three axis's will read zero?

"I know that i can offset the z axis by 1 g..."

That's what is normally done if you want a reading of zero with no movement..

(I think) to find the gravity-pointing pseudo z axis vector and gain as it bobs around at different attitudes, you'll need to do some trigonometry using all 3 axis. I only have a conceptional understanding of this. I can't help with the formula(s). I hope this helps.

Accelerometer alone won't do it, you'll also need a gyroscope sensor. The gyroscope will sense the tilt (rotation) and combined with the accelerometer you can determine the 'gravity compensated' acceleration, and from that the velocity it's moving at and from that the distance moved. The math and the 'fusion' of the two sensors gets real bizarre. Look up 6/9 DOF IMU's and check the Arduino sensors forum. If you really want to do this you're in for a long journey. But it can be done.