Push info about injector into cap sim

This commit is contained in:
DarkPhoenix
2019-08-08 19:46:44 +03:00
parent 27e361dc5b
commit 49cb81b516
2 changed files with 24 additions and 13 deletions

View File

@@ -59,7 +59,7 @@ class CapSimulator:
return duration, capNeed
def init(self, modules):
"""prepare modules. a list of (duration, capNeed, clipSize, disableStagger) tuples is
"""prepare modules. a list of (duration, capNeed, clipSize, disableStagger, reloadTime, isInjector) tuples is
expected, with clipSize 0 if the module has infinite ammo.
"""
self.modules = modules
@@ -72,7 +72,7 @@ class CapSimulator:
disable_period = False
# Loop over modules, clearing clipSize if applicable, and group modules based on attributes
for (duration, capNeed, clipSize, disableStagger, reloadTime) in self.modules:
for (duration, capNeed, clipSize, disableStagger, reloadTime, isInjector) in self.modules:
if self.scale:
duration, capNeed = self.scale_activation(duration, capNeed)
@@ -83,22 +83,22 @@ class CapSimulator:
reloadTime = 0
# Group modules based on their properties
if (duration, capNeed, clipSize, disableStagger, reloadTime) in mods:
mods[(duration, capNeed, clipSize, disableStagger, reloadTime)] += 1
if (duration, capNeed, clipSize, disableStagger, reloadTime, isInjector) in mods:
mods[(duration, capNeed, clipSize, disableStagger, reloadTime, isInjector)] += 1
else:
mods[(duration, capNeed, clipSize, disableStagger, reloadTime)] = 1
mods[(duration, capNeed, clipSize, disableStagger, reloadTime, isInjector)] = 1
# Loop over grouped modules, configure staggering and push to the simulation state
for (duration, capNeed, clipSize, disableStagger, reloadTime), amount in mods.items():
for (duration, capNeed, clipSize, disableStagger, reloadTime, isInjector), amount in mods.items():
if self.stagger and not disableStagger:
if clipSize == 0:
duration = int(duration / amount)
else:
stagger_amount = (duration * clipSize + reloadTime) / (amount * clipSize)
for i in range(1, amount):
heapq.heappush(self.state,
[i * stagger_amount, duration,
capNeed, 0, clipSize, reloadTime])
heapq.heappush(
self.state,
[i * stagger_amount, duration, capNeed, 0, clipSize, reloadTime])
else:
capNeed *= amount

View File

@@ -1244,12 +1244,23 @@ class Fit:
# If this is a turret, don't stagger activations
disableStagger = mod.hardpoint == FittingHardpoint.TURRET
drains.append((int(fullCycleTime), mod.getModifiedItemAttr("capacitorNeed") or 0,
mod.numShots or 0, disableStagger, reloadTime))
drains.append((
int(fullCycleTime),
mod.getModifiedItemAttr("capacitorNeed") or 0,
mod.numShots or 0,
disableStagger,
reloadTime,
mod.item.group == 'Capacitor Booster'))
for fullCycleTime, capNeed, clipSize, reloadTime in self.iterDrains():
# Stagger incoming effects for cap simulation
drains.append((int(fullCycleTime), capNeed, clipSize, False, reloadTime))
drains.append((
int(fullCycleTime),
capNeed,
clipSize,
# Stagger incoming effects for cap simulation
False,
reloadTime,
False))
if capNeed > 0:
capUsed += capNeed / (fullCycleTime / 1000.0)
else: