def getReplyStateForTargetIDAndMarkerType(self, targetID, targetMarkerType):
        if targetMarkerType in self._chatCommands and targetID in self._chatCommands[targetMarkerType]:
            commands = self._chatCommands[targetMarkerType][targetID]
            for commandID, commandData in ((k, commands[k]) for k in reversed(commands)):
                commandName = _ACTIONS.battleChatCommandFromActionID(commandID).name
                if commandName not in BATTLE_CHAT_COMMANDS_BY_NAMES:
                    continue
                hasRepliedTo = avatar_getter.getPlayerVehicleID() in commandData.owners
                if hasRepliedTo:
                    return (ReplyState.CAN_CANCEL_REPLY, commandName)
                if commandName in ONE_SHOT_COMMANDS_TO_REPLIES.keys():
                    return (ReplyState.CAN_CONFIRM, commandName)
                return (ReplyState.CAN_REPLY, commandName)

        playerVehicleID = avatar_getter.getPlayerVehicleID()
        if playerVehicleID in self._chatCommands[targetMarkerType]:
            commands = self._chatCommands[targetMarkerType][playerVehicleID]
            for commandID, commandData in ((k, commands[k]) for k in reversed(commands)):
                if targetID in commandData.owners and self.__delayer.hasDelayedCallbackID(commandData.callbackID):
                    commandName = _ACTIONS.battleChatCommandFromActionID(commandID).name
                    if commandName not in BATTLE_CHAT_COMMANDS_BY_NAMES:
                        continue
                    return (ReplyState.CAN_CONFIRM, commandName)

        return (ReplyState.NO_REPLY, None)
 def invalidateVehicleInfo(self, flags, playerVehVO, arenaDP):
     voSquadIndex = playerVehVO.squadIndex
     if flags & INVALIDATE_OP.PREBATTLE_CHANGED and voSquadIndex > 0:
         squadMembersCount = arenaDP.getPrbVehCount(playerVehVO.team, playerVehVO.prebattleID)
         if squadMembersCount == SQUAD_MEMBERS_COUNT:
             myAvatarVehicle = arenaDP.getVehicleInfo(avatar_getter.getPlayerVehicleID())
             if playerVehVO.prebattleID == myAvatarVehicle.prebattleID:
                 if myAvatarVehicle.player.isPrebattleCreator:
                     self._squadCreatedImOwner(squadNum=voSquadIndex)
                 else:
                     self._squadCreatedImRecruit(squadNum=voSquadIndex)
             elif myAvatarVehicle.team == playerVehVO.team:
                 self._squadCreatedByAllies(squadNum=voSquadIndex)
             else:
                 self._squadCreatedByEnemies(squadNum=voSquadIndex)
         elif squadMembersCount == FULL_SQUAD_MEMBERS_COUNT:
             myAvatarVehicle = arenaDP.getVehicleInfo(avatar_getter.getPlayerVehicleID())
             playerVO = playerVehVO.player
             if playerVO.accountDBID == myAvatarVehicle.player.accountDBID:
                 self._iAmJoinedSquad(squadNum=voSquadIndex)
             elif myAvatarVehicle.team == playerVehVO.team:
                 if myAvatarVehicle.squadIndex == voSquadIndex:
                     self._someoneJoinedMySquad(squadNum=voSquadIndex, receiver=playerVO.name)
                 else:
                     self._someoneJoinedAlliedSquad(squadNum=voSquadIndex, receiver=playerVO.name)
             else:
                 self._someoneJoinedEnemySquad(squadNum=voSquadIndex, receiver=playerVO.name)
Example #3
0
 def process(self, playerVehVO, arenaDP):
     voSquadIndex = playerVehVO.squadIndex
     squadMembersCount = arenaDP.getVehiclesCountInPrebattle(playerVehVO.team, playerVehVO.prebattleID)
     if squadMembersCount == SQUAD_MEMBERS_COUNT:
         myAvatarVehicle = arenaDP.getVehicleInfo(avatar_getter.getPlayerVehicleID())
         if playerVehVO.prebattleID == myAvatarVehicle.prebattleID:
             if myAvatarVehicle.player.isPrebattleCreator:
                 self._squadCreatedImOwner(squadNum=voSquadIndex)
             else:
                 self._squadCreatedImRecruit(squadNum=voSquadIndex)
         elif myAvatarVehicle.team == playerVehVO.team:
             self._squadCreatedByAllies(squadNum=voSquadIndex)
         else:
             self._squadCreatedByEnemies(squadNum=voSquadIndex)
     elif squadMembersCount == FULL_SQUAD_MEMBERS_COUNT:
         myAvatarVehicle = arenaDP.getVehicleInfo(avatar_getter.getPlayerVehicleID())
         playerVO = playerVehVO.player
         if playerVO.accountDBID == myAvatarVehicle.player.accountDBID:
             self._iAmJoinedSquad(squadNum=voSquadIndex)
         elif myAvatarVehicle.team == playerVehVO.team:
             if myAvatarVehicle.squadIndex == voSquadIndex:
                 self._someoneJoinedMySquad(squadNum=voSquadIndex, receiver=playerVO.name)
             else:
                 self._someoneJoinedAlliedSquad(squadNum=voSquadIndex, receiver=playerVO.name)
         else:
             self._someoneJoinedEnemySquad(squadNum=voSquadIndex, receiver=playerVO.name)
 def invalidateVehicleInfo(self, flags, playerVehVO, arenaDP):
     voSquadIndex = playerVehVO.squadIndex
     if flags & INVALIDATE_OP.PREBATTLE_CHANGED and voSquadIndex > 0:
         squadMembersCount = arenaDP.getPrbVehCount(playerVehVO.team,
                                                    playerVehVO.prebattleID)
         if squadMembersCount == SQUAD_MEMBERS_COUNT:
             myAvatarVehicle = arenaDP.getVehicleInfo(
                 avatar_getter.getPlayerVehicleID())
             if playerVehVO.prebattleID == myAvatarVehicle.prebattleID:
                 if myAvatarVehicle.player.isPrebattleCreator:
                     self._squadCreatedImOwner(squadNum=voSquadIndex)
                 else:
                     self._squadCreatedImRecruit(squadNum=voSquadIndex)
             elif myAvatarVehicle.team == playerVehVO.team:
                 self._squadCreatedByAllies(squadNum=voSquadIndex)
             else:
                 self._squadCreatedByEnemies(squadNum=voSquadIndex)
         elif squadMembersCount == FULL_SQUAD_MEMBERS_COUNT:
             myAvatarVehicle = arenaDP.getVehicleInfo(
                 avatar_getter.getPlayerVehicleID())
             playerVO = playerVehVO.player
             if playerVO.accountDBID == myAvatarVehicle.player.accountDBID:
                 self._iAmJoinedSquad(squadNum=voSquadIndex)
             elif myAvatarVehicle.team == playerVehVO.team:
                 if myAvatarVehicle.squadIndex == voSquadIndex:
                     self._someoneJoinedMySquad(squadNum=voSquadIndex,
                                                receiver=playerVO.name)
                 else:
                     self._someoneJoinedAlliedSquad(squadNum=voSquadIndex,
                                                    receiver=playerVO.name)
             else:
                 self._someoneJoinedEnemySquad(squadNum=voSquadIndex,
                                               receiver=playerVO.name)
Example #5
0
def makeTeamCtx(team,
                isEnemy,
                arenaDP,
                playerLabelMaxLength,
                vehicleLabelMaxLength,
                cameraVehicleID=-1):
    if isEnemy:
        ctx = EnemyTeamCtx(team,
                           playerLabelMaxLength,
                           vehicleLabelMaxLength,
                           cameraVehicleID=cameraVehicleID)
    elif cameraVehicleID > 0:
        ctx = PostmortemTeamCtx(team, playerLabelMaxLength,
                                vehicleLabelMaxLength,
                                avatar_getter.getPlayerVehicleID(),
                                avatar_getter.isPlayerTeamKillSuspected(),
                                cameraVehicleID,
                                arenaDP.getVehicleInfo().prebattleID)
    else:
        ctx = PlayerTeamCtx(team, playerLabelMaxLength, vehicleLabelMaxLength,
                            avatar_getter.getPlayerVehicleID(),
                            avatar_getter.isPlayerTeamKillSuspected(),
                            cameraVehicleID,
                            arenaDP.getVehicleInfo().prebattleID)
    return ctx
 def __onReplyFeedbackReceived(self, ucmdID, replierID, markerType, oldReplyCount, newReplyCount):
     if markerType != MarkerType.BASE_MARKER_TYPE or ucmdID not in self.__markerIDs:
         return
     newReply = newReplyCount > oldReplyCount and replierID == avatar_getter.getPlayerVehicleID()
     if newReply:
         pass
     if newReplyCount < oldReplyCount and replierID == avatar_getter.getPlayerVehicleID() or newReplyCount <= 0:
         pass
def makeTeamCtx(team, isEnemy, arenaDP, playerLabelMaxLength, vehicleLabelMaxLength, cameraVehicleID = -1):
    if isEnemy:
        ctx = EnemyTeamCtx(team, playerLabelMaxLength, vehicleLabelMaxLength, cameraVehicleID=cameraVehicleID)
    elif cameraVehicleID > 0:
        ctx = PostmortemTeamCtx(team, playerLabelMaxLength, vehicleLabelMaxLength, avatar_getter.getPlayerVehicleID(), avatar_getter.isPlayerTeamKillSuspected(), cameraVehicleID, arenaDP.getVehicleInfo().prebattleID)
    else:
        ctx = PlayerTeamCtx(team, playerLabelMaxLength, vehicleLabelMaxLength, avatar_getter.getPlayerVehicleID(), avatar_getter.isPlayerTeamKillSuspected(), cameraVehicleID, arenaDP.getVehicleInfo().prebattleID)
    return ctx
 def __onReplyFeedbackReceived(self, ucmdID, replierID, markerType, oldReplyCount, newReplyCount):
     if markerType != MarkerType.HEADQUARTER_MARKER_TYPE or ucmdID not in self.__hqsDict:
         return
     playerHasReplied = replierID == avatar_getter.getPlayerVehicleID()
     if newReplyCount > oldReplyCount:
         if playerHasReplied:
             self._invoke(self.__hqsDict[ucmdID], BATTLE_MINIMAP_CONSTS.SET_STATE, BATTLE_MINIMAP_CONSTS.STATE_REPLY)
             self.__hasActiveCommit = True
         elif not self.__hasActiveCommit:
             self._invoke(self.__hqsDict[ucmdID], BATTLE_MINIMAP_CONSTS.SET_STATE, BATTLE_MINIMAP_CONSTS.STATE_IDLE)
     elif newReplyCount < oldReplyCount and replierID == avatar_getter.getPlayerVehicleID() or newReplyCount <= 0:
         self._invoke(self.__hqsDict[ucmdID], BATTLE_MINIMAP_CONSTS.SET_STATE, BATTLE_MINIMAP_CONSTS.STATE_IDLE)
         if playerHasReplied:
             self.__hasActiveCommit = False
 def __onReplyFeedbackReceived(self, ucmdID, replierID, markerType,
                               oldReplyCount, newReplyCount):
     if markerType != MarkerType.BASE_MARKER_TYPE:
         return
     else:
         newReply = newReplyCount > oldReplyCount
         playerHasReply = replierID == avatar_getter.getPlayerVehicleID()
         if ucmdID in self._TeamsOrControlsPointsPlugin__markerIDs and newReply:
             if playerHasReply:
                 self._invoke(
                     self._TeamsOrControlsPointsPlugin__markerIDs[ucmdID].
                     getID(), BATTLE_MINIMAP_CONSTS.SET_STATE,
                     BATTLE_MINIMAP_CONSTS.STATE_REPLY)
                 self._TeamsOrControlsPointsPlugin__hasActiveCommit = True
             elif not self._TeamsOrControlsPointsPlugin__hasActiveCommit:
                 self._invoke(
                     self._TeamsOrControlsPointsPlugin__markerIDs[ucmdID].
                     getID(), BATTLE_MINIMAP_CONSTS.SET_STATE,
                     BATTLE_MINIMAP_CONSTS.STATE_IDLE)
         if ucmdID in self._TeamsOrControlsPointsPlugin__markerIDs and (
             (newReplyCount < oldReplyCount and playerHasReply) or
             (newReplyCount <= 0)):
             self._invoke(
                 self._TeamsOrControlsPointsPlugin__markerIDs[ucmdID].getID(
                 ), BATTLE_MINIMAP_CONSTS.SET_STATE,
                 BATTLE_MINIMAP_CONSTS.STATE_IDLE)
             if playerHasReply:
                 self._TeamsOrControlsPointsPlugin__hasActiveCommit = False
         return
Example #10
0
 def isSquadMan(self, vID, prebattleID = None):
     if prebattleID is None:
         if not self.__playerVehicleID:
             self.__playerVehicleID = avatar_getter.getPlayerVehicleID()
         if self.__playerVehicleID in self.__vInfoVOs:
             prebattleID = self.__vInfoVOs[self.__playerVehicleID].prebattleID
     return self.__getStateFlag(vID, 'isSquadMan', playerTeam=self.__playerTeam, prebattleID=prebattleID)
 def __updateTeammate(self, vInfo, hpCurrent):
     if self.__arenaDP.isEnemyTeam(vInfo.team):
         return
     else:
         playerVehicleID = avatar_getter.getPlayerVehicleID()
         playerSquad = self.__arenaDP.getVehicleInfo(playerVehicleID).squadIndex
         isSquad = False
         if playerSquad > 0 and playerSquad == vInfo.squadIndex or playerSquad == 0 and vInfo.vehicleID == playerVehicleID:
             isSquad = True
         badgeID = vInfo.selectedBadge
         badge = buildBadge(badgeID, vInfo.getBadgeExtraInfo())
         badgeVO = badge.getBadgeVO(ICONS_SIZES.X24, {'isAtlasSource': True}, shortIconName=True) if badge else None
         suffixBadgeId = vInfo.selectedSuffixBadge
         self.as_setPlayerPanelInfoS({'vehID': vInfo.vehicleID,
          'name': vInfo.player.name,
          'badgeVO': badgeVO,
          'suffixBadgeIcon': 'badge_{}'.format(suffixBadgeId) if suffixBadgeId else '',
          'suffixBadgeStripIcon': 'strip_{}'.format(suffixBadgeId) if suffixBadgeId else '',
          'nameVehicle': vInfo.vehicleType.shortName,
          'typeVehicle': vInfo.vehicleType.classTag,
          'hpMax': vInfo.vehicleType.maxHealth,
          'hpCurrent': hpCurrent,
          'countPoints': self.getPoints(vInfo.vehicleID),
          'isSquad': isSquad})
         self.as_setPlayerPanelHpS(vInfo.vehicleID, vInfo.vehicleType.maxHealth, min(hpCurrent, vInfo.vehicleType.maxHealth))
         if hpCurrent <= 0:
             self.as_setPlayerDeadS(vInfo.vehicleID)
         return
Example #12
0
 def isSquadMan(self, vID, prebattleID = None):
     if prebattleID is None:
         if not self.__playerVehicleID:
             self.__playerVehicleID = avatar_getter.getPlayerVehicleID()
         if self.__playerVehicleID in self.__vInfoVOs:
             prebattleID = self.__vInfoVOs[self.__playerVehicleID].prebattleID
     return self.__getStateFlag(vID, 'isSquadMan', playerTeam=self.__playerTeam, prebattleID=prebattleID)
Example #13
0
 def __onSectorBaseCaptured(self, baseId, _):
     sectorBaseComp = getattr(self.sessionProvider.arenaVisitor.getComponentSystem(), 'sectorBaseComponent', None)
     if sectorBaseComp is not None:
         playerVehID = avatar_getter.getPlayerVehicleID()
         commands = self.sessionProvider.shared.chatCommands
         self.__removeActualTargetIfDestroyed(commands, playerVehID, baseId, MarkerType.BASE_MARKER_TYPE)
     return
Example #14
0
    def start(self):
        visitor = g_sessionProvider.arenaVisitor
        playerVehicleID = avatar_getter.getPlayerVehicleID()
        self.__playerTeam = avatar_getter.getPlayerTeam()
        self.__isTeamPlayer = not visitor.isSoloTeam(self.__playerTeam)
        self.__capturePoints = visitor.type.getFlagAbsorptionPoints()
        self.__spawnPoints = visitor.type.getFlagSpawnPoints()
        isFlagBearer = False
        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'])
            elif vehicleID == playerVehicleID:
                isFlagBearer = True

        if isFlagBearer:
            self.__addCaptureMarkers()
        super(_FlagsMarkerPlugin, self).start()
        return
Example #15
0
    def __removeReplyContributionFromPlayer(self, replierVehID, newTargetType, newTargetID):
        updatedCommand = None
        checkForRemovalOfCommandFromMarker = False
        for markerType in self._chatCommands:
            for targetID in self._chatCommands[markerType]:
                for commandID, commandData in self._chatCommands[markerType][targetID].iteritems():
                    isSameCommand = targetID == newTargetID and newTargetType == markerType
                    if not isSameCommand and replierVehID in commandData.owners:
                        oldOwnerCount = len(commandData.owners)
                        self.__chatCommandsUpdated(markerType, targetID, commandID, replierVehID, ChatCommandChange.CHAT_CMD_WAS_REMOVED)
                        commandData.owners.remove(replierVehID)
                        updatedCommand = (commandID, targetID)
                        self.__notifyReplyCommandUpdate(targetID, replierVehID, commandID, oldOwnerCount, len(commandData.owners))
                        if not commandData.owners and not commandData.command.isServerCommand():
                            checkForRemovalOfCommandFromMarker = True
                        break

        if updatedCommand is not None:
            cmdID, cmdTargetID = updatedCommand
            commandName = _ACTIONS.battleChatCommandFromActionID(cmdID).name
            if replierVehID == avatar_getter.getPlayerVehicleID() and self.__markerInFocus and self.__markerInFocus.isFocused(cmdTargetID, _COMMAND_NAME_TRANSFORM_MARKER_TYPE[commandName]):
                self.__setFocusedOnMarker(-1, MarkerType.INVALID_MARKER_TYPE, -1)
            if checkForRemovalOfCommandFromMarker:
                self.__tryRemovingCommandFromMarker(cmdID, cmdTargetID, commandName in AUTOCOMMIT_COMMAND_NAMES)
        return
Example #16
0
 def __onCommandReceived(self, cmd):
     if not self.__isCalloutEnabled or not self.__isIBCEnabled:
         return
     else:
         vehicleIDToAnswer = self.sessionProvider.getArenaDP(
         ).getVehIDBySessionID(cmd.getSenderID())
         commandName = _ACTIONS.battleChatCommandFromActionID(
             cmd.getID()).name
         if self.__isActive is True and vehicleIDToAnswer == avatar_getter.getPlayerVehicleID(
         ) and self.__commandReceivedData is not None and self.__commandReceivedData.name is not None and commandName == _CALLOUT_COMMANDS_TO_REPLY_COMMANDS[
                 self.__commandReceivedData.name]:
             self.__executeHide(True, self.__commandReceivedData.name)
         if commandName not in _CALLOUT_COMMANDS_TO_REPLY_COMMANDS.keys():
             return
         if cmd.isReceiver():
             currentTime = BigWorld.serverTime()
             isCalloutBlocked = currentTime < self.__lastCalloutTimestamp
             hasRecentPersonalMsg = currentTime < self.__lastPersonalMsgTimestamp
             if self.__isActive is False and not isCalloutBlocked and not hasRecentPersonalMsg:
                 self.__commandReceivedData = CommandReceivedData(
                     commandName, vehicleIDToAnswer)
                 if self.__ui:
                     self.__ui.setShowData(vehicleIDToAnswer, commandName)
                     self.__isActive = True
                     self.delayCallback(_HINT_TIMEOUT, self.__executeHide)
                 self.__lastCalloutTimestamp = currentTime + _CALLOUT_MESSAGES_BLOCK_DURATION
                 CalloutController.fireCalloutDisplayEvent(True)
             if cmd.isPrivate() and not hasRecentPersonalMsg:
                 self.__lastPersonalMsgTimestamp = currentTime + _PERSONAL_MESSAGE_MUTE_DURATION
         return
Example #17
0
 def onVehicleHealthChanged(self, vehicleID, newHealth, attackerID,
                            attackReasonID):
     inv = INV.CUR_HEALTH
     userData = None
     if attackerID == avatar_getter.getPlayerVehicleID():
         inv |= INV.DAMAGE_CAUSED
     self.updatePlayerState(vehicleID, inv, userData)
 def __onVehicleStateUpdated(self, state, value):
     playerVehicleID = avatar_getter.getPlayerVehicleID()
     vInfo = self.__arenaDP.getVehicleInfo(playerVehicleID)
     if state == VEHICLE_VIEW_STATE.HEALTH:
         self.__updateTeammate(vInfo, health=value)
     elif state == VEHICLE_VIEW_STATE.DESTROYED:
         self.__updateTeammate(vInfo, health=0)
Example #19
0
    def _makeData(self):
        arenaDP = g_sessionProvider.getArenaDP()
        teamIds = arenaDP.getMultiTeamsIndexes()
        playerVehID = getPlayerVehicleID()
        allyTeams = arenaDP.getAllyTeams()
        isSquadPlayer = arenaDP.isSquadMan(playerVehID)
        teamScores = {}
        enemyScore = 0
        enemyName = ''
        allyScore = 0
        for vInfoVO, _, viStatsVO in arenaDP.getAllVehiclesIterator():
            points = viStatsVO.winPoints
            if vInfoVO.team in allyTeams:
                allyScore += points
            else:
                if vInfoVO.team in teamScores:
                    currentScore = teamScores[vInfoVO.team]
                    totalScore = currentScore + points
                else:
                    totalScore = points
                teamScores[vInfoVO.team] = totalScore
                if totalScore > enemyScore:
                    enemyScore = totalScore
                    squadIndex = teamIds[vInfoVO.team]
                    enemyName = i18n.makeString(INGAME_GUI.SCOREPANEL_SQUADLBL, sq_number=squadIndex) if squadIndex else vInfoVO.player.name

        if isSquadPlayer:
            playerName = i18n.makeString(INGAME_GUI.SCOREPANEL_MYSQUADLBL)
        else:
            playerName = getPlayerName()
        self.as_setDataS(self._contextType, self._maxScore, 0, allyScore, enemyScore, playerName, enemyName, _TEAM_PROPS)
Example #20
0
    def _makeData(self):
        arenaDP = g_sessionProvider.getArenaDP()
        teamIds = arenaDP.getMultiTeamsIndexes()
        playerVehID = getPlayerVehicleID()
        allyTeams = arenaDP.getAllyTeams()
        isSquadPlayer = arenaDP.isSquadMan(playerVehID)
        teamScores = {}
        enemyScore = 0
        enemyName = ''
        allyScore = 0
        for vInfoVO, _, viStatsVO in arenaDP.getAllVehiclesIterator():
            points = viStatsVO.winPoints
            if vInfoVO.team in allyTeams:
                allyScore += points
            else:
                if vInfoVO.team in teamScores:
                    currentScore = teamScores[vInfoVO.team]
                    totalScore = currentScore + points
                else:
                    totalScore = points
                teamScores[vInfoVO.team] = totalScore
                if totalScore > enemyScore:
                    enemyScore = totalScore
                    squadIndex = teamIds[vInfoVO.team]
                    enemyName = i18n.makeString(INGAME_GUI.SCOREPANEL_SQUADLBL, sq_number=squadIndex) if squadIndex else vInfoVO.player.name

        if isSquadPlayer:
            playerName = i18n.makeString(INGAME_GUI.SCOREPANEL_MYSQUADLBL)
        else:
            playerName = getPlayerName()
        self.__allyScore = allyScore
        self.__enemyScore = enemyScore
        self.as_setDataS(self._contextType, self._maxScore, 0, allyScore, enemyScore, playerName, enemyName, _TEAM_PROPS)
 def showActionMarker(self, vehicleID, vMarker='', mMarker=''):
     if vMarker and vehicleID != avatar_getter.getPlayerVehicleID():
         self.onVehicleFeedbackReceived(_FET.VEHICLE_SHOW_MARKER, vehicleID,
                                        vMarker)
     if mMarker:
         self.onMinimapFeedbackReceived(_FET.MINIMAP_SHOW_MARKER, vehicleID,
                                        mMarker)
Example #22
0
 def __addCommandToList(self, commandID, commandName, commandCreatorID, commandTargetID, command, activeTime=_DEFAULT_ACTIVE_COMMAND_TIME):
     markerType = _COMMAND_NAME_TRANSFORM_MARKER_TYPE[commandName]
     if markerType not in self._chatCommands:
         self._chatCommands[markerType] = dict()
     owners = []
     uniqueCBID = None
     if not command.isServerCommand():
         self.__tryRemovalOfPreviousLocationCommands(commandCreatorID)
         if commandName in AUTOCOMMIT_COMMAND_NAMES:
             self.__removeReplyContributionFromPlayer(commandCreatorID, markerType, commandTargetID)
         uniqueCBID = self.__getUniqueCallbackID()
         self.__delayer.delayCallback(uniqueCBID, activeTime, self.__removeCommandMarkerCB, commandID, commandTargetID)
         if commandName in AUTOCOMMIT_COMMAND_NAMES:
             owners.append(commandCreatorID)
     if commandTargetID not in self._chatCommands[markerType]:
         self._chatCommands[markerType][commandTargetID] = OrderedDict()
     self._chatCommands[markerType][commandTargetID].update({commandID: AdvancedChatCommandData(command=command, commandCreatorVehID=commandCreatorID, callbackID=uniqueCBID, owners=owners)})
     if self.sessionProvider.shared.feedback:
         self.sessionProvider.shared.feedback.onCommandAdded(commandTargetID, markerType)
     updateCmdType = ChatCommandChange.CHAT_CMD_WAS_REPLIED if commandName in AUTOCOMMIT_COMMAND_NAMES else ChatCommandChange.CHAT_CMD_TRIGGERED
     self.__chatCommandsUpdated(markerType, commandTargetID, commandID, commandCreatorID, updateCmdType)
     isTemporarySticky = command and not command.isInSilentMode() and command.isTemporarySticky() and not commandCreatorID == avatar_getter.getPlayerVehicleID()
     if isTemporarySticky:
         self.__temporaryStickyCommands[commandID][commandTargetID] = (commandTargetID, markerType)
     if commandCreatorID == avatar_getter.getPlayerVehicleID() and commandName in AUTOCOMMIT_COMMAND_NAMES or isTemporarySticky:
         BigWorld.callback(0.1, partial(self.__setInFocusCB, commandID, commandTargetID, markerType, commandName in ONE_SHOT_COMMANDS_TO_REPLIES.keys(), isTemporarySticky))
     return
 def _canActivate(self, entityName=None, avatar=None):
     vehicle = BigWorld.entities.get(avatar_getter.getPlayerVehicleID())
     isAlive = avatar_getter.isVehicleAlive()
     return (
         True,
         None) if vehicle and isAlive and self.__hasDebuffComponentsForStop(
             vehicle) else super(_RepairBattleRoyaleCrewAndModules,
                                 self)._canActivate(entityName, avatar)
Example #24
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
 def isTeamKiller(self, playerTeam=None):
     if playerTeam is not None and self.team != playerTeam:
         return False
     elif self.vehicleID == avatar_getter.getPlayerVehicleID() and avatar_getter.isPlayerTeamKillSuspected():
         return True
     else:
         return self.playerStatus & _PLAYER_STATUS.IS_TEAM_KILLER > 0
         return
Example #26
0
 def onVehicleHealthChanged(self, vehicleID, newHealth, attackerID, attackReasonID):
     inv = INV.CUR_HEALTH
     userData = None
     if attackerID == avatar_getter.getPlayerVehicleID():
         inv |= INV.HITLOG
         userData = {'damageFlag':self._getVehicleDamageType(attackerID),
                     'damageType':constants.ATTACK_REASONS[attackReasonID]}
     self.updatePlayerState(vehicleID, inv, userData)
Example #27
0
 def isTeamKiller(self, playerTeam = None):
     if playerTeam is not None and self.team != playerTeam:
         return False
     elif self.vehicleID == avatar_getter.getPlayerVehicleID() and avatar_getter.isPlayerTeamKillSuspected():
         return True
     else:
         return self.playerStatus & _PLAYER_STATUS.IS_TEAM_KILLER > 0
         return
Example #28
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
Example #29
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 __checkIfAccountCreatedOrJoinedDynSquad(self, playerVehVO, arenaDP):
     voSquadIndex = playerVehVO.squadIndex
     if voSquadIndex == 0 or self.__wasOwnSquadCreated:
         return
     myAvatarVehicle = arenaDP.getVehicleInfo(avatar_getter.getPlayerVehicleID())
     if playerVehVO.prebattleID == myAvatarVehicle.prebattleID:
         self.__wasOwnSquadCreated = True
         self.onDynSquadCreatedOrJoined(myAvatarVehicle.player.isPrebattleCreator, myAvatarVehicle.prebattleID)
 def _onReplyFeedbackReceived(self, targetID, replierID, markerType,
                              oldReplyCount, newReplyCount):
     marker = self._getMarkerFromTargetID(targetID, markerType)
     if marker is not None:
         self._setMarkerRepliesAndCheckState(
             marker, newReplyCount,
             replierID == avatar_getter.getPlayerVehicleID())
     return
Example #32
0
def SixthSenseIndicator_as_showS(self):
    try:
        if config.get('sounds/enabled'):
            vehCD = getVehCD(avatar_getter.getPlayerVehicleID())
            # 59393 => Rudy
            soundId = XVM_SOUND_EVENT.SIXTH_SENSE_RUDY if vehCD == 59393 else XVM_SOUND_EVENT.SIXTH_SENSE
            SoundGroups.g_instance.playSound2D(soundId)
    except:
        err(traceback.format_exc())
Example #33
0
 def start(self, vehsList):
     self._populate(self.__proxy.getMember('_level0.battleRespawnView').getInstance())
     slotsData = self.__getSlotsData(vehsList)
     generalData = self.__getGeneralData()
     arenaType = BigWorld.player().arena.arenaType
     arenaDP = g_sessionProvider.getArenaDP()
     playerVehID = getPlayerVehicleID()
     helpText = getHelpText(arenaType)
     self.as_initializeS(generalData, slotsData, helpText)
Example #34
0
 def __onVehicleEnterWorld(self, vehicle):
     avatar = BigWorld.player()
     pVehId = avatar_getter.getPlayerVehicleID()
     if vehicle.id == pVehId:
         self.updateXP(vehicle.battleXP.battleXP, vehicle.id)
         avatar.onVehicleEnterWorld -= self.__onVehicleEnterWorld
         self.__installInitialModules()
         self.__cacheInitialModules(vehicle)
         self.__isStarted = True
Example #35
0
 def setPlayerLaneByPlayerGroups(self):
     playerId = avatar_getter.getPlayerVehicleID()
     playerGroups = self.playerGroups
     if playerGroups and playerId is not 0 and playerId in playerGroups:
         self.__respawnLane = playerGroups[playerId]
         self.onPlayerRespawnLaneUpdated(self.__respawnLane)
         self.setPhysicalLane(self.__respawnLane,
                              self.__physicalSectorGroup,
                              force=True)
Example #36
0
 def switchToPostmortem(self, noRespawnPossible, respawnAvailable):
     self.__isRqToSwitch = False
     if avatar_getter.getPlayerVehicleID() == self.__vehicleID:
         if self.__updater is not None:
             self.__updater.stop()
             self.__updater.updateOnce()
     self.__isInPostmortem = True
     self.onPostMortemSwitched(noRespawnPossible, respawnAvailable)
     return
Example #37
0
def SixthSenseIndicator_as_showS(self):
    try:
        if config.get('sounds/enabled'):
            vehCD = getVehCD(avatar_getter.getPlayerVehicleID())
            # 59393 => Rudy
            soundId = XVM_SOUND_EVENT.SIXTH_SENSE_RUDY if vehCD == 59393 else XVM_SOUND_EVENT.SIXTH_SENSE
            SoundGroups.g_instance.playSound2D(soundId)
    except:
        err(traceback.format_exc())
Example #38
0
 def __handlePrivateCommand(self, cmd):
     vehicleInfo = self.__findVehicleInfoByDatabaseID(cmd.getSenderID())
     if cmd.isReceiver() or cmd.isSender():
         self.__playSound(cmd)
         if vehicleInfo is None:
             vehicleInfo = self.__findVehicleInfoByVehicleID(avatar_getter.getPlayerVehicleID())
         vehicleID = vehicleInfo.vehicleID if vehicleInfo else 0
         vMarker = cmd.getVehMarker(vehicle=vehicleInfo)
         if vMarker and vehicleID:
             self.__feedback.showActionMarker(vehicleID, vMarker, cmd.getVehMarker())
 def _isSquadAllowToInvite(self, arenaDP):
     allow = True
     avatarVeh = arenaDP.getVehicleInfo(avatar_getter.getPlayerVehicleID())
     avatarSquadIndex = avatarVeh.squadIndex
     if avatarSquadIndex > 0:
         if avatarVeh.player.isPrebattleCreator:
             allow = not arenaDP.getVehiclesCountInPrebattle(avatarVeh.team, avatarVeh.prebattleID) >= SquadRoster.MAX_SLOTS
         else:
             allow = False
     return allow
Example #40
0
 def __onArenaVehicleKilled(self, targetID, attackerID, equipmentID, reason, numVehiclesAffected):
     if self.__markerInFocus is None or not self.sessionProvider.shared.chatCommands:
         return
     else:
         playerVehID = avatar_getter.getPlayerVehicleID()
         commands = self.sessionProvider.shared.chatCommands
         self.__removeActualTargetIfDestroyed(commands, playerVehID, targetID, MarkerType.VEHICLE_MARKER_TYPE)
         if playerVehID == targetID:
             commands.sendClearChatCommandsFromTarget(targetID, self.__markerInFocus.markerType.name)
         return
Example #41
0
 def __handleMark3DPosition(self, commandTargetID, creatorVehicleID, commandID, commandName, commandDuration, cmd):
     if commandName == BATTLE_CHAT_COMMAND_NAMES.GOING_THERE:
         self.__addPositiveMarkerAboveCreator(creatorVehicleID)
     position = cmd.getMarkedPosition()
     markerType = _COMMAND_NAME_TRANSFORM_MARKER_TYPE[commandName]
     commandData = self._chatCommands[markerType][commandTargetID][commandID]
     numberOfReplies = len(commandData.owners)
     isTargetForPlayer = avatar_getter.getPlayerVehicleID() in commandData.owners
     g_locationPointManager.addLocationPoint(position, commandTargetID, creatorVehicleID, commandID, commandDuration, None, numberOfReplies, isTargetForPlayer)
     return
 def switchToPostmortem(self):
     """
     Switches to postmortem mode.
     """
     self.__isRqToSwitch = False
     if avatar_getter.getPlayerVehicleID() == self.__vehicleID:
         self.__waitingTI.stop()
         if self.__updater is not None:
             self.__updater.stop()
     self.onPostMortemSwitched()
     return
Example #43
0
def _PersonalEntriesPlugin_start(base, self):
    base(self)
    if g_minimap.active and g_minimap.opt_linesEnabled:
        if not self._PersonalEntriesPlugin__yawLimits:
            vehicle = avatar_getter.getArena().vehicles.get(avatar_getter.getPlayerVehicleID())
            staticTurretYaw = vehicle['vehicleType'].gun.staticTurretYaw
            if staticTurretYaw is None:
                vInfoVO = self._arenaDP.getVehicleInfo()
                yawLimits = vInfoVO.vehicleType.turretYawLimits
                if yawLimits:
                    self._PersonalEntriesPlugin__yawLimits = (math.degrees(yawLimits[0]), math.degrees(yawLimits[1]))
Example #44
0
 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)
Example #45
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()
Example #46
0
 def _getVehicleDamageType(self, attackerID):
     entryVehicle = avatar_getter.getArena().vehicles.get(attackerID, None)
     if not entryVehicle:
         return markers2d_settings.DAMAGE_TYPE.FROM_UNKNOWN
     if attackerID == avatar_getter.getPlayerVehicleID():
         return markers2d_settings.DAMAGE_TYPE.FROM_PLAYER
     entityName = self.sessionProvider.getCtx().getPlayerGuiProps(attackerID, entryVehicle['team'])
     if entityName == PLAYER_GUI_PROPS.squadman:
         return markers2d_settings.DAMAGE_TYPE.FROM_SQUAD
     if entityName == PLAYER_GUI_PROPS.ally:
         return markers2d_settings.DAMAGE_TYPE.FROM_ALLY
     if entityName == PLAYER_GUI_PROPS.enemy:
         return markers2d_settings.DAMAGE_TYPE.FROM_ENEMY
     return markers2d_settings.DAMAGE_TYPE.FROM_UNKNOWN
Example #47
0
 def __getVehicleDamageType(self, attackerInfo):
     if not attackerInfo:
         return settings.DAMAGE_TYPE.FROM_UNKNOWN
     attackerID = attackerInfo.vehicleID
     if attackerID == avatar_getter.getPlayerVehicleID():
         return settings.DAMAGE_TYPE.FROM_PLAYER
     entityName = g_sessionProvider.getCtx().getPlayerGuiProps(attackerID, attackerInfo.team)
     if entityName == PLAYER_GUI_PROPS.squadman:
         return settings.DAMAGE_TYPE.FROM_SQUAD
     if entityName == PLAYER_GUI_PROPS.ally:
         return settings.DAMAGE_TYPE.FROM_ALLY
     if entityName == PLAYER_GUI_PROPS.enemy:
         return settings.DAMAGE_TYPE.FROM_ENEMY
     return settings.DAMAGE_TYPE.FROM_UNKNOWN
Example #48
0
    def _makeData(self):
        arenaDP = g_sessionProvider.getArenaDP()
        playerVehID = getPlayerVehicleID()
        allyTeams = arenaDP.getAllyTeams()
        allyScore, enemyScore, playerScore = (0, 0, 0)
        for vInfoVO, _, viStatsVO in arenaDP.getAllVehiclesIterator():
            points = viStatsVO.winPoints
            if vInfoVO.team in allyTeams:
                allyScore += points
                if vInfoVO.vehicleID == playerVehID:
                    playerScore += points
            else:
                enemyScore += points

        self.as_setDataS(self._contextType, self._maxScore, playerScore, allyScore, enemyScore, '', '', {})
 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)
Example #50
0
 def __handlePublicCommand(self, cmd):
     senderInfo = self.__findVehicleInfoByDatabaseID(cmd.getSenderID())
     if senderInfo is None:
         senderInfo = self.__findVehicleInfoByVehicleID(avatar_getter.getPlayerVehicleID())
     showReceiver = cmd.showMarkerForReceiver()
     recvMarker, senderMarker = cmd.getVehMarkers(vehicle=senderInfo)
     receiverID = cmd.getFirstTargetID()
     senderID = senderInfo.vehicleID if senderInfo else 0
     if showReceiver:
         if receiverID:
             self.__feedback.showActionMarker(receiverID, recvMarker, recvMarker)
         if senderID:
             self.__feedback.showActionMarker(senderID, senderMarker, senderMarker)
     elif senderID:
         self.__feedback.showActionMarker(senderID, recvMarker, recvMarker)
 def invalidateVehicleInfo(self, flags, playerVehVO, arenaDP):
     if arena_info.getArenaGuiType == ARENA_GUI_TYPE.RANDOM:
         if flags & INVALIDATE_OP.PREBATTLE_CHANGED and playerVehVO.squadIndex > 0:
             vID = playerVehVO.vehicleID
             squadMansToUpdate = ()
             avatarVehID = avatar_getter.getPlayerVehicleID()
             aVehInfo = arenaDP.getVehicleInfo(avatarVehID)
             if vID == avatarVehID:
                 squadMansToUpdate = arenaDP.getVehIDsByPrebattleID(aVehInfo.team, aVehInfo.prebattleID) or tuple()
                 if avatarVehID in squadMansToUpdate:
                     del squadMansToUpdate[squadMansToUpdate.index(avatarVehID)]
             elif aVehInfo.team == playerVehVO.team:
                 if arenaDP.isSquadMan(vID):
                     squadMansToUpdate = (vID,)
             for sqVehID in squadMansToUpdate:
                 for client in self.__clients:
                     client.updateSquadmanVeh(sqVehID)
Example #52
0
    def _makeData(self):
        arenaDP = g_sessionProvider.getArenaDP()
        playerVehID = getPlayerVehicleID()
        allyTeams = arenaDP.getAllyTeams()
        allyScore, enemyScore, playerScore = (0, 0, 0)
        for vInfoVO, _, viStatsVO in arenaDP.getAllVehiclesIterator():
            points = viStatsVO.winPoints
            if vInfoVO.team in allyTeams:
                allyScore += points
                if vInfoVO.vehicleID == playerVehID:
                    playerScore += points
            else:
                enemyScore += points

        self.as_setDataS(self._contextType, self._maxScore, playerScore, allyScore, enemyScore, '', '', {})
        self._score = (allyScore, enemyScore)
        g_eventBus.handleEvent(events.ScoreEvent(events.ScoreEvent.FRAGS_UPDATED, ctx={'ally': allyScore,
         'enemy': enemyScore}), EVENT_BUS_SCOPE.BATTLE)
Example #53
0
    def _get_battle(self):
        arenaUniqueID = avatar_getter.getArenaUniqueID()
        if arenaUniqueID is None or arenaUniqueID != self.arenaId:
            self.arenaId = arenaUniqueID
            self.players = {}

        # update players
        self._loadingClanIconsCount = 0
        vehicles = avatar_getter.getArena().vehicles
        for (vehicleID, vData) in vehicles.iteritems():
            if vehicleID not in self.players:
                pl = _Player(vehicleID, vData)
                self._load_clanIcon(pl)
                # cleanup same player with different vehicleID (bug?)
                self.players = {k:v for k,v in self.players.iteritems() if v.accountDBID != pl.accountDBID}
                self.players[vehicleID] = pl
            self.players[vehicleID].update(vData)

        # sleepCounter = 0
        while self._loadingClanIconsCount > 0:
            time.sleep(0.01)

            # # FIX: temporary workaround
            # sleepCounter += 1
            # if sleepCounter > 1000: # 10 sec
            #    log('WARNING: icons loading too long')
            #    break;

        self._load_stat(avatar_getter.getPlayerVehicleID())

        players = {}
        for (vehicleID, pl) in self.players.iteritems():
            cacheKey = "%d=%d" % (pl.accountDBID, pl.vehCD)
            if cacheKey not in self.cacheBattle:
                cacheKey2 = "%d" % pl.accountDBID
                if cacheKey2 not in self.cacheBattle:
                    self.cacheBattle[cacheKey] = self._get_battle_stub(pl)
            stat = self.cacheBattle[cacheKey]
            self._fix(stat)
            players[pl.name] = stat
        # pprint(players)

        with self.lock:
            self.resp = {'players': players}
Example #54
0
def getGlobalBattleData():
    vehicleID = avatar_getter.getPlayerVehicleID()
    arena = avatar_getter.getArena()
    arenaVehicle = arena.vehicles.get(vehicleID)
    vehCD = getVehCD(vehicleID)
    clan = arenaVehicle['clanAbbrev']
    if not clan:
        clan = None
    return (
        vehicleID,                                  # playerVehicleID
        arenaVehicle['name'],                       # playerName
        clan,                                       # playerClan
        vehCD,                                      # playerVehCD
        arena.extraData.get('battleLevel', 0),      # battleLevel
        arena.bonusType,                            # battleType
        arena.guiType,                              # arenaGuiType
        utils.getMapSize(),                         # mapSize
        minimap_circles.getMinimapCirclesData(),    # minimapCirclesData
        vehinfo.getXtdbDataArray(vehCD))            # xtdb_data
    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
Example #56
0
 def setVehicleNewHealth(self, vehicleID, newHealth, attackerID = 0, attackReasonID = -1):
     if not self.__isEnabled:
         return
     elif not newHealth:
         return
     elif not attackerID or attackerID != avatar_getter.getPlayerVehicleID():
         return
     else:
         vo = self.__arenaDP.getVehicleInfo(vehicleID)
         if vo.team != self.__arenaDP.getNumberOfTeam(enemy=True):
             return
         elif attackReasonID >= len(_AR):
             return
         LOG_DEBUG("Enemy's vehicle health has been changed by player action", newHealth, _AR[attackReasonID])
         if _AR[attackReasonID] == 'ramming':
             if self.__rammingCallbackID is None:
                 self.__setRammingCooldown()
                 self.__pushPlayerEvent(_EVENT_ID.PLAYER_DAMAGED_HP_ENEMY)
             else:
                 BigWorld.cancelCallback(self.__rammingCallbackID)
                 self.__setRammingCooldown()
         return
Example #57
0
    def _makeData(self):
        arenaDP = g_sessionProvider.getArenaDP()
        teamIds = arenaDP.getMultiTeamsIndexes()
        playerVehID = avatar_getter.getPlayerVehicleID()
        allyTeams = arenaDP.getAllyTeams()
        isSquadPlayer = arenaDP.isSquadMan(playerVehID)
        teamScores = {}
        enemyScore = 0
        enemyName = ''
        allyScore = 0
        collection = vos_collections.VehiclesItemsCollection()
        for vInfoVO, vStatsVO in collection.iterator(arenaDP):
            points = vStatsVO.winPoints
            if vInfoVO.team in allyTeams:
                allyScore += points
            else:
                if vInfoVO.team in teamScores:
                    currentScore = teamScores[vInfoVO.team]
                    totalScore = currentScore + points
                else:
                    totalScore = points
                teamScores[vInfoVO.team] = totalScore
                if totalScore > enemyScore:
                    enemyScore = totalScore
                    squadIndex = teamIds[vInfoVO.team]
                    enemyName = i18n.makeString(INGAME_GUI.SCOREPANEL_SQUADLBL, sq_number=squadIndex) if squadIndex else vInfoVO.player.name

        if isSquadPlayer:
            playerName = i18n.makeString(INGAME_GUI.SCOREPANEL_MYSQUADLBL)
        else:
            playerName = avatar_getter.getPlayerName()
            if arenaDP.isTeamKiller(playerVehID):
                playerName = makeHtmlString('html_templates:battle', 'fallouScorePanelTeamKiller', playerName)
        self.__allyScore = allyScore
        self.__enemyScore = enemyScore
        self.as_setDataS(self._contextType, self._maxScore, 0, allyScore, enemyScore, playerName, enemyName, _TEAM_PROPS)
        self._score = (allyScore, enemyScore)
        g_eventBus.handleEvent(events.ScoreEvent(events.ScoreEvent.FRAGS_UPDATED, ctx={'ally': allyScore,
         'enemy': enemyScore}), EVENT_BUS_SCOPE.BATTLE)
Example #58
0
    def start(self):
        visitor = g_sessionProvider.arenaVisitor
        playerVehicleID = avatar_getter.getPlayerVehicleID()
        self.__playerTeam = avatar_getter.getPlayerTeam()
        self.__isTeamPlayer = not visitor.isSoloTeam(self.__playerTeam)
        self.__capturePoints = visitor.type.getFlagAbsorptionPoints()
        self.__spawnPoints = visitor.type.getFlagSpawnPoints()
        isFlagBearer = False
        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'])
            elif vehicleID == playerVehicleID:
                isFlagBearer = True

        if isFlagBearer:
            self.__addCaptureMarkers()
        super(_FlagsMarkerPlugin, self).start()
        return