From add4ff12acab3fe80a1dd7a0f858b5946a3265ac Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 13 Feb 2022 23:15:18 -0500 Subject: [PATCH] - virtualize player landing on thing sound --- src/playsim/actor.h | 2 ++ src/playsim/p_mobj.cpp | 31 ++++++++++----------------- src/r_data/gldefs.cpp | 2 +- wadsrc/static/zscript/actors/actor.zs | 25 +++++++++++++++++++++ 4 files changed, 39 insertions(+), 21 deletions(-) diff --git a/src/playsim/actor.h b/src/playsim/actor.h index 02f47f79f..3a0d6d1fa 100644 --- a/src/playsim/actor.h +++ b/src/playsim/actor.h @@ -1499,6 +1499,8 @@ public: bool isFrozen() const; bool hasmodel; + + void PlayerLandedMakeGruntSound(AActor* onmobj); }; class FActorIterator diff --git a/src/playsim/p_mobj.cpp b/src/playsim/p_mobj.cpp index c8ce4a291..eadaa94ae 100644 --- a/src/playsim/p_mobj.cpp +++ b/src/playsim/p_mobj.cpp @@ -2778,10 +2778,17 @@ DEFINE_ACTION_FUNCTION(AActor, CheckFakeFloorTriggers) // //=========================================================================== +void AActor::PlayerLandedMakeGruntSound(AActor *onmobj) +{ + IFVIRTUAL(AActor, PlayerLandedMakeGruntSound) + { + VMValue params[2] = { (AActor*)this, (AActor*)onmobj }; + VMCall(func, params, 2, nullptr, 0); + } +} + static void PlayerLandedOnThing (AActor *mo, AActor *onmobj) { - bool grunted; - if (!mo->player) return; @@ -2795,24 +2802,8 @@ static void PlayerLandedOnThing (AActor *mo, AActor *onmobj) P_FallingDamage (mo); - // [RH] only make noise if alive - if (mo->health > 0 && !mo->player->morphTics) - { - grunted = false; - // Why should this number vary by gravity? - if (mo->Vel.Z < -mo->player->mo->FloatVar(NAME_GruntSpeed)) - { - S_Sound (mo, CHAN_VOICE, 0, "*grunt", 1, ATTN_NORM); - grunted = true; - } - if (onmobj != NULL || !Terrains[P_GetThingFloorType (mo)].IsLiquid) - { - if (!grunted || !S_AreSoundsEquivalent (mo, "*grunt", "*land")) - { - S_Sound (mo, CHAN_AUTO, 0, "*land", 1, ATTN_NORM); - } - } - } + mo->PlayerLandedMakeGruntSound(onmobj); + // mo->player->centering = true; } diff --git a/src/r_data/gldefs.cpp b/src/r_data/gldefs.cpp index 3623e55bf..73428851f 100644 --- a/src/r_data/gldefs.cpp +++ b/src/r_data/gldefs.cpp @@ -65,7 +65,7 @@ struct ExtraUniformCVARData FString Shader; FString Uniform; double* vec4 = nullptr; - ExtraUniformCVARData* Next; + ExtraUniformCVARData* Next = nullptr; }; static void do_uniform_set(float value, ExtraUniformCVARData* data) diff --git a/wadsrc/static/zscript/actors/actor.zs b/wadsrc/static/zscript/actors/actor.zs index 7c39fabc9..7be0f9601 100644 --- a/wadsrc/static/zscript/actors/actor.zs +++ b/wadsrc/static/zscript/actors/actor.zs @@ -1286,6 +1286,31 @@ class Actor : Thinker native } } + virtual void PlayerLandedMakeGruntSound(actor onmobj) + { + bool grunted; + + // [RH] only make noise if alive + if (self.health > 0 && !self.player.morphTics) + { + grunted = false; + // Why should this number vary by gravity? + if (self.Vel.Z < -self.player.mo.GruntSpeed) + { + A_StartSound("*grunt", CHAN_VOICE); + grunted = true; + } + bool isliquid = (pos.Z <= floorz) && HitFloor (); + if (onmobj != NULL || !isliquid) + { + if (!grunted) + { + A_StartSound("*land", CHAN_AUTO); + } + } + } + } + //---------------------------------------------------------------------------- // // PROC A_CheckSkullDone