def getCycleParameters(self, reloadOverride=None): """Copied from new eos as well""" # Determine if we'll take into account reload time or not if reloadOverride is not None: factorReload = reloadOverride else: factorReload = self.owner.factorReload if self.forceReload is None else self.forceReload cycles_until_reload = self.numShots if cycles_until_reload == 0: cycles_until_reload = math.inf active_time = self.rawCycleTime if active_time == 0: return None forced_inactive_time = self.reactivationDelay reload_time = self.reloadTime # Effects which cannot be reloaded have the same processing whether # caller wants to take reload time into account or not if reload_time is None and cycles_until_reload < math.inf: final_cycles = 1 early_cycles = cycles_until_reload - final_cycles # Single cycle until effect cannot run anymore if early_cycles == 0: return CycleInfo(active_time, 0, 1, False) # Multiple cycles with the same parameters if forced_inactive_time == 0: return CycleInfo(active_time, 0, cycles_until_reload, False) # Multiple cycles with different parameters return CycleSequence(( CycleInfo(active_time, forced_inactive_time, early_cycles, False), CycleInfo(active_time, 0, final_cycles, False) ), 1) # Module cycles the same way all the time in 3 cases: # 1) caller doesn't want to take into account reload time # 2) effect does not have to reload anything to keep running # 3) effect has enough time to reload during inactivity periods if ( not factorReload or cycles_until_reload == math.inf or forced_inactive_time >= reload_time ): isInactivityReload = factorReload and forced_inactive_time >= reload_time return CycleInfo(active_time, forced_inactive_time, math.inf, isInactivityReload) # We've got to take reload into consideration else: final_cycles = 1 early_cycles = cycles_until_reload - final_cycles # If effect has to reload after each its cycle, then its parameters # are the same all the time if early_cycles == 0: return CycleInfo(active_time, reload_time, math.inf, True) return CycleSequence(( CycleInfo(active_time, forced_inactive_time, early_cycles, False), CycleInfo(active_time, reload_time, final_cycles, True) ), math.inf)
def getCycleParametersPerEffect(self, reloadOverride=None): factorReload = reloadOverride if reloadOverride is not None else self.owner.factorReload # Assume it can cycle infinitely if not factorReload: return { a.effectID: CycleInfo(a.cycleTime, 0, math.inf) for a in self.abilities if a.cycleTime > 0 } limitedAbilities = [ a for a in self.abilities if a.numShots > 0 and a.cycleTime > 0 ] if len(limitedAbilities) == 0: return { a.effectID: CycleInfo(a.cycleTime, 0, math.inf) for a in self.abilities if a.cycleTime > 0 } validAbilities = [a for a in self.abilities if a.cycleTime > 0] if len(validAbilities) == 0: return {} mostLimitedAbility = min(limitedAbilities, key=lambda a: a.cycleTime * a.numShots) durationToRefuel = mostLimitedAbility.cycleTime * mostLimitedAbility.numShots # find out how many shots various abilities will do until reload, and how much time # "extra" cycle will last (None for no extra cycle) cyclesUntilRefuel = { mostLimitedAbility.effectID: (mostLimitedAbility.numShots, None) } for ability in (a for a in validAbilities if a is not mostLimitedAbility): fullCycles = int(floatUnerr(durationToRefuel / ability.cycleTime)) extraShotTime = floatUnerr(durationToRefuel - (fullCycles * ability.cycleTime)) if extraShotTime == 0: extraShotTime = None cyclesUntilRefuel[ability.effectID] = (fullCycles, extraShotTime) refuelTimes = {} for ability in validAbilities: spentShots, extraShotTime = cyclesUntilRefuel[ability.effectID] if extraShotTime is not None: spentShots += 1 refuelTimes[ability.effectID] = ability.getReloadTime(spentShots) refuelTime = max(refuelTimes.values()) cycleParams = {} for ability in validAbilities: regularShots, extraShotTime = cyclesUntilRefuel[ability.effectID] sequence = [] if extraShotTime is not None: if regularShots > 0: sequence.append( CycleInfo(ability.cycleTime, 0, regularShots)) sequence.append(CycleInfo(extraShotTime, refuelTime, 1)) else: regularShotsNonReload = regularShots - 1 if regularShotsNonReload > 0: sequence.append( CycleInfo(ability.cycleTime, 0, regularShotsNonReload)) sequence.append(CycleInfo(ability.cycleTime, refuelTime, 1)) cycleParams[ability.effectID] = CycleSequence(sequence, math.inf) return cycleParams
def getCycleParameters(self, reloadOverride=None): cycleTime = self.cycleTime if cycleTime == 0: return None return CycleInfo(self.cycleTime, 0, math.inf)
def getCycleParametersPerEffectInfinite(self): return {a.effectID: CycleInfo(a.cycleTime, 0, math.inf) for a in self.abilities if a.numShots == 0 and a.cycleTime > 0}