Added new options:

- ENABLE_TA enables fire ambient sound
- VOLUME_TA controls fire ambient sound volume

Fire ambient sound is played in a loop when there is active fire effect on screen.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8738 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Sevenfm
2020-01-24 10:06:06 +00:00
parent 352a344308
commit 0048e75c80
7 changed files with 162 additions and 3 deletions
+2
View File
@@ -932,6 +932,8 @@ void LoadGameExternalOptions()
gGameExternalOptions.guiWeaponSoundEffectsVolume = iniReader.ReadInteger("Sound Settings","WEAPON_SOUND_EFFECTS_VOLUME", 0, 0, 1000 /*1000 = 10x?*/);
gGameExternalOptions.gubMaxPercentNoiseSilencedSound = iniReader.ReadInteger("Sound Settings","MAX_PERCENT_NOISE_SILENCED_SOUND", 35, 0, 100 );
gGameExternalOptions.fEnableTA = iniReader.ReadBoolean("Sound Settings", "ENABLE_TA", TRUE, false);
gGameExternalOptions.ubVolumeTA = iniReader.ReadInteger("Sound Settings", "VOLUME_TA", 50, 1, 127);
//################# Tactical Interface Settings #################
+2
View File
@@ -465,6 +465,8 @@ typedef struct
//Sound settings
UINT32 guiWeaponSoundEffectsVolume;
UINT8 gubMaxPercentNoiseSilencedSound;
BOOLEAN fEnableTA;
UINT8 ubVolumeTA;
// WDS - Option to turn off stealing
BOOLEAN fStealingDisabled;
+111 -2
View File
@@ -12,12 +12,17 @@
#include "Game Events.h"
#include "Ambient Control.h"
#include "lighting.h"
#include "Random.h"
#include "Random.h"
#include "SmokeEffects.h" // sevenfm
#endif
AMBIENTDATA_STRUCT gAmbData[ MAX_AMBIENT_SOUNDS ];
INT16 gsNumAmbData = 0;
INT16 gsNumAmbData = 0;
// sevenfm
UINT32 guiAmbientFire = NO_SAMPLE;
UINT8 gubAmbientFutureFireVolume = 0;
UINT32 guiFireAmbientLastUpdate = 0;
UINT8 gubCurrentSteadyStateAmbience = SSA_NONE;
UINT8 gubCurrentSteadyStateSound = 0;
@@ -310,3 +315,107 @@ BOOLEAN SetSteadyStateAmbience( UINT8 ubAmbience )
return( TRUE );
}
void UpdateFireAmbient(void)
{
INT32 iVolume;
UINT32 uiClock;
if (!gGameExternalOptions.fEnableTA)
{
return;
}
if (guiCurrentScreen != GAME_SCREEN)
{
return;
}
uiClock = GetJA2Clock();
if (uiClock - guiFireAmbientLastUpdate < 50)
{
return;
}
guiFireAmbientLastUpdate = uiClock;
if (FindVisibleSmokeEffect(BURNABLEGAS_SMOKE_EFFECT))
{
gubAmbientFutureFireVolume = gGameExternalOptions.ubVolumeTA;
if (guiAmbientFire == NO_SAMPLE)
{
StartFireAmbient();
}
// check if successfully started
if (guiAmbientFire != NO_SAMPLE)
{
iVolume = SoundGetVolume(guiAmbientFire);
if (iVolume != gubAmbientFutureFireVolume)
{
// increase volume until it reaches desired level
iVolume = min((INT32)gubAmbientFutureFireVolume, iVolume + 4);
SoundSetVolume(guiAmbientFire, iVolume);
}
}
}
else
{
gubAmbientFutureFireVolume = 0;
// check if ambient sound is playing
if (guiAmbientFire != NO_SAMPLE)
{
iVolume = SoundGetVolume(guiAmbientFire);
if (iVolume != gubAmbientFutureFireVolume)
{
// increase volume until it reaches desired level
iVolume = max((INT32)gubAmbientFutureFireVolume, iVolume - 4);
SoundSetVolume(guiAmbientFire, iVolume);
}
if (iVolume == 0)
{
StopFireAmbient();
}
}
}
}
void StopFireAmbient(void)
{
if (guiAmbientFire != NO_SAMPLE)
{
SoundStop(guiAmbientFire);
guiAmbientFire = NO_SAMPLE;
}
}
void StartFireAmbient(void)
{
CHAR8 filename[1024];
SOUNDPARMS spParms;
// Stop ambient
if (guiAmbientFire != NO_SAMPLE)
{
return;
}
strcpy(filename, "Sounds\\ambient\\fire.ogg");
//gubAmbientFireVolume = LOWVOLUME;
// start sound
memset(&spParms, 0xff, sizeof(SOUNDPARMS));
//spParms.uiVolume = CalculateSoundEffectsVolume( LOWVOLUME );
spParms.uiVolume = 0;
spParms.uiLoop = 0;
spParms.uiPriority = GROUP_AMBIENT;
//guiAmbientFire = SoundPlay( zFileName, &spParms );
guiAmbientFire = SoundPlayStreamedFile(filename, &spParms);
}
+3
View File
@@ -18,6 +18,9 @@ extern INT16 gsNumAmbData;
BOOLEAN SetSteadyStateAmbience( UINT8 ubAmbience );
void UpdateFireAmbient(void);
void StopFireAmbient(void);
void StartFireAmbient(void);
#define SOUND_NAME_SIZE 256
#define NUM_SOUNDS_PER_TIMEFRAME 8
+27
View File
@@ -1063,3 +1063,30 @@ BOOL GetRandomSignalSmokeGridNo(INT32* psGridNo)
return TRUE;
}
BOOLEAN FindVisibleSmokeEffect(INT8 bType)
{
UINT32 uiCnt;
INT8 bSmokeEffectLevel;
//loop through all smoke effects
for (uiCnt = 0; uiCnt < guiNumSmokeEffects; uiCnt++)
{
if (gSmokeEffectData[uiCnt].fAllocated &&
gSmokeEffectData[uiCnt].bType == bType)
{
if (gSmokeEffectData[uiCnt].bFlags & SMOKE_EFFECT_ON_ROOF)
bSmokeEffectLevel = 1;
else
bSmokeEffectLevel = 0;
if (!TileIsOutOfBounds(gSmokeEffectData[uiCnt].sGridNo) &&
GridNoOnScreen(gSmokeEffectData[uiCnt].sGridNo))
{
return TRUE;
}
}
}
return FALSE;
}
+3
View File
@@ -73,4 +73,7 @@ void UpdateSmokeEffectGraphics( );
// Flugente: get the gridno and blevel of a random smoke signal, if one exists
BOOL GetRandomSignalSmokeGridNo(INT32* psGridNo);
// find smoke effect on visible screen
BOOLEAN FindVisibleSmokeEffect(INT8 bType);
#endif
+14 -1
View File
@@ -30,7 +30,8 @@
#include "Tactical Placement GUI.h"//dnl ch45 071009
#include "Map Screen Interface Map Inventory.h"//dnl ch51 081009
#include "World Items.h"//dnl ch77 191113
#include "Overhead.h" // added by Flugente
#include "Overhead.h" // added by Flugente
#include "Ambient Control.h" // sevenfm
#endif
#include "SaveLoadScreen.h"
@@ -409,6 +410,12 @@ void GameLoop(void)
// rain
RenderRain();
// sevenfm: update tactical ambients
if (guiCurrentScreen == GAME_SCREEN)
{
UpdateFireAmbient();
}
// Flugente: dynamic opinions: Dialogue Boxes need to be refreshed
RefreshBoxes( );
@@ -533,6 +540,12 @@ void HandleNewScreenChange( UINT32 uiNewScreen, UINT32 uiOldScreen )
}
}
// end rain
if (uiNewScreen != MSG_BOX_SCREEN)
{
// stop ambients
StopFireAmbient();
}
}
void HandleShortCutExitState( void )