Prop Footsteps: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
 
No edit summary
 
(25 intermediate revisions by 12 users not shown)
Line 1: Line 1:
For player footsteps, Valve used <code>MASK_PLAYERSOLID_BRUSHONLY</code> rather than <code>MASK_PLAYERSOLID</code>. This difference made it so only the static world would have dynamic footsteps. The following precedure will show how to fix this issue.
{{important|This issue has been resolved in the Half-Life 2: Episode Two codebase; if you are using its code, you should not try to implement this mod.}}
 
For player footsteps, Valve used <code>[[MASK_PLAYERSOLID_BRUSHONLY]]</code> rather than <code>[[MASK_PLAYERSOLID]]</code>. This difference made it so only the static world would have dynamic footsteps. The following precedure will show how to fix this issue.
{{note|This will not make any difference if <code>PlayStepSound</code> is overridden by the player entity (i.e. HL2MP).}}
==Basic Fix==
===src\cl_dll\c_baseplayer.cpp===
===src\cl_dll\c_baseplayer.cpp===
<dl><dd>
====Shift Trace Start Up====
====Shift Start Up====
{|style="background:transparent;"
{|style="background:transparent;"
|<pre style="margin:0px 0px 0px 0px;"> // Straight down
|<pre style="margin:0px 0px 0px 0px;"> // Straight down
end.z -= 64;</pre>
end.z -= 64;</pre>
| &rarr;
|
|<pre style="margin:0px 0px 0px 0px;"> // Straight down
|<pre style="margin:0px 0px 0px 0px;"> // Straight down
start.z += 1;
start.z += 1;
end.z -= 64;</pre>
end.z -= 64;</pre>
|}
====Smaller Trace Box Height====
{|style="background:transparent;"
|<pre style="margin:0px 0px 0px 0px;"> Ray_t ray;
ray.Init( start, end, GetPlayerMins(), GetPlayerMaxs() );</pre>
|-
|style="text-align:center;"|↓
|-
|<pre style="margin:0px 0px 0px 0px;"> Ray_t ray;
Vector mins = GetPlayerMins();
Vector maxs = GetPlayerMaxs();
maxs.z = mins.z + 1;
ray.Init( start, end, mins, maxs);</pre>
|}
|}
====Change Trace Mask====
====Change Trace Mask====
Line 15: Line 31:
|<pre style="margin:0px 0px 0px 0px;"> UTIL_TraceRay( ray, MASK_PLAYERSOLID_BRUSHONLY, this, COLLISION_GROUP_PLAYER_MOVEMENT, &trace );</pre>
|<pre style="margin:0px 0px 0px 0px;"> UTIL_TraceRay( ray, MASK_PLAYERSOLID_BRUSHONLY, this, COLLISION_GROUP_PLAYER_MOVEMENT, &trace );</pre>
|-
|-
|style="text-align:center;"|&darr;
|style="text-align:center;"|
|-
|-
|<pre style="margin:0px 0px 0px 0px;"> UTIL_TraceRay( ray, MASK_PLAYERSOLID, this, COLLISION_GROUP_PLAYER_MOVEMENT, &trace );</pre>
|<pre style="margin:0px 0px 0px 0px;"> UTIL_TraceRay( ray, MASK_PLAYERSOLID, this, COLLISION_GROUP_PLAYER_MOVEMENT, &trace );</pre>
|}
|}
</dd></dl>
===src\game_shared\gamemovement.cpp===
===src\game_shared\gamemovement.cpp===
<dl><dd>
====Shift Trace Start Up====
====Shift Start Up====
{|style="background:transparent;"
{|style="background:transparent;"
|<pre style="margin:0px 0px 0px 0px;"> // Straight down
|<pre style="margin:0px 0px 0px 0px;"> // Straight down
end[2] -= 64;</pre>
end[2] -= 64;</pre>
| &rarr;
|
|<pre style="margin:0px 0px 0px 0px;"> // Straight down
|<pre style="margin:0px 0px 0px 0px;"> // Straight down
start[2] += 1;
start[2] += 1;
end[2] -= 64;</pre>
end[2] -= 64;</pre>
|}
|}
====Change Trace Mask====
====Smaller Trace Box Height & Change Trace Mask====
{|style="background:transparent;"
{|style="background:transparent;"
|<pre style="margin:0px 0px 0px 0px;"> TracePlayerBBox( start, end, MASK_PLAYERSOLID_BRUSHONLY, COLLISION_GROUP_PLAYER_MOVEMENT, trace );  
|<pre style="margin:0px 0px 0px 0px;"> TracePlayerBBox( start, end, MASK_PLAYERSOLID_BRUSHONLY, COLLISION_GROUP_PLAYER_MOVEMENT, trace );</pre>
</pre>
|-
|-
|style="text-align:center;"|&darr;
|style="text-align:center;"|
|-
|<pre style="margin:0px 0px 0px 0px;"> Ray_t ray;
Vector mins = player->GetPlayerMins();
Vector maxs = player->GetPlayerMaxs();
maxs.z = mins.z + 1;
ray.Init( start, end, mins, maxs);
UTIL_TraceRay( ray, MASK_PLAYERSOLID, player, COLLISION_GROUP_PLAYER_MOVEMENT, &trace );</pre>
|}
 
==HL2MP Override Removal==
===src\cl_dll\hl2mp\c_hl2mp_player.h===
====Prototype Removal====
* PlayStepSound
* PrecacheFootStepSounds
===src\game_shared\hl2mp\hl2mp_player_shared.cpp===
====Symbol Removal====
* PlayStepSound
* PrecacheFootStepSounds
===src\dlls\hl2mp_dll\hl2mp_player.cpp===
====Precache====
{| class=standard-table
!colspan="2" style="text-align:center;"| In function <tt>CHL2MP_Player::Precache</tt>
|-
|-
|<pre style="margin:0px 0px 0px 0px;"> TracePlayerBBox( start, end, MASK_PLAYERSOLID, COLLISION_GROUP_PLAYER_MOVEMENT, trace );  
| Remove || <pre style="margin:0px 0px 0px 0px;"> PrecacheFootStepSounds();</pre>
</pre>
|}
|}
</dd></dl>
 
[[Category:Programming]]
===src\dlls\hl2mp_dll\hl2mp_player.h===
====Prototype Removal====
* PlayStepSound
* PrecacheFootStepSounds
 
[[Category: Programming]]

Latest revision as of 20:15, 16 March 2025

Icon-Important.pngImportant:This issue has been resolved in the Half-Life 2: Episode Two codebase; if you are using its code, you should not try to implement this mod.

For player footsteps, Valve used MASK_PLAYERSOLID_BRUSHONLY rather than MASK_PLAYERSOLID. This difference made it so only the static world would have dynamic footsteps. The following precedure will show how to fix this issue.

Note.pngNote:This will not make any difference if PlayStepSound is overridden by the player entity (i.e. HL2MP).

Basic Fix

src\cl_dll\c_baseplayer.cpp

Shift Trace Start Up

	// Straight down
	end.z -= 64;
	// Straight down
	start.z += 1;
	end.z -= 64;

Smaller Trace Box Height

	Ray_t ray;
	ray.Init( start, end, GetPlayerMins(), GetPlayerMaxs() );
	Ray_t ray;
	Vector mins = GetPlayerMins();
	Vector maxs = GetPlayerMaxs();
	maxs.z = mins.z + 1;
	ray.Init( start, end, mins, maxs);

Change Trace Mask

	UTIL_TraceRay( ray, MASK_PLAYERSOLID_BRUSHONLY, this, COLLISION_GROUP_PLAYER_MOVEMENT, &trace );
	UTIL_TraceRay( ray, MASK_PLAYERSOLID, this, COLLISION_GROUP_PLAYER_MOVEMENT, &trace );

src\game_shared\gamemovement.cpp

Shift Trace Start Up

	// Straight down
	end[2] -= 64;
	// Straight down
	start[2] += 1;
	end[2] -= 64;

Smaller Trace Box Height & Change Trace Mask

	TracePlayerBBox( start, end, MASK_PLAYERSOLID_BRUSHONLY, COLLISION_GROUP_PLAYER_MOVEMENT, trace );
	Ray_t ray;
	Vector mins = player->GetPlayerMins();
	Vector maxs = player->GetPlayerMaxs();
	maxs.z = mins.z + 1;
	ray.Init( start, end, mins, maxs);
	UTIL_TraceRay( ray, MASK_PLAYERSOLID, player, COLLISION_GROUP_PLAYER_MOVEMENT, &trace );

HL2MP Override Removal

src\cl_dll\hl2mp\c_hl2mp_player.h

Prototype Removal

  • PlayStepSound
  • PrecacheFootStepSounds

src\game_shared\hl2mp\hl2mp_player_shared.cpp

Symbol Removal

  • PlayStepSound
  • PrecacheFootStepSounds

src\dlls\hl2mp_dll\hl2mp_player.cpp

Precache

In function CHL2MP_Player::Precache
Remove
	PrecacheFootStepSounds();

src\dlls\hl2mp_dll\hl2mp_player.h

Prototype Removal

  • PlayStepSound
  • PrecacheFootStepSounds