Person::players[k]->animTarget = Person::players[k]->getLanding();
emit_sound_at(landsound, Person::players[k]->coords, 128.);
if (k == 0) {
- envsound[numenvsounds] = Person::players[k]->coords;
- envsoundvol[numenvsounds] = 16;
- envsoundlife[numenvsounds] = .4;
- numenvsounds++;
+ addEnvSound(Person::players[k]->coords);
}
-
}
}
}
extern int flashdelay;
extern bool showpoints;
extern bool immediate;
-extern XYZ envsound[30];
-extern float envsoundvol[30];
-extern float envsoundlife[30];
-extern int numenvsounds;
extern int tutoriallevel;
extern float smoketex;
extern int tutorialstage;
// play pain sounds
int whichsound = -1;
- // FIXME: seems to be spawning sounds by manipulating attributes... MESSY!
if (creature == wolftype) {
int i = abs(Random() % 2);
if (i == 0)
whichsound = snarlsound;
if (i == 1)
whichsound = snarl2sound;
- envsound[numenvsounds] = coords;
- envsoundvol[numenvsounds] = 16;
- envsoundlife[numenvsounds] = .4;
- numenvsounds++;
}
if (creature == rabbittype) {
int i = abs(Random() % 2);
whichsound = rabbitpainsound;
if (i == 1 && howmuch >= 2)
whichsound = rabbitpain1sound;
- envsound[numenvsounds] = coords;
- envsoundvol[numenvsounds] = 16;
- envsoundlife[numenvsounds] = .4;
- numenvsounds++;
}
- if (whichsound != -1)
+ if (whichsound != -1) {
emit_sound_at(whichsound, coords);
+ addEnvSound(coords);
+ }
}
if (id == 0 && howmuch > 0) {
whichsound = snarlsound;
if (i == 1)
whichsound = snarl2sound;
- envsound[numenvsounds] = coords;
- envsoundvol[numenvsounds] = 16;
- envsoundlife[numenvsounds] = .4;
- numenvsounds++;
}
if (creature == rabbittype) {
int i = abs(Random() % 2);
whichsound = rabbitpainsound;
if (i == 1 && damage > damagetolerance)
whichsound = rabbitpain1sound;
- envsound[numenvsounds] = coords;
- envsoundvol[numenvsounds] = 16;
- envsoundlife[numenvsounds] = .4;
- numenvsounds++;
}
if (whichsound != -1) {
emit_sound_at(whichsound, coords);
+ addEnvSound(coords);
}
}
speechdelay = .3;
if (id == 0)
if (whichsound == footstepsound || whichsound == footstepsound2 || whichsound == footstepsound3 || whichsound == footstepsound4) {
- envsound[numenvsounds] = coords;
- if (animTarget == wolfrunninganim || animTarget == rabbitrunninganim)
- envsoundvol[numenvsounds] = 15;
- else
- envsoundvol[numenvsounds] = 6;
- envsoundlife[numenvsounds] = .4;
- numenvsounds++;
+ if (animTarget == wolfrunninganim || animTarget == rabbitrunninganim) {
+ addEnvSound(coords, 15);
+ } else {
+ addEnvSound(coords, 6);
+ }
}
if (animation[animTarget].label[frameTarget] == 3) {
emit_sound_at(bushrustle, coords, 40 * findLength(&velocity));
if (id == 0) {
- envsound[numenvsounds] = coords;
- envsoundvol[numenvsounds] = 4 * findLength(&velocity);
- envsoundlife[numenvsounds] = .4;
- numenvsounds++;
+ addEnvSound(coords, 4 * findLength(&velocity));
}
int howmany;
emit_sound_at(bushrustle, coords, 40 * findLength(&velocity));
if (id == 0) {
- envsound[numenvsounds] = coords;
- envsoundvol[numenvsounds] = 4 * findLength(&velocity);
- envsoundlife[numenvsounds] = .4;
- numenvsounds++;
+ addEnvSound(coords, 4 * findLength(&velocity));
}
int howmany;
emit_sound_at(landsound, coords, 128.);
if (id == 0) {
- envsound[numenvsounds] = coords;
- envsoundvol[numenvsounds] = 16;
- envsoundlife[numenvsounds] = .4;
- numenvsounds++;
+ addEnvSound(coords);
}
}
}
emit_sound_at(landsound, coords, 128.);
if (id == 0) {
- envsound[numenvsounds] = coords;
- envsoundvol[numenvsounds] = 16;
- envsoundlife[numenvsounds] = .4;
- numenvsounds++;
+ addEnvSound(coords);
}
}
}
extern float camerashake;
extern bool freeze;
extern int detail;
-extern XYZ envsound[30];
-extern float envsoundvol[30];
-extern int numenvsounds;
-extern float envsoundlife[30];
extern int tutoriallevel;
extern int whichjointstartarray[26];
emit_sound_at(breaksound2, joints[i].position * (*scale) + *coords);
- envsound[numenvsounds] = *coords;
- envsoundvol[numenvsounds] = 64;
- envsoundlife[numenvsounds] = .4;
- numenvsounds++;
+ addEnvSound(*coords, 64);
}
if (findLengthfast(&bounceness) > 2500) {
emit_sound_at(breaksound2, joints[i].position * (*scale) + *coords);
- envsound[numenvsounds] = *coords;
- envsoundvol[numenvsounds] = 64;
- envsoundlife[numenvsounds] = .4;
- numenvsounds++;
+ addEnvSound(*coords, 64);
}
if (objects.type[k] == treetrunktype) {
objects.rotx[k] += joints[i].velocity.x * multiplier * .4;
struct OPENAL_SAMPLE *samp[sounds_count];
+extern XYZ envsound[30];
+extern float envsoundvol[30];
+extern int numenvsounds;
+extern float envsoundlife[30];
+
int footstepsound, footstepsound2, footstepsound3, footstepsound4;
int channels[100];
OPENAL_Stream_SetMode(samp[i], OPENAL_LOOP_NORMAL);
}
-void
-emit_sound_at(int soundid, const XYZ &pos, float vol)
+void addEnvSound(XYZ coords, float vol, float life)
+{
+ envsound[numenvsounds] = coords;
+ envsoundvol[numenvsounds] = vol;
+ envsoundlife[numenvsounds] = life;
+ numenvsounds++;
+}
+
+void emit_sound_at(int soundid, const XYZ &pos, float vol)
{
PlaySoundEx (soundid, samp[soundid], NULL, true);
OPENAL_3D_SetAttributes_ (channels[soundid], pos, NULL);
OPENAL_SetPaused (channels[soundid], false);
}
-void
-emit_sound_np(int soundid, float vol)
+void emit_sound_np(int soundid, float vol)
{
PlaySoundEx (soundid, samp[soundid], NULL, true);
OPENAL_SetVolume (channels[soundid], vol);
OPENAL_SetPaused (channels[soundid], false);
}
-void
-emit_stream_at(int soundid, const XYZ &pos, float vol)
+void emit_stream_at(int soundid, const XYZ &pos, float vol)
{
PlayStreamEx (soundid, samp[soundid], NULL, true);
OPENAL_3D_SetAttributes_ (channels[soundid], pos, NULL);
OPENAL_SetPaused (channels[soundid], false);
}
-void
-emit_stream_np(int soundid, float vol)
+void emit_stream_np(int soundid, float vol)
{
PlayStreamEx (soundid, samp[soundid], NULL, true);
OPENAL_SetVolume (channels[soundid], vol);
OPENAL_SetPaused (channels[soundid], false);
}
-void
-resume_stream(int soundid)
+void resume_stream(int soundid)
{
OPENAL_SetPaused (channels[soundid], false);
}
-void
-pause_sound(int soundid)
+void pause_sound(int soundid)
{
OPENAL_SetPaused (channels[soundid], true);
}
-
extern void loadAllSounds();
+extern void addEnvSound(XYZ coords, float vol = 16, float life = .4);
+
extern void emit_sound_at(int soundid, const XYZ &pos = XYZ(), float vol = 256.f);
extern void emit_sound_np(int soundid, float vol = 256.f);
extern void emit_stream_at(int soundid, const XYZ &pos = XYZ(), float vol = 256.f);