Made fighter DPS calculations more accurate when factoring in reload time.

This commit is contained in:
Mr. Nukealizer
2016-09-30 23:44:12 -07:00
parent c1b3491933
commit 30755fbb73
2 changed files with 34 additions and 6 deletions

View File

@@ -164,6 +164,26 @@ class Fighter(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
dps, volley = ability.damageStats(targetResists)
self.__dps += dps
self.__volley += volley
# For forward compatability this assumes a fighter can have more than 2 damaging abilities and/or multiple that use charges.
if self.owner.factorReload:
activeTimes = []
reloadTimes = []
constantDps = 0
for ability in self.abilities:
if not ability.active:
continue
if ability.numShots == 0:
dps, volley = ability.damageStats(targetResists)
constantDps += dps
continue
activeTimes.append(ability.numShots * ability.cycleTime)
reloadTimes.append(ability.reloadTime)
if(len(activeTimes) > 0):
shortestActive = sorted(activeTimes)[0]
longestReload = sorted(reloadTimes, reverse=True)[0]
self.__dps = max(constantDps, self.__dps * shortestActive / (shortestActive + longestReload))
return self.__dps, self.__volley

View File

@@ -30,10 +30,18 @@ class FighterAbility(object):
# with the fighter squadron role
NUM_SHOTS_MAPPING = {
1: 0, # Superiority fighter / Attack
2: 12, # Light fighter / Attack
2: 12, # Light fighter / Attack
4: 6, # Heavy fighter / Heavy attack
5: 3, # Heavy fighter / Long range attack
}
# Same as above
REARM_TIME_MAPPING = {
1: 0, # Superiority fighter / Attack
2: 4000, # Light fighter / Attack
4: 6000, # Heavy fighter / Heavy attack
5: 20000, # Heavy fighter / Long range attack
}
def __init__(self, effect):
"""Initialize from the program"""
@@ -86,7 +94,7 @@ class FighterAbility(object):
@property
def reloadTime(self):
return self.fighter.getModifiedItemAttr("fighterRefuelingTime") * self.numShots
return self.fighter.getModifiedItemAttr("fighterRefuelingTime") + (self.REARM_TIME_MAPPING[self.fighter.getModifiedItemAttr("fighterSquadronRole")] or 0 if self.hasCharges else 0) * self.numShots
@property
def numShots(self):
@@ -97,10 +105,10 @@ class FighterAbility(object):
speed = self.fighter.getModifiedItemAttr("{}Duration".format(self.attrPrefix))
reload = self.reloadTime
if self.fighter.owner.factorReload:
numShots = self.numShots
# Speed here already takes into consideration reactivation time
speed = (speed * numShots + reload) / numShots if numShots > 0 else speed
#if self.fighter.owner.factorReload:
# numShots = self.numShots
# # Speed here already takes into consideration reactivation time
# speed = (speed * numShots + reload) / numShots if numShots > 0 else speed
return speed