From 457ad9755355a6b0f548235822624876673f5528 Mon Sep 17 00:00:00 2001 From: inkoalawetrust <56005600+inkoalawetrust@users.noreply.github.com> Date: Sun, 25 Sep 2022 09:01:46 +0300 Subject: [PATCH] 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. --- src/playsim/a_sharedglobal.h | 2 + src/playsim/mapthinkers/a_quake.cpp | 66 ++++++++++++++++++++++------- 2 files changed, 52 insertions(+), 16 deletions(-) diff --git a/src/playsim/a_sharedglobal.h b/src/playsim/a_sharedglobal.h index 3a9a022721..8a359d80c5 100644 --- a/src/playsim/a_sharedglobal.h +++ b/src/playsim/a_sharedglobal.h @@ -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); }; diff --git a/src/playsim/mapthinkers/a_quake.cpp b/src/playsim/mapthinkers/a_quake.cpp index ca69d305ed..32e8a5e856 100644 --- a/src/playsim/mapthinkers/a_quake.cpp +++ b/src/playsim/mapthinkers/a_quake.cpp @@ -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* 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