Skip to content

Commit c7c0c49

Browse files
committed
Fix #434
1 parent 2b9d85a commit c7c0c49

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

eos/effects/covertopscloakcpupercentbonus1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
type = "passive"
66
runTime = "early"
77
def handler(fit, ship, context):
8-
fit.modules.filteredItemBoost(lambda mod: mod.item.group.name == "Cloaking Device",
8+
fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Cloaking"),
99
"cpu", ship.getModifiedItemAttr("eliteBonusCoverOps1"), skill="Covert Ops")

eos/modifiedAttributeDict.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ class ModifiedAttributeDict(collections.MutableMapping):
4444
class CalculationPlaceholder():
4545
pass
4646

47-
def __init__(self, fit = None):
47+
def __init__(self, fit=None, parent=None):
48+
self.parent = parent
4849
self.fit = fit
4950
# Stores original values of the entity
5051
self.__original = None
@@ -225,8 +226,15 @@ def __handleSkill(self, skillName):
225226
with the fit and thus get the correct affector. Returns skill level to
226227
be used to modify modifier. See GH issue #101
227228
"""
228-
skill = self.fit.character.getSkill(skillName)
229-
self.fit.register(skill)
229+
fit = self.fit
230+
if not fit:
231+
# self.fit is usually set during fit calculations when the item is registered with the fit. However,
232+
# under certain circumstances, an effect will not work as it will try to modify an item which has NOT
233+
# yet been registered and thus has not had self.fit set. In this case, use the modules owner attribute
234+
# to point to the correct fit. See GH Issue #434
235+
fit = self.parent.owner
236+
skill = fit.character.getSkill(skillName)
237+
fit.register(skill)
230238
return skill.level
231239

232240
def getAfflictions(self, key):

eos/saveddata/module.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ def build(self):
107107
self.__reloadForce = None
108108
self.__chargeCycles = None
109109
self.__hardpoint = Hardpoint.NONE
110-
self.__itemModifiedAttributes = ModifiedAttributeDict()
111-
self.__chargeModifiedAttributes = ModifiedAttributeDict()
110+
self.__itemModifiedAttributes = ModifiedAttributeDict(parent=self)
111+
self.__chargeModifiedAttributes = ModifiedAttributeDict(parent=self)
112112
self.__slot = self.dummySlot # defaults to None
113113

114114
if self.__item:

0 commit comments

Comments
 (0)