Fixed delayed mode for grenades.

Changing delayed mode for grenade launcher only possible with DELAYED_GRENADE_EXPLOSION = FALSE.
Minor code improvements and warning fixes.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8771 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Sevenfm
2020-03-14 10:39:18 +00:00
parent 3e07b01a45
commit 560219ac36
2 changed files with 15 additions and 15 deletions
+5 -4
View File
@@ -9674,16 +9674,17 @@ UINT32 CalcThrownChanceToHit(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT16 ubAimTi
void ChangeWeaponMode( SOLDIERTYPE * pSoldier ) void ChangeWeaponMode( SOLDIERTYPE * pSoldier )
{ {
// ATE: Don't do this if in a fire amimation..... // ATE: Don't do this if in a fire animation.....
if ( gAnimControl[ pSoldier->usAnimState ].uiFlags & ANIM_FIRE ) if ( gAnimControl[ pSoldier->usAnimState ].uiFlags & ANIM_FIRE )
{ {
return; return;
} }
// Flugente: if we are in a GL fire mode, switch between impact/delayed mode // Flugente: if we are in a GL fire mode, switch between impact/delayed mode
if ( ( ( pSoldier->bWeaponMode == WM_ATTACHED_GL || pSoldier->bWeaponMode == WM_ATTACHED_GL_BURST || pSoldier->bWeaponMode == WM_ATTACHED_GL_AUTO) || if (((pSoldier->bWeaponMode == WM_ATTACHED_GL || pSoldier->bWeaponMode == WM_ATTACHED_GL_BURST || pSoldier->bWeaponMode == WM_ATTACHED_GL_AUTO) ||
( Item[pSoldier->inv[HANDPOS].usItem].usItemClass & IC_LAUNCHER && !Item[pSoldier->inv[HANDPOS].usItem].rocketlauncher) ) && (Item[pSoldier->inv[HANDPOS].usItem].usItemClass & IC_LAUNCHER && !Item[pSoldier->inv[HANDPOS].usItem].rocketlauncher)) &&
!pSoldier->usGLDelayMode ) !pSoldier->usGLDelayMode &&
!gGameExternalOptions.fDelayedGrenadeExplosion)
{ {
pSoldier->usGLDelayMode = 1; pSoldier->usGLDelayMode = 1;
} }
+10 -11
View File
@@ -2262,15 +2262,15 @@ void CalculateLaunchItemParamsForThrow( SOLDIERTYPE *pSoldier, INT32 sGridNo, UI
} }
// calculate the actual min and max miss radius based on CtH // calculate the actual min and max miss radius based on CtH
bMinMissRadius = ( (FLOAT)bMaxRadius * ( 10.0f - sqrt((FLOAT)uiHitChance) ) / 10.0f ); bMinMissRadius = (INT8)((FLOAT)bMaxRadius * (10.0f - sqrt((FLOAT)uiHitChance)) / 10.0f);
bMaxMissRadius = bMaxRadius * ( 100 - uiHitChance ) / 100; bMaxMissRadius = bMaxRadius * ( 100 - uiHitChance ) / 100;
// modify by a bit of luck // modify by a bit of luck
bMinMissRadius = __max( (bMinMissRadius - Random(2)), 0); bMinMissRadius = __max( (bMinMissRadius - (INT8)Random(2)), 0);
bMinMissRadius = __min( (bMinMissRadius + Random(2)), bMaxRadius); bMinMissRadius = __min( (bMinMissRadius + (INT8)Random(2)), bMaxRadius);
bMaxMissRadius = __max( (bMaxMissRadius - Random(2)), 0); bMaxMissRadius = __max( (bMaxMissRadius - (INT8)Random(2)), 0);
bMaxMissRadius = __min( (bMaxMissRadius + Random(2)), bMaxRadius); bMaxMissRadius = __min( (bMaxMissRadius + (INT8)Random(2)), bMaxRadius);
// min miss radius cannot be greater than max miss radius // min miss radius cannot be greater than max miss radius
bMinMissRadius = __min( bMinMissRadius, bMaxMissRadius); bMinMissRadius = __min( bMinMissRadius, bMaxMissRadius);
@@ -2581,16 +2581,16 @@ void HandleArmedObjectImpact( REAL_OBJECT *pObject )
// ATE: Make sure number of objects is 1... // ATE: Make sure number of objects is 1...
pObj->ubNumberOfObjects = 1; pObj->ubNumberOfObjects = 1;
if ( Item[ pObj->usItem ].usItemClass & IC_GRENADE ) if (Item[pObj->usItem].usItemClass & IC_GRENADE)
{ {
fCheckForDuds = TRUE; fCheckForDuds = TRUE;
if( CanDelayGrenadeExplosion(pObj->usItem) && ( Item[pObj->usItem].ubCursor == TOSSCURS || Item[pObj->usItem].glgrenade )) if (CanDelayGrenadeExplosion(pObj->usItem) && (Item[pObj->usItem].ubCursor == TOSSCURS || Item[pObj->usItem].glgrenade))
{ {
fCanDelayExplosion = TRUE; fCanDelayExplosion = TRUE;
} }
if( (*pObj)[0]->data.sObjectFlag & DELAYED_GRENADE_EXPLOSION ) if ((*pObj)[0]->data.sObjectFlag & DELAYED_GRENADE_EXPLOSION)
{ {
fDelayedExplosion = TRUE; fDelayedExplosion = TRUE;
} }
@@ -2630,9 +2630,8 @@ void HandleArmedObjectImpact( REAL_OBJECT *pObject )
// Flugente: explosion does not happen instantly if grenade // Flugente: explosion does not happen instantly if grenade
// is not in water and // is not in water and
// either has a bad status or is a delayed grenade // either has a bad status or is a delayed grenade
if ( !pObject->fInWater && if (!pObject->fInWater &&
( !fGoodStatus || (!fGoodStatus || fCanDelayExplosion && (gGameExternalOptions.fDelayedGrenadeExplosion || fDelayedExplosion)))
( fCanDelayExplosion && gGameExternalOptions.fDelayedGrenadeExplosion && fDelayedExplosion) ) )
{ {
// didn't go off! // didn't go off!
fDoImpact = FALSE; fDoImpact = FALSE;