Rage through 32 single player levels and 6 deathmatch levels of sheer terror and fully immersive sound and lighting. Arm yourself against the cannibalistic Ogre, fiendish Vore and indestructible Schambler using lethal nails, fierce Thunderbolts and abominable Rocket and Grenade Launchers.

Post tutorial Report RSS Footsteps in DarkPlaces

Want footsteps in q1? Want the sounds to depend on type of ground walking on? Keep on reading then.

Posted by on - Basic Server Side Coding

[page=Introduction]
One noticable thing about quake1 is that you cant hear any footsteps. The most of mods that use footstep-sounds have the same thumping sound no matter what type of ground you are walking on.
This tutor will add texture-based sounds :)

[page=The code]
Lets get down to buissnes.

player.qc
Add the following code before void player_run

void(entity e) walksound ={
	local float surfnum, r;
	local string s;

	makevectors(e.v_angle);

	surfnum = getsurfacenearpoint(world, e.origin - '0 0 24');
	if (surfnum >= 0)
	{
		s = getsurfacetexture(world, surfnum);
		if (s == "wizmet1_2")
		{
			bprint("play metal\n");
			r = rint(random() * 3);			
			if (r == 0)
				sound (e, CHAN_AUTO, "walk/metal1.wav", 0.5, ATTN_NORM);
			else if (r == 1)
				sound (e, CHAN_AUTO, "walk/metal2.wav", 0.5, ATTN_NORM);
			else if (r == 2)
				sound (e, CHAN_AUTO, "walk/metal3.wav", 0.5, ATTN_NORM);
			else
				sound (e, CHAN_AUTO, "walk/metal4.wav", 0.5, ATTN_NORM);
		}
		else
		{
			bprint("play generic\n");
			r = rint(random() * 4);			
			if (r == 0)
				sound (e, CHAN_AUTO, "walk/generic1.wav", 0.5, ATTN_NORM);
			else if (r == 1)
				sound (e, CHAN_AUTO, "walk/generic2.wav", 0.5, ATTN_NORM);
			else if (r == 2)
				sound (e, CHAN_AUTO, "walk/generic3.wav", 0.5, ATTN_NORM);
			else if (r == 3)
				sound (e, CHAN_AUTO, "walk/generic4.wav", 0.5, ATTN_NORM);
			else
				sound (e, CHAN_AUTO, "walk/generic5.wav", 0.5, ATTN_NORM);
		}
	}
};

in void player_run find

void()	player_run =[	$rockrun1,	player_run	]
{

and add the following code directly after it

if (self.walkframe == 1 || self.walkframe == 4 )
		if (checkbottom(self) == TRUE)
			if (self.waterlevel == 0)
				walksound (self);

world.qc
find

precache_sound ("misc/water1.wav");			// swimming
	precache_sound ("misc/water2.wav");			// swimming

and add after that

precache_sound ("walk/generic1.wav");      
	precache_sound ("walk/generic2.wav");      
	precache_sound ("walk/generic3.wav");      
	precache_sound ("walk/generic4.wav");
	precache_sound ("walk/generic5.wav");
	precache_sound ("walk/metal1.wav");      
	precache_sound ("walk/metal2.wav");      
	precache_sound ("walk/metal3.wav");      
	precache_sound ("walk/metal4.wav");      

defs.qc
in bottom of defs.qc add

//DP_QC_GETSURFACE
//idea: LordHavoc
//darkplaces implementation: LordHavoc
//builtin definitions:
float(entity e, float s) getsurfacenumpoints = #434;
vector(entity e, float s, float n) getsurfacepoint = #435;
vector(entity e, float s) getsurfacenormal = #436;
string(entity e, float s) getsurfacetexture = #437;
float(entity e, vector p) getsurfacenearpoint = #438;
vector(entity e, float s, vector p) getsurfaceclippedpoint = #439;
//description:
//functions to query surface information.

(or use dpmods own extensions qc file)

[page=How it works]
void walksound basicly checks what texture the player is standing on, and depending on the texture emits the apropriate sound.

For this to work you will need some sounds. You can make your own or use some sounds from another game. Rename them and place them in the apropriate directory to match:
* walk/generic1.wav
* walk/generic2.wav
* walk/generic2.wav
* walk/generic2.wav
* walk/generic2.wav
For generic footstep sounds, and ...
* walk/metal1.wav
* walk/metal2.wav
* walk/metal3.wav
* walk/metal4.wav
... for sounds of walking on metal surfaces.

You can use this function to do alot of stuff with some tweeking. I made texture-based ricoche sounds for a q1 cs mod :)

[page=Credits]
LordHavoc :: DarkPlaces engine and the extensions
Ze0 :: Footsteps Tutorial on Inside3D
MauveBib :: Mentioned the extention through irc
Me :: Experimenting and writing about it
---
Mail/msn: ego@babiestastegood.com

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Follow Report Profile
Icon
Quake
Platforms
Windows, Mac, Linux, DOS, N64, DC
Developer & Publisher
id Software
Engine
Quake Engine
Contact
Send Message
Homepage
Idsoftware.com
Release date
Game watch
Follow
Tutorial
Browse
Tutorials
Report
Report
Share
Related Games
Quake
Quake First Person Shooter
Related Engines
Quake Engine
Quake Engine GPL
Related Groups
id Software
id Software Developer & Publisher