def _PostMortemControlMode_onMinimapClicked(self, worldPos):
    #log('_PostMortemControlMode_onMinimapClicked active=' + str(g_minimap.active))
    if g_minimap.active and g_minimap.opt_minimapDeadSwitch:
        try:
            battle = getBattleApp()
            if not battle:
                return

            if isReplay() and not IS_DEVELOPMENT:
                return

            minDistance = None
            toID = None
            plugin = g_minimap.minimapComponent.getPlugin('vehicles')
            for vehicleID, entry in plugin._entries.iteritems():
                vData = avatar_getter.getArena().vehicles[vehicleID]
                if avatar_getter.getPlayerTeam() != vData['team'] or not vData['isAlive']:
                    continue
                matrix = entry.getMatrix()
                if matrix is not None:
                    pos = Math.Matrix(matrix).translation
                    distance = Math.Vector3(worldPos - pos).length
                    if minDistance is None or minDistance > distance:
                        minDistance = distance
                        toID = vehicleID
            if toID is not None:
                self.selectPlayer(toID)
        except Exception as ex:
            if IS_DEVELOPMENT:
                err(traceback.format_exc())
Exemple #2
0
def _start(e=None):
    g_eventBus.removeListener(XVM_EVENT.XVM_SERVICES_INITIALIZED, _start)
    if not g_xvm.xvmServicesInitialized:
        g_eventBus.addListener(XVM_EVENT.XVM_SERVICES_INITIALIZED, _start)
        return

    if (config.networkServicesSettings.xmqp and not isReplay()) or XMQP_DEVELOPMENT:
        token = config.token.token
        if token:
            players = []
            for (vehicleID, vData) in avatar_getter.getArena().vehicles.iteritems():
                # ally team only
                if vData['team'] == avatar_getter.getPlayerTeam():
                    players.append(vData['accountDBID'])
            if XMQP_DEVELOPMENT:
                accountDBID = utils.getAccountDBID()
                if accountDBID not in players:
                    players.append(accountDBID)
                #players.append(42)
                #players.append(43)
            players.sort()
            # start
            stop()
            global _xmqp_thread, _xmqp
            _xmqp = _XMQP(players)
            _xmqp_thread = threading.Thread(target=_xmqp.start, name='xmqp')
            _xmqp_thread.setDaemon(True)
            _xmqp_thread.start()
            debug('[XMQP] Thread started')
Exemple #3
0
    def _fix(self, stat, orig_name=None):
        self._fix_common(stat)

        team = avatar_getter.getPlayerTeam()

        if self.players is not None:
            for (vehicleID, pl) in self.players.iteritems():
                if pl.accountDBID == stat['player_id']:
                    stat['vehicleID'] = pl.vehicleID
                    if pl.clan:
                        stat['clan'] = pl.clan
                        clan_id = pl.clanInfo.get('clan_id', None) if pl.clanInfo else None
                        stat_clan_id = stat.get('clan_id', None)
                        if (stat_clan_id is None or stat_clan_id == clan_id) and stat.get('rank') is not None and stat.get('emblem') is not None:
                            pl.clanInfo = {'clan_id': stat_clan_id, 'rank': stat['rank'], 'emblem': stat['emblem']}
                            self._load_clanIcon(pl)
                        else:
                            stat['clan_id'] = clan_id
                            stat['rank'] = pl.clanInfo.get('rank', None) if pl.clanInfo else None
                            stat['emblem'] = pl.clanInfo.get('emblem', None) if pl.clanInfo else None
                    stat['name'] = pl.name
                    stat['team'] = TEAM.ALLY if team == pl.team else TEAM.ENEMY
                    stat['badgeId'] = pl.badgeId
                    if hasattr(pl, 'alive'):
                        stat['alive'] = pl.alive
                    if hasattr(pl, 'ready'):
                        stat['ready'] = pl.ready
                    if 'id' not in stat['v']:
                        stat['v']['id'] = pl.vehCD
                    break

        self._fix_common2(stat, orig_name, False)
        self._addContactData(stat)
        return stat
Exemple #4
0
 def start(self):
     visitor = g_sessionProvider.arenaVisitor
     self.__playerVehicleID = avatar_getter.getPlayerVehicleID()
     self.__playerTeam = avatar_getter.getPlayerTeam()
     self.__isTeamPlayer = not visitor.isSoloTeam(self.__playerTeam)
     self.__addCaptureMarkers(visitor, g_ctfManager.getVehicleCarriedFlagID(self.__playerVehicleID) is not None)
     super(AbsorptionMarkersPlugin, self).start()
     return
Exemple #5
0
 def __init__(self):
     super(ArenaDataProvider, self).__init__()
     self.__playerTeam = avatar_getter.getPlayerTeam()
     self.__playerVehicleID = avatar_getter.getPlayerVehicleID()
     self.__vInfoVOs = {}
     self.__vStatsVOs = VehicleArenaStatsDict()
     self.__prbStats = {}
     self.__playersVIDs = {}
    def _updateTeamData(self, isEnemy, team, arenaDP, isFragsUpdate=True):
        pNamesList, fragsList, vNamesList, additionalDataList = ([], [], [], [])
        valuesHashes = []
        teamsList, teamScoreList = [], []
        playerIdx = -1
        playerTeamID = avatar_getter.getPlayerTeam()
        teamScores = defaultdict(list)
        teamIds = arenaDP.getMultiTeamsIndexes()
        camraVehicleID = self._battleUI.getCameraVehicleID()
        playerNameLength = int(self._battleUI.getPlayerNameLength(isEnemy))
        for index, (vInfoVO, vStatsVO, viStatsVO) in enumerate(arenaDP.getAllVehiclesIteratorByTeamScore()):
            team = vInfoVO.team
            isEnemy = arenaDP.isEnemyTeam(team)
            ctx = makeTeamCtx(team, isEnemy, arenaDP, playerNameLength, camraVehicleID)
            if ctx.playerVehicleID == vInfoVO.vehicleID:
                playerIdx = index
            playerFullName = self._battleCtx.getFullPlayerName(vID=vInfoVO.vehicleID, showVehShortName=False)
            if not playerFullName:
                playerFullName = vInfoVO.player.getPlayerLabel()
            pName, frags, vName, additionalData = self._battleUI.statsForm.getFormattedStrings(
                vInfoVO, vStatsVO, viStatsVO, ctx, playerFullName
            )
            pNamesList.append(pName)
            fragsList.append(frags)
            vNamesList.append(vName)
            additionalDataList.append(additionalData)
            valuesHashes.append({"vehicleState": 0 if viStatsVO.stopRespawn else _VEHICLE_STATUS.IS_ALIVE})
            teamIdx = teamIds[team]
            if (team, teamIdx) not in teamsList:
                teamsList.append((team, teamIdx))
            format = self._battleUI.statsForm.getTeamScoreFormat()
            teamScores[team].append((viStatsVO.winPoints, format))

        for team, _ in teamsList:
            teamScore = teamScores[team]
            totalScore = sum([score for score, _ in teamScore])
            scoreIndexForTable = len(teamScore) / 2
            for index, (score, format) in enumerate(teamScore):
                teamScoreStr = format % " "
                if index == scoreIndexForTable:
                    teamScoreStr = format % BigWorld.wg_getNiceNumberFormat(totalScore)
                teamScoreList.append(teamScoreStr)

        self._battleUI.setMultiteamValues(
            self._makeMultiTeamValues(
                playerTeamID,
                playerIdx,
                pNamesList,
                fragsList,
                vNamesList,
                teamsList,
                teamScoreList,
                additionalDataList,
                valuesHashes,
                arenaDP.getMultiTeamsType(),
            )
        )
    def _updateTeamData(self, isEnemy, team, arenaDP, isFragsUpdate = True):
        pNamesList, fragsList, vNamesList, additionalDataList = ([],
         [],
         [],
         [])
        valuesHashes = []
        teamsList, teamScoreList = [], []
        playerIdx = -1
        playerTeamID = avatar_getter.getPlayerTeam()
        teamScores = defaultdict(list)
        teamIds = arenaDP.getMultiTeamsIndexes()
        camraVehicleID = self._battleUI.getCameraVehicleID()
        playerNameLength = int(self._battleUI.getPlayerNameLength(isEnemy))
        vehicleNameLength = int(self._battleUI.getVehicleNameLength(isEnemy))
        if self._arenaVisitor.hasRespawns():
            sortKey = vos_collections.WinPointsAndRespawnSortKey
        else:
            sortKey = vos_collections.WinPointsAndVehicleInfoSortKey
        collection = vos_collections.FalloutMultiTeamItemsCollection(sortKey=sortKey)
        for index, (vInfoVO, vStatsVO) in enumerate(collection.iterator(arenaDP)):
            team = vInfoVO.team
            isEnemy = arenaDP.isEnemyTeam(team)
            ctx = makeTeamCtx(team, isEnemy, arenaDP, playerNameLength, vehicleNameLength, camraVehicleID)
            if ctx.playerVehicleID == vInfoVO.vehicleID:
                playerIdx = index
            playerFullName = self._battleCtx.getPlayerFullName(vID=vInfoVO.vehicleID, showVehShortName=False)
            if not playerFullName:
                playerFullName = vInfoVO.player.getPlayerLabel()
            pName, frags, vName, additionalData, _ = self._battleUI.statsForm.getFormattedStrings(vInfoVO, vStatsVO, ctx, playerFullName)
            pNamesList.append(pName)
            fragsList.append(frags)
            vNamesList.append(vName)
            additionalDataList.append(additionalData)
            valuesHashes.append({'vehicleState': 0 if vStatsVO.stopRespawn else VEHICLE_STATUS.IS_ALIVE,
             'vehicleType': vInfoVO.vehicleType.getClassName(),
             'teamColorScheme': 'vm_enemy' if isEnemy else 'vm_ally'})
            teamIdx = teamIds[team]
            if (team, teamIdx) not in teamsList:
                teamsList.append((team, teamIdx))
            format = self._battleUI.statsForm.getTeamScoreFormat()
            teamScores[team].append((vStatsVO.interactive.winPoints, format))

        for team, _ in teamsList:
            teamScore = teamScores[team]
            totalScore = sum([ score for score, _ in teamScore ])
            scoreIndexForTable = len(teamScore) / 2
            for index, (score, format) in enumerate(teamScore):
                teamScoreStr = format % ' '
                if index == scoreIndexForTable:
                    teamScoreStr = format % BigWorld.wg_getNiceNumberFormat(totalScore)
                teamScoreList.append(teamScoreStr)

        self._battleUI.setMultiteamValues(self._makeMultiTeamValues(playerTeamID, playerIdx, pNamesList, fragsList, vNamesList, teamsList, teamScoreList, additionalDataList, valuesHashes, arenaDP.getMultiTeamsType()))
Exemple #8
0
 def __init__(self, setup):
     super(ArenaDataProvider, self).__init__()
     self.__playerTeam = avatar_getter.getPlayerTeam(avatar=setup.avatar)
     self.__teamsOnArena = range(1, setup.arenaVisitor.type.getMaxTeamsOnArena() + 1)
     self.__playerVehicleID = avatar_getter.getPlayerVehicleID(setup.avatar)
     self.__vInfoVOs = {}
     self.__vStatsVOs = arena_vos.VehicleArenaStatsDict()
     self.__playersVIDs = {}
     self.__invitationStatuses = {}
     self.__squadFinder = squad_finder.createSquadFinder(setup.arenaVisitor, self.__teamsOnArena)
     self.__description = arena_descrs.createDescription(setup.arenaVisitor)
     settings.addUnknownContourIconToCache()
 def __init__(self, avatar = None):
     super(ArenaDataProvider, self).__init__()
     self.__playerTeam = avatar_getter.getPlayerTeam(avatar)
     self.__teamsOnArena = range(1, avatar_getter.getMaxTeamsOnArena(avatar) + 1)
     self.__playerVehicleID = avatar_getter.getPlayerVehicleID(avatar)
     self.__vInfoVOs = {}
     self.__vStatsVOs = VehicleArenaStatsDict()
     self.__prbStats = {}
     self.__playersVIDs = {}
     self.__viStatsVOs = VehicleArenaInteractiveStatsDict()
     self.__teamsVIStats = {}
     fo_precache.add(settings.UNKNOWN_CONTOUR_ICON_RES_PATH)
 def __init__(self, avatar = None):
     super(ArenaDataProvider, self).__init__()
     self.__playerTeam = avatar_getter.getPlayerTeam(avatar)
     self.__teamsOnArena = range(1, arena_info.getMaxTeamsOnArena(avatar) + 1)
     self.__playerVehicleID = avatar_getter.getPlayerVehicleID(avatar)
     self.__vInfoVOs = {}
     self.__vStatsVOs = arena_vos.VehicleArenaStatsDict()
     self.__prbStats = {}
     self.__playersVIDs = {}
     self.__viStatsVOs = arena_vos.VehicleArenaInteractiveStatsDict()
     self.__teamsVIStats = {}
     self.__teamSquadIndices = {}
     self.__invitationStatuses = {}
     self.__description = arena_descrs.createDescription(arena_info.getClientArena(avatar))
     fo_precache.add(settings.UNKNOWN_CONTOUR_ICON_RES_PATH)
Exemple #11
0
    def start(self):
        visitor = g_sessionProvider.arenaVisitor
        self.__playerTeam = avatar_getter.getPlayerTeam()
        self.__isTeamPlayer = not visitor.isSoloTeam(self.__playerTeam)
        self.__spawnPoints = visitor.type.getFlagSpawnPoints()
        for flagID, flagInfo in g_ctfManager.getFlags():
            vehicleID = flagInfo['vehicle']
            if vehicleID is None:
                flagState = flagInfo['state']
                if flagState == constants.FLAG_STATE.WAITING_FIRST_SPAWN:
                    self.__onFlagSpawning(flagID, flagInfo['respawnTime'])
                elif flagState in (constants.FLAG_STATE.ON_GROUND, constants.FLAG_STATE.ON_SPAWN):
                    self.__onSpawnedAtBase(flagID, flagInfo['team'], flagInfo['minimapPos'])

        super(VehicleAndFlagsMarkerPlugin, self).start()
        return
Exemple #12
0
 def __getHelpText(self):
     visitor = self.sessionProvider.arenaVisitor
     isSolo = visitor.isSoloTeam(avatar_getter.getPlayerTeam())
     plusStr = makeString(FALLOUT.INFOPANEL_SINGLEHELPTEXT_PLUS)
     isMultiteam = visitor.gui.isFalloutMultiTeam()
     headerStr = makeHtmlString(_HTML_TEMPLATE_FALLOUT_INFO_KEY, 'header', makeString(FALLOUT.INFOPANEL_SECRETWIN_HEAD))
     additionalBlockTemplate = makeHtmlString(_HTML_TEMPLATE_FALLOUT_INFO_KEY, 'winPoints')
     costKill, costFlags, costDamage = visitor.type.getWinPointsCosts(isSolo=isSolo, forVehicle=True)
     helpStr = ''
     if visitor.hasFlags() and len(costFlags) > 0:
         costFlags = list(costFlags)[0]
         helpStr = self.__getAdditionalBlockStr(additionalBlockTemplate, FALLOUT.INFOPANEL_SINGLEHELPTEXT_WINPOINTS_FLAGCAPTURE, warning(plusStr + str(costFlags)))
         if isMultiteam and isSolo:
             helpStr = self.__getAdditionalBlockStr(additionalBlockTemplate, FALLOUT.INFOPANEL_SINGLEHELPTEXT_WINPOINTS_FLAGDESTROY, warning(plusStr + str(costFlags)))
     helpStr += self.__getAdditionalBlockStr(additionalBlockTemplate, FALLOUT.INFOPANEL_SINGLEHELPTEXT_WINPOINTS_KILL, warning(plusStr + str(costKill)))
     damageDealt, points = costDamage
     points = warning(plusStr + str(points))
     helpStr += additionalBlockTemplate % makeString(FALLOUT.INFOPANEL_SINGLEHELPTEXT_WINPOINTS_DAMAGE, points=points, damageDealt=damageDealt)
     return headerStr + helpStr
 def sendEndGameMessage(self, winningTeam, reason):
     messageType = GAME_MESSAGES_CONSTS.DRAW
     if winningTeam != 0:
         isWinner = avatar_getter.getPlayerTeam() == winningTeam
         if isWinner:
             messageType = GAME_MESSAGES_CONSTS.WIN
         else:
             messageType = GAME_MESSAGES_CONSTS.DEFEAT
     endGameMsgData = {
         'title':
         toUpper(i18n.makeString(_FULL_RESULT_LABEL.format(messageType))),
         'subTitle':
         makeRegularFinishResultLabel(reason, messageType)
     }
     msg = PlayerMessageData(
         messageType, GAME_MESSAGES_CONSTS.DEFAULT_MESSAGE_LENGTH,
         GAME_MESSAGES_CONSTS.GAME_MESSAGE_PRIORITY_END_GAME,
         endGameMsgData)
     self._addMessage(msg.getDict())
Exemple #14
0
    def _fix(self, stat, orig_name=None):
        self._fix_common(stat)

        team = avatar_getter.getPlayerTeam()

        if self.players is not None:
            for (vehicleID, pl) in self.players.iteritems():
                if pl.accountDBID == stat['player_id']:
                    stat['vehicleID'] = pl.vehicleID
                    if pl.clan:
                        stat['clan'] = pl.clan
                        clan_id = pl.clanInfo.get(
                            'clan_id', None) if pl.clanInfo else None
                        stat_clan_id = stat.get('clan_id', None)
                        if (stat_clan_id is None or stat_clan_id == clan_id
                            ) and stat.get('rank') is not None and stat.get(
                                'emblem') is not None:
                            pl.clanInfo = {
                                'clan_id': stat_clan_id,
                                'rank': stat['rank'],
                                'emblem': stat['emblem']
                            }
                            self._load_clanIcon(pl)
                        else:
                            stat['clan_id'] = clan_id
                            stat['rank'] = pl.clanInfo.get(
                                'rank', None) if pl.clanInfo else None
                            stat['emblem'] = pl.clanInfo.get(
                                'emblem', None) if pl.clanInfo else None
                    stat['name'] = pl.name
                    stat['team'] = TEAM.ALLY if team == pl.team else TEAM.ENEMY
                    stat['badgeId'] = pl.badgeId
                    if hasattr(pl, 'alive'):
                        stat['alive'] = pl.alive
                    if hasattr(pl, 'ready'):
                        stat['ready'] = pl.ready
                    if 'id' not in stat['v']:
                        stat['v']['id'] = pl.vehCD
                    break

        self._fix_common2(stat, orig_name, False)
        self._addContactData(stat)
        return stat
Exemple #15
0
 def sendEndGameMessage(self, winningTeam, reason):
     isWinner = avatar_getter.getPlayerTeam() == winningTeam
     if winningTeam == 0:
         messageType = GAME_MESSAGES_CONSTS.DRAW
         title = EPIC_BATTLE.GAME_DRAW
     else:
         messageType = GAME_MESSAGES_CONSTS.WIN if isWinner else GAME_MESSAGES_CONSTS.DEFEAT
         title = EPIC_BATTLE.GAME_VICTORY if isWinner else EPIC_BATTLE.GAME_DEFEAT
     endGameMsgData = {
         'title': title,
         'reason': reason,
         'subTitle': makeEpicBattleFinishResultLabel(reason, messageType)
     }
     msg = PlayerMessageData(
         messageType, GAME_MESSAGES_CONSTS.DEFAULT_MESSAGE_LENGTH,
         GAME_MESSAGES_CONSTS.GAME_MESSAGE_PRIORITY_END_GAME,
         endGameMsgData)
     self.__onIngameMessageReady(msg)
     self.__blockNewMessages = True
Exemple #16
0
 def __getHelpText(self):
     visitor = g_sessionProvider.arenaVisitor
     isSolo = visitor.isSoloTeam(avatar_getter.getPlayerTeam())
     plusStr = makeString(FALLOUT.INFOPANEL_SINGLEHELPTEXT_PLUS)
     isMultiteam = visitor.gui.isFalloutMultiTeam()
     headerStr = makeHtmlString(_HTML_TEMPLATE_FALLOUT_INFO_KEY, 'header', makeString(FALLOUT.INFOPANEL_SECRETWIN_HEAD))
     additionalBlockTemplate = makeHtmlString(_HTML_TEMPLATE_FALLOUT_INFO_KEY, 'winPoints')
     costKill, costFlags, costDamage = visitor.type.getWinPointsCosts(isSolo=isSolo, forVehicle=True)
     helpStr = ''
     if visitor.hasFlags() and len(costFlags) > 0:
         costFlags = list(costFlags)[0]
         helpStr = self.__getAdditionalBlockStr(additionalBlockTemplate, FALLOUT.INFOPANEL_SINGLEHELPTEXT_WINPOINTS_FLAGCAPTURE, warning(plusStr + str(costFlags)))
         if isMultiteam and isSolo:
             helpStr = self.__getAdditionalBlockStr(additionalBlockTemplate, FALLOUT.INFOPANEL_SINGLEHELPTEXT_WINPOINTS_FLAGDESTROY, warning(plusStr + str(costFlags)))
     helpStr += self.__getAdditionalBlockStr(additionalBlockTemplate, FALLOUT.INFOPANEL_SINGLEHELPTEXT_WINPOINTS_KILL, warning(plusStr + str(costKill)))
     damageDealt, points = costDamage
     points = warning(plusStr + str(points))
     helpStr += additionalBlockTemplate % makeString(FALLOUT.INFOPANEL_SINGLEHELPTEXT_WINPOINTS_DAMAGE, points=points, damageDealt=damageDealt)
     return headerStr + helpStr
    def __onAvatarReady(self):
        if self._componentSystem() is None:
            return
        else:
            self.__sectorComponent = weakref.proxy(self._componentSystem().sectorComponent)
            self.__playerDataComponent = weakref.proxy(self._componentSystem().playerDataComponent)
            self.__protectionZoneComponent = weakref.proxy(self._componentSystem().protectionZoneComponent)
            self.__teamId = getPlayerTeam()
            self.__transitionEndTimes = {}
            self.__nodes = defaultdict(_SectorGroupNode)
            self.__edges = defaultdict(_SectorGroupEdge)
            self.__protectionZones = defaultdict(_ProtectionZoneSetting)
            self.__activeWarnings = {}
            self.__visual = SectorBorderVisualisation(self)
            self.__sectorComponent.onSectorAdded += self.__onSectorAdded
            for sector in self.__sectorComponent.sectors:
                self.__onSectorAdded(sector, self.__sectorComponent.getSectorGroupById(sector.groupID))

            self.__sectorComponent.onSectorGroupUpdated += self.__onSectorGroupUpdated
            sectorGroups = self.__sectorComponent.sectorGroups
            for groupId in sectorGroups:
                group = sectorGroups[groupId]
                self.__onSectorGroupUpdated(group.id, group.state, group.center, group.getBound())

            self.__sectorComponent.onSectorGroupTransitionTimeChanged += self.__onSectorGroupTransitionTimeChanged
            self.__protectionZoneComponent.onProtectionZoneAdded += self.__onProtectionZoneAdded
            self.__protectionZoneComponent.onProtectionZoneActive += self.__onProtectionZoneActive
            for _, zone in self.__protectionZoneComponent.protectionZones.items():
                self.__onProtectionZoneAdded(zone.zoneID, zone.position, zone.bound)
                if zone.isActive:
                    self.__onProtectionZoneActive(zone.zoneID, zone.isActive)

            self.__sectorComponent.onPlayerSectorGroupChanged += self.__onPlayerSectorGroupChanged
            groupId = self.__playerDataComponent.physicalSectorGroup
            if groupId is not None:
                self.__onPlayerSectorGroupChanged(groupId, None, None, None)
            self.__protectionZoneComponent.onPlayerInProtectedZoneAction += self.__onPlayerInProtectionZone
            for _, zone in [ x for _, x in self.__protectionZoneComponent.protectionZones.items() if self.__protectionZoneComponent.isPlayerInProtectedZone(x.zoneID) ]:
                self.__onPlayerInProtectionZone(zone.zoneID, True)

            return
    def __tryToGetRequiredData(self):
        successful = True
        self.__playerTeam = avatar_getter.getPlayerTeam()
        if not self.__playerTeam:
            successful = False
            LOG_NOTE("Player's team not found.")
        self.__playerVehicleID = avatar_getter.getPlayerVehicleID()
        if not self.__playerVehicleID:
            successful = False
            LOG_NOTE("Player's vehicle ID not found.")
        if not successful:
            playerName = avatar_getter.getPlayerName()
            LOG_NOTE('Uses slow player search by name')
            for vo in self.__vInfoVOs.itervalues():
                if vo.player.name == playerName:
                    self.__playerTeam = vo.team
                    self.__playerVehicleID = vo.vehicleID
                    successful = True
                    break

        return successful
Exemple #19
0
    def start(self):
        playerTeam = avatar_getter.getPlayerTeam()
        ctrl = g_sessionProvider.dynamic.repair
        if ctrl is not None:
            getPointStateID = ctrl.getPointStateID
        else:

            def getPointStateID(_):
                return REPAIR_STATE_ID.UNRESOLVED

        for pointID, (team, repairPos) in g_sessionProvider.arenaVisitor.type.getRepairPointIterator():
            isAlly = team in (NEUTRAL_TEAM, playerTeam)
            markerID = self._createMarker(repairPos + settings.MARKER_POSITION_ADJUSTMENT, settings.REPAIR_MARKER_TYPE)
            if getPointStateID(pointID) == REPAIR_STATE_ID.COOLDOWN:
                icon = 'cooldown'
            else:
                icon = 'active'
            self._invokeMarker(markerID, 'setIcon', [icon, isAlly])
            self.__markers[pointID] = (markerID, isAlly)

        super(RepairsMarkerPlugin, self).start()
        return
 def sendEndGameMessage(self, winningTeam, reason):
     messageType = GAME_MESSAGES_CONSTS.DRAW
     if winningTeam != 0:
         isWinner = avatar_getter.getPlayerTeam() == winningTeam
         if isWinner:
             messageType = GAME_MESSAGES_CONSTS.WIN
         else:
             messageType = GAME_MESSAGES_CONSTS.DEFEAT
     endGameMsgData = {
         'title':
         toUpper(
             backport.text(
                 R.strings.menu.finalStatistic.commonStats.resultlabel.dyn(
                     messageType)())),
         'subTitle':
         makeRegularFinishResultLabel(reason, messageType)
     }
     msg = PlayerMessageData(
         messageType, GAME_MESSAGES_CONSTS.DEFAULT_MESSAGE_LENGTH,
         GAME_MESSAGES_CONSTS.GAME_MESSAGE_PRIORITY_END_GAME,
         endGameMsgData)
     self._addMessage(msg.getDict())
def update_hp(vehicleID, hp):
    try:
        team = 0 if avatar_getter.getPlayerTeam() == avatar_getter.getArena().vehicles[vehicleID]['team'] else 1

        global teams_vehicles, teams_totalhp, total_hp_color, total_hp_sign

        #log('update_hp: {} {} => {}'.format(vehicleID, teams_vehicles[team].get(vehicleID, None), hp))
        teams_vehicles[team][vehicleID] = max(hp, 0)
        teams_totalhp[team] = sum(teams_vehicles[team].values())

        if teams_totalhp[0] < teams_totalhp[1]:
            ratio = max(min(2.0 * teams_totalhp[0] / teams_totalhp[1] - 0.9, 1), 0)
            total_hp_color = color_gradient(hp_colors['neutral'], hp_colors['bad'], ratio)
            total_hp_sign = '<'
        elif teams_totalhp[0] > teams_totalhp[1]:
            ratio = max(min(2.0 * teams_totalhp[1] / teams_totalhp[0] - 0.9, 1), 0)
            total_hp_color = color_gradient(hp_colors['neutral'], hp_colors['good'], ratio)
            total_hp_sign = '>'
        else:
            total_hp_color = color_gradient(hp_colors['neutral'], hp_colors['neutral'], 1)
            total_hp_sign = '='
    except Exception, ex:
        err(traceback.format_exc())
Exemple #22
0
    def __tryToGetRequiredData(self):
        successful = True
        self.__playerTeam = avatar_getter.getPlayerTeam()
        if not self.__playerTeam:
            successful = False
            LOG_NOTE("Player's team not found.")
        self.__playerVehicleID = avatar_getter.getPlayerVehicleID()
        if not self.__playerVehicleID:
            successful = False
            LOG_NOTE("Player's vehicle ID not found.")
        if not successful:
            playerName = avatar_getter.getPlayerName()
            LOG_NOTE('Uses slow player search by name')
            for vo in self.__vInfoVOs.itervalues():
                if vo.player.name == playerName:
                    self.__playerTeam = vo.team
                    self.__playerVehicleID = vo.vehicleID
                    successful = True
                    break

        if successful:
            self.__setPersonalDataOnce()
        return successful
Exemple #23
0
def update_hp(vehicleID, hp):
    try:
        team = 0 if avatar_getter.getPlayerTeam() == avatar_getter.getArena().vehicles[vehicleID]['team'] else 1

        global teams_vehicles, teams_totalhp, total_hp_color, total_hp_sign

        #log('update_hp: {} {} => {}'.format(vehicleID, teams_vehicles[team].get(vehicleID, None), hp))
        teams_vehicles[team][vehicleID] = max(hp, 0)
        teams_totalhp[team] = sum(teams_vehicles[team].values())

        if teams_totalhp[0] < teams_totalhp[1]:
            ratio = max(min(2.0 * teams_totalhp[0] / teams_totalhp[1] - 0.9, 1), 0)
            total_hp_color = color_gradient(hp_colors['neutral'], hp_colors['bad'], ratio)
            total_hp_sign = '<'
        elif teams_totalhp[0] > teams_totalhp[1]:
            ratio = max(min(2.0 * teams_totalhp[1] / teams_totalhp[0] - 0.9, 1), 0)
            total_hp_color = color_gradient(hp_colors['neutral'], hp_colors['good'], ratio)
            total_hp_sign = '>'
        else:
            total_hp_color = color_gradient(hp_colors['neutral'], hp_colors['neutral'], 1)
            total_hp_sign = '='
    except Exception, ex:
        err(traceback.format_exc())
 def updatePositions(self, iterator):
     if not self.__marker or not self.__currentWaypointSector:
         return
     else:
         sectorComponent = getattr(
             self.sessionProvider.arenaVisitor.getComponentSystem(),
             'sectorComponent', None)
         if sectorComponent is None:
             LOG_ERROR('Expected SectorComponent not present!')
             return
         waypointPosition = sectorComponent.getClosestWayPointForSectorAndTeam(
             self.__currentWaypointSector.sectorID,
             self.sessionProvider.arenaVisitor.type,
             avatar_getter.getPlayerTeam(),
             avatar_getter.getOwnVehiclePosition())
         if waypointPosition is None:
             return
         if waypointPosition != self.__currentWaypointPositon:
             self.__currentWaypointPositon = waypointPosition
             self._setMarkerPosition(
                 self.__marker, self.__currentWaypointPositon +
                 settings.MARKER_POSITION_ADJUSTMENT)
         return
Exemple #25
0
    def __checkRequiredData(self):
        result = self.__playerTeam > 0 and self.__playerVehicleID > 0
        if not result:
            requestToFind = False
            self.__playerTeam = avatar_getter.getPlayerTeam()
            if not self.__playerTeam:
                requestToFind = True
                LOG_NOTE("Player's team not found.")
            self.__playerVehicleID = avatar_getter.getPlayerVehicleID()
            if not self.__playerVehicleID:
                requestToFind = True
                LOG_NOTE("Player's vehicle ID not found.")
            if not requestToFind:
                return
            playerName = avatar_getter.getPlayerName()
            LOG_NOTE('Uses slow player search by name')
            for vo in self.__vInfoVOs.itervalues():
                if vo.player.name == playerName:
                    self.__playerTeam = vo.team
                    self.__playerVehicleID = vo.vehicleID
                    result = True
                    break

        return result
    def __checkRequiredData(self):
        result = self.__playerTeam > 0 and self.__playerVehicleID > 0
        if not result:
            requestToFind = False
            self.__playerTeam = avatar_getter.getPlayerTeam()
            if not self.__playerTeam:
                requestToFind = True
                LOG_NOTE("Player's team not found.")
            self.__playerVehicleID = avatar_getter.getPlayerVehicleID()
            if not self.__playerVehicleID:
                requestToFind = True
                LOG_NOTE("Player's vehicle ID not found.")
            if not requestToFind:
                return
            playerName = avatar_getter.getPlayerName()
            LOG_NOTE('Uses slow player search by name')
            for vo in self.__vInfoVOs.itervalues():
                if vo.player.name == playerName:
                    self.__playerTeam = vo.team
                    self.__playerVehicleID = vo.vehicleID
                    result = True
                    break

        return result
    def __onTransitionTimerUpdated(self, sectorGroupID, seconds):
        sc = getattr(self.sessionProvider.arenaVisitor.getComponentSystem(),
                     'sectorComponent', None)
        if sc is None:
            LOG_ERROR('Expected SectorComponent not present!')
            return
        else:
            isAttacker = avatar_getter.getPlayerTeam(
            ) == EPIC_BATTLE_TEAM_ID.TEAM_ATTACKER
            for marker in self.__markers.values():
                targetSectorGroup = sc.getSectorGroupById(marker.target)
                if isAttacker:
                    for targetSector in targetSectorGroup.sectors:
                        timerSectorId = sc.playerGroups[
                            targetSector.playerGroup].sectors.get(
                                targetSector.IDInPlayerGroup - 1, None)
                        if timerSectorId is not None and sc.getSectorById(
                                timerSectorId).groupID == sectorGroupID:
                            self.__updateTimer(marker, seconds)

                if marker.target == sectorGroupID:
                    self.__updateTimer(marker, seconds)

            return
Exemple #28
0
    def _updateTeamData(self, isEnemy, team, arenaDP, isFragsUpdate=True):
        pNamesList, fragsList, vNamesList, additionalDataList = ([], [], [],
                                                                 [])
        valuesHashes = []
        teamsList, teamScoreList = [], []
        playerIdx = -1
        playerTeamID = avatar_getter.getPlayerTeam()
        teamScores = defaultdict(list)
        teamIds = arenaDP.getMultiTeamsIndexes()
        camraVehicleID = self._battleUI.getCameraVehicleID()
        playerNameLength = int(self._battleUI.getPlayerNameLength(isEnemy))
        vehicleNameLength = int(self._battleUI.getVehicleNameLength(isEnemy))
        if self._arenaVisitor.hasRespawns():
            sortKey = vos_collections.WinPointsAndRespawnSortKey
        else:
            sortKey = vos_collections.WinPointsAndVehicleInfoSortKey
        collection = vos_collections.FalloutMultiTeamItemsCollection(
            sortKey=sortKey)
        for index, (vInfoVO,
                    vStatsVO) in enumerate(collection.iterator(arenaDP)):
            team = vInfoVO.team
            isEnemy = arenaDP.isEnemyTeam(team)
            ctx = makeTeamCtx(team, isEnemy, arenaDP, playerNameLength,
                              vehicleNameLength, camraVehicleID)
            if ctx.playerVehicleID == vInfoVO.vehicleID:
                playerIdx = index
            playerFullName = self._battleCtx.getPlayerFullName(
                vID=vInfoVO.vehicleID, showVehShortName=False)
            if not playerFullName:
                playerFullName = vInfoVO.player.getPlayerLabel()
            pName, frags, vName, additionalData, _ = self._battleUI.statsForm.getFormattedStrings(
                vInfoVO, vStatsVO, ctx, playerFullName)
            pNamesList.append(pName)
            fragsList.append(frags)
            vNamesList.append(vName)
            additionalDataList.append(additionalData)
            valuesHashes.append({
                'vehicleState':
                0 if vStatsVO.stopRespawn else VEHICLE_STATUS.IS_ALIVE,
                'vehicleType':
                vInfoVO.vehicleType.getClassName(),
                'teamColorScheme':
                'vm_enemy' if isEnemy else 'vm_ally'
            })
            teamIdx = teamIds[team]
            if (team, teamIdx) not in teamsList:
                teamsList.append((team, teamIdx))
            format = self._battleUI.statsForm.getTeamScoreFormat()
            teamScores[team].append((vStatsVO.interactive.winPoints, format))

        for team, _ in teamsList:
            teamScore = teamScores[team]
            totalScore = sum([score for score, _ in teamScore])
            scoreIndexForTable = len(teamScore) / 2
            for index, (score, format) in enumerate(teamScore):
                teamScoreStr = format % ' '
                if index == scoreIndexForTable:
                    teamScoreStr = format % BigWorld.wg_getNiceNumberFormat(
                        totalScore)
                teamScoreList.append(teamScoreStr)

        self._battleUI.setMultiteamValues(
            self._makeMultiTeamValues(playerTeamID, playerIdx, pNamesList,
                                      fragsList, vNamesList, teamsList,
                                      teamScoreList,
                                      additionalDataList, valuesHashes,
                                      arenaDP.getMultiTeamsType()))
Exemple #29
0
 def __addMarkerToPool(self, vehicleID, vInfo, vProxy=None):
     if not self.__needsMarker(vInfo):
         return
     else:
         if vProxy is not None:
             matrixProvider = self._clazz.fetchMatrixProvider(vProxy)
             active = True
         else:
             matrixProvider = None
             active = False
         markerID = self._createMarkerWithMatrix(self._getMarkerSymbol(vehicleID), matrixProvider=matrixProvider, active=active)
         self._setMarkerRenderInfo(markerID, _VEHICLE_MARKER_MIN_SCALE, _VEHICLE_MARKER_BOUNDS, _INNER_VEHICLE_MARKER_BOUNDS, _VEHICLE_MARKER_CULL_DISTANCE, _VEHICLE_MARKER_BOUNDS_MIN_SCALE)
         marker = self._clazz(markerID, vehicleID, vProxy=vProxy, active=active, isPlayerTeam=vInfo.team == avatar_getter.getPlayerTeam())
         marker.onVehicleModelChanged += self.__onVehicleModelChanged
         self._markers[vehicleID] = marker
         if marker.isActive():
             if not marker.isAlive():
                 self.__updateMarkerState(markerID, 'dead', True, '')
                 self._setMarkerBoundEnabled(markerID, False)
             elif not avatar_getter.isVehicleAlive() and marker.getIsPlayerTeam():
                 self._setMarkerBoundEnabled(markerID, False)
         return marker
 def _isFitByTeam(self, teamID):
     return teamID != avatar_getter.getPlayerTeam()
 def getTeamAmount(avatar = None):
     arena = avatar_getter.getArena(avatar)
     team = avatar_getter.getPlayerTeam(avatar)
     return len([ k for k, v in arena.vehicles.items() if v['team'] == team and v['isAlive'] ])
Exemple #32
0
 def __isAttacker(self):
     return avatar_getter.getPlayerTeam(
     ) == EPIC_BATTLE_TEAM_ID.TEAM_ATTACKER
 def _doAttentionToBase(self, senderID, baseId, baseName, duration):
     position = self.__baseList[baseId]
     isAtk = avatar_getter.getPlayerTeam(
     ) == EPIC_BATTLE_TEAM_ID.TEAM_ATTACKER
     entryName = _S_NAME.MARK_OBJECTIVE_ATK if isAtk else _S_NAME.MARK_OBJECTIVE_DEF
     self.__doAttentionToItem(position, entryName, duration)