mirror of
https://github.com/1dot13/source.git
synced 2026-07-29 13:52:17 +02:00
Fixed function PickPocket to work with MOLLE type of LBEs (by Shadooow).
Changed code that handles putting medical kit from merc inventory into his main hand to respect pockets restrictions to avoid putting gun into medkit only pocket etc.. Writes an error in case that medical kit cannot be put into hands due to no suitable place for currently held items (by Shadooow). git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9015 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+58
-19
@@ -1458,7 +1458,7 @@ BOOLEAN CanCharacterRepair( SOLDIERTYPE *pSoldier )
|
||||
}
|
||||
|
||||
// anything around to clean?
|
||||
if ( pSoldier->GetObjectWithFlag( CLEANING_KIT ) != NULL && IsAnythingAroundForSoldierToClean( pSoldier ) )
|
||||
if ( pSoldier->GetObjectWithFlag( CLEANING_KIT ) != NULL && IsAnythingAroundForSoldierToClean( pSoldier ) )//todo shadooow: not if dirty system is disabled
|
||||
{
|
||||
return( TRUE );
|
||||
}
|
||||
@@ -10432,10 +10432,10 @@ BOOLEAN MakeSureToolKitIsInHand( SOLDIERTYPE *pSoldier )
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN MakeSureMedKitIsInHand( SOLDIERTYPE *pSoldier )
|
||||
BOOLEAN MakeSureMedKitIsInHand( SOLDIERTYPE *pSoldier , bool bAllow1stAidKit)
|
||||
{
|
||||
INT8 bPocket = 0;
|
||||
|
||||
bool can_swap = true, medkit_found = false;
|
||||
fTeamPanelDirty = TRUE;
|
||||
|
||||
// if there is a MEDICAL BAG in his hand, we're set
|
||||
@@ -10445,29 +10445,68 @@ BOOLEAN MakeSureMedKitIsInHand( SOLDIERTYPE *pSoldier )
|
||||
}
|
||||
|
||||
// run through rest of inventory looking 1st for MEDICAL BAGS, swap the first one into hand if found
|
||||
// CHRISL: Changed to dynamically determine max inventory locations.
|
||||
for (bPocket = SECONDHANDPOS; bPocket < NUM_INV_SLOTS; ++bPocket)
|
||||
{
|
||||
if ( Item[pSoldier->inv[ bPocket ].usItem].medicalkit )
|
||||
{
|
||||
medkit_found = true;
|
||||
can_swap = true;
|
||||
fCharacterInfoPanelDirty = TRUE;
|
||||
// HEADROCK HAM B2.8: These new conditions will create a bias for swapping an item out of
|
||||
// our hand.
|
||||
|
||||
//If the second hand is free, the item will go to the SECONDHANDPOS while the medikit
|
||||
// goes into the HANDPOS
|
||||
if( Item[pSoldier->inv[HANDPOS].usItem].usItemClass & (IC_WEAPON | IC_PUNCH) && !pSoldier->inv[SECONDHANDPOS].exists())
|
||||
SwapObjs(pSoldier, HANDPOS, SECONDHANDPOS, TRUE);
|
||||
// Else, if the gun sling slot is free, and the item can go there, it will.
|
||||
else if(UsingNewInventorySystem() && !pSoldier->inv[GUNSLINGPOCKPOS].exists() && CanItemFitInPosition(pSoldier, &pSoldier->inv[HANDPOS], GUNSLINGPOCKPOS, FALSE))
|
||||
SwapObjs(pSoldier, HANDPOS, GUNSLINGPOCKPOS, TRUE);
|
||||
else if(!CanItemFitInPosition(pSoldier, &pSoldier->inv[HANDPOS], bPocket, FALSE))
|
||||
SwapObjs(pSoldier, HANDPOS, SECONDHANDPOS, TRUE);
|
||||
|
||||
SwapObjs( pSoldier, HANDPOS, bPocket, TRUE );
|
||||
return(TRUE);
|
||||
//shadooow: rules for item swapping rewritten to honor pocket restrictions
|
||||
//nothing in main hand
|
||||
if (!pSoldier->inv[HANDPOS].exists())
|
||||
{
|
||||
SwapObjs(pSoldier, HANDPOS, bPocket, TRUE);//todo: this should probably be more robust and handle potentional custom medical kit that uses both hands
|
||||
return(TRUE);
|
||||
}
|
||||
//nothing in offhand
|
||||
else if (!pSoldier->inv[SECONDHANDPOS].exists())
|
||||
{
|
||||
SwapObjs(pSoldier, HANDPOS, SECONDHANDPOS, TRUE);
|
||||
SwapObjs(pSoldier, HANDPOS, bPocket, TRUE);
|
||||
return(TRUE);
|
||||
}
|
||||
else if (UsingNewInventorySystem())
|
||||
{
|
||||
// Else, if the gun sling slot is free, and the item can go there, it will.
|
||||
if (!pSoldier->inv[GUNSLINGPOCKPOS].exists() && CanItemFitInPosition(pSoldier, &pSoldier->inv[HANDPOS], GUNSLINGPOCKPOS, FALSE))
|
||||
SwapObjs(pSoldier, HANDPOS, GUNSLINGPOCKPOS, TRUE);
|
||||
else if (!pSoldier->inv[GUNSLINGPOCKPOS].exists() && CanItemFitInPosition(pSoldier, &pSoldier->inv[SECONDHANDPOS], GUNSLINGPOCKPOS, FALSE))
|
||||
SwapObjs(pSoldier, SECONDHANDPOS, GUNSLINGPOCKPOS, TRUE);
|
||||
else if (CanItemFitInPosition(pSoldier, &pSoldier->inv[HANDPOS], bPocket, FALSE))
|
||||
SwapObjs(pSoldier, HANDPOS, bPocket, TRUE);
|
||||
else if (CanItemFitInPosition(pSoldier, &pSoldier->inv[SECONDHANDPOS], bPocket, FALSE))
|
||||
SwapObjs(pSoldier, SECONDHANDPOS, bPocket, TRUE);
|
||||
else if (!AutoPlaceObject(pSoldier, &pSoldier->inv[HANDPOS], FALSE, GUNSLINGPOCKPOS, FALSE) && !AutoPlaceObject(pSoldier, &pSoldier->inv[SECONDHANDPOS], FALSE, GUNSLINGPOCKPOS, FALSE))
|
||||
can_swap = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CanItemFitInPosition(pSoldier, &pSoldier->inv[HANDPOS], bPocket, FALSE))
|
||||
SwapObjs(pSoldier, HANDPOS, bPocket, TRUE);
|
||||
else if (CanItemFitInPosition(pSoldier, &pSoldier->inv[SECONDHANDPOS], bPocket, FALSE))
|
||||
SwapObjs(pSoldier, SECONDHANDPOS, bPocket, TRUE);
|
||||
else if (!AutoPlaceObject(pSoldier, &pSoldier->inv[HANDPOS], FALSE, GUNSLINGPOCKPOS, FALSE) && !AutoPlaceObject(pSoldier, &pSoldier->inv[SECONDHANDPOS], FALSE, GUNSLINGPOCKPOS, FALSE))
|
||||
can_swap = false;
|
||||
}
|
||||
|
||||
if (can_swap && (!pSoldier->inv[HANDPOS].exists() || !pSoldier->inv[SECONDHANDPOS].exists()))
|
||||
{
|
||||
if (pSoldier->inv[HANDPOS].exists())
|
||||
{
|
||||
SwapObjs(pSoldier, HANDPOS, SECONDHANDPOS, TRUE);
|
||||
}
|
||||
SwapObjs(pSoldier, HANDPOS, bPocket, TRUE);
|
||||
return(TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
//if we came here it means we don't have medical kit or we cannot place it into hand due to no suitable pockets for whatever merc carries in them
|
||||
if(medkit_found)
|
||||
ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, TacticalStr[QUICK_ITEMS_NOWHERE_TO_PLACE]);
|
||||
if(!bAllow1stAidKit)
|
||||
return FALSE;
|
||||
|
||||
// we didn't find a medical bag, so settle for a FIRST AID KIT
|
||||
if ( Item[pSoldier->inv[ HANDPOS ].usItem].firstaidkit )
|
||||
@@ -10475,7 +10514,7 @@ BOOLEAN MakeSureMedKitIsInHand( SOLDIERTYPE *pSoldier )
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
// run through rest of inventory looking 1st for MEDICAL BAGS, swap the first one into hand if found
|
||||
// run through rest of inventory looking for 1st aid kits, swap the first one into hand if found
|
||||
// CHRISL: Changed to dynamically determine max inventory locations.
|
||||
for (bPocket = SECONDHANDPOS; bPocket < NUM_INV_SLOTS; ++bPocket)
|
||||
{
|
||||
|
||||
@@ -583,7 +583,7 @@ void HandleGatheringInformationBySoldier( SOLDIERTYPE* pSoldier );
|
||||
|
||||
BOOLEAN MercStaffsMilitaryHQ();
|
||||
|
||||
BOOLEAN MakeSureMedKitIsInHand( SOLDIERTYPE *pSoldier );
|
||||
BOOLEAN MakeSureMedKitIsInHand( SOLDIERTYPE *pSoldier, bool bAllow1stAidKit = false);
|
||||
|
||||
UINT8 CalcSoldierNeedForSleep( SOLDIERTYPE *pSoldier );
|
||||
|
||||
|
||||
@@ -6546,6 +6546,10 @@ INT32 PickPocket(SOLDIERTYPE *pSoldier, UINT8 ppStart, UINT8 ppStop, UINT16 usIt
|
||||
}
|
||||
else {
|
||||
pIndex=LoadBearingEquipment[Item[pSoldier->inv[icLBE[uiPos]].usItem].ubClassIndex].lbePocketIndex[icPocket[uiPos]];
|
||||
if (pIndex == 0 && LoadBearingEquipment[Item[pSoldier->inv[icLBE[uiPos]].usItem].ubClassIndex].lbePocketsAvailable & (UINT16)pow((double)2, icPocket[uiPos]))
|
||||
{
|
||||
pIndex = GetPocketFromAttachment(&pSoldier->inv[icLBE[uiPos]], icPocket[uiPos]);
|
||||
}
|
||||
}
|
||||
// Here's were we get complicated. We should look for the smallest pocket all items can fit in
|
||||
if(LBEPocketType[pIndex].ItemCapacityPerSize[Item[usItem].ItemSize] >= iNumber &&
|
||||
|
||||
@@ -19418,7 +19418,7 @@ BOOLEAN SOLDIERTYPE::AIDoctorFriend( )
|
||||
if ( pSoldier->iHealableInjury > 0 )
|
||||
{
|
||||
// move medkit into hand - if we don't have a medkit in our hands, abort
|
||||
if ( !MakeSureMedKitIsInHand( this ) )
|
||||
if (!MakeSureMedKitIsInHand(this, true))
|
||||
return FALSE;
|
||||
|
||||
if ( gAnimControl[this->usAnimState].ubEndHeight == ANIM_CROUCH )
|
||||
@@ -19470,7 +19470,7 @@ BOOLEAN SOLDIERTYPE::AIDoctorSelf( )
|
||||
if ( this->iHealableInjury > 0 )
|
||||
{
|
||||
// move medkit into hand - if we don't have a medkit in our hands, abort
|
||||
if ( !MakeSureMedKitIsInHand( this ) )
|
||||
if (!MakeSureMedKitIsInHand(this, true))
|
||||
return FALSE;
|
||||
|
||||
if ( gAnimControl[this->usAnimState].ubEndHeight == ANIM_CROUCH )
|
||||
|
||||
Reference in New Issue
Block a user