Skip to content

Commit

Permalink
Get resists working with more things, and fix bug in which we were st…
Browse files Browse the repository at this point in the history
…ill looking at an effect info (which doesn't exist anymore)
  • Loading branch information
blitzmann committed May 7, 2017
1 parent 4a9662c commit 0507a55
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 41 deletions.
7 changes: 6 additions & 1 deletion eos/effects/ecmburstjammer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 6 additions & 1 deletion eos/effects/energyneutralizerfalloff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
7 changes: 6 additions & 1 deletion eos/effects/energynosferatufalloff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 6 additions & 1 deletion eos/effects/entityecmfalloff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 5 additions & 1 deletion eos/effects/entityenergyneutralizerfalloff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 5 additions & 1 deletion eos/effects/fighterabilityecm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
7 changes: 6 additions & 1 deletion eos/effects/fighterabilityenergyneutralizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions eos/effects/modulebonusancillaryremotearmorrepairer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
type = "projected", "active"


def handler(fit, module, context):
def handler(fit, module, context, **kwargs):
if "projected" not in context:
return

Expand All @@ -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)
4 changes: 2 additions & 2 deletions eos/effects/modulebonusancillaryremoteshieldbooster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions eos/effects/remotearmorrepairfalloff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
7 changes: 6 additions & 1 deletion eos/effects/remoteecmfalloff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions eos/effects/remoteshieldtransferfalloff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 4 additions & 4 deletions eos/effects/shipmoduleremotetrackingcomputer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions eos/gamedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
45 changes: 26 additions & 19 deletions eos/modifiedAttributeDict.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -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)
Expand All @@ -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):
Expand Down

0 comments on commit 0507a55

Please sign in to comment.