Skip to content

Commit

Permalink
Implement ewar resists (#597)
Browse files Browse the repository at this point in the history
  • Loading branch information
blitzmann committed May 22, 2016
1 parent f9c5954 commit 4607dd7
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 10 deletions.
2 changes: 1 addition & 1 deletion eos/effects/remoteguidancedisruptfalloff.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ def handler(fit, src, context):
):
fit.modules.filteredChargeBoost(lambda mod: mod.charge.requiresSkill("Missile Launcher Operation"),
tgtAttr, src.getModifiedItemAttr(srcAttr),
stackingPenalties=True)
stackingPenalties=True, remoteResists=True)
8 changes: 6 additions & 2 deletions eos/effects/remotesensordampfalloff.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
def handler(fit, module, context):
if "projected" not in context:
return

print "in sensor damp projection on ", fit, module.getModifiedItemAttr("maxTargetRangeBonus")
print fit.ship.getModifiedItemAttr('maxTargetRange')
fit.ship.boostItemAttr("maxTargetRange", module.getModifiedItemAttr("maxTargetRangeBonus"),
stackingPenalties = True)
stackingPenalties = True, remoteResists=True)
print fit.ship.getModifiedItemAttr('maxTargetRange')
fit.ship.boostItemAttr("scanResolution", module.getModifiedItemAttr("scanResolutionBonus"),
stackingPenalties = True)
stackingPenalties = True, remoteResists=True)
2 changes: 1 addition & 1 deletion eos/effects/remotetargetpaintfalloff.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
def handler(fit, container, context):
if "projected" in context:
fit.ship.boostItemAttr("signatureRadius", container.getModifiedItemAttr("signatureRadiusBonus"),
stackingPenalties = True)
stackingPenalties = True, remoteResists=True)
6 changes: 3 additions & 3 deletions eos/effects/remotetrackingdisruptfalloff.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ def handler(fit, module, context):
if "projected" in context:
fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Gunnery"),
"trackingSpeed", module.getModifiedItemAttr("trackingSpeedBonus"),
stackingPenalties = True)
stackingPenalties = True, remoteResists=True)
fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Gunnery"),
"maxRange", module.getModifiedItemAttr("maxRangeBonus"),
stackingPenalties = True)
stackingPenalties = True, remoteResists=True)
fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Gunnery"),
"falloff", module.getModifiedItemAttr("falloffBonus"),
stackingPenalties = True)
stackingPenalties = True, remoteResists=True)
2 changes: 1 addition & 1 deletion eos/effects/remotewebifierfalloff.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
def handler(fit, module, context):
if "projected" not in context: return
fit.ship.boostItemAttr("maxVelocity", module.getModifiedItemAttr("speedFactor"),
stackingPenalties = True)
stackingPenalties = True, remoteResists=True)
15 changes: 14 additions & 1 deletion eos/modifiedAttributeDict.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,27 @@ def multiply(self, attributeName, multiplier, stackingPenalties=False, penaltyGr
if not attributeName in self.__multipliers:
self.__multipliers[attributeName] = 1
self.__multipliers[attributeName] *= multiplier

self.__placehold(attributeName)
self.__afflict(attributeName, "%s*" % ("s" if stackingPenalties else ""), multiplier, multiplier != 1)

def boost(self, attributeName, boostFactor, skill=None, *args, **kwargs):
def boost(self, attributeName, boostFactor, skill=None, remoteResists=False, *args, **kwargs):
"""Boost value by some percentage"""
if skill:
boostFactor *= self.__handleSkill(skill)

if remoteResists:
# @todo: this is such a disgusting hack. Look into sending these checks to the module class before the
# effect is applied.
mod = self.fit.getModifier()
remoteResistID = mod.getModifiedItemAttr("remoteResistanceID") or None

# We really don't have a way of getting a ships attribute by ID. Fail.
resist = next((x for x in self.fit.ship.item.attributes.values() if x.ID == remoteResistID), None)

if remoteResistID and resist:
boostFactor *= resist.value

# We just transform percentage boost into multiplication factor
self.multiply(attributeName, 1 + boostFactor / 100.0, *args, **kwargs)

Expand Down
5 changes: 4 additions & 1 deletion eos/saveddata/character.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,10 @@ def item(self):
return self.__item

def getModifiedItemAttr(self, key):
return self.item.attributes[key].value
if key in self.item.attributes:
return self.item.attributes[key].value
else:
return None

def calculateModifiedAttributes(self, fit, runTime):
if self.__suppressed: # or not self.learned - removed for GH issue 101
Expand Down

0 comments on commit 4607dd7

Please sign in to comment.