Plug webs/TPs into calculation process
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
# ===============================================================================
|
||||
|
||||
import collections
|
||||
from copy import copy
|
||||
from math import exp
|
||||
# TODO: This needs to be moved out, we shouldn't have *ANY* dependencies back to other modules/methods inside eos.
|
||||
# This also breaks writing any tests. :(
|
||||
@@ -33,9 +34,9 @@ class ItemAttrShortcut:
|
||||
return_value = self.itemModifiedAttributes.get(key)
|
||||
return return_value or default
|
||||
|
||||
def getModifiedItemAttrWithExtraMods(self, key, multipliers=(), boosts=(), default=0):
|
||||
def getModifiedItemAttrWithExtraMods(self, key, extraMultipliers=None, default=0):
|
||||
"""Returns attribute value with passed modifiers applied to it."""
|
||||
return_value = self.itemModifiedAttributes.getWithExtraMods(key, multipliers=multipliers, boosts=boosts)
|
||||
return_value = self.itemModifiedAttributes.getWithExtraMods(key, extraMultipliers=extraMultipliers)
|
||||
return return_value or default
|
||||
|
||||
def getItemBaseAttrValue(self, key, default=0):
|
||||
@@ -49,9 +50,9 @@ class ChargeAttrShortcut:
|
||||
return_value = self.chargeModifiedAttributes.get(key)
|
||||
return return_value or default
|
||||
|
||||
def getModifiedChargeAttrWithExtraMods(self, key, multipliers=(), boosts=(), default=0):
|
||||
def getModifiedChargeAttrWithExtraMods(self, key, extraMultipliers=None, default=0):
|
||||
"""Returns attribute value with passed modifiers applied to it."""
|
||||
return_value = self.itemModifiedAttributes.getWithExtraMods(key, multipliers=multipliers, boosts=boosts)
|
||||
return_value = self.itemModifiedAttributes.getWithExtraMods(key, extraMultipliers=extraMultipliers)
|
||||
return return_value or default
|
||||
|
||||
def getChargeBaseAttrValue(self, key, default=0):
|
||||
@@ -163,12 +164,12 @@ class ModifiedAttributeDict(collections.MutableMapping):
|
||||
# Original value is the least priority
|
||||
return self.getOriginal(key)
|
||||
|
||||
def getWithExtraMods(self, key, multipliers=(), boosts=(), default=0):
|
||||
def getWithExtraMods(self, key, extraMultipliers=None, default=0):
|
||||
"""Copy of __getitem__ with some modifications."""
|
||||
if not multipliers and not boosts:
|
||||
if not extraMultipliers:
|
||||
return self.get(key, default=default)
|
||||
|
||||
val = self.__calculateValue(key, extraMultipliers=multipliers, extraBoosts=boosts)
|
||||
val = self.__calculateValue(key, extraMultipliers=extraMultipliers)
|
||||
if val is not None:
|
||||
return val
|
||||
|
||||
@@ -233,7 +234,7 @@ class ModifiedAttributeDict(collections.MutableMapping):
|
||||
keys.update(iter(self.__intermediary.keys()))
|
||||
return len(keys)
|
||||
|
||||
def __calculateValue(self, key, extraMultipliers=(), extraBoosts=()):
|
||||
def __calculateValue(self, key, extraMultipliers=None):
|
||||
# It's possible that various attributes are capped by other attributes,
|
||||
# it's defined by reference maxAttributeID
|
||||
try:
|
||||
@@ -270,6 +271,11 @@ class ModifiedAttributeDict(collections.MutableMapping):
|
||||
preIncrease = self.__preIncreases.get(key, 0)
|
||||
multiplier = self.__multipliers.get(key, 1)
|
||||
penalizedMultiplierGroups = self.__penalizedMultipliers.get(key, {})
|
||||
# Add extra multipliers to the group, not modifying initial data source
|
||||
if extraMultipliers is not None:
|
||||
penalizedMultiplierGroups = copy(penalizedMultiplierGroups)
|
||||
for k, v in extraMultipliers.items():
|
||||
penalizedMultiplierGroups[k] = penalizedMultiplierGroups.get(k, []) + v
|
||||
postIncrease = self.__postIncreases.get(key, 0)
|
||||
|
||||
# Grab initial value, priorities are:
|
||||
|
||||
@@ -178,24 +178,24 @@ def applyWebs(tgt, currentUnwebbedSpeed, webMods, distance):
|
||||
except ZeroDivisionError:
|
||||
currentWebbedSpeed = 0
|
||||
else:
|
||||
appliedBoosts = []
|
||||
for boost, optimal, falloff in webMods:
|
||||
appliedMultipliers = {}
|
||||
for boost, optimal, falloff, stackingChain in webMods:
|
||||
appliedBoost = boost * _calcRangeFactor(atkOptimalRange=optimal, atkFalloffRange=falloff, distance=distance)
|
||||
if appliedBoost:
|
||||
appliedBoosts.append(appliedBoost)
|
||||
webbedSpeed = tgt.ship.getModifiedItemAttrWithExtraMods('maxVelocity', boosts=appliedBoosts)
|
||||
appliedMultipliers.setdefault(stackingChain, []).append(1 + appliedBoost / 100)
|
||||
webbedSpeed = tgt.ship.getModifiedItemAttrWithExtraMods('maxVelocity', extraMultipliers=appliedMultipliers)
|
||||
currentWebbedSpeed = webbedSpeed * speedRatio
|
||||
return currentWebbedSpeed
|
||||
|
||||
|
||||
def applyTps(tgt, tpMods, distance):
|
||||
untpedSig = tgt.ship.getModifiedItemAttr('signatureRadius')
|
||||
appliedBoosts = []
|
||||
for boost, optimal, falloff in tpMods:
|
||||
appliedMultipliers = {}
|
||||
for boost, optimal, falloff, stackingChain in tpMods:
|
||||
appliedBoost = boost * _calcRangeFactor(atkOptimalRange=optimal, atkFalloffRange=falloff, distance=distance)
|
||||
if appliedBoost:
|
||||
appliedBoosts.append(appliedBoost)
|
||||
tpedSig = tgt.ship.getModifiedItemAttrWithExtraMods('signatureRadius', boosts=appliedBoosts)
|
||||
appliedMultipliers.setdefault(stackingChain, []).append(1 + appliedBoost / 100)
|
||||
tpedSig = tgt.ship.getModifiedItemAttrWithExtraMods('signatureRadius', extraMultipliers=appliedMultipliers)
|
||||
mult = tpedSig / untpedSig
|
||||
return mult
|
||||
|
||||
|
||||
@@ -27,13 +27,13 @@ class ProjectedDataCache(FitDataCache):
|
||||
try:
|
||||
projectedData = self._data[fit.ID]['modules']
|
||||
except KeyError:
|
||||
# Format of items for both: (boost strength, optimal, falloff)
|
||||
# Format of items for both: (boost strength, optimal, falloff, stacking group)
|
||||
webMods = []
|
||||
tpMods = []
|
||||
projectedData = self._data.setdefault(fit.ID, {})['modules'] = (webMods, tpMods)
|
||||
for mod in fit.modules:
|
||||
if 'remoteWebifierFalloff' in mod.item.effects or 'structureModuleEffectStasisWebifier' in mod.item.effects:
|
||||
webMods.append((mod.getModifiedItemAttr('speedFactor'), mod.maxRange or 0, mod.falloff or 0))
|
||||
webMods.append((mod.getModifiedItemAttr('speedFactor'), mod.maxRange or 0, mod.falloff or 0, 'default'))
|
||||
if 'remoteTargetPaintFalloff' in mod.item.effects or 'structureModuleEffectTargetPainter' in mod.item.effects:
|
||||
tpMods.append((mod.getModifiedItemAttr('signatureRadiusBonus'), mod.maxRange or 0, mod.falloff or 0))
|
||||
tpMods.append((mod.getModifiedItemAttr('signatureRadiusBonus'), mod.maxRange or 0, mod.falloff or 0, 'default'))
|
||||
return projectedData
|
||||
|
||||
@@ -24,6 +24,7 @@ import wx
|
||||
import gui.display
|
||||
import gui.globalEvents as GE
|
||||
from gui.builtinShipBrowser.events import EVT_FIT_RENAMED
|
||||
from service.const import GraphCacheCleanupReason
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -135,7 +136,7 @@ class BaseList(gui.display.Display):
|
||||
self.fits.remove(fit)
|
||||
self.update(self.fits)
|
||||
for fit in fits:
|
||||
self.graphFrame.clearCache(fitID=fit.ID)
|
||||
self.graphFrame.clearCache(reason=GraphCacheCleanupReason.fitChanged, extraData=fit.ID)
|
||||
self.graphFrame.draw()
|
||||
|
||||
def unbindExternalEvents(self):
|
||||
|
||||
Reference in New Issue
Block a user