mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +02:00
- Bugfix: AI acts strange (does not shoot out of weapon range, ...) when NCTH is enabled
o AICalcChanceToHitGun the change to hit is reduced to zero if the AI exceeds the gun range by 10% and is only 50% when in that range. o I've changed that code to use externalize the parameters to the CTHConstants.ini file. o The result is no change in how actual code runs but now those hard coded parameters should be modifiable. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@4713 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+3
-2
@@ -2236,8 +2236,9 @@ void LoadCTHConstants()
|
|||||||
gGameCTHConstants.NORMAL_RECOIL_DISTANCE = iniReader.ReadInteger("Shooting Mechanism","NORMAL_RECOIL_DISTANCE",140, 10, 10000);
|
gGameCTHConstants.NORMAL_RECOIL_DISTANCE = iniReader.ReadInteger("Shooting Mechanism","NORMAL_RECOIL_DISTANCE",140, 10, 10000);
|
||||||
gGameCTHConstants.MAX_BULLET_DEV = iniReader.ReadFloat("Shooting Mechanism","MAX_BULLET_DEV ",10.0, -1000.0, 1000.0);
|
gGameCTHConstants.MAX_BULLET_DEV = iniReader.ReadFloat("Shooting Mechanism","MAX_BULLET_DEV ",10.0, -1000.0, 1000.0);
|
||||||
gGameCTHConstants.RANGE_EFFECTS_DEV = iniReader.ReadBoolean("Shooting Mechanism","RANGE_EFFECTS_DEV", TRUE );
|
gGameCTHConstants.RANGE_EFFECTS_DEV = iniReader.ReadBoolean("Shooting Mechanism","RANGE_EFFECTS_DEV", TRUE );
|
||||||
|
gGameCTHConstants.MAX_EFFECTIVE_RANGE_MULTIPLIER = iniReader.ReadFloat("Shooting Mechanism","MAX_EFFECTIVE_RANGE_MULTIPLIER",1.1f, 0.5f, 10.0f);
|
||||||
|
gGameCTHConstants.MAX_EFFECTIVE_RANGE_REDUCTION = iniReader.ReadFloat("Shooting Mechanism","MAX_EFFECTIVE_RANGE_REDUCTION",0.5f, 0.0f, 1.0f);
|
||||||
|
gGameCTHConstants.MAX_EFFECTIVE_USE_GRADIENT = iniReader.ReadBoolean("Shooting Mechanism","MAX_EFFECTIVE_USE_GRADIENT", FALSE );
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreeGameExternalOptions()
|
void FreeGameExternalOptions()
|
||||||
|
|||||||
@@ -1344,6 +1344,9 @@ typedef struct
|
|||||||
UINT32 NORMAL_RECOIL_DISTANCE;
|
UINT32 NORMAL_RECOIL_DISTANCE;
|
||||||
FLOAT MAX_BULLET_DEV;
|
FLOAT MAX_BULLET_DEV;
|
||||||
BOOLEAN RANGE_EFFECTS_DEV;
|
BOOLEAN RANGE_EFFECTS_DEV;
|
||||||
|
FLOAT MAX_EFFECTIVE_RANGE_MULTIPLIER;
|
||||||
|
FLOAT MAX_EFFECTIVE_RANGE_REDUCTION;
|
||||||
|
BOOLEAN MAX_EFFECTIVE_USE_GRADIENT;
|
||||||
|
|
||||||
} CTH_CONSTANTS;
|
} CTH_CONSTANTS;
|
||||||
|
|
||||||
|
|||||||
+13
-3
@@ -8045,15 +8045,25 @@ UINT32 AICalcChanceToHitGun(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT16 ubAimTim
|
|||||||
}
|
}
|
||||||
|
|
||||||
FLOAT dGunRange = (FLOAT)(GunRange( &(pSoldier->inv[pSoldier->ubAttackingHand]), pSoldier ) );
|
FLOAT dGunRange = (FLOAT)(GunRange( &(pSoldier->inv[pSoldier->ubAttackingHand]), pSoldier ) );
|
||||||
if ( (dGunRange * 1.1f) < d2DDistance)
|
FLOAT dMaxGunRange = dGunRange * gGameCTHConstants.MAX_EFFECTIVE_RANGE_MULTIPLIER;
|
||||||
|
if ( dMaxGunRange < d2DDistance)
|
||||||
{
|
{
|
||||||
// Weapon out of conceivable hit range. Reduce chance to hit to 0!
|
// Weapon out of conceivable hit range. Reduce chance to hit to 0!
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
else if ( dGunRange < d2DDistance)
|
else if ( dGunRange < d2DDistance)
|
||||||
{
|
{
|
||||||
// Just outside range. Reduce considerably!
|
FLOAT dChance = (FLOAT)uiChance;
|
||||||
return (uiChance / 2);
|
FLOAT dMaxChanceReduction = (dChance * gGameCTHConstants.MAX_EFFECTIVE_RANGE_REDUCTION);
|
||||||
|
if (gGameCTHConstants.MAX_EFFECTIVE_USE_GRADIENT)
|
||||||
|
{
|
||||||
|
// Just outside range. Reduce considerably!
|
||||||
|
return min(uiChance, (UINT)(dChance - (dMaxChanceReduction * ((d2DDistance - dGunRange) / (dMaxGunRange - dGunRange)))));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return (UINT)(dChance - dMaxChanceReduction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return( uiChance );
|
return( uiChance );
|
||||||
|
|||||||
Reference in New Issue
Block a user