def setShotPosition(self, shotPos, shotVec, dispersionAngle): if self.__clientMode and not self.__showServerMarker: return self.__dispersionAngle = dispersionAngle if not self.__clientMode and VehicleGunRotator.USE_LOCK_PREDICTION: lockEnabled = BigWorld.player().inputHandler.getAimingMode(AIMING_MODE.TARGET_LOCK) if lockEnabled: predictedTargetPos = self.predictLockedTargetShotPoint() if predictedTargetPos is None: return dirToTarget = predictedTargetPos - shotPos dirToTarget.normalise() shotDir = Math.Vector3(shotVec) shotDir.normalise() if shotDir.dot(dirToTarget) > 0.0: return markerPos, markerDir, markerSize, collData = self.__getGunMarkerPosition(shotPos, shotVec, dispersionAngle) replayCtrl = BattleReplay.g_replayCtrl if replayCtrl.isRecording: replayCtrl.setGunMarkerParams(markerSize, markerPos, markerDir) if self.__clientMode and self.__showServerMarker: self.__avatar.inputHandler.updateGunMarker2(markerPos, markerDir, markerSize, SERVER_TICK_LENGTH, collData) if not self.__clientMode: self.__lastShotPoint = markerPos self.__avatar.inputHandler.updateGunMarker(markerPos, markerDir, markerSize, SERVER_TICK_LENGTH, collData) self.__turretYaw, self.__gunPitch = getShotAngles(self.__avatar.vehicleTypeDescriptor, self.__avatar.getOwnVehicleMatrix(), (self.__turretYaw, self.__gunPitch), markerPos, True) descr = self.__avatar.vehicleTypeDescriptor turretYawLimits = descr.gun['turretYawLimits'] closestLimit = self.__isOutOfLimits(self.__turretYaw, turretYawLimits) if closestLimit is not None: self.__turretYaw = closestLimit self.__updateTurretMatrix(self.__turretYaw, SERVER_TICK_LENGTH) self.__updateGunMatrix(self.__gunPitch, SERVER_TICK_LENGTH) self.__markerInfo = (markerPos, markerDir, markerSize)
def setShotPosition(self, shotPos, shotVec, dispersionAngle): if self.__clientMode and not self.__showServerMarker: return self.__dispersionAngle = dispersionAngle if not self.__clientMode and VehicleGunRotator.USE_LOCK_PREDICTION: lockEnabled = BigWorld.player().inputHandler.getAimingMode( AIMING_MODE.TARGET_LOCK) if lockEnabled: predictedTargetPos = self.__predictLockedTargetShotPoint() dirToTarget = predictedTargetPos - shotPos dirToTarget.normalise() shotDir = Math.Vector3(shotVec) shotDir.normalise() if shotDir.dot(dirToTarget) > 0.0: return markerPos, markerDir, markerSize, collData = self.__getGunMarkerPosition( shotPos, shotVec, dispersionAngle) if self.__clientMode and self.__showServerMarker: self.__avatar.inputHandler.updateGunMarker2( markerPos, markerDir, markerSize, SERVER_TICK_LENGTH, collData) if not self.__clientMode: self.__lastShotPoint = markerPos self.__avatar.inputHandler.updateGunMarker(markerPos, markerDir, markerSize, SERVER_TICK_LENGTH, collData) self.__turretYaw, self.__gunPitch = getShotAngles( self.__avatar.vehicleTypeDescriptor, self.__avatar.getOwnVehicleMatrix(), (self.__turretYaw, self.__gunPitch), markerPos, True) self.__updateTurretMatrix(self.__turretYaw, SERVER_TICK_LENGTH) self.__updateGunMatrix(self.__gunPitch, SERVER_TICK_LENGTH) self.__markerInfo = (markerPos, markerDir, markerSize)
def setShotPosition(self, shotPos, shotVec, dispersionAngle): if self.__clientMode and not self.__showServerMarker: return else: self.__dispersionAngle = dispersionAngle if not self.__clientMode and VehicleGunRotator.USE_LOCK_PREDICTION: lockEnabled = BigWorld.player().inputHandler.getAimingMode(AIMING_MODE.TARGET_LOCK) if lockEnabled: predictedTargetPos = self.predictLockedTargetShotPoint() dirToTarget = predictedTargetPos - shotPos dirToTarget.normalise() shotDir = Math.Vector3(shotVec) shotDir.normalise() if shotDir.dot(dirToTarget) > 0.0: return markerPos, markerDir, markerSize, collData = self.__getGunMarkerPosition(shotPos, shotVec, dispersionAngle) replayCtrl = BattleReplay.g_replayCtrl if replayCtrl.isRecording: replayCtrl.setGunMarkerParams(markerSize, markerPos, markerDir) if self.__clientMode and self.__showServerMarker: self.__avatar.inputHandler.updateGunMarker2(markerPos, markerDir, markerSize, SERVER_TICK_LENGTH, collData) if not self.__clientMode: self.__lastShotPoint = markerPos self.__avatar.inputHandler.updateGunMarker(markerPos, markerDir, markerSize, SERVER_TICK_LENGTH, collData) self.__turretYaw, self.__gunPitch = getShotAngles(self.__avatar.vehicleTypeDescriptor, self.__avatar.getOwnVehicleMatrix(), (self.__turretYaw, self.__gunPitch), markerPos, True) descr = self.__avatar.vehicleTypeDescriptor turretYawLimits = descr.gun['turretYawLimits'] closestLimit = self.__isOutOfLimits(self.__turretYaw, turretYawLimits) if closestLimit is not None: self.__turretYaw = closestLimit self.__updateTurretMatrix(self.__turretYaw, SERVER_TICK_LENGTH) self.__updateGunMatrix(self.__gunPitch, SERVER_TICK_LENGTH) self.__markerInfo = (markerPos, markerDir, markerSize) return
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 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
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
def setShotPosition(self, shotPos, shotVec, dispersionAngle): if self.__clientMode and not self.__showServerMarker: return self.__dispersionAngle = dispersionAngle if not self.__clientMode and VehicleGunRotator.USE_LOCK_PREDICTION: lockEnabled = BigWorld.player().inputHandler.getAimingMode(AIMING_MODE.TARGET_LOCK) if lockEnabled: predictedTargetPos = self.__predictLockedTargetShotPoint() dirToTarget = predictedTargetPos - shotPos dirToTarget.normalise() shotDir = Math.Vector3(shotVec) shotDir.normalise() if shotDir.dot(dirToTarget) > 0.0: return markerPos, markerDir, markerSize, collData = self.__getGunMarkerPosition(shotPos, shotVec, dispersionAngle) if self.__clientMode and self.__showServerMarker: self.__avatar.inputHandler.updateGunMarker2(markerPos, markerDir, markerSize, SERVER_TICK_LENGTH, collData) if not self.__clientMode: self.__lastShotPoint = markerPos self.__avatar.inputHandler.updateGunMarker(markerPos, markerDir, markerSize, SERVER_TICK_LENGTH, collData) self.__turretYaw, self.__gunPitch = getShotAngles( self.__avatar.vehicleTypeDescriptor, self.__avatar.getOwnVehicleMatrix(), (self.__turretYaw, self.__gunPitch), markerPos, True, ) self.__updateTurretMatrix(self.__turretYaw, SERVER_TICK_LENGTH) self.__updateGunMatrix(self.__gunPitch, SERVER_TICK_LENGTH) self.__markerInfo = (markerPos, markerDir, markerSize)
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)
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 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']))
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
def setShotPosition(self, vehicleID, shotPos, shotVec, dispersionAngle, forceValueRefresh=False): if self.__clientMode and not self.__showServerMarker and not forceValueRefresh: return else: self.__dispersionAngles[0] = dispersionAngle if not self.__clientMode and VehicleGunRotator.USE_LOCK_PREDICTION: lockEnabled = BigWorld.player().inputHandler.getAimingMode( AIMING_MODE.TARGET_LOCK) if lockEnabled: predictedTargetPos = self.predictLockedTargetShotPoint() if predictedTargetPos is None: return dirToTarget = predictedTargetPos - shotPos dirToTarget.normalise() shotDir = Math.Vector3(shotVec) shotDir.normalise() if shotDir.dot(dirToTarget) > 0.0: return markerPos, markerDir, markerSize, idealMarkerSize, collData = self.__getGunMarkerPosition( shotPos, shotVec, self.__dispersionAngles) replayCtrl = BattleReplay.g_replayCtrl if replayCtrl.isRecording: replayCtrl.setGunMarkerParams(markerSize, markerPos, markerDir) if self.__clientMode and self.__showServerMarker: self._avatar.inputHandler.updateGunMarker2( markerPos, markerDir, (markerSize, idealMarkerSize), SERVER_TICK_LENGTH, collData) if not self.__clientMode or forceValueRefresh: self.__lastShotPoint = markerPos self._avatar.inputHandler.updateGunMarker( markerPos, markerDir, (markerSize, idealMarkerSize), SERVER_TICK_LENGTH, collData) self.__turretYaw, self.__gunPitch = getShotAngles( self._avatar.getVehicleDescriptor(), self._avatar.getOwnVehicleStabilisedMatrix(), (self.__turretYaw, self.__gunPitch), markerPos, adjust=True, overrideGunPosition=self.__gunPosition) turretYawLimits = self.__getTurretYawLimits() closestLimit = self.__isOutOfLimits(self.__turretYaw, turretYawLimits) if closestLimit is not None: self.__turretYaw = closestLimit self.__updateTurretMatrix(self.__turretYaw, SERVER_TICK_LENGTH) self.__updateGunMatrix(self.__gunPitch, SERVER_TICK_LENGTH) self.__markerInfo = (markerPos, markerDir, markerSize) return
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 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)
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)
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
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)
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']))
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)
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 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
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, *args): player = BigWorld.player() descr = player.vehicleTypeDescriptor if not spgAim.enabled: if spgAim._lastModeWasSniper: if BigWorld._ba_config['spg']['ignoreObstacles']: turretYaw, gunPitch = getShotAngles( descr, player.getOwnVehicleStabilisedMatrix(), (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, *args)
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 StrategicAimingSystem_updateMatrix(self): global gSPGSniperEnabled if not gSPGSniperEnabled: if self._lastModeWasSniper: self._StrategicAimingSystem__planePosition.x = self._matrix.translation.x self._StrategicAimingSystem__planePosition.y = 0.0 self._StrategicAimingSystem__planePosition.z = self._matrix.translation.z oldStrategicAimingSystem_updateMatrix(self) self._lastModeWasSniper = False return player = BigWorld.player() descr = player.vehicleTypeDescriptor bb = BigWorld.player().arena.arenaType.boundingBox pos2D = _clampPoint2DInBox2D( bb[0] - Math.Vector2(200.0, 200.0), bb[1] + Math.Vector2(200.0, 200.0), Math.Vector2(self._StrategicAimingSystem__planePosition.x, self._StrategicAimingSystem__planePosition.z)) self._StrategicAimingSystem__planePosition.x = pos2D[0] self._StrategicAimingSystem__planePosition.z = pos2D[1] playerPos = player.getOwnVehiclePosition() if not self._lastModeWasSniper: 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) self._StrategicAimingSystem__planePosition.y = 0.0 if collPoint is None else collPoint[ 0][1] self._initialDistance = (Math.Vector3( self._StrategicAimingSystem__planePosition.x, playerPos.y, self._StrategicAimingSystem__planePosition.z) - playerPos).length + 0.01 distance = ( Math.Vector3(self._StrategicAimingSystem__planePosition.x, playerPos.y, self._StrategicAimingSystem__planePosition.z) - playerPos).length + 0.01 heightFactor = distance / self._initialDistance turretYaw, gunPitch = getShotAngles( descr, player.getOwnVehicleMatrix(), (0, 0), Math.Vector3( self._StrategicAimingSystem__planePosition.x, playerPos.y * (1.0 - heightFactor) + self._StrategicAimingSystem__planePosition.y * heightFactor, self._StrategicAimingSystem__planePosition.z), True) #gunPitchLimits = calcPitchLimitsFromDesc(turretYaw, descr.gun['pitchLimits']) currentGunMat = AimingSystems.getPlayerGunMat(turretYaw, gunPitch) clientShotStart = currentGunMat.translation clientShotVec = currentGunMat.applyVector( Math.Vector3(0, 0, descr.shot['speed'])) self._matrix.translation, self._shellVelocity = _getGunMarkerPosition( clientShotStart, clientShotVec) self._lastModeWasSniper = True