[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4787: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4789: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4790: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4791: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
InsideQC Forums • View topic - Footsteps on different materials

Footsteps on different materials

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Footsteps on different materials

Postby jim » Thu Jun 12, 2008 5:13 pm

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!
User avatar
jim
 
Posts: 599
Joined: Fri Aug 05, 2005 2:35 pm
Location: In The Sun

Re: Footsteps on different materials

Postby xaGe » Mon Jun 16, 2008 1:30 pm

User avatar
xaGe
 
Posts: 462
Joined: Wed Mar 01, 2006 8:29 am
Location: Upstate, New York

Postby Freemanoid » Thu Jun 26, 2008 6:03 pm

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^
Freemanoid
 
Posts: 52
Joined: Mon Jun 16, 2008 11:25 am
Location: BELARUS

Postby RenegadeC » Sat Jun 28, 2008 6:13 am

User avatar
RenegadeC
 
Posts: 391
Joined: Fri Oct 15, 2004 10:19 pm
Location: The freezing hell; Canada


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 2 guests