From 3c836ba191ae7eaeaeff0382634b2781b06633a7 Mon Sep 17 00:00:00 2001 From: Flugente Date: Mon, 24 Oct 2016 20:15:35 +0000 Subject: [PATCH] Items in a slot granted by LBE with the flag LBE_EXPLOSIONPROOF ( 2147483648) are protected from explosion damage (and cannot cause a chain reaction). git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8335 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Item Types.h | 2 +- Tactical/Items.cpp | 32 +++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/Tactical/Item Types.h b/Tactical/Item Types.h index 8b207b96e..b3d21e176 100644 --- a/Tactical/Item Types.h +++ b/Tactical/Item Types.h @@ -769,7 +769,7 @@ extern OBJECTTYPE gTempObject; #define ROOF_COLLAPSE_ITEM 0x10000000 //268435456 // this item is required in the collapsing of roof tiles. It is used internally and should never be seen by the player #define DISEASEPROTECTION_1 0x20000000 //536870912 // this item protects us from getting diseases by human contact if kept in inventory #define DISEASEPROTECTION_2 0x40000000 //1073741824 // this item protects us from getting diseases by human contact if kept in inventory -/*#define PLAYER_NET_4_LVL_4 0x80000000 //2147483648*/ +#define LBE_EXPLOSIONPROOF 0x80000000 //2147483648 // any gear in LBE with this flag is protected from explosions // ---------------------------------------------------------------- // -------- added by Flugente: flags for objects -------- diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index 568fbfd48..af7f787ef 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -92,6 +92,8 @@ extern BOOLEAN fMapInventoryZoom; // HEADROCK HAM 5: And this, for checking whether an item is in the pool. extern std::vector pInventoryPoolList; +extern INT16 uiNIVSlotType[NUM_INV_SLOTS]; + UINT16 OldWayOfCalculatingScopeBonus(SOLDIERTYPE *pSoldier); // weight units are 100g each @@ -8966,9 +8968,37 @@ void CheckEquipmentForDamage( SOLDIERTYPE *pSoldier, INT32 iDamage ) UINT8 invsize = pSoldier->inv.size(); for (UINT8 bSlot = 0; bSlot < invsize; ++bSlot) { - if (pSoldier->inv[bSlot].exists() == false) { + if (pSoldier->inv[bSlot].exists() == false){ continue; } + + // Flugente: if this item is 'in' LBE that protects it, don't damage it + if ( UsingNewInventorySystem( ) ) + { + INT16 lbeslot = 0; + + switch ( uiNIVSlotType[bSlot] ) + { + case 3: lbeslot = VESTPOCKPOS; break; + case 4: + if ( bSlot == MEDPOCK3POS || bSlot == SMALLPOCK11POS || bSlot == SMALLPOCK12POS || bSlot == SMALLPOCK13POS || bSlot == SMALLPOCK14POS ) + lbeslot = LTHIGHPOCKPOS; + else + lbeslot = RTHIGHPOCKPOS; + break; + case 5: lbeslot = CPACKPOCKPOS; break; + case 6: lbeslot = BPACKPOCKPOS; break; + default: + break; + } + + if ( VESTPOCKPOS <= lbeslot && lbeslot <= BPACKPOCKPOS ) + { + if ( pSoldier->inv[lbeslot].exists( ) && HasItemFlag( pSoldier->inv[lbeslot].usItem, LBE_EXPLOSIONPROOF ) ) + continue; + } + } + ubNumberOfObjects = pSoldier->inv[bSlot].ubNumberOfObjects; fBlowsUp = DamageItem( &(pSoldier->inv[bSlot]), iDamage, FALSE ); if (fBlowsUp)