def readRecoilEffect(xmlCtx, section, cache): """Reads configuration of gun recoil effect. :param xmlCtx: tuple(root ctx or None, path to section). :param section: instance of DataSection. :param cache: instance of vehicles.Cache to get desired LoD distance by name. :return: instance of RecoilEffect. """ effName = _xml.readStringOrNone(xmlCtx, section, 'recoil/recoilEffect') if effName is not None: recoilEff = cache.getGunRecoilEffects(effName) if recoilEff is not None: backoffTime = recoilEff[0] returnTime = recoilEff[1] else: backoffTime = component_constants.ZERO_FLOAT returnTime = component_constants.ZERO_FLOAT else: backoffTime = _xml.readNonNegativeFloat(xmlCtx, section, 'recoil/backoffTime') returnTime = _xml.readNonNegativeFloat(xmlCtx, section, 'recoil/returnTime') return gun_components.RecoilEffect( lodDist=shared_readers.readLodDist(xmlCtx, section, 'recoil/lodDist', cache), amplitude=_xml.readNonNegativeFloat(xmlCtx, section, 'recoil/amplitude'), backoffTime=backoffTime, returnTime=returnTime)
def readDeviceHealthParams(xmlCtx, section, subsectionName='', withHysteresis=True): if subsectionName: section = _xml.getSubsection(xmlCtx, section, subsectionName) xmlCtx = (xmlCtx, subsectionName) component = shared_components.DeviceHealth( _xml.readInt(xmlCtx, section, 'maxHealth', 1), _xml.readNonNegativeFloat(xmlCtx, section, 'repairCost'), _xml.readInt(xmlCtx, section, 'maxRegenHealth', 0)) if component.maxRegenHealth > component.maxHealth: _xml.raiseWrongSection(xmlCtx, 'maxRegenHealth') if not IS_CLIENT and not IS_BOT: component.healthRegenPerSec = _xml.readNonNegativeFloat( xmlCtx, section, 'healthRegenPerSec') component.healthBurnPerSec = _xml.readNonNegativeFloat( xmlCtx, section, 'healthBurnPerSec') if section.has_key('chanceToHit'): component.chanceToHit = _xml.readFraction(xmlCtx, section, 'chanceToHit') else: component.chanceToHit = None if withHysteresis: hysteresisHealth = _xml.readInt(xmlCtx, section, 'hysteresisHealth', 0) if hysteresisHealth > component.maxRegenHealth: _xml.raiseWrongSection(xmlCtx, 'hysteresisHealth') component.hysteresisHealth = hysteresisHealth return component
def _readConfig(self, xmlCtx, section): self.delay = _xml.readPositiveFloat(xmlCtx, section, 'delay') self.modelName = _xml.readString(xmlCtx, section, 'modelName') if IS_CLIENT: self.soundEvent = _xml.readString(xmlCtx, section, 'wwsoundEvent') self.speed = _xml.readInt(xmlCtx, section, 'speed') self.heights = _xml.readTupleOfPositiveInts(xmlCtx, section, 'heights', 2) self.areaLength = _xml.readPositiveFloat(xmlCtx, section, 'areaLength') self.areaWidth = _xml.readPositiveFloat(xmlCtx, section, 'areaWidth') self.antepositions = _xml.readTupleOfFloats(xmlCtx, section, 'antepositions') self.lateropositions = _xml.readTupleOfFloats(xmlCtx, section, 'lateropositions') self.bombingMask = tuple((bool(v) for v in _xml.readTupleOfInts(xmlCtx, section, 'bombingMask'))) if not len(self.antepositions) == len(self.lateropositions) == len(self.bombingMask): _xml.raiseWrongSection(xmlCtx, 'bombers number mismatch') self.waveFraction = _xml.readPositiveFloat(xmlCtx, section, 'waveFraction') self.bombsNumber = _xml.readNonNegativeInt(xmlCtx, section, 'bombsNumber') self.shellCompactDescr = _xml.readInt(xmlCtx, section, 'shellCompactDescr') self.tracerKind = _xml.readInt(xmlCtx, section, 'tracerKind') self.piercingPower = _xml.readTupleOfPositiveInts(xmlCtx, section, 'piercingPower', 2) self.gravity = _xml.readPositiveFloat(xmlCtx, section, 'gravity') self.areaVisual = _xml.readStringOrNone(xmlCtx, section, 'areaVisual') self.areaColor = _xml.readIntOrNone(xmlCtx, section, 'areaColor') self.areaMarker = _xml.readStringOrNone(xmlCtx, section, 'areaMarker') self.reusable = _xml.readBool(xmlCtx, section, 'reusable') self.cooldownTime = _xml.readNonNegativeFloat(xmlCtx, section, 'cooldownTime') if self.reusable else 0.0 self.deployTime = _xml.readNonNegativeFloat(xmlCtx, section, 'deployTime')
def _readConfig(self, xmlCtx, section): self.delay = _xml.readPositiveFloat(xmlCtx, section, 'delay') self.modelName = _xml.readString(xmlCtx, section, 'modelName') self.soundEvent = _xml.readString(xmlCtx, section, 'soundEvent') self.speed = _xml.readInt(xmlCtx, section, 'speed') self.heights = _xml.readTupleOfPositiveInts(xmlCtx, section, 'heights', 2) self.areaLength = _xml.readPositiveFloat(xmlCtx, section, 'areaLength') self.areaWidth = _xml.readPositiveFloat(xmlCtx, section, 'areaWidth') self.antepositions = _xml.readTupleOfFloats(xmlCtx, section, 'antepositions') self.lateropositions = _xml.readTupleOfFloats(xmlCtx, section, 'lateropositions') self.bombingMask = tuple((bool(v) for v in _xml.readTupleOfInts(xmlCtx, section, 'bombingMask'))) if not len(self.antepositions) == len(self.lateropositions) == len(self.bombingMask): _xml.raiseWrongSection(xmlCtx, 'bombers number mismatch') self.waveFraction = _xml.readPositiveFloat(xmlCtx, section, 'waveFraction') self.bombsNumber = _xml.readNonNegativeInt(xmlCtx, section, 'bombsNumber') self.shellCompactDescr = _xml.readInt(xmlCtx, section, 'shellCompactDescr') self.tracerKind = _xml.readInt(xmlCtx, section, 'tracerKind') self.piercingPower = _xml.readTupleOfPositiveInts(xmlCtx, section, 'piercingPower', 2) self.gravity = _xml.readPositiveFloat(xmlCtx, section, 'gravity') self.areaVisual = _xml.readStringOrNone(xmlCtx, section, 'areaVisual') self.areaColor = _xml.readIntOrNone(xmlCtx, section, 'areaColor') self.areaMarker = _xml.readStringOrNone(xmlCtx, section, 'areaMarker') self.reusable = _xml.readBool(xmlCtx, section, 'reusable') self.cooldownTime = _xml.readNonNegativeFloat(xmlCtx, section, 'cooldownTime') if self.reusable else 0.0 self.deployTime = _xml.readNonNegativeFloat(xmlCtx, section, 'deployTime')
def readRecoilEffect(xmlCtx, section, cache): effName = _xml.readStringOrNone(xmlCtx, section, 'recoil/recoilEffect') if effName is not None: recoilEff = cache.getGunRecoilEffects(effName) if recoilEff is not None: backoffTime = recoilEff[0] returnTime = recoilEff[1] else: backoffTime = component_constants.ZERO_FLOAT returnTime = component_constants.ZERO_FLOAT else: backoffTime = _xml.readNonNegativeFloat(xmlCtx, section, 'recoil/backoffTime') returnTime = _xml.readNonNegativeFloat(xmlCtx, section, 'recoil/returnTime') recoil = gun_components.RecoilEffect( lodDist=shared_readers.readLodDist(xmlCtx, section, 'recoil/lodDist', cache), amplitude=_xml.readNonNegativeFloat(xmlCtx, section, 'recoil/amplitude'), backoffTime=backoffTime, returnTime=returnTime) if IS_EDITOR: recoil.effectName = effName return recoil
def readDeviceHealthParams(xmlCtx, section, subsectionName = '', withHysteresis = True): """Reads health parameter for each device. :param xmlCtx: tuple(root ctx or None, path to section). :param section: instance of DataSection. :param subsectionName: string containing name of desired section or empty string if desired section is already exist. :param withHysteresis: if value equals True than read section 'hysteresisHealth', otherwise - do nothing. :return: instance of DeviceHealth. """ if subsectionName: section = _xml.getSubsection(xmlCtx, section, subsectionName) xmlCtx = (xmlCtx, subsectionName) component = shared_components.DeviceHealth(_xml.readInt(xmlCtx, section, 'maxHealth', 1), _xml.readNonNegativeFloat(xmlCtx, section, 'repairCost'), _xml.readInt(xmlCtx, section, 'maxRegenHealth', 0)) if component.maxRegenHealth > component.maxHealth: _xml.raiseWrongSection(xmlCtx, 'maxRegenHealth') if not IS_CLIENT and not IS_BOT: component.healthRegenPerSec = _xml.readNonNegativeFloat(xmlCtx, section, 'healthRegenPerSec') component.healthBurnPerSec = _xml.readNonNegativeFloat(xmlCtx, section, 'healthBurnPerSec') if section.has_key('chanceToHit'): component.chanceToHit = _xml.readFraction(xmlCtx, section, 'chanceToHit') else: component.chanceToHit = None if withHysteresis: hysteresisHealth = _xml.readInt(xmlCtx, section, 'hysteresisHealth', 0) if hysteresisHealth > component.maxRegenHealth: _xml.raiseWrongSection(xmlCtx, 'hysteresisHealth') component.hysteresisHealth = hysteresisHealth return component
def readConfig(): section = ResMgr.openSection(_CONFIG_FILE) if section is None: _xml.raiseWrongXml(None, _CONFIG_FILE, 'can not open or read') xmlCtx = (None, _CONFIG_FILE) c = {} c['baseStunDuration'] = _xml.readNonNegativeFloat(xmlCtx, section, 'baseStunDuration') c['guaranteedStunDuration'] = _xml.readFraction(xmlCtx, section, 'guaranteedStunDuration') c['damageDurationCoeff'] = _xml.readFraction(xmlCtx, section, 'damageDurationCoeff') c['guaranteedStunEffect'] = _xml.readFraction(xmlCtx, section, 'guaranteedStunEffect') c['damageEffectCoeff'] = _xml.readFraction(xmlCtx, section, 'damageEffectCoeff') c['minStunDuration'] = _xml.readNonNegativeFloat(xmlCtx, section, 'minStunDuration') c['shellEffectFactor'] = _xml.readFraction(xmlCtx, section, 'shellEffectFactor') c['stunFactorEnginePower'] = _xml.readFraction(xmlCtx, section, 'stunFactorEnginePower') c['stunFactorVehicleRotationSpeed'] = _xml.readFraction(xmlCtx, section, 'stunFactorVehicleRotationSpeed') c['stunFactorTurretTraverse'] = _xml.readFraction(xmlCtx, section, 'stunFactorTurretTraverse') c['stunFactorViewDistance'] = _xml.readFraction(xmlCtx, section, 'stunFactorViewDistance') c['stunFactorMaxSpeed'] = _xml.readFraction(xmlCtx, section, 'stunFactorMaxSpeed') c['stunFactorReloadTime'] = _xml.readPositiveFloat(xmlCtx, section, 'stunFactorReloadTime', 1.0) _validateValue1inf('stunFactorReloadTime', c['stunFactorReloadTime']) c['stunFactorAimingTime'] = _xml.readPositiveFloat(xmlCtx, section, 'stunFactorAimingTime', 1.0) _validateValue1inf('stunFactorAimingTime', c['stunFactorAimingTime']) c['stunFactorVehicleMovementShotDispersion'] = _xml.readPositiveFloat(xmlCtx, section, 'stunFactorVehicleMovementShotDispersion', 1.0) _validateValue1inf('stunFactorVehicleMovementShotDispersion', c['stunFactorVehicleMovementShotDispersion']) c['stunFactorVehicleRotationShotDispersion'] = _xml.readPositiveFloat(xmlCtx, section, 'stunFactorVehicleRotationShotDispersion', 1.0) _validateValue1inf('stunFactorVehicleRotationShotDispersion', c['stunFactorVehicleRotationShotDispersion']) c['stunFactorTurretRotationShotDispersion'] = _xml.readPositiveFloat(xmlCtx, section, 'stunFactorTurretRotationShotDispersion', 1.0) _validateValue1inf('stunFactorTurretRotationShotDispersion', c['stunFactorTurretRotationShotDispersion']) c['stunFactorMinShotDispersion'] = _xml.readPositiveFloat(xmlCtx, section, 'stunFactorMinShotDispersion', 1.0) _validateValue1inf('stunFactorMinShotDispersion', c['stunFactorMinShotDispersion']) return c
def _readWeight(xmlCtx, section): fraction = 0.0 if section.has_key('vehicleWeightFraction'): fraction = _xml.readNonNegativeFloat(xmlCtx, section, 'vehicleWeightFraction') weight = 0.0 if section.has_key('weight'): weight = _xml.readNonNegativeFloat(xmlCtx, section, 'weight') return (fraction, weight)
def _readCommanderEnemyShotPredictorSkill(xmlCtx, section, subsectionName): skill, xmlCtx, section = _readSkillBasics(xmlCtx, section, subsectionName) return skills_components.CommanderEnemyShotPredictor( skill, _xml.readNonNegativeFloat(xmlCtx, section, 'minExplosionRadius'), _xml.readNonNegativeFloat(xmlCtx, section, 'explosionMultiplier'), _xml.readNonNegativeFloat(xmlCtx, section, 'recalculatingHeight'), _xml.readNonNegativeFloat(xmlCtx, section, 'targetRadius'))
def _readWeight(self, xmlCtx, section): if section.has_key('vehicleWeightFraction'): self._vehWeightFraction = _xml.readNonNegativeFloat(xmlCtx, section, 'vehicleWeightFraction') else: self._vehWeightFraction = 0.0 if section.has_key('weight'): self._weight = _xml.readNonNegativeFloat(xmlCtx, section, 'weight') else: self._weight = 0.0 self._maxWeightChange = 0.0
def _readConfig(self, xmlCtx, section): self.delay = _xml.readPositiveFloat(xmlCtx, section, 'delay') self.duration = _xml.readPositiveFloat(xmlCtx, section, 'duration') self.shotsNumber = _xml.readNonNegativeInt(xmlCtx, section, 'shotsNumber') self.areaRadius = _xml.readPositiveFloat(xmlCtx, section, 'areaRadius') self.shellCompactDescr = _xml.readInt(xmlCtx, section, 'shellCompactDescr') self.piercingPower = _xml.readTupleOfPositiveInts(xmlCtx, section, 'piercingPower', 2) self.areaVisual = _xml.readStringOrNone(xmlCtx, section, 'areaVisual') self.areaColor = _xml.readIntOrNone(xmlCtx, section, 'areaColor') self.areaMarker = _xml.readStringOrNone(xmlCtx, section, 'areaMarker') self.areaLength = self.areaWidth = self.areaRadius * 2 self.reusable = _xml.readBool(xmlCtx, section, 'reusable') self.cooldownTime = _xml.readNonNegativeFloat(xmlCtx, section, 'cooldownTime') if self.reusable else 0.0 self.deployTime = _xml.readNonNegativeFloat(xmlCtx, section, 'deployTime')
def _readTankmenGroup(xmlCtx, subsection, firstNames, lastNames, icons): """Reads section containing data of tankmen group and stores it to NationGroup. :param xmlCtx: tuple(root ctx or None, path to section). :param subsection: instance of DataSection. :param firstNames: dict(ID of first name: string or None) :param lastNames: dict(ID of last name: string or None) :param icons: dict(ID of icon: string or None) :return: instance of NationGroup. """ if IS_CLIENT or IS_WEB: parseName = _parseName parseIcon = _parseIcon else: parseName = parseIcon = None return tankmen_components.NationGroup( subsection.asString, 'female' == _xml.readNonEmptyString(xmlCtx, subsection, 'sex'), subsection.readBool('notInShop', False), _readIDs((xmlCtx, 'firstNames'), _xml.getChildren(xmlCtx, subsection, 'firstNames'), firstNames, parseName), _readIDs((xmlCtx, 'lastNames'), _xml.getChildren(xmlCtx, subsection, 'lastNames'), lastNames, parseName), _readIDs((xmlCtx, 'icons'), _xml.getChildren(xmlCtx, subsection, 'icons'), icons, parseIcon), _xml.readNonNegativeFloat(xmlCtx, subsection, 'weight'), _readGroupTags((xmlCtx, 'tags'), subsection, 'tags'), _readGroupRoles((xmlCtx, 'roles'), subsection, 'roles'))
def readShot(xmlCtx, section, nationID, projectileSpeedFactor, cache): """Reads section 'gun/shots/<shell_name>'. :param xmlCtx: tuple(root ctx or None, path to section). :param section: instance of DataSection. :param nationID: integer containing ID of nation. :param projectileSpeedFactor: float containing factor that is applied to projectile speeds and gravities at reading from configs. :param cache: instance of vehicles.Cache to get desired shell by name. :return: instance of GunShot. """ shellName = section.name shellID = cache.shellIDs(nationID).get(shellName) if shellID is None: _xml.raiseWrongXml(xmlCtx, '', 'unknown shell type name') shellDescr = cache.shells(nationID)[shellID] return gun_components.GunShot( shellDescr, 0.0 if not section.has_key('defaultPortion') else _xml.readFraction( xmlCtx, section, 'defaultPortion'), _xml.readVector2(xmlCtx, section, 'piercingPower'), _xml.readPositiveFloat(xmlCtx, section, 'speed') * projectileSpeedFactor, _xml.readNonNegativeFloat(xmlCtx, section, 'gravity') * projectileSpeedFactor**2, _xml.readPositiveFloat(xmlCtx, section, 'maxDistance'), section.readFloat('maxHeight', 1000000.0))
def readSwingingSettings(xmlCtx, section, cache): return shared_components.SwingingSettings( readLodDist(xmlCtx, section, 'swinging/lodDist', cache), _xml.readNonNegativeFloat(xmlCtx, section, 'swinging/sensitivityToImpulse'), _xml.readTupleOfFloats(xmlCtx, section, 'swinging/pitchParams', 6), _xml.readTupleOfFloats(xmlCtx, section, 'swinging/rollParams', 7))
def _readNationConfigSection(xmlCtx, section): res = {} firstNames = {} lastNames = {} icons = {} for kindName in ('normalGroups', 'premiumGroups'): groups = [] res[kindName] = groups totalWeight = 0.0 for sname, subsection in _xml.getChildren(xmlCtx, section, kindName): ctx = (xmlCtx, kindName + '/' + sname) group = { 'notInShop': subsection.readBool('notInShop', False), 'isFemales': 'female' == _xml.readNonEmptyString(ctx, subsection, 'sex'), 'firstNames': _readIDs((ctx, 'firstNames'), _xml.getChildren(ctx, subsection, 'firstNames'), firstNames, _parseName), 'lastNames': _readIDs((ctx, 'lastNames'), _xml.getChildren(ctx, subsection, 'lastNames'), lastNames, _parseName), 'icons': _readIDs((ctx, 'icons'), _xml.getChildren(ctx, subsection, 'icons'), icons, _parseIcon) } group['firstNamesList'] = list(group['firstNames']) group['lastNamesList'] = list(group['lastNames']) group['iconsList'] = list(group['icons']) weight = _xml.readNonNegativeFloat(ctx, subsection, 'weight') totalWeight += weight group['weight'] = weight groups.append(group) totalWeight = max(0.001, totalWeight) for group in groups: group['weight'] /= totalWeight ranks, rankIDsByNames = _readRanks( (xmlCtx, 'ranks'), _xml.getChildren(xmlCtx, section, 'ranks')) res['roleRanks'] = _readRoleRanks( (xmlCtx, 'roleRanks'), _xml.getSubsection(xmlCtx, section, 'roleRanks'), rankIDsByNames) if IS_CLIENT or IS_WEB: res['firstNames'] = firstNames res['lastNames'] = lastNames res['icons'] = icons res['ranks'] = ranks else: res['firstNames'] = frozenset(firstNames) res['lastNames'] = frozenset(lastNames) res['icons'] = frozenset(icons) return res
def _readRepairSpeedLimiter(xmlCtx, section): if not section.has_key('repairSpeedLimiter'): return None else: ctx, subsection = _xml.getSubSectionWithContext( xmlCtx, section, 'repairSpeedLimiter') repairSpeedModifier = _xml.readNonNegativeFloat( ctx, subsection, 'repairSpeedModifier') return { 'repairSpeedModifier': repairSpeedModifier, 'speedToStartLimitedRepair': component_constants.KMH_TO_MS * _xml.readNonNegativeFloat( ctx, subsection, 'speedToStartLimitedRepair'), 'speedToStopLimitedRepair': component_constants.KMH_TO_MS * _xml.readNonNegativeFloat( ctx, subsection, 'speedToStopLimitedRepair'), 'repairMode': DeviceRepairMode.SLOWED if repairSpeedModifier > 0.0 else DeviceRepairMode.SUSPENDED }
def readSwingingSettings(xmlCtx, section, cache): """Reads section 'swinging' for each hull. :param xmlCtx: tuple(root ctx or None, path to section). :param section: instance of DataSection. :param cache: instance of vehicles.Cache. :return: instance of SwingingSettings. """ return shared_components.SwingingSettings( readLodDist(xmlCtx, section, 'swinging/lodDist', cache), _xml.readNonNegativeFloat(xmlCtx, section, 'swinging/sensitivityToImpulse'), _xml.readTupleOfFloats(xmlCtx, section, 'swinging/pitchParams', 6), _xml.readTupleOfFloats(xmlCtx, section, 'swinging/rollParams', 7))
def _readNationConfigSection(xmlCtx, section): res = {} firstNames = {} lastNames = {} icons = {} for kindName in ("normalGroups", "premiumGroups"): groups = [] res[kindName] = groups totalWeight = 0.0 for sname, subsection in _xml.getChildren(xmlCtx, section, kindName): ctx = (xmlCtx, kindName + "/" + sname) group = { "notInShop": subsection.readBool("notInShop", False), "isFemales": "female" == _xml.readNonEmptyString(ctx, subsection, "sex"), "firstNames": _readIDs( (ctx, "firstNames"), _xml.getChildren(ctx, subsection, "firstNames"), firstNames, _parseName ), "lastNames": _readIDs( (ctx, "lastNames"), _xml.getChildren(ctx, subsection, "lastNames"), lastNames, _parseName ), "icons": _readIDs((ctx, "icons"), _xml.getChildren(ctx, subsection, "icons"), icons, _parseIcon), } group["firstNamesList"] = list(group["firstNames"]) group["lastNamesList"] = list(group["lastNames"]) group["iconsList"] = list(group["icons"]) weight = _xml.readNonNegativeFloat(ctx, subsection, "weight") totalWeight += weight group["weight"] = weight groups.append(group) totalWeight = max(0.001, totalWeight) for group in groups: group["weight"] /= totalWeight ranks, rankIDsByNames = _readRanks((xmlCtx, "ranks"), _xml.getChildren(xmlCtx, section, "ranks")) res["roleRanks"] = _readRoleRanks( (xmlCtx, "roleRanks"), _xml.getSubsection(xmlCtx, section, "roleRanks"), rankIDsByNames ) if IS_CLIENT or IS_WEB: res["firstNames"] = firstNames res["lastNames"] = lastNames res["icons"] = icons res["ranks"] = ranks else: res["firstNames"] = frozenset(firstNames) res["lastNames"] = frozenset(lastNames) res["icons"] = frozenset(icons) return res
def readShot(xmlCtx, section, nationID, projectileSpeedFactor, cache): shellName = section.name shellID = cache.shellIDs(nationID).get(shellName) if shellID is None: _xml.raiseWrongXml(xmlCtx, '', 'unknown shell type name') shellDescr = cache.shells(nationID)[shellID] return gun_components.GunShot( shellDescr, ZERO_FLOAT if not section.has_key('defaultPortion') else _xml.readFraction(xmlCtx, section, 'defaultPortion'), _xml.readVector2(xmlCtx, section, 'piercingPower'), _xml.readPositiveFloat(xmlCtx, section, 'speed') * projectileSpeedFactor, _xml.readNonNegativeFloat(xmlCtx, section, 'gravity') * projectileSpeedFactor**2, _xml.readPositiveFloat(xmlCtx, section, 'maxDistance'), _xml.readFloat(xmlCtx, section, 'maxHeight', 1000000.0))
def _readNationConfigSection(xmlCtx, section): res = {} firstNames = {} lastNames = {} icons = {} for kindName in ('normalGroups', 'premiumGroups'): groups = [] res[kindName] = groups totalWeight = 0.0 for sname, subsection in _xml.getChildren(xmlCtx, section, kindName): ctx = (xmlCtx, kindName + '/' + sname) group = {'notInShop': subsection.readBool('notInShop', False), 'isFemales': 'female' == _xml.readNonEmptyString(ctx, subsection, 'sex'), 'firstNames': _readIDs((ctx, 'firstNames'), _xml.getChildren(ctx, subsection, 'firstNames'), firstNames, _parseName), 'lastNames': _readIDs((ctx, 'lastNames'), _xml.getChildren(ctx, subsection, 'lastNames'), lastNames, _parseName), 'icons': _readIDs((ctx, 'icons'), _xml.getChildren(ctx, subsection, 'icons'), icons, _parseIcon)} group['firstNamesList'] = list(group['firstNames']) group['lastNamesList'] = list(group['lastNames']) group['iconsList'] = list(group['icons']) weight = _xml.readNonNegativeFloat(ctx, subsection, 'weight') totalWeight += weight group['weight'] = weight groups.append(group) totalWeight = max(0.001, totalWeight) for group in groups: group['weight'] /= totalWeight ranks, rankIDsByNames = _readRanks((xmlCtx, 'ranks'), _xml.getChildren(xmlCtx, section, 'ranks')) res['roleRanks'] = _readRoleRanks((xmlCtx, 'roleRanks'), _xml.getSubsection(xmlCtx, section, 'roleRanks'), rankIDsByNames) if IS_CLIENT or IS_WEB: res['firstNames'] = firstNames res['lastNames'] = lastNames res['icons'] = icons res['ranks'] = ranks else: res['firstNames'] = frozenset(firstNames) res['lastNames'] = frozenset(lastNames) res['icons'] = frozenset(icons) return res
def _readTankmenGroup(xmlCtx, groupName, subsection, firstNames, lastNames, icons): if IS_CLIENT or IS_WEB: parseName = _parseName parseIcon = _parseIcon else: parseName = parseIcon = None return tankmen_components.NationGroup( groupName, 'female' == _xml.readNonEmptyString(xmlCtx, subsection, 'sex'), subsection.readBool('notInShop', False), _readIDs((xmlCtx, 'firstNames'), _xml.getChildren(xmlCtx, subsection, 'firstNames'), firstNames, parseName), _readIDs((xmlCtx, 'lastNames'), _xml.getChildren(xmlCtx, subsection, 'lastNames'), lastNames, parseName), _readIDs((xmlCtx, 'icons'), _xml.getChildren(xmlCtx, subsection, 'icons'), icons, parseIcon), _xml.readNonNegativeFloat(xmlCtx, subsection, 'weight'), _readGroupTags((xmlCtx, 'tags'), subsection, 'tags'), _readGroupRoles((xmlCtx, 'roles'), subsection, 'roles'))
def _readConfig(self, xmlCtx, section): self.activateWhenStillSec = _xml.readNonNegativeFloat( xmlCtx, section, 'activateWhenStillSec') self.circularVisionRadiusFactor = _xml.readPositiveFloat( xmlCtx, section, 'circularVisionRadiusFactor')
def _readConfig(self, xmlCtx, section): self.activateWhenStillSec = _xml.readNonNegativeFloat( xmlCtx, section, 'activateWhenStillSec')
def _readLoaderPedantSkill(xmlCtx, section, subsectionName): skill, xmlCtx, section = _readSkillBasics(xmlCtx, section, subsectionName) return skills_components.LoaderPedantSkill(skill, _xml.readNonNegativeFloat(xmlCtx, section, 'ammoBayHealthFactor'))
def _readSkillNonNegFloat(paramName, xmlCtx, section, subsectionName): res, xmlCtx, section = _readSkillBasics(xmlCtx, section, subsectionName) res[paramName] = _xml.readNonNegativeFloat(xmlCtx, section, paramName) return res
def _readDriverRammingMasterSkill(xmlCtx, section, subsectionName): skill, xmlCtx, section = _readSkillBasics(xmlCtx, section, subsectionName) return skills_components.DriverRammingMasterSkill(skill, _xml.readNonNegativeFloat(xmlCtx, section, 'rammingBonusFactorPerLevel'))
def _readGunnerSmoothTurretSkill(xmlCtx, section, subsectionName): skill, xmlCtx, section = _readSkillBasics(xmlCtx, section, subsectionName) return skills_components.GunnerSmoothTurretSkill(skill, _xml.readNonNegativeFloat(xmlCtx, section, 'shotDispersionFactorPerLevel'))
def _readDriverTidyPersonSkill(xmlCtx, section, subsectionName): skill, xmlCtx, section = _readSkillBasics(xmlCtx, section, subsectionName) return skills_components.DriverTidyPersonSkill(skill, _xml.readNonNegativeFloat(xmlCtx, section, 'fireStartingChanceFactor'))
def _readDriverVirtuosoSkill(xmlCtx, section, subsectionName): skill, xmlCtx, section = _readSkillBasics(xmlCtx, section, subsectionName) return skills_components.DriverVirtuosoSkill(skill, _xml.readNonNegativeFloat(xmlCtx, section, 'rotationSpeedFactorPerLevel'))
def _readCommanderTutorSkill(xmlCtx, section, subsectionName): skill, xmlCtx, section = _readSkillBasics(xmlCtx, section, subsectionName) return skills_components.CommanderTutorSkill(skill, _xml.readNonNegativeFloat(xmlCtx, section, 'xpBonusFactorPerLevel'))
def _readCommanderSkillWithDelaySkill(xmlCtx, section, subsectionName): skill, xmlCtx, section = _readSkillBasics(xmlCtx, section, subsectionName) return skills_components.CommanderSkillWithDelay(skill, _xml.readNonNegativeFloat(xmlCtx, section, 'delay'))
def _readRadiomanRetransmitterSkill(xmlCtx, section, subsectionName): skill, xmlCtx, section = _readSkillBasics(xmlCtx, section, subsectionName) return skills_components.RadiomanRetransmitterSkill(skill, _xml.readNonNegativeFloat(xmlCtx, section, 'distanceFactorPerLevel'))
def _readRadiomanFinderSkill(xmlCtx, section, subsectionName): skill, xmlCtx, section = _readSkillBasics(xmlCtx, section, subsectionName) return skills_components.RadiomanFinderSkill(skill, _xml.readNonNegativeFloat(xmlCtx, section, 'visionRadiusFactorPerLevel'))
def _readConfig(self, xmlCtx, section): self.activateWhenStillSec = _xml.readNonNegativeFloat(xmlCtx, section, 'activateWhenStillSec') self.circularVisionRadiusFactor = _xml.readPositiveFloat(xmlCtx, section, 'circularVisionRadiusFactor')
def _readConfig(self, xmlCtx, section): self.activateWhenStillSec = _xml.readNonNegativeFloat(xmlCtx, section, 'activateWhenStillSec')