Environmet based footsteps (simulator)
Moderator: InsideQC Admins
8 posts
• Page 1 of 1
Environmet based footsteps (simulator)
hello friends.
I created a code for a function to simulate textures for the footsteps. If you walk into the normal floor, the engine plays sounds of current footsteps. But if you walk on the functions, the engine plays sounds for each function.
This function is very useful for creating the necessary environment (for example) a horror mod. Although it is laborious for the mapping, the result is very good and atmospheric mainly because you can create several different simulators are run on the bsp of quake 1.
I tested the function in DOS quake, Qrack, Fitzquake, Winquake and some older versions of Darkplaces (the newest 2006, but I do not know which version) and it works perfectly.
But I have problems in the latest version of Darkplaces, the function does not work correctly.
I wanted someone to help me.
Here is my tutorial, I added only a single function (func metal) because it was too long with 12 functions that I use in my mod "wasste. "
I hope to get help with my code and the texture´s simulator will serve someone .
new code
normal code
Here is my tutorial
you remember that YOU NEED 4 new wavs, two for normal footsteps and 2 for the footstep of the metal texture.
you place the 4 wavs in sound/player
they are:
alk2.wav alk1.wav and (for the normal footsteps)
met.wav met1.wav (for footsteps on metal)
do not forget to precache it in world.qc
Well now creates a new file called "textures.qc"
and copy this
.float onmetal;
.float onmetal2;
.float texs;
float TX_METAL = 2; // for metal
void() vmetal =
{
if ((other.flags & FL_CLIENT)) // code for Nahuel
{
other.onmetal = TRUE;
other.texs = other.texs | TX_METAL;
}
};
void () func_metal = // code for Nahuel
{
self.mangle = self.angles;
self.angles = '0 0 0';
self.solid = SOLID_BSP;
self.movetype = MOVETYPE_PUSH;
self.classname = "metal";
setmodel (self, self.model);
setorigin (self, self.origin);
self.touch = vmetal;
};
.float nextfootstep2;
void() playerfootstep = //Thanks Darksnow for this function, I modified it
{
local float r;
if (self.deadflag) // not walking dead...
return;
if (!(self.flags & FL_ONGROUND))
return;
if (self.texs & TX_METAL)
return;
if (vlen(self.velocity) < 300)
return;
if (time < self.nextfootstep2)
return;
if (!(self.flags & FL_ONGROUND))
return;
self.nextfootstep2 = time + (0.3);
r = random() * 2;
// ATTN_IDLE to make them short range
if (r < 1) sound(self, CHAN_VOICE, "player/alk1.wav", 1.0, ATTN_IDLE);
else sound(self, CHAN_VOICE, "player/alk2.wav", 1.0, ATTN_IDLE);
return;
};
void() playerfootstepl = //Thanks Darksnow for this function, I modified it
{
local float r;
if (self.deadflag) // not walking dead...
return;
if (!(self.flags & FL_ONGROUND))
return;
if (self.texs & TX_METAL)
return;
if (self.waterlevel >= 3)
return;
if (vlen(self.velocity) > 300)
return;
if (vlen(self.velocity) < 50)
return;
if (!(self.flags & FL_ONGROUND))
return;
if (self.texs & TX_METAL)
return;
if (time < self.nextfootstep2)
return;
self.nextfootstep2 = time + 0.5;
r = random() * 2;
// ATTN_IDLE to make them short range
if (r < 1) sound(self, CHAN_VOICE, "player/alk1.wav", 0.65, ATTN_IDLE);
else sound(self, CHAN_VOICE, "player/alk2.wav", 0.65, ATTN_IDLE);
return;
};
void() playerfootstepm = //Thanks Darksnow for this function, I modified it
{
local float r;
if (self.deadflag) // not walking dead...
return;
if (!(self.flags & FL_ONGROUND))
return;
if (!(self.texs & TX_METAL))
return;
if (vlen(self.velocity) < 300)
return;
if (time < self.nextfootstep2)
return;
self.nextfootstep2 = time + 0.3;
r = random() * 2;
// ATTN_IDLE to make them short range
if (r < 1) sound(self, CHAN_VOICE, "player/met.wav", 1.0, ATTN_IDLE);
else sound(self, CHAN_VOICE, "player/met1.wav", 1.0, ATTN_IDLE);
return;
};
void() playerfootstepn = //Thanks Darksnow for this function, I modified it
{
local float r;
if (self.deadflag) // not walking dead...
return;
if (!(self.flags & FL_ONGROUND))
return;
if (!(self.texs & TX_METAL))
return;
if (vlen(self.velocity) > 300)
return;
if (vlen(self.velocity) < 50)
return;
if (time < self.nextfootstep2)
return;
self.nextfootstep2 = time + 0.5;
r = random() * 2;
// ATTN_IDLE to make them short range
if (r < 1) sound(self, CHAN_VOICE, "player/met.wav", 0.65, ATTN_IDLE);
else sound(self, CHAN_VOICE, "player/met1.wav", 0.65, ATTN_IDLE);
return;
};
save and close
now in in playerprethink client.qc
above
if (time> self.attack_finished & & self.currentammo self.weapon == 0 & &! = IT_AXE)
{
W_BestWeapon self.weapon = ();
W_SetCurrentAmmo ();
}
just put this
if (self.onmetal2)
{
self.onmetal = 0;
self.onmetal2 = FALSE;
}
now in playerpostthink
and after
if (!(self.flags & FL_ONGROUND))
self.jump_flag = self.velocity_z;
put this
if (self.texs & TX_METAL)
if (self.onmetal)
{
self.onmetal2 = TRUE;
//self.velocity = '0 0 0';
}
else
{
self.onmetal2 = FALSE;
self.texs = self.texs - TX_METAL;
self.onmetal = 0;
}
and after
CheckPowerups ();
put this
playerfootstep();
playerfootstepl();
playerfootstepm();
playerfootstepn();
save and close.
in progs.src put textures.qc before client.qc, precache the wavs in the world.qc and compile.
Create a map with a funtion calle func_metal (put some metallic texture) and run!
I created a code for a function to simulate textures for the footsteps. If you walk into the normal floor, the engine plays sounds of current footsteps. But if you walk on the functions, the engine plays sounds for each function.
This function is very useful for creating the necessary environment (for example) a horror mod. Although it is laborious for the mapping, the result is very good and atmospheric mainly because you can create several different simulators are run on the bsp of quake 1.
I tested the function in DOS quake, Qrack, Fitzquake, Winquake and some older versions of Darkplaces (the newest 2006, but I do not know which version) and it works perfectly.
But I have problems in the latest version of Darkplaces, the function does not work correctly.
I wanted someone to help me.
Here is my tutorial, I added only a single function (func metal) because it was too long with 12 functions that I use in my mod "wasste. "
I hope to get help with my code and the texture´s simulator will serve someone .
new code
normal code
Here is my tutorial
you remember that YOU NEED 4 new wavs, two for normal footsteps and 2 for the footstep of the metal texture.
you place the 4 wavs in sound/player
they are:
alk2.wav alk1.wav and (for the normal footsteps)
met.wav met1.wav (for footsteps on metal)
do not forget to precache it in world.qc
Well now creates a new file called "textures.qc"
and copy this
.float onmetal;
.float onmetal2;
.float texs;
float TX_METAL = 2; // for metal
void() vmetal =
{
if ((other.flags & FL_CLIENT)) // code for Nahuel
{
other.onmetal = TRUE;
other.texs = other.texs | TX_METAL;
}
};
void () func_metal = // code for Nahuel
{
self.mangle = self.angles;
self.angles = '0 0 0';
self.solid = SOLID_BSP;
self.movetype = MOVETYPE_PUSH;
self.classname = "metal";
setmodel (self, self.model);
setorigin (self, self.origin);
self.touch = vmetal;
};
.float nextfootstep2;
void() playerfootstep = //Thanks Darksnow for this function, I modified it
{
local float r;
if (self.deadflag) // not walking dead...
return;
if (!(self.flags & FL_ONGROUND))
return;
if (self.texs & TX_METAL)
return;
if (vlen(self.velocity) < 300)
return;
if (time < self.nextfootstep2)
return;
if (!(self.flags & FL_ONGROUND))
return;
self.nextfootstep2 = time + (0.3);
r = random() * 2;
// ATTN_IDLE to make them short range
if (r < 1) sound(self, CHAN_VOICE, "player/alk1.wav", 1.0, ATTN_IDLE);
else sound(self, CHAN_VOICE, "player/alk2.wav", 1.0, ATTN_IDLE);
return;
};
void() playerfootstepl = //Thanks Darksnow for this function, I modified it
{
local float r;
if (self.deadflag) // not walking dead...
return;
if (!(self.flags & FL_ONGROUND))
return;
if (self.texs & TX_METAL)
return;
if (self.waterlevel >= 3)
return;
if (vlen(self.velocity) > 300)
return;
if (vlen(self.velocity) < 50)
return;
if (!(self.flags & FL_ONGROUND))
return;
if (self.texs & TX_METAL)
return;
if (time < self.nextfootstep2)
return;
self.nextfootstep2 = time + 0.5;
r = random() * 2;
// ATTN_IDLE to make them short range
if (r < 1) sound(self, CHAN_VOICE, "player/alk1.wav", 0.65, ATTN_IDLE);
else sound(self, CHAN_VOICE, "player/alk2.wav", 0.65, ATTN_IDLE);
return;
};
void() playerfootstepm = //Thanks Darksnow for this function, I modified it
{
local float r;
if (self.deadflag) // not walking dead...
return;
if (!(self.flags & FL_ONGROUND))
return;
if (!(self.texs & TX_METAL))
return;
if (vlen(self.velocity) < 300)
return;
if (time < self.nextfootstep2)
return;
self.nextfootstep2 = time + 0.3;
r = random() * 2;
// ATTN_IDLE to make them short range
if (r < 1) sound(self, CHAN_VOICE, "player/met.wav", 1.0, ATTN_IDLE);
else sound(self, CHAN_VOICE, "player/met1.wav", 1.0, ATTN_IDLE);
return;
};
void() playerfootstepn = //Thanks Darksnow for this function, I modified it
{
local float r;
if (self.deadflag) // not walking dead...
return;
if (!(self.flags & FL_ONGROUND))
return;
if (!(self.texs & TX_METAL))
return;
if (vlen(self.velocity) > 300)
return;
if (vlen(self.velocity) < 50)
return;
if (time < self.nextfootstep2)
return;
self.nextfootstep2 = time + 0.5;
r = random() * 2;
// ATTN_IDLE to make them short range
if (r < 1) sound(self, CHAN_VOICE, "player/met.wav", 0.65, ATTN_IDLE);
else sound(self, CHAN_VOICE, "player/met1.wav", 0.65, ATTN_IDLE);
return;
};
save and close
now in in playerprethink client.qc
above
if (time> self.attack_finished & & self.currentammo self.weapon == 0 & &! = IT_AXE)
{
W_BestWeapon self.weapon = ();
W_SetCurrentAmmo ();
}
just put this
if (self.onmetal2)
{
self.onmetal = 0;
self.onmetal2 = FALSE;
}
now in playerpostthink
and after
if (!(self.flags & FL_ONGROUND))
self.jump_flag = self.velocity_z;
put this
if (self.texs & TX_METAL)
if (self.onmetal)
{
self.onmetal2 = TRUE;
//self.velocity = '0 0 0';
}
else
{
self.onmetal2 = FALSE;
self.texs = self.texs - TX_METAL;
self.onmetal = 0;
}
and after
CheckPowerups ();
put this
playerfootstep();
playerfootstepl();
playerfootstepm();
playerfootstepn();
save and close.
in progs.src put textures.qc before client.qc, precache the wavs in the world.qc and compile.
Create a map with a funtion calle func_metal (put some metallic texture) and run!
hi, I am nahuel, I love quake and qc.
-

Nahuel - Posts: 492
- Joined: Wed Jan 12, 2011 8:42 pm
- Location: mar del plata
Problem with this is worldcraft will ignore whatever brush that has an entity tied to it. So you may get some problems/leaks in the level. I'd be careful with this. I also did something similar like this.
Good tutorial nonetheless
Good tutorial nonetheless
-

Mexicouger - Posts: 514
- Joined: Sat May 01, 2010 10:12 pm
Mexicouger wrote:Problem with this is worldcraft will ignore whatever brush that has an entity tied to it. So you may get some problems/leaks in the level. I'd be careful with this. I also did something similar like this.
Good tutorial nonetheless
oh, never tried it because I use quake army knife. Another option is to create a func_wall and rename it later.
but really i do not know why the latest version of Darkplaces not run this function
Another option is to use the functions in a small, occasionally put up a real floor
hi, I am nahuel, I love quake and qc.
-

Nahuel - Posts: 492
- Joined: Wed Jan 12, 2011 8:42 pm
- Location: mar del plata
My opinion is that a simple function that reads the current texture and then redirects the sounds is the best.
For example, a function that reads a texture like metal_01.tga, will apply a footstep sound of metal.
I'm not really sure if reading current texture is easy to implement.
For example, a function that reads a texture like metal_01.tga, will apply a footstep sound of metal.
I'm not really sure if reading current texture is easy to implement.
QuakeWiki
getButterfly - WordPress Support Services
Roo Holidays
Fear not the dark, but what the dark hides.
getButterfly - WordPress Support Services
Roo Holidays
Fear not the dark, but what the dark hides.
-

Chip - Posts: 575
- Joined: Wed Jan 21, 2009 9:12 am
- Location: Dublin, Ireland
of course would be less work, but I do not create such a function. I think that it would have to modify the engine, or the format of the maps (a bsp like Quake 3 but with more material). Or work as half life, rather more simple. But it is achieved, this simulator works fine now, but have problems with Darkplaces.
hi, I am nahuel, I love quake and qc.
-

Nahuel - Posts: 492
- Joined: Wed Jan 12, 2011 8:42 pm
- Location: mar del plata
My thought on this, if you want to create a mod that works with standard engines, is to place triggers in the level which indicate the current floor surface -- so in a doorway you'd have two triggers, one sets "wood" if walking into the house, the other sets "grass" if walking out. (the direction of movement determines which trigger you touch last)
This means you can't (easily) have one room with lots of floor changes, but i'm sure you can simply avoid that situation if you're making custom maps.
This means you can't (easily) have one room with lots of floor changes, but i'm sure you can simply avoid that situation if you're making custom maps.
- metlslime
- Posts: 316
- Joined: Tue Feb 05, 2008 11:03 pm
at first I had thought of that option is I can even use the values "TX ". But in the end is more work in some complex maps. And these functions running smoothly with a really good result. Another value to use (and do not include in the tutorial) is one for the bsp called "textype" (something like worldtype) that tells the engine which is the default material on which it is built the bsp.
For now I'm just using old versions of Darkplaces (operate in 2006 or earlier), which is a shame, because I programmed all based on DP. I think this may be specified in the readme, but I still wonder what is wrong with the code, but I think the problem is in these lines:
if (self.texs & TX_METAL)
if (self.onmetal)
{
self.onmetal2 = TRUE;
}
else
{
self.onmetal2 = FALSE;
self.texs = self.texs - TX_METAL;
self.onmetal = 0;
}
the darplaces not seem to want to run it like the other engines.It is the only engine (to testing) in which I have had problems.
For now I'm just using old versions of Darkplaces (operate in 2006 or earlier), which is a shame, because I programmed all based on DP. I think this may be specified in the readme, but I still wonder what is wrong with the code, but I think the problem is in these lines:
if (self.texs & TX_METAL)
if (self.onmetal)
{
self.onmetal2 = TRUE;
}
else
{
self.onmetal2 = FALSE;
self.texs = self.texs - TX_METAL;
self.onmetal = 0;
}
the darplaces not seem to want to run it like the other engines.It is the only engine (to testing) in which I have had problems.
hi, I am nahuel, I love quake and qc.
-

Nahuel - Posts: 492
- Joined: Wed Jan 12, 2011 8:42 pm
- Location: mar del plata
Won't darkplaces load HL maps, which allow you to set accessible texture properties on surfaces? I haven't really investigated it myself but there are some bits in dpextensions.qc that suggest this is possible.
-

lth - Posts: 144
- Joined: Thu Nov 11, 2004 1:15 pm
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest