Footsteps on different materials
Moderator: InsideQC Admins
4 posts
• Page 1 of 1
Footsteps on different materials
I've decided to switch into using q3 map, texture, etc format, so now I can have longer texture names and place them in folders.
This not really coding about anything yet, more just how to name the textures/materials...
I decided I'll put them in folders like this:
brick
metal
steel
earth
liquid
tech
What if I have a brick texture named: base_01 and a metal texture named base_01... Is the full texture name then brick/base_01 and for the other metal/base_01?
If I then make some code that checks if the texture name starts with brick, metal, etc.. then play the brick sounds or metal sounds, would it work, or would it interpret both textures as base_01 and play no sounds or some default sound for undefined materials?
This not really coding about anything yet, more just how to name the textures/materials...
I decided I'll put them in folders like this:
brick
metal
steel
earth
liquid
tech
What if I have a brick texture named: base_01 and a metal texture named base_01... Is the full texture name then brick/base_01 and for the other metal/base_01?
If I then make some code that checks if the texture name starts with brick, metal, etc.. then play the brick sounds or metal sounds, would it work, or would it interpret both textures as base_01 and play no sounds or some default sound for undefined materials?
zbang!
-

jim - Posts: 599
- Joined: Fri Aug 05, 2005 2:35 pm
- Location: In The Sun
Re: Footsteps on different materials
..Good question! At worst you could use a another naming convention... bbase_01.ogg, mbase_01.ogg, sbase_01.ogg, etc...
-

xaGe - Posts: 461
- Joined: Wed Mar 01, 2006 8:29 am
- Location: Upstate, New York
I see tutorial in QuakeDev, by DarkSnow.
Maby this help you :
Difficulity: Easy/Human readable
For: DarkPlaces (Quake1)
Alright, after a long conversation with LordHavoc the pieces of the puzzle finaly came together. About 5 minutes ago i tweaked around the last parts of the code and as by a miracle it worked superb
The following code is qc only, for darkplaces engine. If you want this in your own engine then you will have to copy various stuff from darkplaces to make it work.
When you walk around, you will hear a generic footstep sound, until you walk on metal - and *poff* - you will her footsteps on metal insted of generic, without using triggers in the map. It checks what texture the player is standing on basicly, and if it is (for this snippet) the wizmetal texture (normal skill bridge map "start") the sound will be walk/metal1*4 instead of generic.
So if anyone havent gotten this to work yet, but want it - here it is
player.qc
add the following code before void player_run
Code:
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);
}
}
};
This is the interesting part all in all. First the code "contacts" the game engine and recive the name of the texture the player is standing on. If that texture is named "wizmet1_2" it will play one of the metal sounds, else it will play one of the generic sounds.
in void player_run find
Code:
void() player_run =[ $rockrun1, player_run ]
{
and add the following code directly after it
Code:
if (self.walkframe == 1 || self.walkframe == 4 )
if (checkbottom(self) == TRUE)
if (self.waterlevel == 0)
walksound (self);
world.qc
find
Code:
precache_sound ("misc/water1.wav"); // swimming
precache_sound ("misc/water2.wav"); // swimming
and add after that
Code:
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
Code:
//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)
The final thing,
you have to create a new folder - \modname\sound\walk
and add the sound files there. (sound files from half-life - copyright)
There is room for improvements
Credits
LordHavoc :: Engine and the extensions
Ze0 :: Footsteps Tutorial on Inside3D
MauveBib :: Mentioned the extention
Me :: Experimenting and writing about it
Maby this help you :
Difficulity: Easy/Human readable
For: DarkPlaces (Quake1)
Alright, after a long conversation with LordHavoc the pieces of the puzzle finaly came together. About 5 minutes ago i tweaked around the last parts of the code and as by a miracle it worked superb
The following code is qc only, for darkplaces engine. If you want this in your own engine then you will have to copy various stuff from darkplaces to make it work.
When you walk around, you will hear a generic footstep sound, until you walk on metal - and *poff* - you will her footsteps on metal insted of generic, without using triggers in the map. It checks what texture the player is standing on basicly, and if it is (for this snippet) the wizmetal texture (normal skill bridge map "start") the sound will be walk/metal1*4 instead of generic.
So if anyone havent gotten this to work yet, but want it - here it is
player.qc
add the following code before void player_run
Code:
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);
}
}
};
This is the interesting part all in all. First the code "contacts" the game engine and recive the name of the texture the player is standing on. If that texture is named "wizmet1_2" it will play one of the metal sounds, else it will play one of the generic sounds.
in void player_run find
Code:
void() player_run =[ $rockrun1, player_run ]
{
and add the following code directly after it
Code:
if (self.walkframe == 1 || self.walkframe == 4 )
if (checkbottom(self) == TRUE)
if (self.waterlevel == 0)
walksound (self);
world.qc
find
Code:
precache_sound ("misc/water1.wav"); // swimming
precache_sound ("misc/water2.wav"); // swimming
and add after that
Code:
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
Code:
//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)
The final thing,
you have to create a new folder - \modname\sound\walk
and add the sound files there. (sound files from half-life - copyright)
There is room for improvements
Credits
LordHavoc :: Engine and the extensions
Ze0 :: Footsteps Tutorial on Inside3D
MauveBib :: Mentioned the extention
Me :: Experimenting and writing about it
^O,..,o^
- Freemanoid
- Posts: 52
- Joined: Mon Jun 16, 2008 11:25 am
- Location: BELARUS
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: Bing [Bot] and 1 guest