From a7e6b96bbeb2f67fe3b36019f2b99fe98def8b23 Mon Sep 17 00:00:00 2001 From: ChrisL Date: Sat, 29 Mar 2008 20:40:40 +0000 Subject: [PATCH] Build1937 This build includes the "Professional Sniper" skill and changes made to aiming and scopes in the CTH calculation functions. Modified Sniper skill and "per click" aim bonus functionality. Added some adjustments to how Scopes effect the CTH calculations. This should drastically reduce the effectiveness of sniper weapons and scopes, while still leaving them effective at closer ranges. Adjusted the scope vision bonus so that it plays on range with a minimum attainable reduction equal to the scopes minrange value. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1937 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- GameVersion.cpp | 6 +++--- Tactical/Items.cpp | 25 +++++++++++++++++++++++-- Tactical/Weapons.cpp | 27 +++++++++++++++++++++++---- ja2_2005Express.vcproj | 6 +++--- 4 files changed, 52 insertions(+), 12 deletions(-) diff --git a/GameVersion.cpp b/GameVersion.cpp index de15b37a9..735fda28e 100644 --- a/GameVersion.cpp +++ b/GameVersion.cpp @@ -13,12 +13,12 @@ #ifdef JA2EDITOR //MAP EDITOR BUILD VERSION -CHAR16 zVersionLabel[256] = { L"Map Editor v1.13.1936" }; +CHAR16 zVersionLabel[256] = { L"Map Editor v1.13.1937" }; #elif defined JA2BETAVERSION //BETA/TEST BUILD VERSION -CHAR16 zVersionLabel[256] = { L"Debug v1.13.1936" }; +CHAR16 zVersionLabel[256] = { L"Debug v1.13.1937" }; #elif defined CRIPPLED_VERSION @@ -28,7 +28,7 @@ CHAR16 zVersionLabel[256] = { L"Beta v. 0.98" }; #else //RELEASE BUILD VERSION - CHAR16 zVersionLabel[256] = { L"Release v1.13.1936" }; + CHAR16 zVersionLabel[256] = { L"Release v1.13.1937" }; #endif diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index b9cddf278..651580440 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -6887,7 +6887,25 @@ INT16 GetItemAimBonus( const INVTYPE* pItem, INT32 iRange, UINT8 ubAimTime ) if ( pItem->aimbonus < 0) ubAimTime = 1; - return ( pItem->aimbonus * ubAimTime * ( iRange - pItem->minrangeforaimbonus ) ) / 100; + //CHRISL: The old system basically allowed scopes to reduce sight range by AimBonus%/click. So a scope with an + // AimBonus 20, and 8 clicks, would reduce sight range by 160%. In other words, it would effectively reduce sight + // range to 0 just for using 8 APs to aim. + //return ( pItem->aimbonus * ubAimTime * ( iRange - pItem->minrangeforaimbonus ) ) / 100; + // Instead, let's have the bonus reduce each click seperately and base the percentage on the new range. + INT16 bonus = 0, stepBonus = 0; + for( UINT8 step = 0; step < ubAimTime; step++) + { + stepBonus = (pItem->aimbonus * iRange)/100; + iRange -= stepBonus; + bonus += stepBonus; + if(iRange < pItem->minrangeforaimbonus) + { + stepBonus = pItem->minrangeforaimbonus - iRange; + bonus -= stepBonus; + break; + } + } + return(bonus); } INT16 GetAimBonus( OBJECTTYPE * pObj, INT32 iRange, UINT8 ubAimTime ) @@ -7449,13 +7467,16 @@ INT16 GetDayVisionRangeBonus( SOLDIERTYPE * pSoldier, UINT8 bLightLevel ) } // Snap: check only attachments on a raised weapon! + //CHRISL: Since this is a daytime calculation, I think we want the difference between NORMAL_LIGHTLEVEL_NIGHT and + // NORMAL_LIGHTLEVEL_DAY. To just use NORMAL_LIGHTLEVEL_NIGHT is the same as basing the calculation off of the + // difference between NORMAL_LIGHTLEVEL_NIGHT and 0, which represent bright light. if ( usingGunScope == true ) { pObj = &( pSoldier->inv[HANDPOS]); if (pObj->exists() == true) { for (attachmentList::iterator iter = (*pObj)[0]->attachments.begin(); iter != (*pObj)[0]->attachments.end(); ++iter) { bonus += BonusReduceMore( idiv( Item[iter->usItem].dayvisionrangebonus - * (NORMAL_LIGHTLEVEL_NIGHT - bLightLevel), NORMAL_LIGHTLEVEL_NIGHT ), + * (NORMAL_LIGHTLEVEL_NIGHT - __max(bLightLevel,NORMAL_LIGHTLEVEL_DAY)), (NORMAL_LIGHTLEVEL_NIGHT-NORMAL_LIGHTLEVEL_DAY) ), (*iter)[0]->data.objectStatus ); } } diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index 4f12b5a54..4f9acdcd3 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -3754,15 +3754,32 @@ UINT32 CalcChanceToHitGun(SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubAimTime, if ( iSightRange > (sDistVis * CELL_X_SIZE) ) { + //CHRISL: Because of the changes I've made to how scopes modify iSightRange, this penalty makes it basically impossible + // to shot at targets you can't see yourself. While this isn't an issue for most weapons, it overly restricts the + // effectiveness of sniper rifles. So pull this penalty but leave the one that comes later in the code. // shooting beyond max normal vision... penalize such distance at double (also later we halve the remaining chance) - iSightRange += (iSightRange - sDistVis * CELL_X_SIZE); + //iSightRange += (iSightRange - sDistVis * CELL_X_SIZE); } // if shooter spent some extra time aiming and can see the target if (iSightRange > 0 && ubAimTime && !pSoldier->bDoBurst ) { - INT32 aimTimeBonus = 0; - if(highPowerScope == true) + // CHRISL: Rather then a flat +10/click bonus, we're going to try a bonus that's based on MRK and Lvl which gets + // progressivly less the more we aim. Everything is based on the maxBonus that a merc can possibly get which + // uses the equation: 20+(MRK/20*LVL)+Accuracy+(Sniper trait * 10). This value is then split between the 8 + // possible AimTime's using a max aimTime bonus of 10. + INT16 bonusProgression[8] = {500,500,600,600,750,750,750,1000}; + FLOAT maxBonus = 20+((FLOAT)iMarksmanship/20*pSoldier->stats.bExpLevel)+(Weapon[Item[pInHand->usItem].ubClassIndex].bAccuracy*2)+(NUM_SKILL_TRAITS( pSoldier, PROF_SNIPER )*10); + INT8 maxClickBonus = 10; + FLOAT aimTimeBonus; + for(int i = 0; i < ubAimTime; i++) + { + aimTimeBonus = __min((maxBonus*bonusProgression[i]/1000),maxClickBonus); + maxBonus -= aimTimeBonus; + iChance += (INT32)floor(aimTimeBonus+.5); + } +/* if(highPowerScope == true) + { { if ( NUM_SKILL_TRAITS( pSoldier, PROF_SNIPER ) == 2 ) aimTimeBonus = -((__max(0,75-pSoldier->stats.bMarksmanship))/(pSoldier->stats.bExpLevel*2)); @@ -3776,7 +3793,7 @@ UINT32 CalcChanceToHitGun(SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubAimTime, } else aimTimeBonus = AIM_BONUS_PER_AP; - iChance += (aimTimeBonus * ubAimTime); // bonus for every pt of aiming + iChance += (aimTimeBonus * ubAimTime); // bonus for every pt of aiming*/ } if ( !(pSoldier->flags.uiStatusFlags & SOLDIER_PC ) ) // if this is a computer AI controlled enemy @@ -5945,3 +5962,5 @@ INT8 GetAPsToReload( OBJECTTYPE *pObj ) + + diff --git a/ja2_2005Express.vcproj b/ja2_2005Express.vcproj index 596fa2ac0..0b264a475 100644 --- a/ja2_2005Express.vcproj +++ b/ja2_2005Express.vcproj @@ -1,7 +1,7 @@