TargetResists: drones work. Also cleaned up redundancy in module.damageStats()
This commit is contained in:
@@ -22,7 +22,7 @@ from eos.effectHandlerHelpers import HandledItem, HandledCharge
|
||||
from sqlalchemy.orm import validates, reconstructor
|
||||
|
||||
class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
DAMAGE_ATTRIBUTES = ("emDamage", "kineticDamage", "explosiveDamage", "thermalDamage")
|
||||
DAMAGE_TYPES = ("em", "kinetic", "explosive", "thermal")
|
||||
MINING_ATTRIBUTES = ("miningAmount",)
|
||||
|
||||
def __init__(self, item):
|
||||
@@ -111,6 +111,9 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
|
||||
@property
|
||||
def dps(self):
|
||||
return self.damageStats()
|
||||
|
||||
def damageStats(self, targetResists = None):
|
||||
if self.__dps == None:
|
||||
if self.dealsDamage is True and self.amountActive > 0:
|
||||
if self.hasAmmo:
|
||||
@@ -121,7 +124,9 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
getter = self.getModifiedItemAttr
|
||||
|
||||
cycleTime = self.getModifiedItemAttr(attr)
|
||||
volley = sum(map(lambda d: getter(d), self.DAMAGE_ATTRIBUTES)) * self.amountActive
|
||||
|
||||
volley = sum(map(lambda d: (getter("%sDamage"%d) or 0) * (1-getattr(targetResists, "%sAmount"%d, 0)), self.DAMAGE_TYPES))
|
||||
volley *= self.amountActive
|
||||
volley *= self.getModifiedItemAttr("damageMultiplier") or 1
|
||||
self.__dps = volley / (cycleTime / 1000.0)
|
||||
else:
|
||||
|
||||
@@ -827,7 +827,7 @@ class Fit(object):
|
||||
weaponVolley += volley
|
||||
|
||||
for drone in self.drones:
|
||||
droneDPS += drone.dps
|
||||
droneDPS += drone.damageStats(self.targetResists)
|
||||
|
||||
self.__weaponDPS = weaponDPS
|
||||
self.__weaponVolley = weaponVolley
|
||||
|
||||
@@ -310,28 +310,21 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
|
||||
def damageStats(self, targetResists):
|
||||
if self.__dps == None:
|
||||
if self.isEmpty:
|
||||
self.__dps = 0
|
||||
self.__volley = 0
|
||||
else:
|
||||
if self.state >= State.ACTIVE:
|
||||
if self.charge:
|
||||
func = self.getModifiedChargeAttr
|
||||
else:
|
||||
func = self.getModifiedItemAttr
|
||||
self.__dps = 0
|
||||
self.__volley = 0
|
||||
|
||||
volley = sum(map(lambda attr: (func("%sDamage"%attr) or 0) * (1-getattr(targetResists, "%sAmount"%attr, 0)), self.DAMAGE_TYPES))
|
||||
volley *= self.getModifiedItemAttr("damageMultiplier") or 1
|
||||
if volley:
|
||||
cycleTime = self.cycleTime
|
||||
self.__volley = volley
|
||||
self.__dps = volley / (cycleTime / 1000.0)
|
||||
else:
|
||||
self.__volley = 0
|
||||
self.__dps = 0
|
||||
if not self.isEmpty and self.state >= State.ACTIVE:
|
||||
if self.charge:
|
||||
func = self.getModifiedChargeAttr
|
||||
else:
|
||||
self.__volley = 0
|
||||
self.__dps = 0
|
||||
func = self.getModifiedItemAttr
|
||||
|
||||
volley = sum(map(lambda attr: (func("%sDamage"%attr) or 0) * (1-getattr(targetResists, "%sAmount"%attr, 0)), self.DAMAGE_TYPES))
|
||||
volley *= self.getModifiedItemAttr("damageMultiplier") or 1
|
||||
if volley:
|
||||
cycleTime = self.cycleTime
|
||||
self.__volley = volley
|
||||
self.__dps = volley / (cycleTime / 1000.0)
|
||||
|
||||
return self.__dps, self.__volley
|
||||
|
||||
@@ -355,11 +348,11 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
|
||||
@property
|
||||
def dps(self):
|
||||
return self.damageStats[0]
|
||||
return self.damageStats(None)[0]
|
||||
|
||||
@property
|
||||
def volley(self):
|
||||
return self.damageStats[1]
|
||||
return self.damageStats(None)[1]
|
||||
|
||||
@property
|
||||
def reloadTime(self):
|
||||
|
||||
Reference in New Issue
Block a user