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.

Report article Footsteps in DarkPlaces

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

Posted by DarkSnow on Jun 6th, 2005 digg this super bookmark
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

  1. code:
  1. void(entity e) walksound ={
  2.   local float surfnum, r;
  3.   local string s;
  4.  
  5.   makevectors(e.v_angle);
  6.  
  7.   surfnum = getsurfacenearpoint(world, e.origin - '0 0 24');
  8.   if (surfnum >= 0)
  9.   {
  10.     s = getsurfacetexture(world, surfnum);
  11.     if (s == "wizmet1_2")
  12.     {
  13.       bprint("play metal\n");
  14.       r = rint(random() * 3);     
  15.       if (r == 0)
  16.         sound (e, CHAN_AUTO, "walk/metal1.wav", 0.5, ATTN_NORM);
  17.       else if (r == 1)
  18.         sound (e, CHAN_AUTO, "walk/metal2.wav", 0.5, ATTN_NORM);
  19.       else if (r == 2)
  20.         sound (e, CHAN_AUTO, "walk/metal3.wav", 0.5, ATTN_NORM);
  21.       else
  22.         sound (e, CHAN_AUTO, "walk/metal4.wav", 0.5, ATTN_NORM);
  23.     }
  24.     else
  25.     {
  26.       bprint("play generic\n");
  27.       r = rint(random() * 4);     
  28.       if (r == 0)
  29.         sound (e, CHAN_AUTO, "walk/generic1.wav", 0.5, ATTN_NORM);
  30.       else if (r == 1)
  31.         sound (e, CHAN_AUTO, "walk/generic2.wav", 0.5, ATTN_NORM);
  32.       else if (r == 2)
  33.         sound (e, CHAN_AUTO, "walk/generic3.wav", 0.5, ATTN_NORM);
  34.       else if (r == 3)
  35.         sound (e, CHAN_AUTO, "walk/generic4.wav", 0.5, ATTN_NORM);
  36.       else
  37.         sound (e, CHAN_AUTO, "walk/generic5.wav", 0.5, ATTN_NORM);
  38.     }
  39.   }
  40. };
  41.  

in void player_run find

  1. code:
  1. void() player_run =[ $rockrun1,  player_run  ]
  2. {
  3.  

and add the following code directly after it

  1. code:
  1. if (self.walkframe == 1 || self.walkframe == 4 )
  2.     if (checkbottom(self) == TRUE)
  3.       if (self.waterlevel == 0)
  4.         walksound (self);
  5.  

world.qc
find

  1. code:
  1. precache_sound ("misc/water1.wav");      // swimming
  2.   precache_sound ("misc/water2.wav");      // swimming
  3.  

and add after that

  1. code:
  1. precache_sound ("walk/generic1.wav");      
  2.   precache_sound ("walk/generic2.wav");      
  3.   precache_sound ("walk/generic3.wav");      
  4.   precache_sound ("walk/generic4.wav");
  5.   precache_sound ("walk/generic5.wav");
  6.   precache_sound ("walk/metal1.wav");      
  7.   precache_sound ("walk/metal2.wav");      
  8.   precache_sound ("walk/metal3.wav");      
  9.   precache_sound ("walk/metal4.wav");      
  10.  

defs.qc
in bottom of defs.qc add

  1. code:
  1. //DP_QC_GETSURFACE
  2. //idea: LordHavoc
  3. //darkplaces implementation: LordHavoc
  4. //builtin definitions:
  5. float(entity e, float s) getsurfacenumpoints = #434;
  6. vector(entity e, float s, float n) getsurfacepoint = #435;
  7. vector(entity e, float s) getsurfacenormal = #436;
  8. string(entity e, float s) getsurfacetexture = #437;
  9. float(entity e, vector p) getsurfacenearpoint = #438;
  10. vector(entity e, float s, vector p) getsurfaceclippedpoint = #439;
  11. //description:
  12. //functions to query surface information.
  13.  

(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

Only registered members can share their thoughts. So come on! Join the community today (totally free) and do things you never thought possible.

Icon
Quake
Platforms
PC, Linux, Mac, DC, N64, DOS
Developer & Publisher
id Software
Engine
Quake Engine
Contact
Send Message
Official Page
Idsoftware.com
Release Date
Released Jun 19, 1996
Game Watch
Track this game
Bookmark
Digg Super bookmark
Tutorial
Browse
Tutorials
Report Abuse
Report article
Bookmark
Digg Super bookmark
Related Games
Quake
Quake
Single & Multiplayer First Person Shooter