- Added QF_SCALEUP and QF_MAX.

- QF_SCALEUP behaves like QF_SCALEDOWN: it gradually scales the tremors, only going upwards.
- QF_SCALEUP and QF_SCALEDOWN can be combined to make an earthquake that gradually smoothes in and out.
- QF_MAX can be used to invert this behavior, where it starts at the peak of the amplitude, fades out half way, and then grows back to maximum.
This commit is contained in:
MajorCooke 2015-02-20 10:46:37 -06:00
commit 140a650442
4 changed files with 31 additions and 7 deletions

View file

@ -781,13 +781,31 @@ static fixed_t QuakePower(double factor, int intensity, quakeInfo quake)
else
{
double ss = (double)((pr_torchflicker() % (intensity << 2)) - (intensity << 1));
if (scaleDownStart == 0)
if (quake.isScalingDown || quake.isScalingUp)
{
return FLOAT2FIXED(factor * ss);
fixed_t result;
if (scaleDownStart == 0) scaleDownStart = 1;
if (quake.isScalingDown && quake.isScalingUp)
{
if (quake.preferMaximum)
result = FLOAT2FIXED((factor * ss) * MAX((scaleDown / scaleDownStart), (scaleDownStart - scaleDown) / scaleDownStart));
else
result = FLOAT2FIXED((factor * ss) * MIN((scaleDown / scaleDownStart), (scaleDownStart - scaleDown) / scaleDownStart));
}
else if (quake.isScalingDown)
result = FLOAT2FIXED((factor * ss) * (scaleDown / scaleDownStart));
else if (quake.isScalingUp)
result = FLOAT2FIXED((factor * ss) * ((scaleDownStart - scaleDown) / scaleDownStart));
else
result = FLOAT2FIXED(factor * ss);
return result;
}
else
{
return FLOAT2FIXED(((factor * ss) * ((scaleDown / scaleDownStart))));
return FLOAT2FIXED(factor * ss);
}
}