Merge pull request #1491 from Neugeniko/Capsimreload

CapSim changes to make reloadtime a variable.
This commit is contained in:
Ryan Holmes
2018-03-21 21:03:40 -04:00
committed by GitHub
2 changed files with 17 additions and 15 deletions

View File

@@ -71,7 +71,7 @@ class CapSimulator(object):
disable_period = False disable_period = False
# Loop over modules, clearing clipSize if applicable, and group modules based on attributes # Loop over modules, clearing clipSize if applicable, and group modules based on attributes
for (duration, capNeed, clipSize, disableStagger) in self.modules: for (duration, capNeed, clipSize, disableStagger, reloadTime) in self.modules:
if self.scale: if self.scale:
duration, capNeed = self.scale_activation(duration, capNeed) duration, capNeed = self.scale_activation(duration, capNeed)
@@ -79,24 +79,25 @@ class CapSimulator(object):
# a cap booster module. # a cap booster module.
if not self.reload and capNeed > 0: if not self.reload and capNeed > 0:
clipSize = 0 clipSize = 0
reloadTime = 0
# Group modules based on their properties # Group modules based on their properties
if (duration, capNeed, clipSize, disableStagger) in mods: if (duration, capNeed, clipSize, disableStagger, reloadTime) in mods:
mods[(duration, capNeed, clipSize, disableStagger)] += 1 mods[(duration, capNeed, clipSize, disableStagger, reloadTime)] += 1
else: else:
mods[(duration, capNeed, clipSize, disableStagger)] = 1 mods[(duration, capNeed, clipSize, disableStagger, reloadTime)] = 1
# Loop over grouped modules, configure staggering and push to the simulation state # Loop over grouped modules, configure staggering and push to the simulation state
for (duration, capNeed, clipSize, disableStagger), amount in mods.iteritems(): for (duration, capNeed, clipSize, disableStagger, reloadTime), amount in mods.iteritems():
if self.stagger and not disableStagger: if self.stagger and not disableStagger:
if clipSize == 0: if clipSize == 0:
duration = int(duration / amount) duration = int(duration / amount)
else: else:
stagger_amount = (duration * clipSize + 10000) / (amount * clipSize) stagger_amount = (duration * clipSize + reloadTime) / (amount * clipSize)
for i in range(1, amount): for i in range(1, amount):
heapq.heappush(self.state, heapq.heappush(self.state,
[i * stagger_amount, duration, [i * stagger_amount, duration,
capNeed, 0, clipSize]) capNeed, 0, clipSize, reloadTime])
else: else:
capNeed *= amount capNeed *= amount
@@ -106,7 +107,7 @@ class CapSimulator(object):
if clipSize: if clipSize:
disable_period = True disable_period = True
heapq.heappush(self.state, [0, duration, capNeed, 0, clipSize]) heapq.heappush(self.state, [0, duration, capNeed, 0, clipSize, reloadTime])
if disable_period: if disable_period:
self.period = self.t_max self.period = self.t_max
@@ -143,7 +144,7 @@ class CapSimulator(object):
while 1: while 1:
activation = pop(state) activation = pop(state)
t_now, duration, capNeed, shot, clipSize = activation t_now, duration, capNeed, shot, clipSize, reloadTime = activation
if t_now >= t_max: if t_now >= t_max:
break break
@@ -179,7 +180,7 @@ class CapSimulator(object):
if clipSize: if clipSize:
if shot % clipSize == 0: if shot % clipSize == 0:
shot = 0 shot = 0
t_now += 10000 # include reload time t_now += reloadTime # include reload time
activation[0] = t_now activation[0] = t_now
activation[3] = shot activation[3] = shot

View File

@@ -1186,7 +1186,7 @@ class Fit(object):
rechargeRate = self.ship.getModifiedItemAttr("shieldRechargeRate") / 1000.0 rechargeRate = self.ship.getModifiedItemAttr("shieldRechargeRate") / 1000.0
return 10 / rechargeRate * sqrt(percent) * (1 - sqrt(percent)) * capacity return 10 / rechargeRate * sqrt(percent) * (1 - sqrt(percent)) * capacity
def addDrain(self, src, cycleTime, capNeed, clipSize=0): def addDrain(self, src, cycleTime, capNeed, clipSize=0, reloadTime=0):
""" Used for both cap drains and cap fills (fills have negative capNeed) """ """ Used for both cap drains and cap fills (fills have negative capNeed) """
energyNeutralizerSignatureResolution = src.getModifiedItemAttr("energyNeutralizerSignatureResolution") energyNeutralizerSignatureResolution = src.getModifiedItemAttr("energyNeutralizerSignatureResolution")
@@ -1196,7 +1196,7 @@ class Fit(object):
if energyNeutralizerSignatureResolution: if energyNeutralizerSignatureResolution:
capNeed = capNeed * min(1, signatureRadius / energyNeutralizerSignatureResolution) capNeed = capNeed * min(1, signatureRadius / energyNeutralizerSignatureResolution)
self.__extraDrains.append((cycleTime, capNeed, clipSize)) self.__extraDrains.append((cycleTime, capNeed, clipSize, reloadTime))
def removeDrain(self, i): def removeDrain(self, i):
del self.__extraDrains[i] del self.__extraDrains[i]
@@ -1214,6 +1214,7 @@ class Fit(object):
cycleTime = mod.rawCycleTime or 0 cycleTime = mod.rawCycleTime or 0
reactivationTime = mod.getModifiedItemAttr("moduleReactivationDelay") or 0 reactivationTime = mod.getModifiedItemAttr("moduleReactivationDelay") or 0
fullCycleTime = cycleTime + reactivationTime fullCycleTime = cycleTime + reactivationTime
reloadTime = mod.reloadTime
if fullCycleTime > 0: if fullCycleTime > 0:
capNeed = mod.capUse capNeed = mod.capUse
if capNeed > 0: if capNeed > 0:
@@ -1225,11 +1226,11 @@ class Fit(object):
disableStagger = mod.hardpoint == Hardpoint.TURRET disableStagger = mod.hardpoint == Hardpoint.TURRET
drains.append((int(fullCycleTime), mod.getModifiedItemAttr("capacitorNeed") or 0, drains.append((int(fullCycleTime), mod.getModifiedItemAttr("capacitorNeed") or 0,
mod.numShots or 0, disableStagger)) mod.numShots or 0, disableStagger, reloadTime))
for fullCycleTime, capNeed, clipSize in self.iterDrains(): for fullCycleTime, capNeed, clipSize, reloadTime in self.iterDrains():
# Stagger incoming effects for cap simulation # Stagger incoming effects for cap simulation
drains.append((int(fullCycleTime), capNeed, clipSize, False)) drains.append((int(fullCycleTime), capNeed, clipSize, False, reloadTime))
if capNeed > 0: if capNeed > 0:
capUsed += capNeed / (fullCycleTime / 1000.0) capUsed += capNeed / (fullCycleTime / 1000.0)
else: else: