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!