Merge branch 'master' into fix-syntax-warnings
This commit is contained in:
24
graphs/data/fitDamageStats/cache/time.py
vendored
24
graphs/data/fitDamageStats/cache/time.py
vendored
@@ -117,7 +117,7 @@ class TimeCache(FitDataCache):
|
||||
pointData[timeStart] = (dps, volley)
|
||||
# Gap between items
|
||||
elif floatUnerr(prevTimeEnd) < floatUnerr(timeStart):
|
||||
pointData[prevTimeEnd] = (DmgTypes(0, 0, 0, 0), DmgTypes(0, 0, 0, 0))
|
||||
pointData[prevTimeEnd] = (DmgTypes.default(), DmgTypes.default())
|
||||
pointData[timeStart] = (dps, volley)
|
||||
# Changed value
|
||||
elif dps != prevDps or volley != prevVolley:
|
||||
@@ -157,7 +157,7 @@ class TimeCache(FitDataCache):
|
||||
def addDpsVolley(ddKey, addedTimeStart, addedTimeFinish, addedVolleys):
|
||||
if not addedVolleys:
|
||||
return
|
||||
volleySum = sum(addedVolleys, DmgTypes(0, 0, 0, 0))
|
||||
volleySum = sum(addedVolleys, DmgTypes.default())
|
||||
if volleySum.total > 0:
|
||||
addedDps = volleySum / (addedTimeFinish - addedTimeStart)
|
||||
# We can take "just best" volley, no matter target resistances, because all
|
||||
@@ -170,24 +170,38 @@ class TimeCache(FitDataCache):
|
||||
def addDmg(ddKey, addedTime, addedDmg):
|
||||
if addedDmg.total == 0:
|
||||
return
|
||||
addedDmg._breachers = {addedTime + k: v for k, v in addedDmg._breachers.items()}
|
||||
addedDmg._clear_cached()
|
||||
intCacheDmg.setdefault(ddKey, {})[addedTime] = addedDmg
|
||||
|
||||
# Modules
|
||||
for mod in src.item.activeModulesIter():
|
||||
if not mod.isDealingDamage():
|
||||
continue
|
||||
cycleParams = mod.getCycleParameters(reloadOverride=True)
|
||||
cycleParams = mod.getCycleParametersForDps(reloadOverride=True)
|
||||
if cycleParams is None:
|
||||
continue
|
||||
currentTime = 0
|
||||
nonstopCycles = 0
|
||||
isBreacher = mod.isBreacher
|
||||
for cycleTimeMs, inactiveTimeMs, isInactivityReload in cycleParams.iterCycles():
|
||||
cycleVolleys = []
|
||||
volleyParams = mod.getVolleyParameters(spoolOptions=SpoolOptions(SpoolType.CYCLES, nonstopCycles, True))
|
||||
|
||||
for volleyTimeMs, volley in volleyParams.items():
|
||||
cycleVolleys.append(volley)
|
||||
addDmg(mod, currentTime + volleyTimeMs / 1000, volley)
|
||||
addDpsVolley(mod, currentTime, currentTime + cycleTimeMs / 1000, cycleVolleys)
|
||||
time = currentTime + volleyTimeMs / 1000
|
||||
if isBreacher:
|
||||
time += 1
|
||||
addDmg(mod, time, volley)
|
||||
if isBreacher:
|
||||
break
|
||||
timeStart = currentTime
|
||||
timeFinish = currentTime + cycleTimeMs / 1000
|
||||
if isBreacher:
|
||||
timeStart += 1
|
||||
timeFinish += 1
|
||||
addDpsVolley(mod, timeStart, timeFinish, cycleVolleys)
|
||||
if inactiveTimeMs > 0:
|
||||
nonstopCycles = 0
|
||||
else:
|
||||
|
||||
@@ -98,6 +98,8 @@ def getApplicationPerKey(src, tgt, atkSpeed, atkAngle, distance, tgtSpeed, tgtAn
|
||||
tgt=tgt,
|
||||
distance=distance,
|
||||
tgtSigRadius=tgtSigRadius)
|
||||
elif mod.isBreacher:
|
||||
applicationMap[mod] = getBreacherMult(mod=mod, distance=distance) if inLockRange else 0
|
||||
for drone in src.item.activeDronesIter():
|
||||
if not drone.isDealingDamage():
|
||||
continue
|
||||
@@ -192,6 +194,21 @@ def getLauncherMult(mod, distance, tgtSpeed, tgtSigRadius):
|
||||
return distanceFactor * applicationFactor
|
||||
|
||||
|
||||
def getBreacherMult(mod, distance):
|
||||
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 <= lowerRange:
|
||||
distanceFactor = 1
|
||||
elif lowerRange < distance <= higherRange:
|
||||
distanceFactor = higherChance
|
||||
else:
|
||||
distanceFactor = 0
|
||||
return distanceFactor
|
||||
|
||||
|
||||
def getSmartbombMult(mod, distance):
|
||||
modRange = mod.maxRange
|
||||
if modRange is None:
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
|
||||
import eos.config
|
||||
from eos.saveddata.targetProfile import TargetProfile
|
||||
from eos.utils.spoolSupport import SpoolOptions, SpoolType
|
||||
from eos.utils.stats import DmgTypes
|
||||
from graphs.data.base import PointGetter, SmoothPointGetter
|
||||
@@ -27,17 +28,16 @@ from .calc.application import getApplicationPerKey
|
||||
from .calc.projected import getScramRange, getScrammables, getTackledSpeed, getSigRadiusMult
|
||||
|
||||
|
||||
def applyDamage(dmgMap, applicationMap, tgtResists):
|
||||
total = DmgTypes(em=0, thermal=0, kinetic=0, explosive=0)
|
||||
def applyDamage(dmgMap, applicationMap, tgtResists, tgtFullHp):
|
||||
total = DmgTypes.default()
|
||||
for key, dmg in dmgMap.items():
|
||||
total += dmg * applicationMap.get(key, 0)
|
||||
if not GraphSettings.getInstance().get('ignoreResists'):
|
||||
emRes, thermRes, kinRes, exploRes = tgtResists
|
||||
total = DmgTypes(
|
||||
em=total.em * (1 - emRes),
|
||||
thermal=total.thermal * (1 - thermRes),
|
||||
kinetic=total.kinetic * (1 - kinRes),
|
||||
explosive=total.explosive * (1 - exploRes))
|
||||
else:
|
||||
emRes = thermRes = kinRes = exploRes = 0
|
||||
total.profile = TargetProfile(
|
||||
emAmount=emRes, thermalAmount=thermRes, kineticAmount=kinRes, explosiveAmount=exploRes, hp=tgtFullHp)
|
||||
return total
|
||||
|
||||
|
||||
@@ -144,7 +144,8 @@ class XDistanceMixin(SmoothPointGetter):
|
||||
'srcScramRange': getScramRange(src=src) if applyProjected else None,
|
||||
'tgtScrammables': getScrammables(tgt=tgt) if applyProjected else (),
|
||||
'dmgMap': self._getDamagePerKey(src=src, time=miscParams['time']),
|
||||
'tgtResists': tgt.getResists()}
|
||||
'tgtResists': tgt.getResists(),
|
||||
'tgtFullHp': tgt.getFullHp()}
|
||||
|
||||
def _calculatePoint(self, x, miscParams, src, tgt, commonData):
|
||||
distance = x
|
||||
@@ -186,7 +187,8 @@ class XDistanceMixin(SmoothPointGetter):
|
||||
y = applyDamage(
|
||||
dmgMap=commonData['dmgMap'],
|
||||
applicationMap=applicationMap,
|
||||
tgtResists=commonData['tgtResists']).total
|
||||
tgtResists=commonData['tgtResists'],
|
||||
tgtFullHp=commonData['tgtFullHp']).total
|
||||
return y
|
||||
|
||||
|
||||
@@ -241,14 +243,17 @@ class XTimeMixin(PointGetter):
|
||||
self._prepareTimeCache(src=src, maxTime=maxTime)
|
||||
timeCache = self._getTimeCacheData(src=src)
|
||||
applicationMap = self._prepareApplicationMap(miscParams=miscParams, src=src, tgt=tgt)
|
||||
tgtResists = tgt.getResists()
|
||||
# Custom iteration for time graph to show all data points
|
||||
currentDmg = None
|
||||
currentTime = None
|
||||
for currentTime in sorted(timeCache):
|
||||
prevDmg = currentDmg
|
||||
currentDmgData = timeCache[currentTime]
|
||||
currentDmg = applyDamage(dmgMap=currentDmgData, applicationMap=applicationMap, tgtResists=tgtResists).total
|
||||
currentDmg = applyDamage(
|
||||
dmgMap=currentDmgData,
|
||||
applicationMap=applicationMap,
|
||||
tgtResists=tgt.getResists(),
|
||||
tgtFullHp=tgt.getFullHp()).total
|
||||
if currentTime < minTime:
|
||||
continue
|
||||
# First set of data points
|
||||
@@ -294,7 +299,11 @@ class XTimeMixin(PointGetter):
|
||||
self._prepareTimeCache(src=src, maxTime=time)
|
||||
dmgData = self._getTimeCacheDataPoint(src=src, time=time)
|
||||
applicationMap = self._prepareApplicationMap(miscParams=miscParams, src=src, tgt=tgt)
|
||||
y = applyDamage(dmgMap=dmgData, applicationMap=applicationMap, tgtResists=tgt.getResists()).total
|
||||
y = applyDamage(
|
||||
dmgMap=dmgData,
|
||||
applicationMap=applicationMap,
|
||||
tgtResists=tgt.getResists(),
|
||||
tgtFullHp=tgt.getFullHp()).total
|
||||
return y
|
||||
|
||||
|
||||
@@ -310,7 +319,8 @@ class XTgtSpeedMixin(SmoothPointGetter):
|
||||
return {
|
||||
'applyProjected': GraphSettings.getInstance().get('applyProjected'),
|
||||
'dmgMap': self._getDamagePerKey(src=src, time=miscParams['time']),
|
||||
'tgtResists': tgt.getResists()}
|
||||
'tgtResists': tgt.getResists(),
|
||||
'tgtFullHp': tgt.getFullHp()}
|
||||
|
||||
def _calculatePoint(self, x, miscParams, src, tgt, commonData):
|
||||
tgtSpeed = x
|
||||
@@ -353,7 +363,8 @@ class XTgtSpeedMixin(SmoothPointGetter):
|
||||
y = applyDamage(
|
||||
dmgMap=commonData['dmgMap'],
|
||||
applicationMap=applicationMap,
|
||||
tgtResists=commonData['tgtResists']).total
|
||||
tgtResists=commonData['tgtResists'],
|
||||
tgtFullHp=commonData['tgtFullHp']).total
|
||||
return y
|
||||
|
||||
|
||||
@@ -398,7 +409,8 @@ class XTgtSigRadiusMixin(SmoothPointGetter):
|
||||
'tgtSpeed': tgtSpeed,
|
||||
'tgtSigMult': tgtSigMult,
|
||||
'dmgMap': self._getDamagePerKey(src=src, time=miscParams['time']),
|
||||
'tgtResists': tgt.getResists()}
|
||||
'tgtResists': tgt.getResists(),
|
||||
'tgtFullHp': tgt.getFullHp()}
|
||||
|
||||
def _calculatePoint(self, x, miscParams, src, tgt, commonData):
|
||||
tgtSigRadius = x
|
||||
@@ -414,7 +426,8 @@ class XTgtSigRadiusMixin(SmoothPointGetter):
|
||||
y = applyDamage(
|
||||
dmgMap=commonData['dmgMap'],
|
||||
applicationMap=applicationMap,
|
||||
tgtResists=commonData['tgtResists']).total
|
||||
tgtResists=commonData['tgtResists'],
|
||||
tgtFullHp=commonData['tgtFullHp']).total
|
||||
return y
|
||||
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ class FitDamageStatsGraph(FitGraph):
|
||||
cols = []
|
||||
if not GraphSettings.getInstance().get('ignoreResists'):
|
||||
cols.append('Target Resists')
|
||||
cols.extend(('Speed', 'SigRadius', 'Radius'))
|
||||
cols.extend(('Speed', 'SigRadius', 'Radius', 'FullHP'))
|
||||
return cols
|
||||
|
||||
# Calculation stuff
|
||||
|
||||
@@ -145,6 +145,11 @@ class TargetWrapper(BaseWrapper):
|
||||
else:
|
||||
return em, therm, kin, explo
|
||||
|
||||
def getFullHp(self):
|
||||
if self.isProfile:
|
||||
return self.item.hp
|
||||
if self.isFit:
|
||||
return self.item.hp.get('shield', 0) + self.item.hp.get('armor', 0) + self.item.hp.get('hull', 0)
|
||||
|
||||
|
||||
def _getShieldResists(ship):
|
||||
|
||||
Reference in New Issue
Block a user