Inside3D!
     

Footsteps on different materials

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
jim



Joined: 05 Aug 2005
Posts: 400
Location: In The Sun

PostPosted: Thu Jun 12, 2008 5:13 pm    Post subject: Footsteps on different materials Reply with quote

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?
_________________
zbang!
Back to top
View user's profile Send private message Visit poster's website
xaGe



Joined: 01 Mar 2006
Posts: 329
Location: Upstate, New York

PostPosted: Mon Jun 16, 2008 1:30 pm    Post subject: Re: Footsteps on different materials Reply with quote

..Good question! At worst you could use a another naming convention... bbase_01.ogg, mbase_01.ogg, sbase_01.ogg, etc...
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Freemanoid



Joined: 16 Jun 2008
Posts: 52
Location: BELARUS

PostPosted: Thu Jun 26, 2008 6:03 pm    Post subject: Reply with quote

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
_________________
^O,..,o^
Back to top
View user's profile Send private message Visit poster's website
RenegadeC



Joined: 15 Oct 2004
Posts: 370
Location: The freezing hell; Canada

PostPosted: Sat Jun 28, 2008 6:13 am    Post subject: Reply with quote

That should be in a tutorial on here Smile
Back to top
View user's profile Send private message AIM Address MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group