def ally_silouhette(self):
        if self.__enableRenderModel:
            try:
                BigWorld.wgSetEdgeDetectColors((self.__color, self.__enemyhigh, self.__allyhigh))
                player = BigWorld.player()
                if player is not None:
                    if hasattr(player, 'isOnArena'):
                        curCtrl = getattr(getattr(BigWorld.player(), 'inputHandler', None), 'ctrl', None)
                        if player.isOnArena:
                            for v in BigWorld.entities.values():
                                if isinstance(v, Vehicle):
                                    if v.isAlive() and v.isStarted:
                                        if v.publicInfo['team'] is BigWorld.player().team:
                                            target = BigWorld.target()
                                            if BigWorld.entity(BigWorld.player().playerVehicleID) is not None and BigWorld.entity(v.id) is not None:
                                                distance = (BigWorld.entity(BigWorld.player().playerVehicleID).position - BigWorld.entity(v.id).position).length
                                            else:
                                                distance = 1
                                            if target is not None and target.id == v.id:
                                                BigWorld.wgDelEdgeDetectEntity(v)
                                                BigWorld.wgAddEdgeDetectEntity(v, 2, False)
                                            elif int(v.id) != int(BigWorld.player().playerVehicleID) and distance <= self.__distancevalue or self.__sniperonly == True and not isinstance(curCtrl, SniperControlMode):
                                                BigWorld.wgDelEdgeDetectEntity(v)
                                            elif int(v.id) == int(BigWorld.player().playerVehicleID):
                                                continue
                                            else:
                                                BigWorld.wgDelEdgeDetectEntity(v)
                                                BigWorld.wgAddEdgeDetectEntity(v, 0, False)
                                    else:
                                        BigWorld.wgDelEdgeDetectEntity(v)

            except TypeError as err:
                print ('[ally_silouhette] Error: ', err)

        return
 def __playFirstFromQueue(self, queueNum):
     if not self.__queues[queueNum]:
         self.__playingEvents[queueNum] = None
         return
     else:
         queueItem = self.__queues[queueNum][0]
         del self.__queues[queueNum][0]
         checkCooldown = queueItem.eventName not in self.__eventsCooldowns or not self.__eventsCooldowns[
             queueItem.eventName]
         checkVehicle = queueItem.vehicleID is None or BigWorld.entity(
             queueItem.vehicleID) is not None
         checkFunction = queueItem.checkFn() if queueItem.checkFn else True
         if checkFunction and checkVehicle and checkCooldown:
             vehicle = BigWorld.entity(
                 queueItem.vehicleID
             ) if queueItem.vehicleID is not None else None
             boundVehicle = BigWorld.entity(
                 queueItem.boundVehicleID
             ) if queueItem.boundVehicleID is not None else None
             position = vehicle.position if vehicle else queueItem.position
             self.__playingEvents[queueNum] = self.PlayingEvent(
                 queueItem.eventName, vehicle, position, boundVehicle,
                 position is None)
             self.onPlayEvent(queueItem.eventName)
         else:
             self.__playFirstFromQueue(queueNum)
         return
def new_autoAim(target, init=False):
    global autoAimVehicle
    prevAutoAimVehicleID = 0
    if not init:
        prevAutoAimVehicleID = player._PlayerAvatar__autoAimVehID
        old_autoAim(target)
    if prevAutoAimVehicleID != 0:
        removeOutline(autoAimVehicle)
    autoAimVehicleID = player._PlayerAvatar__autoAimVehID
    enabled = autoAimVehicleID != 0
    if enabled:
        autoAimVehicle = BigWorld.entity(autoAimVehicleID)
        if config.get('use_target_as_text', True):
            indicator.setText(autoAimVehicle.typeDescriptor.type.shortUserString[0:config.get('max_characters', 15) - 1])
    else:
        autoAimVehicle = None
    indicator.setVisible(enabled)
    if not init and prevAutoAimVehicleID == 0 and not enabled and config.get('snap_to_nearest', False):
        try:
            callers_frame = inspect.getouterframes(inspect.currentframe())[1]
            if callers_frame[3] == 'handleKeyEvent':
                callers_locals = inspect.getargvalues(callers_frame[0]).locals
                if callers_locals['cmdMap'].isFired(CommandMapping.CMD_CM_LOCK_TARGET_OFF, callers_locals['key']) and callers_locals['isDown']:
                    return
        except:
            pass

        if isinstance(player.inputHandler.ctrl, ArcadeControlMode):
            desiredShotPoint = player.inputHandler.ctrl.camera.aimingSystem.getThirdPersonShotPoint()
        else:
            desiredShotPoint = player.inputHandler.getDesiredShotPoint()
            if desiredShotPoint is None:
                MYLOG('No desiredShotPoint available - trying alternative')
                desiredShotPoint = player.gunRotator.markerInfo[0]
        if desiredShotPoint is None:
            MYLOG('No desiredShotPoint available')
        else:
            new_target = None
            distance_to_target = math.radians(config.get('snapping_angle_degrees', 7.5))
            vehicles = player.arena.vehicles
            v1norm = normalize(desiredShotPoint - playerVehicle.position)
            for vehicleID in enemies:
                vehicle = BigWorld.entity(vehicleID)
                if vehicle is not None and vehicle.isAlive():
                    v2norm = normalize(vehicle.position - playerVehicle.position)
                    distance = math.acos(v1norm.x * v2norm.x + v1norm.y * v2norm.y + v1norm.z * v2norm.z)
                    if distance < 0:
                        distance = -distance
                    if distance > math.pi:
                        distance = 2 * math.pi - distance
                    if distance < distance_to_target:
                        new_target = vehicle
                        distance_to_target = distance

            if new_target is not None:
                MYLOG('new target acquired at %f degrees' % math.degrees(distance_to_target))
                new_autoAim(new_target)
    if enabled:
        addOutline(autoAimVehicle)
    return
Example #4
0
 def __moveCameraTo(self, vehicleID, sourceVehicleID = None):
     vehicle = BigWorld.entity(vehicleID)
     if vehicle is None:
         if vehicleID == BigWorld.player().playerVehicleID:
             targetMatrix = BigWorld.player().getOwnVehicleMatrix()
             self.__setCameraSettings(targetMP=targetMatrix, pivotSettings=self.__savedPivotSettings, cameraDistance=self.__savedCameraDistance, yawPitch=self.__savedYawPitch)
             return True
         return False
     else:
         targetMatrix = vehicle.matrix
         self.__setCameraSettings(targetMP=targetMatrix, pivotSettings=self.__savedPivotSettings, cameraDistance=self.__savedCameraDistance, yawPitch=self.__savedYawPitch)
         if sourceVehicleID is not None:
             sourceVehicle = BigWorld.entity(sourceVehicleID)
             if sourceVehicle is not None:
                 self.__savedPivotSettings = self.__arcadeCamera.getPivotSettings()
                 self.__savedCameraDistance = self.__arcadeCamera.getCameraDistance()
                 self.__savedYawPitch = self.__arcadeCamera.angles
                 dir = Math.Matrix(vehicle.matrix).translation - Math.Matrix(sourceVehicle.matrix).translation
                 yaw = dir.yaw
                 pitch = dir.pitch + self.KILLER_VEHICLE_PITCH_OFFSET
                 if pitch > math.pi * 0.5:
                     pitch = math.pi * 0.5
                 if pitch < -math.pi * 0.5:
                     pitch = -math.pi * 0.5
                 self.__setCameraSettings(pivotSettings=self.KILLER_VEHICLE_CAMERA_PIVOT_SETTINGS, cameraDistance=self.KILLER_VEHICLE_CAMERA_DISTANCE, yawPitch=(yaw, pitch))
         return True
 def handleKey(self, isDown, key, mods):
     if not self.__enabled:
         return
     else:
         cmdMap = CommandMapping.g_instance
         isFired = cmdMap.isFired(CommandMapping.CMD_REQUEST_RECOVERY, key)
         if isFired and self.isVehicleAlive and not self.isObserver():
             if isDown and not self.isForcedGuiControlMode():
                 if self.__currentRevcoveryState() in (
                         None, RM_STATE.NOT_RECOVERING):
                     ownVehicle = BigWorld.entity(self.playerVehicleID)
                     ownVehicle.cell.recoveryMechanic_startRecovering()
                     if not self.__keyCheckCallback:
                         self.__keyCheckCallback = BigWorld.callback(
                             0.1, partial(self.__checkKey, key))
                 if self.__currentRevcoveryState(
                 ) == RM_STATE.TEMPORARILY_BLOCKED_FROM_RECOVERING:
                     activated, _, timerDuration, endOfTimer = self.__lastRecoveryArgs
                     self.guiSessionProvider.shared.feedback.setVehicleRecoveryState(
                         self.playerVehicleID, activated,
                         RM_STATE.TEMPORARILY_BLOCKED_RECOVER_TRY,
                         timerDuration, endOfTimer)
             elif not isDown:
                 if self.__currentRevcoveryState() == RM_STATE.RECOVERING:
                     ownVehicle = BigWorld.entity(self.playerVehicleID)
                     ownVehicle.cell.recoveryMechanic_stopRecovering()
                     if self.__keyCheckCallback:
                         BigWorld.cancelCallback(self.__keyCheckCallback)
                         self.__keyCheckCallback = None
             self.__recoveryRequested = True
         return
Example #6
0
 def __moveCameraTo(self, vehicleID, sourceVehicleID=None):
     vehicle = BigWorld.entity(vehicleID)
     if vehicle is None:
         if vehicleID == BigWorld.player().playerVehicleID:
             steadyMatrix = BigWorld.player().inputHandler.steadyVehicleMatrixCalculator
             targetMatrix = steadyMatrix.outputMProv
             self.__setCameraSettings(targetMP=targetMatrix, pivotSettings=self.__savedPivotSettings, cameraDistance=self.__savedCameraDistance, yawPitch=self.__savedYawPitch)
             return True
         return False
     else:
         targetMatrix = vehicle.matrix
         self.__setCameraSettings(targetMP=targetMatrix, pivotSettings=self.__savedPivotSettings, cameraDistance=self.__savedCameraDistance, yawPitch=self.__savedYawPitch)
         if sourceVehicleID is not None:
             sourceVehicle = BigWorld.entity(sourceVehicleID)
             if sourceVehicle is not None:
                 self.__savedPivotSettings = self.__arcadeCamera.getPivotSettings()
                 self.__savedCameraDistance = self.__arcadeCamera.getCameraDistance()
                 self.__savedYawPitch = self.__arcadeCamera.angles
                 direction = Math.Matrix(vehicle.matrix).translation - Math.Matrix(sourceVehicle.matrix).translation
                 yaw = direction.yaw
                 pitch = direction.pitch + self.KILLER_VEHICLE_PITCH_OFFSET
                 if pitch > math.pi * 0.5:
                     pitch = math.pi * 0.5
                 if pitch < -math.pi * 0.5:
                     pitch = -math.pi * 0.5
                 self.__setCameraSettings(pivotSettings=self.KILLER_VEHICLE_CAMERA_PIVOT_SETTINGS, cameraDistance=self.KILLER_VEHICLE_CAMERA_DISTANCE, yawPitch=(yaw, pitch))
         return True
Example #7
0
 def getPlayerTankValues(self):
     if self.player is None:
         self.player = BigWorld.player()
     playerVehicle = BigWorld.entity(self.playerVehicleID)
     if playerVehicle is None:
         playerVehicle = BigWorld.entity(
             BigWorld.player().getVehicleAttached().id)
     vTypeDesc = playerVehicle.typeDescriptor
     hullArmor = vTypeDesc.hull.primaryArmor
     self.front = hullArmor[0]
     self.side = hullArmor[1]
     # use standard front armor given by WoT as effective front armor in pre-battle to avoid errors with variables yet to be defined like gun marker position
     self.effFrontArmor = self.front
     if vTypeDesc.gun.turretYawLimits is not None:
         self.rightArc = abs(math.degrees(vTypeDesc.gun.turretYawLimits[0]))
         self.leftArc = abs(math.degrees(vTypeDesc.gun.turretYawLimits[1]))
         self.leftArc = float('%.1f' % self.leftArc)
         self.rightArc = float('%.1f' % self.rightArc)
         self.getClassWithTurretYawLimits(BigWorld.player().playerVehicleID)
     else:
         self.tankType = "Tank"
         self.rightArc = 0.0
         self.leftArc = 0.0
     utills.eDebug("tankType:", self.tankType, "front:", self.front,
                   " side:", self.side, " Left:", self.leftArc, " Right:",
                   self.rightArc)
    def find_autoaim_target(self):
        auto_aim_vehicle = property(lambda self_other: BigWorld.entities.get(self_other.__autoAimVehID, None))
        print('find_autoaim_target', auto_aim_vehicle)
        if auto_aim_vehicle is None and BigWorld.target() is not None:
            return BigWorld.target()
        player = BigWorld.player()
        vehicles = player.arena.vehicles
        camera_dir, camera_pos = cameras.getWorldRayAndPoint(0, 0)
        camera_dir.normalise()
        result_len = None
        las_vehicle = None
        min_radian = 100000.0
        for vId, vData in vehicles.items():
            if vData['team'] == player.team:
                continue
            vehicle = BigWorld.entity(vId)
            if vehicle is None or not vehicle.isStarted or not vehicle.isAlive():
                continue
            temp1, radian = self._calc_radian(vehicle.position, self.angle_autoaim) #1.289 градуса в радианах

            if not temp1 and temp1 is not None:
                continue
            length = self._calc_length(vehicle.position, BigWorld.player().position)
            if radian:
                if result_len is None:
                    result_len = length
                    las_vehicle = vehicle
                if radian < min_radian and result_len >= length:
                    min_radian = radian
                    las_vehicle = vehicle
        result = las_vehicle
        if result is not None:
            if BigWorld.wg_collideSegment(BigWorld.player().spaceID, BigWorld.entity(result.id).appearance.modelsDesc['gun']['model'].position, camera_pos, False) is None:
                return result
        return BigWorld.target()
Example #9
0
 def getVehicleHealth(vehicleID):
     if hasattr(BigWorld.entity(vehicleID), 'health'):
         vehicle = BigWorld.entity(vehicleID)
         return vehicle.health if vehicle.isCrewActive and vehicle.health >= 0 else 0
     else:
         vehicle = BigWorld.player().arena.vehicles.get(vehicleID)
         if vehicle is not None and vehicle['vehicleType'] is not None:
             return vehicle['vehicleType'].maxHealth
         return ''
Example #10
0
    def update(self):
        global printedVehicle
        self.vehicle = BigWorld.entity(self.vehicleID)
        if self.vehicle is not None:
            if self.vehicle.health > 0 and self.vehicle.isAlive():
                self.isAlive = True
        if self.isAlive is False or self.vehicle is None or (self.vehicle is not None and self.vehicle.health <= 0):
            print('[predictAim] enemy died or does not exists')
            self.hideVisible()
            return
        if not hasattr(BigWorld.player(), 'vehicleTypeDescriptor') or not hasattr(BigWorld.player(), 'gunRotator') or (hasattr(self.vehicle,"health") and self.vehicle.health <= 0):
            print('[predictAim] player has no vehicleTypeDescriptor or gunRotator OR enemy is has no health or health is lower/same as zero')
            self.hideVisible()
            return
        if self.modelDot is not None and self.modelDot._StaticObjectMarker3D__model:
            playerVehicleID = BigWorld.player().playerVehicleID
            if playerVehicleID:
                playerVehicle = BigWorld.entity(playerVehicleID)
                playerPosition = playerVehicle.model.node("hull").position
                self.vehicle = BigWorld.entity(self.vehicleID)
                shotSpeed = BigWorld.player().vehicleTypeDescriptor.shot.speed
                distance = playerPosition.flatDistTo(self.vehicle.model.node("hull").position)
                traveltime = distance / shotSpeed
                enemyCurrentSpeed = self.vehicle.speedInfo.value
                if self.lastSpeedValue is None or self.lastSpeedValue is enemyCurrentSpeed:
                    self.lastSpeedValue = enemyCurrentSpeed
                enemyCurrentSpeed = (enemyCurrentSpeed + self.lastSpeedValue) / 2
                self.lastSpeedValue = enemyCurrentSpeed
                centerFront = self.vehicle.model.node("hull").position

                cMin , cMax , _ = self.vehicle.getBounds(TankPartIndexes.CHASSIS)
                _ , hMax , _ = self.vehicle.getBounds(TankPartIndexes.HULL)
                hMax.y += cMax.y
                _ , tMax , _ =self.vehicle.getBounds(TankPartIndexes.TURRET)
                tMax.y += hMax.y
                cMax.y = tMax.y
                matrix = Matrix(self.vehicle.matrix)

                FRONT_RIGTH_BOTTOM = matrix.applyVector(Vector3(cMax.x , cMin.y , cMax.z )) + self.vehicle.position
                FRONT_LEFT_BOTTOM = matrix.applyVector(Vector3(cMin.x , cMin.y , cMax.z )) + self.vehicle.position
                centerFront = (FRONT_RIGTH_BOTTOM + FRONT_LEFT_BOTTOM)/2
                #print("[predictAim]: center Front pos: %s" % centerFront)
                #print("[predictAim]: hull: %s" % self.vehicle.model.node("hull").position)
                #print("[predictAim]: center Back pos: %s" % centerBack)

                travel_distance_0 = enemyCurrentSpeed[0] * traveltime
                #travel_distance_2 = enemyCurrentSpeed[2] * traveltime

                v = centerFront - self.vehicle.model.node("hull").position
                v3 = Vector3(v)
                #v3.normalise()
                predPos_test = self.vehicle.model.node("hull").position + (v3*travel_distance_0)
                tmp_veh = BigWorld.entity(self.vehicleID)
                predPos_test[1] = tmp_veh.model.node("hull").position[1]

                self.modelDot._StaticObjectMarker3D__model.position = predPos_test
                self.modelDot._StaticObjectMarker3D__model.visible = True
Example #11
0
def clearCollision(self):
    vEntityId = self._VehicleAppearance__vEntityId
    if getattr(self, 'collisionLoaded', False):
        for moduleName, moduleDict in self.modifiedModelsDesc.items():
            if moduleDict['model'] in tuple(BigWorld.entity(vEntityId).models):
                BigWorld.entity(vEntityId).delModel(moduleDict['model'])
                for motor in tuple(moduleDict['model'].motors):
                    moduleDict['model'].delMotor(motor)
    if hasattr(self, 'collisionTable'):
        del self.collisionTable
Example #12
0
def find_autoaimtarget(self):
    #AutoaimSelf._PlayerAvatar__autoAimVehID
    autoAimVehicle = property(
        lambda self: BigWorld.entities.get(self.__autoAimVehID, None))
    if autoAimVehicle is None and BigWorld.target() is not None:
        return BigWorld.target()
    player = BigWorld.player()
    vehicles = player.arena.vehicles
    cameraDir, cameraPos = cameras.getWorldRayAndPoint(0, 0)
    cameraDir.normalise()

    result = None
    result_len = None
    las_vehicle = None
    minRadian = 100000.0
    for vId, vData in vehicles.items():
        if vData['team'] == player.team:
            continue
        vehicle = BigWorld.entity(vId)
        if vehicle is None or not vehicle.isStarted or not vehicle.isAlive():
            continue
        temp1, Radian = calc_radian(vehicle.position, radians_angle_autoaim,
                                    minRadian)  #1.289 градуса в радианах

        if temp1 == False:
            continue
        len = cacl_lengh(vehicle.position, BigWorld.player().position)
        if Radian:
            debugs('%s, distance: %dm., Angle = %.2f degrees' %
                   (vehicle.id, len, math.degrees(Radian)))
            if result_len is None:
                result_len = len
                las_vehicle = vehicle
            if Radian < minRadian and result_len >= len:
                minRadian = Radian
                las_vehicle = vehicle
                debugs(
                    'Set priority: %s, distance: %dm., Angle = %.2f degrees' %
                    (las_vehicle.id, result_len, math.degrees(minRadian)))
    result = las_vehicle

    #if BigWorld.wg_collideSegment(BigWorld.player().spaceID, result.position, cameraPos,False) == None:
    #    debugs('get visible target: %s' % (result.id))
    #    return result
    if result is not None:
        if BigWorld.wg_collideSegment(
                BigWorld.player().spaceID,
                BigWorld.entity(
                    result.id).appearance.modelsDesc['gun']['model'].position,
                cameraPos, False) == None:
            debugs('get visible gun target: %s' % (result.id))
            return result
        debugs('target gun: %s not visible' % (result.id))
    return BigWorld.target()
Example #13
0
def new_onControlModeChanged(current, eMode, **args):
    global g_tundra
    old_onControlModeChanged(current, eMode, **args)
    if eMode == 'sniper':
        for id in g_vehicle_list:
            if id != g_focused_id:
                addEdge(BigWorld.entity(id))
    else:
        for id in g_vehicle_list:
            if id != g_focused_id:
                delEdge(BigWorld.entity(id))
Example #14
0
 def __checkKey(self, key, isFirstCheck=False):
     if not self.__keyCheckCallback:
         return
     else:
         if BigWorld.isKeyDown(key):
             if isFirstCheck:
                 ownVehicle = BigWorld.entity(self.playerVehicleID)
                 ownVehicle.cell.recoveryMechanic_startRecovering()
             self.__keyCheckCallback = BigWorld.callback(
                 1, partial(self.__checkKey, key))
         else:
             self.__keyCheckCallback = None
             if not isFirstCheck:
                 ownVehicle = BigWorld.entity(self.playerVehicleID)
                 ownVehicle.cell.recoveryMechanic_stopRecovering()
         return
Example #15
0
 def catch(self):
     # noinspection PyProtectedMember
     if self.player._PlayerAvatar__autoAimVehID: return
     if BigWorld.target() is not None: return
     if self.player.isObserver(): return
     playerPosition = self.player.getOwnVehiclePosition()
     minRadian = 100000.0
     result = None
     result_len = None
     for vId, vData in self.player.arena.vehicles.iteritems():
         if vData['team'] != self.player.team and vData['isAlive']:
             vehicle = BigWorld.entity(vId)
             if vehicle is not None and vehicle.isStarted and vehicle.isAlive(
             ):
                 radian = self.calc_radian(
                     vehicle.position,
                     self.angle)  # 1.289 градуса в радианах
                 if radian:
                     length = Math.Vector3(vehicle.position -
                                           playerPosition).length
                     if result_len is None:
                         result_len = length
                         result = vehicle
                     if radian < minRadian and result_len >= length:
                         minRadian = radian
                         result = vehicle
     if config.data['catchHiddenTarget']:
         self.player.autoAim(result)
         return result if result is not None else None
     if result is not None and BigWorld.wg_collideSegment(
             self.player.spaceID, result.position,
             cameras.getWorldRayAndPoint(0, 0)[1], 128) is None:
         self.player.autoAim(result)
         return result if result is not None else None
     return
Example #16
0
def onVehicleKilled(targetID, atackerID, *args):
    g_vehicle_list.remove(targetID)
    vehicle = BigWorld.entity(targetID)
    if vehicle and vehicle.isStarted and not vehicle.isPlayer:
        if vehicle.publicInfo['team'] is not BigWorld.player().team:
            if isSniperMode():
                delEdge(vehicle)
Example #17
0
    def calc_marker_pos(self, gun_rotator, shot_pos, shot_vector):
        marker_pos, marker_direction, marker_size, ideal_marker_size, coll_data = gun_rotator._VehicleGunRotator__getGunMarkerPosition(
            shot_pos, shot_vector,
            gun_rotator._VehicleGunRotator__dispersionAngles)
        gun_rotator._VehicleGunRotator__avatar.inputHandler.updateGunMarker2(
            marker_pos, marker_direction, (marker_size, ideal_marker_size),
            SERVER_TICK_LENGTH, coll_data)
        gun_rotator._VehicleGunRotator__lastShotPoint = marker_pos
        gun_rotator._VehicleGunRotator__avatar.inputHandler.updateGunMarker(
            marker_pos, marker_direction, (marker_size, ideal_marker_size),
            SERVER_TICK_LENGTH, coll_data)
        gun_rotator._VehicleGunRotator__markerInfo = (marker_pos,
                                                      marker_direction,
                                                      marker_size)

        vehicle = BigWorld.entity(
            gun_rotator._VehicleGunRotator__avatar.playerVehicleID)
        vehicle_descr = vehicle.typeDescriptor

        gun_rotator._VehicleGunRotator__turretYaw, gun_rotator._VehicleGunRotator__gunPitch = decodeGunAngles(
            vehicle.gunAnglesPacked,
            vehicle_descr.gun['pitchLimits']['absolute'])
        gun_rotator._VehicleGunRotator__updateTurretMatrix(
            gun_rotator._VehicleGunRotator__turretYaw, SERVER_TICK_LENGTH)
        gun_rotator._VehicleGunRotator__updateGunMatrix(
            gun_rotator._VehicleGunRotator__gunPitch, SERVER_TICK_LENGTH)
        return
 def __onFakeShadowLoaded(self, resourceRefs):
     modelName = _CFG['shadow_model_name']
     fakeShadowModel = None
     if modelName not in resourceRefs.failedIDs and resourceRefs.has_key(
             modelName):
         fakeShadowModel = resourceRefs[modelName]
     if fakeShadowModel is None:
         LOG_ERROR('Could not load model %s' % modelName)
         return
     else:
         shadowProxyNodes = [
             udo for udo in BigWorld.userDataObjects.values()
             if isinstance(udo, TankHangarShadowProxy.TankHangarShadowProxy)
         ]
         if len(shadowProxyNodes) == 1:
             shadowProxy = shadowProxyNodes[0]
             shadowXFormPosition = shadowProxy.position
             shadowXFormOrientation = (shadowProxy.roll, shadowProxy.pitch,
                                       shadowProxy.yaw)
         else:
             LOG_DEBUG('Too many TankHangarShadowProxies? Or not enough.')
             return
         self.__fakeShadowId = BigWorld.createEntity(
             'OfflineEntity', self.__spaceId, 0, shadowXFormPosition,
             shadowXFormOrientation, dict())
         entity = BigWorld.entity(self.__fakeShadowId)
         entity.model = fakeShadowModel
         entity.model.position = shadowProxy.position
         entity.model.yaw = shadowProxy.yaw
         self.modifyFakeShadowScale(self.__fakeShadowScale)
         self.modifyFakeShadowAsset(self.__fakeShadowAsset)
         return
Example #19
0
 def __cameraUpdate(self):
     curTime = BigWorld.time()
     deltaTime = curTime - self.__prevTime
     self.__prevTime = curTime
     if not self.__autoUpdateDxDyDz.x == self.__autoUpdateDxDyDz.y == self.__autoUpdateDxDyDz.z == 0.0:
         self.__rotateAndZoom(self.__autoUpdateDxDyDz.x, self.__autoUpdateDxDyDz.y, self.__autoUpdateDxDyDz.z)
     self.__aimingSystem.update(deltaTime)
     localTransform, impulseTransform = self.__updateOscillators(deltaTime)
     ownVehicle = BigWorld.entity(BigWorld.player().playerVehicleID)
     if ownVehicle is not None and ownVehicle.isStarted and ownVehicle.appearance.isUnderwater:
         self.__onChangeControlMode()
         return 0.0
     else:
         aimMatrix = cameras.getAimMatrix(*self.__defaultAimOffset)
         camMat = Matrix(aimMatrix)
         rodMat = mathUtils.createTranslationMatrix(-self.__dynamicCfg['pivotShift'])
         antiRodMat = mathUtils.createTranslationMatrix(self.__dynamicCfg['pivotShift'])
         camMat.postMultiply(rodMat)
         camMat.postMultiply(localTransform)
         camMat.postMultiply(antiRodMat)
         camMat.postMultiply(self.__aimingSystem.matrix)
         camMat.invert()
         self.__cam.set(camMat)
         replayCtrl = BattleReplay.g_replayCtrl
         if replayCtrl.isPlaying and replayCtrl.isControllingCamera:
             aimOffset = replayCtrl.getAimClipPosition()
             binocularsOffset = aimOffset
         else:
             aimOffset = self.__calcAimOffset(impulseTransform)
             binocularsOffset = self.__calcAimOffset()
             if replayCtrl.isRecording:
                 replayCtrl.setAimClipPosition(aimOffset)
         self.__aim.offset((aimOffset.x, aimOffset.y))
         self.__binoculars.setMaskCenter(binocularsOffset.x, binocularsOffset.y)
         return 0.0
def new_autoAim(target, init = False):
    prevAutoAimVehicle = None
    if not init:
        prevAutoAimVehicle = BigWorld.player().autoAimVehicle
        old_autoAim(target)
    autoAimVehicle = BigWorld.player().autoAimVehicle
    enabled = not autoAimVehicle is None
    #MYLOGLIVE("autoAimVehicle = %s" % (not autoAimVehicle is None))
    if enabled and config.get("use_target_as_text", False):
        indicator.setText(autoAimVehicle.typeDescriptor.type.userString)
    indicator.setVisible(enabled)
    if not init and prevAutoAimVehicle is None and not enabled and config.get("snap_to_nearest", False):
        player = BigWorld.player()
        source = player.inputHandler.getDesiredShotPoint()
        new_target = None
        distance_to_target = 10000
        vehicles = player.arena.vehicles
        for vehicleID, desc in vehicles.items():
            if player.team is not vehicles[vehicleID]['team'] and desc['isAlive'] == True:
                entity = BigWorld.entity(vehicleID)
                if not entity is None:
                    vehicle = BigWorld.entities[vehicleID]
                    distance = source.flatDistTo(vehicle.position)
                    if distance < distance_to_target:
                        new_target = vehicle
                        distance_to_target = distance
        if not new_target is None:
            new_autoAim(new_target)
Example #21
0
def findWheelNodes(vehicleID, place):
    nodeList = []
    nodeNamesList = []
    vEntity = BigWorld.entity(vehicleID)
    vDesc = vEntity.typeDescriptor
    chassisSource = vDesc.chassis.models.undamaged
    modelSec = ResMgr.openSection(chassisSource)
    if modelSec is None:
        print chassisSource
        return [], []
    sourceSecStr = modelSec['nodefullVisual'].asString
    sourceSec = ResMgr.openSection(sourceSecStr + '.visual')
    if sourceSec is None:
        sourceSec = ResMgr.openSection(sourceSecStr + '.visual_processed')
    if sourceSec is None:
        print 'LampLights: visual not found for %s' % chassisSource
        return [], []
    for template in ('W_%s' % place, 'WD_%s' % place):
        wheelsCount = 0
        while True:
            restoreMat = Math.Matrix()
            transMat = nodeWatcher(sourceSec, template + str(wheelsCount))
            if transMat is not None:
                restoreMat.setTranslate(transMat.translation)
                nodeList.append(restoreMat)
                nodeNamesList.append(template + str(wheelsCount))
                wheelsCount += 1
            else:
                break
    return [nodeList, nodeNamesList]
 def getClassWithTurretYawLimits(self, vehicleID):
     vehicle = BigWorld.entity(vehicleID)
     vehicleClass = vehicle and tuple(vehicle.typeDescriptor.type.tags & items.vehicles.VEHICLE_CLASS_TAGS)[0]
     if vehicleClass == "SPG":
         self.tankType = "SPG"
     else:
         self.tankType = "TD"
 def __destroy(self):
     LOG_DEBUG('Hangar successfully destroyed.')
     if self.__cam == BigWorld.camera():
         self.__cam.spaceID = 0
         BigWorld.camera(None)
         BigWorld.worldDrawEnabled(False)
     self.__cam = None
     self.__loadingStatus = 0.0
     if self.__vAppearance is not None:
         self.__vAppearance.destroy()
         self.__vAppearance = None
     self.__onLoadedCallback = None
     self.__boundingRadius = None
     entity = None if self.__vEntityId is None else BigWorld.entity(self.__vEntityId)
     BigWorld.SetDrawInflux(False)
     MapActivities.g_mapActivities.stop()
     if self.__spaceId is not None and BigWorld.isClientSpace(self.__spaceId):
         if self.__spaceMappingId is not None:
             BigWorld.delSpaceGeometryMapping(self.__spaceId, self.__spaceMappingId)
         BigWorld.clearSpace(self.__spaceId)
         BigWorld.releaseSpace(self.__spaceId)
     self.__spaceMappingId = None
     self.__spaceId = None
     if entity is None or not entity.inWorld:
         return
     else:
         BigWorld.destroyEntity(self.__vEntityId)
         self.__vEntityId = None
         BigWorld.wg_disableSpecialFPSMode()
         if hasattr(BigWorld.player(), 'inputHandler') and self.__savedInputHandler is not None:
             BigWorld.player().inputHandler = self.__savedInputHandler
             g_hangarInputHandler.hangarSpace = None
             self.__savedInputHandler = None
         return
Example #24
0
    def __doFinalSetup(self, buildIdx, model, delModel):
        if delModel:
            BigWorld.delModel(model)
        if model.attached:
            BigWorld.callback(
                0.0, partial(self.__doFinalSetup, buildIdx, model, False))
            return
        elif buildIdx != self.__curBuildInd:
            return
        else:
            entity = BigWorld.entity(self.__vEntityId)
            if entity:
                for m in self.__models:
                    m.visible = True
                    m.visibleAttachments = True

                for sticker, alpha in self.__stickers:
                    sticker.setAlphas(alpha, alpha)

                entity.model = model
                entity.model.delMotor(entity.model.motors[0])
                entity.model.addMotor(
                    BigWorld.Servo(
                        _createMatrix(_CFG['v_scale'], _CFG['v_start_angles'],
                                      _CFG['v_start_pos'])))
                if self.__onLoadedCallback is not None:
                    self.__onLoadedCallback()
                    self.__onLoadedCallback = None
                self.updateCamouflage()
                if self.__smCb is None:
                    self.__setupHangarShadowMap()
            if self.__vDesc is not None and 'observer' in self.__vDesc.type.tags:
                model.visible = False
                model.visibleAttachments = False
            return
    def calc_marker_pos(self, gun_rotator, shot_pos, shot_vector, dispersion_angle, shot_point):
        gun_rotator._VehicleGunRotator__dispersionAngle = dispersion_angle
        if shot_point is None:
            marker_pos, marker_direction, marker_size, coll_data = gun_rotator._VehicleGunRotator__getGunMarkerPosition(shot_pos, shot_vector, dispersion_angle)
            gun_rotator._VehicleGunRotator__avatar.inputHandler.updateGunMarker2(marker_pos, marker_direction, marker_size, SERVER_TICK_LENGTH, coll_data)
            gun_rotator._VehicleGunRotator__lastShotPoint = marker_pos
            gun_rotator._VehicleGunRotator__avatar.inputHandler.updateGunMarker(marker_pos, marker_direction, marker_size, SERVER_TICK_LENGTH, coll_data)
            gun_rotator._VehicleGunRotator__markerInfo = (marker_pos, marker_direction, marker_size)
            self.coll_data = coll_data
        else:
            gun_rotator._VehicleGunRotator__avatar.inputHandler.updateGunMarker2(shot_point, gun_rotator._VehicleGunRotator__markerInfo[1], gun_rotator._VehicleGunRotator__markerInfo[2],
                SERVER_TICK_LENGTH, self.coll_data)
            gun_rotator._VehicleGunRotator__lastShotPoint = shot_point
            gun_rotator._VehicleGunRotator__avatar.inputHandler.updateGunMarker(shot_point, gun_rotator._VehicleGunRotator__markerInfo[1], gun_rotator._VehicleGunRotator__markerInfo[2],
                SERVER_TICK_LENGTH, self.coll_data)
            gun_rotator._VehicleGunRotator__markerInfo = (shot_point, gun_rotator._VehicleGunRotator__markerInfo[1], gun_rotator._VehicleGunRotator__markerInfo[2])

        vehicle = BigWorld.entity(gun_rotator._VehicleGunRotator__avatar.playerVehicleID)
        vehicle_descr = vehicle.typeDescriptor

        gun_rotator._VehicleGunRotator__turretYaw, gun_rotator._VehicleGunRotator__gunPitch = decodeGunAngles(vehicle.gunAnglesPacked, vehicle_descr.gun['pitchLimits']['absolute'])
        gun_rotator._VehicleGunRotator__updateTurretMatrix(gun_rotator._VehicleGunRotator__turretYaw, SERVER_TICK_LENGTH)
        gun_rotator._VehicleGunRotator__updateGunMatrix(gun_rotator._VehicleGunRotator__gunPitch, SERVER_TICK_LENGTH)
        self.serverTurretYaw = gun_rotator._VehicleGunRotator__turretYaw
        self.serverGunPitch = gun_rotator._VehicleGunRotator__gunPitch
        self.serverReceiveTime = BigWorld.time()
        return
    def __doFinalSetup(self, buildIdx, model, delModel):
        if delModel:
            BigWorld.delModel(model)
        if model.attached:
            self.__setupModelCb = BigWorld.callback(0.0, partial(self.__doFinalSetup, buildIdx, model, False))
            return
        else:
            self.__setupModelCb = None
            if buildIdx != self.__curBuildInd:
                return
            entity = BigWorld.entity(self.__vEntityId)
            if entity:
                for m in self.__models:
                    m.visible = True
                    m.visibleAttachments = True

                self.__vehicleStickers.show = True
                entity.model = model
                entity.model.delMotor(entity.model.motors[0])
                entity.model.addMotor(BigWorld.Servo(_createMatrix(_CFG['v_scale'], _CFG['v_start_angles'], _CFG['v_start_pos'])))
                self.__isLoaded = True
                if self.__onLoadedCallback is not None:
                    self.__onLoadedCallback()
                    self.__onLoadedCallback = None
                self.updateCamouflage()
                self.updateRepaint()
                if self.__smCb is None:
                    self.__setupHangarShadowMap()
            if self.__vDesc is not None and 'observer' in self.__vDesc.type.tags:
                model.visible = False
                model.visibleAttachments = False
            return
Example #27
0
    def start(self):
        g_guiResetters.add(self.__onRecreateDevice)
        import aims
        aims.clearState()
        ownVehicle = BigWorld.entity(BigWorld.player().playerVehicleID)
        vehTypeDesc = ownVehicle.typeDescriptor.type
        self.__isSPG = 'SPG' in vehTypeDesc.tags
        self.__isATSPG = 'AT-SPG' in vehTypeDesc.tags
        for control in self.__ctrls.itervalues():
            control.create()

        g_cursorDelegator.detachCursor()
        if not self.__curCtrl.isManualBind():
            BigWorld.player().positionControl.bindToVehicle(True)
        self.__curCtrl.enable(ctrlState=control_modes.dumpStateEmpty())
        self.onCameraChanged('arcade')
        tmp = self.__curCtrl.getPreferredAutorotationMode()
        if tmp is not None:
            self.__isAutorotation = tmp
            self.__prevModeAutorotation = True
        else:
            self.__isAutorotation = True
            self.__prevModeAutorotation = None
        BigWorld.player().enableOwnVehicleAutorotation(self.__isAutorotation)
        self.__targeting.enable(True)
        self.__isStarted = True
        self.__isGUIVisible = True
        self.__killerVehicleID = None
        arena = BigWorld.player().arena
        arena.onPeriodChange += self.__onArenaStarted
        from account_helpers.SettingsCore import g_settingsCore
        g_settingsCore.onSettingsChanged += self.__onSettingsChanged
        self.__onArenaStarted(arena.period)
        return
 def __destroy(self):
     LOG_DEBUG('Hangar successfully destroyed.')
     if self.__cam == BigWorld.camera():
         self.__cam.spaceID = 0
         BigWorld.camera(None)
         BigWorld.worldDrawEnabled(False)
     self.__cam = None
     self.__loadingStatus = 0.0
     if self.__vAppearance is not None:
         self.__vAppearance.destroy()
         self.__vAppearance = None
     self.__onLoadedCallback = None
     self.__boundingRadius = None
     g_keyEventHandlers.remove(self.handleKeyEvent)
     g_mouseEventHandlers.remove(self.handleMouseEventGlobal)
     entity = None if self.__vEntityId is None else BigWorld.entity(self.__vEntityId)
     BigWorld.SetDrawInflux(False)
     MapActivities.g_mapActivities.stop()
     if self.__spaceId is not None and BigWorld.isClientSpace(self.__spaceId):
         if self.__spaceMappingId is not None:
             BigWorld.delSpaceGeometryMapping(self.__spaceId, self.__spaceMappingId)
         BigWorld.clearSpace(self.__spaceId)
         BigWorld.releaseSpace(self.__spaceId)
     self.__spaceMappingId = None
     self.__spaceId = None
     if entity is None or not entity.inWorld:
         return
     BigWorld.destroyEntity(self.__vEntityId)
     self.__vEntityId = None
     BigWorld.wg_disableSpecialFPSMode()
     g_postProcessing.disable()
    def update(self, vehicleID, ticker):
        vehicle = BigWorld.entity(vehicleID)
        if vehicle is not None:
            states = []
            health = vehicle.health
            if self.__health != health:
                self.__health = health
                states.append((VEHICLE_VIEW_STATE.HEALTH, health))
            if vehicle.isStarted:
                try:
                    speed = vehicle.filter.speedInfo.value[0]
                    fwdSpeedLimit, bckwdSpeedLimit = vehicle.typeDescriptor.physics[
                        'speedLimits']
                    speed = max(min(speed, fwdSpeedLimit), -bckwdSpeedLimit)
                    speed = int(speed * 3.6)
                    if self.__speed != speed:
                        self.__speed = speed
                        states.append((VEHICLE_VIEW_STATE.SPEED, speed))
                except (AttributeError, IndexError, ValueError):
                    LOG_CURRENT_EXCEPTION()
                    LOG_ERROR('Can not update speed. Stop')
                    ticker.stop()

            if not vehicle.isAlive():
                states.append((VEHICLE_VIEW_STATE.DESTROYED, None))
                ticker.stop()
        else:
            states = None
        return states
Example #30
0
def new_autoAim(target, init=False):
    prevAutoAimVehicle = None
    if not init:
        prevAutoAimVehicle = BigWorld.player().autoAimVehicle
        old_autoAim(target)
    autoAimVehicle = BigWorld.player().autoAimVehicle
    enabled = not autoAimVehicle is None
    #MYLOGLIVE("autoAimVehicle = %s" % (not autoAimVehicle is None))
    if enabled and config.get("use_target_as_text", False):
        indicator.setText(autoAimVehicle.typeDescriptor.type.userString)
    indicator.setVisible(enabled)
    if not init and prevAutoAimVehicle is None and not enabled and config.get(
            "snap_to_nearest", False):
        player = BigWorld.player()
        source = player.inputHandler.getDesiredShotPoint()
        new_target = None
        distance_to_target = 10000
        vehicles = player.arena.vehicles
        for vehicleID, desc in vehicles.items():
            if player.team is not vehicles[vehicleID]['team'] and desc[
                    'isAlive'] == True:
                entity = BigWorld.entity(vehicleID)
                if not entity is None:
                    vehicle = BigWorld.entities[vehicleID]
                    distance = source.flatDistTo(vehicle.position)
                    if distance < distance_to_target:
                        new_target = vehicle
                        distance_to_target = distance
        if not new_target is None:
            new_autoAim(new_target)
Example #31
0
def getModelDescInfo(vehicleID, vDesc, mode):
    currentTeam = 'enemy'
    if mode == 'battle':
        player = BigWorld.player()
        vehInfoVO = player.guiSessionProvider.getArenaDP().getVehicleInfo(
            vehicleID)
        playerName = vehInfoVO.player.name
        if vehicleID == player.playerVehicleID:
            currentTeam = 'player'
        elif vehInfoVO.team == player.team:
            currentTeam = 'ally'
    elif mode == 'hangar':
        currentTeam = g_config.currentTeam
        playerName = None
    else:
        return None, None
    xmlName = vDesc.name.split(':')[1].lower()
    modelDesc = g_config.findModelDesc(
        xmlName, currentTeam, isinstance(BigWorld.entity(vehicleID), HeroTank))
    if modelDesc is not None and vDesc.chassis.generalWheelsAnimatorConfig is not None:
        print g_config.ID + ':', (
            'WARNING: wheeled vehicles are NOT processed. At least until WG moves params processing out of Vehicular.'
        )
        if xmlName in modelDesc['whitelist']:
            modelDesc['whitelist'].remove(xmlName)
        g_config.modelsData['selected'][currentTeam].pop(xmlName, None)
        SystemMessages.pushMessage(
            g_config.i18n['UI_install_wheels_unsupported'],
            SystemMessages.SM_TYPE.Warning)
        modelDesc = None
    return modelDesc, playerName
Example #32
0
    def finishUp(self):
        try:
            BigWorld.setShimmerStyle(0)
        except:
            pass

        if hasattr(self, 'matID'):
            BigWorld.delMat(self.matID)
            del self.matID
        for matID, entry in self.victimList.items():
            BigWorld.delMat(matID)
            entID = entry[0]
            wasHit = entry[1]
            if not wasHit:
                ent = BigWorld.entity(entID)
                if ent:
                    try:
                        imfn = ent.shockImpact
                    except:
                        pass
                    else:
                        imfn(0, self.model.position)

        self.model = None
        self.effect = None
        try:
            BigWorld.setShimmerAlpha(None)
        except:
            pass

        return
 def removeVehicle(self):
     self.__boundingRadius = None
     self.__vAppearance.destroy()
     self.__vAppearance = _VehicleAppearance(self.__spaceId, self.__vEntityId)
     BigWorld.entity(self.__vEntityId).model = None
     self.__selectedEmblemInfo = None
     return
Example #34
0
def hookedActivateAlternateMode(self, pos=None, bByScroll=False):
    ownVehicle = BigWorld.entity(BigWorld.player().playerVehicleID)
    if ownVehicle is not None and ownVehicle.isStarted and avatar_getter.isVehicleBarrelUnderWater(
    ) or BigWorld.player().isGunLocked:
        return
    elif self._aih.isSPG and bByScroll:
        self._cam.update(0, 0, 0, False, False)
        if BattleReplay.isPlaying() and BigWorld.player().isGunLocked:
            mode = BattleReplay.g_replayCtrl.getControlMode()
            pos = BattleReplay.g_replayCtrl.getGunMarkerPos()
            equipmentID = BattleReplay.g_replayCtrl.getEquipmentId()
        else:
            mode = CTRL_MODE_NAME.SNIPER
            equipmentID = None
            if pos is None:
                pos = self.camera.aimingSystem.getDesiredShotPoint()
                if pos is None:
                    pos = self._gunMarker.getPosition()
        self._aih.onControlModeChanged(mode,
                                       preferredPos=pos,
                                       aimingMode=self._aimingMode,
                                       saveZoom=not bByScroll,
                                       equipmentID=equipmentID)
        return
    else:
        return hookActivateAlternateMode(self, pos, bByScroll)
    def update(self, vehicleID, ticker):
        vehicle = BigWorld.entity(vehicleID)
        if vehicle is not None:
            states = []
            health = vehicle.health
            if self.__health != health:
                self.__health = health
                states.append((VEHICLE_VIEW_STATE.HEALTH, health))
            if vehicle.isStarted:
                try:
                    speed = vehicle.filter.speedInfo.value[0]
                    fwdSpeedLimit, bckwdSpeedLimit = vehicle.typeDescriptor.physics['speedLimits']
                    speed = max(min(speed, fwdSpeedLimit), -bckwdSpeedLimit)
                    speed = int(speed * 3.6)
                    if self.__speed != speed:
                        self.__speed = speed
                        states.append((VEHICLE_VIEW_STATE.SPEED, speed))
                except (AttributeError, IndexError, ValueError):
                    LOG_CURRENT_EXCEPTION()
                    LOG_ERROR('Can not update speed. Stop')
                    ticker.stop()

            if not vehicle.isAlive():
                states.append((VEHICLE_VIEW_STATE.DESTROYED, None))
                ticker.stop()
        else:
            states = None
        return states
Example #36
0
 def __cameraUpdate(self):
     self.__autoUpdateCallbackId = BigWorld.callback(
         0.0, self.__cameraUpdate)
     ownVehicle = BigWorld.entity(BigWorld.player().playerVehicleID)
     if ownVehicle is not None and ownVehicle.isStarted and ownVehicle.appearance.isUnderwater:
         self.__onChangeControlMode()
         return
     else:
         self.__setupZoom(self.__dxdydz[2])
         self.__rotate(self.__dxdydz[0], self.__dxdydz[1])
         yawRotateMat = Math.Matrix()
         yawRotateMat.setRotateY(self.__angles[0])
         pitchRotateMat = Math.Matrix()
         pitchRotateMat.setRotateX(self.__angles[1])
         camMat = Math.Matrix()
         camMat.set(pitchRotateMat)
         camMat.postMultiply(self.__gunOffsetMat)
         camMat.postMultiply(yawRotateMat)
         camMat.postMultiply(self.__turretJointMat)
         if not self._USE_ALIGN_TO_VEHICLE:
             pos = camMat.applyToOrigin()
             dir = camMat.applyToAxis(2)
             camMat.lookAt(pos, dir, (0, 1, 0))
         else:
             camMat.invert()
         self.__cam.set(camMat)
         if not self.__autoUpdate:
             self.__dxdydz = [0, 0, 0]
         return
Example #37
0
 def _update(self):
     target = BigWorld.entity(self.__trackID)
     if target is not None:
         self.__updateDistance(target)
     else:
         self.__stopTrack()
     return
Example #38
0
    def start(self):
        g_guiResetters.add(self.__onRecreateDevice)
        import aims
        aims.clearState()
        ownVehicle = BigWorld.entity(BigWorld.player().playerVehicleID)
        vehTypeDesc = ownVehicle.typeDescriptor.type
        self.__isSPG = 'SPG' in vehTypeDesc.tags
        self.__isATSPG = 'AT-SPG' in vehTypeDesc.tags
        for control in self.__ctrls.itervalues():
            control.create()

        self.__addBattleCtrlListeners()
        g_cursorDelegator.detachCursor()
        if not self.__curCtrl.isManualBind():
            BigWorld.player().positionControl.bindToVehicle(True)
        self.__curCtrl.enable(ctrlState=control_modes.dumpStateEmpty())
        self.onCameraChanged('arcade')
        tmp = self.__curCtrl.getPreferredAutorotationMode()
        if tmp is not None:
            self.__isAutorotation = tmp
            self.__prevModeAutorotation = True
        else:
            self.__isAutorotation = True
            self.__prevModeAutorotation = None
        BigWorld.player().enableOwnVehicleAutorotation(self.__isAutorotation)
        self.__targeting.enable(True)
        self.__isStarted = True
        self.__isGUIVisible = True
        self.__killerVehicleID = None
        arena = BigWorld.player().arena
        arena.onPeriodChange += self.__onArenaStarted
        from account_helpers.settings_core.SettingsCore import g_settingsCore
        g_settingsCore.onSettingsChanged += self.__onSettingsChanged
        self.__onArenaStarted(arena.period)
Example #39
0
 def __cameraUpdate(self):
     self.__autoUpdateCallbackId = BigWorld.callback(0.0, self.__cameraUpdate)
     ownVehicle = BigWorld.entity(BigWorld.player().playerVehicleID)
     if ownVehicle is not None and ownVehicle.isStarted and ownVehicle.appearance.isUnderwater:
         self.__onChangeControlMode()
         return
     else:
         self.__setupZoom(self.__dxdydz[2])
         self.__rotate(self.__dxdydz[0], self.__dxdydz[1])
         yawRotateMat = Math.Matrix()
         yawRotateMat.setRotateY(self.__angles[0])
         pitchRotateMat = Math.Matrix()
         pitchRotateMat.setRotateX(self.__angles[1])
         camMat = Math.Matrix()
         camMat.set(pitchRotateMat)
         camMat.postMultiply(self.__gunOffsetMat)
         camMat.postMultiply(yawRotateMat)
         camMat.postMultiply(self.__turretJointMat)
         if not self._USE_ALIGN_TO_VEHICLE:
             pos = camMat.applyToOrigin()
             dir = camMat.applyToAxis(2)
             camMat.lookAt(pos, dir, (0, 1, 0))
         else:
             camMat.invert()
         self.__cam.set(camMat)
         if not self.__autoUpdate:
             self.__dxdydz = [0, 0, 0]
         return
Example #40
0
    def finishUp(self):
        try:
            BigWorld.setShimmerStyle(0)
        except:
            pass

        if hasattr(self, 'matID'):
            BigWorld.delMat(self.matID)
            del self.matID
        for matID, entry in self.victimList.items():
            BigWorld.delMat(matID)
            entID = entry[0]
            wasHit = entry[1]
            if not wasHit:
                ent = BigWorld.entity(entID)
                if ent:
                    try:
                        imfn = ent.shockImpact
                    except:
                        pass
                    else:
                        imfn(0, self.model.position)

        self.model = None
        self.effect = None
        try:
            BigWorld.setShimmerAlpha(None)
        except:
            pass

        return
Example #41
0
    def updatePlayerState(self, vehicleID, targets, userData=None):
        try:
            if self.active:
                data = {}

                if targets & INV.ALL_ENTITY:
                    entity = BigWorld.entity(vehicleID)

                    if targets & INV.MARKS_ON_GUN:
                        if entity and hasattr(entity, 'publicInfo'):
                            data['marksOnGun'] = entity.publicInfo.marksOnGun

                    if targets & INV.TURRET:
                        if entity and hasattr(entity, 'typeDescriptor'):
                            data[
                                'turretCD'] = entity.typeDescriptor.turret.compactDescr

                    if targets & INV.CREW_ACTIVE:
                        if entity and hasattr(entity, 'isCrewActive'):
                            data['isCrewActive'] = bool(entity.isCrewActive)

                if targets & (INV.ALL_VINFO | INV.ALL_VSTATS):
                    arenaDP = self.sessionProvider.getArenaDP()
                    if targets & INV.ALL_VSTATS:
                        vStatsVO = arenaDP.getVehicleStats(vehicleID)

                        if targets & INV.FRAGS:
                            data['frags'] = vStatsVO.frags

                if data:
                    self.call(XVM_BATTLE_COMMAND.AS_UPDATE_PLAYER_STATE,
                              vehicleID, data)
        except Exception, ex:
            err(traceback.format_exc())
Example #42
0
 def getTargetMProv(self):
     replayCtrl = BattleReplay.g_replayCtrl
     if replayCtrl.isPlaying and replayCtrl.playerVehicleID != 0:
         vehicleID = replayCtrl.playerVehicleID
     else:
         vehicleID = BigWorld.player().playerVehicleID
     return BigWorld.entity(vehicleID).matrix
 def locateCameraOnEmblem(self,
                          onHull,
                          emblemType,
                          emblemIdx,
                          relativeSize=0.5):
     self.__selectedEmblemInfo = (onHull, emblemType, emblemIdx,
                                  relativeSize)
     vEntity = BigWorld.entity(self.__currentEntityId)
     from HangarVehicle import HangarVehicle
     if not isinstance(vEntity, HangarVehicle):
         return False
     else:
         emblemPositionParams = vEntity.appearance.getEmblemPos(
             onHull, emblemType, emblemIdx)
         if emblemPositionParams is None:
             return False
         position = emblemPositionParams.position
         direction = emblemPositionParams.direction
         emblemPositionParams = emblemPositionParams.emblemDescription
         from gui.ClientHangarSpace import hangarCFG
         cfg = hangarCFG()
         emblemSize = emblemPositionParams[3] * cfg['v_scale']
         halfF = emblemSize / (2 * relativeSize)
         dist = halfF / math.tan(BigWorld.projection().fov / 2)
         self.setCameraLocation(position, Math.Vector3(0, 0,
                                                       0), direction.yaw,
                                -direction.pitch, dist, None, False)
         self.__locatedOnEmbelem = True
         return True
 def _update(self):
     target = BigWorld.entity(self.__trackID)
     if target is not None:
         self.__updateDistance(target)
     else:
         self.__stopTrack()
     return
 def moveVehicleTo(self, position):
     try:
         vehicle = BigWorld.entity(self.__vEntityId)
         vehicle.model.motors[0].signal = _createMatrix(
             _CFG['v_scale'], _CFG['v_start_angles'], position)
     except Exception:
         LOG_CURRENT_EXCEPTION()
 def getVehicleProxy(self, vehicleID):
     proxy = None
     if vehicleID in self.__visible:
         vehicle = BigWorld.entity(vehicleID)
         if vehicle is not None:
             proxy = vehicle.proxy
     return proxy
Example #47
0
 def getTargetMProv(self):
     replayCtrl = BattleReplay.g_replayCtrl
     if replayCtrl.isPlaying and replayCtrl.playerVehicleID != 0:
         vehicleID = replayCtrl.playerVehicleID
     else:
         vehicleID = BigWorld.player().playerVehicleID
     return BigWorld.entity(vehicleID).matrix
Example #48
0
 def removeVehicle(self, vehID):
     vehicle = BigWorld.entity(vehID)
     if vehicle is None:
         return
     else:
         vehicle.show(False)
         return
def find_autoaimtarget(self):
    #AutoaimSelf._PlayerAvatar__autoAimVehID
    autoAimVehicle = property(lambda self: BigWorld.entities.get(self.__autoAimVehID, None))
    if autoAimVehicle is None and BigWorld.target() is not None:
        return BigWorld.target()
    player = BigWorld.player()
    vehicles = player.arena.vehicles
    cameraDir, cameraPos = cameras.getWorldRayAndPoint(0, 0)
    cameraDir.normalise()


    
    result = None
    result_len = None
    las_vehicle = None
    minRadian = 100000.0
    for vId, vData in vehicles.items():
        if vData['team'] == player.team:
            continue
        vehicle = BigWorld.entity(vId)
        if vehicle is None or not vehicle.isStarted or not vehicle.isAlive():
            continue
        temp1, Radian = calc_radian(vehicle.position, radians_angle_autoaim, minRadian) #1.289 градуса в радианах
        
        if temp1 == False:
            continue
        len = cacl_lengh(vehicle.position, BigWorld.player().position)
        if Radian:
            debugs('%s, distance: %dm., Angle = %.2f degrees' % (vehicle.id, len, math.degrees(Radian)))
            if result_len is None:
                result_len = len
                las_vehicle = vehicle
            if Radian < minRadian and result_len >= len:
                minRadian = Radian
                las_vehicle = vehicle
                debugs('Set priority: %s, distance: %dm., Angle = %.2f degrees' % (las_vehicle.id, result_len, math.degrees(minRadian)))
    result = las_vehicle
    
    #if BigWorld.wg_collideSegment(BigWorld.player().spaceID, result.position, cameraPos,False) == None:
    #    debugs('get visible target: %s' % (result.id))
    #    return result
    if result is not None:
        if BigWorld.wg_collideSegment(BigWorld.player().spaceID, BigWorld.entity(result.id).appearance.modelsDesc['gun']['model'].position, cameraPos,False) == None:
            debugs('get visible gun target: %s' % (result.id))
            return result
        debugs('target gun: %s not visible' % (result.id))
    return BigWorld.target()
 def __initSounds(self):
     vehicle = BigWorld.entity(BigWorld.player().playerVehicleID)
     if vehicle is None:
         return
     else:
         if self.__isPlayerVehicle:
             if self.__typeDesc.engine['wwsoundPC'] != '':
                 self.__event = self.__typeDesc.engine['wwsoundPC']
             else:
                 self.__event = self.__typeDesc.engine['wwsound']
             if self.__typeDesc.chassis['wwsoundPC'] != '':
                 self.__eventC = self.__typeDesc.chassis['wwsoundPC']
             else:
                 self.__eventC = self.__typeDesc.chassis['wwsound']
         else:
             if self.__typeDesc.engine['wwsoundNPC'] != '':
                 self.__event = self.__typeDesc.engine['wwsoundNPC']
             else:
                 self.__event = self.__typeDesc.engine['wwsound']
             if self.__typeDesc.chassis['wwsoundNPC'] != '':
                 self.__eventC = self.__typeDesc.chassis['wwsoundNPC']
             else:
                 self.__eventC = self.__typeDesc.chassis['wwsound']
         nodeMatrix = Math.Matrix()
         nodeMatrix.set(self.__modelsDesc['hull']['model'].matrix)
         vehicleMProv = self.__modelsDesc['hull']['model'].matrix
         vehicleMatrix = Math.Matrix()
         vehicleMatrix.set(vehicleMProv)
         self.__engineSoundHP = 'engine' + str(self.__vehicleId)
         self.__movementSoundHP = 'tracks' + str(self.__vehicleId)
         self.__gunSoundHP = 'gun' + str(self.__vehicleId)
         nodeMatrix.set(self.__modelsDesc['gun']['model'].matrix)
         node = nodeMatrix.translation - vehicleMatrix.translation
         self.__gunSound = SoundGroups.g_instance.WWgetSoundObject(self.__gunSoundHP, vehicleMProv, node)
         self.__engineSound = SoundGroups.g_instance.WWgetSoundObject(self.__engineSoundHP, vehicleMProv)
         if self.__engineSound is None:
             print '!!!self.__engineSound is None'
             return
         self.__engineSound.setSwitch('SWITCH_ext_physics_state', 'SWITCH_ext_physics_state_off' if self.__physicsMode == VEHICLE_PHYSICS_MODE.STANDARD else 'SWITCH_ext_physics_state_on')
         if SoundGroups.ENABLE_ENGINE_N_TRACKS:
             self.__engineSound.play(self.__event)
         nodeMatrix.set(self.__modelsDesc['turret']['model'].matrix)
         node = nodeMatrix.translation - vehicleMatrix.translation
         self.__movementSound = SoundGroups.g_instance.WWgetSound(self.__eventC, self.__movementSoundHP, vehicleMProv, node)
         if self.__movementSound is None:
             print '!!!self.__movementSound is None'
             return
         self.__movementSound.setSwitch('SWITCH_ext_physics_state', 'SWITCH_ext_physics_state_off' if self.__physicsMode == VEHICLE_PHYSICS_MODE.STANDARD else 'SWITCH_ext_physics_state_on')
         if SoundGroups.ENABLE_ENGINE_N_TRACKS:
             self.__movementSound.play()
         self.__engineSound.setRTPC('RTPC_ext_vehicle_weight', self.__typeDesc.physics['weight'] / 1000)
         self.__movementSound.setRTPC('RTPC_ext_vehicle_weight', self.__typeDesc.physics['weight'] / 1000)
         self.__movementSound.setRTPC('RTPC_ext_engine_state', 0.0)
         self.__engineSound.setRTPC('RTPC_ext_engine_state', 0.0)
         self.__engineSound.setRTPC('RTPC_ext_physic_rpm_rel', 0.0)
         self.__movementSound.setRTPC('RTPC_ext_physic_rpm_rel', 0.0)
         self.__engineSound.setRTPC('RTPC_ext_physic_rpm_abs', 0.0)
         self.__movementSound.setRTPC('RTPC_ext_physic_rpm_abs', 0.0)
         return
Example #51
0
 def __showVehicleMarker(self, vehicleID, markerName):
     if vehicleID == avatar_getter.getPlayerVehicleID():
         return
     else:
         entity = BigWorld.entity(vehicleID)
         if entity is not None and entity.isStarted:
             self.__battleUI.vMarkersManager.showActionMarker(entity.marker, markerName)
         return
Example #52
0
 def __waitVehicle(self):
     vehicle = BigWorld.entity(BigWorld.player().playerVehicleID)
     if vehicle is not None and vehicle.isStarted:
         self.__waitVehicleCallbackId = None
     else:
         self.__waitVehicleCallbackId = BigWorld.callback(0.1, self.__waitVehicle)
         return
     self.__showVehicle(False)
Example #53
0
def testAllocate(spaceID):
    import items.vehicles
    vehicleDesc = items.vehicles.VehicleDescr(
        typeName=items.vehicles.g_cache.vehicle(0, 1).name)
    entityId = BigWorld.createEntity('OfflineEntity', spaceID, 0,
                                     BigWorld.camera().position, (0, 0, 0),
                                     dict())
    return CrashedTrackController(vehicleDesc, BigWorld.entity(entityId))
Example #54
0
 def addVehicleInfo(self, vInfo, arenaDP):
     vehicleID = vInfo.vehicleID
     if vehicleID != self.__playerVehicleID:
         active = self.__isVehicleActive(vehicleID)
         vehicle = BigWorld.entity(vehicleID)
         if vehicle:
             guiProps = g_sessionProvider.getCtx().getPlayerGuiProps(vehicleID, vInfo.team)
             self.__addOrUpdateVehicleMarker(vehicle.proxy, vInfo, guiProps, active)
Example #55
0
 def __startTrack(self, vehicleID):
     self._interval.stop()
     target = BigWorld.entity(vehicleID)
     if target is not None:
         self.__trackID = vehicleID
         self.__updateDistance(target)
         self._interval.start()
     return
Example #56
0
 def setTeamKiller(self, vID):
     ctx = g_sessionProvider.getCtx()
     if not ctx.isTeamKiller(vID=vID) or ctx.isSquadMan(vID=vID):
         return
     else:
         handle = getattr(BigWorld.entity(vID), 'marker', None)
         if handle is not None:
             self.invokeMarker(handle, 'setEntityName', [PLAYER_ENTITY_NAME.teamKiller.name()])
         return
Example #57
0
 def getVehicle(self):
     vehicle = BigWorld.entity(self.__vehicleID)
     if vehicle is None:
         return 
     if not vehicle.inWorld or not vehicle.isStarted:
         return 
     if not self._canAcceptVehicle(vehicle):
         return 
     return vehicle
Example #58
0
 def enable(self, **args):
     SoundGroups.g_instance.changePlayMode(0)
     self.__cam.enable(None, False, args.get('postmortemParams'))
     self.__aim.enable()
     player = BigWorld.player()
     self.__curVehicleID = player.playerVehicleID
     self.__cam.vehicleMProv = Math.Matrix(BigWorld.entity(self.__curVehicleID).matrix)
     self.__isEnabled = True
     return
Example #59
0
	def getVisibleVehicles(filterID=None, filterVehicle=None, skipPlayer=False):
		vehicles = list()
		for vehicleID in filter(filterID, BigWorld.player().arena.vehicles):
			if skipPlayer and vehicleID == BigWorld.player().playerVehicleID:
				continue
			vehicle = BigWorld.entity(vehicleID)
			if vehicle is not None and vehicle.isStarted:
				vehicles.append(vehicle)
		return filter(filterVehicle, vehicles)
Example #60
0
 def __onVehicleChanged(self, isStatic):
     if self.__waitObserverCallback and self.__observerVehicle:
         player = BigWorld.player()
         ownVehicle = BigWorld.entity(player.playerVehicleID)
         vehicle = player.getVehicleAttached()
         if vehicle != ownVehicle:
             self.__waitObserverCallback()
             self.__waitObserverCallback = None
     return