Get resists working with more things, and fix bug in which we were still looking at an effect info (which doesn't exist anymore)

This commit is contained in:
blitzmann
2017-05-07 18:55:47 -04:00
parent 4a9662c0f7
commit 0507a55731
15 changed files with 86 additions and 41 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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:

View File

@@ -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

View File

@@ -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)

View File

@@ -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 @@ prefix = "fighterAbilityECM"
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

View File

@@ -4,14 +4,19 @@ Since fighter abilities do not have any sort of item entity in the EVE database,
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)

View File

@@ -6,7 +6,7 @@ runTime = "late"
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)

View File

@@ -6,9 +6,9 @@ runTime = "late"
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)

View File

@@ -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)

View File

@@ -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

View File

@@ -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)

View File

@@ -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)

View File

@@ -407,7 +407,7 @@ class Item(EqBase):
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 @@ class Item(EqBase):
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

View File

@@ -306,11 +306,14 @@ class ModifiedAttributeDict(collections.MutableMapping):
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 @@ class ModifiedAttributeDict(collections.MutableMapping):
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 @@ class ModifiedAttributeDict(collections.MutableMapping):
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):