diff --git a/eos/effects/ecmburstjammer.py b/eos/effects/ecmburstjammer.py index 1d733e6506..f21b89391d 100644 --- a/eos/effects/ecmburstjammer.py +++ b/eos/effects/ecmburstjammer.py @@ -2,12 +2,17 @@ # # Used by: # Modules from group: Burst Jammer (11 of 11) +from eos.modifiedAttributeDict import ModifiedAttributeDict + type = "projected", "active" -def handler(fit, module, context): +def handler(fit, module, context, **kwargs): if "projected" in context: # jam formula: 1 - (1- (jammer str/ship str))^(# of jam mods with same str)) strModifier = 1 - module.getModifiedItemAttr("scan{0}StrengthBonus".format(fit.scanType)) / fit.scanStrength + if 'effect' in kwargs: + strModifier *= ModifiedAttributeDict.getResistance(fit, kwargs['effect']) + fit.ecmProjectedStr *= strModifier diff --git a/eos/effects/energyneutralizerfalloff.py b/eos/effects/energyneutralizerfalloff.py index bdaaa2d3ac..37d829baaa 100644 --- a/eos/effects/energyneutralizerfalloff.py +++ b/eos/effects/energyneutralizerfalloff.py @@ -3,14 +3,19 @@ # Used by: # Modules from group: Energy Neutralizer (51 of 51) from eos.saveddata.module import State +from eos.modifiedAttributeDict import ModifiedAttributeDict type = "active", "projected" -def handler(fit, src, context): +def handler(fit, src, context, **kwargs): if "projected" in context and ((hasattr(src, "state") and src.state >= State.ACTIVE) or hasattr(src, "amountActive")): amount = src.getModifiedItemAttr("energyNeutralizerAmount") + + if 'effect' in kwargs: + amount *= ModifiedAttributeDict.getResistance(fit, kwargs['effect']) + time = src.getModifiedItemAttr("duration") fit.addDrain(src, time, amount, 0) diff --git a/eos/effects/energynosferatufalloff.py b/eos/effects/energynosferatufalloff.py index 15c7d20ff3..841efb7cfc 100644 --- a/eos/effects/energynosferatufalloff.py +++ b/eos/effects/energynosferatufalloff.py @@ -2,14 +2,19 @@ # # Used by: # Modules from group: Energy Nosferatu (51 of 51) +from eos.modifiedAttributeDict import ModifiedAttributeDict + type = "active", "projected" runTime = "late" -def handler(fit, src, context): +def handler(fit, src, context, **kwargs): amount = src.getModifiedItemAttr("powerTransferAmount") time = src.getModifiedItemAttr("duration") + if 'effect' in kwargs: + amount *= ModifiedAttributeDict.getResistance(fit, kwargs['effect']) + if "projected" in context: fit.addDrain(src, time, amount, 0) elif "module" in context: diff --git a/eos/effects/entityecmfalloff.py b/eos/effects/entityecmfalloff.py index 5d3ec62e92..9e382a6412 100644 --- a/eos/effects/entityecmfalloff.py +++ b/eos/effects/entityecmfalloff.py @@ -2,12 +2,17 @@ # # Used by: # Drones named like: EC (3 of 3) +from eos.modifiedAttributeDict import ModifiedAttributeDict + type = "projected", "active" -def handler(fit, module, context): +def handler(fit, module, context, **kwargs): if "projected" in context: # jam formula: 1 - (1- (jammer str/ship str))^(# of jam mods with same str)) strModifier = 1 - module.getModifiedItemAttr("scan{0}StrengthBonus".format(fit.scanType)) / fit.scanStrength + if 'effect' in kwargs: + strModifier *= ModifiedAttributeDict.getResistance(fit, kwargs['effect']) + fit.ecmProjectedStr *= strModifier diff --git a/eos/effects/entityenergyneutralizerfalloff.py b/eos/effects/entityenergyneutralizerfalloff.py index f5aa5ead14..751cd540c3 100644 --- a/eos/effects/entityenergyneutralizerfalloff.py +++ b/eos/effects/entityenergyneutralizerfalloff.py @@ -3,14 +3,18 @@ # Used by: # Drones from group: Energy Neutralizer Drone (3 of 3) from eos.saveddata.module import State +from eos.modifiedAttributeDict import ModifiedAttributeDict type = "active", "projected" -def handler(fit, src, context): +def handler(fit, src, context, **kwargs): if "projected" in context and ((hasattr(src, "state") and src.state >= State.ACTIVE) or hasattr(src, "amountActive")): amount = src.getModifiedItemAttr("energyNeutralizerAmount") time = src.getModifiedItemAttr("energyNeutralizerDuration") + if 'effect' in kwargs: + amount *= ModifiedAttributeDict.getResistance(fit, kwargs['effect']) + fit.addDrain(src, time, amount, 0) diff --git a/eos/effects/fighterabilityecm.py b/eos/effects/fighterabilityecm.py index 743df38ed3..be4e41929b 100644 --- a/eos/effects/fighterabilityecm.py +++ b/eos/effects/fighterabilityecm.py @@ -3,6 +3,7 @@ Since fighter abilities do not have any sort of item entity in the EVE database, we must derive the abilities from the effects, and thus this effect file contains some custom information useful only to fighters. """ +from eos.modifiedAttributeDict import ModifiedAttributeDict # User-friendly name for the ability displayName = "ECM" @@ -12,10 +13,13 @@ type = "projected", "active" -def handler(fit, module, context): +def handler(fit, module, context, **kwargs): if "projected" not in context: return # jam formula: 1 - (1- (jammer str/ship str))^(# of jam mods with same str)) strModifier = 1 - module.getModifiedItemAttr("{}Strength{}".format(prefix, fit.scanType)) / fit.scanStrength + if 'effect' in kwargs: + strModifier *= ModifiedAttributeDict.getResistance(fit, kwargs['effect']) + fit.ecmProjectedStr *= strModifier diff --git a/eos/effects/fighterabilityenergyneutralizer.py b/eos/effects/fighterabilityenergyneutralizer.py index dd771b7504..1e27342026 100644 --- a/eos/effects/fighterabilityenergyneutralizer.py +++ b/eos/effects/fighterabilityenergyneutralizer.py @@ -4,14 +4,19 @@ effects, and thus this effect file contains some custom information useful only to fighters. """ # User-friendly name for the ability +from eos.modifiedAttributeDict import ModifiedAttributeDict + displayName = "Energy Neutralizer" prefix = "fighterAbilityEnergyNeutralizer" type = "active", "projected" -def handler(fit, src, context): +def handler(fit, src, context, **kwargs): if "projected" in context: amount = src.getModifiedItemAttr("{}Amount".format(prefix)) time = src.getModifiedItemAttr("{}Duration".format(prefix)) + if 'effect' in kwargs: + amount *= ModifiedAttributeDict.getResistance(fit, kwargs['effect']) + fit.addDrain(src, time, amount, 0) diff --git a/eos/effects/modulebonusancillaryremotearmorrepairer.py b/eos/effects/modulebonusancillaryremotearmorrepairer.py index 78a6ef855c..95aa3c793e 100644 --- a/eos/effects/modulebonusancillaryremotearmorrepairer.py +++ b/eos/effects/modulebonusancillaryremotearmorrepairer.py @@ -6,7 +6,7 @@ type = "projected", "active" -def handler(fit, module, context): +def handler(fit, module, context, **kwargs): if "projected" not in context: return @@ -17,4 +17,4 @@ def handler(fit, module, context): amount = module.getModifiedItemAttr("armorDamageAmount") * multiplier speed = module.getModifiedItemAttr("duration") / 1000.0 - fit.extraAttributes.increase("armorRepair", amount / speed) + fit.extraAttributes.increase("armorRepair", amount / speed, **kwargs) diff --git a/eos/effects/modulebonusancillaryremoteshieldbooster.py b/eos/effects/modulebonusancillaryremoteshieldbooster.py index 99b1a444cd..36271629e8 100644 --- a/eos/effects/modulebonusancillaryremoteshieldbooster.py +++ b/eos/effects/modulebonusancillaryremoteshieldbooster.py @@ -6,9 +6,9 @@ type = "projected", "active" -def handler(fit, module, context): +def handler(fit, module, context, **kwargs): if "projected" not in context: return amount = module.getModifiedItemAttr("shieldBonus") speed = module.getModifiedItemAttr("duration") / 1000.0 - fit.extraAttributes.increase("shieldRepair", amount / speed) + fit.extraAttributes.increase("shieldRepair", amount / speed, **kwargs) diff --git a/eos/effects/remotearmorrepairfalloff.py b/eos/effects/remotearmorrepairfalloff.py index e20db1af6a..9bce298299 100644 --- a/eos/effects/remotearmorrepairfalloff.py +++ b/eos/effects/remotearmorrepairfalloff.py @@ -5,8 +5,8 @@ type = "projected", "active" -def handler(fit, container, context): +def handler(fit, container, context, **kwargs): if "projected" in context: bonus = container.getModifiedItemAttr("armorDamageAmount") duration = container.getModifiedItemAttr("duration") / 1000.0 - fit.extraAttributes.increase("armorRepair", bonus / duration) + fit.extraAttributes.increase("armorRepair", bonus / duration, **kwargs) diff --git a/eos/effects/remoteecmfalloff.py b/eos/effects/remoteecmfalloff.py index 3778879922..4092358956 100644 --- a/eos/effects/remoteecmfalloff.py +++ b/eos/effects/remoteecmfalloff.py @@ -2,12 +2,17 @@ # # Used by: # Modules from group: ECM (39 of 39) +from eos.modifiedAttributeDict import ModifiedAttributeDict + type = "projected", "active" -def handler(fit, module, context): +def handler(fit, module, context, **kwargs): if "projected" in context: # jam formula: 1 - (1- (jammer str/ship str))^(# of jam mods with same str)) strModifier = 1 - module.getModifiedItemAttr("scan{0}StrengthBonus".format(fit.scanType)) / fit.scanStrength + if 'effect' in kwargs: + strModifier *= ModifiedAttributeDict.getResistance(fit, kwargs['effect']) + fit.ecmProjectedStr *= strModifier diff --git a/eos/effects/remoteshieldtransferfalloff.py b/eos/effects/remoteshieldtransferfalloff.py index 4bdeee8ebb..f8fc36e604 100644 --- a/eos/effects/remoteshieldtransferfalloff.py +++ b/eos/effects/remoteshieldtransferfalloff.py @@ -5,8 +5,8 @@ type = "projected", "active" -def handler(fit, container, context): +def handler(fit, container, context, **kwargs): if "projected" in context: bonus = container.getModifiedItemAttr("shieldBonus") duration = container.getModifiedItemAttr("duration") / 1000.0 - fit.extraAttributes.increase("shieldRepair", bonus / duration) + fit.extraAttributes.increase("shieldRepair", bonus / duration, **kwargs) diff --git a/eos/effects/shipmoduleremotetrackingcomputer.py b/eos/effects/shipmoduleremotetrackingcomputer.py index 83a63b97f9..698307183d 100644 --- a/eos/effects/shipmoduleremotetrackingcomputer.py +++ b/eos/effects/shipmoduleremotetrackingcomputer.py @@ -5,14 +5,14 @@ type = "projected", "active" -def handler(fit, module, context): +def handler(fit, module, context, **kwargs): if "projected" in context: fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Gunnery"), "trackingSpeed", module.getModifiedItemAttr("trackingSpeedBonus"), - stackingPenalties=True) + stackingPenalties=True, **kwargs) fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Gunnery"), "maxRange", module.getModifiedItemAttr("maxRangeBonus"), - stackingPenalties=True) + stackingPenalties=True, **kwargs) fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Gunnery"), "falloff", module.getModifiedItemAttr("falloffBonus"), - stackingPenalties=True) + stackingPenalties=True, **kwargs) diff --git a/eos/gamedata.py b/eos/gamedata.py index 70a051c8fe..cf5fe17776 100644 --- a/eos/gamedata.py +++ b/eos/gamedata.py @@ -407,7 +407,7 @@ def assistive(self): assistive = False # Go through all effects and find first assistive for effect in self.effects.itervalues(): - if effect.info.isAssistance is True: + if effect.isAssistance is True: # If we find one, stop and mark item as assistive assistive = True break @@ -422,7 +422,7 @@ def offensive(self): offensive = False # Go through all effects and find first offensive for effect in self.effects.itervalues(): - if effect.info.isOffensive is True: + if effect.isOffensive is True: # If we find one, stop and mark item as offensive offensive = True break diff --git a/eos/modifiedAttributeDict.py b/eos/modifiedAttributeDict.py index c8482f15ed..55463448ce 100644 --- a/eos/modifiedAttributeDict.py +++ b/eos/modifiedAttributeDict.py @@ -306,11 +306,14 @@ def preAssign(self, attributeName, value): self.__placehold(attributeName) self.__afflict(attributeName, "=", value, value != self.getOriginal(attributeName)) - def increase(self, attributeName, increase, position="pre", skill=None): + def increase(self, attributeName, increase, position="pre", skill=None, **kwargs): """Increase value of given attribute by given number""" if skill: increase *= self.__handleSkill(skill) + if 'effect' in kwargs: + increase *= ModifiedAttributeDict.getResistance(self.fit, kwargs['effect']) or 1 + # Increases applied before multiplications and after them are # written in separate maps if position == "pre": @@ -365,25 +368,10 @@ def boost(self, attributeName, boostFactor, skill=None, *args, **kwargs): resist = None - # Goddammit CCP, make up you mind where you want this information >.< See #1139 + # Goddammit CCP, make up your mind where you want this information >.< See #1139 if 'effect' in kwargs: - remoteResistID = kwargs['effect'].resistanceID - - # If it doesn't exist on the effect, check the modifying modules attributes. If it's there, set it on the - # effect for this session so that we don't have to look here again (won't always work when it's None, but - # will catch most) - if not remoteResistID: - mod = self.fit.getModifier() - kwargs['effect'].resistanceID = int(mod.getModifiedItemAttr("remoteResistanceID")) or None - remoteResistID = kwargs['effect'].resistanceID - - attrInfo = getAttributeInfo(remoteResistID) - - # Get the attribute of the resist - resist = self.fit.ship.itemModifiedAttributes[attrInfo.attributeName] or None - - if resist: - boostFactor *= resist + resist = ModifiedAttributeDict.getResistance(self.fit, kwargs['effect']) or 1 + boostFactor *= resist # We just transform percentage boost into multiplication factor self.multiply(attributeName, 1 + boostFactor / 100.0, resist=(True if resist else False), *args, **kwargs) @@ -394,6 +382,25 @@ def force(self, attributeName, value): self.__placehold(attributeName) self.__afflict(attributeName, u"\u2263", value) + @staticmethod + def getResistance(fit, effect): + remoteResistID = effect.resistanceID + + # If it doesn't exist on the effect, check the modifying modules attributes. If it's there, set it on the + # effect for this session so that we don't have to look here again (won't always work when it's None, but + # will catch most) + if not remoteResistID: + mod = fit.getModifier() + effect.resistanceID = int(mod.getModifiedItemAttr("remoteResistanceID")) or None + remoteResistID = effect.resistanceID + + attrInfo = getAttributeInfo(remoteResistID) + + # Get the attribute of the resist + resist = fit.ship.itemModifiedAttributes[attrInfo.attributeName] or None + + return resist or 1.0 + class Affliction(object): def __init__(self, affliction_type, amount):