Added rumble from world

This commit is contained in:
Marcus Minhorst 2025-07-21 22:45:32 -04:00 committed by Rachael Alexanderson
commit d4a6e1c6aa
8 changed files with 96 additions and 2 deletions

View file

@ -142,6 +142,7 @@ CUSTOM_CVARD(Int, haptics_compat, HAPTCOMPAT_MATCH, CVAR_ARCHIVE | CVAR_GLOBALCO
}
CVARD(Bool, haptics_do_menus, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "allow haptic feedback for menus");
CVARD(Bool, haptics_do_world, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "allow haptic feedback for things acting on player");
CVARD(Bool, haptics_do_action, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "allow haptic feedback for player doing things");
// CODE --------------------------------------------------------------------

View file

@ -1714,11 +1714,30 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch
}
if (thing->flags2 & MF2_PUSHABLE && !(tm.thing->flags2 & MF2_CANNOTPUSH))
{ // Push thing
if (thing->lastpush != tm.PushTime)
{
thing->PlayPushSound();
thing->Vel += tm.thing->Vel.XY() * thing->pushfactor;
thing->lastpush = tm.PushTime;
if (tm.thing == players[consoleplayer].mo || tm.thing == players[consoleplayer].camera)
{
IFVIRTUALPTR(tm.thing, AActor, PlayerPushedSomethingMakeRumble)
{
VMValue params[1] = { thing };
VMCall(func, params, 1, nullptr, 0);
}
}
else if (thing == players[consoleplayer].mo || thing == players[consoleplayer].camera)
{
// I assume the player can be pushed, correct?
IFVIRTUALPTR(thing, AActor, PlayerWasPushedMakeRumble)
{
VMValue params[1] = { tm.thing };
VMCall(func, params, 1, nullptr, 0);
}
}
}
}
solid = (thing->flags & MF_SOLID) &&

View file

@ -3272,6 +3272,22 @@ DEFINE_ACTION_FUNCTION(AActor, CheckFakeFloorTriggers)
P_CheckFakeFloorTriggers(self, oldz, oldz_has_viewh);
return 0;
}
//==========================================================================
//
// Rumble functions
//
//==========================================================================
static void PlayerLandedMakeRumble(AActor* self, AActor *onmobj)
{
IFVIRTUALPTR(self, AActor, PlayerLandedMakeRumble)
{
VMValue params[2] = { self, onmobj };
VMCall(func, params, 2, nullptr, 0);
}
}
//===========================================================================
//
// PlayerLandedOnThing
@ -3305,6 +3321,7 @@ static void PlayerLandedOnThing (AActor *mo, AActor *onmobj)
P_FallingDamage (mo);
PlayerLandedMakeRumble(mo, onmobj);
PlayerLandedMakeGruntSound(mo, onmobj);
// mo->player->centering = true;

View file

@ -81,6 +81,7 @@
#include "g_levellocals.h"
#include "gstrings.h"
#include "i_soundinternal.h"
#include "m_joy.h"
#include "m_random.h"
#include "p_3dmidtex.h"
#include "p_acs.h"
@ -97,6 +98,7 @@ static FRandom pr_actorinspecialsector ("ActorInSpecialSector");
EXTERN_CVAR(Bool, cl_predict_specials)
EXTERN_CVAR(Bool, forcewater)
EXTERN_CVAR (Bool, haptics_do_world)
// [RH] Check dmflags for noexit and respond accordingly
bool FLevelLocals::CheckIfExitIsGood (AActor *self, level_info_t *info)
@ -210,6 +212,7 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType, DVe
P_ChangeSwitchTexture (line->sidedef[0], repeat, special);
line->special = 0;
}
// end of changed code
if (developer >= DMSG_SPAMMY && buttonSuccess)
{
@ -639,7 +642,8 @@ void P_GiveSecret(FLevelLocals *Level, AActor *actor, bool printmessage, bool pl
Printf(PRINT_HIGH | PRINT_NONOTIFY, "Secret found in sector %d\n", sectornum);
}
}
if (playsound) S_Sound (CHAN_AUTO, CHANF_UI, "misc/secret", 1, ATTN_NORM);
if (playsound)
S_Sound (CHAN_AUTO, CHANF_UI|(haptics_do_world?CHANF_RUMBLE:CHANF_NORUMBLE), "misc/secret", 1, ATTN_NORM);
}
}
Level->found_secrets++;

View file

@ -190,6 +190,13 @@ bool P_Teleport (AActor *thing, DVector3 pos, DAngle angle, int flags)
{
player->mo->Angles.Pitch = nullAngle;
}
if (player->mo == players[consoleplayer].mo || player->mo == players[consoleplayer].camera)
{
IFVIRTUALPTR(player->mo, AActor, PlayerTeleportedMakeRumble)
{
CallVM<void>(func, player->mo);
}
}
}
if (!(flags & TELF_KEEPORIENTATION))
{

View file

@ -44,6 +44,7 @@
#include "i_interface.h"
#include "i_time.h"
#include "i_video.h"
#include "m_haptics.h"
#include "m_random.h"
#include "p_3dmidtex.h"
#include "p_effect.h"
@ -64,6 +65,7 @@ const float MY_SQRT2 = float(1.41421356237309504880); // sqrt(2)
extern bool DrawFSHUD; // [RH] Defined in d_main.cpp
EXTERN_CVAR (Bool, cl_capfps)
EXTERN_CVAR (Bool, haptics_do_world)
// TYPES -------------------------------------------------------------------
@ -1040,8 +1042,15 @@ void R_SetupFrame(FRenderViewpoint& viewPoint, const FViewWindow& viewWindow, AA
if (!WorldPaused())
{
FQuakeJiggers jiggers;
if (DEarthquake::StaticGetQuakeIntensities(viewPoint.TicFrac, viewPoint.camera, jiggers) > 0)
int intensity = DEarthquake::StaticGetQuakeIntensities(viewPoint.TicFrac, viewPoint.camera, jiggers);
if (intensity > 0)
{
if (haptics_do_world)
{
// f(0)->1 f(9)->0
Joy_Rumble("world/quake", (9.0-intensity)/9);
}
const double quakeFactor = r_quakeintensity;
if (jiggers.RollIntensity || jiggers.RollWave)
iView->AngleOffsets.Roll = DAngle::fromDeg(QuakePower(quakeFactor, jiggers.RollIntensity, jiggers.RollWave));

View file

@ -1264,6 +1264,7 @@ OptionMenu "HapticsOptions" protected
StaticText "$HAPMNU_OPTIONS"
Option "$HAPMNU_OPT_MENU", "haptics_do_menus", "OnOff"
Option "$HAPMNU_OPT_ACTION", "haptics_do_action", "OnOff"
Option "$HAPMNU_OPT_WORLD", "haptics_do_world", "OnOff"
}
//-------------------------------------------------------------------------------------------

View file

@ -1717,6 +1717,21 @@ class Actor : Thinker native
//
//----------------------------------------------------------------------------
virtual void PlayerLandedMakeRumble(actor onmobj)
{
if (!CVar.GetCVar("haptics_do_world").GetBool()) return;
bool isliquid = (pos.Z <= floorz) && HitFloor ();
if (onmobj != NULL || !isliquid)
{
Haptics.Rumble("*land");
}
else if (self.Vel.Z < -self.player.mo.GruntSpeed)
{
Haptics.Rumble("*grunt");
}
}
virtual void PlayerUsedSomethingMakeRumble(int activationType, int levelNum, int lineNum, int lineSpecial)
{
if (!CVar.GetCVar("haptics_do_action").GetBool()) return;
@ -1724,6 +1739,27 @@ class Actor : Thinker native
Haptics.Rumble("*usesuccess");
}
virtual void PlayerTeleportedMakeRumble()
{
if (!CVar.GetCVar("haptics_do_world").GetBool()) return;
Haptics.Rumble("misc/teleport");
}
virtual void PlayerPushedSomethingMakeRumble(actor thing)
{
if (!CVar.GetCVar("haptics_do_world").GetBool()) return;
Haptics.Rumble("misc/push");
}
virtual void PlayerWasPushedMakeRumble(actor source)
{
if (!CVar.GetCVar("haptics_do_world").GetBool()) return;
Haptics.Rumble("misc/pushed");
}
//----------------------------------------------------------------------------
//
// PROC A_CheckSkullDone