mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-12 23:54:35 +00:00
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:
parent
05a5a4be51
commit
457ad97553
2 changed files with 52 additions and 16 deletions
|
@ -114,6 +114,7 @@ enum
|
||||||
QF_WAVE = 1 << 5,
|
QF_WAVE = 1 << 5,
|
||||||
QF_3D = 1 << 6,
|
QF_3D = 1 << 6,
|
||||||
QF_GROUNDONLY = 1 << 7,
|
QF_GROUNDONLY = 1 << 7,
|
||||||
|
QF_AFFECTACTORS = 1 << 8,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FQuakeJiggers
|
struct FQuakeJiggers
|
||||||
|
@ -152,6 +153,7 @@ public:
|
||||||
double GetModIntensity(double intensity, bool fake = false) const;
|
double GetModIntensity(double intensity, bool fake = false) const;
|
||||||
double GetModWave(double ticFrac, double waveMultiplier) const;
|
double GetModWave(double ticFrac, double waveMultiplier) const;
|
||||||
double GetFalloff(double dist) const;
|
double GetFalloff(double dist) const;
|
||||||
|
void DoQuakeDamage(AActor *m_Spot, AActor *victim) const;
|
||||||
|
|
||||||
static int StaticGetQuakeIntensities(double ticFrac, AActor *viewer, FQuakeJiggers &jiggers);
|
static int StaticGetQuakeIntensities(double ticFrac, AActor *viewer, FQuakeJiggers &jiggers);
|
||||||
};
|
};
|
||||||
|
|
|
@ -120,26 +120,29 @@ void DEarthquake::Tick ()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_DamageRadius > 0)
|
if (m_DamageRadius > 0)
|
||||||
|
{
|
||||||
|
if (m_Flags & QF_AFFECTACTORS)
|
||||||
|
{
|
||||||
|
auto iterator = m_Spot->Level->GetThinkerIterator<AActor>();
|
||||||
|
AActor* mo = nullptr;
|
||||||
|
|
||||||
|
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++)
|
for (i = 0; i < MAXPLAYERS; i++)
|
||||||
{
|
{
|
||||||
if (Level->PlayerInGame(i) && !(Level->Players[i]->cheats & CF_NOCLIP))
|
if (Level->PlayerInGame(i) && !(Level->Players[i]->cheats & CF_NOCLIP))
|
||||||
{
|
{
|
||||||
AActor *victim = Level->Players[i]->mo;
|
AActor* victim = Level->Players[i]->mo;
|
||||||
double dist;
|
DoQuakeDamage(m_Spot, victim);
|
||||||
|
|
||||||
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 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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
// DEarthquake :: GetModWave
|
||||||
|
|
Loading…
Reference in a new issue