From ec4d1f6e24e798c6b402d3f265a58ff11f280d2d Mon Sep 17 00:00:00 2001 From: Overhaul Date: Mon, 9 Jul 2007 11:06:57 +0000 Subject: [PATCH] Fix to stackable throwables: Stop assertion failure for stack of 6 throwables. Report correct damage and AP for stacked throwables. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1036 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Points.cpp | 19 +++++++++++++++++-- Tactical/Weapons.cpp | 6 +++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Tactical/Points.cpp b/Tactical/Points.cpp index 3cc58c2e4..245bbe671 100644 --- a/Tactical/Points.cpp +++ b/Tactical/Points.cpp @@ -1170,7 +1170,14 @@ UINT8 BaseAPsToShootOrStab( INT8 bAPs, INT8 bAimSkill, OBJECTTYPE * pObj ) // Shots per turn rating is for max. aimSkill(100), drops down to 1/2 at = 0 // DIVIDE BY 4 AT THE END HERE BECAUSE THE SHOTS PER TURN IS NOW QUADRUPLED! // NB need to define shots per turn for ALL Weapons then. - rof = Weapon[ pObj->usItem ].ubShotsPer4Turns + GetRateOfFireBonus(pObj); + // 0verhaul: Do not calculate rate of fire bonus for stackable items (knives) + // Their info is an array of item status, not weapon info, and they don't repeat + // fire anyway. + rof = Weapon[ pObj->usItem ].ubShotsPer4Turns; + if (Item[ pObj->usItem ].ubPerPocket == 0) + { + rof += GetRateOfFireBonus(pObj); + } //Bottom = ( ( 50 + (bAimSkill / 2) ) * rof ) / 4; @@ -1180,7 +1187,15 @@ UINT8 BaseAPsToShootOrStab( INT8 bAPs, INT8 bAimSkill, OBJECTTYPE * pObj ) //return( ( ( ( 100 * Top ) / Bottom ) + 1) / 2); // Snap: Refactored the formula to reduce the number of integer divisions - Top = 8 * bAPs * ( 100 - GetPercentAPReduction(pObj) ); + Top = 8 * bAPs; + if (Item[ pObj->usItem ].ubPerPocket == 0) + { + Top *= ( 100 - GetPercentAPReduction(pObj) ); + } + else + { + Top *= 100; + } Bottom = ( 100 + bAimSkill ) * rof; // (this will round to the nearest integer) return ( Top + Bottom / 2 ) / Bottom; diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index 5480ec2a8..ffb9e8e3d 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -5690,7 +5690,11 @@ UINT8 GetDamage ( OBJECTTYPE *pObj ) } else { - UINT8 ubDamage = Weapon[ pObj->usItem ].ubImpact + GetDamageBonus(pObj); + UINT8 ubDamage = Weapon[ pObj->usItem ].ubImpact; + if (Item[ pObj->usItem ].ubPerPocket == 0) + { + ubDamage += GetDamageBonus(pObj); + } return min(255, (UINT8)( (ubDamage) + ( (double)ubDamage / 100) * gGameExternalOptions.ubGunDamageMultiplier ) ); } }