Do not allow to activate most modules besides guns on targets which are at distance more than optimal + 3x falloff

This commit is contained in:
DarkPhoenix
2019-08-18 22:13:43 +03:00
parent edd261c677
commit 9b15f1942d
2 changed files with 6 additions and 2 deletions

View File

@@ -21,11 +21,14 @@
import math
def calculateRangeFactor(srcOptimalRange, srcFalloffRange, distance):
def calculateRangeFactor(srcOptimalRange, srcFalloffRange, distance, restrictedRange=True):
"""Range strength/chance factor, applicable to guns, ewar, RRs, etc."""
if distance is None:
return 1
if srcFalloffRange > 0:
# Most modules cannot be activated when at 3x falloff range, with few exceptions like guns
if restrictedRange and distance > srcOptimalRange + 3 * srcFalloffRange:
return 0
return 0.5 ** ((max(0, distance - srcOptimalRange) / srcFalloffRange) ** 2)
elif distance <= srcOptimalRange:
return 1

View File

@@ -302,7 +302,8 @@ def _calcTurretChanceToHit(
"""Calculate chance to hit for turret-based weapons."""
# https://wiki.eveuniversity.org/Turret_mechanics#Hit_Math
angularSpeed = _calcAngularSpeed(atkSpeed, atkAngle, atkRadius, distance, tgtSpeed, tgtAngle, tgtRadius)
rangeFactor = calculateRangeFactor(atkOptimalRange, atkFalloffRange, distance)
# Turrets can be activated regardless of range to target
rangeFactor = calculateRangeFactor(atkOptimalRange, atkFalloffRange, distance, restrictedRange=False)
trackingFactor = _calcTrackingFactor(atkTracking, atkOptimalSigRadius, angularSpeed, tgtSigRadius)
cth = rangeFactor * trackingFactor
return cth