Added QF_AFFECTACTORS.

The QF_AFFECTACTORS flag makes the thrusting and harming of damaging earthquakes also affect monsters. Monsters with DONTTHRUST will not be flung around by earthquakes.
This commit is contained in:
inkoalawetrust 2022-09-25 09:01:46 +03:00 committed by Christoph Oelckers
parent 05a5a4be51
commit 457ad97553
2 changed files with 52 additions and 16 deletions

View File

@ -114,6 +114,7 @@ enum
QF_WAVE = 1 << 5,
QF_3D = 1 << 6,
QF_GROUNDONLY = 1 << 7,
QF_AFFECTACTORS = 1 << 8,
};
struct FQuakeJiggers
@ -152,6 +153,7 @@ public:
double GetModIntensity(double intensity, bool fake = false) const;
double GetModWave(double ticFrac, double waveMultiplier) const;
double GetFalloff(double dist) const;
void DoQuakeDamage(AActor *m_Spot, AActor *victim) const;
static int StaticGetQuakeIntensities(double ticFrac, AActor *viewer, FQuakeJiggers &jiggers);
};

View File

@ -121,25 +121,28 @@ void DEarthquake::Tick ()
if (m_DamageRadius > 0)
{
for (i = 0; i < MAXPLAYERS; i++)
if (m_Flags & QF_AFFECTACTORS)
{
if (Level->PlayerInGame(i) && !(Level->Players[i]->cheats & CF_NOCLIP))
{
AActor *victim = Level->Players[i]->mo;
double dist;
auto iterator = m_Spot->Level->GetThinkerIterator<AActor>();
AActor* mo = nullptr;
dist = m_Spot->Distance2D(victim, true);
// Check if in damage radius
if (dist < m_DamageRadius && victim->Z() <= victim->floorz)
while ((mo = iterator.Next()) != NULL)
{
if (mo == m_Spot) //Ignore the earthquake origin.
continue;
DoQuakeDamage(m_Spot, mo);
}
}
else
{
for (i = 0; i < MAXPLAYERS; i++)
{
if (Level->PlayerInGame(i) && !(Level->Players[i]->cheats & CF_NOCLIP))
{
if (pr_quake() < 50)
{
P_DamageMobj (victim, NULL, NULL, pr_quake.HitDice (1), NAME_Quake);
}
// Thrust player around
DAngle an = victim->Angles.Yaw + DAngle::fromDeg(pr_quake());
victim->Vel.X += m_Intensity.X * an.Cos() * 0.5;
victim->Vel.Y += m_Intensity.Y * an.Sin() * 0.5;
AActor* victim = Level->Players[i]->mo;
DoQuakeDamage(m_Spot, victim);
}
}
}
@ -157,6 +160,37 @@ void DEarthquake::Tick ()
}
}
//==========================================================================
//
// DEarthquake :: DoQuakeDamage
//
// Handles performing earthquake damage and thrust to the specified victim.
//
//==========================================================================
void DEarthquake::DoQuakeDamage(AActor *m_Spot, AActor *victim) const
{
double dist;
dist = m_Spot->Distance2D(victim, true);
// Check if in damage radius
if (dist < m_DamageRadius && victim->Z() <= victim->floorz)
{
if (pr_quake() < 50)
{
P_DamageMobj(victim, NULL, NULL, pr_quake.HitDice(1), NAME_Quake);
}
// Thrust player or thrustable actor around
if (victim->player || !(victim->flags7 & MF7_DONTTHRUST))
{
DAngle an = victim->Angles.Yaw + DAngle::fromDeg(pr_quake());
victim->Vel.X += m_Intensity.X * an.Cos() * 0.5;
victim->Vel.Y += m_Intensity.Y * an.Sin() * 0.5;
}
}
return;
}
//==========================================================================
//
// DEarthquake :: GetModWave