Make sure dromis can be resisted

This commit is contained in:
DarkPhoenix
2019-07-08 16:37:43 +03:00
parent a74984d37b
commit e796b748b6
5 changed files with 4658 additions and 4776 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -29,14 +29,19 @@ cappingAttrKeyCache = {}
def getResistanceAttrID(modifyingItem, 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:
effect.resistanceID = int(modifyingItem.getModifiedItemAttr("remoteResistanceID")) or None
remoteResistID = effect.resistanceID
return remoteResistID
if not effect.getattr('resistanceCalculated'):
attrPrefix = effect.getattr('prefix')
if attrPrefix:
effect.resistanceID = int(modifyingItem.getModifiedItemAttr('{}ResistanceID'.format(attrPrefix))) or None
if not effect.resistanceID:
effect.resistanceID = int(modifyingItem.getModifiedItemAttr('{}RemoteResistanceID'.format(attrPrefix))) or None
else:
effect.resistanceID = int(modifyingItem.getModifiedItemAttr("remoteResistanceID")) or None
effect.resistanceCalculated = True
return effect.resistanceID
class ItemAttrShortcut:
@@ -396,7 +401,7 @@ class ModifiedAttributeDict(collections.MutableMapping):
# Add current affliction to list
affs.append((modifier, operation, bonus, used))
def preAssign(self, attributeName, value):
def preAssign(self, attributeName, value, **kwargs):
"""Overwrites original value of the entity with given one, allowing further modification"""
self.__preAssigns[attributeName] = value
self.__placehold(attributeName)
@@ -424,7 +429,7 @@ class ModifiedAttributeDict(collections.MutableMapping):
self.__placehold(attributeName)
self.__afflict(attributeName, "+", increase, increase != 0)
def multiply(self, attributeName, multiplier, stackingPenalties=False, penaltyGroup="default", skill=None, *args, **kwargs):
def multiply(self, attributeName, multiplier, stackingPenalties=False, penaltyGroup="default", skill=None, **kwargs):
"""Multiply value of given attribute by given factor"""
if multiplier is None: # See GH issue 397
return
@@ -465,15 +470,15 @@ class ModifiedAttributeDict(collections.MutableMapping):
self.__afflict(attributeName, "%s*" % afflictPenal, multiplier, multiplier != 1)
def boost(self, attributeName, boostFactor, skill=None, *args, **kwargs):
def boost(self, attributeName, boostFactor, skill=None, **kwargs):
"""Boost value by some percentage"""
if skill:
boostFactor *= self.__handleSkill(skill)
# We just transform percentage boost into multiplication factor
self.multiply(attributeName, 1 + boostFactor / 100.0, *args, **kwargs)
self.multiply(attributeName, 1 + boostFactor / 100.0, **kwargs)
def force(self, attributeName, value):
def force(self, attributeName, value, **kwargs):
"""Force value to attribute and prohibit any changes to it"""
self.__forced[attributeName] = value
self.__placehold(attributeName)
@@ -481,6 +486,13 @@ class ModifiedAttributeDict(collections.MutableMapping):
@staticmethod
def getResistance(fit, effect):
# Resistances are applicable only to projected effects
if isinstance(effect.type, (tuple, list)):
effectType = effect.type
else:
effectType = (effect.type,)
if 'projected' not in effectType:
return 1
remoteResistID = getResistanceAttrID(modifyingItem=fit.getModifier(), effect=effect)
attrInfo = getAttributeInfo(remoteResistID)
# Get the attribute of the resist

View File

@@ -308,11 +308,17 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
projected is False and effect.isType("passive")):
# See GH issue #765
if effect.getattr('grouped'):
effect.handler(fit, self, context)
try:
effect.handler(fit, self, context, effect=effect)
except:
effect.handler(fit, self, context)
else:
i = 0
while i != self.amountActive:
effect.handler(fit, self, context)
try:
effect.handler(fit, self, context, effect=effect)
except:
effect.handler(fit, self, context)
i += 1
if self.charge:

View File

@@ -394,11 +394,17 @@ class Fighter(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
if effect.runTime == runTime and effect.activeByDefault and \
((projected and effect.isType("projected")) or not projected):
if ability.grouped:
effect.handler(fit, self, context)
try:
effect.handler(fit, self, context, effect=effect)
except:
effect.handler(fit, self, context)
else:
i = 0
while i != self.amountActive:
effect.handler(fit, self, context)
try:
effect.handler(fit, self, context, effect=effect)
except:
effect.handler(fit, self, context)
i += 1
def __deepcopy__(self, memo):

View File

@@ -72,27 +72,29 @@ class ProjectedDataCache(FitDataCache):
try:
projectedData = self._data[fit.ID]['drones']
except KeyError:
# Format of items for both: (boost strength, optimal, falloff, stacking group, speed, radius)
webMods = []
tpMods = []
projectedData = self._data.setdefault(fit.ID, {})['drones'] = (webMods, tpMods)
# Format of items for both: (boost strength, optimal, falloff, stacking group, resistance attr ID, drone speed, drone radius)
webDrones = []
tpDrones = []
projectedData = self._data.setdefault(fit.ID, {})['drones'] = (webDrones, tpDrones)
for drone in fit.drones:
if drone.amountActive <= 0:
continue
if 'remoteWebifierEntity' in drone.item.effects:
webMods.extend(drone.amountActive * ((
webDrones.extend(drone.amountActive * ((
drone.getModifiedItemAttr('speedFactor'),
drone.maxRange or 0,
drone.falloff or 0,
'default',
getResistanceAttrID(modifyingItem=drone, effect=drone.item.effects['remoteWebifierEntity']),
drone.getModifiedItemAttr('maxVelocity'),
drone.getModifiedItemAttr('radius')),))
if 'remoteTargetPaintEntity' in drone.item.effects:
tpMods.extend(drone.amountActive * ((
tpDrones.extend(drone.amountActive * ((
drone.getModifiedItemAttr('signatureRadiusBonus'),
drone.maxRange or 0,
drone.falloff or 0,
'default',
getResistanceAttrID(modifyingItem=drone, effect=drone.item.effects['remoteTargetPaintEntity']),
drone.getModifiedItemAttr('maxVelocity'),
drone.getModifiedItemAttr('radius')),))
return projectedData
@@ -101,27 +103,23 @@ class ProjectedDataCache(FitDataCache):
try:
projectedData = self._data[fit.ID]['fighters']
except KeyError:
# Format of items for both: (boost strength, optimal, falloff, stacking group, speed, radius)
webMods = []
tpMods = []
projectedData = self._data.setdefault(fit.ID, {})['fighters'] = (webMods, tpMods)
for drone in fit.drones:
if drone.amountActive <= 0:
# Format of items for both: (boost strength, optimal, falloff, stacking group, resistance attr ID, drone speed, drone radius)
webFighters = []
tpFighters = []
projectedData = self._data.setdefault(fit.ID, {})['fighters'] = (webFighters, tpFighters)
for fighter in fit.fighters:
if not fighter.active:
continue
if 'remoteWebifierEntity' in drone.item.effects:
webMods.extend(drone.amountActive * ((
drone.getModifiedItemAttr('speedFactor'),
drone.maxRange or 0,
drone.falloff or 0,
'default',
drone.getModifiedItemAttr('maxVelocity'),
drone.getModifiedItemAttr('radius')),))
if 'remoteTargetPaintEntity' in drone.item.effects:
tpMods.extend(drone.amountActive * ((
drone.getModifiedItemAttr('signatureRadiusBonus'),
drone.maxRange or 0,
drone.falloff or 0,
'default',
drone.getModifiedItemAttr('maxVelocity'),
drone.getModifiedItemAttr('radius')),))
for ability in fighter.abilities:
if not ability.active:
continue
if ability.effect.name == 'fighterAbilityStasisWebifier':
webFighters.extend((
drone.getModifiedItemAttr('speedFactor'),
drone.maxRange or 0,
drone.falloff or 0,
'default',
getResistanceAttrID(modifyingItem=drone, effect=drone.item.effects['remoteWebifierEntity']),
drone.getModifiedItemAttr('maxVelocity'),
drone.getModifiedItemAttr('radius')))
return projectedData