mirror of
https://github.com/1dot13/source.git
synced 2026-08-19 14:20:30 +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:
@@ -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