mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
Possible fix for the intermittent sector inventory right-click issue.
Fixed the display AP cost for shooting (when you also have to change facing and/or ready a weapon) so that it correctly matches the APs that are really charged. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@2298 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -835,20 +835,36 @@ void MapInvenPoolSlots(MOUSE_REGION * pRegion, INT32 iReason )
|
||||
{
|
||||
//CHRISL: Make it possible to right click and pull up stack popup and/or item description boxes
|
||||
WORLDITEM * twItem = &(pInventoryPoolList[ ( iCurrentInventoryPoolPage * MAP_INVENTORY_POOL_SLOT_COUNT ) + iCounter ]);
|
||||
bool fValidPointer = false;
|
||||
if ( !InSectorStackPopup( ) && !InItemStackPopup( ) && !InItemDescriptionBox( ) && !InKeyRingPopup( ) && twItem->object.exists() == true && (bSelectedInfoChar != -1 && gCharactersList[bSelectedInfoChar].fValid))
|
||||
{
|
||||
if(OK_CONTROLLABLE_MERC( MercPtrs[gCharactersList[bSelectedInfoChar].usSolID] ))
|
||||
{
|
||||
if(ItemSlotLimit( &twItem->object, STACK_SIZE_LIMIT ) == 1)
|
||||
{
|
||||
fShowInventoryFlag = TRUE;
|
||||
MAPInternalInitItemDescriptionBox( &twItem->object, 0, MercPtrs[gCharactersList[bSelectedInfoChar].usSolID] );
|
||||
}
|
||||
else if(gpItemPointer == NULL || gpItemPointer->usItem == twItem->object.usItem || ValidAttachment(gpItemPointer->usItem, twItem->object.usItem) == TRUE || ValidAmmoType(twItem->object.usItem, gpItemPointer->usItem) == TRUE)
|
||||
{
|
||||
InitSectorStackPopup( MercPtrs[gCharactersList[bSelectedInfoChar].usSolID], twItem, iCounter, 0, INV_REGION_Y, 261, ( SCREEN_HEIGHT - PLAYER_INFO_Y ) );
|
||||
fTeamPanelDirty=TRUE;
|
||||
fInterfacePanelDirty = DIRTYLEVEL2;
|
||||
//CHRISL: The old setup had a flaw I didn't consider. if, for some reason, the ItemSlotLimit = 0
|
||||
// nothing might happen. Now we setup a flag to determine if our cursor is value for the item we're
|
||||
// clicking on. If it's not valid, we can't do anything so all conditions rely on it being true.
|
||||
//if(ItemSlotLimit( &twItem->object, STACK_SIZE_LIMIT ) == 1)
|
||||
if(gpItemPointer == NULL)
|
||||
fValidPointer = true;
|
||||
else
|
||||
{
|
||||
if(gpItemPointer->usItem == twItem->object.usItem)
|
||||
fValidPointer = true;
|
||||
if(ValidAttachment(gpItemPointer->usItem, twItem->object.usItem) == TRUE)
|
||||
fValidPointer = true;
|
||||
if(ValidAmmoType(twItem->object.usItem, gpItemPointer->usItem) == TRUE)
|
||||
fValidPointer = true;
|
||||
}
|
||||
if(twItem->object.ubNumberOfObjects == 1 && fValidPointer)
|
||||
{
|
||||
fShowInventoryFlag = TRUE;
|
||||
MAPInternalInitItemDescriptionBox( &twItem->object, 0, MercPtrs[gCharactersList[bSelectedInfoChar].usSolID] );
|
||||
}
|
||||
else if(fValidPointer)
|
||||
{
|
||||
InitSectorStackPopup( MercPtrs[gCharactersList[bSelectedInfoChar].usSolID], twItem, iCounter, 0, INV_REGION_Y, 261, ( SCREEN_HEIGHT - PLAYER_INFO_Y ) );
|
||||
fTeamPanelDirty=TRUE;
|
||||
fInterfacePanelDirty = DIRTYLEVEL2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,6 +197,8 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bLevel, UINT16 usHa
|
||||
BOOLEAN fAddingRaiseGunCost = FALSE;
|
||||
LEVELNODE *pIntNode;
|
||||
STRUCTURE *pStructure;
|
||||
UINT16 usRaiseGunCost = 0;
|
||||
UINT16 usTurningCost = 0;
|
||||
|
||||
|
||||
// Remove any previous actions
|
||||
@@ -405,13 +407,19 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bLevel, UINT16 usHa
|
||||
|
||||
|
||||
GetAPChargeForShootOrStabWRTGunRaises( pSoldier, sTargetGridNo, TRUE, &fAddingTurningCost, &fAddingRaiseGunCost );
|
||||
usTurningCost = CalculateTurningCost(pSoldier, usHandItem, fAddingTurningCost);
|
||||
usRaiseGunCost = CalculateRaiseGunCost(pSoldier, fAddingRaiseGunCost);
|
||||
|
||||
// If we are standing and are asked to turn AND raise gun, ignore raise gun...
|
||||
if ( gAnimControl[ pSoldier->usAnimState ].ubHeight == ANIM_STAND )
|
||||
//CHRISL: Actually, the display value is based on the higher of turn and raise gun so we should do the same
|
||||
if ( gAnimControl[ pSoldier->usAnimState ].ubHeight != ANIM_PRONE )
|
||||
{
|
||||
if ( fAddingRaiseGunCost )
|
||||
if ( fAddingTurningCost && fAddingRaiseGunCost )
|
||||
{
|
||||
pSoldier->flags.fDontChargeTurningAPs = TRUE;
|
||||
if(usRaiseGunCost > usTurningCost)
|
||||
pSoldier->flags.fDontChargeTurningAPs = TRUE;
|
||||
else
|
||||
pSoldier->flags.fDontChargeReadyAPs = TRUE;
|
||||
}
|
||||
}
|
||||
/*else
|
||||
@@ -1329,13 +1337,19 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bLevel, UINT16 usHa
|
||||
else if ( Item[usHandItem].grenadelauncher )//usHandItem == GLAUNCHER || usHandItem == UNDER_GLAUNCHER )
|
||||
{
|
||||
GetAPChargeForShootOrStabWRTGunRaises( pSoldier, sTargetGridNo, TRUE, &fAddingTurningCost, &fAddingRaiseGunCost );
|
||||
usTurningCost = CalculateTurningCost(pSoldier, usHandItem, fAddingTurningCost);
|
||||
usRaiseGunCost = CalculateRaiseGunCost(pSoldier, fAddingRaiseGunCost);
|
||||
|
||||
// If we are standing and are asked to turn AND raise gun, ignore raise gun...
|
||||
if ( gAnimControl[ pSoldier->usAnimState ].ubHeight == ANIM_STAND )
|
||||
//CHRISL: Actually, the display value is based on the higher of turn and raise gun so we should do the same
|
||||
if ( gAnimControl[ pSoldier->usAnimState ].ubHeight != ANIM_PRONE )
|
||||
{
|
||||
if ( fAddingRaiseGunCost )
|
||||
if ( fAddingTurningCost && fAddingRaiseGunCost )
|
||||
{
|
||||
pSoldier->flags.fDontChargeTurningAPs = TRUE;
|
||||
if(usRaiseGunCost > usTurningCost)
|
||||
pSoldier->flags.fDontChargeTurningAPs = TRUE;
|
||||
else
|
||||
pSoldier->flags.fDontChargeReadyAPs = TRUE;
|
||||
}
|
||||
}
|
||||
/*else
|
||||
|
||||
+39
-14
@@ -1402,12 +1402,45 @@ void GetAPChargeForShootOrStabWRTGunRaises( SOLDIERTYPE *pSoldier, INT16 sGridNo
|
||||
{
|
||||
fAddingRaiseGunCost = TRUE;
|
||||
}
|
||||
//CHRISL: If we are prone and we need to turn, we will need to ready our weapon no matter what our current state is
|
||||
if(fAddingTurningCost && gAnimControl[ pSoldier->usAnimState ].ubHeight == ANIM_PRONE)
|
||||
{
|
||||
fAddingRaiseGunCost = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
(*pfChargeTurning) = fAddingTurningCost;
|
||||
(*pfChargeRaise ) = fAddingRaiseGunCost;
|
||||
}
|
||||
|
||||
UINT16 CalculateTurningCost(SOLDIERTYPE *pSoldier, UINT16 usItem, BOOLEAN fAddingTurningCost)
|
||||
{
|
||||
UINT16 usTurningCost = 0;
|
||||
|
||||
if ( fAddingTurningCost )
|
||||
{
|
||||
if ( Item[ usItem ].usItemClass == IC_THROWING_KNIFE )
|
||||
usTurningCost = 1;
|
||||
else
|
||||
usTurningCost = GetAPsToLook( pSoldier );
|
||||
}
|
||||
|
||||
return usTurningCost;
|
||||
}
|
||||
|
||||
UINT16 CalculateRaiseGunCost(SOLDIERTYPE *pSoldier, BOOLEAN fAddingRaiseGunCost)
|
||||
{
|
||||
UINT16 usRaiseGunCost = 0;
|
||||
|
||||
if (fAddingRaiseGunCost )
|
||||
{
|
||||
usRaiseGunCost = GetAPsToReadyWeapon( pSoldier, pSoldier->usAnimState );
|
||||
pSoldier->flags.fDontChargeReadyAPs = FALSE;
|
||||
}
|
||||
|
||||
return usRaiseGunCost;
|
||||
}
|
||||
|
||||
UINT8 MinAPsToShootOrStab(SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubAddTurningCost, UINT8 ubForceRaiseGunCost)
|
||||
{
|
||||
UINT32 uiMercFlags;
|
||||
@@ -1451,24 +1484,16 @@ UINT8 MinAPsToShootOrStab(SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubAddTurni
|
||||
}
|
||||
|
||||
//Calculate usTurningCost
|
||||
if ( fAddingTurningCost )
|
||||
{
|
||||
if ( Item[ usItem ].usItemClass == IC_THROWING_KNIFE )
|
||||
usTurningCost = 1;
|
||||
else
|
||||
usTurningCost = GetAPsToLook( pSoldier );
|
||||
}
|
||||
usTurningCost = CalculateTurningCost(pSoldier, usItem, fAddingTurningCost);
|
||||
|
||||
//Calculate usRaiseGunCost
|
||||
if (fAddingRaiseGunCost )
|
||||
{
|
||||
usRaiseGunCost = GetAPsToReadyWeapon( pSoldier, pSoldier->usAnimState );
|
||||
pSoldier->flags.fDontChargeReadyAPs = FALSE;
|
||||
}
|
||||
|
||||
usRaiseGunCost = CalculateRaiseGunCost(pSoldier, fAddingRaiseGunCost);
|
||||
|
||||
//charge the maximum of the 2
|
||||
bAPCost += __max(usTurningCost,usRaiseGunCost);
|
||||
if ( gAnimControl[ pSoldier->usAnimState ].ubHeight == ANIM_PRONE )
|
||||
bAPCost += (usTurningCost + usRaiseGunCost);
|
||||
else
|
||||
bAPCost += __max(usTurningCost,usRaiseGunCost);
|
||||
|
||||
|
||||
if ( sGridNo != NOWHERE )
|
||||
|
||||
@@ -288,6 +288,8 @@ UINT8 MinAPsToAttack(SOLDIERTYPE *pSoldier, INT16 sGridno, UINT8 ubAddTurningCos
|
||||
INT8 MinPtsToMove(SOLDIERTYPE *pSoldier);
|
||||
INT8 MinAPsToStartMovement( SOLDIERTYPE * pSoldier, UINT16 usMovementMode );
|
||||
INT8 PtsToMoveDirection(SOLDIERTYPE *pSoldier, INT8 bDirection );
|
||||
UINT16 CalculateTurningCost(SOLDIERTYPE *pSoldier, UINT16 usItem, BOOLEAN fAddingTurningCost);
|
||||
UINT16 CalculateRaiseGunCost(SOLDIERTYPE *pSoldier, BOOLEAN fAddingRaiseGunCost);
|
||||
UINT8 MinAPsToShootOrStab(SOLDIERTYPE *pSoldier, INT16 sGridno, UINT8 ubAddTurningCost, UINT8 ubForceRaiseGunCost = 0 );
|
||||
BOOLEAN EnoughAmmo( SOLDIERTYPE *pSoldier, BOOLEAN fDisplay, INT8 bInvPos );
|
||||
void DeductAmmo( SOLDIERTYPE *pSoldier, INT8 bInvPos );
|
||||
|
||||
Reference in New Issue
Block a user