Dropping items from hand when being hit:

- civilians with profile should not drop items from hand as it may break quests
- fixed possible incorrect type conversion which could result in dropping too often if weapon in hand marked as undroppable

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9280 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Sevenfm
2022-01-27 01:24:11 +00:00
parent c29e070ccf
commit 49989da8b1
+5 -5
View File
@@ -10741,22 +10741,22 @@ UINT8 SOLDIERTYPE::SoldierTakeDamage( INT8 bHeight, INT16 sLifeDeduct, INT16 sBr
} }
// OK, if here, let's see if we should drop our weapon.... // OK, if here, let's see if we should drop our weapon....
if ( !dropiteminmainhand && ubReason != TAKE_DAMAGE_BLOODLOSS && !(AM_A_ROBOT( this )) ) if (!dropiteminmainhand && ubReason != TAKE_DAMAGE_BLOODLOSS && !(AM_A_ROBOT(this)) && !(this->bTeam == CIV_TEAM && this->ubProfile != NO_PROFILE))
{ {
INT16 sTestOne, sTestTwo, sChanceToDrop; INT16 sTestOne, sTestTwo, sChanceToDrop;
INT8 bVisible = -1; INT8 bVisible = -1;
sTestOne = EffectiveStrength( this, FALSE ); sTestOne = EffectiveStrength( this, FALSE );
sTestTwo = (2 * (__max( sLifeDeduct, (sBreathLoss / 100) ))); sTestTwo = 2 * max(sLifeDeduct, (sBreathLoss / 100));
if ( this->ubAttackerID != NOBODY && MercPtrs[this->ubAttackerID]->ubBodyType == BLOODCAT ) if (this->ubAttackerID != NOBODY && MercPtrs[this->ubAttackerID]->ubBodyType == BLOODCAT)
{ {
// bloodcat boost, let them make people drop items more // bloodcat boost, let them make people drop items more
sTestTwo += 20; sTestTwo += 20;
} }
// If damage > effective strength.... // If damage > effective strength....
sChanceToDrop = (__max( 0, (sTestTwo - sTestOne) )); sChanceToDrop = sTestTwo - sTestOne;
// ATE: Increase odds of NOT dropping an UNDROPPABLE OBJECT // ATE: Increase odds of NOT dropping an UNDROPPABLE OBJECT
if ( (this->inv[HANDPOS].fFlags & OBJECT_UNDROPPABLE) ) if ( (this->inv[HANDPOS].fFlags & OBJECT_UNDROPPABLE) )
@@ -10768,7 +10768,7 @@ UINT8 SOLDIERTYPE::SoldierTakeDamage( INT8 bHeight, INT16 sLifeDeduct, INT16 sBr
//ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_TESTVERSION, L"Chance To Drop Weapon: str: %d Dam: %d Chance: %d", sTestOne, sTestTwo, sChanceToDrop ); //ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_TESTVERSION, L"Chance To Drop Weapon: str: %d Dam: %d Chance: %d", sTestOne, sTestTwo, sChanceToDrop );
#endif #endif
if ( Random( 100 ) < (UINT16)sChanceToDrop ) if ((INT16)Random(100) < sChanceToDrop)
{ {
dropiteminmainhand = true; dropiteminmainhand = true;
} }