From ae28eeae94384dfebbe93c45ed95921c15fccd1f Mon Sep 17 00:00:00 2001 From: nashmuhandes Date: Tue, 14 May 2024 21:26:12 +0800 Subject: [PATCH] Scriptified the view squatting. --- src/playsim/p_mobj.cpp | 17 ++++++++++------- wadsrc/static/zscript/actors/actor.zs | 11 +++++++++++ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/playsim/p_mobj.cpp b/src/playsim/p_mobj.cpp index d5fdf8574..9c0b99c88 100644 --- a/src/playsim/p_mobj.cpp +++ b/src/playsim/p_mobj.cpp @@ -2811,15 +2811,18 @@ static void PlayerLandedMakeGruntSound(AActor* self, AActor *onmobj) } } +static void PlayerSquatView(AActor *self, AActor *onmobj) +{ + IFVIRTUALPTR(self, AActor, PlayerSquatView) + { + VMValue params[2] = { self, onmobj }; + VMCall(func, params, 2, nullptr, 0); + } +} + static void PlayerLandedOnThing (AActor *mo, AActor *onmobj) { - if (!mo->player) - return; - - if (mo->player->mo == mo) - { - mo->player->deltaviewheight = mo->Vel.Z / 8.; - } + PlayerSquatView(mo, onmobj); if (mo->player->cheats & CF_PREDICTING) return; diff --git a/wadsrc/static/zscript/actors/actor.zs b/wadsrc/static/zscript/actors/actor.zs index 7c52030da..694f8262e 100644 --- a/wadsrc/static/zscript/actors/actor.zs +++ b/wadsrc/static/zscript/actors/actor.zs @@ -1439,6 +1439,17 @@ class Actor : Thinker native } } + virtual void PlayerSquatView(Actor onmobj) + { + if (!self.player) + return; + + if (self.player.mo == self) + { + self.player.deltaviewheight = self.Vel.Z / 8.; + } + } + //---------------------------------------------------------------------------- // // PROC A_CheckSkullDone