Added helper functions to easier determine gun stats

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9158 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2021-08-27 20:48:19 +00:00
parent 99142603cb
commit a93e9b4a9c
4 changed files with 75 additions and 25 deletions
+30
View File
@@ -15832,3 +15832,33 @@ BOOLEAN CanDelayGrenadeExplosion( UINT16 usItem )
return TRUE; return TRUE;
} }
FLOAT GetBestScopeMagFactorForGun(UINT16 ausItemGun)
{
FLOAT bestscopemagfactor = 1.0f;
for ( UINT16 usItem = 1; usItem < gMAXITEMS_READ; ++usItem )
{
if ( ValidAttachment( usItem, ausItemGun ) )
{
if ( bestscopemagfactor < Item[usItem].scopemagfactor )
bestscopemagfactor = Item[usItem].scopemagfactor;
}
}
return bestscopemagfactor;
}
bool HasScopeMagFactorForGun( UINT16 ausItemGun, FLOAT aFactor )
{
for ( UINT16 usItem = 1; usItem < gMAXITEMS_READ; ++usItem )
{
if ( ValidAttachment( usItem, ausItemGun ) )
{
if ( std::fabs( Item[usItem].scopemagfactor - aFactor ) < 0.1 )
return true;
}
}
return false;
}
+32 -18
View File
@@ -1723,15 +1723,15 @@ INT16 CalcAPsToBurst( INT16 bBaseActionPoints, OBJECTTYPE * pObj, SOLDIERTYPE* p
} }
// HEADROCK HAM 4: Same as above, without percent modifiers. // HEADROCK HAM 4: Same as above, without percent modifiers.
INT16 CalcAPsToBurstNoModifier( INT16 bBaseActionPoints, OBJECTTYPE * pObj ) INT16 CalcAPsToBurstNoModifier( INT16 bBaseActionPoints, UINT16 usItem )
{ {
INT32 aps, iModifiedAPs; INT32 aps, iModifiedAPs;
iModifiedAPs = Weapon[ pObj->usItem ].bBurstAP; iModifiedAPs = Weapon[ usItem ].bBurstAP;
// modify by ini values // modify by ini values
// although the function says "no modifier" the ini values represent our new base value // although the function says "no modifier" the ini values represent our new base value
if ( Item[ pObj->usItem ].usItemClass == IC_GUN ) if ( Item[ usItem ].usItemClass == IC_GUN )
iModifiedAPs *= gItemSettings.fBurstAPModifierGun[ Weapon[ pObj->usItem ].ubWeaponType ]; iModifiedAPs *= gItemSettings.fBurstAPModifierGun[ Weapon[ usItem ].ubWeaponType ];
aps = ( iModifiedAPs * bBaseActionPoints + (APBPConstants[AP_MAXIMUM] - 1) ) / APBPConstants[AP_MAXIMUM]; aps = ( iModifiedAPs * bBaseActionPoints + (APBPConstants[AP_MAXIMUM] - 1) ) / APBPConstants[AP_MAXIMUM];
@@ -1743,6 +1743,11 @@ INT16 CalcAPsToBurstNoModifier( INT16 bBaseActionPoints, OBJECTTYPE * pObj )
return (UINT8) aps; return (UINT8) aps;
} }
INT16 CalcAPsToBurstNoModifier( INT16 bBaseActionPoints, OBJECTTYPE * pObj )
{
return CalcAPsToBurstNoModifier( bBaseActionPoints, pObj->usItem );
}
INT16 CalcAPsToAutofire( INT16 bBaseActionPoints, OBJECTTYPE * pObj, UINT8 bDoAutofire, SOLDIERTYPE* pSoldier ) INT16 CalcAPsToAutofire( INT16 bBaseActionPoints, OBJECTTYPE * pObj, UINT8 bDoAutofire, SOLDIERTYPE* pSoldier )
{ {
//CHRISL: We send the actual number of rounds being fired in the bDoAutofire paramter. But that implies that it would take longer to fire the first round //CHRISL: We send the actual number of rounds being fired in the bDoAutofire paramter. But that implies that it would take longer to fire the first round
@@ -1804,14 +1809,13 @@ INT16 CalcAPsToAutofire( INT16 bBaseActionPoints, OBJECTTYPE * pObj, UINT8 bDoAu
} }
// HEADROCK HAM 4: Same as above, without modifiers // HEADROCK HAM 4: Same as above, without modifiers
INT16 CalcAPsToAutofireNoModifier( INT16 bBaseActionPoints, OBJECTTYPE * pObj, UINT8 bDoAutofire ) INT16 CalcAPsToAutofireNoModifier( INT16 bBaseActionPoints, UINT16 usItem, UINT8 bDoAutofire )
{ {
INT32 aps = APBPConstants[AP_MAXIMUM] + 1;
INT32 aps=APBPConstants[AP_MAXIMUM] + 1; if ( GetAutofireShotsPerFiveAPs ( usItem ) )
if ( GetAutofireShotsPerFiveAPs (pObj) )
{ {
const INT32 autofireaps = const INT32 autofireaps =
aps = ( ( APBPConstants[AUTOFIRE_SHOTS_AP_VALUE] * bDoAutofire * bBaseActionPoints ) / GetAutofireShotsPerFiveAPs(pObj) + (APBPConstants[AP_MAXIMUM] - 1) ) / APBPConstants[AP_MAXIMUM]; aps = ( ( APBPConstants[AUTOFIRE_SHOTS_AP_VALUE] * bDoAutofire * bBaseActionPoints ) / GetAutofireShotsPerFiveAPs( usItem ) + (APBPConstants[AP_MAXIMUM] - 1) ) / APBPConstants[AP_MAXIMUM];
aps = __max( aps, ( autofireaps + 1 ) / 2 ); aps = __max( aps, ( autofireaps + 1 ) / 2 );
@@ -1821,6 +1825,11 @@ INT16 CalcAPsToAutofireNoModifier( INT16 bBaseActionPoints, OBJECTTYPE * pObj, U
return (UINT8) aps; return (UINT8) aps;
} }
INT16 CalcAPsToAutofireNoModifier( INT16 bBaseActionPoints, OBJECTTYPE * pObj, UINT8 bDoAutofire )
{
return CalcAPsToAutofireNoModifier( bBaseActionPoints, pObj->usItem, bDoAutofire );
}
INT16 CalcTotalAPsToAttack( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 ubAddTurningCost, INT16 bAimTime ) INT16 CalcTotalAPsToAttack( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 ubAddTurningCost, INT16 bAimTime )
{ {
UINT16 sAPCost = 0; UINT16 sAPCost = 0;
@@ -2144,26 +2153,26 @@ INT16 BaseAPsToShootOrStab( INT16 bAPs, INT16 bAimSkill, OBJECTTYPE * pObj, SOLD
} }
// HEADROCK HAM 4: Same function as above, except no modifier. // HEADROCK HAM 4: Same function as above, except no modifier.
INT16 BaseAPsToShootOrStabNoModifier( INT16 bAPs, INT16 bAimSkill, OBJECTTYPE * pObj ) INT16 BaseAPsToShootOrStabNoModifier( INT16 bAPs, INT16 bAimSkill, UINT16 usItem )
{ {
INT32 Top, Bottom; INT32 Top, Bottom;
FLOAT rof; FLOAT rof;
rof = Weapon[ pObj->usItem ].ubShotsPer4Turns; rof = Weapon[usItem].ubShotsPer4Turns;
// modify by ini values // modify by ini values
// although this function says "no modifiers" our ini values are supposed to provide new base values // although this function says "no modifiers" our ini values are supposed to provide new base values
if ( Item[ pObj->usItem ].usItemClass == IC_GUN ) if ( Item[usItem].usItemClass == IC_GUN )
rof *= gItemSettings.fShotsPer4TurnsModifierGun[ Weapon[ pObj->usItem ].ubWeaponType ]; rof *= gItemSettings.fShotsPer4TurnsModifierGun[Weapon[usItem].ubWeaponType];
else if ( Item[ pObj->usItem ].usItemClass == IC_LAUNCHER ) else if ( Item[usItem].usItemClass == IC_LAUNCHER )
rof *= gItemSettings.fShotsPer4TurnsModifierLauncher; rof *= gItemSettings.fShotsPer4TurnsModifierLauncher;
else if ( Item[ pObj->usItem ].usItemClass == IC_BLADE ) else if ( Item[usItem].usItemClass == IC_BLADE )
rof *= gItemSettings.fShotsPer4TurnsModifierBlade; rof *= gItemSettings.fShotsPer4TurnsModifierBlade;
else if ( Item[ pObj->usItem ].usItemClass == IC_PUNCH ) else if ( Item[usItem].usItemClass == IC_PUNCH )
rof *= gItemSettings.fShotsPer4TurnsModifierPunch; rof *= gItemSettings.fShotsPer4TurnsModifierPunch;
else if ( Item[ pObj->usItem ].usItemClass == IC_TENTACLES ) else if ( Item[usItem].usItemClass == IC_TENTACLES )
rof *= gItemSettings.fShotsPer4TurnsModifierTentacle; rof *= gItemSettings.fShotsPer4TurnsModifierTentacle;
else if ( Item[ pObj->usItem ].usItemClass == IC_THROWING_KNIFE ) else if ( Item[usItem].usItemClass == IC_THROWING_KNIFE )
rof *= gItemSettings.fShotsPer4TurnsModifierThrowKnife; rof *= gItemSettings.fShotsPer4TurnsModifierThrowKnife;
Top = 8 * bAPs * 100; Top = 8 * bAPs * 100;
@@ -2178,6 +2187,11 @@ INT16 BaseAPsToShootOrStabNoModifier( INT16 bAPs, INT16 bAimSkill, OBJECTTYPE *
return baseAPsToShootOrStab; return baseAPsToShootOrStab;
} }
INT16 BaseAPsToShootOrStabNoModifier( INT16 bAPs, INT16 bAimSkill, OBJECTTYPE * pObj )
{
return BaseAPsToShootOrStabNoModifier( bAPs, bAimSkill, pObj->usItem );
}
void GetAPChargeForShootOrStabWRTGunRaises( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 ubAddTurningCost, BOOLEAN *pfChargeTurning, BOOLEAN *pfChargeRaise, INT16 bAimTime ) void GetAPChargeForShootOrStabWRTGunRaises( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 ubAddTurningCost, BOOLEAN *pfChargeTurning, BOOLEAN *pfChargeRaise, INT16 bAimTime )
{ {
UINT8 ubDirection; UINT8 ubDirection;
+12 -7
View File
@@ -10740,18 +10740,18 @@ BOOLEAN WasPrevBulletATracer( SOLDIERTYPE *pSoldier, OBJECTTYPE *pWeapon )
} }
} }
UINT8 GetAutofireShotsPerFiveAPs( OBJECTTYPE *pObj ) UINT8 GetAutofireShotsPerFiveAPs( UINT16 usItem )
{ {
// DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("GetAutofireShotsPerFiveAPs")); // DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("GetAutofireShotsPerFiveAPs"));
// HEADROCK HAM B2.6: Added overall modifier // HEADROCK HAM B2.6: Added overall modifier
if (Weapon[ pObj->usItem ].bAutofireShotsPerFiveAP > 0) if (Weapon[ usItem ].bAutofireShotsPerFiveAP > 0)
{ {
UINT8 usAutoFireShots = Weapon[ pObj->usItem ].bAutofireShotsPerFiveAP; UINT8 usAutoFireShots = Weapon[ usItem ].bAutofireShotsPerFiveAP;
// modify by ini values // modify by ini values
if ( Item[ pObj->usItem ].usItemClass == IC_GUN ) if ( Item[ usItem ].usItemClass == IC_GUN )
usAutoFireShots *= gItemSettings.fAFShotsPer5APModifierGun[ Weapon[ pObj->usItem ].ubWeaponType ]; usAutoFireShots *= gItemSettings.fAFShotsPer5APModifierGun[ Weapon[ usItem ].ubWeaponType ];
// WANNE: Fix by Headrock // WANNE: Fix by Headrock
// Weapons shouldn't ever lose their Bp5AP due to this modifier. // Weapons shouldn't ever lose their Bp5AP due to this modifier.
@@ -10759,10 +10759,15 @@ UINT8 GetAutofireShotsPerFiveAPs( OBJECTTYPE *pObj )
//return __max((Weapon[ pObj->usItem ].bAutofireShotsPerFiveAP + gGameExternalOptions.bAutofireBulletsPer5APModifier), 0); //return __max((Weapon[ pObj->usItem ].bAutofireShotsPerFiveAP + gGameExternalOptions.bAutofireBulletsPer5APModifier), 0);
} }
else
return 0;
return 0;
} }
UINT8 GetAutofireShotsPerFiveAPs( OBJECTTYPE *pObj )
{
return GetAutofireShotsPerFiveAPs( pObj->usItem );
}
UINT16 GetMagSize( OBJECTTYPE *pObj, UINT8 subObject ) UINT16 GetMagSize( OBJECTTYPE *pObj, UINT8 subObject )
{ {
// DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("GetMagSize")); // DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("GetMagSize"));
+1
View File
@@ -501,6 +501,7 @@ BOOLEAN IsWeapon ( UINT16 itemIndex );
UINT8 GetDamage ( OBJECTTYPE *pObj ); UINT8 GetDamage ( OBJECTTYPE *pObj );
// HEADROCK HAM 4: Same function as above, but without modifiers from attached items. // HEADROCK HAM 4: Same function as above, but without modifiers from attached items.
UINT8 GetBasicDamage ( OBJECTTYPE *pObj ); UINT8 GetBasicDamage ( OBJECTTYPE *pObj );
UINT8 GetAutofireShotsPerFiveAPs( UINT16 usItem );
UINT8 GetAutofireShotsPerFiveAPs( OBJECTTYPE *pObj ); UINT8 GetAutofireShotsPerFiveAPs( OBJECTTYPE *pObj );
UINT8 GetBaseAutoFireCost( OBJECTTYPE *pObj ); UINT8 GetBaseAutoFireCost( OBJECTTYPE *pObj );
UINT8 GetBurstPenalty( OBJECTTYPE *pObj, BOOLEAN fProneStance = FALSE ); UINT8 GetBurstPenalty( OBJECTTYPE *pObj, BOOLEAN fProneStance = FALSE );