From a7f76fe8b967168489aad8ecbffd37cb3fb36832 Mon Sep 17 00:00:00 2001 From: inkoalawetrust <56005600+inkoalawetrust@users.noreply.github.com> Date: Sun, 8 Jan 2023 08:23:30 +0200 Subject: [PATCH] Added damage property to earthquakes. When this property is set to any value above 0. The earthquake does the exact amount of damage specified, instead of a random amount. --- src/playsim/a_sharedglobal.h | 3 ++- src/playsim/mapthinkers/a_quake.cpp | 28 ++++++++++++++++----------- src/playsim/p_acs.cpp | 5 +++-- src/playsim/p_actionfunctions.cpp | 3 ++- src/playsim/p_spec.h | 2 +- wadsrc/static/zscript/actors/actor.zs | 2 +- 6 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/playsim/a_sharedglobal.h b/src/playsim/a_sharedglobal.h index 8221797418..466ec5c607 100644 --- a/src/playsim/a_sharedglobal.h +++ b/src/playsim/a_sharedglobal.h @@ -136,7 +136,7 @@ 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, double damageMultiplier, double thrustMultiplier); + double waveSpeedX, double waveSpeedY, double waveSpeedZ, int falloff, int highpoint, double rollIntensity, double rollWave, double damageMultiplier, double thrustMultiplier, int damage); void Serialize(FSerializer &arc); void Tick (); @@ -152,6 +152,7 @@ public: int m_Highpoint, m_MiniCount; double m_RollIntensity, m_RollWave; double m_DamageMultiplier, m_ThrustMultiplier; + int m_Damage; 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 6055c3e114..6cb82cd3ec 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 damageMultiplier, double thrustMultiplier) + double rollIntensity, double rollWave, double damageMultiplier, double thrustMultiplier, int damage) { m_QuakeSFX = quakesound; m_Spot = center; @@ -71,6 +71,7 @@ void DEarthquake::Construct(AActor *center, double intensityX, double intensityY m_RollWave = rollWave; m_DamageMultiplier = damageMultiplier; m_ThrustMultiplier = thrustMultiplier; + m_Damage = damage; } //========================================================================== @@ -98,6 +99,7 @@ void DEarthquake::Serialize(FSerializer &arc) ("rollwave", m_RollWave); ("damagemultiplier", m_DamageMultiplier); ("thrustmultiplier", m_ThrustMultiplier); + ("damage", m_Damage); } //========================================================================== @@ -174,12 +176,11 @@ void DEarthquake::Tick () // //========================================================================== -//[inkoalawetrust] Todo: Add a damage multiplier variable to DEarthquake ? Could be useful for making stronger earthquakes more damaging and stuff. void DEarthquake::DoQuakeDamage(DEarthquake *quake, AActor *victim, bool falloff) const { double dist; - double thrustfalloff = 0.f; - int damage = 0; + double thrustfalloff; + int damage; if (!quake || !victim) return; @@ -190,13 +191,18 @@ 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) * m_DamageMultiplier : pr_quake.HitDice(1) * m_DamageMultiplier; + if (m_Damage < 1) + damage = falloff ? (int)(pr_quake.HitDice(1) * GetFalloff(dist, m_DamageRadius) * m_DamageMultiplier) : (int)(pr_quake.HitDice(1) * m_DamageMultiplier); + //[inkoalawetrust] Do the exact specified damage. + else + damage = falloff ? (int)(m_Damage * GetFalloff(dist, m_DamageRadius) * m_DamageMultiplier) : (int)(m_Damage * 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); } // Thrust pushable actor around - if (!(victim->flags7 & MF7_DONTTHRUST)) + if (!(victim->flags7 & MF7_DONTTHRUST) && m_ThrustMultiplier > 0) { DAngle an = victim->Angles.Yaw + DAngle::fromDeg(pr_quake()); victim->Vel.X += m_Intensity.X * an.Cos() * m_ThrustMultiplier * thrustfalloff; @@ -424,7 +430,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 damageMultiplier, double thrustMultiplier) + double rollIntensity, double rollWave, double damageMultiplier, double thrustMultiplier, int damage) { AActor *center; bool res = false; @@ -438,7 +444,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, damageMultiplier, thrustMultiplier); + quakesfx, flags, waveSpeedX, waveSpeedY, waveSpeedZ, falloff, highpoint, rollIntensity, rollWave, damageMultiplier, thrustMultiplier, damage); return true; } } @@ -449,14 +455,14 @@ 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, damageMultiplier, thrustMultiplier); + quakesfx, flags, waveSpeedX, waveSpeedY, waveSpeedZ, falloff, highpoint, rollIntensity, rollWave, damageMultiplier, thrustMultiplier, damage); } } return res; } -bool P_StartQuake(FLevelLocals *Level, AActor *activator, int tid, double intensity, int duration, int damrad, int tremrad, FSoundID quakesfx) +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, 0, 0); + return P_StartQuakeXYZ(Level, activator, tid, intensity, intensity, 0, duration, damrad, tremrad, quakesfx, 0, 0, 0, 0, 0, 0, 0, 0, 1.0, 0.5, 0); } diff --git a/src/playsim/p_acs.cpp b/src/playsim/p_acs.cpp index c912f47cec..429fe1b694 100644 --- a/src/playsim/p_acs.cpp +++ b/src/playsim/p_acs.cpp @@ -6244,8 +6244,9 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) argCount > 13 ? args[13] : 0, argCount > 14 ? ACSToDouble(args[14]) : 0, argCount > 15 ? ACSToDouble(args[15]) : 0, - argCount > 16 ? ACSToDouble(args[16]) : 0, - argCount > 17 ? ACSToDouble(args[17]) : 0); + argCount > 16 ? ACSToDouble(args[16]) : 1.0, + argCount > 17 ? ACSToDouble(args[17]) : 0.5, + argCount > 18 ? args[18] : 0); } case ACSF_SetLineActivation: diff --git a/src/playsim/p_actionfunctions.cpp b/src/playsim/p_actionfunctions.cpp index c69f1b7033..20eac3a652 100644 --- a/src/playsim/p_actionfunctions.cpp +++ b/src/playsim/p_actionfunctions.cpp @@ -3371,8 +3371,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_QuakeEx) PARAM_FLOAT(rollWave); PARAM_FLOAT(damageMultiplier); PARAM_FLOAT(thrustMultiplier); + PARAM_INT(damage); P_StartQuakeXYZ(self->Level, self, 0, intensityX, intensityY, intensityZ, duration, damrad, tremrad, sound, flags, mulWaveX, mulWaveY, mulWaveZ, falloff, highpoint, - rollIntensity, rollWave, damageMultiplier, thrustMultiplier); + rollIntensity, rollWave, damageMultiplier, thrustMultiplier, damage); return 0; } diff --git a/src/playsim/p_spec.h b/src/playsim/p_spec.h index c98d805501..ff0095eea9 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, double damageMultiplier, double thrustMultiplier); +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, int damage); 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 275fb00f7f..e6c4a04e3d 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, double damageMultiplier = 1, double thrustMultiplier = 0.5); + 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, int damage = 0); 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);