This commit is contained in:
blitzmann
2015-11-27 20:08:36 -05:00
parent 2b9d85a4bc
commit c7c0c49218
3 changed files with 14 additions and 6 deletions

View File

@@ -5,5 +5,5 @@
type = "passive"
runTime = "early"
def handler(fit, ship, context):
fit.modules.filteredItemBoost(lambda mod: mod.item.group.name == "Cloaking Device",
fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Cloaking"),
"cpu", ship.getModifiedItemAttr("eliteBonusCoverOps1"), skill="Covert Ops")

View File

@@ -44,7 +44,8 @@ class ModifiedAttributeDict(collections.MutableMapping):
class CalculationPlaceholder():
pass
def __init__(self, fit = None):
def __init__(self, fit=None, parent=None):
self.parent = parent
self.fit = fit
# Stores original values of the entity
self.__original = None
@@ -225,8 +226,15 @@ class ModifiedAttributeDict(collections.MutableMapping):
with the fit and thus get the correct affector. Returns skill level to
be used to modify modifier. See GH issue #101
"""
skill = self.fit.character.getSkill(skillName)
self.fit.register(skill)
fit = self.fit
if not fit:
# self.fit is usually set during fit calculations when the item is registered with the fit. However,
# under certain circumstances, an effect will not work as it will try to modify an item which has NOT
# yet been registered and thus has not had self.fit set. In this case, use the modules owner attribute
# to point to the correct fit. See GH Issue #434
fit = self.parent.owner
skill = fit.character.getSkill(skillName)
fit.register(skill)
return skill.level
def getAfflictions(self, key):

View File

@@ -107,8 +107,8 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
self.__reloadForce = None
self.__chargeCycles = None
self.__hardpoint = Hardpoint.NONE
self.__itemModifiedAttributes = ModifiedAttributeDict()
self.__chargeModifiedAttributes = ModifiedAttributeDict()
self.__itemModifiedAttributes = ModifiedAttributeDict(parent=self)
self.__chargeModifiedAttributes = ModifiedAttributeDict(parent=self)
self.__slot = self.dummySlot # defaults to None
if self.__item: