From 643612540deb5996de2366ae27da0b4d97147515 Mon Sep 17 00:00:00 2001 From: Wanne Date: Tue, 20 Aug 2013 08:33:32 +0000 Subject: [PATCH] - Bugfix: Externalized Music (Music.lua) (by Jazz) o Added missing: 6 - creature start battle (CREATURE_BATTLE_xxx.wav or CREATURE_BATTLE_xxx.ogg) 7 - creepy music (CREEPY_xxx.wav or CREEPY_xxx.ogg) git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6296 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Init.cpp | 3 +++ Strategic/Auto Resolve.cpp | 16 +++++++++++++ Strategic/Creature Spreading.cpp | 6 +++++ Strategic/LuaInitNPCs.cpp | 40 +++++++++++++++++++++++++++++++ Strategic/PreBattle Interface.cpp | 6 ++++- Strategic/Strategic Movement.cpp | 4 ++++ Tactical/Auto Bandage.cpp | 7 ++++++ Tactical/Boxing.cpp | 5 ++++ Tactical/Overhead.cpp | 7 ++++++ Tactical/Rotting Corpses.cpp | 7 ++++++ Utils/Music Control.cpp | 26 ++++++++++++++++++-- Utils/Music Control.h | 9 +++++++ 12 files changed, 133 insertions(+), 3 deletions(-) diff --git a/Init.cpp b/Init.cpp index 17a5a619..a4b0cf83 100644 --- a/Init.cpp +++ b/Init.cpp @@ -1344,6 +1344,9 @@ BackupBRandEncyclopedia ( gBriefingRoomData, gBriefingRoomDataBackup, 0); MusicSoundValues[iloop].SoundTacticalNothing[zloop] = -1; MusicSoundValues[iloop].SoundTacticalTensor[zloop] = -1; MusicSoundValues[iloop].SoundTacticalDeath[zloop] = -1; + MusicSoundValues[iloop].SoundTacticalBattleCreature[zloop] = -1; + MusicSoundValues[iloop].SoundTacticalBattleCreepy[zloop] = -1; + MusicSoundValues[iloop].SoundTacticalBattleGroup[iloop] = -1; } } diff --git a/Strategic/Auto Resolve.cpp b/Strategic/Auto Resolve.cpp index c4c36996..3b7a1371 100644 --- a/Strategic/Auto Resolve.cpp +++ b/Strategic/Auto Resolve.cpp @@ -2061,7 +2061,12 @@ void RenderAutoResolve() SectorInfo[ SECTOR( gpAR->ubSectorX, gpAR->ubSectorY ) ].bLastKnownEnemies = 0; SetThisSectorAsPlayerControlled( gpAR->ubSectorX, gpAR->ubSectorY, 0, TRUE ); + GlobalSoundID = MusicSoundValues[ SECTOR( gpAR->ubSectorX, gpAR->ubSectorY ) ].SoundTacticalVictory[0]; + if ( MusicSoundValues[ SECTOR( gpAR->ubSectorX, gpAR->ubSectorY ) ].SoundTacticalVictory[0] != -1 ) + SetMusicModeID( MUSIC_TACTICAL_VICTORY, MusicSoundValues[ SECTOR( gpAR->ubSectorX, gpAR->ubSectorY ) ].SoundTacticalVictory[0] ); + else SetMusicMode( MUSIC_TACTICAL_VICTORY ); + LogBattleResults( LOG_VICTORY ); break; @@ -2081,7 +2086,12 @@ void RenderAutoResolve() HandleMoraleEvent( NULL, MORALE_HEARD_BATTLE_LOST, gpAR->ubSectorX, gpAR->ubSectorY, 0 ); if( ProcessLoyalty() )HandleGlobalLoyaltyEvent( GLOBAL_LOYALTY_BATTLE_LOST, gpAR->ubSectorX, gpAR->ubSectorY, 0 ); + GlobalSoundID = MusicSoundValues[ SECTOR( gpAR->ubSectorX, gpAR->ubSectorY ) ].SoundTacticalDeath[0]; + if ( MusicSoundValues[ SECTOR( gpAR->ubSectorX, gpAR->ubSectorY ) ].SoundTacticalDeath[0] != -1 ) + SetMusicModeID( MUSIC_TACTICAL_DEATH, MusicSoundValues[ SECTOR( gpAR->ubSectorX, gpAR->ubSectorY ) ].SoundTacticalDeath[0] ); + else SetMusicMode( MUSIC_TACTICAL_DEATH ); + gsEnemyGainedControlOfSectorID = (INT16)SECTOR( gpAR->ubSectorX, gpAR->ubSectorY ); break; case BATTLE_DEFEAT: @@ -2096,7 +2106,13 @@ void RenderAutoResolve() gsEnemyGainedControlOfSectorID = (INT16)SECTOR( gpAR->ubSectorX, gpAR->ubSectorY ); gsCiviliansEatenByMonsters = gpAR->ubAliveEnemies; } + + GlobalSoundID = MusicSoundValues[ SECTOR( gpAR->ubSectorX, gpAR->ubSectorY ) ].SoundTacticalDeath[0]; + if ( MusicSoundValues[ SECTOR( gpAR->ubSectorX, gpAR->ubSectorY ) ].SoundTacticalDeath[0] != -1 ) + SetMusicModeID( MUSIC_TACTICAL_DEATH, MusicSoundValues[ SECTOR( gpAR->ubSectorX, gpAR->ubSectorY ) ].SoundTacticalDeath[0] ); + else SetMusicMode( MUSIC_TACTICAL_DEATH ); + LogBattleResults( LOG_DEFEAT ); break; diff --git a/Strategic/Creature Spreading.cpp b/Strategic/Creature Spreading.cpp index ebd54f56..74973298 100644 --- a/Strategic/Creature Spreading.cpp +++ b/Strategic/Creature Spreading.cpp @@ -1284,7 +1284,13 @@ BOOLEAN PrepareCreaturesForBattle() { //creatures are attacking a town sector //gfUseCreatureMusic = TRUE; UseCreatureMusic(TRUE); + + GlobalSoundID = MusicSoundValues[ SECTOR( gWorldSectorX, gWorldSectorY ) ].SoundTacticalNothing[gbWorldSectorZ]; + if ( MusicSoundValues[ SECTOR( gWorldSectorX, gWorldSectorY ) ].SoundTacticalNothing[gbWorldSectorZ] != -1 ) + SetMusicModeID( MUSIC_TACTICAL_NOTHING, MusicSoundValues[ SECTOR( gWorldSectorX, gWorldSectorY ) ].SoundTacticalNothing[gbWorldSectorZ] ); + else SetMusicMode( MUSIC_TACTICAL_NOTHING ); + ubCreatureHabitat = MINE_EXIT; ubNumCreatures = gubNumCreaturesAttackingTown; } diff --git a/Strategic/LuaInitNPCs.cpp b/Strategic/LuaInitNPCs.cpp index 3df3cfc2..58f38f0d 100644 --- a/Strategic/LuaInitNPCs.cpp +++ b/Strategic/LuaInitNPCs.cpp @@ -5283,6 +5283,16 @@ static int l_SetMusicID (lua_State *L) if ((x>=1 || x<=16) && (y>=1 || y<=16) && (z>=0 || z<=3) ) SetMusicModeID( MUSIC_TACTICAL_DEATH, MusicSoundValues[ SECTOR( x, y ) ].SoundTacticalDeath[z] ); } + else if ( MusicType == 6 ) + { + if ((x>=1 || x<=16) && (y>=1 || y<=16) && (z>=0 || z<=3) ) + SetMusicModeID( MUSIC_TACTICAL_BATTLE, MusicSoundValues[ SECTOR( x, y ) ].SoundTacticalBattleCreature[z] ); + } + else if ( MusicType == 7 ) + { + if ((x>=1 || x<=16) && (y>=1 || y<=16) && (z>=0 || z<=3) ) + SetMusicModeID( MUSIC_TACTICAL_BATTLE, MusicSoundValues[ SECTOR( x, y ) ].SoundTacticalBattleCreepy[z] ); + } } return 0; @@ -5320,6 +5330,21 @@ INT32 SoundID = -1; if ((x>=1 || x<=16) && (y>=1 || y<=16) && (z>=0 || z<=3) ) SoundID = MusicSoundValues[SECTOR( x, y )].SoundTacticalVictory[z]; } + else if ( MusicType == 5 ) + { + if ((x>=1 || x<=16) && (y>=1 || y<=16) && (z>=0 || z<=3) ) + SoundID = MusicSoundValues[ SECTOR( x, y ) ].SoundTacticalDeath[z]; + } + else if ( MusicType == 6 ) + { + if ((x>=1 || x<=16) && (y>=1 || y<=16) && (z>=0 || z<=3) ) + SoundID = MusicSoundValues[ SECTOR( x, y ) ].SoundTacticalBattleCreature[z]; + } + else if ( MusicType == 7 ) + { + if ((x>=1 || x<=16) && (y>=1 || y<=16) && (z>=0 || z<=3) ) + SoundID = MusicSoundValues[ SECTOR( x, y ) ].SoundTacticalBattleCreepy[z]; + } } lua_pushinteger(L, SoundID); @@ -5364,6 +5389,21 @@ static int l_gAddMusic(lua_State *L) if ((x>=1 || x<=16) && (y>=1 || y<=16) && (z>=0 || z<=3) ) MusicSoundValues[SECTOR( x, y )].SoundTacticalVictory[z] = SoundId; } + else if ( MusicType == 5 ) + { + if ((x>=1 || x<=16) && (y>=1 || y<=16) && (z>=0 || z<=3) ) + MusicSoundValues[ SECTOR( x, y ) ].SoundTacticalDeath[z] = SoundId; + } + else if ( MusicType == 6 ) + { + if ((x>=1 || x<=16) && (y>=1 || y<=16) && (z>=0 || z<=3) ) + MusicSoundValues[ SECTOR( x, y ) ].SoundTacticalBattleCreature[z] = SoundId; + } + else if ( MusicType == 7 ) + { + if ((x>=1 || x<=16) && (y>=1 || y<=16) && (z>=0 || z<=3) ) + MusicSoundValues[ SECTOR( x, y ) ].SoundTacticalBattleCreepy[z] = SoundId; + } } return 0; diff --git a/Strategic/PreBattle Interface.cpp b/Strategic/PreBattle Interface.cpp index f73455df..cd7e0c93 100644 --- a/Strategic/PreBattle Interface.cpp +++ b/Strategic/PreBattle Interface.cpp @@ -873,6 +873,10 @@ void InitPreBattleInterface( GROUP *pBattleGroup, BOOLEAN fPersistantPBI ) UseCreatureMusic(HostileZombiesPresent()); #endif + GlobalSoundID = MusicSoundValues[ SECTOR( gubPBSectorX, gubPBSectorY ) ].SoundTacticalTensor[gubPBSectorZ]; + if ( MusicSoundValues[ SECTOR( gubPBSectorX, gubPBSectorY ) ].SoundTacticalTensor[gubPBSectorZ] != -1 ) + SetMusicModeID( MUSIC_TACTICAL_ENEMYPRESENT, MusicSoundValues[ SECTOR( gubPBSectorX, gubPBSectorY ) ].SoundTacticalTensor[gubPBSectorZ] ); + else SetMusicMode( MUSIC_TACTICAL_ENEMYPRESENT ); #ifdef JA2UB @@ -2210,4 +2214,4 @@ void HandlePreBattleInterfaceStates() { gfTransitionMapscreenToAutoResolve = FALSE; } -} +} diff --git a/Strategic/Strategic Movement.cpp b/Strategic/Strategic Movement.cpp index 1061c8cd..407ee1aa 100644 --- a/Strategic/Strategic Movement.cpp +++ b/Strategic/Strategic Movement.cpp @@ -963,6 +963,10 @@ void PrepareForPreBattleInterface( GROUP *pPlayerDialogGroup, GROUP *pInitiating UseCreatureMusic(HostileZombiesPresent()); #endif + GlobalSoundID = MusicSoundValues[ SECTOR( gWorldSectorX, gWorldSectorY ) ].SoundTacticalTensor[gbWorldSectorZ]; + if ( MusicSoundValues[ SECTOR( gWorldSectorX, gWorldSectorY ) ].SoundTacticalTensor[gbWorldSectorZ] != -1 ) + SetMusicModeID( MUSIC_TACTICAL_ENEMYPRESENT, MusicSoundValues[ SECTOR( gWorldSectorX, gWorldSectorY ) ].SoundTacticalTensor[gbWorldSectorZ] ); + else SetMusicMode( MUSIC_TACTICAL_ENEMYPRESENT ); if( gfTacticalTraversal && pInitiatingBattleGroup == gpTacticalTraversalGroup || diff --git a/Tactical/Auto Bandage.cpp b/Tactical/Auto Bandage.cpp index 352dd422..6509a60b 100644 --- a/Tactical/Auto Bandage.cpp +++ b/Tactical/Auto Bandage.cpp @@ -29,6 +29,7 @@ #include "English.h" #endif +#include "Music Control.h" // max number of merc faces per row in autobandage box #define NUMBER_MERC_FACES_AUTOBANDAGE_BOX 4 @@ -154,6 +155,12 @@ void BeginAutoBandage( ) DoMessageBox( MSG_BOX_BASIC_STYLE, TacticalStr[ BEGIN_AUTOBANDAGE_PROMPT_STR ], GAME_SCREEN, ( UINT8 )MSG_BOX_FLAG_YESNO, BeginAutoBandageCallBack, NULL ); } } + + GlobalSoundID = MusicSoundValues[ SECTOR( gWorldSectorX, gWorldSectorY ) ].SoundTacticalNothing[gbWorldSectorZ]; + if ( MusicSoundValues[ SECTOR( gWorldSectorX, gWorldSectorY ) ].SoundTacticalNothing[gbWorldSectorZ] != -1 ) + SetMusicModeID( MUSIC_TACTICAL_NOTHING, MusicSoundValues[ SECTOR( gWorldSectorX, gWorldSectorY ) ].SoundTacticalNothing[gbWorldSectorZ] ); + else + SetMusicMode( MUSIC_TACTICAL_NOTHING ); } diff --git a/Tactical/Boxing.cpp b/Tactical/Boxing.cpp index 8cce8f2f..862a561a 100644 --- a/Tactical/Boxing.cpp +++ b/Tactical/Boxing.cpp @@ -117,6 +117,11 @@ void ExitBoxing( void ) if ( CheckForEndOfCombatMode( FALSE ) ) { EndTopMessage(); + + GlobalSoundID = MusicSoundValues[ SECTOR( gWorldSectorX, gWorldSectorY ) ].SoundTacticalNothing[gbWorldSectorZ]; + if ( MusicSoundValues[ SECTOR( gWorldSectorX, gWorldSectorY ) ].SoundTacticalNothing[gbWorldSectorZ] != -1 ) + SetMusicModeID( MUSIC_TACTICAL_NOTHING, MusicSoundValues[ SECTOR( gWorldSectorX, gWorldSectorY ) ].SoundTacticalNothing[gbWorldSectorZ] ); + else SetMusicMode( MUSIC_TACTICAL_NOTHING ); // Lock UI until we get out of the ring diff --git a/Tactical/Overhead.cpp b/Tactical/Overhead.cpp index 4b89a734..c6f64923 100644 --- a/Tactical/Overhead.cpp +++ b/Tactical/Overhead.cpp @@ -7215,6 +7215,13 @@ BOOLEAN CheckForEndOfBattle( BOOLEAN fAnEnemyRetreated ) HandleFirstBattleEndingWhileInTown( gWorldSectorX, gWorldSectorY, gbWorldSectorZ, FALSE ); #endif } + + GlobalSoundID = MusicSoundValues[ SECTOR( gWorldSectorX, gWorldSectorY ) ].SoundTacticalNothing[gbWorldSectorZ]; + if ( MusicSoundValues[ SECTOR( gWorldSectorX, gWorldSectorY ) ].SoundTacticalNothing[gbWorldSectorZ] != -1 ) + SetMusicModeID( MUSIC_TACTICAL_NOTHING, MusicSoundValues[ SECTOR( gWorldSectorX, gWorldSectorY ) ].SoundTacticalNothing[gbWorldSectorZ] ); + else + SetMusicMode( MUSIC_TACTICAL_NOTHING ); + } //Whenever returning TRUE, make sure you clear gfBlitBattleSectorLocator; diff --git a/Tactical/Rotting Corpses.cpp b/Tactical/Rotting Corpses.cpp index 4dd0abc2..a9d78a87 100644 --- a/Tactical/Rotting Corpses.cpp +++ b/Tactical/Rotting Corpses.cpp @@ -2652,7 +2652,14 @@ UINT8 GetNearestRottingCorpseAIWarning( INT32 sGridNo ) PlayJA2SampleFromFile( "Sounds\\zombie1.wav", RATE_11025, HIGHVOLUME, 1, MIDDLEPAN ); UseCreatureMusic(TRUE); // Madd: music when zombies rise + + GlobalSoundID = MusicSoundValues[ SECTOR( gWorldSectorX, gWorldSectorY ) ].SoundTacticalTensor[gbWorldSectorZ]; + if ( MusicSoundValues[ SECTOR( gWorldSectorX, gWorldSectorY ) ].SoundTacticalTensor[gbWorldSectorZ] != -1 ) + SetMusicModeID( MUSIC_TACTICAL_ENEMYPRESENT, MusicSoundValues[ SECTOR( gWorldSectorX, gWorldSectorY ) ].SoundTacticalTensor[gbWorldSectorZ] ); + else SetMusicMode( MUSIC_TACTICAL_ENEMYPRESENT ); + + } } } diff --git a/Utils/Music Control.cpp b/Utils/Music Control.cpp index f37faf92..0222d061 100644 --- a/Utils/Music Control.cpp +++ b/Utils/Music Control.cpp @@ -11,6 +11,7 @@ #include "strategicmap.h" #endif +#include "Overhead Types.h" //extern int iScreenMode; static UINT32 uiMusicHandle = NO_SAMPLE; @@ -168,6 +169,25 @@ BOOLEAN MusicPlay(UINT32 uiNum, UINT32 MusicMode, BOOLEAN NewSound ) if ( !FileExists( zFileName ) ) sprintf( zFileName, "%s\\TRIUMPH_%d.wav", szMusicList[15], uiNum ); } + else if ( MusicMode == MUSIC_TACTICAL_BATTLE_MUSIC ) + { + sprintf( zFileName, "%s\\CREATURE_BATTLE_%d.ogg", szMusicList[15], uiNum); + if ( !FileExists( zFileName ) ) + sprintf( zFileName, "%s\\CREATURE_BATTLE_%d.wav", szMusicList[15], uiNum ); + } + else if ( MusicMode == MUSIC_TACTICAL_CREEPY_MUSIC ) + { + sprintf( zFileName, "%s\\CREEPY_%d.ogg", szMusicList[15], uiNum); + if ( !FileExists( zFileName ) ) + sprintf( zFileName, "%s\\CREEPY_%d.wav", szMusicList[15], uiNum ); + } + else if ( MusicMode == OTHER_MUSIC_TACTICAL ) + { + sprintf( zFileName, "%s\\%d.ogg", szMusicList[15], uiNum); + if ( !FileExists( zFileName ) ) + sprintf( zFileName, "%s\\%d.wav", szMusicList[15], uiNum ); + } + } uiMusicHandle = SoundPlayStreamedFile(zFileName, &spParms); @@ -542,6 +562,8 @@ static BOOLEAN StartMusicBasedOnMode(void) { static BOOLEAN fFirstTime = TRUE; + static BOOLEAN fCivGroup = FALSE; + if (fFirstTime) { fFirstTime = FALSE; @@ -581,7 +603,7 @@ static BOOLEAN StartMusicBasedOnMode(void) else { SetSoundID = TRUE; - MusicPlay(NewSoundID,MUSIC_TACTICAL_NOTHING,TRUE); + MusicPlay(NewSoundID,MUSIC_TACTICAL_CREEPY_MUSIC,TRUE); } } else @@ -646,7 +668,7 @@ static BOOLEAN StartMusicBasedOnMode(void) else { SetSoundID = TRUE; - MusicPlay(NewSoundID,MUSIC_TACTICAL_BATTLE,TRUE); + MusicPlay(NewSoundID,MUSIC_TACTICAL_BATTLE_MUSIC,TRUE); } } else diff --git a/Utils/Music Control.h b/Utils/Music Control.h index a0c0cbd6..fedbb6aa 100644 --- a/Utils/Music Control.h +++ b/Utils/Music Control.h @@ -1,6 +1,8 @@ #ifndef _MUSIC_CONTROL_H_ #define _MUSIC_CONTROL_H_ +#include "Overhead Types.h" + enum MusicList { MARIMBAD2_MUSIC, @@ -34,6 +36,10 @@ enum MusicMode MUSIC_TACTICAL_DEATH, MUSIC_LAPTOP, MUSIC_OLD_TYPE, + MUSIC_TACTICAL_BATTLE_MUSIC, + MUSIC_TACTICAL_CREEPY_MUSIC, + OTHER_MUSIC_TACTICAL, + MUSIC_TACTICAL_CIV_GROUP_BATTLE, }; typedef struct @@ -44,6 +50,9 @@ typedef struct INT32 SoundTacticalNothing[4]; INT32 SoundTacticalTensor[4]; INT32 SoundTacticalDeath[4]; + INT32 SoundTacticalBattleCreature[4]; + INT32 SoundTacticalBattleCreepy[4]; + INT32 SoundTacticalBattleGroup[NUM_CIV_GROUPS]; } MUSIC_SOUND_VALUES;