ew-progs/ew/talk/smacktalk.qc

85 lines
1.5 KiB
C++
Raw Normal View History

2011-09-06 00:00:00 +00:00
/*
=============================
smacktalk.qc
coded by
Robert de Heus a.k.a Koolio
koolio@planetkoolio.com
http://www.planetkoolio.com
Description:
Plays a random sound when you kill something.
=============================
*/
//float SMACKSOUNDS = 2; //currently used smacksounds
/* non external file method
void() PlayRandomSmackSound =
{
local float rand1, rand2;
rand1 = random()*10;
if (rand1 < 8) //Doesn't happen very often (20% chance)
return;
rand2 = random()*2;
if (rand2 < 2)
sound (self, CHAN_VOICE, "player/mike/smacktalk/youwantsomeofme.wav", 1, ATTN_NORM);
if (rand2 < 1)
sound (self, CHAN_VOICE, "player/mike/smacktalk/whosnext.wav", 1, ATTN_NORM);
};
*/
void(entity who) PlayRandomSmackSound =
{
if (!(who.flags & FL_CLIENT)) //Only works for clients
return;
if(deathmatch || coop) //Only in SP
return;
local float file, i, j, k;
local string h;
k = random()*10;
if (k < 8) //20% chance
return;
local string beep;
file = open ("sound/player/mike/smacktalk/smacktalklist.txt", FILE_READ);
if (file == -1)
{
bprint("Error: file not found\n");
return;
}
//Find a random number between 0 and the amount of sounds in the file
i = random()*26;
ceil(i);
//Play a random sound by reading the file the correct number of times
while (j < i)
{
h = read(file);
j = j + 1;
}
sound (who, CHAN_VOICE, h, 1, ATTN_NORM);
//sprint(who,"beep = ");
//sprint(who,h);
//sprint(who,"\n");
//stuffcmd(who, "play ");
//stuffcmd(who, h);
//stuffcmd(who, "\n");
close(file);
};