int xyzsound(short num,short i,long x,long y,long z) { long sndist, cx, cy, cz, j,k; short pitche,pitchs,cs; int voice, sndang, ca, pitch; // if(num != 358) return 0; if( num >= NUM_SOUNDS || FXDevice < 0 || ( (soundm[num]&8) && ud.lockout ) || SoundToggle == 0 || Sound[num].num > 3 || FX_VoiceAvailable(soundpr[num]) == 0 || (ps[myconnectindex].timebeforeexit > 0 && ps[myconnectindex].timebeforeexit <= 26*3) || ps[myconnectindex].gm&MODE_MENU) return -1; if( soundm[num]&128 ) { sound(num); return 0; } if( soundm[num]&4 ) { if(VoiceToggle==0 || (ud.multimode > 1 && PN == APLAYER && sprite[i].yvel != screenpeek && ud.coop != 1) ) return -1; for(j=0;j<NUM_SOUNDS;j++) for(k=0;k<Sound[j].num;k++) if( (Sound[j].num > 0) && (soundm[j]&4) ) return -1; } cx = ps[screenpeek].oposx; cy = ps[screenpeek].oposy; cz = ps[screenpeek].oposz; cs = ps[screenpeek].cursectnum; ca = ps[screenpeek].ang+ps[screenpeek].look_ang; sndist = FindDistance3D((cx-x),(cy-y),(cz-z)>>4); if( i >= 0 && (soundm[num]&16) == 0 && PN == MUSICANDSFX && SLT < 999 && (sector[SECT].lotag&0xff) < 9 ) sndist = divscale14(sndist,(SHT+1)); pitchs = soundps[num]; pitche = soundpe[num]; j = klabs(pitche-pitchs); if(j) { if( pitchs < pitche ) pitch = pitchs + ( rand()%j ); else pitch = pitche + ( rand()%j ); } else pitch = pitchs; sndist += soundvo[num]; if(sndist < 0) sndist = 0; if( sndist && PN != MUSICANDSFX && !cansee(cx,cy,cz-(24<<8),cs,SX,SY,SZ-(24<<8),SECT) ) sndist += sndist>>5; switch(num) { case PIPEBOMB_EXPLODE: case LASERTRIP_EXPLODE: case RPG_EXPLODE: if(sndist > (6144) ) sndist = 6144; if(sector[ps[screenpeek].cursectnum].lotag == 2) pitch -= 1024; break; default: if(sector[ps[screenpeek].cursectnum].lotag == 2 && (soundm[num]&4) == 0) pitch = -768; if( sndist > 31444 && PN != MUSICANDSFX) return -1; break; } if( Sound[num].num > 0 && PN != MUSICANDSFX ) { if( SoundOwner[num][0].i == i ) stopsound(num); else if( Sound[num].num > 1 ) stopsound(num); else if( badguy(&sprite[i]) && sprite[i].extra <= 0 ) stopsound(num); } if( PN == APLAYER && sprite[i].yvel == screenpeek ) { sndang = 0; sndist = 0; } else { sndang = 2048 + ca - getangle(cx-x,cy-y); sndang &= 2047; } if(Sound[num].ptr == 0) { if( loadsound(num) == 0 ) return 0; } else { if (Sound[num].lock < 200) Sound[num].lock = 200; else Sound[num].lock++; } if( soundm[num]&16 ) sndist = 0; if(sndist < ((255-LOUDESTVOLUME)<<6) ) sndist = ((255-LOUDESTVOLUME)<<6); if( soundm[num]&1 ) { if(Sound[num].num > 0) return -1; voice = FX_PlayLoopedAuto( Sound[num].ptr, soundsiz[num], 0, -1, pitch,sndist>>6,sndist>>6,0,soundpr[num],num); } else {
int xyzsound(short num,short i,int32_t x,int32_t y,int32_t z) { int32_t sndist, cx, cy, cz, j,k; short pitche,pitchs,cs; int voice, sndang, ca, pitch; if ( num >= NUM_SOUNDS || FXDevice == NumSoundCards || ( (soundm[num]&8) && ud.lockout ) || SoundToggle == 0 || Sound[num].num > 3 || FX_VoiceAvailable(soundpr[num]) == 0 || (ps[myconnectindex].timebeforeexit > 0 && ps[myconnectindex].timebeforeexit <= 26*3) || ps[myconnectindex].gm&MODE_MENU) { return -1; } if ( soundm[num]&128 ) { sound(num); return 0; } if ( soundm[num]&4 ) { // FIX_00041: Toggle to hear the opponent sound in DM (like it used to be in v1.3d) if (VoiceToggle==0 || (ud.multimode > 1 && PN == APLAYER && sprite[i].yvel != screenpeek && /*ud.coop!=1 &&*/ !OpponentSoundToggle) ) { return -1; //xduke : 1.3d Style: makes opponent sound in DM as in COOP } for (j=0; j<NUM_SOUNDS; j++) for (k=0; k<Sound[j].num; k++) if ( (Sound[j].num > 0) && (soundm[j]&4) ) { return -1; } } cx = ps[screenpeek].oposx; cy = ps[screenpeek].oposy; cz = ps[screenpeek].oposz; cs = ps[screenpeek].cursectnum; ca = ps[screenpeek].ang+ps[screenpeek].look_ang; sndist = FindDistance3D((cx-x),(cy-y),(cz-z)>>4); if ( i >= 0 && (soundm[num]&16) == 0 && PN == MUSICANDSFX && SLT < 999 && (sector[SECT].lotag&0xff) < 9 ) { sndist = divscale14(sndist,(SHT+1)); } pitchs = soundps[num]; pitche = soundpe[num]; cx = klabs(pitche-pitchs); if (cx) { if ( pitchs < pitche ) { pitch = pitchs + ( rand()%cx ); } else { pitch = pitche + ( rand()%cx ); } } else { pitch = pitchs; } sndist += soundvo[num]; if (sndist < 0) { sndist = 0; } if ( sndist && PN != MUSICANDSFX && !cansee(cx,cy,cz-(24<<8),cs,SX,SY,SZ-(24<<8),SECT) ) { sndist += sndist>>5; }
static int32_t S_CalcDistAndAng(int32_t i, int32_t num, int32_t camsect, int32_t camang, const vec3_t *cam, const vec3_t *pos, int32_t *sndistptr, int32_t *sndangptr) { int32_t sndang = 0, sndist = 0; int32_t explosion = 0; if (PN == APLAYER && P_Get(i) == screenpeek) goto sound_further_processing; sndang = S_GetAngle(camang, cam, pos); sndist = FindDistance3D(cam->x-pos->x, cam->y-pos->y, (cam->z-pos->z)); #ifdef SPLITSCREEN_MOD_HACKS if (g_fakeMultiMode==2) { // HACK for splitscreen mod: take the min of sound distances // to 1st and 2nd player. if (PN == APLAYER && P_Get(i) == 1) { sndist = sndang = 0; goto sound_further_processing; } { const vec3_t *cam2 = &g_player[1].ps->pos; int32_t sndist2 = FindDistance3D(cam2->x-pos->x, cam2->y-pos->y, (cam2->z-pos->z)); if (sndist2 < sndist) { cam = cam2; camsect = g_player[1].ps->cursectnum; camang = g_player[1].ps->ang; sndist = sndist2; sndang = S_GetAngle(camang, cam, pos); } } } #endif if ((g_sounds[num].m & SF_GLOBAL) == 0 && S_IsAmbientSFX(i) && (sector[SECT].lotag&0xff) < 9) // ST_9_SLIDING_ST_DOOR sndist = divscale14(sndist, SHT+1); sound_further_processing: sndist += g_sounds[num].vo; if (sndist < 0) sndist = 0; if (camsect > -1 && sndist && PN != MUSICANDSFX && !cansee(cam->x,cam->y,cam->z-(24<<8),camsect, SX,SY,SZ-(24<<8),SECT)) sndist += sndist>>5; switch (DYNAMICSOUNDMAP(num)) { case PIPEBOMB_EXPLODE__STATIC: case LASERTRIP_EXPLODE__STATIC: case RPG_EXPLODE__STATIC: explosion = 1; if (sndist > 6144) sndist = 6144; break; } if ((g_sounds[num].m & SF_GLOBAL) || sndist < ((255-LOUDESTVOLUME)<<6)) sndist = ((255-LOUDESTVOLUME)<<6); *sndistptr = sndist; *sndangptr = sndang; return explosion; }