def update(self, deltaTime):
     self.__oscillator.constraints = mathUtils.matrixScale(self.__yprDeviationConstraints, SniperAimingSystem.__CONSTRAINTS_MULTIPLIERS)
     l_curYaw, l_curPitch = self.__worldYawPitchToTurret(self.__g_curYaw, self.__g_curPitch)
     stabilizationOn = math.fabs(self._matrix.roll) < self.__stailizationLimit and SniperAimingSystem.__FILTER_ENABLED
     if stabilizationOn:
         l_curYaw, l_curNewPitch = self.__clampToLimits(l_curYaw, l_curPitch)
     else:
         l_curNewPitch = l_curPitch
     if stabilizationOn:
         newLocal = l_curPitch + (l_curNewPitch - l_curPitch)
         newGunMat = AimingSystems.getPlayerGunMat(l_curYaw, newLocal)
         new__g_curPitch = newGunMat.pitch
         new__g_curPitch = self.__pitchfilter.update(new__g_curPitch, deltaTime)
         globalDelta = new__g_curPitch - self.__g_curPitch
     else:
         globalDelta = l_curNewPitch - self.__idealPitch
     yprDelta = Vector3(l_curYaw - self.__idealYaw, globalDelta, 0.0)
     self.__oscillator.deviation = yprDelta
     self.__oscillator.update(deltaTime)
     l_curYaw = self.__idealYaw + self.__oscillator.deviation.x
     if stabilizationOn:
         l_curPitch = l_curPitch + self.__oscillator.deviation.y
     else:
         l_curPitch = self.__idealPitch + self.__oscillator.deviation.y
     l_curYaw, l_newCurPitch = self.__clampToLimits(l_curYaw, l_curPitch)
     if not stabilizationOn:
         globalDelta = l_newCurPitch - self.__idealPitch
         l_curPitch = l_newCurPitch
     yprDelta = Vector3(l_curYaw - self.__idealYaw, globalDelta, 0.0)
     self.__oscillator.deviation = yprDelta
     currentGunMat = AimingSystems.getPlayerGunMat(l_curYaw, l_curPitch)
     self.__g_curYaw = currentGunMat.yaw
     self.__g_curPitch = currentGunMat.pitch
     self._matrix.set(currentGunMat)
     return 0.0
Example #2
0
 def update(self, deltaTime):
     self.__oscillator.constraints = mathUtils.matrixScale(self.__yprDeviationConstraints, SniperAimingSystem.__CONSTRAINTS_MULTIPLIERS)
     l_curYaw, l_curPitch = self.__worldYawPitchToTurret(self.__g_curYaw, self.__g_curPitch)
     stabilizationOn = math.fabs(self._matrix.roll) < self.__stailizationLimit and SniperAimingSystem.__FILTER_ENABLED
     if stabilizationOn:
         l_curYaw, l_curNewPitch = self.__clampToLimits(l_curYaw, l_curPitch)
     else:
         l_curNewPitch = l_curPitch
     if stabilizationOn:
         newLocal = l_curPitch + (l_curNewPitch - l_curPitch)
         newGunMat = AimingSystems.getPlayerGunMat(l_curYaw, newLocal)
         new__g_curPitch = newGunMat.pitch
         new__g_curPitch = self.__pitchfilter.update(new__g_curPitch, deltaTime)
         globalDelta = new__g_curPitch - self.__g_curPitch
     else:
         globalDelta = l_curNewPitch - self.__idealPitch
     yprDelta = Vector3(l_curYaw - self.__idealYaw, globalDelta, 0.0)
     self.__oscillator.deviation = yprDelta
     self.__oscillator.update(deltaTime)
     l_curYaw = self.__idealYaw + self.__oscillator.deviation.x
     if stabilizationOn:
         l_curPitch = l_curPitch + self.__oscillator.deviation.y
     else:
         l_curPitch = self.__idealPitch + self.__oscillator.deviation.y
     l_curYaw, l_newCurPitch = self.__clampToLimits(l_curYaw, l_curPitch)
     if not stabilizationOn:
         globalDelta = l_newCurPitch - self.__idealPitch
         l_curPitch = l_newCurPitch
     yprDelta = Vector3(l_curYaw - self.__idealYaw, globalDelta, 0.0)
     self.__oscillator.deviation = yprDelta
     currentGunMat = AimingSystems.getPlayerGunMat(l_curYaw, l_curPitch)
     self.__g_curYaw = currentGunMat.yaw
     self.__g_curPitch = currentGunMat.pitch
     self._matrix.set(currentGunMat)
     return 0.0
 def enable(self, targetPos):
     player = BigWorld.player()
     self.__vehicleTypeDescriptor = player.vehicleTypeDescriptor
     self.__vehicleMProv = player.getOwnVehicleStabilisedMatrix()
     self.__vehiclePrevMat = Matrix(self.__vehicleMProv)
     IAimingSystem.enable(self, targetPos)
     self.__yawLimits = self.__vehicleTypeDescriptor.gun['turretYawLimits']
     self.__pitchLimits = self.__vehicleTypeDescriptor.gun['pitchLimits']
     self.__idealYaw, self.__idealPitch = AimingSystems.getTurretYawGunPitch(self.__vehicleTypeDescriptor, self.__vehicleMProv, targetPos, True)
     self.__idealYaw, self.__idealPitch = self.__clampToLimits(self.__idealYaw, self.__idealPitch)
     currentGunMat = AimingSystems.getPlayerGunMat(self.__idealYaw, self.__idealPitch)
     self.__g_curYaw = currentGunMat.yaw
     self.__g_curPitch = (targetPos - currentGunMat.translation).pitch
     self._matrix.set(currentGunMat)
     self.__idealYaw, self.__idealPitch = self.__worldYawPitchToTurret(self.__g_curYaw, self.__g_curPitch)
     self.__idealYaw, self.__idealPitch = self.__clampToLimits(self.__idealYaw, self.__idealPitch)
     self.__oscillator.reset()
     self.__pitchfilter.reset(currentGunMat.pitch)
     SniperAimingSystem.__activeSystem = self
     vehicle = player.getVehicleAttached()
     if vehicle is not None:
         if not vehicle.filter.placingOnGround:
             vehicle.filter.calcPlacedMatrix(True)
             self.__baseMatrix = vehicle.filter.placingMatrix
         else:
             self.__baseMatrix = vehicle.matrix
     return
Example #4
0
 def handleMovement(self, dx, dy):
     self.__idealYaw, self.__idealPitch = self.__worldYawPitchToTurret(self.__g_curYaw, self.__pitchfilter.value())
     newPitch = self.__idealPitch + dy
     newYaw = self.__idealYaw + dx
     self.__idealYaw, idealPitch, inLimit, pitchMin, dp = self.__inLimit(self.__idealYaw, newYaw, newPitch)
     newPitch += dp
     if not inLimit:
         d1 = pitchMin - self.__idealPitch
         d2 = pitchMin - newPitch
         if math.fabs(d1) >= math.fabs(d2):
             self.__idealPitch = idealPitch
         currentGunMat = AimingSystems.getPlayerGunMat(self.__idealYaw, self.__idealPitch)
         self.__pitchfilter.adjust(currentGunMat.pitch - self.__pitchfilter.value())
     else:
         currentGunMat = AimingSystems.getPlayerGunMat(self.__idealYaw, idealPitch)
         self.__pitchfilter.reset(currentGunMat.pitch)
     self.__g_curYaw = currentGunMat.yaw
     self.__g_curPitch = currentGunMat.pitch
     self._matrix.set(currentGunMat)
     self.__oscillator.velocity = Vector3(0.0, 0.0, 0.0)
     _, uncompensatedPitch = AimingSystems.getTurretYawGunPitch(self.__vehicleTypeDescriptor, BigWorld.player().getOwnVehicleStabilisedMatrix(), self.getDesiredShotPoint())
     if inLimit:
         self.__pitchCompensating = mathUtils.clamp(math.radians(-2.0), math.radians(2.0), idealPitch - uncompensatedPitch)
     else:
         self.__pitchCompensating = 0.0
Example #5
0
 def enable(self, targetPos):
     player = BigWorld.player()
     self.__vehicleTypeDescriptor = player.vehicleTypeDescriptor
     self.__vehicleMProv = player.getOwnVehicleStabilisedMatrix()
     self.__vehiclePrevMat = Matrix(self.__vehicleMProv)
     IAimingSystem.enable(self, targetPos)
     self.__yawLimits = self.__vehicleTypeDescriptor.gun['turretYawLimits']
     self.__pitchLimits = self.__vehicleTypeDescriptor.gun['pitchLimits']
     self.__idealYaw, self.__idealPitch = AimingSystems.getTurretYawGunPitch(self.__vehicleTypeDescriptor, self.__vehicleMProv, targetPos, True)
     self.__idealYaw, self.__idealPitch = self.__clampToLimits(self.__idealYaw, self.__idealPitch)
     currentGunMat = AimingSystems.getPlayerGunMat(self.__idealYaw, self.__idealPitch)
     self.__g_curYaw = currentGunMat.yaw
     self.__g_curPitch = (targetPos - currentGunMat.translation).pitch
     self._matrix.set(currentGunMat)
     self.__idealYaw, self.__idealPitch = self.__worldYawPitchToTurret(self.__g_curYaw, self.__g_curPitch)
     self.__idealYaw, self.__idealPitch = self.__clampToLimits(self.__idealYaw, self.__idealPitch)
     self.__oscillator.reset()
     self.__pitchfilter.reset(currentGunMat.pitch)
     SniperAimingSystem.__activeSystem = self
     vehicle = player.getVehicleAttached()
     if vehicle is not None:
         if hasattr(vehicle.filter, 'placingOnGround') and not vehicle.filter.placingOnGround:
             vehicle.filter.calcPlacedMatrix(True)
             self.__baseMatrix = vehicle.filter.placingMatrix
         else:
             self.__baseMatrix = vehicle.matrix
     return
 def selectPlacement(self, placement):
     if self.__vehicle is None:
         return
     else:
         self.__placement = placement
         self.__lookAtProvider = None
         if placement == _VehicleBounder.SELECT_CHASSIS:
             self.matrix = self.__vehicle.matrix
         elif placement == _VehicleBounder.SELECT_TURRET:
             self.matrix = AimingSystems.getTurretMatrixProvider(
                 self.__vehicle.typeDescriptor, self.__vehicle.matrix,
                 self.__vehicle.appearance.turretMatrix)
         elif placement == _VehicleBounder.SELECT_GUN:
             turretMatrixProv = AimingSystems.getTurretMatrixProvider(
                 self.__vehicle.typeDescriptor, self.__vehicle.matrix,
                 self.__vehicle.appearance.turretMatrix)
             self.matrix = AimingSystems.getGunMatrixProvider(
                 self.__vehicle.typeDescriptor, turretMatrixProv,
                 self.__vehicle.appearance.gunMatrix)
         elif placement == _VehicleBounder.SELECT_LOOK_AT:
             self.matrix = math_utils.createIdentityMatrix()
             self.__lookAtProvider = math_utils.MatrixProviders.product(
                 math_utils.createTranslationMatrix(self.__boundLocalPos),
                 self.__vehicle.matrix)
         return
 def handleMovement(self, dx, dy):
     self.__idealYaw, self.__idealPitch = self.__worldYawPitchToTurret(self.__g_curYaw, self.__pitchfilter.value())
     newPitch = self.__idealPitch + dy
     newYaw = self.__idealYaw + dx
     self.__idealYaw, idealPitch, inLimit, pitchMin, dp = self.__inLimit(self.__idealYaw, newYaw, newPitch)
     newPitch += dp
     if not inLimit:
         d1 = pitchMin - self.__idealPitch
         d2 = pitchMin - newPitch
         if math.fabs(d1) >= math.fabs(d2):
             self.__idealPitch = idealPitch
         currentGunMat = AimingSystems.getPlayerGunMat(self.__idealYaw, self.__idealPitch)
         self.__pitchfilter.adjust(currentGunMat.pitch - self.__pitchfilter.value())
     else:
         currentGunMat = AimingSystems.getPlayerGunMat(self.__idealYaw, idealPitch)
         self.__pitchfilter.reset(currentGunMat.pitch)
     self.__g_curYaw = currentGunMat.yaw
     self.__g_curPitch = currentGunMat.pitch
     self._matrix.set(currentGunMat)
     self.__oscillator.velocity = Vector3(0.0, 0.0, 0.0)
     _, uncompensatedPitch = AimingSystems.getTurretYawGunPitch(self.__vehicleTypeDescriptor, BigWorld.player().getOwnVehicleStabilisedMatrix(), self.getDesiredShotPoint())
     if inLimit:
         self.__pitchCompensating = mathUtils.clamp(math.radians(-2.0), math.radians(2.0), idealPitch - uncompensatedPitch)
     else:
         self.__pitchCompensating = 0.0
Example #8
0
 def selectPlacement(self, placement):
     if self.__vehicle is None:
         return
     else:
         self.__placement = placement
         self.__lookAtProvider = None
         if placement == _VehicleBounder.SELECT_CHASSIS:
             self.matrix = self.__vehicle.matrix
         elif placement == _VehicleBounder.SELECT_TURRET:
             self.matrix = AimingSystems.getTurretMatrixProvider(
                 self.__vehicle.typeDescriptor, self.__vehicle.matrix, self.__vehicle.appearance.turretMatrix
             )
         elif placement == _VehicleBounder.SELECT_GUN:
             turretMatrixProv = AimingSystems.getTurretMatrixProvider(
                 self.__vehicle.typeDescriptor, self.__vehicle.matrix, self.__vehicle.appearance.turretMatrix
             )
             self.matrix = AimingSystems.getGunMatrixProvider(
                 self.__vehicle.typeDescriptor, turretMatrixProv, self.__vehicle.appearance.gunMatrix
             )
         elif placement == _VehicleBounder.SELECT_LOOK_AT:
             self.matrix = mathUtils.createIdentityMatrix()
             self.__lookAtProvider = mathUtils.MatrixProviders.product(
                 mathUtils.createTranslationMatrix(self.__boundLocalPos), self.__vehicle.matrix
             )
         return
Example #9
0
 def handleMovement(self, dx, dy):
     self.__idealTurretYaw, self.__idealGunPitch = self.__worldYawPitchToTurret(self.__worldYaw, self.__worldPitch)
     self.__idealTurretYaw, self.__idealGunPitch = self.__clampToLimits(self.__idealTurretYaw + dx, self.__idealGunPitch + dy)
     currentGunMat = AimingSystems.getPlayerGunMat(self.__idealTurretYaw, self.__idealGunPitch)
     self.__worldYaw = currentGunMat.yaw
     self.__worldPitch = currentGunMat.pitch
     self._matrix.set(currentGunMat)
     self.__oscillator.velocity = Vector3(0.0, 0.0, 0.0)
     _, uncompensatedPitch = AimingSystems.getTurretYawGunPitch(self.__vehicleTypeDescriptor, BigWorld.player().getOwnVehicleMatrix(), self.getDesiredShotPoint())
     self.__pitchCompensating = mathUtils.clamp(math.radians(-2.0), math.radians(2.0), self.__idealGunPitch - uncompensatedPitch)
Example #10
0
 def getDesiredShotPoint(self, scanStart, scanDir):
     scanPos, isPointConvenient = self.__testMouseTargetPoint(scanStart, scanDir)
     if isPointConvenient:
         return scanPos
     planePos = self.__aimPlane.intersectRay(scanStart, scanDir)
     if scanStart.distSqrTo(planePos) < scanStart.distSqrTo(scanPos):
         return scanPos
     turretYaw, gunPitch = AimingSystems.getTurretYawGunPitch(self.__vehicleDesc, self.__vehicleMat, planePos, True)
     gunMat = AimingSystems.getGunJointMat(self.__vehicleDesc, self.__getTurretMat(turretYaw), gunPitch)
     aimDir = gunMat.applyVector(Vector3(0.0, 0.0, 1.0))
     return AimingSystems.getDesiredShotPoint(gunMat.translation, aimDir)
 def _getCorrectGunPitch(vehicleMatrix,
                         turretYaw,
                         gunPitch,
                         overrideTurretLocalZ=None):
     turretMat = AimingSystems.getTurretJointMat(
         self._vehicleTypeDescriptor, vehicleMatrix, turretYaw,
         overrideTurretLocalZ)
     gunMat = AimingSystems.getGunJointMat(self._vehicleTypeDescriptor,
                                           turretMat, gunPitch,
                                           overrideTurretLocalZ)
     return gunMat.pitch
 def getThirdPersonShotPoint(self):
     if self.__shotPointCalculator is not None:
         return self.__shotPointCalculator.aimPlane.intersectRay(
             *self.__getScanRay())
     else:
         return AimingSystems.getDesiredShotPoint(*self.__getScanRay())
         return
def getSPGShotResult(targetPosition,
                     shotIdx,
                     shotPos,
                     shotVel,
                     shotGravity,
                     player=None,
                     target=None):
    if player is None:
        player = BigWorld.player()
    shotResult = SPGShotResultEnum.NOT_HIT
    if targetPosition is None or player is None:
        return shotResult
    else:
        vehicleDescriptor = player.getVehicleDescriptor()
        shotDescr = vehicleDescriptor.getShot(shotIdx)
        minBounds, maxBounds = player.arena.getSpaceBB()
        endPos, _, collData, usedMaxDistance = AimingSystems.getCappedShotTargetInfos(
            shotPos, shotVel, shotGravity, shotDescr, player.playerVehicleID,
            minBounds, maxBounds, CollisionStrategy.COLLIDE_DYNAMIC_AND_STATIC)
        if not usedMaxDistance:
            if collData is None and (
                    endPos -
                    targetPosition).lengthSquared < _SPG_SHOT_RESULT_TOLERANCE:
                shotResult = SPGShotResultEnum.HIT
            elif collData is not None and collData.isVehicle():
                if target is None:
                    target = BigWorld.target()
                if isinstance(target, VehicleEntity):
                    targetVehicleID = target.id
                else:
                    targetVehicleID = None
                if targetVehicleID == collData.entity.id:
                    shotResult = SPGShotResultEnum.HIT
        return shotResult
 def __calculateClosestPoint(self, start, direction):
     direction.normalise()
     distance = self.__vehicleDesc.shot.maxDistance if self.__vehicleDesc is not None else 10000.0
     end = start + direction.scale(distance)
     testResStatic = BigWorld.wg_collideSegment(BigWorld.player().spaceID,
                                                start, end, 128)
     testResDynamic = collideDynamic(start, end,
                                     (BigWorld.player().playerVehicleID, ),
                                     False)
     closestPoint = None
     closestDist = 1000000
     isPointConvenient = True
     if testResStatic:
         closestPoint = testResStatic.closestPoint
         closestDist = (closestPoint - start).length
         shouldCheck = True
         if testResStatic.isTerrain():
             shouldCheck = testResStatic.normal.dot(
                 Math.Vector3(0.0, 1.0, 0.0)) <= math.cos(
                     ShotPointCalculatorPlanar.TERRAIN_MIN_ANGLE)
         if shouldCheck:
             isPointConvenient = closestDist >= self.__minDist
     if closestPoint is None and testResDynamic is None:
         return (AimingSystems.shootInSkyPoint(start, direction), True)
     else:
         if testResDynamic is not None:
             dynDist = testResDynamic[0]
             if dynDist <= closestDist:
                 direction = end - start
                 direction.normalise()
                 closestPoint = start + direction * dynDist
                 isPointConvenient = True
         return (closestPoint, isPointConvenient)
Example #15
0
 def __calculateClosestPoint(self, start, dir):
     dir.normalise()
     end = start + dir.scale(10000.0)
     testResTerrain = BigWorld.wg_collideSegment(BigWorld.player().spaceID, start, end, 128, 8)
     terrainSuitsForCheck = testResTerrain and testResTerrain[1].dot(Math.Vector3(0.0, 1.0, 0.0)) <= math.cos(ShotPointCalculatorPlanar.TERRAIN_MIN_ANGLE)
     testResNonTerrain = BigWorld.wg_collideSegment(BigWorld.player().spaceID, start, end, 136)
     testResDynamic = collideDynamic(start, end, (BigWorld.player().playerVehicleID,), False)
     closestPoint = None
     closestDist = 1000000
     isPointConvenient = True
     if testResTerrain:
         closestPoint = testResTerrain[0]
         closestDist = (testResTerrain[0] - start).length
     if terrainSuitsForCheck:
         isPointConvenient = closestDist >= ShotPointCalculatorPlanar.MIN_DIST
     if testResNonTerrain is not None:
         dist = (testResNonTerrain[0] - start).length
         if dist < closestDist:
             closestPoint = testResNonTerrain[0]
             closestDist = dist
             isPointConvenient = closestDist >= ShotPointCalculatorPlanar.MIN_DIST
     if closestPoint is None and testResDynamic is None:
         return (AimingSystems.shootInSkyPoint(start, dir), True)
     else:
         if testResDynamic is not None:
             dynDist = testResDynamic[0]
             if dynDist <= closestDist:
                 dir = end - start
                 dir.normalise()
                 closestPoint = start + dir * dynDist
                 isPointConvenient = True
         return (closestPoint, isPointConvenient)
 def enable(self, targetPos):
     player = BigWorld.player()
     self.__vehicleTypeDescriptor = player.vehicleTypeDescriptor
     self.__vehicleMProv = player.getOwnVehicleMatrix()
     self.__vehiclePrevMat = Matrix(self.__vehicleMProv)
     IAimingSystem.enable(self, targetPos)
     self.__yawLimits = self.__vehicleTypeDescriptor.gun['turretYawLimits']
     self.__pitchLimits = self.__vehicleTypeDescriptor.gun['pitchLimits']
     self.__idealYaw, self.__idealPitch = getShotAngles(
         self.__vehicleTypeDescriptor, player.getOwnVehicleMatrix(),
         (0.0, 0.0), targetPos, False)
     self.__idealYaw, self.__idealPitch = self.__clampToLimits(
         self.__idealYaw, self.__idealPitch)
     currentGunMat = AimingSystems.getPlayerGunMat(self.__idealYaw,
                                                   self.__idealPitch)
     self.__g_curYaw = currentGunMat.yaw
     self.__g_curPitch = (targetPos - currentGunMat.translation).pitch
     self._matrix.set(currentGunMat)
     self.__idealYaw, self.__idealPitch = self.__worldYawPitchToTurret(
         self.__g_curYaw, self.__g_curPitch)
     self.__idealYaw, self.__idealPitch = self.__clampToLimits(
         self.__idealYaw, self.__idealPitch)
     self.__oscillator.reset()
     self.__pitchfilter.reset(currentGunMat.pitch)
     SniperAimingSystem.__activeSystem = self
Example #17
0
 def update(self, deltaTime):
     self.__oscillator.constraints = mathUtils.matrixScale(
         self.__yprDeviationConstraints,
         SniperAimingSystem.__CONSTRAINTS_MULTIPLIERS)
     vehicleMat = Matrix(self.__vehicleMProv)
     curTurretYaw, curGunPitch = self.__worldYawPitchToTurret(
         self.__worldYaw, self.__worldPitch)
     yprDelta = Vector3(curTurretYaw - self.__idealTurretYaw,
                        curGunPitch - self.__idealGunPitch, 0)
     self.__oscillator.deviation = yprDelta
     self.__oscillator.update(deltaTime)
     curTurretYaw = self.__idealTurretYaw + self.__oscillator.deviation.x
     curGunPitch = self.__idealGunPitch + self.__oscillator.deviation.y
     curTurretYaw, curGunPitch = self.__clampToLimits(
         curTurretYaw, curGunPitch)
     yprDelta = Vector3(curTurretYaw - self.__idealTurretYaw,
                        curGunPitch - self.__idealGunPitch, 0)
     self.__oscillator.deviation = yprDelta
     currentGunMat = AimingSystems.getPlayerGunMat(curTurretYaw,
                                                   curGunPitch)
     self.__worldYaw = currentGunMat.yaw
     self.__worldPitch = currentGunMat.pitch
     self._matrix.set(currentGunMat)
     self.__vehiclePrevMat = vehicleMat
     return 0.0
 def getDesiredShotPoint(self):
     start = self._matrix.translation
     scanDir = self._matrix.applyVector(Vector3(0.0, 0.0, 1.0))
     shotDistance = self._vehicleTypeDescriptor.shot.maxDistance
     return AimingSystems.getDesiredShotPoint(start,
                                              scanDir,
                                              shotDistance=shotDistance)
 def __update(self):
     if self.__manualSound is None:
         return
     elif not hasattr(BigWorld.player(), 'gunRotator'):
         return
     else:
         p = BigWorld.player().gunRotator
         if p.maxturretRotationSpeed is not None and p.maxturretRotationSpeed > 0:
             self.__manualSound.setRTPC('RTPC_ext_turret_speed', p.turretRotationSpeed / p.maxturretRotationSpeed)
         else:
             self.__manualSound.setRTPC('RTPC_ext_turret_speed', 0)
         player = BigWorld.player()
         vehicleTypeDescriptor = player.vehicleTypeDescriptor
         gunRotator = player.gunRotator
         turretYaw = gunRotator.turretYaw
         desiredShotPoint = gunRotator.predictLockedTargetShotPoint()
         if desiredShotPoint is None:
             desiredShotPoint = player.inputHandler.getDesiredShotPoint()
         if desiredShotPoint is None:
             desiredShotPoint = gunRotator.markerInfo[0]
         cameraTurretYaw, _ = AimingSystems.getTurretYawGunPitch(vehicleTypeDescriptor, player.getOwnVehicleStabilisedMatrix(), desiredShotPoint, True)
         angleDiff = abs(turretYaw - cameraTurretYaw)
         if angleDiff > math.pi:
             angleDiff = 2 * math.pi - angleDiff
         self.__manualSound.setRTPC('RTPC_ext_turret_angle', angleDiff)
         turretPitch = BigWorld.player().gunRotator.gunPitch
         self.__manualSound.setRTPC('RTPC_ext_turret_pitch', turretPitch)
         self.__manualSound.setRTPC('RTPC_ext_turret_pitch_speed', abs(self.__oldPitch - turretPitch) / (BigWorld.time() - self.__oldTime))
         self.__oldPitch = turretPitch
         self.__oldTime = BigWorld.time()
         self.__manualSound.setRTPC('RTPC_ext_turret_damaged', 0 if BigWorld.player().deviceStates.get('turretRotator', None) is None else 1)
         return self.__updatePeriod
 def __update(self):
     if self.__manualSound is None:
         return
     elif not hasattr(BigWorld.player(), 'gunRotator'):
         return
     else:
         p = BigWorld.player().gunRotator
         if p.maxturretRotationSpeed is not None and p.maxturretRotationSpeed > 0:
             self.__manualSound.setRTPC('RTPC_ext_turret_speed', p.turretRotationSpeed / p.maxturretRotationSpeed)
         else:
             self.__manualSound.setRTPC('RTPC_ext_turret_speed', 0)
         player = BigWorld.player()
         vehicleTypeDescriptor = player.vehicleTypeDescriptor
         gunRotator = player.gunRotator
         turretYaw = gunRotator.turretYaw
         desiredShotPoint = gunRotator.predictLockedTargetShotPoint()
         if desiredShotPoint is None:
             desiredShotPoint = player.inputHandler.getDesiredShotPoint()
         if desiredShotPoint is None:
             desiredShotPoint = gunRotator.markerInfo[0]
         cameraTurretYaw, _ = AimingSystems.getTurretYawGunPitch(vehicleTypeDescriptor, player.getOwnVehicleStabilisedMatrix(), desiredShotPoint, True)
         angleDiff = abs(turretYaw - cameraTurretYaw)
         if angleDiff > math.pi:
             angleDiff = 2 * math.pi - angleDiff
         self.__manualSound.setRTPC('RTPC_ext_turret_angle', angleDiff)
         turretPitch = BigWorld.player().gunRotator.gunPitch
         self.__manualSound.setRTPC('RTPC_ext_turret_pitch', turretPitch)
         self.__manualSound.setRTPC('RTPC_ext_turret_pitch_speed', abs(self.__oldPitch - turretPitch) / (BigWorld.time() - self.__oldTime))
         self.__oldPitch = turretPitch
         self.__oldTime = BigWorld.time()
         self.__manualSound.setRTPC('RTPC_ext_turret_damaged', 0 if BigWorld.player().deviceStates.get('turretRotator', None) is None else 1)
         return self.__updatePeriod
Example #21
0
 def getThirdPersonShotPoint(self):
     if self.__worldSpaceAimingWithLimits.isEnabled:
         return self.__worldSpaceAimingWithLimits.getAimPoint()
     elif self.__shotPointCalculator is not None:
         return self.__shotPointCalculator.aimPlane.intersectRay(*self.__getScanRay())
     else:
         shotDistance = self._vehicleTypeDescriptor.shot.maxDistance if self._vehicleTypeDescriptor else 10000.0
         return AimingSystems.getDesiredShotPoint(shotDistance=shotDistance, *self.__getScanRay())
Example #22
0
 def enable(self, targetPos):
     player = BigWorld.player()
     self.__vehicleTypeDescriptor = player.vehicleTypeDescriptor
     self.__vehicleMProv = player.getOwnVehicleMatrix()
     self.__vehiclePrevMat = Matrix(self.__vehicleMProv)
     IAimingSystem.enable(self, targetPos)
     self.__yawLimits = self.__vehicleTypeDescriptor.gun['turretYawLimits']
     self.__pitchLimits = self.__vehicleTypeDescriptor.gun['pitchLimits']
     self.__idealTurretYaw, self.__idealGunPitch = AimingSystems.getTurretYawGunPitch(self.__vehicleTypeDescriptor, player.getOwnVehicleMatrix(), targetPos, True)
     self.__idealTurretYaw, self.__idealGunPitch = self.__clampToLimits(self.__idealTurretYaw, self.__idealGunPitch)
     currentGunMat = AimingSystems.getPlayerGunMat(self.__idealTurretYaw, self.__idealGunPitch)
     self.__worldYaw = currentGunMat.yaw
     self.__worldPitch = (targetPos - currentGunMat.translation).pitch
     self._matrix.set(currentGunMat)
     self.__idealTurretYaw, self.__idealGunPitch = self.__worldYawPitchToTurret(self.__worldYaw, self.__worldPitch)
     self.__idealTurretYaw, self.__idealGunPitch = self.__clampToLimits(self.__idealTurretYaw, self.__idealGunPitch)
     self.__oscillator.reset()
     SniperAimingSystem.__activeSystem = self
    def calcTrajectoryProperties(self, aimPoint):
        player = BigWorld.player( )
        descr = player.vehicleTypeDescriptor

        finalPathTurretYaw, finalPathGunPitch = getShotAngles(descr, player.getOwnVehicleMatrix(), (0, 0), aimPoint, True )
        currentGunMat = AimingSystems.getPlayerGunMat(finalPathTurretYaw, finalPathGunPitch)
        clientShotStart = currentGunMat.translation
        clientShotVec = currentGunMat.applyVector(Math.Vector3(0, 0, descr.shot['speed']))

        self._finalPathPoint, self._finalPathShellVelocity, finalPathFlightTime = self._getGunMarkerPosition( clientShotStart, clientShotVec, aimPoint.y if BigWorld._ba_config['spg']['ignoreObstacles'] else None )
 def _getTurretYawGunPitch(self, targetPos, compensateGravity=False):
     player = BigWorld.player()
     stabilisedMatrix = Math.Matrix(player.inputHandler.steadyVehicleMatrixCalculator.stabilisedMProv)
     turretYaw, gunPitch = AimingSystems.getTurretYawGunPitch(self._vehicleTypeDescriptor, stabilisedMatrix, targetPos, compensateGravity)
     rotation = math_utils.createRotationMatrix((turretYaw, gunPitch, 0.0))
     rotation.postMultiply(stabilisedMatrix)
     invertSteady = Math.Matrix(self._vehicleMProv)
     invertSteady.invert()
     rotation.postMultiply(invertSteady)
     return (rotation.yaw, rotation.pitch)
Example #25
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)
Example #26
0
 def processHover(self, position, force = False):
     if force:
         position = AimingSystems.getDesiredShotPoint(Math.Vector3(position[0], 500.0, position[2]), Math.Vector3(0.0, -1.0, 0.0), True, True, True)
         self.__marker.setPosition(position)
         BigWorld.callback(SERVER_TICK_LENGTH, self.__markerForceUpdate)
     else:
         self.__marker.update(position, Vector3(0, 0, 1), 10, SERVER_TICK_LENGTH, None)
     self.hitPosition = position
     self.writeStateToReplay()
     return
Example #27
0
 def handleMovement(self, dx, dy):
     self.resetIdealDirection()
     self.__idealTurretYaw += dx
     self.__idealGunPitch += dy
     self.__idealTurretYaw, self.__idealGunPitch = self.__clampToLimits(self.__idealTurretYaw, self.__idealGunPitch)
     currentGunMat = AimingSystems.getPlayerGunMat(self.__idealTurretYaw, self.__idealGunPitch)
     self.__worldYaw = currentGunMat.yaw
     self.__worldPitch = currentGunMat.pitch
     self._matrix.set(currentGunMat)
     self.__oscillator.velocity = Vector3(0, 0, 0)
Example #28
0
 def __isTurretTurnRequired(self, viewDir, turretYawOnPoint, targetPoint):
     turretMat = self.__getTurretMat(turretYawOnPoint)
     turretPos = turretMat.translation
     gunPos = AimingSystems.getGunJointMat(self.__vehicleDesc, turretMat, 0.0).translation
     dirFromTurretPos = targetPoint - turretPos
     dirFromSniperPos = targetPoint - gunPos
     viewDir = Math.Vector3(viewDir)
     viewDir.y = 0.0
     viewDir.normalise()
     dirFromSniperPos.y = 0.0
     dirFromTurretPos.y = 0.0
     return viewDir.dot(dirFromSniperPos) < 0.0 or viewDir.dot(dirFromTurretPos) < 0.0
Example #29
0
 def processHover(self, position, force=False):
     if force:
         position = AimingSystems.getDesiredShotPoint(
             Math.Vector3(position[0], 500.0, position[2]),
             Math.Vector3(0.0, -1.0, 0.0), True, True, True)
         self.__marker.setPosition(position)
         BigWorld.callback(SERVER_TICK_LENGTH, self.__markerForceUpdate)
     else:
         self.__marker.update(position, Vector3(0, 0, 1), 10,
                              SERVER_TICK_LENGTH, None)
     self.hitPosition = position
     self.writeStateToReplay()
    def predictProjectile(self):
        player = BigWorld.player( )
        if not self.enabled or self._projectileID in player._PlayerAvatar__projectileMover._ProjectileMover__projectiles:
            return
        descr = player.vehicleTypeDescriptor
        self._trackProjectile = True
        self._trackProjectileStartTime = BigWorld.time() + 2 * SERVER_TICK_LENGTH

        finalPathTurretYaw, finalPathGunPitch = getShotAngles(descr, player.getOwnVehicleStabilisedMatrix(), (0, 0), self._lastShotPoint, True)
        currentGunMat = AimingSystems.getPlayerGunMat(finalPathTurretYaw, finalPathGunPitch)
        self._trackProjectileStartPoint = currentGunMat.translation
        self._trackProjectileVelocity = currentGunMat.applyVector(Math.Vector3(0, 0, descr.shot['speed']))
Example #31
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)
Example #32
0
 def focusAtPos(self, scanStart, scanDir, yawPitch = None):
     scanPos, isPointConvenient = self.__testMouseTargetPoint(scanStart, scanDir)
     if not isPointConvenient:
         if yawPitch is not None:
             turretYaw, gunPitch = yawPitch
             gunMat = AimingSystems.getGunJointMat(self.__vehicleDesc, self.__getTurretMat(turretYaw), gunPitch)
             planePos = self.__aimPlane.intersectRay(gunMat.translation, gunMat.applyVector(Vector3(0, 0, 1)), False, False)
         else:
             planePos = self.__aimPlane.intersectRay(scanStart, scanDir, False)
         if scanStart.distSqrTo(planePos) < scanStart.distSqrTo(scanPos):
             return scanPos
         return planePos
     self.__aimPlane.init(scanStart, scanPos)
     return scanPos
Example #33
0
 def handleMovement(self, dx, dy):
     self.__idealTurretYaw, self.__idealGunPitch = self.__worldYawPitchToTurret(
         self.__worldYaw, self.__worldPitch)
     self.__idealTurretYaw, self.__idealGunPitch = self.__clampToLimits(
         self.__idealTurretYaw, self.__idealGunPitch)
     self.__idealTurretYaw += dx
     self.__idealGunPitch += dy
     self.__idealTurretYaw, self.__idealGunPitch = self.__clampToLimits(
         self.__idealTurretYaw, self.__idealGunPitch)
     currentGunMat = AimingSystems.getPlayerGunMat(self.__idealTurretYaw,
                                                   self.__idealGunPitch)
     self.__worldYaw = currentGunMat.yaw
     self.__worldPitch = currentGunMat.pitch
     self._matrix.set(currentGunMat)
     self.__oscillator.velocity = Vector3(0, 0, 0)
Example #34
0
 def focusAtPos(self, scanStart, scanDir, yawPitch = None):
     scanPos, isPointConvenient = self.__testMouseTargetPoint(scanStart, scanDir)
     if not isPointConvenient:
         if yawPitch is not None:
             turretYaw, gunPitch = yawPitch
             gunMat = AimingSystems.getGunJointMat(self.__vehicleDesc, self.__getTurretMat(turretYaw), gunPitch)
             planePos = self.__aimPlane.intersectRay(gunMat.translation, gunMat.applyVector(Vector3(0, 0, 1)), False, False)
         else:
             planePos = self.__aimPlane.intersectRay(scanStart, scanDir, False)
         if scanStart.distSqrTo(planePos) < scanStart.distSqrTo(scanPos):
             return scanPos
         return planePos
     else:
         self.__aimPlane.init(scanStart, scanPos)
         return scanPos
Example #35
0
def SniperAimingSystem_getDesiredShotPoint(self):
    start = self.matrix.translation
    dir = self.matrix.applyVector(Math.Vector3(0, 0, 1))

    end = start + dir.scale(10000.0)
    point = collideDynamicAndStatic(start, end, (BigWorld.player().playerVehicleID,), skipGun=False)
    if point is not None:
        result = point[0]
        self._shootDistance = (result - start).length
    else:
        if self._shootDistance > 0.0:
            result = start + dir.scale(self._shootDistance)
        else:
            result = AimingSystems.shootInSkyPoint(start, dir)

    return result
    def calcTrajectoryProperties(self, aimPoint):
        player = BigWorld.player()
        descr = player.vehicleTypeDescriptor

        finalPathTurretYaw, finalPathGunPitch = getShotAngles(
            descr, player.getOwnVehicleStabilisedMatrix(), (0, 0), aimPoint,
            True)
        currentGunMat = AimingSystems.getPlayerGunMat(finalPathTurretYaw,
                                                      finalPathGunPitch)
        clientShotStart = currentGunMat.translation
        clientShotVec = currentGunMat.applyVector(
            Math.Vector3(0, 0, descr.shot['speed']))

        self._finalPathPoint, self._finalPathShellVelocity, finalPathFlightTime = self._getGunMarkerPosition(
            clientShotStart, clientShotVec, aimPoint.y
            if BigWorld._ba_config['spg']['ignoreObstacles'] else None)
Example #37
0
def SniperAimingSystem_getDesiredShotPoint(self, *args):
    start = self.matrix.translation
    dir = self.matrix.applyVector(Math.Vector3(0, 0, 1))

    end = start + dir.scale(10000.0)
    point = collideDynamicAndStatic(start, end, (BigWorld.player().playerVehicleID,), skipGun=False)
    if point is not None:
        result = point[0]
        self._shootDistance = (result - start).length
    else:
        if self._shootDistance > 0.0:
            result = start + dir.scale(self._shootDistance)
        else:
            result = AimingSystems.shootInSkyPoint(start, dir)

    return result
    def predictProjectile(self):
        player = BigWorld.player()
        if not self.enabled or self._projectileID in player._PlayerAvatar__projectileMover._ProjectileMover__projectiles:
            return
        descr = player.vehicleTypeDescriptor
        self._trackProjectile = True
        self._trackProjectileStartTime = BigWorld.time(
        ) + 2 * SERVER_TICK_LENGTH

        finalPathTurretYaw, finalPathGunPitch = getShotAngles(
            descr, player.getOwnVehicleStabilisedMatrix(), (0, 0),
            self._lastShotPoint, True)
        currentGunMat = AimingSystems.getPlayerGunMat(finalPathTurretYaw,
                                                      finalPathGunPitch)
        self._trackProjectileStartPoint = currentGunMat.translation
        self._trackProjectileVelocity = currentGunMat.applyVector(
            Math.Vector3(0, 0, descr.shot['speed']))
Example #39
0
 def update(self, deltaTime):
     self.__oscillator.constraints = mathUtils.matrixScale(self.__yprDeviationConstraints, SniperAimingSystem.__CONSTRAINTS_MULTIPLIERS)
     vehicleMat = Matrix(self.__vehicleMProv)
     curTurretYaw, curGunPitch = self.__worldYawPitchToTurret(self.__worldYaw, self.__worldPitch)
     yprDelta = Vector3(curTurretYaw - self.__idealTurretYaw, curGunPitch - self.__idealGunPitch, 0.0)
     self.__oscillator.deviation = yprDelta
     self.__oscillator.update(deltaTime)
     curTurretYaw = self.__idealTurretYaw + self.__oscillator.deviation.x
     curGunPitch = self.__idealGunPitch + self.__oscillator.deviation.y
     curTurretYaw, curGunPitch = self.__clampToLimits(curTurretYaw, curGunPitch)
     yprDelta = Vector3(curTurretYaw - self.__idealTurretYaw, curGunPitch - self.__idealGunPitch, 0.0)
     self.__oscillator.deviation = yprDelta
     currentGunMat = AimingSystems.getPlayerGunMat(curTurretYaw, curGunPitch)
     self.__worldYaw = currentGunMat.yaw
     self.__worldPitch = currentGunMat.pitch
     self._matrix.set(currentGunMat)
     self.__vehiclePrevMat = vehicleMat
     return 0.0
 def __getTargetedEnemyForGun(self, gunShotPosition, excludeTeam):
     shotPos, shotVec = self.__getShotPosition(self.__turretYaw,
                                               self.__gunPitch,
                                               gunShotPosition)
     shotDescr = self._avatar.getVehicleDescriptor().shot
     gravity = Math.Vector3(0.0, -shotDescr.gravity, 0.0)
     testVehicleID = self.getAttachedVehicleID()
     collisionStrategy = AimingSystems.CollisionStrategy.COLLIDE_DYNAMIC_AND_STATIC
     minBounds, maxBounds = BigWorld.player().arena.getSpaceBB()
     _, _, collision, _ = AimingSystems.getCappedShotTargetInfos(
         shotPos, shotVec, gravity, shotDescr, testVehicleID, minBounds,
         maxBounds, collisionStrategy)
     if collision is not None:
         entity = collision.entity
         if entity is not None and entity.publicInfo and entity.publicInfo[
                 'team'] is not excludeTeam and entity.health > 0:
             return entity
     return
 def enable(self, targetPos):
     player = BigWorld.player()
     self.__vehicleTypeDescriptor = player.vehicleTypeDescriptor
     self.__vehicleMProv = player.getOwnVehicleMatrix()
     self.__vehiclePrevMat = Matrix(self.__vehicleMProv)
     IAimingSystem.enable(self, targetPos)
     player = BigWorld.player()
     desc = player.vehicleTypeDescriptor
     self.__yawLimits = desc.gun['turretYawLimits']
     self.__idealTurretYaw, self.__idealGunPitch = getShotAngles(desc, player.getOwnVehicleMatrix(), (0, 0), targetPos, False)
     self.__idealTurretYaw, self.__idealGunPitch = self.__clampToLimits(self.__idealTurretYaw, self.__idealGunPitch)
     currentGunMat = AimingSystems.getPlayerGunMat(self.__idealTurretYaw, self.__idealGunPitch)
     self.__worldYaw = currentGunMat.yaw
     self.__worldPitch = (targetPos - currentGunMat.translation).pitch
     self._matrix.set(currentGunMat)
     self.__idealTurretYaw, self.__idealGunPitch = self.__worldYawPitchToTurret(self.__worldYaw, self.__worldPitch)
     self.__idealTurretYaw, self.__idealGunPitch = self.__clampToLimits(self.__idealTurretYaw, self.__idealGunPitch)
     self.__oscillator.reset()
Example #42
0
 def __update(self):
     player = BigWorld.player()
     vehicleTypeDescriptor = player.vehicleTypeDescriptor
     gunRotator = player.gunRotator
     turretYaw = gunRotator.turretYaw
     desiredShotPoint = gunRotator.predictLockedTargetShotPoint()
     if desiredShotPoint is None:
         desiredShotPoint = player.inputHandler.getDesiredShotPoint()
     if desiredShotPoint is None:
         desiredShotPoint = gunRotator.markerInfo[0]
     cameraTurretYaw, _ = AimingSystems.getTurretYawGunPitch(vehicleTypeDescriptor, player.getOwnVehicleMatrix(), desiredShotPoint, True)
     angleDiff = abs(turretYaw - cameraTurretYaw)
     if angleDiff > math.pi:
         angleDiff = 2 * math.pi - angleDiff
     rotationSpeed = gunRotator.turretRotationSpeed
     if rotationSpeed < 0.0001:
         angleDiff = 0.0
     self.__updateSound(angleDiff)
     return self.__updatePeriod
 def __getGunMarkerPosition(self, shotPos, shotVec, dispersionAngles):
     shotDescr = self._avatar.getVehicleDescriptor().shot
     gravity = Math.Vector3(0.0, -shotDescr.gravity, 0.0)
     testVehicleID = self.getAttachedVehicleID()
     collisionStrategy = AimingSystems.CollisionStrategy.COLLIDE_DYNAMIC_AND_STATIC
     minBounds, maxBounds = BigWorld.player().arena.getSpaceBB()
     endPos, direction, collData, usedMaxDistance = AimingSystems.getCappedShotTargetInfos(
         shotPos, shotVec, gravity, shotDescr, testVehicleID, minBounds,
         maxBounds, collisionStrategy)
     distance = shotDescr.maxDistance if usedMaxDistance else (
         endPos - shotPos).length
     markerDiameter = 2.0 * distance * dispersionAngles[0]
     idealMarkerDiameter = 2.0 * distance * dispersionAngles[1]
     replayCtrl = BattleReplay.g_replayCtrl
     if replayCtrl.isPlaying and replayCtrl.isClientReady:
         markerDiameter, endPos, direction = replayCtrl.getGunMarkerParams(
             endPos, direction)
     return (endPos, direction, markerDiameter, idealMarkerDiameter,
             collData)
 def __update(self):
     player = BigWorld.player()
     vehicleTypeDescriptor = player.vehicleTypeDescriptor
     gunRotator = player.gunRotator
     turretYaw = gunRotator.turretYaw
     desiredShotPoint = gunRotator.predictLockedTargetShotPoint()
     if desiredShotPoint is None:
         desiredShotPoint = player.inputHandler.getDesiredShotPoint()
     if desiredShotPoint is None:
         desiredShotPoint = gunRotator.markerInfo[0]
     cameraTurretYaw, _ = AimingSystems.getTurretYawGunPitch(vehicleTypeDescriptor, player.getOwnVehicleStabilisedMatrix(), desiredShotPoint, True)
     angleDiff = abs(turretYaw - cameraTurretYaw)
     if angleDiff > math.pi:
         angleDiff = 2 * math.pi - angleDiff
     rotationSpeed = gunRotator.turretRotationSpeed
     if rotationSpeed < 0.0001:
         angleDiff = 0.0
     self.__updateSound(angleDiff)
     return self.__updatePeriod
Example #45
0
 def __update(self):
     if self.__soundObject is None:
         return
     elif not hasattr(BigWorld.player(), 'gunRotator'):
         return
     else:
         player = BigWorld.player()
         gunRotator = player.gunRotator
         speedValue = 0.0
         if gunRotator.maxturretRotationSpeed is not None and gunRotator.maxturretRotationSpeed > 0:
             speedValue = gunRotator.turretRotationSpeed / gunRotator.maxturretRotationSpeed
         self.__rtpcTurretSpeed.set(self.__soundObject, speedValue)
         vehicleTypeDescriptor = player.vehicleTypeDescriptor
         turretYaw = gunRotator.turretYaw
         desiredShotPoint = gunRotator.predictLockedTargetShotPoint()
         if desiredShotPoint is None:
             desiredShotPoint = player.inputHandler.getDesiredShotPoint()
         if desiredShotPoint is None:
             desiredShotPoint = gunRotator.markerInfo[0]
         cameraTurretYaw, _ = AimingSystems.getTurretYawGunPitch(
             vehicleTypeDescriptor, player.getOwnVehicleStabilisedMatrix(),
             desiredShotPoint, True)
         turretPitch = player.gunRotator.gunPitch
         angleDiff = abs(turretYaw - cameraTurretYaw)
         if angleDiff > math.pi:
             angleDiff = 2 * math.pi - angleDiff
         self.__rtpcTurretAngle.set(self.__soundObject, angleDiff)
         self.__rtpcTurretPitch.set(self.__soundObject, turretPitch)
         self.__rtpcTurretPitchSpeed.set(
             self.__soundObject,
             abs(self.__oldPitch - turretPitch) /
             (BigWorld.time() - self.__oldTime))
         self.__rtpcTurretDamaged.set(
             self.__soundObject, 0 if
             player.deviceStates.get('turretRotator', None) is None else 1)
         self.__oldPitch = turretPitch
         self.__oldTime = BigWorld.time()
         return self.__updatePeriod
Example #46
0
 def enable(self, targetPos):
     player = BigWorld.player()
     self.__vehicleTypeDescriptor = player.vehicleTypeDescriptor
     self.__vehicleMProv = player.getOwnVehicleMatrix()
     self.__vehiclePrevMat = Matrix(self.__vehicleMProv)
     IAimingSystem.enable(self, targetPos)
     player = BigWorld.player()
     desc = player.vehicleTypeDescriptor
     self.__yawLimits = desc.gun['turretYawLimits']
     self.__idealTurretYaw, self.__idealGunPitch = getShotAngles(
         desc, player.getOwnVehicleMatrix(), (0, 0), targetPos, False)
     self.__idealTurretYaw, self.__idealGunPitch = self.__clampToLimits(
         self.__idealTurretYaw, self.__idealGunPitch)
     currentGunMat = AimingSystems.getPlayerGunMat(self.__idealTurretYaw,
                                                   self.__idealGunPitch)
     self.__worldYaw = currentGunMat.yaw
     self.__worldPitch = (targetPos - currentGunMat.translation).pitch
     self._matrix.set(currentGunMat)
     self.__idealTurretYaw, self.__idealGunPitch = self.__worldYawPitchToTurret(
         self.__worldYaw, self.__worldPitch)
     self.__idealTurretYaw, self.__idealGunPitch = self.__clampToLimits(
         self.__idealTurretYaw, self.__idealGunPitch)
     self.__oscillator.reset()
def StrategicAimingSystem_updateMatrix(self):
    player = BigWorld.player( )
    descr = player.vehicleTypeDescriptor

    if not spgAim.enabled:
        if spgAim._lastModeWasSniper:
            if BigWorld._ba_config['spg']['ignoreObstacles']:
                turretYaw, gunPitch = getShotAngles(descr, player.getOwnVehicleMatrix(), (0, 0), self._matrix.translation, True )
                currentGunMat = AimingSystems.getPlayerGunMat(turretYaw, gunPitch)
                clientShotStart = currentGunMat.translation
                clientShotVec = currentGunMat.applyVector(Math.Vector3(0, 0, descr.shot['speed']))
                self._matrix.translation, spgAim._shellVelocity, _ = spgAim._getGunMarkerPosition( clientShotStart, clientShotVec, None )

            self._StrategicAimingSystem__planePosition = Math.Vector3(self._matrix.translation.x, 0.0, self._matrix.translation.z)

        oldStrategicAimingSystem_updateMatrix( self )
        spgAim._lastModeWasSniper = False

        collPoint = BigWorld.wg_collideSegment(BigWorld.player().spaceID, self._StrategicAimingSystem__planePosition + Math.Vector3(0, 1000.0, 0), self._StrategicAimingSystem__planePosition + Math.Vector3(0, -1000.0, 0), 3)
        aimPoint = Math.Vector3( self._StrategicAimingSystem__planePosition.x, 0.0 if collPoint is None else collPoint[0][1], self._StrategicAimingSystem__planePosition.z )
        spgAim.calcTrajectoryProperties(aimPoint)
        return

    spgAim.onStrategicAimingSystemUpdateMatrix(self)
def Main_update():
    if ME_Tank.player is not None and ME_Tank.alive:
        if config.get('armorPanel/enable', True):
            try:
                if eAP.armorCallBack is not None:
                    BigWorld.cancelCallback(eAP.armorCallBack)
            except Exception:
                pass
            player = BigWorld.player()
            playerVehicle = BigWorld.player().getVehicleAttached()
            gunRotator = player.gunRotator
            vehicleTypeDescriptor = player.vehicleTypeDescriptor
            turretYawRad = gunRotator.turretYaw
            turretYawDeg = math.degrees(turretYawRad)
            ME_Tank.turretYawDeg = turretYawDeg  # don't need just for debug out

            ME_Tank.aimMode = player.inputHandler.ctrlModeName
            if ME_Tank.aimMode == CTRL_MODE_NAME.SNIPER:
                cameraTurretYawRad = player.inputHandler.ctrl.camera.aimingSystem.turretYaw
                cameraTurretYawDeg = math.degrees(cameraTurretYawRad)
                turretPitch = player.gunRotator.gunPitch

                ME_Tank.cameraTurretYaw = cameraTurretYawDeg  # don't need just for debug out

            elif BigWorld.player().inputHandler.ctrlModeName == CTRL_MODE_NAME.ARCADE:
                # noinspection PyProtectedMember
                scanDir, scanStart = AvatarInputHandler.cameras.getWorldRayAndPoint(*BigWorld.player().inputHandler.ctrl._aimOffset)
                scanStop = scanStart + utills.getNormalisedVector(scanDir).scale(720)
                cameraTurretYawRad, _ = AimingSystems.getTurretYawGunPitch(vehicleTypeDescriptor, player.getOwnVehicleStabilisedMatrix(), scanStop, True)
                cameraTurretYawDeg = math.degrees(cameraTurretYawRad)
                turretPitch = Math.Matrix(gunRotator.gunMatrix).pitch

                ME_Tank.cameraTurretYaw = cameraTurretYawDeg  # don't need just for debug out

            else:
                desiredShotPoint = gunRotator.predictLockedTargetShotPoint()
                if desiredShotPoint is None:
                    desiredShotPoint = player.inputHandler.getDesiredShotPoint()
                if desiredShotPoint is None:
                    desiredShotPoint = gunRotator.markerInfo[0]
                cameraTurretYawRad, _ = AimingSystems.getTurretYawGunPitch(vehicleTypeDescriptor, player.getOwnVehicleStabilisedMatrix(), desiredShotPoint, True)
                cameraTurretYawDeg = math.degrees(cameraTurretYawRad)
                turretPitch = Math.Matrix(gunRotator.gunMatrix).pitch
            vehicleMP = Math.Matrix(player.getOwnVehicleMatrix())
            tankYawDeg = math.degrees(Math.Matrix(vehicleMP).yaw)
            arc = eAP.getDynamicArc(playerVehicle, vehicleTypeDescriptor, vehicleMP, turretYawRad, cameraTurretYawRad, turretPitch)
            ME_Tank.effFrontArmor = eAP.getEquArmor(ME_Tank.front, turretYawDeg, cameraTurretYawDeg, arc)
            ME_Tank.effSideArmor = eAP.getEquArmor(ME_Tank.side, (90 - math.fabs(turretYawDeg)), (90 - math.fabs(cameraTurretYawDeg)), 0)
            if ME_Tank.tankType != "SPG":
                eAP.updateEffArmor(ME_Tank.effFrontArmor, turretYawDeg, cameraTurretYawDeg)
                AnglePanel.updateProtractor(turretYawDeg, cameraTurretYawDeg, int(ME_Tank.leftArc), int(ME_Tank.rightArc))
            else:
                AnglePanel.setArtyProtractor(turretYawDeg, int(ME_Tank.leftArc), int(ME_Tank.rightArc), tankYawDeg, ME_Tank.aimMode)
            as_event('ON_ARMOR')
            eAP.armorCallBack = BigWorld.callback(eAP.tickRate, Main_update)  # 0.033 = 30hz 0.01667 = 60hz
    else:
        try:
            if eAP.armorCallBack is not None:
                BigWorld.cancelCallback(eAP.armorCallBack)
        except Exception:
            pass
 def __getStabilizedRoll(self, turretYaw = 0.0, gunPitch = 0.0):
     turretMat = AimingSystems.getTurretJointMat(self.__vehicleTypeDescriptor, self.__baseMatrix, turretYaw)
     return AimingSystems.getGunJointMat(self.__vehicleTypeDescriptor, turretMat, gunPitch).roll
 def getThirdPersonShotPoint(self):
     if self.__shotPointCalculator is not None:
         return self.__shotPointCalculator.aimPlane.intersectRay(*self.__getScanRay())
     else:
         return AimingSystems.getDesiredShotPoint(*self.__getScanRay())
         return
Example #51
0
 def update(self, deltaTime):
     self.__oscillator.constraints = mathUtils.matrixScale(self.__yprDeviationConstraints, SniperAimingSystem.__CONSTRAINTS_MULTIPLIERS)
     l_curYaw, l_curPitch = self.__worldYawPitchToTurret(self.__g_curYaw, self.__g_curPitch)
     if self.__dInputYaw != 0.0 or self.__dInputPitch != 0.0:
         if SniperAimingSystem.__FILTER_ENABLED:
             wasInLimit, _ = self.__inLimit(l_curYaw, l_curPitch, True)
             self.__g_curYaw += self.__dInputYaw
             g_newPitch = self.__g_curPitch + self.__dInputPitch
             l_newYaw, l_newPitch = self.__worldYawPitchToTurret(self.__g_curYaw, g_newPitch)
             if self.__dInputYaw != 0.0:
                 self.__idealYaw, l_limPitch = self.__clampToLimits(l_newYaw, l_newPitch, True)
                 l_curYaw = self.__idealYaw
                 if math.fabs(l_limPitch - l_newPitch) > 1e-05:
                     self.__dInputPitch = l_limPitch - l_curPitch
                     g_newPitch = self.__g_curPitch + self.__dInputPitch
                     l_newPitch = l_limPitch
                 self.__idealPitch = l_limPitch
             if self.__dInputPitch != 0.0:
                 inLimit, limPitch = self.__inLimit(self.__idealYaw, l_newPitch, True)
                 if not wasInLimit and not inLimit and math.fabs(l_newPitch) >= math.fabs(l_curPitch):
                     self.__pitchfilter.resetTimer()
                 else:
                     if wasInLimit and not inLimit:
                         self.__g_curPitch += limPitch - l_curPitch
                         l_curPitch = self.__idealPitch = limPitch
                     else:
                         self.__g_curPitch = g_newPitch
                         l_curPitch = self.__idealPitch = l_newPitch
                     if inLimit:
                         self.__pitchfilter.reset(self.__g_curPitch)
         else:
             self.__idealYaw, self.__idealPitch = self.__clampToLimits(l_curYaw + self.__dInputYaw, l_curPitch + self.__dInputPitch)
             l_curYaw = self.__idealYaw
             currentGunMat = AimingSystems.getPlayerGunMat(self.__idealYaw, self.__idealPitch)
             self.__g_curYaw = currentGunMat.yaw
             self.__g_curPitch = currentGunMat.pitch
         self.__oscillator.velocity = Vector3(0.0, 0.0, 0.0)
         self.__dInputYaw = 0.0
         self.__dInputPitch = 0.0
         l_curNewPitch = self.__idealPitch
     elif SniperAimingSystem.__FILTER_ENABLED:
         l_curYaw, l_curNewPitch = self.__clampToLimits(l_curYaw, l_curPitch)
     else:
         l_curNewPitch = l_curPitch
     if SniperAimingSystem.__FILTER_ENABLED:
         new__g_curPitch = self.__g_curPitch + (l_curNewPitch - l_curPitch)
         new__g_curPitch = self.__pitchfilter.update(new__g_curPitch, deltaTime)
         globalDelta = new__g_curPitch - self.__g_curPitch
     else:
         globalDelta = l_curNewPitch - self.__idealPitch
     yprDelta = Vector3(l_curYaw - self.__idealYaw, globalDelta, 0.0)
     self.__oscillator.deviation = yprDelta
     self.__oscillator.update(deltaTime)
     l_curYaw = self.__idealYaw + self.__oscillator.deviation.x
     if SniperAimingSystem.__FILTER_ENABLED:
         l_curPitch = l_curPitch + self.__oscillator.deviation.y
     else:
         l_curPitch = self.__idealPitch + self.__oscillator.deviation.y
     l_curYaw, l_newCurPitch = self.__clampToLimits(l_curYaw, l_curPitch)
     if not SniperAimingSystem.__FILTER_ENABLED:
         globalDelta = l_newCurPitch - self.__idealPitch
         l_curPitch = l_newCurPitch
     yprDelta = Vector3(l_curYaw - self.__idealYaw, globalDelta, 0.0)
     self.__oscillator.deviation = yprDelta
     currentGunMat = AimingSystems.getPlayerGunMat(l_curYaw, l_curPitch)
     self.__g_curYaw = currentGunMat.yaw
     self.__g_curPitch = currentGunMat.pitch
     self._matrix.set(currentGunMat)
     return 0.0
 def getDesiredShotPoint(self):
     return AimingSystems.getDesiredShotPoint(self._matrix.translation, Vector3(0, -1, 0), True, True)
 def getDesiredShotPoint(self):
     start = self._matrix.translation
     scanDir = self._matrix.applyVector(Vector3(0.0, 0.0, 1.0))
     return AimingSystems.getDesiredShotPoint(start, scanDir)
Example #54
0
 def getDesiredShotPoint(self, terrainOnlyCheck = False):
     return AimingSystems.getDesiredShotPoint(self._matrix.translation, Vector3(0, -1, 0), True, True, terrainOnlyCheck)
 def getThirdPersonShotPoint(self):
     return AimingSystems.getDesiredShotPoint(*self.__getScanRay())