From 5110e63809b7a65bbe38657221823c954f91bb2d Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Mon, 8 Jul 2019 19:53:10 +0300 Subject: [PATCH] Apply webs and TPs for all graph types --- gui/builtinGraphs/fitDamageStats/calc.py | 16 ++++--- gui/builtinGraphs/fitDamageStats/graph.py | 57 +++++++++++++++++++++-- 2 files changed, 62 insertions(+), 11 deletions(-) diff --git a/gui/builtinGraphs/fitDamageStats/calc.py b/gui/builtinGraphs/fitDamageStats/calc.py index 51a8beb68..fa720ba5a 100644 --- a/gui/builtinGraphs/fitDamageStats/calc.py +++ b/gui/builtinGraphs/fitDamageStats/calc.py @@ -174,9 +174,9 @@ def getFighterAbilityMult(fighter, ability, fit, distance, tgtSpeed, tgtSigRadiu def getWebbedSpeed(fit, tgt, currentUnwebbedSpeed, webMods, webDrones, webFighters, distance): if tgt.ship.getModifiedItemAttr('disallowOffensiveModifiers'): return currentUnwebbedSpeed - unwebbedSpeed = tgt.ship.getModifiedItemAttr('maxVelocity') + maxUnwebbedSpeed = tgt.ship.getModifiedItemAttr('maxVelocity') try: - speedRatio = currentUnwebbedSpeed / unwebbedSpeed + speedRatio = currentUnwebbedSpeed / maxUnwebbedSpeed except ZeroDivisionError: currentWebbedSpeed = 0 else: @@ -189,7 +189,8 @@ def getWebbedSpeed(fit, tgt, currentUnwebbedSpeed, webMods, webDrones, webFighte distance=distance) if appliedBoost: appliedMultipliers.setdefault(wData.stackingGroup, []).append((1 + appliedBoost / 100, wData.resAttrID)) - webbedSpeed = tgt.ship.getModifiedItemAttrWithExtraMods('maxVelocity', extraMultipliers=appliedMultipliers) + maxWebbedSpeed = tgt.ship.getModifiedItemAttrWithExtraMods('maxVelocity', extraMultipliers=appliedMultipliers) + currentWebbedSpeed = maxWebbedSpeed * speedRatio # Drones and fighters mobileWebs = [] mobileWebs.extend(webFighters) @@ -204,7 +205,8 @@ def getWebbedSpeed(fit, tgt, currentUnwebbedSpeed, webMods, webDrones, webFighte for mwData in longEnoughMws: appliedMultipliers.setdefault(mwData.stackingGroup, []).append((1 + mwData.boost / 100, mwData.resAttrID)) mobileWebs.remove(mwData) - webbedSpeed = tgt.ship.getModifiedItemAttrWithExtraMods('maxVelocity', extraMultipliers=appliedMultipliers) + maxWebbedSpeed = tgt.ship.getModifiedItemAttrWithExtraMods('maxVelocity', extraMultipliers=appliedMultipliers) + currentWebbedSpeed = maxWebbedSpeed * speedRatio # Apply remaining webs, from fastest to slowest droneOpt = GraphSettings.getInstance().get('mobileDroneMode') while mobileWebs: @@ -213,7 +215,7 @@ def getWebbedSpeed(fit, tgt, currentUnwebbedSpeed, webMods, webDrones, webFighte fastestMws = [mw for mw in mobileWebs if mw.speed == fastestMwSpeed] for mwData in fastestMws: # Faster than target or set to follow it - apply full slowdown - if (droneOpt == GraphDpsDroneMode.auto and mwData.speed >= webbedSpeed) or droneOpt == GraphDpsDroneMode.followTarget: + if (droneOpt == GraphDpsDroneMode.auto and mwData.speed >= currentWebbedSpeed) or droneOpt == GraphDpsDroneMode.followTarget: appliedMwBoost = mwData.boost # Otherwise project from the center of the ship else: @@ -223,8 +225,8 @@ def getWebbedSpeed(fit, tgt, currentUnwebbedSpeed, webMods, webDrones, webFighte distance=distance + atkRadius - mwData.radius) appliedMultipliers.setdefault(mwData.stackingGroup, []).append((1 + appliedMwBoost / 100, mwData.resAttrID)) mobileWebs.remove(mwData) - webbedSpeed = tgt.ship.getModifiedItemAttrWithExtraMods('maxVelocity', extraMultipliers=appliedMultipliers) - currentWebbedSpeed = webbedSpeed * speedRatio + maxWebbedSpeed = tgt.ship.getModifiedItemAttrWithExtraMods('maxVelocity', extraMultipliers=appliedMultipliers) + currentWebbedSpeed = maxWebbedSpeed * speedRatio return currentWebbedSpeed diff --git a/gui/builtinGraphs/fitDamageStats/graph.py b/gui/builtinGraphs/fitDamageStats/graph.py index 1567e5007..b8c6fde4a 100644 --- a/gui/builtinGraphs/fitDamageStats/graph.py +++ b/gui/builtinGraphs/fitDamageStats/graph.py @@ -297,7 +297,7 @@ class FitDamageStatsGraph(FitGraph): def _xTgtSpeedGetter(self, mainInput, miscInputs, fit, tgt, dmgFunc, timeCachePrepFunc): xs = [] ys = [] - tgtSigRadius = tgt.ship.getModifiedItemAttr('signatureRadius') + applyProjected = GraphSettings.getInstance().get('applyProjected') # Process inputs into more convenient form miscInputMap = dict(miscInputs) # Get all data we need for all target speeds into maps/caches @@ -305,13 +305,37 @@ class FitDamageStatsGraph(FitGraph): dmgMap = dmgFunc(fit=fit, time=miscInputMap['time']) # Go through target speeds and calculate distance-dependent data for tgtSpeed in self._iterLinear(mainInput[1]): + # Get separate internal speed to calculate proper application, for graph + # itself we still want to show pre-modification speed on X axis + tgtSpeedInternal = tgtSpeed + tgtSigRadius = tgt.ship.getModifiedItemAttr('signatureRadius') + if applyProjected: + webMods, tpMods = self._projectedCache.getProjModData(fit) + webDrones, tpDrones = self._projectedCache.getProjDroneData(fit) + webFighters, tpFighters = self._projectedCache.getProjFighterData(fit) + tgtSpeedInternal = getWebbedSpeed( + fit=fit, + tgt=tgt, + currentUnwebbedSpeed=tgtSpeedInternal, + webMods=webMods, + webDrones=webDrones, + webFighters=webFighters, + distance=miscInputMap['distance']) + tgtSigRadius = tgtSigRadius * getTpMult( + fit=fit, + tgt=tgt, + tgtSpeed=tgtSpeedInternal, + tpMods=tpMods, + tpDrones=tpDrones, + tpFighters=tpFighters, + distance=miscInputMap['distance']) applicationMap = self._getApplicationPerKey( fit=fit, tgt=tgt, atkSpeed=miscInputMap['atkSpeed'], atkAngle=miscInputMap['atkAngle'], distance=miscInputMap['distance'], - tgtSpeed=tgtSpeed, + tgtSpeed=tgtSpeedInternal, tgtAngle=miscInputMap['tgtAngle'], tgtSigRadius=tgtSigRadius) dmg = self._aggregate(dmgMap=dmgMap, applicationMap=applicationMap).total @@ -324,20 +348,45 @@ class FitDamageStatsGraph(FitGraph): ys = [] # Process inputs into more convenient form miscInputMap = dict(miscInputs) + tgtSpeed = miscInputMap['tgtSpeed'] + tgtSigMult = 1 + if GraphSettings.getInstance().get('applyProjected'): + webMods, tpMods = self._projectedCache.getProjModData(fit) + webDrones, tpDrones = self._projectedCache.getProjDroneData(fit) + webFighters, tpFighters = self._projectedCache.getProjFighterData(fit) + tgtSpeed = getWebbedSpeed( + fit=fit, + tgt=tgt, + currentUnwebbedSpeed=tgtSpeed, + webMods=webMods, + webDrones=webDrones, + webFighters=webFighters, + distance=miscInputMap['distance']) + tgtSigMult = getTpMult( + fit=fit, + tgt=tgt, + tgtSpeed=tgtSpeed, + tpMods=tpMods, + tpDrones=tpDrones, + tpFighters=tpFighters, + distance=miscInputMap['distance']) # Get all data we need for all target speeds into maps/caches timeCachePrepFunc(fit, miscInputMap['time']) dmgMap = dmgFunc(fit=fit, time=miscInputMap['time']) # Go through target speeds and calculate distance-dependent data for tgtSigRadius in self._iterLinear(mainInput[1]): + # Separate variable to show base signature on X axis and use modified + # signature in calculations + tgtSigRadiusInternal = tgtSigRadius * tgtSigMult applicationMap = self._getApplicationPerKey( fit=fit, tgt=tgt, atkSpeed=miscInputMap['atkSpeed'], atkAngle=miscInputMap['atkAngle'], distance=miscInputMap['distance'], - tgtSpeed=miscInputMap['tgtSpeed'], + tgtSpeed=tgtSpeed, tgtAngle=miscInputMap['tgtAngle'], - tgtSigRadius=tgtSigRadius) + tgtSigRadius=tgtSigRadiusInternal) dmg = self._aggregate(dmgMap=dmgMap, applicationMap=applicationMap).total xs.append(tgtSigRadius) ys.append(dmg)