diff --git a/Tactical/Handle Items.cpp b/Tactical/Handle Items.cpp index c571ecf0..7f2ee470 100644 --- a/Tactical/Handle Items.cpp +++ b/Tactical/Handle Items.cpp @@ -101,6 +101,7 @@ extern BOOL GetBetterObject_InventoryPool( UINT16 usItem, INT16 status, UINT32& extern BOOL GetFittingAmmo_InventoryPool( UINT8 usCalibre, UINT8 usAmmoType, UINT32& arLoop ); extern BOOLEAN HandleNailsVestFetish( SOLDIERTYPE *pSoldier, UINT32 uiHandPos, UINT16 usReplaceItem ); +extern void PlaySplashSound(INT32 sGridNo); extern std::vector pInventoryPoolList; extern INT32 GetAttachmentInfoIndex( UINT16 usItem ); @@ -2114,7 +2115,22 @@ void SoldierHandleDropItem( SOLDIERTYPE *pSoldier ) { if ( pSoldier->bVisible != -1 ) { - PlayJA2Sample( THROW_IMPACT_2, RATE_11025, SoundVolume( MIDVOLUME, pSoldier->sGridNo ), 1, SoundDir( pSoldier->sGridNo ) ); + if (Water(pSoldier->sGridNo, pSoldier->pathing.bLevel)) + { + UINT16 usItem = pSoldier->pTempObject->usItem; + INT32 sGridNo = pSoldier->sGridNo; + + if (HasItemFlag(usItem, CORPSE)) + PlayJA2Sample(ENTER_DEEP_WATER_1, RATE_11025, SoundVolume(MIDVOLUME, sGridNo), 1, SoundDir(sGridNo)); + else if (Item[usItem].ubWeight > 10) + PlayJA2Sample(ENTER_WATER_1, RATE_11025, SoundVolume(MIDVOLUME, sGridNo), 1, SoundDir(sGridNo)); + else + PlaySplashSound(sGridNo); + } + else + { + PlayJA2Sample(THROW_IMPACT_2, RATE_11025, SoundVolume(MIDVOLUME, pSoldier->sGridNo), 1, SoundDir(pSoldier->sGridNo)); + } } AddItemToPool( pSoldier->sGridNo, pSoldier->pTempObject, 1, pSoldier->pathing.bLevel, 0 , -1 ); diff --git a/Tactical/Soldier Ani.cpp b/Tactical/Soldier Ani.cpp index 2dc12389..05ca3344 100644 --- a/Tactical/Soldier Ani.cpp +++ b/Tactical/Soldier Ani.cpp @@ -115,6 +115,7 @@ extern UINT8 gubInterruptProvoker; extern UINT16 PickSoldierReadyAnimation( SOLDIERTYPE *pSoldier, BOOLEAN fEndReady, BOOLEAN fHipStance ); extern bool RemoveOneTurncoat( INT16 sSectorX, INT16 sSectorY, UINT8 aSoldierClass ); +extern void PlaySplashSound(INT32 sGridNo); // Animation code explanations! // @@ -3190,7 +3191,22 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier ) { if ( pSoldier->bVisible != -1 ) { - PlayJA2Sample( THROW_IMPACT_2, RATE_11025, SoundVolume( MIDVOLUME, pSoldier->sGridNo ), 1, SoundDir( pSoldier->sGridNo ) ); + if (Water(pSoldier->aiData.sPendingActionData2, pSoldier->pathing.bLevel)) + { + UINT16 usItem = pSoldier->pTempObject->usItem; + INT32 sGridNo = pSoldier->aiData.sPendingActionData2; + + if (HasItemFlag(usItem, CORPSE)) + PlayJA2Sample(ENTER_DEEP_WATER_1, RATE_11025, SoundVolume(MIDVOLUME, sGridNo), 1, SoundDir(sGridNo)); + else if (Item[usItem].ubWeight > 10) + PlayJA2Sample(ENTER_WATER_1, RATE_11025, SoundVolume(MIDVOLUME, sGridNo), 1, SoundDir(sGridNo)); + else + PlaySplashSound(sGridNo); + } + else + { + PlayJA2Sample(THROW_IMPACT_2, RATE_11025, SoundVolume(MIDVOLUME, pSoldier->sGridNo), 1, SoundDir(pSoldier->sGridNo)); + } } AddItemToPool( pSoldier->aiData.sPendingActionData2, pSoldier->pTempObject, 1, pSoldier->pathing.bLevel, 0 , -1 ); diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index 8bade039..ae5403a2 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -5872,14 +5872,13 @@ void StructureHit( INT32 iBullet, UINT16 usWeaponIndex, INT16 bWeaponStatus, UIN } else { - if ( sZPos == 0 ) - { + if (Water(sGridNo, bLevel)) + PlayJA2Sample(S_WATER_IMPACT1, RATE_11025, uiMissVolume, 1, SoundDir(sGridNo)); + else if ( sZPos == 0 ) PlayJA2Sample( MISS_G2 , RATE_11025, 5, 1, SoundDir( sGridNo ) ); - } else - { PlayJA2Sample( MISS_1 + Random(8), RATE_11025, 5, 1, SoundDir( sGridNo ) ); - } + RemoveBullet( iBullet ); } @@ -5915,14 +5914,12 @@ void StructureHit( INT32 iBullet, UINT16 usWeaponIndex, INT16 bWeaponStatus, UIN if ( !fStopped || !DoSpecialEffectAmmoMiss( ubAttackerID, usWeaponIndex, sGridNo, sXPos, sYPos, sZPos, FALSE, TRUE, iBullet ) ) { - if ( sZPos == 0 ) - { + if (Water(sGridNo, bLevel)) + PlayJA2Sample(S_WATER_IMPACT1, RATE_11025, uiMissVolume, 1, SoundDir(sGridNo)); + else if ( sZPos == 0 ) PlayJA2Sample( MISS_G2 , RATE_11025, uiMissVolume, 1, SoundDir( sGridNo ) ); - } else - { PlayJA2Sample( MISS_1 + Random(8), RATE_11025, uiMissVolume, 1, SoundDir( sGridNo ) ); - } // Default hit is the ground usMissTileIndex = FIRSTMISS1; diff --git a/TileEngine/physics.cpp b/TileEngine/physics.cpp index 8df7d76f..9bc20d71 100644 --- a/TileEngine/physics.cpp +++ b/TileEngine/physics.cpp @@ -779,6 +779,31 @@ void PhysicsDeleteObject( REAL_OBJECT *pObject ) INT16 gsWaterSplashSoundNum = -1; +void PlaySplashSound(INT32 sGridNo) +{ + // sevenfm: also play sound + CHAR8 zFilename[512]; + // prepare water splash sound + if (gsWaterSplashSoundNum < 0) + { + gsWaterSplashSoundNum = 0; + do + { + gsWaterSplashSoundNum++; + sprintf(zFilename, "sounds\\misc\\Splash%d.ogg", gsWaterSplashSoundNum); + } while (FileExists(zFilename)); + gsWaterSplashSoundNum--; + } + if (gsWaterSplashSoundNum > 0) + { + sprintf(zFilename, "sounds\\misc\\Splash%d.ogg", Random(gsWaterSplashSoundNum) + 1); + if (FileExists(zFilename)) + { + PlayJA2SampleFromFile(zFilename, RATE_11025, SoundVolume(MIDVOLUME, sGridNo), 1, SoundDir(sGridNo)); + } + } +} + BOOLEAN PhysicsCheckForCollisions( REAL_OBJECT *pObject, INT32 *piCollisionID ) { vector_3 vTemp; @@ -1113,26 +1138,15 @@ BOOLEAN PhysicsCheckForCollisions( REAL_OBJECT *pObject, INT32 *piCollisionID ) pNode->pLevelNode->sRelativeZ = (INT16)CONVERT_HEIGHTUNITS_TO_PIXELS( (INT16)pObject->Position.z ); // sevenfm: also play sound - CHAR8 zFilename[512]; - // prepare water splash sound - if (gsWaterSplashSoundNum < 0) - { - gsWaterSplashSoundNum = 0; - do - { - gsWaterSplashSoundNum++; - sprintf(zFilename, "sounds\\misc\\Splash%d.ogg", gsWaterSplashSoundNum); - } while (FileExists(zFilename)); - gsWaterSplashSoundNum--; - } - if (gsWaterSplashSoundNum > 0) - { - sprintf(zFilename, "sounds\\misc\\Splash%d.ogg", Random(gsWaterSplashSoundNum) + 1); - if (FileExists(zFilename)) - { - PlayJA2SampleFromFile(zFilename, RATE_11025, SoundVolume(MIDVOLUME, pObject->sGridNo), 1, SoundDir(pObject->sGridNo)); - } - } + UINT16 usItem = pObject->Obj.usItem; + INT32 sGridNo = pObject->sGridNo; + + if (HasItemFlag(usItem, CORPSE)) + PlayJA2Sample(ENTER_DEEP_WATER_1, RATE_11025, SoundVolume(MIDVOLUME, sGridNo), 1, SoundDir(sGridNo)); + else if (Item[usItem].ubWeight > 10) + PlayJA2Sample(ENTER_WATER_1, RATE_11025, SoundVolume(MIDVOLUME, sGridNo), 1, SoundDir(sGridNo)); + else + PlaySplashSound(sGridNo); } }