From 405492d9d78a5aa64e7bce7ae8ffd898c44f0e1c Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Wed, 3 Jul 2019 11:38:21 +0300 Subject: [PATCH] Move all the turret calculation logic into new graph --- eos/graph/fitDpsVsRange.py | 48 ----------------------------- gui/builtinGraphs/fitDamageStats.py | 17 +++++++++- 2 files changed, 16 insertions(+), 49 deletions(-) diff --git a/eos/graph/fitDpsVsRange.py b/eos/graph/fitDpsVsRange.py index 741a7d2d8..41fa6e25d 100644 --- a/eos/graph/fitDpsVsRange.py +++ b/eos/graph/fitDpsVsRange.py @@ -108,21 +108,6 @@ class FitDpsVsRangeGraph(SmoothGraph): return min(sigRadiusFactor, velocityFactor, 1) - @classmethod - def calculateTurretMultiplier(cls, fit, mod, distance, angle, tgtSpeed, tgtSigRad): - # Source for most of turret calculation info: http://wiki.eveonline.com/en/wiki/Falloff - chanceToHit = cls.calculateTurretChanceToHit(fit, mod, distance, angle, tgtSpeed, tgtSigRad) - if chanceToHit > 0.01: - # AvgDPS = Base Damage * [ ( ChanceToHit^2 + ChanceToHit + 0.0499 ) / 2 ] - multiplier = (chanceToHit ** 2 + chanceToHit + 0.0499) / 2 - else: - # All hits are wreckings - multiplier = chanceToHit * 3 - dmgScaling = mod.getModifiedItemAttr('turretDamageScalingRadius') - if dmgScaling: - multiplier = min(1, (float(tgtSigRad) / dmgScaling) ** 2) - return multiplier - @staticmethod def calculateFighterMissileMultiplier(tgtSpeed, tgtSigRad, ability): prefix = ability.attrPrefix @@ -150,39 +135,6 @@ class FitDpsVsRangeGraph(SmoothGraph): return min(sigRadiusFactor, velocityFactor, 1) - @staticmethod - def calculateTurretChanceToHit(fit, mod, distance, angle, tgtSpeed, tgtSigRad): - tracking = mod.getModifiedItemAttr('trackingSpeed') - turretOptimal = mod.maxRange - turretFalloff = mod.falloff - turretSigRes = mod.getModifiedItemAttr('optimalSigRadius') - transversal = sin(radians(angle)) * tgtSpeed - - # Angular velocity is calculated using range from ship center to target center. - # We do not know target radius but we know attacker radius - angDistance = distance + fit.ship.getModifiedItemAttr('radius', 0) - if angDistance == 0 and transversal == 0: - angularVelocity = 0 - elif angDistance == 0 and transversal != 0: - angularVelocity = inf - else: - angularVelocity = transversal / angDistance - trackingEq = (((angularVelocity / tracking) * - (turretSigRes / tgtSigRad)) ** 2) - rangeEq = ((max(0, distance - turretOptimal)) / turretFalloff) ** 2 - - return 0.5 ** (trackingEq + rangeEq) - - @staticmethod - def calculateModuleMultiplier(mod, distance): - # Simplified formula, we make some assumptions about the module - # This is basically the calculateTurretChanceToHit without tracking values - turretOptimal = mod.maxRange - turretFalloff = mod.falloff - rangeEq = ((max(0, distance - turretOptimal)) / turretFalloff) ** 2 - - return 0.5 ** rangeEq - @staticmethod def penalizeModChain(value, mods): mods.sort(key=lambda v: -abs(v - 1)) diff --git a/gui/builtinGraphs/fitDamageStats.py b/gui/builtinGraphs/fitDamageStats.py index 567d45f5d..f8609ba9e 100644 --- a/gui/builtinGraphs/fitDamageStats.py +++ b/gui/builtinGraphs/fitDamageStats.py @@ -424,10 +424,25 @@ class FitDamageStatsGraph(FitGraph): return xs, ys -def calcTurretCth( +def calcTurretMult(chanceToHit): + # https://wiki.eveuniversity.org/Turret_mechanics#Damage + wreckingChance = min(chanceToHit, 0.01) + wreckingPart = wreckingChance * 3 + normalChance = chanceToHit - wreckingChance + if normalChance > 0: + avgDamageMult = (0.01 + chanceToHit) / 2 + 0.49 + normalPart = normalChance * avgDamageMult + else: + normalPart = 0 + totalMult = normalPart + wreckingPart + return totalMult + + +def calcTurretChanceToHit( atkSpeed, atkAngle, atkRadius, atkOptimalRange, atkFalloffRange, atkTracking, atkOptimalSigRadius, distance, tgtSpeed, tgtAngle, tgtRadius, tgtSigRadius ): + # https://wiki.eveuniversity.org/Turret_mechanics#Hit_Math angularSpeed = calcAngularSpeed(atkSpeed, atkAngle, atkRadius, distance, tgtSpeed, tgtAngle, tgtRadius) rangeFactor = calcRangeFactor(atkOptimalRange, atkFalloffRange, distance) trackingFactor = calcTrackingFactor(atkTracking, atkOptimalSigRadius, angularSpeed, tgtSigRadius)