diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index 58a8e6afe..2980b093d 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -83,6 +83,7 @@ static struct { uint32_t keyw; uint32_t date; } g_keywdate[] = { CON_CALCHYPOTENUSE, 20100927 }, { CON_CLIPMOVENOSLIDE, 20101009 }, { CON_INCLUDEDEFAULT, 20110615 }, + { CON_SETACTORSOUNDPITCH, 20111102 }, }; char g_szScriptFileName[BMAX_PATH] = "(none)"; // file we're currently compiling @@ -562,6 +563,7 @@ const char *keyw[] = "calchypotenuse", // 358 "clipmovenoslide", // 359 "includedefault", // 360 + "setactorsoundpitch", // 361 "" }; @@ -3477,6 +3479,10 @@ static int32_t C_ParseCommand(int32_t loop) C_GetManyVars(2); continue; + case CON_SETACTORSOUNDPITCH: + C_GetManyVars(3); + continue; + case CON_SECTOROFWALL: C_GetNextVarType(GAMEVAR_READONLY); C_GetNextVar(); diff --git a/polymer/eduke32/source/gamedef.h b/polymer/eduke32/source/gamedef.h index 6192aca86..e1e731d07 100644 --- a/polymer/eduke32/source/gamedef.h +++ b/polymer/eduke32/source/gamedef.h @@ -936,6 +936,7 @@ enum ScriptKeywords_t CON_CALCHYPOTENUSE, // 358 CON_CLIPMOVENOSLIDE, // 359 CON_INCLUDEDEFAULT, // 360 + CON_SETACTORSOUNDPITCH, // 361 CON_END }; #endif diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 15fd921cb..2856898b4 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -1089,6 +1089,22 @@ skip_check: continue; } + case CON_SETACTORSOUNDPITCH: + insptr++; + { + int32_t i = Gv_GetVarX(*insptr++), j = Gv_GetVarX(*insptr++), pitchoffset = Gv_GetVarX(*insptr++); + + if ((j<0 || j>=MAXSOUNDS)) + { + OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],j); + continue; + } + + S_ChangeSoundPitch(j,i,pitchoffset); + + continue; + } + case CON_GLOBALSOUND: if (((unsigned)*(++insptr) >= MAXSOUNDS)) { diff --git a/polymer/eduke32/source/sounds.c b/polymer/eduke32/source/sounds.c index 1a87d6236..cb9e83179 100644 --- a/polymer/eduke32/source/sounds.c +++ b/polymer/eduke32/source/sounds.c @@ -663,6 +663,28 @@ void S_StopEnvSound(int32_t num, int32_t i) while (j >= 0); } +void S_ChangeSoundPitch(int32_t num, int32_t i, int32_t pitchoffset) +{ + int32_t j; + + if ((unsigned)num > (unsigned)g_maxSoundPos || g_sounds[num].num <= 0) + return; + + for (j=MAXSOUNDINSTANCES-1; j>=0; j--) + { + int32_t voice = g_sounds[num].SoundOwner[j].voice; + + if ((i == -1 && voice > FX_Ok) || (i != -1 && g_sounds[num].SoundOwner[j].i == i)) + { + if (i >= 0 && voice <= FX_Ok) + initprintf(OSD_ERROR "S_ChangeSoundPitch(): bad voice %d for sound ID %d index %d!\n", voice, num, j); + else if (voice > FX_Ok && FX_SoundActive(voice)) + FX_SetPitch(voice, pitchoffset); + break; + } + } +} + void S_Update(void) { vec3_t *s, *c; diff --git a/polymer/eduke32/source/sounds.h b/polymer/eduke32/source/sounds.h index 1dcc1c52e..e71bf13b4 100644 --- a/polymer/eduke32/source/sounds.h +++ b/polymer/eduke32/source/sounds.h @@ -89,5 +89,6 @@ void S_SoundStartup(void); void S_StopEnvSound(int32_t num,int32_t i); void S_StopMusic(void); void S_Update(void); +void S_ChangeSoundPitch(int32_t num, int32_t i, int32_t pitchoffset); #endif