From d0b9c0a0325551a41d4411cc73597fb7c2bd2f19 Mon Sep 17 00:00:00 2001 From: Flugente Date: Sun, 7 Apr 2013 22:54:43 +0000 Subject: [PATCH] Fix: underbarrel weapons did not properly cause explosions according to their ammotype git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5988 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- TileEngine/Explosion Control.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/TileEngine/Explosion Control.cpp b/TileEngine/Explosion Control.cpp index cdaf7872..1c367cef 100644 --- a/TileEngine/Explosion Control.cpp +++ b/TileEngine/Explosion Control.cpp @@ -297,11 +297,18 @@ void InternalIgniteExplosion( UINT8 ubOwner, INT16 sX, INT16 sY, INT16 sZ, INT32 return; // no explosive / no attacker } + // The ammotype used. WARNING! This will only be != 0 if ubOwner != NOBODY ! + UINT16 ammotype = 0; + // Okay, we either got an explosive or a real attacker to check for. // Let's check for the attacker first. if ( ubOwner != NOBODY ) { - if ( !( Item[ usItem ].usItemClass & IC_EXPLOSV ) && AmmoTypes[MercPtrs[ubOwner]->inv[MercPtrs[ubOwner]->ubAttackingHand ][0]->data.gun.ubGunAmmoType].explosionSize < 2 ) + OBJECTTYPE* pUsedGun = MercPtrs[ ubOwner ]->GetUsedWeapon( &MercPtrs [ ubOwner ]->inv[MercPtrs[ubOwner]->ubAttackingHand] ); + + ammotype = (*pUsedGun)[0]->data.gun.ubGunAmmoType; + + if ( !( Item[ usItem ].usItemClass & IC_EXPLOSV ) && AmmoTypes[ammotype].explosionSize < 2 ) { return; // no explosive and attackers gun is not fireing HE } @@ -328,7 +335,7 @@ void InternalIgniteExplosion( UINT8 ubOwner, INT16 sX, INT16 sY, INT16 sZ, INT32 // No explosive but an attacker with HE ammo. if ( !( Item[ usItem ].usItemClass & IC_EXPLOSV ) && ubOwner != NOBODY) { - ExpParams.ubTypeID = (INT8)Explosive[AmmoTypes[MercPtrs[ubOwner]->inv[MercPtrs[ubOwner]->ubAttackingHand ][0]->data.gun.ubGunAmmoType].highExplosive].ubAnimationID; + ExpParams.ubTypeID = (INT8)Explosive[AmmoTypes[ammotype].highExplosive].ubAnimationID; // return; } else // just normal explosives should get here