Skip to content

Commit

Permalink
Added generic StepSound TERRAIN property.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
inkoalawetrust authored and madame-rachelle committed Oct 14, 2024
1 parent 8a410ba commit b0b58f4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/gamedata/p_terrain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ enum ETerrainKeywords
TR_RIGHTSTEPSOUNDS,
TR_LIQUID,
TR_FRICTION,
TR_ALLOWPROTECTION
TR_ALLOWPROTECTION,
TR_STEPSOUNDS
};

enum EGenericType
Expand Down Expand Up @@ -187,6 +188,7 @@ static const char *TerrainKeywords[] =
"friction",
"allowprotection",
"damageonland",
"stepsounds",
NULL
};

Expand Down Expand Up @@ -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)} },
};


Expand Down Expand Up @@ -747,3 +750,4 @@ DEFINE_FIELD(FTerrainDef, AllowProtection)
DEFINE_FIELD(FTerrainDef, DamageOnLand)
DEFINE_FIELD(FTerrainDef, Friction)
DEFINE_FIELD(FTerrainDef, MoveFactor)
DEFINE_FIELD(FTerrainDef, StepSound)
1 change: 1 addition & 0 deletions src/gamedata/p_terrain.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ struct FTerrainDef
bool DamageOnLand;
double Friction;
double MoveFactor;
FSoundID StepSound;
};

extern TArray<FSplashDef> Splashes;
Expand Down
9 changes: 9 additions & 0 deletions wadsrc/static/zscript/actors/player/player.zs
Original file line number Diff line number Diff line change
Expand Up @@ -1742,6 +1742,15 @@ class PlayerPawn : Actor

if (Delay <= 0) return;

//Generic foot-agnostic sound takes precedence.
if (Ground.StepSound && GetAge() % Delay == 0)
{
A_StartSound (Ground.StepSound,flags:CHANF_OVERLAP,volume:Ground.StepVolume);
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);
return;
}

//Apparently most people walk with their right foot first, so assume that here.
bool LeftStep; //Prevent the right step playing twice.
if (GetAge() % (Delay*2) == 0)
Expand Down
1 change: 1 addition & 0 deletions wadsrc/static/zscript/doombase.zs
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ struct TerrainDef native
native bool DamageOnLand;
native double Friction;
native double MoveFactor;
native Sound StepSound;
};

enum EPickStart
Expand Down

0 comments on commit b0b58f4

Please sign in to comment.