From cd1c0a4e4302d3ba906a42b1711a27db16abcab2 Mon Sep 17 00:00:00 2001 From: Wanne Date: Sat, 19 Apr 2014 09:24:17 +0000 Subject: [PATCH] Merged from revision: 7155 Custom sounds for non-guns (by anv) - knives, throwing knives, blunt weapons can use attack sounds specified with tag - previously their sound was chosen depending on animation used and hardcoded - it should open space for exotic weapons like chainsaws, lawn mowers, jackhammers, etc. If is left unspecified, default hardcoded sound will be used normally. - knives, throwing knives, blunt weapons, launchers on attack can cause noise specified with , previously it was ignored for anything but guns, - small fix for knife/wire cutters combo where using it on empty grid would cause deadlock during battle. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7156 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Handle Items.cpp | 4 ++-- Tactical/Soldier Ani.cpp | 26 ++++++++++++++++++++++++-- Tactical/Weapons.cpp | 16 ++++++++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/Tactical/Handle Items.cpp b/Tactical/Handle Items.cpp index c62ed011..fa2ae502 100644 --- a/Tactical/Handle Items.cpp +++ b/Tactical/Handle Items.cpp @@ -893,7 +893,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bLevel, UINT16 usHa { // See if we can get there to stab sActionGridNo = FindAdjacentGridEx( pSoldier, sGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE ); - if ( sActionGridNo != -1 ) + if ( sActionGridNo != -1 && IsCuttableWireFenceAtGridNo( sGridNo ) ) { // Calculate AP costs... sAPCost = GetAPsToCutFence( pSoldier ); @@ -939,7 +939,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bLevel, UINT16 usHa return( ITEM_HANDLE_NOAPS ); } } - else + else if( sActionGridNo == -1 ) { return( ITEM_HANDLE_CANNOT_GETTO_LOCATION ); } diff --git a/Tactical/Soldier Ani.cpp b/Tactical/Soldier Ani.cpp index d4fcff13..266630b6 100644 --- a/Tactical/Soldier Ani.cpp +++ b/Tactical/Soldier Ani.cpp @@ -2714,7 +2714,18 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier ) case 709: // Knife throw sound... - PlayJA2Sample( Weapon[ THROWING_KNIFE ].sSound, RATE_11025, SoundVolume( HIGHVOLUME, pSoldier->sGridNo ), 1, SoundDir( pSoldier->sGridNo ) ); + // anv: possiblity to use custom sounds for throwing knives + { + UINT16 usedWeapon = pSoldier->GetUsedWeaponNumber( &pSoldier->inv[ pSoldier->ubAttackingHand ] ); + if ( Weapon[ usedWeapon ].sSound != 0 ) + { + PlayJA2Sample( Weapon[ usedWeapon ].sSound, 44100-Random(5000)-Random(5000)-Random(5000), SoundVolume( HIGHVOLUME, pSoldier->sGridNo ), 1, SoundDir( pSoldier->sGridNo ) ); + } + else + { + PlayJA2Sample( Weapon[ THROWING_KNIFE ].sSound, RATE_11025, SoundVolume( HIGHVOLUME, pSoldier->sGridNo ), 1, SoundDir( pSoldier->sGridNo ) ); + } + } break; case 710: @@ -2909,7 +2920,18 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier ) case 727: // Swoosh - PlaySoldierJA2Sample( pSoldier->ubID, (UINT8)( SWOOSH_1 + Random( 6 ) ), RATE_11025, SoundVolume( HIGHVOLUME, pSoldier->sGridNo ), 1, SoundDir( pSoldier->sGridNo ), TRUE ); + // anv: possiblity to use custom sounds for melee weapons + { + UINT16 usedWeapon = pSoldier->GetUsedWeaponNumber( &pSoldier->inv[ pSoldier->ubAttackingHand ] ); + if ( Weapon[ usedWeapon ].sSound != 0 ) + { + PlayJA2Sample( Weapon[ usedWeapon ].sSound, 44100-Random(5000)-Random(5000)-Random(5000), SoundVolume( HIGHVOLUME, pSoldier->sGridNo ), 1, SoundDir( pSoldier->sGridNo ) ); + } + else + { + PlaySoldierJA2Sample( pSoldier->ubID, (UINT8)( SWOOSH_1 + Random( 6 ) ), RATE_11025, SoundVolume( HIGHVOLUME, pSoldier->sGridNo ), 1, SoundDir( pSoldier->sGridNo ), TRUE ); + } + } break; case 728: diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index 0e727720..28066a1c 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -3199,6 +3199,11 @@ BOOLEAN UseBlade( SOLDIERTYPE *pSoldier , INT32 sTargetGridNo ) // FreeUpAttacker( (UINT8) pSoldier->ubID ); // } + // anv: melee attack noise + UINT16 usUBItem = pSoldier->GetUsedWeaponNumber( &pSoldier->inv[ pSoldier->ubAttackingHand ] ); + UINT8 ubVolume = Weapon[ usUBItem ].ubAttackVolume; + MakeNoise( pSoldier->ubID, pSoldier->sGridNo, pSoldier->pathing.bLevel, pSoldier->bOverTerrainType, ubVolume, NOISE_UNKNOWN ); + // possibly reduce monster smell if ( pSoldier->aiData.bMonsterSmell > 0 && Random( 5 ) == 0 ) { @@ -3880,6 +3885,11 @@ BOOLEAN UseHandToHand( SOLDIERTYPE *pSoldier, INT32 sTargetGridNo, BOOLEAN fStea } } + // anv: hth (inluding blunt weapons) attack noise + UINT16 usUBItem = pSoldier->GetUsedWeaponNumber( &pSoldier->inv[ pSoldier->ubAttackingHand ] ); + UINT8 ubVolume = Weapon[ usUBItem ].ubAttackVolume; + MakeNoise( pSoldier->ubID, pSoldier->sGridNo, pSoldier->pathing.bLevel, pSoldier->bOverTerrainType, ubVolume, NOISE_UNKNOWN ); + // possibly reduce monster smell (gunpowder smell) if ( pSoldier->aiData.bMonsterSmell > 0 && Random( 5 ) == 0 ) { @@ -4022,6 +4032,12 @@ BOOLEAN UseThrown( SOLDIERTYPE *pSoldier, INT32 sTargetGridNo ) DeductPoints( pSoldier, sAPCost, 0 ); RemoveObjs( &(pSoldier->inv[ HANDPOS ] ), 1 ); */ + + // anv: knife throw attack noise + UINT16 usUBItem = pSoldier->GetUsedWeaponNumber( &pSoldier->inv[ pSoldier->ubAttackingHand ] ); + UINT8 ubVolume = Weapon[ usUBItem ].ubAttackVolume; + MakeNoise( pSoldier->ubID, pSoldier->sGridNo, pSoldier->pathing.bLevel, pSoldier->bOverTerrainType, ubVolume, NOISE_UNKNOWN ); + return( TRUE ); }