示例#1
0
 def __inLimit(self, prevYaw, newYaw, newPitch):
     if self.__yawLimits is not None:
         prevYaw = mathUtils.clamp(self.__yawLimits[0], self.__yawLimits[1],
                                   prevYaw)
         newYaw = mathUtils.clamp(self.__yawLimits[0], self.__yawLimits[1],
                                  newYaw)
     prevPitchLimits = calcPitchLimitsFromDesc(prevYaw, self.__pitchLimits)
     pitchLimits = calcPitchLimitsFromDesc(newYaw, self.__pitchLimits)
     if SniperAimingSystem.__FILTER_ENABLED:
         pitchLimitsMin = pitchLimits[0] + self.__pitchDeviation[0]
         pitchLimitsMax = pitchLimits[1] + self.__pitchDeviation[1]
         prevLimMin = prevPitchLimits[0] + self.__pitchDeviation[0]
         prevLimMax = prevPitchLimits[1] + self.__pitchDeviation[1]
     else:
         pitchLimitsMin = pitchLimits[0]
         pitchLimitsMax = pitchLimits[1]
         prevLimMin = prevPitchLimits[0]
         prevLimMax = prevPitchLimits[1]
     prevLimitedPitch = mathUtils.clamp(prevLimMin, prevLimMax, newPitch)
     limitedPitch = mathUtils.clamp(pitchLimitsMin, pitchLimitsMax,
                                    newPitch)
     dp = limitedPitch - prevLimitedPitch
     return (newYaw, limitedPitch,
             pitchLimitsMin <= newPitch <= pitchLimitsMax, pitchLimitsMin,
             dp)
示例#2
0
 def __rotate(self, shotPoint, timeDiff):
     self.__turretRotationSpeed = 0.0
     if shotPoint is None or self.__isLocked:
         self.__dispersionAngle = self.__avatar.getOwnVehicleShotDispersionAngle(0.0)
         return
     avatar = self.__avatar
     descr = avatar.vehicleTypeDescriptor
     turretYawLimits = descr.gun['turretYawLimits']
     maxTurretRotationSpeed = self.__maxTurretRotationSpeed
     prevTurretYaw = self.__turretYaw
     shotTurretYaw, shotGunPitch = getShotAngles(descr, avatar.getOwnVehicleMatrix(), (prevTurretYaw, self.__gunPitch), shotPoint)
     self.__turretYaw = turretYaw = self.__getNextTurretYaw(prevTurretYaw, shotTurretYaw, maxTurretRotationSpeed * timeDiff, turretYawLimits)
     if maxTurretRotationSpeed != 0:
         self.estimatedTurretRotationTime = abs(turretYaw - shotTurretYaw) / maxTurretRotationSpeed
     else:
         self.estimatedTurretRotationTime = 0
     gunPitchLimits = calcPitchLimitsFromDesc(turretYaw, descr.gun['pitchLimits'])
     self.__gunPitch = self.__getNextGunPitch(self.__gunPitch, shotGunPitch, timeDiff, gunPitchLimits)
     replayCtrl = BattleReplay.g_replayCtrl
     if replayCtrl.isPlaying and replayCtrl.isUpdateGunOnTimeWarp:
         self.__updateTurretMatrix(turretYaw, 0.001)
         self.__updateGunMatrix(self.__gunPitch, 0.001)
     else:
         self.__updateTurretMatrix(turretYaw, self.__ROTATION_TICK_LENGTH)
         self.__updateGunMatrix(self.__gunPitch, self.__ROTATION_TICK_LENGTH)
     diff = abs(turretYaw - prevTurretYaw)
     if diff > pi:
         diff = 2 * pi - diff
     self.__turretRotationSpeed = diff / timeDiff
     self.__dispersionAngle = avatar.getOwnVehicleShotDispersionAngle(self.__turretRotationSpeed)
示例#3
0
def _getRanges(turret, gun, nation, vclass):
    visionRadius = firingRadius = artyRadius = 0
    gunsInfoPath = _VEHICLE_TYPE_XML_PATH + nation + '/components/guns.xml/shared/'

    # Turret-dependent
    visionRadius = int(turret['circularVisionRadius'])  # 240..420

    # Gun-dependent
    shots = gun['shots']
    for shot in shots:
        radius = int(shot['maxDistance'])
        if firingRadius < radius:
            firingRadius = radius  # 10000, 720, 395, 360, 350

        if vclass == 'SPG' and shot['shell']['kind'] == 'HIGH_EXPLOSIVE':
            try:    # faster way
                pitchLimit_rad = min(CONST_45_IN_RADIANS, -calcPitchLimitsFromDesc(0, gun['pitchLimits']))
            except Exception: # old way
                gunsInfoPath = _VEHICLE_TYPE_XML_PATH + nation + '/components/guns.xml/shared/'
                pitchLimit = ResMgr.openSection(gunsInfoPath + gun['name']).readInt('pitchLimits')
                pitchLimit = min(45, -pitchLimit)  # -35..-65
                pitchLimit_rad = radians(pitchLimit)

            radius = int(pow(shot['speed'], 2) * sin(2 * pitchLimit_rad) / shot['gravity'])
            if artyRadius < radius:
                artyRadius = radius  # 485..1469

    return (visionRadius, firingRadius, artyRadius)
示例#4
0
def _getRanges(turret, gun, nation, vclass):
    visionRadius = firingRadius = artyRadius = 0
    gunsInfoPath = _VEHICLE_TYPE_XML_PATH + nation + '/components/guns.xml/shared/'

    # Turret-dependent
    visionRadius = int(turret['circularVisionRadius'])  # 240..420

    # Gun-dependent
    shots = gun['shots']
    for shot in shots:
        radius = int(shot['maxDistance'])
        if firingRadius < radius:
            firingRadius = radius  # 10000, 720, 395, 360, 350

        if vclass == 'SPG' and shot['shell']['kind'] == 'HIGH_EXPLOSIVE':
            try:  # faster way
                pitchLimit_rad = min(
                    CONST_45_IN_RADIANS,
                    -calcPitchLimitsFromDesc(0, gun['pitchLimits']))
            except Exception:  # old way
                gunsInfoPath = _VEHICLE_TYPE_XML_PATH + nation + '/components/guns.xml/shared/'
                pitchLimit = ResMgr.openSection(
                    gunsInfoPath + gun['name']).readInt('pitchLimits')
                pitchLimit = min(45, -pitchLimit)  # -35..-65
                pitchLimit_rad = radians(pitchLimit)

            radius = int(
                pow(shot['speed'], 2) * sin(2 * pitchLimit_rad) /
                shot['gravity'])
            if artyRadius < radius:
                artyRadius = radius  # 485..1469

    return (visionRadius, firingRadius, artyRadius)
def _getRanges(turret, gun, nation, vclass):
    visionRadius = firingRadius = artyRadius = 0
    gunsInfoPath = _VEHICLE_TYPE_XML_PATH + nation + '/components/guns.xml/shared/'

    # Turret-dependent
    visionRadius = int(turret.circularVisionRadius)  # 240..420

    # Gun-dependent
    shots = gun.shots
    for shot in shots:
        radius = int(shot.maxDistance)
        if firingRadius < radius:
            firingRadius = radius  # 10000, 720, 395, 360, 350

        if vclass == 'SPG' and shot.shell.kind == 'HIGH_EXPLOSIVE':
            try:    # faster way
                pitchLimit_rad = min(CONST_45_IN_RADIANS, -calcPitchLimitsFromDesc(0, gun.pitchLimits)[0])
            except Exception: # old way
                minPitch = radians(-45)
                for _gun in turret.guns:
                    if _gun.name == gun.name:
                        minPitch = _gun.pitchLimits['minPitch'][0][1]
                        break
                pitchLimit_rad = min(CONST_45_IN_RADIANS, -minPitch)  # -35..-65
            radius = int(pow(shot.speed, 2) * sin(2 * pitchLimit_rad) / shot.gravity)
            if artyRadius < radius:
                artyRadius = radius  # 485..1469

    return (visionRadius, firingRadius, artyRadius)
 def __rotate(self, shotPoint, timeDiff):
     self.__turretRotationSpeed = 0.0
     if shotPoint is None or self.__isLocked:
         self.__dispersionAngles = self.__avatar.getOwnVehicleShotDispersionAngle(0.0)
         return
     else:
         avatar = self.__avatar
         descr = avatar.vehicleTypeDescriptor
         turretYawLimits = descr.gun['turretYawLimits']
         maxTurretRotationSpeed = self.__maxTurretRotationSpeed
         prevTurretYaw = self.__turretYaw
         shotTurretYaw, shotGunPitch = getShotAngles(descr, avatar.getOwnVehicleStabilisedMatrix(), (prevTurretYaw, self.__gunPitch), shotPoint)
         self.__turretYaw = turretYaw = self.__getNextTurretYaw(prevTurretYaw, shotTurretYaw, maxTurretRotationSpeed * timeDiff, turretYawLimits)
         if maxTurretRotationSpeed != 0:
             self.estimatedTurretRotationTime = abs(turretYaw - shotTurretYaw) / maxTurretRotationSpeed
         else:
             self.estimatedTurretRotationTime = 0
         gunPitchLimits = calcPitchLimitsFromDesc(turretYaw, descr.gun['pitchLimits'])
         self.__gunPitch = self.__getNextGunPitch(self.__gunPitch, shotGunPitch, timeDiff, gunPitchLimits)
         replayCtrl = BattleReplay.g_replayCtrl
         if replayCtrl.isPlaying and replayCtrl.isUpdateGunOnTimeWarp:
             self.__updateTurretMatrix(turretYaw, 0.001)
             self.__updateGunMatrix(self.__gunPitch, 0.001)
         else:
             self.__updateTurretMatrix(turretYaw, self.__ROTATION_TICK_LENGTH)
             self.__updateGunMatrix(self.__gunPitch, self.__ROTATION_TICK_LENGTH)
         diff = abs(turretYaw - prevTurretYaw)
         if diff > pi:
             diff = 2 * pi - diff
         self.__turretRotationSpeed = diff / timeDiff
         self.__dispersionAngles = avatar.getOwnVehicleShotDispersionAngle(self.__turretRotationSpeed)
         return
 def __rotate(self, shotPoint, timeDiff):
     self.__turretRotationSpeed = 0.0
     if shotPoint is None or self.__isLocked:
         self.__dispersionAngle = self.__avatar.getOwnVehicleShotDispersionAngle(0.0)
         return
     else:
         avatar = self.__avatar
         descr = avatar.vehicleTypeDescriptor
         turretYawLimits = descr.gun["turretYawLimits"]
         maxTurretRotationSpeed = self.__maxTurretRotationSpeed
         prevTurretYaw = self.__turretYaw
         shotTurretYaw, shotGunPitch = getShotAngles(
             descr, avatar.getOwnVehicleMatrix(), (prevTurretYaw, self.__gunPitch), shotPoint
         )
         self.__turretYaw = turretYaw = self.__getNextTurretYaw(
             prevTurretYaw, shotTurretYaw, maxTurretRotationSpeed * timeDiff, turretYawLimits
         )
         if maxTurretRotationSpeed != 0:
             self.estimatedTurretRotationTime = abs(turretYaw - shotTurretYaw) / maxTurretRotationSpeed
         else:
             self.estimatedTurretRotationTime = 0
         gunPitchLimits = calcPitchLimitsFromDesc(turretYaw, descr.gun["pitchLimits"])
         self.__gunPitch = self.__getNextGunPitch(
             self.__gunPitch, shotGunPitch, self.__maxGunRotationSpeed * timeDiff, gunPitchLimits
         )
         self.__updateTurretMatrix(turretYaw, self.__ROTATION_TICK_LENGTH)
         self.__updateGunMatrix(self.__gunPitch, self.__ROTATION_TICK_LENGTH)
         diff = abs(turretYaw - prevTurretYaw)
         if diff > pi:
             diff = 2 * pi - diff
         self.__turretRotationSpeed = diff / timeDiff
         self.__dispersionAngle = avatar.getOwnVehicleShotDispersionAngle(self.__turretRotationSpeed)
         return
示例#8
0
def _getRanges(turret, gun, nation, vclass):
    visionRadius = firingRadius = artyRadius = 0
    gunsInfoPath = _VEHICLE_TYPE_XML_PATH + nation + '/components/guns.xml/shared/'

    # Turret-dependent
    visionRadius = int(turret.circularVisionRadius)  # 240..420

    # Gun-dependent
    shots = gun.shots
    for shot in shots:
        radius = int(shot.maxDistance)
        if firingRadius < radius:
            firingRadius = radius  # 10000, 720, 395, 360, 350

        if vclass == 'SPG' and shot.shell.kind == 'HIGH_EXPLOSIVE':
            try:    # faster way
                pitchLimit_rad = min(CONST_45_IN_RADIANS, -calcPitchLimitsFromDesc(0, gun.pitchLimits)[0])
            except Exception: # old way
                minPitch = radians(-45)
                for _gun in turret.guns:
                    if _gun.name == gun.name:
                        minPitch = _gun.pitchLimits['minPitch'][0][1]
                        break
                pitchLimit_rad = min(CONST_45_IN_RADIANS, -minPitch)  # -35..-65
            radius = int(pow(shot.speed, 2) * sin(2 * pitchLimit_rad) / shot.gravity)
            if artyRadius < radius:
                artyRadius = radius  # 485..1469

    return (visionRadius, firingRadius, artyRadius)
示例#9
0
 def __rotate(self, dx, dy):
     cfg = self.__cfg
     angles = self.__angles
     angles[0] += dx * self.__curSense * (-1 if cfg['horzInvert'] else 1)
     angles[1] += dy * self.__curSense * (-1 if cfg['vertInvert'] else 1)
     if self.__yawLimits is not None:
         angles[0] = _clamp(self.__yawLimits[0], self.__yawLimits[1],
                            angles[0])
     desc = BigWorld.player().vehicleTypeDescriptor
     self.__pitchLimits = calcPitchLimitsFromDesc(angles[0],
                                                  desc.gun['pitchLimits'])
     chassisMatInv = Math.Matrix(self.__chassisMat)
     chassisMatInv.invert()
     turretJointMat = Math.Matrix(self.__turretJointMat)
     turretJointMat.postMultiply(chassisMatInv)
     pitchDelta = abs(turretJointMat.pitch)
     dTime = min(2.0, BigWorld.time() - self.__pitchCompensationTimestamp)
     self.__pitchCompensation = (
         dTime * pitchDelta +
         (2.0 - dTime) * self.__pitchCompensation) * 0.5
     self.__pitchCompensationTimestamp = BigWorld.time()
     pitchLimitsMin = self.__pitchLimits[0] - self.__pitchCompensation
     pitchLimitsMax = self.__pitchLimits[1] + self.__pitchCompensation
     angles[1] = _clamp(pitchLimitsMin, pitchLimitsMax, angles[1])
     return
 def __calcPitchExcess(self, turretYaw, gunPitch):
     if self.__yawLimits is not None:
         turretYaw = math_utils.clamp(self.__yawLimits[0], self.__yawLimits[1], turretYaw)
     pitchLimits = calcPitchLimitsFromDesc(turretYaw, self.getPitchLimits(turretYaw))
     if pitchLimits[0] > gunPitch:
         return pitchLimits[0] - gunPitch
     else:
         return self.__pitchCompensating + pitchLimits[1] - gunPitch if self.__pitchCompensating + pitchLimits[1] < gunPitch else 0.0
 def __clampToLimits(self, turretYaw, gunPitch):
     if self.__yawLimits is not None:
         turretYaw = math_utils.clamp(self.__yawLimits[0], self.__yawLimits[1], turretYaw)
     pitchLimits = calcPitchLimitsFromDesc(turretYaw, self.getPitchLimits(turretYaw))
     adjustment = max(0, self.__returningOscillator.deviation.y)
     pitchLimits[0] -= adjustment
     pitchLimits[1] += adjustment
     gunPitch = math_utils.clamp(pitchLimits[0], pitchLimits[1] + self.__pitchCompensating, gunPitch)
     return (turretYaw, gunPitch)
 def __clampToLimits(self, turretYaw, gunPitch):
     if self.__yawLimits is not None:
         turretYaw = mathUtils.clamp(self.__yawLimits[0], self.__yawLimits[1], turretYaw)
     desc = BigWorld.player().vehicleTypeDescriptor
     pitchLimits = calcPitchLimitsFromDesc(turretYaw, desc.gun['pitchLimits'])
     pitchLimitsMin = pitchLimits[0]
     pitchLimitsMax = pitchLimits[1]
     gunPitch = mathUtils.clamp(pitchLimitsMin, pitchLimitsMax, gunPitch)
     return (turretYaw, gunPitch)
示例#13
0
 def __testMouseTargetPoint(self, start, dir):
     closestPoint, isPointConvenient = self.__calculateClosestPoint(start, dir)
     turretYaw, gunPitch = AimingSystems.getTurretYawGunPitch(self.__vehicleDesc, self.__vehicleMat, closestPoint, True)
     if not isPointConvenient:
         minPitch, maxPitch = gun_rotation_shared.calcPitchLimitsFromDesc(turretYaw, self.__vehicleDesc.gun['pitchLimits'])
         pitchInBorders = gunPitch <= maxPitch + 0.001
         isPointConvenient = not pitchInBorders
     if isPointConvenient:
         isPointConvenient = not self.__isTurretTurnRequired(dir, turretYaw, closestPoint)
     return (closestPoint, isPointConvenient)
示例#14
0
def clampToLimits(base, self, turretYaw, gunPitch):
    if config.get('battle/camera/enabled') and config.get('battle/camera/sniper/noCameraLimit/enabled'):
        if not BigWorld.isKeyDown(KEY_RIGHTMOUSE) and self._SniperAimingSystem__yawLimits is not None and config.get('battle/camera/sniper/noCameraLimit/mode') == "hotkey":
            turretYaw = math_utils.clamp(self._SniperAimingSystem__yawLimits[0], self._SniperAimingSystem__yawLimits[1], turretYaw)
        pitchLimits = calcPitchLimitsFromDesc(turretYaw, self.getPitchLimits(turretYaw))
        adjustment = max(0, self._SniperAimingSystem__returningOscillator.deviation.y)
        pitchLimits[0] -= adjustment
        pitchLimits[1] += adjustment
        gunPitch = math_utils.clamp(pitchLimits[0], pitchLimits[1] + self._SniperAimingSystem__pitchCompensating, gunPitch)
        return (turretYaw, gunPitch)
    return base(self, turretYaw, gunPitch)
示例#15
0
 def __clampToLimits(self, turretYaw, gunPitch):
     if self.__yawLimits is not None:
         turretYaw = mathUtils.clamp(self.__yawLimits[0],
                                     self.__yawLimits[1], turretYaw)
     desc = BigWorld.player().vehicleTypeDescriptor
     pitchLimits = calcPitchLimitsFromDesc(turretYaw,
                                           desc.gun['pitchLimits'])
     pitchLimitsMin = pitchLimits[0]
     pitchLimitsMax = pitchLimits[1]
     gunPitch = mathUtils.clamp(pitchLimitsMin, pitchLimitsMax, gunPitch)
     return (turretYaw, gunPitch)
 def __rotate(self, shotPoint, timeDiff):
     self.__turretRotationSpeed = 0.0
     targetPoint = shotPoint if shotPoint is not None else self.__prevSentShotPoint
     if targetPoint is None or self.__isLocked:
         self.__dispersionAngles = self._avatar.getOwnVehicleShotDispersionAngle(
             0.0)
         return
     else:
         avatar = self._avatar
         descr = avatar.getVehicleDescriptor()
         turretYawLimits = self.__getTurretYawLimits()
         maxTurretRotationSpeed = self.__maxTurretRotationSpeed
         prevTurretYaw = self.__turretYaw
         replayCtrl = BattleReplay.g_replayCtrl
         vehicleMatrix = self.getAvatarOwnVehicleStabilisedMatrix()
         shotTurretYaw, shotGunPitch = getShotAngles(
             descr,
             vehicleMatrix, (prevTurretYaw, self.__gunPitch),
             targetPoint,
             overrideGunPosition=self.__gunPosition)
         estimatedTurretYaw = self.getNextTurretYaw(
             prevTurretYaw, shotTurretYaw,
             maxTurretRotationSpeed * timeDiff, turretYawLimits)
         if replayCtrl.isRecording:
             self.__turretYaw = turretYaw = self.__syncWithServerTurretYaw(
                 estimatedTurretYaw)
         else:
             self.__turretYaw = turretYaw = estimatedTurretYaw
         if maxTurretRotationSpeed != 0:
             self.estimatedTurretRotationTime = abs(
                 turretYaw - shotTurretYaw) / maxTurretRotationSpeed
         else:
             self.estimatedTurretRotationTime = 0
         gunPitchLimits = calcPitchLimitsFromDesc(
             turretYaw, self.__getGunPitchLimits())
         self.__gunPitch = self.getNextGunPitch(self.__gunPitch,
                                                shotGunPitch, timeDiff,
                                                gunPitchLimits)
         if replayCtrl.isPlaying and replayCtrl.isUpdateGunOnTimeWarp:
             self.__updateTurretMatrix(turretYaw, 0.001)
             self.__updateGunMatrix(self.__gunPitch, 0.001)
         else:
             self.__updateTurretMatrix(turretYaw,
                                       self.__ROTATION_TICK_LENGTH)
             self.__updateGunMatrix(self.__gunPitch,
                                    self.__ROTATION_TICK_LENGTH)
         diff = abs(estimatedTurretYaw - prevTurretYaw)
         if diff > pi:
             diff = 2 * pi - diff
         self.__turretRotationSpeed = diff / timeDiff
         self.__dispersionAngles = avatar.getOwnVehicleShotDispersionAngle(
             self.__turretRotationSpeed)
         return
 def __clampToLimits(self, turretYaw, gunPitch):
     if self.__yawLimits is not None:
         turretYaw = mathUtils.clamp(self.__yawLimits[0], self.__yawLimits[1], turretYaw)
     pitchLimits = calcPitchLimitsFromDesc(turretYaw, self.__pitchLimits)
     if SniperAimingSystem.__FILTER_ENABLED:
         pitchLimitsMin = min(pitchLimits[0] + self.__pitchDeviation[0], _MAX_DEVIATION)
         pitchLimitsMax = max(pitchLimits[1] + self.__pitchDeviation[1], -_MAX_DEVIATION)
     else:
         pitchLimitsMin = pitchLimits[0]
         pitchLimitsMax = pitchLimits[1]
     gunPitch = mathUtils.clamp(pitchLimitsMin, pitchLimitsMax + self.__pitchCompensating, gunPitch)
     return (turretYaw, gunPitch)
示例#18
0
 def __clampToLimits(self, turretYaw, gunPitch):
     if self.__yawLimits is not None:
         turretYaw = mathUtils.clamp(self.__yawLimits[0], self.__yawLimits[1], turretYaw)
     pitchLimits = calcPitchLimitsFromDesc(turretYaw, self.__pitchLimits)
     if SniperAimingSystem.__FILTER_ENABLED:
         pitchLimitsMin = min(pitchLimits[0] + self.__pitchDeviation[0], _MAX_DEVIATION)
         pitchLimitsMax = max(pitchLimits[1] + self.__pitchDeviation[1], -_MAX_DEVIATION)
     else:
         pitchLimitsMin = pitchLimits[0]
         pitchLimitsMax = pitchLimits[1]
     gunPitch = mathUtils.clamp(pitchLimitsMin, pitchLimitsMax + self.__pitchCompensating, gunPitch)
     return (turretYaw, gunPitch)
示例#19
0
 def __setupCamera(self, targetPos):
     player = BigWorld.player()
     desc = player.vehicleTypeDescriptor
     angles = self.__angles
     self.__yawLimits = desc.gun['turretYawLimits']
     angles[0], angles[1] = getShotAngles(desc,
                                          player.getOwnVehicleMatrix(),
                                          (0, 0), targetPos, False)
     self.__pitchLimits = calcPitchLimitsFromDesc(angles[0],
                                                  desc.gun['pitchLimits'])
     gunOffs = desc.turret['gunPosition']
     self.__gunOffsetMat = Math.Matrix()
     self.__gunOffsetMat.setTranslate(gunOffs)
     calc = True
     if self._USE_SWINGING:
         vehicle = BigWorld.entity(player.playerVehicleID)
         if vehicle is not None and vehicle.isStarted:
             self.__turretJointMat = vehicle.appearance.modelsDesc['hull'][
                 'model'].node('HP_turretJoint')
             self.__chassisMat = vehicle.matrix
             calc = False
     if calc:
         turretOffs = desc.chassis['hullPosition'] + desc.hull[
             'turretPositions'][0]
         turretOffsetMat = Math.Matrix()
         turretOffsetMat.setTranslate(turretOffs)
         self.__turretJointMat = Math.MatrixProduct()
         self.__turretJointMat.a = turretOffsetMat
         self.__turretJointMat.b = player.getOwnVehicleMatrix()
         self.__chassisMat = player.getOwnVehicleMatrix()
     invGunJointMat = Math.Matrix()
     invGunJointMat.set(self.__gunOffsetMat)
     invGunJointMat.postMultiply(self.__turretJointMat)
     invGunJointMat.invert()
     invTurretJointMat = Math.Matrix(self.__turretJointMat)
     invTurretJointMat.invert()
     gunYawRotateMat = Math.Matrix()
     gunYawRotateMat.setRotateY(angles[0])
     camPosMat = Math.Matrix()
     camPosMat.set(self.__gunOffsetMat)
     camPosMat.postMultiply(gunYawRotateMat)
     camPosMat.postMultiply(self.__turretJointMat)
     camDir = targetPos - camPosMat.applyToOrigin()
     angles[0] = invTurretJointMat.applyVector(camDir).yaw
     angles[1] = invGunJointMat.applyVector(camDir).pitch
     camMat = Math.Matrix()
     if self._USE_ALIGN_TO_VEHICLE:
         up = camPosMat.applyToAxis(1)
     else:
         up = Math.Vector3(0, 1, 0)
     camMat.lookAt(camPosMat.applyToOrigin(), camDir, up)
     self.__cam.set(camMat)
     return
示例#20
0
def clampToLimits(base, self, turretYaw, gunPitch):
    if config.get('battle/camera/enabled') and config.get('battle/camera/sniper/noCameraLimit/enabled'):
        if not BigWorld.isKeyDown(KEY_RIGHTMOUSE) and self._SniperAimingSystem__yawLimits is not None and config.get('battle/camera/sniper/noCameraLimit/mode') == "hotkey":
            turretYaw = mathUtils.clamp(self._SniperAimingSystem__yawLimits[0], self._SniperAimingSystem__yawLimits[1], turretYaw)
        getPitchLimits = avatar_getter.getVehicleTypeDescriptor().gun.combinedPitchLimits
        pitchLimits = calcPitchLimitsFromDesc(turretYaw, getPitchLimits)
        adjustment = max(0, self._SniperAimingSystem__returningOscillator.deviation.y)
        pitchLimits[0] -= adjustment
        pitchLimits[1] += adjustment
        gunPitch = mathUtils.clamp(pitchLimits[0], pitchLimits[1] + self._SniperAimingSystem__pitchCompensating, gunPitch)
        return (turretYaw, gunPitch)
    return base(self, turretYaw, gunPitch)
示例#21
0
 def __clampToLimits(self, turretYaw, gunPitch, withDeviation = False):
     if self.__yawLimits is not None:
         turretYaw = mathUtils.clamp(self.__yawLimits[0], self.__yawLimits[1], turretYaw)
     pitchLimits = calcPitchLimitsFromDesc(turretYaw, self.__pitchLimits)
     if withDeviation:
         pitchLimitsMin = min(pitchLimits[0] + self.__pitchDeviation[0], _MAX_DEVIATION)
         pitchLimitsMax = max(pitchLimits[1] + self.__pitchDeviation[1], -_MAX_DEVIATION)
     else:
         pitchLimitsMin = pitchLimits[0]
         pitchLimitsMax = pitchLimits[1]
     gunPitch = mathUtils.clamp(pitchLimitsMin, pitchLimitsMax, gunPitch)
     return (turretYaw, gunPitch)
示例#22
0
 def __inLimit(self, yaw, pitch, withDeviation = False):
     if self.__yawLimits is not None:
         yaw = mathUtils.clamp(self.__yawLimits[0], self.__yawLimits[1], yaw)
     pitchLimits = calcPitchLimitsFromDesc(yaw, self.__pitchLimits)
     if withDeviation:
         pitchLimitsMin = pitchLimits[0] + self.__pitchDeviation[0]
         pitchLimitsMax = pitchLimits[1] + self.__pitchDeviation[1]
     else:
         pitchLimitsMin = pitchLimits[0]
         pitchLimitsMax = pitchLimits[1]
     limitedPitch = mathUtils.clamp(pitchLimitsMin, pitchLimitsMax, pitch)
     return (pitchLimitsMin <= pitch <= pitchLimitsMax, limitedPitch)
示例#23
0
 def __inLimit(self, yaw, pitch, withDeviation=False):
     if self.__yawLimits is not None:
         yaw = mathUtils.clamp(self.__yawLimits[0], self.__yawLimits[1],
                               yaw)
     pitchLimits = calcPitchLimitsFromDesc(yaw, self.__pitchLimits)
     if withDeviation:
         pitchLimitsMin = pitchLimits[0] + self.__pitchDeviation[0]
         pitchLimitsMax = pitchLimits[1] + self.__pitchDeviation[1]
     else:
         pitchLimitsMin = pitchLimits[0]
         pitchLimitsMax = pitchLimits[1]
     limitedPitch = mathUtils.clamp(pitchLimitsMin, pitchLimitsMax, pitch)
     return (pitchLimitsMin <= pitch <= pitchLimitsMax, limitedPitch)
示例#24
0
 def __testMouseTargetPoint(self, start, direction):
     currentFrameStamp = BigWorld.wg_getFrameTimestamp()
     if self.__cachedResult.frameStamp == currentFrameStamp and self.__cachedResult.scanStart == start and self.__cachedResult.scanDir == direction:
         return (self.__cachedResult.result, self.__cachedResult.isConvenient)
     closestPoint, isPointConvenient = self.__calculateClosestPoint(start, direction)
     turretYaw, gunPitch = AimingSystems.getTurretYawGunPitch(self.__vehicleDesc, self.__vehicleMat, closestPoint, True)
     if not isPointConvenient:
         _, maxPitch = gun_rotation_shared.calcPitchLimitsFromDesc(turretYaw, self.__vehicleDesc.gun.pitchLimits)
         pitchInBorders = gunPitch <= maxPitch + 0.001
         isPointConvenient = not pitchInBorders
     if isPointConvenient:
         isPointConvenient = not self.__isTurretTurnRequired(direction, turretYaw, closestPoint)
     self.__cachedResult.update(currentFrameStamp, start, direction, closestPoint, isPointConvenient)
     return (closestPoint, isPointConvenient)
 def __inLimit(self, prevYaw, newYaw, newPitch):
     if self.__yawLimits is not None:
         prevYaw = mathUtils.clamp(self.__yawLimits[0], self.__yawLimits[1], prevYaw)
         newYaw = mathUtils.clamp(self.__yawLimits[0], self.__yawLimits[1], newYaw)
     prevPitchLimits = calcPitchLimitsFromDesc(prevYaw, self.__pitchLimits)
     pitchLimits = calcPitchLimitsFromDesc(newYaw, self.__pitchLimits)
     if SniperAimingSystem.__FILTER_ENABLED:
         pitchLimitsMin = pitchLimits[0] + self.__pitchDeviation[0]
         pitchLimitsMax = pitchLimits[1] + self.__pitchDeviation[1]
         prevLimMin = prevPitchLimits[0] + self.__pitchDeviation[0]
         prevLimMax = prevPitchLimits[1] + self.__pitchDeviation[1]
     else:
         pitchLimitsMin = pitchLimits[0]
         pitchLimitsMax = pitchLimits[1]
         prevLimMin = prevPitchLimits[0]
         prevLimMax = prevPitchLimits[1]
     prevLimitedPitch = mathUtils.clamp(prevLimMin, prevLimMax, newPitch)
     limitedPitch = mathUtils.clamp(pitchLimitsMin, pitchLimitsMax, newPitch)
     dp = limitedPitch - prevLimitedPitch
     return (newYaw,
      limitedPitch,
      pitchLimitsMin <= newPitch <= pitchLimitsMax,
      pitchLimitsMin,
      dp)
 def __calcPitchExcess(self, turretYaw, gunPitch):
     descr = self._vehicleTypeDescriptor
     if self.__yawLimits is not None:
         turretYaw = math_utils.clamp(self.__yawLimits[0],
                                      self.__yawLimits[1], turretYaw)
     pitchLimits = calcPitchLimitsFromDesc(turretYaw,
                                           self.getPitchLimits(turretYaw),
                                           descr.hull.turretPitches[0],
                                           descr.turret.gunJointPitch)
     if pitchLimits[0] > gunPitch:
         return pitchLimits[0] - gunPitch
     else:
         return self.__pitchCompensating + pitchLimits[
             1] - gunPitch if self.__pitchCompensating + pitchLimits[
                 1] < gunPitch else 0.0
示例#27
0
 def getShotParams(self, targetPoint, ignoreYawLimits = False):
     descr = self.__avatar.vehicleTypeDescriptor
     shotTurretYaw, shotGunPitch = getShotAngles(descr, self.__avatar.getOwnVehicleStabilisedMatrix(), (self.__turretYaw, self.__gunPitch), targetPoint)
     gunPitchLimits = calcPitchLimitsFromDesc(shotTurretYaw, descr.gun['pitchLimits'])
     closestLimit = self.__isOutOfLimits(shotGunPitch, gunPitchLimits)
     if closestLimit is not None:
         shotGunPitch = closestLimit
     turretYawLimits = descr.gun['turretYawLimits']
     if not ignoreYawLimits:
         closestLimit = self.__isOutOfLimits(shotTurretYaw, turretYawLimits)
         if closestLimit is not None:
             shotTurretYaw = closestLimit
     pos, vel = self.__getShotPosition(shotTurretYaw, shotGunPitch)
     grav = Math.Vector3(0.0, -descr.shot['gravity'], 0.0)
     return (pos, vel, grav)
示例#28
0
 def __clampToLimits(self, turretYaw, gunPitch, withDeviation=False):
     if self.__yawLimits is not None:
         turretYaw = mathUtils.clamp(self.__yawLimits[0],
                                     self.__yawLimits[1], turretYaw)
     pitchLimits = calcPitchLimitsFromDesc(turretYaw, self.__pitchLimits)
     if withDeviation:
         pitchLimitsMin = min(pitchLimits[0] + self.__pitchDeviation[0],
                              _MAX_DEVIATION)
         pitchLimitsMax = max(pitchLimits[1] + self.__pitchDeviation[1],
                              -_MAX_DEVIATION)
     else:
         pitchLimitsMin = pitchLimits[0]
         pitchLimitsMax = pitchLimits[1]
     gunPitch = mathUtils.clamp(pitchLimitsMin, pitchLimitsMax, gunPitch)
     return (turretYaw, gunPitch)
示例#29
0
 def getShotParams(self, targetPoint, ignoreYawLimits = False):
     descr = self.__avatar.vehicleTypeDescriptor
     shotTurretYaw, shotGunPitch = getShotAngles(descr, self.__avatar.getOwnVehicleMatrix(), (self.__turretYaw, self.__gunPitch), targetPoint)
     gunPitchLimits = calcPitchLimitsFromDesc(shotTurretYaw, descr.gun['pitchLimits'])
     closestLimit = self.__isOutOfLimits(shotGunPitch, gunPitchLimits)
     if closestLimit is not None:
         shotGunPitch = closestLimit
     turretYawLimits = descr.gun['turretYawLimits']
     if not ignoreYawLimits:
         closestLimit = self.__isOutOfLimits(shotTurretYaw, turretYawLimits)
         if closestLimit is not None:
             shotTurretYaw = closestLimit
     pos, vel = self.__getShotPosition(shotTurretYaw, shotGunPitch)
     grav = Math.Vector3(0.0, -descr.shot['gravity'], 0.0)
     return (pos, vel, grav)
示例#30
0
 def __setupCamera(self, targetPos):
     player = BigWorld.player()
     desc = player.vehicleTypeDescriptor
     angles = self.__angles
     self.__yawLimits = desc.gun['turretYawLimits']
     angles[0], angles[1] = getShotAngles(desc, player.getOwnVehicleMatrix(), (0, 0), targetPos, False)
     self.__pitchLimits = calcPitchLimitsFromDesc(angles[0], desc.gun['pitchLimits'])
     gunOffs = desc.turret['gunPosition']
     self.__gunOffsetMat = Math.Matrix()
     self.__gunOffsetMat.setTranslate(gunOffs)
     calc = True
     if self._USE_SWINGING:
         vehicle = BigWorld.entity(player.playerVehicleID)
         if vehicle is not None and vehicle.isStarted:
             self.__turretJointMat = vehicle.appearance.modelsDesc['hull']['model'].node('HP_turretJoint')
             self.__chassisMat = vehicle.matrix
             calc = False
     if calc:
         turretOffs = desc.chassis['hullPosition'] + desc.hull['turretPositions'][0]
         turretOffsetMat = Math.Matrix()
         turretOffsetMat.setTranslate(turretOffs)
         self.__turretJointMat = Math.MatrixProduct()
         self.__turretJointMat.a = turretOffsetMat
         self.__turretJointMat.b = player.getOwnVehicleMatrix()
         self.__chassisMat = player.getOwnVehicleMatrix()
     invGunJointMat = Math.Matrix()
     invGunJointMat.set(self.__gunOffsetMat)
     invGunJointMat.postMultiply(self.__turretJointMat)
     invGunJointMat.invert()
     invTurretJointMat = Math.Matrix(self.__turretJointMat)
     invTurretJointMat.invert()
     gunYawRotateMat = Math.Matrix()
     gunYawRotateMat.setRotateY(angles[0])
     camPosMat = Math.Matrix()
     camPosMat.set(self.__gunOffsetMat)
     camPosMat.postMultiply(gunYawRotateMat)
     camPosMat.postMultiply(self.__turretJointMat)
     camDir = targetPos - camPosMat.applyToOrigin()
     angles[0] = invTurretJointMat.applyVector(camDir).yaw
     angles[1] = invGunJointMat.applyVector(camDir).pitch
     camMat = Math.Matrix()
     if self._USE_ALIGN_TO_VEHICLE:
         up = camPosMat.applyToAxis(1)
     else:
         up = Math.Vector3(0, 1, 0)
     camMat.lookAt(camPosMat.applyToOrigin(), camDir, up)
     self.__cam.set(camMat)
     return
示例#31
0
 def getShotParams(self, targetPoint, ignoreYawLimits=False):
     descr = self.__avatar.getVehicleAttached().typeDescriptor
     shotTurretYaw, shotGunPitch = getShotAngles(
         descr, self.__avatar.getOwnVehicleStabilisedMatrix(),
         (self.__turretYaw, self.__gunPitch), targetPoint)
     gunPitchLimits = calcPitchLimitsFromDesc(shotTurretYaw,
                                              self.__getGunPitchLimits())
     closestLimit = self.__isOutOfLimits(shotGunPitch, gunPitchLimits)
     if closestLimit is not None:
         shotGunPitch = closestLimit
     turretYawLimits = self.__getTurretYawLimits()
     if not ignoreYawLimits:
         closestLimit = self.__isOutOfLimits(shotTurretYaw, turretYawLimits)
         if closestLimit is not None:
             shotTurretYaw = closestLimit
     pos, vel = self.__getShotPosition(shotTurretYaw, shotGunPitch)
     grav = Math.Vector3(0.0, -descr.shot.gravity, 0.0)
     return (pos, vel, grav)
示例#32
0
 def __rotate(self, dx, dy):
     cfg = self.__cfg
     angles = self.__angles
     angles[0] += dx * self.__curSense * (-1 if cfg['horzInvert'] else 1)
     angles[1] += dy * self.__curSense * (-1 if cfg['vertInvert'] else 1)
     if self.__yawLimits is not None:
         angles[0] = _clamp(self.__yawLimits[0], self.__yawLimits[1], angles[0])
     desc = BigWorld.player().vehicleTypeDescriptor
     self.__pitchLimits = calcPitchLimitsFromDesc(angles[0], desc.gun['pitchLimits'])
     chassisMatInv = Math.Matrix(self.__chassisMat)
     chassisMatInv.invert()
     turretJointMat = Math.Matrix(self.__turretJointMat)
     turretJointMat.postMultiply(chassisMatInv)
     pitchDelta = abs(turretJointMat.pitch)
     dTime = min(2.0, BigWorld.time() - self.__pitchCompensationTimestamp)
     self.__pitchCompensation = (dTime * pitchDelta + (2.0 - dTime) * self.__pitchCompensation) * 0.5
     self.__pitchCompensationTimestamp = BigWorld.time()
     pitchLimitsMin = self.__pitchLimits[0] - self.__pitchCompensation
     pitchLimitsMax = self.__pitchLimits[1] + self.__pitchCompensation
     angles[1] = _clamp(pitchLimitsMin, pitchLimitsMax, angles[1])
     return
 def __clampToLimits(self, turretYaw, gunPitch):
     if self.__yawLimits is not None and self.__wasAutoRotationEnabled and turretYaw > self.__yawLimits[
             0] and turretYaw < self.__yawLimits[1]:
         self.__idealTurretYaw, self.__idealGunPitch = self.__getOscillatorAdjustedYawPitch(
         )
         self.__forceFullStabilization = False
         self.__wasAutoRotationEnabled = False
     if self.__yawLimits is not None and not self.__autoRotationEnabled and not self.__wasAutoRotationEnabled:
         turretYaw = math_utils.clamp(self.__yawLimits[0],
                                      self.__yawLimits[1], turretYaw)
     descr = self._vehicleTypeDescriptor
     pitchLimits = calcPitchLimitsFromDesc(turretYaw,
                                           self.getPitchLimits(turretYaw),
                                           descr.hull.turretPitches[0],
                                           descr.turret.gunJointPitch)
     adjustment = max(0, self.__returningOscillator.deviation.y)
     pitchLimits[0] -= adjustment
     pitchLimits[1] += adjustment
     gunPitch = math_utils.clamp(pitchLimits[0],
                                 pitchLimits[1] + self.__pitchCompensating,
                                 gunPitch)
     return (turretYaw, gunPitch)
示例#34
0
 def __clampToLimits(self, turretYaw, gunPitch):
     if self.__yawLimits is not None:
         turretYaw = mathUtils.clamp(self.__yawLimits[0], self.__yawLimits[1], turretYaw)
     pitchLimits = calcPitchLimitsFromDesc(turretYaw, self.__pitchLimits)
     gunPitch = mathUtils.clamp(pitchLimits[0], pitchLimits[1] + self.__pitchCompensating, gunPitch)
     return (turretYaw, gunPitch)
示例#35
0
def CommonStatsBlockConstructor_construct(base, self):
    try:
        self.leftPadding = -15
        vehicle = self.vehicle
        cache_result = carousel_tooltips_cache.get(vehicle.intCD)
        if cache_result:
            return cache_result
        result = []
        if not config.get('tooltips/hideSimplifiedVehParams'):
            result.append(formatters.packTitleDescBlock(text_styles.middleTitle(i18n.makeString(TOOLTIPS.TANKCARUSEL_MAINPROPERTY)), padding=formatters.packPadding(left=0, right=self.rightPadding, bottom=8)))
        params = self.configuration.params
        veh_descr = vehicle.descriptor
        gun = vehicle.gun.descriptor
        turret = vehicle.turret.descriptor
        comparator = idealCrewComparator_helper(vehicle)
        vehicleCommonParams = getParameters_helper(vehicle)
        veh_type_inconfig = vehicle.type.replace('AT-SPG', 'TD')
        clipGunInfoShown = False
        premium_shells = {}

        for shell in vehicle.shells:
            premium_shells[shell.intCompactDescr] = shell.isPremium
        if params:
            values = config.get('tooltips/%s' % veh_type_inconfig)
            if values and len(values):
                params_list = values # overriding parameters
            else:
                params_list = self.PARAMS.get(vehicle.type, 'default') # original parameters
            paramInfo = None
            for paramName in params_list:
                if paramName is None:
                    continue
                if paramName == 'rateOfFire':
                    paramName = 'reloadTime'
                elif paramName == 'traverseLimits':
                    paramName = 'gunYawLimits' if 'gunYawLimits' in vehicleCommonParams else 'turretYawLimits'
                elif paramName == 'radioRange':
                    paramName = 'radioDistance'
                elif paramName == 'reloadTimeSecs' and vehicle.gun.isClipGun():
                    paramName = 'clipFireRate'
                elif paramName == 'turretRotationSpeed' and not vehicle.hasTurrets:
                    paramName = 'gunRotationSpeed'
                if paramName in vehicleCommonParams:
                    paramInfo = comparator.getExtendedData(paramName)
                if paramName == 'turretArmor' and not vehicle.hasTurrets:
                    continue
                #maxHealth
                elif paramName == 'maxHealth':
                    tooltip_add_param(self, result, i18n.makeString('#menu:vehicleInfo/params/maxHealth'), formatNumber(veh_descr.maxHealth))
                #battle tiers
                elif paramName == 'battleTiers':
                    (minTier, maxTier) = getTiers(vehicle.level, vehicle.type, vehicle.name)
                    tooltip_add_param(self, result, l10n('Battle tiers'), '%s..%s' % (minTier, maxTier))
                #explosionRadius
                elif paramName == 'explosionRadius':
                    explosionRadiusMin = 999
                    explosionRadiusMax = 0
                    for shot in gun['shots']:
                        if 'explosionRadius' in shot['shell']:
                            if shot['shell']['explosionRadius'] < explosionRadiusMin:
                                explosionRadiusMin = shot['shell']['explosionRadius']
                            if shot['shell']['explosionRadius'] > explosionRadiusMax:
                                explosionRadiusMax = shot['shell']['explosionRadius']
                    if explosionRadiusMax == 0: # no HE
                        continue
                    explosionRadius_str = formatNumber(explosionRadiusMin)
                    if explosionRadiusMin != explosionRadiusMax:
                        explosionRadius_str += '/%s' % gold_pad(formatNumber(explosionRadiusMax))
                    tooltip_add_param(self, result, getParameterValue(paramName), explosionRadius_str)
                #shellSpeedSummary
                elif paramName == 'shellSpeedSummary':
                    shellSpeedSummary_arr = []
                    for shot in gun['shots']:
                        shellSpeed_str = '%g' % round(shot['speed'] * 1.25)
                        if premium_shells[shot['shell']['compactDescr']]:
                            shellSpeed_str = gold_pad(shellSpeed_str)
                        shellSpeedSummary_arr.append(shellSpeed_str)
                    shellSpeedSummary_str = '/'.join(shellSpeedSummary_arr)
                    tooltip_add_param(self, result, tooltip_with_units(l10n('shellSpeed'), l10n('(m/sec)')), shellSpeedSummary_str)
                #piercingPowerAvg
                elif paramName == 'piercingPowerAvg':
                    piercingPowerAvg = formatNumber(veh_descr.shot['piercingPower'][0])
                    tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/avgPiercingPower')), piercingPowerAvg)
                #piercingPowerAvgSummary
                elif paramName == 'piercingPowerAvgSummary':
                    piercingPowerAvgSummary_arr = []
                    for shot in gun['shots']:
                        piercingPower_str = formatNumber(shot['piercingPower'][0])
                        if premium_shells[shot['shell']['compactDescr']]:
                            piercingPower_str = gold_pad(piercingPower_str)
                        piercingPowerAvgSummary_arr.append(piercingPower_str)
                    piercingPowerAvgSummary_str = '/'.join(piercingPowerAvgSummary_arr)
                    tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/avgPiercingPower')), piercingPowerAvgSummary_str)
                #damageAvgSummary
                elif paramName == 'damageAvgSummary':
                    damageAvgSummary_arr = []
                    for shot in gun['shots']:
                        damageAvg_str = formatNumber(shot['shell']['damage'][0])
                        if premium_shells[shot['shell']['compactDescr']]:
                            damageAvg_str = gold_pad(damageAvg_str)
                        damageAvgSummary_arr.append(damageAvg_str)
                    damageAvgSummary_str = '/'.join(damageAvgSummary_arr)
                    tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/avgDamage')), damageAvgSummary_str)
                #magazine loading
                # elif (paramName == 'reloadTimeSecs' or paramName == 'rateOfFire') and vehicle.gun.isClipGun():
                #     if clipGunInfoShown:
                #         continue
                #     (shellsCount, shellReloadingTime) = gun['clip']
                #     reloadMagazineTime = gun['reloadTime']
                #     shellReloadingTime_str = formatNumber(shellReloadingTime)
                #     reloadMagazineTime_str = formatNumber(reloadMagazineTime)
                #     tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/shellsCount')), shellsCount)
                #     tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/shellReloadingTime')), shellReloadingTime_str)
                #     tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/reloadMagazineTime')), reloadMagazineTime_str)
                #     clipGunInfoShown = True
                #rate of fire
                # elif paramName == 'rateOfFire' and not vehicle.gun.isClipGun():
                #     rateOfFire_str = formatNumber(60 / gun['reloadTime'])
                #     tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/reloadTime')), rateOfFire_str)
                # gun traverse limits
                # elif paramName == 'traverseLimits' and gun['turretYawLimits']:
                #     (traverseMin, traverseMax) = gun['turretYawLimits']
                #     traverseLimits_str = '%g..+%g' % (round(degrees(traverseMin)), round(degrees(traverseMax)))
                #     tooltip_add_param(self, result, l10n('traverseLimits'), traverseLimits_str)
                # elevation limits (front)
                # elif paramName == 'pitchLimits':
                #     (pitchMax, pitchMin) = calcPitchLimitsFromDesc(0, gun['pitchLimits'])
                #     pitchLimits_str = '%g..+%g' % (round(degrees(-pitchMin)), round(degrees(-pitchMax)))
                #     tooltip_add_param(self, result, l10n('pitchLimits'), pitchLimits_str)
                # elevation limits (side)
                elif paramName == 'pitchLimitsSide':
                    if gun['turretYawLimits'] and abs(degrees(gun['turretYawLimits'][0])) < 89: continue # can't look aside 90 degrees
                    (pitchMax, pitchMin) = calcPitchLimitsFromDesc(pi / 2, gun['pitchLimits'])
                    pitchLimits_str = '%g..+%g' % (round(degrees(-pitchMin)), round(degrees(-pitchMax)))
                    tooltip_add_param(self, result, l10n('pitchLimitsSide'), pitchLimits_str)
                # elevation limits (rear)
                elif paramName == 'pitchLimitsRear':
                    if gun['turretYawLimits']: continue # can't look back
                    (pitchMax, pitchMin) = calcPitchLimitsFromDesc(pi, gun['pitchLimits'])
                    pitchLimits_str = '%g..+%g' % (round(degrees(-pitchMin)), round(degrees(-pitchMax)))
                    tooltip_add_param(self, result, l10n('pitchLimitsRear'), pitchLimits_str)
                # shooting range
                elif paramName == 'shootingRadius':
                    viewRange, shellRadius, artiRadius = _getRanges(turret, gun, vehicle.nationName, vehicle.type)
                    if vehicle.type == 'SPG':
                        tooltip_add_param(self, result, tooltip_with_units(l10n('shootingRadius'), l10n('(m)')), artiRadius)
                    elif shellRadius < 707:
                        tooltip_add_param(self, result, tooltip_with_units(l10n('shootingRadius'), l10n('(m)')), shellRadius)
                #reverse max speed
                elif paramName == 'speedLimits':
                    (speedLimitForward, speedLimitReverse) = veh_descr.physics['speedLimits']
                    speedLimits_str = str(int(speedLimitForward * 3.6)) + '/' + str(int(speedLimitReverse * 3.6))
                    tooltip_add_param(self, result, getParameterValue(paramName), speedLimits_str)
                #turret rotation speed
                # elif paramName == 'turretRotationSpeed' or paramName == 'gunRotationSpeed':
                #     if not vehicle.hasTurrets:
                #         paramName = 'gunRotationSpeed'
                #     turretRotationSpeed_str = str(int(degrees(veh_descr.turret['rotationSpeed'])))
                #     tooltip_add_param(self, result, tooltip_with_units(i18n.makeString('#menu:tank_params/%s' % paramName).rstrip(), i18n.makeString('#menu:tank_params/gps')), turretRotationSpeed_str)
                #terrain resistance
                elif paramName == 'terrainResistance':
                    resistances_arr = []
                    for key in veh_descr.chassis['terrainResistance']:
                        resistances_arr.append(formatNumber(key))
                    terrainResistance_str = '/'.join(resistances_arr)
                    tooltip_add_param(self, result, l10n('terrainResistance'), terrainResistance_str)
                #radioRange
                # elif paramName == 'radioRange':
                #     radioRange_str = '%s' % int(vehicle.radio.descriptor['distance'])
                #     tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/radioDistance')), radioRange_str)
                #gravity
                elif paramName == 'gravity':
                    gravity_str = formatNumber(veh_descr.shot['gravity'])
                    tooltip_add_param(self, result, l10n('gravity'), gravity_str)
                #inner name, for example - ussr:R100_SU122A
                elif paramName == 'innerName':
                    tooltip_add_param(self, result, vehicle.name, '')
                #custom text
                elif paramName.startswith('TEXT:'):
                    customtext = paramName[5:]
                    tooltip_add_param(self, result, l10n(customtext), '')
                elif paramInfo is not None and paramName in paramInfo.name:
                    valueStr = str(param_formatter.formatParameter(paramName, paramInfo.value))
                    tooltip_add_param(self, result, getParameterValue(paramName), valueStr)
        if vehicle.isInInventory:
            # optional devices icons, must be in the end
            if 'optDevicesIcons' in params_list:
                optDevicesIcons_arr = []
                for key in vehicle.optDevices:
                    if key:
                        imgPath = 'img://gui' + key.icon.lstrip('.')
                    else:
                        imgPath = 'img://gui/maps/icons/artefact/empty.png'
                    optDevicesIcons_arr.append('<img src="%s" height="16" width="16">' % imgPath)
                optDevicesIcons_str = ' '.join(optDevicesIcons_arr)
                tooltip_add_param(self, result, optDevicesIcons_str, '')

            # equipment icons, must be in the end
            if 'equipmentIcons' in params_list:
                equipmentIcons_arr = []
                for key in vehicle.eqs:
                    if key:
                        imgPath = 'img://gui' + key.icon.lstrip('.')
                    else:
                        imgPath = 'img://gui/maps/icons/artefact/empty.png'
                    equipmentIcons_arr.append('<img src="%s" height="16" width="16">' % imgPath)
                equipmentIcons_str = ' '.join(equipmentIcons_arr)
                if config.get('tooltips/combineIcons') and optDevicesIcons_str:
                    tmp_list = []
                    tooltip_add_param(self, tmp_list, equipmentIcons_str, '')
                    result[-1]['data']['name'] += ' ' + tmp_list[0]['data']['name']
                else:
                    tooltip_add_param(self, result, equipmentIcons_str, '')

        # crew roles icons, must be in the end
        if 'crewRolesIcons' in params_list:
            imgPath = 'img://../mods/shared_resources/xvm/res/icons/tooltips/roles'
            crewRolesIcons_arr = []
            for tankman_role in vehicle.descriptor.type.crewRoles:
                crewRolesIcons_arr.append('<img src="%s/%s.png" height="16" width="16">' % (imgPath, tankman_role[0]))
            crewRolesIcons_str = ''.join(crewRolesIcons_arr)
            tooltip_add_param(self, result, crewRolesIcons_str, '')
        if (len(result) > 30) and config.get('tooltips/hideBottomText'): # limitation
            result = result[:30]
        elif (len(result) > 29) and not config.get('tooltips/hideBottomText'): # limitation
            result = result[:29]
        carousel_tooltips_cache[vehicle.intCD] = result
        return result
    except Exception as ex:
        err(traceback.format_exc())
        return base(self)
示例#36
0
def VehicleParamsField_getValue(base, self):
    # log('VehicleParamsField_getValue')
    try:
        global carousel_tooltips_cache
        vehicle = self._tooltip.item
        context_name = self._tooltip.context.getComponent()
        cache_result = carousel_tooltips_cache.get(vehicle.intCD, {}).get(context_name)
        if cache_result:
            return cache_result
        result = list()
        configuration = self._tooltip.context.getParamsConfiguration(vehicle)
        params = configuration.params
        crew = configuration.crew
        eqs = configuration.eqs
        devices = configuration.devices
        veh_descr = vehicle.descriptor
        gun = vehicle.gun.descriptor
        turret = vehicle.turret.descriptor
        vehicleCommonParams = dict(ItemsParameters.g_instance.getParameters(veh_descr))
        vehicleRawParams = dict(ParametersCache.g_instance.getParameters(veh_descr))
        result.append([])
        veh_type_inconfig = vehicle.type.replace('AT-SPG', 'TD')
        clipGunInfoShown = False
        premium_shells = {}
        for shell in vehicle.shells:
            premium_shells[shell.intCompactDescr] = shell.isPremium
        if params:
            values = config.get('tooltips/%s' % veh_type_inconfig)
            if values and len(values):
                params_list = values # overriding parameters
            else:
                params_list = self.PARAMS.get(vehicle.type, 'default') # original parameters
            for paramName in params_list:
                if paramName == 'turretArmor' and not vehicle.hasTurrets:
                    continue
                #inner name, for example - ussr:R100_SU122A
                if paramName == 'innerName':
                    result[-1].append([h1_pad(vehicle.name), ''])
                    continue
                #maxHealth
                if paramName == 'maxHealth':
                    result[-1].append([h1_pad(i18n.makeString('#menu:vehicleInfo/params/maxHealth')), h1_pad(veh_descr.maxHealth)])
                    continue
                #battle tiers
                if paramName == 'battleTiers':
                    (minTier, maxTier) = getTiers(vehicle.level, vehicle.type, vehicle.name)
                    result[-1].append([h1_pad(l10n('Battle tiers')), h1_pad('%s..%s' % (minTier, maxTier))])
                    continue
                #gravity
                if paramName == 'gravity':
                    gravity_str = '%g' % round(veh_descr.shot['gravity'], 2)
                    result[-1].append([h1_pad(l10n('gravity')), h1_pad(gravity_str)])
                    continue
                #camo coeffitients
                if paramName == 'camo_coeff':
                    topTurret = veh_descr.type.turrets[0][-1]
                    camo_coeff_arr = getCamoValues(vehicle.name, turret['name'] == topTurret['name'], gun['name'])
                    camo_coeff_str = '/'.join(map(camo_smart_round, camo_coeff_arr))
                    result[-1].append([h1_pad(l10n('camoCoeff') + ' <p>(%)</p>'), h1_pad(camo_coeff_str)])
                    continue
                #radioRange
                if paramName == 'radioRange':
                    radioRange_str = '%s' % int(vehicle.radio.descriptor['distance'])
                    result[-1].append([i18n.makeString('#menu:moduleInfo/params/radioDistance').replace('h>', 'h1>'), h1_pad(radioRange_str)])
                    continue
                #explosionRadius
                if paramName == 'explosionRadius':
                    explosionRadiusMin = 999
                    explosionRadiusMax = 0
                    for shot in gun['shots']:
                        if 'explosionRadius' in shot['shell']:
                            if shot['shell']['explosionRadius'] < explosionRadiusMin:
                                explosionRadiusMin = shot['shell']['explosionRadius']
                            if shot['shell']['explosionRadius'] > explosionRadiusMax:
                                explosionRadiusMax = shot['shell']['explosionRadius']
                    if explosionRadiusMax == 0: # no HE
                        continue
                    explosionRadius_str = '%g' % round(explosionRadiusMin, 2)
                    if explosionRadiusMin != explosionRadiusMax:
                        explosionRadius_str += '/%s' % gold_pad('%g' % round(explosionRadiusMax, 2))
                    result[-1].append([self._getParameterValue(paramName, vehicleCommonParams, vehicleRawParams)[0], h1_pad(explosionRadius_str)])
                    continue
                #shellSpeedSummary
                if paramName == 'shellSpeedSummary':
                    shellSpeedSummary_arr = []
                    for shot in gun['shots']:
                        shellSpeed_str = '%g' % round(shot['speed'] * 1.25)
                        if premium_shells[shot['shell']['compactDescr']]:
                            shellSpeed_str = gold_pad(shellSpeed_str)
                        shellSpeedSummary_arr.append(shellSpeed_str)
                    shellSpeedSummary_str = '/'.join(shellSpeedSummary_arr)
                    result[-1].append([h1_pad('%s <p>%s</p>' % (l10n('shellSpeed'), l10n('(m/sec)'))), h1_pad(shellSpeedSummary_str)])
                    continue
                #piercingPowerAvg
                if paramName == 'piercingPowerAvg':
                    piercingPowerAvg = '%g' % veh_descr.shot['piercingPower'][0]
                    result[-1].append([i18n.makeString('#menu:moduleInfo/params/avgPiercingPower').replace('h>', 'h1>'), h1_pad(piercingPowerAvg)])
                    continue
                #piercingPowerAvgSummary
                if paramName == 'piercingPowerAvgSummary':
                    piercingPowerAvgSummary_arr = []
                    for shot in gun['shots']:
                        piercingPower_str = '%g' % shot['piercingPower'][0]
                        if premium_shells[shot['shell']['compactDescr']]:
                            piercingPower_str = gold_pad(piercingPower_str)
                        piercingPowerAvgSummary_arr.append(piercingPower_str)
                    piercingPowerAvgSummary_str = '/'.join(piercingPowerAvgSummary_arr)
                    result[-1].append([i18n.makeString('#menu:moduleInfo/params/avgPiercingPower').replace('h>', 'h1>'), h1_pad(piercingPowerAvgSummary_str)])
                    continue
                #damageAvgSummary
                if paramName == 'damageAvgSummary':
                    damageAvgSummary_arr = []
                    for shot in gun['shots']:
                        damageAvg_str = '%g' % shot['shell']['damage'][0]
                        if premium_shells[shot['shell']['compactDescr']]:
                            damageAvg_str = gold_pad(damageAvg_str)
                        damageAvgSummary_arr.append(damageAvg_str)
                    damageAvgSummary_str = '/'.join(damageAvgSummary_arr)
                    result[-1].append([i18n.makeString('#menu:moduleInfo/params/avgDamage').replace('h>', 'h1>'), h1_pad(damageAvgSummary_str)])
                    continue
                #magazine loading
                if (paramName == 'reloadTimeSecs' or paramName == 'rateOfFire') and vehicle.gun.isClipGun():
                    if clipGunInfoShown:
                        continue
                    (shellsCount, shellReloadingTime) = gun['clip']
                    reloadMagazineTime = gun['reloadTime']
                    shellReloadingTime_str = '%g' % round(shellReloadingTime, 2)
                    reloadMagazineTime_str = '%g' % round(reloadMagazineTime, 2)
                    result[-1].append([i18n.makeString('#menu:moduleInfo/params/shellsCount').replace('h>', 'h1>'), h1_pad(shellsCount)])
                    result[-1].append([i18n.makeString('#menu:moduleInfo/params/shellReloadingTime').replace('h>', 'h1>'), h1_pad(shellReloadingTime_str)])
                    result[-1].append([i18n.makeString('#menu:moduleInfo/params/reloadMagazineTime').replace('h>', 'h1>'), h1_pad(reloadMagazineTime_str)])
                    clipGunInfoShown = True
                    continue
                #rate of fire
                if paramName == 'rateOfFire' and not vehicle.gun.isClipGun():
                    rateOfFire_str = '%g' % round(60 / gun['reloadTime'], 2)
                    result[-1].append([i18n.makeString('#menu:moduleInfo/params/reloadTime').replace('h>', 'h1>'), h1_pad(rateOfFire_str)])
                    continue
                # gun traverse limits
                if paramName == 'traverseLimits' and gun['turretYawLimits']:
                    (traverseMin, traverseMax) = gun['turretYawLimits']
                    traverseLimits_str = '%g..+%g' % (round(degrees(traverseMin)), round(degrees(traverseMax)))
                    result[-1].append([h1_pad(l10n('traverseLimits')), h1_pad(traverseLimits_str)])
                    continue
                # elevation limits (front)
                if paramName == 'pitchLimits':
                    (pitchMax, pitchMin) = calcPitchLimitsFromDesc(0, gun['pitchLimits'])
                    pitchLimits_str = '%g..+%g' % (round(degrees(-pitchMin)), round(degrees(-pitchMax)))
                    result[-1].append([h1_pad(l10n('pitchLimits')), h1_pad(pitchLimits_str)])
                    continue
                # elevation limits (side)
                if paramName == 'pitchLimitsSide':
                    if gun['turretYawLimits'] and abs(degrees(gun['turretYawLimits'][0])) < 89: continue # can't look aside 90 degrees
                    (pitchMax, pitchMin) = calcPitchLimitsFromDesc(pi / 2, gun['pitchLimits'])
                    pitchLimits_str = '%g..+%g' % (round(degrees(-pitchMin)), round(degrees(-pitchMax)))
                    result[-1].append([h1_pad(l10n('pitchLimitsSide')), h1_pad(pitchLimits_str)])
                    continue
                # elevation limits (rear)
                if paramName == 'pitchLimitsRear':
                    if gun['turretYawLimits']: continue # can't look back
                    (pitchMax, pitchMin) = calcPitchLimitsFromDesc(pi, gun['pitchLimits'])
                    pitchLimits_str = '%g..+%g' % (round(degrees(-pitchMin)), round(degrees(-pitchMax)))
                    result[-1].append([h1_pad(l10n('pitchLimitsRear')), h1_pad(pitchLimits_str)])
                    continue
                # shooting range
                if paramName == 'shootingRadius':
                    viewRange, shellRadius, artiRadius = _getRanges(turret, gun, vehicle.nationName, vehicle.type)
                    if vehicle.type == 'SPG':
                        result[-1].append([h1_pad('%s <p>%s</p>' % (l10n('shootingRadius'), l10n('(m)'))), h1_pad(artiRadius)])
                    elif shellRadius < 707:
                        result[-1].append([h1_pad('%s <p>%s</p>' % (l10n('shootingRadius'), l10n('(m)'))), h1_pad(shellRadius)])
                    continue
                #reverse max speed
                if paramName == 'speedLimits':
                    (speedLimitForward, speedLimitReverse) = veh_descr.physics['speedLimits']
                    speedLimits_str = str(int(speedLimitForward * 3.6)) + '/' + str(int(speedLimitReverse * 3.6))
                    result[-1].append([self._getParameterValue(paramName, vehicleCommonParams, vehicleRawParams)[0], speedLimits_str])
                    continue
                #turret rotation speed
                if paramName == 'turretRotationSpeed':
                    if not vehicle.hasTurrets:
                        paramName = 'gunRotationSpeed'
                    turretRotationSpeed_str = str(int(degrees(veh_descr.turret['rotationSpeed'])))
                    result[-1].append([self._getParameterValue(paramName, vehicleCommonParams, vehicleRawParams)[0], turretRotationSpeed_str])
                    continue
                #terrain resistance
                if paramName == 'terrainResistance':
                    resistances_arr = []
                    for key in veh_descr.chassis['terrainResistance']:
                        resistances_arr.append('%g' % round(key, 2))
                    terrainResistance_str = '/'.join(resistances_arr)
                    result[-1].append([h1_pad(l10n('terrainResistance')), h1_pad(terrainResistance_str)])
                    continue
                #custom text
                if paramName.startswith('TEXT:'):
                    customtext = paramName[5:]
                    result[-1].append([h1_pad(l10n_macros_replace(customtext)), ''])
                    continue
                if paramName in vehicleCommonParams or paramName in vehicleRawParams:
                    result[-1].append(self._getParameterValue(paramName, vehicleCommonParams, vehicleRawParams))

        if vehicle.isInInventory:
            # optional devices icons, must be in the end
            if 'optDevicesIcons' in params_list:
                optDevicesIcons_arr = []
                for key in vehicle.optDevices:
                    if key:
                        imgPath = 'img://gui' + key.icon.lstrip('.')
                    else:
                        imgPath = 'img://gui/maps/icons/artefact/empty.png'
                    optDevicesIcons_arr.append('<img src="%s" height="16" width="16">' % imgPath)
                optDevicesIcons_str = ' '.join(optDevicesIcons_arr)
                result[-1].append([optDevicesIcons_str, ''])

            # equipment icons, must be in the end
            if 'equipmentIcons' in params_list:
                equipmentIcons_arr = []
                for key in vehicle.eqs:
                    if key:
                        imgPath = 'img://gui' + key.icon.lstrip('.')
                    else:
                        imgPath = 'img://gui/maps/icons/artefact/empty.png'
                    equipmentIcons_arr.append('<img src="%s" height="16" width="16">' % imgPath)
                equipmentIcons_str = ' '.join(equipmentIcons_arr)
                if config.get('tooltips/combineIcons') and optDevicesIcons_str:
                    result[-1][-1][0] += ' ' + equipmentIcons_str
                else:
                    result[-1].append([equipmentIcons_str, ''])

        # crew roles icons, must be in the end
        if 'crewRolesIcons' in params_list:
            imgPath = 'img://../mods/shared_resources/xvm/res/icons/tooltips/roles'
            crewRolesIcons_arr = []
            for tankman_role in vehicle.descriptor.type.crewRoles:
                crewRolesIcons_arr.append('<img src="%s/%s.png" height="16" width="16">' % (imgPath, tankman_role[0]))
            crewRolesIcons_str = ''.join(crewRolesIcons_arr)
            result[-1].append([crewRolesIcons_str, ''])

        result.append([])
        if config.get('tooltips/hideBottomText'):
            pass
        else:
            if crew:
                currentCrewSize = 0
                if vehicle.isInInventory:
                    currentCrewSize = len([ x for _, x in vehicle.crew if x is not None ])
                result[-1].append({'label': 'crew',
                 'current': currentCrewSize,
                 'total': len(vehicle.descriptor.type.crewRoles)})
            if eqs:
                result[-1].append({'label': 'equipments',
                 'current': len([ x for x in vehicle.eqs if x ]),
                 'total': len(vehicle.eqs)})
            if devices:
                result[-1].append({'label': 'devices',
                 'current': len([ x for x in vehicle.descriptor.optionalDevices if x ]),
                 'total': len(vehicle.descriptor.optionalDevices)})

        if vehicle.intCD not in carousel_tooltips_cache:
            carousel_tooltips_cache[vehicle.intCD] = {}
        carousel_tooltips_cache[vehicle.intCD][context_name] = result
        return result
    except Exception as ex:
        err(traceback.format_exc())
        return base(self)
示例#37
0
def CommonStatsBlockConstructor_construct(base, self):
    try:
        self.leftPadding = -15
        vehicle = self.vehicle
        cache_result = carousel_tooltips_cache.get(vehicle.intCD)
        if cache_result:
            return cache_result
        result = []
        if not config.get('tooltips/hideSimplifiedVehParams'):
            result.append(
                formatters.packTitleDescBlock(text_styles.middleTitle(
                    i18n.makeString(TOOLTIPS.TANKCARUSEL_MAINPROPERTY)),
                                              padding=formatters.packPadding(
                                                  left=0,
                                                  right=self.rightPadding,
                                                  bottom=8)))
        params = self.configuration.params
        veh_descr = vehicle.descriptor
        gun = vehicle.gun.descriptor
        turret = vehicle.turret.descriptor
        comparator = idealCrewComparator_helper(vehicle)
        vehicleCommonParams = getParameters_helper(vehicle)
        veh_type_inconfig = vehicle.type.replace('AT-SPG', 'TD')
        clipGunInfoShown = False
        premium_shells = {}

        for shell in vehicle.shells:
            premium_shells[shell.intCompactDescr] = shell.isPremium
        if params:
            values = config.get('tooltips/%s' % veh_type_inconfig)
            if values and len(values):
                params_list = values  # overriding parameters
            else:
                params_list = self.PARAMS.get(vehicle.type,
                                              'default')  # original parameters
            paramInfo = None
            for paramName in params_list:
                if paramName is None:
                    continue
                if paramName == 'rateOfFire':
                    paramName = 'reloadTime'
                elif paramName == 'traverseLimits':
                    paramName = 'gunYawLimits' if 'gunYawLimits' in vehicleCommonParams else 'turretYawLimits'
                elif paramName == 'radioRange':
                    paramName = 'radioDistance'
                elif paramName == 'reloadTimeSecs' and (gun.clip[0] > 1):
                    paramName = 'clipFireRate'
                elif paramName == 'turretRotationSpeed' and not vehicle.hasTurrets:
                    paramName = 'gunRotationSpeed'
                if paramName in vehicleCommonParams:
                    paramInfo = comparator.getExtendedData(paramName)
                if paramName == 'turretArmor' and not vehicle.hasTurrets:
                    continue
                #maxHealth
                elif paramName == 'maxHealth':
                    tooltip_add_param(
                        self, result,
                        i18n.makeString('#menu:vehicleInfo/params/maxHealth'),
                        formatNumber(veh_descr.maxHealth))
                #battle tiers
                elif paramName == 'battleTiers':
                    (minTier, maxTier) = getTiers(vehicle.level, vehicle.type,
                                                  vehicle.name)
                    tooltip_add_param(self, result, l10n('Battle tiers'),
                                      '%s..%s' % (minTier, maxTier))
                #explosionRadius
                elif paramName == 'explosionRadius':
                    explosionRadiusMin = 999
                    explosionRadiusMax = 0
                    for shot in gun.shots:
                        if shot.shell.kind == SHELL_TYPES.HIGH_EXPLOSIVE:
                            explosionRadius = shot.shell.type.explosionRadius
                            if explosionRadius < explosionRadiusMin:
                                explosionRadiusMin = explosionRadius
                            if explosionRadius > explosionRadiusMax:
                                explosionRadiusMax = explosionRadius
                    if explosionRadiusMax == 0:  # no HE
                        continue
                    explosionRadius_str = formatNumber(explosionRadiusMin)
                    if explosionRadiusMin != explosionRadiusMax:
                        explosionRadius_str += '/%s' % gold_pad(
                            formatNumber(explosionRadiusMax))
                    tooltip_add_param(self, result,
                                      getParameterValue(paramName),
                                      explosionRadius_str)
                #shellSpeedSummary
                elif paramName == 'shellSpeedSummary':
                    shellSpeedSummary_arr = []
                    for shot in gun.shots:
                        shellSpeed_str = '%g' % round(shot.speed * 1.25)
                        if premium_shells[shot.shell.compactDescr]:
                            shellSpeed_str = gold_pad(shellSpeed_str)
                        shellSpeedSummary_arr.append(shellSpeed_str)
                    shellSpeedSummary_str = '/'.join(shellSpeedSummary_arr)
                    tooltip_add_param(
                        self, result,
                        tooltip_with_units(l10n('shellSpeed'),
                                           l10n('(m/sec)')),
                        shellSpeedSummary_str)
                #piercingPowerAvg
                elif paramName == 'piercingPowerAvg':
                    piercingPowerAvg = formatNumber(
                        veh_descr.shot.piercingPower[0])
                    tooltip_add_param(
                        self, result,
                        replace_p(
                            i18n.makeString(
                                '#menu:moduleInfo/params/avgPiercingPower')),
                        piercingPowerAvg)
                #piercingPowerAvgSummary
                elif paramName == 'piercingPowerAvgSummary':
                    piercingPowerAvgSummary_arr = []
                    for shot in gun.shots:
                        piercingPower_str = formatNumber(shot.piercingPower[0])
                        if premium_shells[shot.shell.compactDescr]:
                            piercingPower_str = gold_pad(piercingPower_str)
                        piercingPowerAvgSummary_arr.append(piercingPower_str)
                    piercingPowerAvgSummary_str = '/'.join(
                        piercingPowerAvgSummary_arr)
                    tooltip_add_param(
                        self, result,
                        replace_p(
                            i18n.makeString(
                                '#menu:moduleInfo/params/avgPiercingPower')),
                        piercingPowerAvgSummary_str)
                #damageAvgSummary
                elif paramName == 'damageAvgSummary':
                    damageAvgSummary_arr = []
                    for shot in gun.shots:
                        damageAvg_str = formatNumber(shot.shell.damage[0])
                        if premium_shells[shot.shell.compactDescr]:
                            damageAvg_str = gold_pad(damageAvg_str)
                        damageAvgSummary_arr.append(damageAvg_str)
                    damageAvgSummary_str = '/'.join(damageAvgSummary_arr)
                    tooltip_add_param(
                        self, result,
                        replace_p(
                            i18n.makeString(
                                '#menu:moduleInfo/params/avgDamage')),
                        damageAvgSummary_str)
                #magazine loading
                # elif (paramName == 'reloadTimeSecs' or paramName == 'rateOfFire') and vehicle.gun.isClipGun():
                #     if clipGunInfoShown:
                #         continue
                #     (shellsCount, shellReloadingTime) = gun.clip
                #     reloadMagazineTime = gun.reloadTime
                #     shellReloadingTime_str = formatNumber(shellReloadingTime)
                #     reloadMagazineTime_str = formatNumber(reloadMagazineTime)
                #     tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/shellsCount')), shellsCount)
                #     tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/shellReloadingTime')), shellReloadingTime_str)
                #     tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/reloadMagazineTime')), reloadMagazineTime_str)
                #     clipGunInfoShown = True
                #rate of fire
                # elif paramName == 'rateOfFire' and not vehicle.gun.isClipGun():
                #     rateOfFire_str = formatNumber(60 / gun.reloadTime)
                #     tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/reloadTime')), rateOfFire_str)
                # gun traverse limits
                # elif paramName == 'traverseLimits' and gun.turretYawLimits:
                #     (traverseMin, traverseMax) = gun.turretYawLimits
                #     traverseLimits_str = '%g..+%g' % (round(degrees(traverseMin)), round(degrees(traverseMax)))
                #     tooltip_add_param(self, result, l10n('traverseLimits'), traverseLimits_str)
                # elevation limits (front)
                # elif paramName == 'pitchLimits':
                #     (pitchMax, pitchMin) = calcPitchLimitsFromDesc(0, gun.pitchLimits)
                #     pitchLimits_str = '%g..+%g' % (round(degrees(-pitchMin)), round(degrees(-pitchMax)))
                #     tooltip_add_param(self, result, l10n('pitchLimits'), pitchLimits_str)
                # elevation limits (side)
                elif paramName == 'pitchLimitsSide':
                    if gun.turretYawLimits and abs(
                            degrees(gun.turretYawLimits[0])) < 89:
                        continue  # can't look aside 90 degrees
                    (pitchMax, pitchMin) = calcPitchLimitsFromDesc(
                        pi / 2, gun.pitchLimits)
                    pitchLimits_str = '%g..+%g' % (round(
                        degrees(-pitchMin)), round(degrees(-pitchMax)))
                    tooltip_add_param(self, result, l10n('pitchLimitsSide'),
                                      pitchLimits_str)
                # elevation limits (rear)
                elif paramName == 'pitchLimitsRear':
                    if gun.turretYawLimits: continue  # can't look back
                    (pitchMax,
                     pitchMin) = calcPitchLimitsFromDesc(pi, gun.pitchLimits)
                    pitchLimits_str = '%g..+%g' % (round(
                        degrees(-pitchMin)), round(degrees(-pitchMax)))
                    tooltip_add_param(self, result, l10n('pitchLimitsRear'),
                                      pitchLimits_str)
                # shooting range
                elif paramName == 'shootingRadius':
                    viewRange, shellRadius, artiRadius = _getRanges(
                        turret, gun, vehicle.nationName, vehicle.type)
                    if vehicle.type == 'SPG':
                        tooltip_add_param(
                            self, result,
                            tooltip_with_units(l10n('shootingRadius'),
                                               l10n('(m)')), artiRadius)
                    elif shellRadius < 707:
                        tooltip_add_param(
                            self, result,
                            tooltip_with_units(l10n('shootingRadius'),
                                               l10n('(m)')), shellRadius)
                #reverse max speed
                elif paramName == 'speedLimits':
                    (speedLimitForward,
                     speedLimitReverse) = veh_descr.physics['speedLimits']
                    speedLimits_str = str(int(
                        speedLimitForward * 3.6)) + '/' + str(
                            int(speedLimitReverse * 3.6))
                    tooltip_add_param(self, result,
                                      getParameterValue(paramName),
                                      speedLimits_str)
                #turret rotation speed
                # elif paramName == 'turretRotationSpeed' or paramName == 'gunRotationSpeed':
                #     if not vehicle.hasTurrets:
                #         paramName = 'gunRotationSpeed'
                #     turretRotationSpeed_str = str(int(degrees(veh_descr.turret.rotationSpeed)))
                #     tooltip_add_param(self, result, tooltip_with_units(i18n.makeString('#menu:tank_params/%s' % paramName).rstrip(), i18n.makeString('#menu:tank_params/gps')), turretRotationSpeed_str)
                #terrain resistance
                elif paramName == 'terrainResistance':
                    resistances_arr = []
                    for key in veh_descr.chassis.terrainResistance:
                        resistances_arr.append(formatNumber(key))
                    terrainResistance_str = '/'.join(resistances_arr)
                    tooltip_add_param(self, result, l10n('terrainResistance'),
                                      terrainResistance_str)
                #radioRange
                # elif paramName == 'radioRange':
                #     radioRange_str = '%s' % int(vehicle.radio.descriptor.distance)
                #     tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/radioDistance')), radioRange_str)
                #gravity
                elif paramName == 'gravity':
                    gravity_str = formatNumber(veh_descr.shot.gravity)
                    tooltip_add_param(self, result, l10n('gravity'),
                                      gravity_str)
                #inner name, for example - ussr:R100_SU122A
                elif paramName == 'innerName':
                    tooltip_add_param(self, result, vehicle.name, '')
                #custom text
                elif paramName.startswith('TEXT:'):
                    customtext = paramName[5:]
                    tooltip_add_param(self, result, l10n(customtext), '')
                elif paramInfo is not None and paramName in paramInfo.name:
                    valueStr = str(
                        param_formatter.formatParameter(
                            paramName, paramInfo.value))
                    tooltip_add_param(self, result,
                                      getParameterValue(paramName), valueStr)
        if vehicle.isInInventory:
            # optional devices icons, must be in the end
            if 'optDevicesIcons' in params_list:
                optDevicesIcons_arr = []
                for key in vehicle.optDevices:
                    if key:
                        imgPath = 'img://gui' + key.icon.lstrip('.')
                    else:
                        imgPath = 'img://gui/maps/icons/artefact/empty.png'
                    optDevicesIcons_arr.append(
                        '<img src="%s" height="16" width="16">' % imgPath)
                optDevicesIcons_str = ' '.join(optDevicesIcons_arr)
                tooltip_add_param(self, result, optDevicesIcons_str, '')

            # equipment icons, must be in the end
            if 'equipmentIcons' in params_list:
                equipmentIcons_arr = []
                for key in vehicle.equipment.regularConsumables.getInstalledItems(
                ):
                    if key:
                        imgPath = 'img://gui' + key.icon.lstrip('.')
                    else:
                        imgPath = 'img://gui/maps/icons/artefact/empty.png'
                    equipmentIcons_arr.append(
                        '<img src="%s" height="16" width="16">' % imgPath)
                for key in vehicle.equipment.battleBoosterConsumables.getInstalledItems(
                ):
                    if key:
                        imgPath = 'img://gui' + key.icon.lstrip('.')
                    else:
                        imgPath = 'img://gui/maps/icons/artefact/empty.png'
                    equipmentIcons_arr.append(
                        '<img src="%s" height="16" width="16">' % imgPath)
                equipmentIcons_str = ' '.join(equipmentIcons_arr)
                if config.get('tooltips/combineIcons') and optDevicesIcons_str:
                    tmp_list = []
                    tooltip_add_param(self, tmp_list, equipmentIcons_str, '')
                    result[-1]['data'][
                        'name'] += ' ' + tmp_list[0]['data']['name']
                else:
                    tooltip_add_param(self, result, equipmentIcons_str, '')

        # crew roles icons, must be in the end
        if 'crewRolesIcons' in params_list:
            imgPath = 'img://../mods/shared_resources/xvm/res/icons/tooltips/roles'
            crewRolesIcons_arr = []
            for tankman_role in vehicle.descriptor.type.crewRoles:
                crewRolesIcons_arr.append(
                    '<img src="%s/%s.png" height="16" width="16">' %
                    (imgPath, tankman_role[0]))
            crewRolesIcons_str = ''.join(crewRolesIcons_arr)
            tooltip_add_param(self, result, crewRolesIcons_str, '')
        if (len(result) >
                30) and config.get('tooltips/hideBottomText'):  # limitation
            result = result[:30]
        elif (len(result) >
              29) and not config.get('tooltips/hideBottomText'):  # limitation
            result = result[:29]
        carousel_tooltips_cache[vehicle.intCD] = result
        return result
    except Exception as ex:
        err(traceback.format_exc())
        return base(self)