mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
- 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:
parent
3019f2cc23
commit
140a650442
4 changed files with 31 additions and 7 deletions
|
@ -80,7 +80,6 @@ void DEarthquake::Serialize (FArchive &arc)
|
|||
{
|
||||
arc << m_CountdownStart;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -101,7 +100,7 @@ void DEarthquake::Tick ()
|
|||
Destroy ();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!S_IsActorPlayingSomething (m_Spot, CHAN_BODY, m_QuakeSFX))
|
||||
{
|
||||
S_Sound (m_Spot, CHAN_BODY | CHAN_LOOP, m_QuakeSFX, 1, ATTN_NORM);
|
||||
|
@ -141,6 +140,7 @@ void DEarthquake::Tick ()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (--m_Countdown == 0)
|
||||
{
|
||||
if (S_IsActorPlayingSomething(m_Spot, CHAN_BODY, m_QuakeSFX))
|
||||
|
@ -166,7 +166,7 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, quakeInfo &qprop)
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
qprop.isScalingDown = qprop.isScalingUp = false, qprop.preferMaximum = false;
|
||||
qprop.intensityX = qprop.intensityY = qprop.intensityZ = qprop.relIntensityX = qprop.relIntensityY = qprop.relIntensityZ = 0;
|
||||
|
||||
TThinkerIterator<DEarthquake> iterator(STAT_EARTHQUAKE);
|
||||
|
@ -194,10 +194,13 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, quakeInfo &qprop)
|
|||
qprop.intensityY = MAX(qprop.intensityY, quake->m_IntensityY);
|
||||
qprop.intensityZ = MAX(qprop.intensityZ, quake->m_IntensityZ);
|
||||
}
|
||||
if (quake->m_Flags & QF_SCALEDOWN)
|
||||
if (quake->m_Flags)
|
||||
{
|
||||
qprop.scaleDownStart = quake->m_CountdownStart;
|
||||
qprop.scaleDown = quake->m_Countdown;
|
||||
qprop.isScalingDown = (quake->m_Flags & QF_SCALEDOWN) ? true : false;
|
||||
qprop.isScalingUp = (quake->m_Flags & QF_SCALEUP) ? true : false;
|
||||
qprop.preferMaximum = (quake->m_Flags & QF_MAX) ? true : false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -136,12 +136,14 @@ enum
|
|||
QF_RELATIVE = 1,
|
||||
QF_SCALEDOWN = 1 << 1,
|
||||
QF_SCALEUP = 1 << 2,
|
||||
QF_MAX = 1 << 3,
|
||||
};
|
||||
|
||||
struct quakeInfo
|
||||
{
|
||||
int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ;
|
||||
double scaleDown, scaleDownStart;
|
||||
bool isScalingDown, isScalingUp, preferMaximum;
|
||||
};
|
||||
|
||||
class DEarthquake : public DThinker
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -464,6 +464,7 @@ enum
|
|||
QF_RELATIVE = 1,
|
||||
QF_SCALEDOWN = 1 << 1,
|
||||
QF_SCALEUP = 1 << 2,
|
||||
QF_MAX = 1 << 3,
|
||||
};
|
||||
|
||||
// This is only here to provide one global variable for testing.
|
||||
|
|
Loading…
Reference in a new issue