From a38b151940e754b6ff03a07c95b8e2d04b232f74 Mon Sep 17 00:00:00 2001 From: inkoalawetrust <56005600+inkoalawetrust@users.noreply.github.com> Date: Sun, 8 Jan 2023 07:20:26 +0200 Subject: [PATCH] Added damage and thrust multipliers to quakes. These properties allow for scaling the amount of damage an earthquake does and how much it pushes actors around. --- src/playsim/a_sharedglobal.h | 5 +++-- src/playsim/mapthinkers/a_quake.cpp | 22 +++++++++++++--------- src/playsim/p_acs.cpp | 4 +++- src/playsim/p_actionfunctions.cpp | 4 +++- src/playsim/p_spec.h | 2 +- wadsrc/static/zscript/actors/actor.zs | 2 +- 6 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/playsim/a_sharedglobal.h b/src/playsim/a_sharedglobal.h index 16354f2c7d..8221797418 100644 --- a/src/playsim/a_sharedglobal.h +++ b/src/playsim/a_sharedglobal.h @@ -135,8 +135,8 @@ class DEarthquake : public DThinker public: static const int DEFAULT_STAT = STAT_EARTHQUAKE; void Construct(AActor *center, double intensityX, double intensityY, double intensityZ, int duration, - int damrad, int tremrad, FSoundID quakesfx, int flags, - double waveSpeedX, double waveSpeedY, double waveSpeedZ, int falloff, int highpoint, double rollIntensity, double rollWave); + int damrad, int tremrad, FSoundID quakesfx, int flags, + double waveSpeedX, double waveSpeedY, double waveSpeedZ, int falloff, int highpoint, double rollIntensity, double rollWave, double damageMultiplier, double thrustMultiplier); void Serialize(FSerializer &arc); void Tick (); @@ -151,6 +151,7 @@ public: double m_Falloff; int m_Highpoint, m_MiniCount; double m_RollIntensity, m_RollWave; + double m_DamageMultiplier, m_ThrustMultiplier; double GetModIntensity(double intensity, bool fake = false) const; double GetModWave(double ticFrac, double waveMultiplier) const; diff --git a/src/playsim/mapthinkers/a_quake.cpp b/src/playsim/mapthinkers/a_quake.cpp index 8cd3897cad..6055c3e114 100644 --- a/src/playsim/mapthinkers/a_quake.cpp +++ b/src/playsim/mapthinkers/a_quake.cpp @@ -52,7 +52,7 @@ IMPLEMENT_POINTERS_END void DEarthquake::Construct(AActor *center, double intensityX, double intensityY, double intensityZ, int duration, int damrad, int tremrad, FSoundID quakesound, int flags, double waveSpeedX, double waveSpeedY, double waveSpeedZ, int falloff, int highpoint, - double rollIntensity, double rollWave) + double rollIntensity, double rollWave, double damageMultiplier, double thrustMultiplier) { m_QuakeSFX = quakesound; m_Spot = center; @@ -69,6 +69,8 @@ void DEarthquake::Construct(AActor *center, double intensityX, double intensityY m_MiniCount = highpoint; m_RollIntensity = rollIntensity; m_RollWave = rollWave; + m_DamageMultiplier = damageMultiplier; + m_ThrustMultiplier = thrustMultiplier; } //========================================================================== @@ -94,13 +96,15 @@ void DEarthquake::Serialize(FSerializer &arc) ("minicount", m_MiniCount) ("rollintensity", m_RollIntensity) ("rollwave", m_RollWave); + ("damagemultiplier", m_DamageMultiplier); + ("thrustmultiplier", m_ThrustMultiplier); } //========================================================================== // // DEarthquake :: Tick // -// Deals damage to any players near the earthquake and makes sure it's +// Deals damage to any actors near the earthquake and makes sure it's // making noise. // //========================================================================== @@ -186,7 +190,7 @@ void DEarthquake::DoQuakeDamage(DEarthquake *quake, AActor *victim, bool falloff { if (!(quake->m_Flags & QF_SHAKEONLY) && pr_quake() < 50) { - damage = falloff ? pr_quake.HitDice(1) * GetFalloff(dist, m_DamageRadius) : pr_quake.HitDice(1); + damage = falloff ? pr_quake.HitDice(1) * GetFalloff(dist, m_DamageRadius) * m_DamageMultiplier : pr_quake.HitDice(1) * m_DamageMultiplier; damage = damage < 1 ? 1 : damage; //Do at least a tiny bit of damage when in radius. P_DamageMobj(victim, NULL, NULL, damage, NAME_Quake); @@ -195,8 +199,8 @@ void DEarthquake::DoQuakeDamage(DEarthquake *quake, AActor *victim, bool falloff if (!(victim->flags7 & MF7_DONTTHRUST)) { DAngle an = victim->Angles.Yaw + DAngle::fromDeg(pr_quake()); - victim->Vel.X += m_Intensity.X * an.Cos() * 0.5 * thrustfalloff; - victim->Vel.Y += m_Intensity.Y * an.Sin() * 0.5 * thrustfalloff; + victim->Vel.X += m_Intensity.X * an.Cos() * m_ThrustMultiplier * thrustfalloff; + victim->Vel.Y += m_Intensity.Y * an.Sin() * m_ThrustMultiplier * thrustfalloff; } } return; @@ -420,7 +424,7 @@ int DEarthquake::StaticGetQuakeIntensities(double ticFrac, AActor *victim, FQuak bool P_StartQuakeXYZ(FLevelLocals *Level, AActor *activator, int tid, double intensityX, double intensityY, double intensityZ, int duration, int damrad, int tremrad, FSoundID quakesfx, int flags, double waveSpeedX, double waveSpeedY, double waveSpeedZ, int falloff, int highpoint, - double rollIntensity, double rollWave) + double rollIntensity, double rollWave, double damageMultiplier, double thrustMultiplier) { AActor *center; bool res = false; @@ -434,7 +438,7 @@ bool P_StartQuakeXYZ(FLevelLocals *Level, AActor *activator, int tid, double int if (activator != NULL) { Level->CreateThinker(activator, intensityX, intensityY, intensityZ, duration, damrad, tremrad, - quakesfx, flags, waveSpeedX, waveSpeedY, waveSpeedZ, falloff, highpoint, rollIntensity, rollWave); + quakesfx, flags, waveSpeedX, waveSpeedY, waveSpeedZ, falloff, highpoint, rollIntensity, rollWave, damageMultiplier, thrustMultiplier); return true; } } @@ -445,7 +449,7 @@ bool P_StartQuakeXYZ(FLevelLocals *Level, AActor *activator, int tid, double int { res = true; Level->CreateThinker(center, intensityX, intensityY, intensityZ, duration, damrad, tremrad, - quakesfx, flags, waveSpeedX, waveSpeedY, waveSpeedZ, falloff, highpoint, rollIntensity, rollWave); + quakesfx, flags, waveSpeedX, waveSpeedY, waveSpeedZ, falloff, highpoint, rollIntensity, rollWave, damageMultiplier, thrustMultiplier); } } @@ -454,5 +458,5 @@ bool P_StartQuakeXYZ(FLevelLocals *Level, AActor *activator, int tid, double int bool P_StartQuake(FLevelLocals *Level, AActor *activator, int tid, double intensity, int duration, int damrad, int tremrad, FSoundID quakesfx) { //Maintains original behavior by passing 0 to intensityZ, flags, and everything else after QSFX. - return P_StartQuakeXYZ(Level, activator, tid, intensity, intensity, 0, duration, damrad, tremrad, quakesfx, 0, 0, 0, 0, 0, 0, 0, 0); + return P_StartQuakeXYZ(Level, activator, tid, intensity, intensity, 0, duration, damrad, tremrad, quakesfx, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); } diff --git a/src/playsim/p_acs.cpp b/src/playsim/p_acs.cpp index ff97c7484e..c912f47cec 100644 --- a/src/playsim/p_acs.cpp +++ b/src/playsim/p_acs.cpp @@ -6243,7 +6243,9 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) argCount > 12 ? args[12] : 0, argCount > 13 ? args[13] : 0, argCount > 14 ? ACSToDouble(args[14]) : 0, - argCount > 15 ? ACSToDouble(args[15]) : 0); + argCount > 15 ? ACSToDouble(args[15]) : 0, + argCount > 16 ? ACSToDouble(args[16]) : 0, + argCount > 17 ? ACSToDouble(args[17]) : 0); } case ACSF_SetLineActivation: diff --git a/src/playsim/p_actionfunctions.cpp b/src/playsim/p_actionfunctions.cpp index b4768cae0d..c69f1b7033 100644 --- a/src/playsim/p_actionfunctions.cpp +++ b/src/playsim/p_actionfunctions.cpp @@ -3369,8 +3369,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_QuakeEx) PARAM_INT(highpoint); PARAM_FLOAT(rollIntensity); PARAM_FLOAT(rollWave); + PARAM_FLOAT(damageMultiplier); + PARAM_FLOAT(thrustMultiplier); P_StartQuakeXYZ(self->Level, self, 0, intensityX, intensityY, intensityZ, duration, damrad, tremrad, sound, flags, mulWaveX, mulWaveY, mulWaveZ, falloff, highpoint, - rollIntensity, rollWave); + rollIntensity, rollWave, damageMultiplier, thrustMultiplier); return 0; } diff --git a/src/playsim/p_spec.h b/src/playsim/p_spec.h index a0918da917..c98d805501 100644 --- a/src/playsim/p_spec.h +++ b/src/playsim/p_spec.h @@ -164,7 +164,7 @@ void P_TerminateScript (FLevelLocals *Level, int script, const char *map); // // [RH] p_quake.c // -bool P_StartQuakeXYZ(FLevelLocals *Level, AActor *activator, int tid, double intensityX, double intensityY, double intensityZ, int duration, int damrad, int tremrad, FSoundID quakesfx, int flags, double waveSpeedX, double waveSpeedY, double waveSpeedZ, int falloff, int highpoint, double rollIntensity, double rollWave); +bool P_StartQuakeXYZ(FLevelLocals *Level, AActor *activator, int tid, double intensityX, double intensityY, double intensityZ, int duration, int damrad, int tremrad, FSoundID quakesfx, int flags, double waveSpeedX, double waveSpeedY, double waveSpeedZ, int falloff, int highpoint, double rollIntensity, double rollWave, double damageMultiplier, double thrustMultiplier); bool P_StartQuake(FLevelLocals *Level, AActor *activator, int tid, double intensity, int duration, int damrad, int tremrad, FSoundID quakesfx); #endif diff --git a/wadsrc/static/zscript/actors/actor.zs b/wadsrc/static/zscript/actors/actor.zs index 30c763463a..275fb00f7f 100644 --- a/wadsrc/static/zscript/actors/actor.zs +++ b/wadsrc/static/zscript/actors/actor.zs @@ -1209,7 +1209,7 @@ class Actor : Thinker native deprecated("2.3", "User variables are deprecated in ZScript. Actor variables are directly accessible") native void A_SetUserVarFloat(name varname, double value); deprecated("2.3", "User variables are deprecated in ZScript. Actor variables are directly accessible") native void A_SetUserArrayFloat(name varname, int index, double value); native void A_Quake(double intensity, int duration, int damrad, int tremrad, sound sfx = "world/quake"); - native void A_QuakeEx(double intensityX, double intensityY, double intensityZ, int duration, int damrad, int tremrad, sound sfx = "world/quake", int flags = 0, double mulWaveX = 1, double mulWaveY = 1, double mulWaveZ = 1, int falloff = 0, int highpoint = 0, double rollIntensity = 0, double rollWave = 0); + native void A_QuakeEx(double intensityX, double intensityY, double intensityZ, int duration, int damrad, int tremrad, sound sfx = "world/quake", int flags = 0, double mulWaveX = 1, double mulWaveY = 1, double mulWaveZ = 1, int falloff = 0, int highpoint = 0, double rollIntensity = 0, double rollWave = 0, double damageMultiplier = 1, double thrustMultiplier = 0.5); action native void A_SetTics(int tics); native void A_DamageSelf(int amount, name damagetype = "none", int flags = 0, class filter = null, name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT); native void A_DamageTarget(int amount, name damagetype = "none", int flags = 0, class filter = null, name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT);