Example #1
1
    def __init__(self, data, position):
        super(_StaticObjectMarker3D, self).__init__()
        path = data.get('path')
        offset = data.get('offset', Math.Vector3(0, 0, 0))
        self.__model = None
        if path is not None:
            try:
                self.__model = BigWorld.Model(path)
                self.__model.position = Math.Vector3(position[:]) + offset
                self.__model.castsShadow = False
            except ValueError:
                LOG_CURRENT_EXCEPTION()
                LOG_ERROR('Model not found', path)
                return
            except AttributeError:
                LOG_CURRENT_EXCEPTION()
                return

            BigWorld.addModel(self.__model)
            action = data.get('action')
            if action is not None and len(action):
                try:
                    self.__model.action(action)()
                except ValueError:
                    LOG_ERROR('Action not found', path, action)

        return
Example #2
0
 def _callbackWrapper(self, requestType, callback, cooldown, *args):
     callbackID = self._waiters.pop(requestType, None)
     if callbackID is not None:
         BigWorld.cancelCallback(callbackID)
     self._cooldown.adjust(requestType, cooldown)
     callback(*args)
     return
Example #3
0
 def __getControlQuestion(self, usingGold = False):
     if usingGold:
         currencyFormatter = BigWorld.wg_getGoldFormat(long(self.controlNumber))
     else:
         currencyFormatter = BigWorld.wg_getIntegralFormat(long(self.controlNumber))
     question = makeHtmlString('html_templates:lobby/dialogs', 'vehicleSellQuestion', {'controlNumber': currencyFormatter})
     return question
Example #4
0
 def __setSoundMuted(self, isMuted):
     BigWorld.wg_setMovieSoundMuted(isMuted)
     SoundGroups.g_instance.enableAmbientAndMusic(isMuted)
     if isMuted:
         MusicController.g_musicController.play(MusicController.MUSIC_EVENT_LOBBY)
     else:
         MusicController.g_musicController.stop()
Example #5
0
    def __devSellInvalidVehicle(self, vehInvID, callback):

        def response(code):
            LOG_WARNING('Invalid vehicle selling result', vehInvID, code)
            callback(code >= 0)

        BigWorld.player().inventory.sellVehicle(vehInvID, True, [], [], response)
Example #6
0
    def onLogoff(self, arg):
        import BigWorld

        def logOff():
            g_appLoader.goToLoginByRQ()

        BigWorld.callback(0.1, logOff)
 def __updateAim(self):
     if self.getPlaybackSpeedIdx() == 0:
         player = BigWorld.player()
         if isPlayerAvatar():
             if player.inputHandler.aim is not None:
                 player.inputHandler.aim._update()
             BigWorld.callback(0, self.__updateAim)
 def shot(self, vehicle, attacker_id, points, effects_index):
     if not (_config.data['enabled'] and self.on_off): return
     if not vehicle.isStarted: return
     if not vehicle.isPlayerVehicle: return
     if BigWorld.player().team == BigWorld.player().arena.vehicles.get(attacker_id)['team']: return
     if vehicle.health < 1: return
     self.shots += 1
     index_hit, decode_comp_name = DamageFromShotDecoder.decodeHitPoints(points, vehicle.typeDescriptor)
     #compName = decode_comp_name[0].componentName if decode_comp_name else None
     has_pierced_hit = index_hit >= VEHICLE_HIT_EFFECT.ARMOR_PIERCED
     is_blocked = self.blocked_armor_hit(vehicle, decode_comp_name[0]) if decode_comp_name else False
     if is_blocked:
         for shell in BigWorld.player().arena.vehicles.get(attacker_id)['vehicleType'].gun['shots']:
             if effects_index == shell['shell']['effectsIndex']:
                 type_shell = shell['shell']['kind']
                 if type_shell != 'HIGH_EXPLOSIVE':
                     self.avgDMG, _ = shell['shell']['damage']
                     if has_pierced_hit:
                         self.list[self.shots] = {
                             'id'      : attacker_id,
                             'avgDMG'  : self.avgDMG,
                             'isDamage': False,
                             'used'    : False
                         }
                         BigWorld.callback(0.15, partial(self.shout_damage_hp, self.shots))
                     else: self.shout_damage()
                 break
     else: self.clear_data()
Example #9
0
 def onLogin(self, user, password, host, hdlr, isSocialToken2Login = False):
     self.__onLoggingTryingEndHdlr = hdlr
     self.__kickedFromServer = False
     self.__kickPeripheryID = None
     if self.__closeCallbackId:
         BigWorld.cancelCallback(self.__closeCallbackId)
         self.__closeCallbackId = None
     if not isSocialToken2Login:
         if not self.__validateCredentials(user.lower().strip(), password.strip()):
             self.__onLoggingTryingEndHdlr()
             return
     Waiting.show('login')
     self.__loginDataLoader.host = host
     self.__loginDataLoader.user = user
     self.__loginDataLoader.passLength = len(password)
     self.__loginDataLoader.saveUserConfig(user, self.__loginDataLoader.host)
     password = pwd_token.generate(password)
     if len(self.__loginDataLoader.token2):
         password = ''
     token2 = self.__loginDataLoader.token2
     if AUTO_LOGIN_QUERY_URL == host:
         g_preDefinedHosts.autoLoginQuery(lambda host: connectionManager.connect(getHostURL(host, token2), user, password, host.keyPath, nickName=None, token2=token2, isNeedSavingPwd=self.__loginDataLoader.rememberPwd))
         return
     else:
         host = g_preDefinedHosts.byUrl(host)
         connectionManager.connect(getHostURL(host, token2, True), user, password, host.keyPath, nickName=None, token2=token2, isNeedSavingPwd=self.__loginDataLoader.rememberPwd)
         return
 def __init_sound(self):
     if BigWorld.player() is not None and BigWorld.player().getVehicleAttached() is not None:
         self.connectSoundToMatrix(BigWorld.player().getVehicleAttached().appearance.modelsDesc['turret']['model'].matrix)
     else:
         self.connectSoundToMatrix(mathUtils.createIdentityMatrix())
     self.delayCallback(self.__updatePeriod, self.__update)
     return
 def __calculateClosestPoint(self, start, dir):
     dir.normalise()
     end = start + dir.scale(10000.0)
     testResTerrain = BigWorld.wg_collideSegment(BigWorld.player().spaceID, start, end, 128, 8)
     terrainSuitsForCheck = testResTerrain and testResTerrain[1].dot(Math.Vector3(0.0, 1.0, 0.0)) <= math.cos(ShotPointCalculatorPlanar.TERRAIN_MIN_ANGLE)
     testResNonTerrain = BigWorld.wg_collideSegment(BigWorld.player().spaceID, start, end, 136)
     testResDynamic = collideDynamic(start, end, (BigWorld.player().playerVehicleID,), False)
     closestPoint = None
     closestDist = 1000000
     isPointConvenient = True
     if testResTerrain:
         closestPoint = testResTerrain[0]
         closestDist = (testResTerrain[0] - start).length
     if terrainSuitsForCheck:
         isPointConvenient = closestDist >= ShotPointCalculatorPlanar.MIN_DIST
     if testResNonTerrain is not None:
         dist = (testResNonTerrain[0] - start).length
         if dist < closestDist:
             closestPoint = testResNonTerrain[0]
             closestDist = dist
             isPointConvenient = closestDist >= ShotPointCalculatorPlanar.MIN_DIST
     if closestPoint is None and testResDynamic is None:
         return (AimingSystems.shootInSkyPoint(start, dir), True)
     else:
         if testResDynamic is not None:
             dynDist = testResDynamic[0]
             if dynDist <= closestDist:
                 dir = end - start
                 dir.normalise()
                 closestPoint = start + dir * dynDist
                 isPointConvenient = True
         return (closestPoint, isPointConvenient)
 def __updateSound(self, angleDiff):
     if self.__manualSound is None:
         return
     else:
         if self.__gearSound is not None and angleDiff >= _PlayerTurretRotationSoundEffect.__MIN_ANGLE_TO_ENABLE_GEAR:
             if self.__currentSpeedState != self.__SPEED_FAST and self.__currentSpeedState != self.__SPEED_PRE_FAST:
                 nextSpeedState = self.__SPEED_PRE_FAST
             else:
                 nextSpeedState = self.__currentSpeedState
         elif angleDiff >= _PlayerTurretRotationSoundEffect.__MIN_ANGLE_TO_ENABLE_MANUAL:
             nextSpeedState = self.__SPEED_SLOW
         else:
             nextSpeedState = self.__SPEED_IDLE
         stateFn = self.__stateTable[self.__currentSpeedState][nextSpeedState]
         if stateFn is not None:
             stateFn()
         self.__currentSpeedState = nextSpeedState
         if g__attachToCam:
             __p = BigWorld.camera().position
         else:
             __p = BigWorld.player().position
         isTurretAlive = BigWorld.player().deviceStates.get('turretRotator', None) is None
         if self.__gearDamagedParam is not None:
             self.__gearDamagedParam.value = 0.0 if isTurretAlive else 1.0
         if self.__manGearDamagedParam is not None:
             self.__manGearDamagedParam.value = 0.0 if isTurretAlive else 1.0
         if self.__manualSound is not None:
             self.__manualSound.position = __p
         if self.__gearSound is not None:
             self.__gearSound.position = __p
         return
 def __onTick(self):
     self.__timerID = BigWorld.callback(self.__ROTATION_TICK_LENGTH, self.__onTick)
     lockEnabled = BigWorld.player().inputHandler.getAimingMode(AIMING_MODE.TARGET_LOCK)
     usePredictedLockShotPoint = lockEnabled and VehicleGunRotator.USE_LOCK_PREDICTION
     replayCtrl = BattleReplay.g_replayCtrl
     if not self.__clientMode and not replayCtrl.isPlaying and not usePredictedLockShotPoint:
         return
     else:
         replayCtrl = BattleReplay.g_replayCtrl
         if replayCtrl.isPlaying:
             shotPoint = replayCtrl.getGunRotatorTargetPoint()
         else:
             predictedLockShotPoint = self.predictLockedTargetShotPoint() if usePredictedLockShotPoint else None
             shotPoint = self.__shotPointSourceFunctor() if predictedLockShotPoint is None else predictedLockShotPoint
         if shotPoint is None and self.__targetLastShotPoint:
             shotPoint = self.__lastShotPoint
         if replayCtrl.isRecording:
             if shotPoint is not None:
                 replayCtrl.setGunRotatorTargetPoint(shotPoint)
         self.__updateShotPointOnServer(shotPoint)
         timeDiff = self.__getTimeDiff()
         if timeDiff is None:
             return
         self.__time = BigWorld.time()
         self.__rotate(shotPoint, timeDiff)
         self.__updateGunMarker()
         if replayCtrl.isPlaying:
             replayCtrl.resetUpdateGunOnTimeWarp()
         return
Example #14
0
    def _clearWaiters(self):
        if self._waiters is not None:
            while len(self._waiters):
                _, callbackID = self._waiters.popitem()
                BigWorld.cancelCallback(callbackID)

        return
 def destroy(self):
     BigWorld.player().arena.onPeriodChange -= self.__arenaPeriodChanged
     if self.__startEngineCbk is not None:
         BigWorld.cancelCallback(self.__startEngineCbk)
     self._vehicle = None
     self._gearUpCbk = None
     return
Example #16
0
    def handleLoginRejectedBan(self, status, message):
        try:
            LOG_DEBUG('handleLoginRejectedBan', message)
            msg_dict = json.loads(message)
            if not isinstance(msg_dict, dict):
                self.handleLoginCustomDefinedError(status, message)
                return
            self.__loginDataLoader.token2 = msg_dict.get('token2', '')
            self.__loginDataLoader.saveUserToken(self.__loginDataLoader.passLength, self.__loginDataLoader.token2)
            json_dict = msg_dict.get('bans')
            msg_dict = json.loads(json_dict)
        except Exception:
            LOG_CURRENT_EXCEPTION()
            self.handleLoginCustomDefinedError(status, message)
            return

        expiryTime = 0
        reason = ''
        if isinstance(msg_dict, dict):
            expiryTime = int(msg_dict.get('expiryTime', 0))
            reason = i18n.encodeUtf8(msg_dict.get('reason', ''))
        if reason == BAN_REASON.CHINA_MIGRATION:
            self.__handleMigrationNeeded()
        if reason.startswith('#'):
            reason = i18n.makeString(reason)
        if expiryTime > 0:
            expiryTime = makeLocalServerTime(expiryTime)
            expiryTime = BigWorld.wg_getLongDateFormat(expiryTime) + ' ' + BigWorld.wg_getLongTimeFormat(expiryTime)
            errorMessage = i18n.makeString(MENU.LOGIN_STATUS_LOGIN_REJECTED_BAN, time=expiryTime, reason=reason)
        else:
            errorMessage = i18n.makeString(MENU.LOGIN_STATUS_LOGIN_REJECTED_BAN_UNLIMITED, reason=reason)
        self.onSetStatus(errorMessage, self.ALL_VALID)
Example #17
0
    def __onResourcesLoaded(self, resourceRefs):
        if self.guid not in BigWorld.userDataObjects:
            return
        else:
            self.__clear()
            if self.modelName in resourceRefs.failedIDs:
                return
            try:
                self.__model = resourceRefs[self.modelName]
                self.__modelMatrix = Matrix()
                self.__modelMatrix.setIdentity()
                servo = BigWorld.Servo(self.__modelMatrix)
                self.__model.addMotor(servo)
                BigWorld.addModel(self.__model)
                if self.actionName != '':
                    action = self.__model.action(self.actionName)
                    if action is not None:
                        action()
                if self.pixieName != '' and self.pixieName not in resourceRefs.failedIDs:
                    pixieNode = self.__model.node(self.pixieHardPoint)
                    pixieNode.attach(resourceRefs[self.pixieName])
                if self.soundName != '':
                    self.__sound = SoundGroups.g_instance.playSoundModel(self.__model, self.soundName)
            except:
                LOG_CURRENT_EXCEPTION()
                self.__model = None
                return

            self.__prevTime = BigWorld.time()
            self.__update()
            return
Example #18
0
 def _populate(self):
     super(BattleLoading, self)._populate()
     g_sessionProvider.addArenaCtrl(self)
     BigWorld.wg_updateColorGrading()
     BigWorld.wg_enableGUIBackground(True, False)
     self._addArenaTypeData()
     Waiting.close()
Example #19
0
    def handleKey(self, key, isDown, offset):
        cmdMap = CommandMapping.g_instance
        if cmdMap.isFired(CommandMapping.CMD_RADIAL_MENU_SHOW, key):
            if isDown:
                if self.__currentVehicleDesc is None:
                    self.__currentVehicleDesc = self.__getCurrentVehicleDesc()
                if self.__currentVehicleDesc is not None:
                    self.__currentTarget = BigWorld.target()
                    mouseUsedForShow = getScaleformKey(key) <= BW_TO_SCALEFORM[Keys.KEY_MOUSE7]
                    self.__onMenuShow(offset, mouseUsedForShow)
            else:
                self.__onMenuHide()
        elif isDown:
            if not self.__ingameMenuIsVisible():
                if self.__currentVehicleDesc is None:
                    self.__currentVehicleDesc = self.__getCurrentVehicleDesc()
                if not self.__showed:
                    self.__currentTarget = BigWorld.target()
                for command in self.KEYB_MAPPINGS:
                    shortcut = self.KEYB_CMDS_MAPPINGS[command]
                    if cmdMap.isFired(getattr(CommandMapping, shortcut), key):
                        action = self.__getMappedCommand(command)
                        if action not in self.DENIED_KEYB_CMDS:
                            self.onAction(action)

        return
Example #20
0
 def tryBattlesTillCaptchaReset(self):
     if self.__tryReset:
         return
     if self.__triesLeft > 1:
         self.__tryReset = True
         LOG_WARNING('Client try battlesTillCaptcha reset')
         BigWorld.player().challengeCaptcha('', '', lambda resultID, errorCode: None)
Example #21
0
 def _clearEntitiesAndSpaces(self):
     from gui.shared.utils.HangarSpace import g_hangarSpace
     keepClientOnlySpaces = False
     if g_hangarSpace is not None and g_hangarSpace.inited:
         keepClientOnlySpaces = g_hangarSpace.spaceLoading()
     BigWorld.clearEntitiesAndSpaces(keepClientOnlySpaces)
     return
Example #22
0
 def delayCallback(self, seconds, func, *args, **kwargs):
     curId = self.__callbacks.get(func)
     if curId is not None:
         BigWorld.cancelCallback(curId)
         del self.__callbacks[func]
     curId = BigWorld.callback(seconds, functools.partial(self.__funcWrapper, func, *args, **kwargs))
     self.__callbacks[func] = curId
Example #23
0
 def _doAttention(self, index, duration):
     player = BigWorld.player()
     if player is not None and player.isTeleport:
         position = minimap_utils.getPositionByCellIndex(index, *self._boundingBox)
         result = BigWorld.collide(player.spaceID, (position[0], 1000.0, position[2]), (position[0], -1000.0, position[2]))
         player.base.vehicle_teleport((position[0], result[0][1], position[2]), 0)
     return
Example #24
0
 def create(self):
     if self.__flagEntity is not None:
         LOG_ERROR('Flags: Wrong usage of offline flags')
         return
     else:
         self.__entityID = BigWorld.createEntity('OfflineFlag', BigWorld.player().spaceID, 0, self.__position, Vector3(0.0, 0.0, 0.0), dict({'flagID': self.__flagID}))
         return
Example #25
0
    def __devDismissInvalidTankmen(self, tmanInvID, callback):

        def response(code):
            LOG_WARNING('Invalid tankman dismissing result', tmanInvID, code)
            callback(code >= 0)

        BigWorld.player().inventory.dismissTankman(tmanInvID, response)
Example #26
0
def showCursor():
    """not scaleform specific. show the bigworld mouse cursor"""
    import GUI
    import BigWorld
    c = GUI.mcursor()
    c.visible = 1
    BigWorld.setCursor(c)
Example #27
0
    def save(self):
        tmpList = []
        for fireKey, listKeyInfo in self.__mapping.iteritems():
            for command, satelliteKeys, isDefault in listKeyInfo:
                if isDefault:
                    continue
                if len(satelliteKeys):
                    continue
                commandName = self.getName(command)
                listSatelliteKeyNames = []
                for key in satelliteKeys:
                    listSatelliteKeyNames.append('KEY_' + BigWorld.keyToString(key))

                strSatelliteKeyNames = ''
                for keyName in listSatelliteKeyNames:
                    strSatelliteKeyNames += keyName + ' '

                strSatelliteKeyNames = strSatelliteKeyNames.strip()
                fireKeyName = 'KEY_' + BigWorld.keyToString(fireKey)
                tmpList.append((commandName, fireKeyName, strSatelliteKeyNames))

        if len(tmpList):
            section = Settings.g_instance.userPrefs
            section.deleteSection(CommandMapping.__USER_CONFIG_SECTION_NAME)
            section = section.createSection(CommandMapping.__USER_CONFIG_SECTION_NAME)
            for commandName, fireKeyName, strSatelliteKeynames in tmpList:
                subsec = section.createSection(commandName)
                subsec.writeString('fireKey', fireKeyName)
                subsec.writeString('satelliteKeys', strSatelliteKeyNames)

            Settings.g_instance.save()
Example #28
0
    def __doShot(self, data):
        data['_timerID'] = None
        try:
            vehicle = data['entity']
            if not vehicle.isAlive():
                self.stop(data)
                return
            burstCount, burstInterval = data['_burst']
            gunModel = data['_gunModel']
            effPlayer = data['_effectsListPlayer']
            effPlayer.stop()
            if burstCount == 1:
                effPlayer.play(gunModel, None, partial(self.stop, data))
                withShot = 1
            else:
                data['_burst'] = (burstCount - 1, burstInterval)
                data['_timerID'] = BigWorld.callback(burstInterval, partial(self.__doShot, data))
                effPlayer.play(gunModel)
                withShot = 2
            if data['entity'].isPlayerVehicle:
                avatar = BigWorld.player()
                avatar.getOwnVehicleShotDispersionAngle(avatar.gunRotator.turretRotationSpeed, withShot)
            if not vehicle.appearance.isInWater:
                groundWaveEff = effPlayer.effectsList.relatedEffects.get('groundWave')
                if groundWaveEff is not None:
                    self.__doGroundWaveEffect(data['entity'], groundWaveEff, gunModel)
            self.__doRecoil(vehicle, gunModel)
            if vehicle.isPlayerVehicle:
                appearance = vehicle.appearance
                appearance.executeShootingVibrations(vehicle.typeDescriptor.shot['shell']['caliber'])
        except Exception:
            LOG_CURRENT_EXCEPTION()
            self.stop(data)

        return
Example #29
0
 def requestEmblemByUrl(cls, url, callback):
     if hasattr(BigWorld.player(), 'customFilesCache'):
         if url is not None:
             BigWorld.player().customFilesCache.get(url, lambda _, data: callback(data))
     else:
         LOG_WARNING('Trying to get emblem by url from non-account', url)
     return
Example #30
0
 def stop(self, finished = False, reason = TUTORIAL_STOP_REASON.DEFAULT):
     if self._tutorialStopped:
         return
     else:
         if self.__callbackID is not None:
             BigWorld.cancelCallback(self.__callbackID)
             self.__callbackID = None
         if self._funcScene is not None:
             self._funcScene.leave()
         if self._data is not None:
             self._data.clear()
         GlobalStorage.clearFlags()
         if self._sound is not None:
             self._sound.stop()
         self._sound = None
         if self._gui is not None:
             self._gui.fini(isItemsRevert=self._descriptor.isItemsRevertIfStop(reason))
         self._gui = None
         if finished:
             self._cache.setFinished(True).write()
         else:
             self._cache.update(self._currentChapter, self._flags.getDict() if self._flags else None)
         self._cache = None
         g_tutorialWeaver.clear()
         clearTutorialProxy()
         self.removeEffectsInQueue()
         self._nextChapter = False
         self._tutorialStopped = True
         self._initialized = 0
         return