From f778f9ceae639168aa1896bf92a9ae1bb4018a7d Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Wed, 13 Nov 2019 20:51:14 +0300 Subject: [PATCH] Take ship radius in consideration when displaying missile range in range column --- eos/saveddata/module.py | 5 +++++ graphs/data/fitDamageStats/calc/application.py | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/eos/saveddata/module.py b/eos/saveddata/module.py index 973e2fb05..817ca6736 100644 --- a/eos/saveddata/module.py +++ b/eos/saveddata/module.py @@ -368,11 +368,16 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): higherTime = math.ceil(flightTime) lowerRange = calculateRange(maxVelocity, mass, agility, lowerTime) higherRange = calculateRange(maxVelocity, mass, agility, higherTime) + # Fof range limit is supposedly calculated based on overview (surface-to-surface) range if 'fofMissileLaunching' in self.charge.effects: rangeLimit = self.getModifiedChargeAttr("maxFOFTargetRange") if rangeLimit: lowerRange = min(lowerRange, rangeLimit) higherRange = min(higherRange, rangeLimit) + # Make range center-to-surface, as missiles spawn in the center of the ship + shipRadius = self.owner.ship.getModifiedItemAttr("radius") + lowerRange = max(0, lowerRange - shipRadius) + higherRange = max(0, higherRange - shipRadius) higherChance = flightTime - lowerTime return lowerRange, higherRange, higherChance diff --git a/graphs/data/fitDamageStats/calc/application.py b/graphs/data/fitDamageStats/calc/application.py index f0f9f4cd5..1536fe2b2 100644 --- a/graphs/data/fitDamageStats/calc/application.py +++ b/graphs/data/fitDamageStats/calc/application.py @@ -155,10 +155,11 @@ def getLauncherMult(mod, src, distance, tgtSpeed, tgtSigRadius): missileMaxRangeData = mod.missileMaxRangeData if missileMaxRangeData is None: return 0 + # The ranges already consider ship radius lowerRange, higherRange, higherChance = missileMaxRangeData - if distance is None or distance + src.getRadius() <= lowerRange: + if distance is None or distance <= lowerRange: distanceFactor = 1 - elif lowerRange < distance + src.getRadius() <= higherRange: + elif lowerRange < distance <= higherRange: distanceFactor = higherChance else: distanceFactor = 0