Fixed WalkStepTics & RunStepTics in terrain parser

Fixed the discrepancy where WalkStepTics and RunStepTics were called, well, that. In the terrain struct in both C++ and ZScript. While the terrain parser looked for WALKINGSTEPTIME and RUNNINGSTEPTIME instead.
Also made the parse not multiply these time values by the ticrate to treat them as seconds instead of tics.

Added flags for P_HitWater().

Added optional overridable footsteps for players.

Added an overridable MakeFootsteps() virtual in PlayerPawn. Which allows for adding totally custom footstep logic for players. By default, it comes with a basic footstep system that uses the footstep properties of whatever terrain the pawn is standing on. bMakeFootsteps must be enabled on the pawn for the virtual to run.

Added generic StepSound TERRAIN property.

Added a generic step sound TERRAIN property, for defining foot-agnostic step sounds. Used by the built-in footstep system over the individual foot ones.

Simplified MakeFootsteps().

Also removed a leftover debug message.
This commit is contained in:
inkoalawetrust 2024-10-02 03:53:30 +03:00 committed by Rachael Alexanderson
parent 8e4080f8d1
commit 12d1afcc4e
No known key found for this signature in database
GPG key ID: 26A8ACCE97115EE0
8 changed files with 76 additions and 12 deletions

View file

@ -77,13 +77,14 @@ enum ETerrainKeywords
TR_DAMAGETIMEMASK,
TR_FOOTCLIP,
TR_STEPVOLUME,
TR_WALKINGSTEPTIME,
TR_RUNNINGSTEPTIME,
TR_WALKSTEPTICS,
TR_RUNSTEPTICS,
TR_LEFTSTEPSOUNDS,
TR_RIGHTSTEPSOUNDS,
TR_LIQUID,
TR_FRICTION,
TR_ALLOWPROTECTION
TR_ALLOWPROTECTION,
TR_STEPSOUNDS
};
enum EGenericType
@ -179,14 +180,15 @@ static const char *TerrainKeywords[] =
"damagetimemask",
"footclip",
"stepvolume",
"walkingsteptime",
"runningsteptime",
"walksteptics",
"runsteptics",
"leftstepsounds",
"rightstepsounds",
"liquid",
"friction",
"allowprotection",
"damageonland",
"stepsounds",
NULL
};
@ -223,6 +225,7 @@ static FGenericParse TerrainParser[] =
{ GEN_Custom, {(size_t)ParseFriction} },
{ GEN_Bool, {myoffsetof(FTerrainDef, AllowProtection)} },
{ GEN_Bool, {myoffsetof(FTerrainDef, DamageOnLand)} },
{ GEN_Sound, {myoffsetof(FTerrainDef, StepSound)} },
};
@ -599,7 +602,7 @@ static void GenericParse (FScanner &sc, FGenericParse *parser, const char **keyw
case GEN_Time:
sc.MustGetFloat ();
SET_FIELD (int, (int)(sc.Float * TICRATE));
SET_FIELD (int, (int)(sc.Float));
break;
case GEN_Bool:
@ -747,3 +750,4 @@ DEFINE_FIELD(FTerrainDef, AllowProtection)
DEFINE_FIELD(FTerrainDef, DamageOnLand)
DEFINE_FIELD(FTerrainDef, Friction)
DEFINE_FIELD(FTerrainDef, MoveFactor)
DEFINE_FIELD(FTerrainDef, StepSound)

View file

@ -118,6 +118,7 @@ struct FTerrainDef
bool DamageOnLand;
double Friction;
double MoveFactor;
FSoundID StepSound;
};
extern TArray<FSplashDef> Splashes;

View file

@ -352,7 +352,7 @@ void P_TraceBleed (int damage, AActor *target, AActor *missile); // missile ver
void P_TraceBleed(int damage, FTranslatedLineTarget *t, AActor *puff); // hitscan version
void P_TraceBleed (int damage, AActor *target); // random direction version
bool P_HitFloor (AActor *thing);
bool P_HitWater (AActor *thing, sector_t *sec, const DVector3 &pos, bool checkabove = false, bool alert = true, bool force = false);
bool P_HitWater (AActor *thing, sector_t *sec, const DVector3 &pos, bool checkabove = false, bool alert = true, bool force = false, int flags = 0);
struct FRailParams

View file

@ -6631,7 +6631,13 @@ int P_GetThingFloorType (AActor *thing)
// Returns true if hit liquid and splashed, false if not.
//---------------------------------------------------------------------------
bool P_HitWater (AActor * thing, sector_t * sec, const DVector3 &pos, bool checkabove, bool alert, bool force)
enum HitWaterFlags
{
THW_SMALL = 1 << 0,
THW_NOVEL = 1 << 1,
};
bool P_HitWater (AActor * thing, sector_t * sec, const DVector3 &pos, bool checkabove, bool alert, bool force, int flags)
{
if (thing->player && (thing->player->cheats & CF_PREDICTING))
return false;
@ -6719,13 +6725,13 @@ foundone:
// Don't splash for living things with small vertical velocities.
// There are levels where the constant splashing from the monsters gets extremely annoying
if (((thing->flags3&MF3_ISMONSTER || thing->player) && thing->Vel.Z >= -6) && !force)
if (!(flags & THW_NOVEL) && ((thing->flags3 & MF3_ISMONSTER || thing->player) && thing->Vel.Z >= -6) && !force)
return Terrains[terrainnum].IsLiquid;
splash = &Splashes[splashnum];
// Small splash for small masses
if (thing->Mass < 10)
if (flags & THW_SMALL || thing->Mass < 10)
smallsplash = true;
if (!(thing->flags3 & MF3_DONTSPLASH))
@ -6790,7 +6796,8 @@ DEFINE_ACTION_FUNCTION(AActor, HitWater)
PARAM_BOOL(checkabove);
PARAM_BOOL(alert);
PARAM_BOOL(force);
ACTION_RETURN_BOOL(P_HitWater(self, sec, DVector3(x, y, z), checkabove, alert, force));
PARAM_INT(flags);
ACTION_RETURN_BOOL(P_HitWater(self, sec, DVector3(x, y, z), checkabove, alert, force, flags));
}

View file

@ -773,7 +773,7 @@ class Actor : Thinker native
native Actor SpawnPuff(class<Actor> pufftype, vector3 pos, double hitdir, double particledir, int updown, int flags = 0, Actor victim = null);
native void SpawnBlood (Vector3 pos1, double dir, int damage);
native void BloodSplatter (Vector3 pos, double hitangle, bool axe = false);
native bool HitWater (sector sec, Vector3 pos, bool checkabove = false, bool alert = true, bool force = false);
native bool HitWater (sector sec, Vector3 pos, bool checkabove = false, bool alert = true, bool force = false, int flags = 0);
native void PlaySpawnSound(Actor missile);
native clearscope bool CountsAsKill() const;

View file

@ -87,6 +87,8 @@ class PlayerPawn : Actor
flagdef CanSuperMorph: PlayerFlags, 1;
flagdef CrouchableMorph: PlayerFlags, 2;
flagdef WeaponLevel2Ended: PlayerFlags, 3;
//PF_VOODOO_ZOMBIE
flagdef MakeFootsteps: PlayerFlags, 5; //[inkoalawetrust] Use footstep system virtual.
enum EPrivatePlayerFlags
{
@ -1690,6 +1692,7 @@ class PlayerPawn : Actor
CheckPitch();
HandleMovement();
CalcHeight ();
if (bMakeFootsteps) MakeFootsteps();
if (!(player.cheats & CF_PREDICTING))
{
@ -1718,6 +1721,48 @@ class PlayerPawn : Actor
}
}
//---------------------------------------------------------------------------
//
// Handle player footstep sounds.
// Default footstep handling.
//
//---------------------------------------------------------------------------
virtual void MakeFootsteps()
{
if (pos.z > floorz) return;
let Ground = GetFloorTerrain();
let cmd = player.cmd;
if (Ground && (cmd.forwardMove != 0 || cmd.sideMove != 0))
{
bool Running = (cmd.buttons & BT_RUN); //Holding down run key, or it's toggled.
int Delay = !Running ? Ground.WalkStepTics : Ground.RunStepTics;
if (Delay <= 0 || GetAge() % Delay != 0) return;
Sound Step = Ground.StepSound;
//Generic foot-agnostic sound takes precedence.
if (!Step)
{
//Apparently most people walk with their right foot first, so assume that here.
if (GetAge() % (Delay*2) == 0)
Step = Ground.LeftStepSound;
else
Step = Ground.RightStepSound;
}
if (Step)
A_StartSound (Step,flags:CHANF_OVERLAP,volume:Ground.StepVolume);
//Steps make splashes regardless.
bool Heavy = Mass >= 200 ? 0 : THW_SMALL; //Big player makes big splash.
HitWater (CurSector,(Pos.XY,CurSector.FloorPlane.ZatPoint(Pos.XY)),True,False,flags:Heavy|THW_NOVEL);
}
}
//---------------------------------------------------------------------------
//
// PROC P_BringUpWeapon

View file

@ -1466,6 +1466,12 @@ enum ECompatFlags
COMPATF2_VOODOO_ZOMBIES = 1 << 15, // allow playerinfo, playerpawn, and voodoo health to all be different, and allow monster targetting of 'dead' players that have positive health
};
enum HitWaterFlags
{
THW_SMALL = 1 << 0,
THW_NOVEL = 1 << 1,
};
const M_E = 2.7182818284590452354; // e
const M_LOG2E = 1.4426950408889634074; // log_2 e
const M_LOG10E = 0.43429448190325182765; // log_10 e

View file

@ -613,6 +613,7 @@ struct TerrainDef native
native bool DamageOnLand;
native double Friction;
native double MoveFactor;
native Sound StepSound;
};
enum EPickStart