Editing and Customization > Community Content

[Gameplay] Freeze Tag Mode

<< < (8/10) > >>

killermonkey:
I can add getting the steam id to my list of python API enhancements.

Joe:

--- Quote from: killermonkey on November 21, 2012, 05:38:03 pm ---I can add getting the steam id to my list of python API enhancements.

--- End quote ---

Thanks

Joe:
I've fixed 2 bugs in the latest development version and I've improved the script's code.

The spectator view bug is now the only bug I need to fix before I can release beta 1.0.


--- Code: ---
from . import GEScenario
from GamePlay.Utils.GEPlayerTracker import GEPlayerTracker
from Utils.GETimer import TimerTracker, Timer
from collections import defaultdict

import GEPlayer, GEUtil, GEMPGameRules, GEGlobal

USING_API = GEGlobal.API_VERSION_1_0_0

'''
I chose to implement this mode by editing the "You Only Live Twice" mode script. So
this script uses lots of code that was created by the author(s) of the YOLT script.

I've also reused code from the "Capture The Key" mode's script.

Unresolved bugs:
* When an eliminated & unspawned player changes their team to spectator, there is a problem with their spectator view.

@author: Joe
@version: Dev 24.00 (22/11/12 0:31 GMT)
'''

class DieAnotherDay( GEScenario ):
    MRE_MODEL = "models/players/bond/bond.mdl"
    JRE_MODEL = "models/players/jaws/jaws.mdl"
   
    COLOR_MI6_RADAR = GEUtil.Color( 94, 171, 231, 255 )
    COLOR_JANUS_RADAR = GEUtil.Color( 206, 43, 43, 255 )
   
    JBountyFontColour = GEUtil.CColor( 206, 43, 43, 255 )
    MBountyFontColour = GEUtil.CColor( 100, 184, 234, 220 )
   
    #Progress bar positions
    MBountyPBX = 0.4
    MBountyPBY = 0
   
    JBountyPBX = 0.6
    JBountyPBY = 0
   
    ResurrectionPBX = -1
    ResurrectionPBY = 0.6
    #-------------------------
   
    resurrectionTime = 5.0
   
    TR_ELIMINATED = "eliminated"
    TR_SPAWNED = "spawned"
   
    TOKEN_MI6 = 'token_mi6'
    TOKEN_JANUS = 'token_janus'
   
    #Progress Bar Indexs
    MBountyPBIndex = 0
    JBountyPBIndex = 1
    ResurrectionPBIndex = 2

    def __init__( self ):
        super( DieAnotherDay, self ).__init__()
       
        self.radar = None
       
        self.eliminateNewPlayers = False

        self.waitingForPlayers = False
        self.radarSet = False
        self.mi6Bounty = 0
        self.janusBounty = 0
        self.pltracker = GEPlayerTracker( self )
       
        self.timerTracker = TimerTracker( self )
        self.tokenManager = GEMPGameRules.GetTokenMgr()
       
        self.changingTeamPlayers = {}
       
        #Eliminated player collections
        self.mResurrectionQueue = []
        self.jResurrectionQueue = []
       
        self.eliminatedSpectators = []
       
        #Collections related to resurrection area entities
        self.mAreaIDs = []
        self.jAreaIDs = []
       
        self.mAreaLocations = []
        self.jAreaLocations = []
       
        self.resurrectionAreaUserLists = defaultdict(list)
       
    def OnLoadGamePlay( self ):
        GEUtil.PrecacheModel( self.MRE_MODEL )
        GEUtil.PrecacheModel( self.JRE_MODEL )

    def Cleanup( self ):
        super( DieAnotherDay, self ).Cleanup()
        self.pltracker = None

    def GetPrintName( self ):
        return "Die Another Day"

    def GetScenarioHelp( self, help_obj ):
        #TODO use UI Language Files:
        help_obj.SetDescription(
                                 """
Based on: Mefy's MOHAA Freeze Tag Mode
Version: Dev 24.00

*Eliminate the opposing team.
*Resurrect your eliminated team mates.
*To resurrect a team mate stand next
to them.
   
The ability to resurrect players from
a long distance will be added in
version 2.00, if it can be implemented.
                                 """)
       
    def GetGameDescription( self ):
        return "Die Another Day"

    def OnPlayerConnect( self, player ):
        self.pltracker.SetValue( player, self.TR_SPAWNED, False )

    def OnPlayerDisconnect( self, player ):
        team = player.GetTeamNumber()
       
        if team != GEGlobal.TEAM_SPECTATOR:
            self.updateTeamsMaxPlayers(team) #Will the diconnecting player still be counted?
           
            if self.isEliminatedPlayer(player): self.deleteNotInUseResurrectionEntityFromTeam(team)
            else: self.decreaseTeamBounty(team)
               
    def isEliminatedPlayer(self,player):
        return self.pltracker.GetValue(player,self.TR_ELIMINATED)
   
    #-------------------------------
    def CanPlayerChangeTeam(self,player,oldTeam,newTeam ):
        if oldTeam == GEGlobal.TEAM_NONE: return True
        elif oldTeam == GEGlobal.TEAM_SPECTATOR and player.IsInitialSpawn(): self.newPlayerWantsToJoinTeam(player,newTeam)
        elif oldTeam == GEGlobal.TEAM_SPECTATOR: self.spectatorWantsToJoinTeam(player,newTeam)
        elif oldTeam != GEGlobal.TEAM_SPECTATOR and newTeam != GEGlobal.TEAM_SPECTATOR: self.playerWantsToChangeTheirTeam(player,oldTeam,newTeam)
        elif oldTeam != GEGlobal.TEAM_SPECTATOR and newTeam == GEGlobal.TEAM_SPECTATOR:
            #EPILEPSY WARNING: The view bug caused by an eliminated player becoming a spectator may be capable of causing epileptic seizures.
            if self.isEliminatedPlayer(player):
                GEUtil.PopupMessage(player, "You can't become a spectator","If eliminated players became spectators in this version, a bug would occur.")
                GEUtil.ClientPrint(player,GEGlobal.HUD_PRINTTALK,"You can't become a spectator:A bug would occur if eliminated players could become spectators.")
                return False
            else: self.playerWantsToBecomeSpectator(player,oldTeam)
       
        return True

    def newPlayerWantsToJoinTeam(self,player,newTeam):
        if self.eliminateNewPlayers:
            #TODO use language files
            GEUtil.PopupMessage(player, "You Can't Spawn Yet","To prevent resurrection rejoins, new players won't spawn until a team mate spawns them.")
            self.eliminatePlayer(player)
            self.spawnNewResurrectionEntity(player,newTeam)
            self.addPlayerToResurrectionQueue(player,newTeam)
           
        else: self.increaseTeamBounty(newTeam)
   
    def playerWantsToChangeTheirTeam(self,player,oldTeam,newTeam):
        self.changingTeamPlayers[player] = oldTeam
       
        if self.isEliminatedPlayer(player):
            self.deleteNotInUseResurrectionEntityFromTeam(oldTeam)
            self.removePlayerFromTeamsRQueue(player,oldTeam)
           
            self.spawnNewResurrectionEntity(player,newTeam)
            self.addPlayerToResurrectionQueue(player,newTeam)
           
        else:
            self.decreaseTeamBounty(oldTeam)
            self.increaseTeamBounty(newTeam)
   
    def playerWantsToBecomeSpectator(self,player,oldTeam):
        self.changingTeamPlayers[player] = GEGlobal.TEAM_SPECTATOR
        self.decreaseTeamBounty(oldTeam)
       
        #if self.isEliminatedPlayer(player):
            #self.deleteNotInUseResurrectionEntityFromTeam(oldTeam)
            #self.removePlayerFromTeamsRQueue(player,oldTeam)
        #else: self.decreaseTeamBounty(oldTeam)
   
    def spectatorWantsToJoinTeam(self,player,newTeam):
        if self.isEliminatedPlayer(player):
            #TODO use language files
            GEUtil.PopupMessage(player, "You Can't Spawn Yet","You will have to wait for a team mate to spawn you because you were eliminated before becoming a specator.")
            self.spawnNewResurrectionEntity(player,newTeam)
            self.addPlayerToResurrectionQueue(player,newTeam)
           
        else: self.increaseTeamBounty(newTeam)
       
    #-------------------------------   
    def deleteNotInUseResurrectionEntityFromTeam(self,team):
        teamsResurrectionAreaIDs = None
        if team == GEGlobal.TEAM_MI6: teamsResurrectionAreaIDs = self.mAreaIDs
        else: teamsResurrectionAreaIDs = self.jAreaIDs
       
        for areaID in teamsResurrectionAreaIDs:
            if not self.areaInUse(areaID):
                self.deleteResurrectionArea(areaID,team)
                break
   
    def deleteResurrectionArea(self,areasID,areasTeam):
        self.resurrectionAreaUserLists.pop(areasID)
           
        if areasTeam == GEGlobal.TEAM_MI6: self.mAreaIDs.remove(areasID)
        else: self.jAreaIDs.remove(areasID)
           
        self.tokenManager.RemoveCaptureArea(areasID)
       
    def areaInUse(self,areasID):
        return len(self.resurrectionAreaUserLists[areasID]) > 0
       
    def eliminatePlayer(self,player):
        self.pltracker.SetValue(player,self.TR_ELIMINATED,True)
       
    def announceElimination(self,victim,killer):
        #Emit "Player Eliminated" event
        GEUtil.EmitGameplayEvent( "DieAnotherDay_eliminated", "%i" % victim.GetUserID(), "%i" % killer.GetUserID())
       
        #Tell the other players that a player has been eliminated #TODO use UI Language Files
        GEUtil.ClientPrint(None,GEGlobal.HUD_PRINTTALK, "A " + self.getTeamString(victim.GetTeamNumber()) + " player has been eliminated.")
       
    def getTeamString(self,teamNumber):
        if(teamNumber == GEGlobal.TEAM_MI6): return "MI6"
        elif(teamNumber == GEGlobal.TEAM_JANUS): return "Janus"   
        else: return "Spectator"
       
    def addPlayerToResurrectionQueue(self,player,team):
        if team == GEGlobal.TEAM_MI6: self.mResurrectionQueue.append(player)
        else: self.jResurrectionQueue.append(player)
       
    def removePlayerFromTeamsRQueue(self,player,team):
        if team == GEGlobal.TEAM_MI6: self.mResurrectionQueue.remove(player)
        else: self.jResurrectionQueue.remove(player)
           
    def spawnNewResurrectionEntity(self,victim,team):
        #Create a new resurrection area id
        newAreasID = str(victim.GetUserID())
       
        #Spawn a new resurrection area
        self.spawnResurrectionEntity(newAreasID,team)
       
        #Create entries for the new area in resurrection entity collections
        if team == GEGlobal.TEAM_MI6: self.mAreaIDs.append(newAreasID)
        else: self.jAreaIDs.append(newAreasID)
       
        #Added to radar in CaptureAreaSpawned()
   
    def respawnResurrectionEntity(self,areaID,team):
        self.tokenManager.RemoveCaptureArea(areaID)
        self.spawnResurrectionEntity(areaID,team)
       
    def spawnResurrectionEntity(self,areaID,team):
        #Get Model Name
        modelName = None
       
        if team == GEGlobal.TEAM_MI6: modelName = self.MRE_MODEL
        else: modelName = self.JRE_MODEL
       
        #Spawn resurrection entity
        self.tokenManager.SetupCaptureArea(areaID,
                                   model=modelName,
                                   limit=1, location=GEGlobal.SPAWN_PLAYER,
                                   rqd_team=team)

    def OnPlayerSpawn(self,player):
        playersTeam = player.GetTeamNumber()
       
        if playersTeam != GEGlobal.TEAM_SPECTATOR:
            if self.changingTeamPlayers.has_key(player):
                #update the max players in their new team's bounty progress bar:
                self.updateTeamsMaxPlayers(playersTeam)
                #update the max players in their old team's bounty progress bar:
                if self.changingTeamPlayers[player] != GEGlobal.TEAM_SPECTATOR: self.updateTeamsMaxPlayers(self.changingTeamPlayers[player])
               
                self.changingTeamPlayers.remove(player)
           
            if player in self.eliminatedSpectators:
                self.spawnNewResurrectionEntity(player,playersTeam)
                self.updateTeamsMaxPlayers(playersTeam)
               
                self.eliminatedSpectators.remove(player)
               
            #If can spawn:
            else:
                self.pltracker.SetValue( player, self.TR_SPAWNED,True)
           
        #TODO Use UI Language Files
        GEUtil.PopupMessage( player, "Die Another Day", "Eliminate your opponents and resurrect your eliminated team mates." )

    def OnRoundBegin( self ):
        self.mi6Bounty = 0
        self.janusBounty = 0
       
        self.radar = GEMPGameRules.GetRadar()
       
        if not self.waitingForPlayers:
            for i in range( 32 ):
                if not GEPlayer.IsValidPlayerIndex( i ):
                    continue
                self.pltracker.SetValue( GEPlayer.GetMPPlayer( i ), self.TR_ELIMINATED, False )
   
            GEMPGameRules.ResetAllPlayerDeaths()
            GEMPGameRules.ResetAllPlayersScores()

    def OnRoundEnd( self ):
        self.eliminateNewPlayers = False
        self.radar.DropAllContacts()
        self.timerTracker.RemoveTimer(None) #Stop all timers
       
        #Remove all progress bars
        GEUtil.RemoveHudProgressBar( None,self.MBountyPBIndex)
        GEUtil.RemoveHudProgressBar( None,self.JBountyPBIndex)
        GEUtil.RemoveHudProgressBar( None,self.ResurrectionPBIndex)
       
        #Empty resurrection queues
        del self.mResurrectionQueue[:]
        del self.jResurrectionQueue[:]
       
        self.deleteAllCaptureAreasAndTheirCollections()

    def deleteAllCaptureAreasAndTheirCollections(self):
        for areaID in self.mAreaIDs: self.tokenManager.RemoveCaptureArea(areaID)
        for areaID in self.jAreaIDs: self.tokenManager.RemoveCaptureArea(areaID)
       
        self.resurrectionAreaUserLists.clear()
        del self.mAreaIDs[:]
        del self.jAreaIDs[:]

    def OnPlayerKilled( self, victim, killer, weapon ):
        super( DieAnotherDay, self ).OnPlayerKilled( victim, killer, weapon )
        self.InitializePlayerBounty() #if not initialised already
       
        victimsTeam = victim.GetTeamNumber()
       
        #Don't allow player's to accidentally/intentionally eliminate their team mates
        if killer.GetTeamNumber()!= victimsTeam:
            self.eliminatePlayer(victim)
            self.announceElimination(victim,killer)
           
            self.decreaseTeamBounty(victimsTeam)
         
            #Get the survivor count for the victim's team.
            teamsSurvivors = 0
            if victimsTeam == GEGlobal.TEAM_MI6: teamsSurvivors = self.mi6Bounty
            else: teamsSurvivors = self.janusBounty
           
            #If the victim was the last player alive on their team then don't create a resurrection area because
            #the game will be ended by OnThink() when this function has finished.
            if teamsSurvivors > 0:
                self.eliminateNewPlayers = True
                self.spawnNewResurrectionEntity(victim,victimsTeam)
                self.addPlayerToResurrectionQueue(victim,victimsTeam)
               
                if self.playerNotBot(victim):
                    queuePosition = None
                    if victimsTeam == GEGlobal.TEAM_MI6: queuePosition = self.mResurrectionQueue.index(victim)
                    else: queuePosition = self.jResurrectionQueue.index(victim)
               
                    #TODO use language files
                    self.tellPlayerWhatTheirResurrectionQueuePositionIs(victim,queuePositionP=queuePosition)
               
            elif teamsSurvivors < 0: GEUtil.Msg("ERROR:OnPlayerKilled():teamsSurvivors < 0: = " + str(teamsSurvivors))

    def OnCaptureAreaSpawned( self, area ):
        areasTeam = area.GetTeamNumber()
        location = area.GetAbsOrigin()
           
        #Recusrive Function Call Loop:
        #If the area has spawned at an enemy resurrection area's location respawn it and exit this function call
        #because this function will be called again when the area respawns and should only execute statements
        #after the respawn IF block, when it is called for an area which has an acceptable location.
        if areasTeam == GEGlobal.TEAM_MI6 and location in self.jAreaLocations or areasTeam == GEGlobal.TEAM_JANUS and location in self.mAreaLocations:
            self.respawnResurrectionEntity(area.GetGroupName(),areasTeam)
            return
       
        colour = None
        if area.GetTeamNumber() == GEGlobal.TEAM_MI6:
            self.mAreaLocations.append(location)
            colour = self.COLOR_MI6_RADAR
        else:
            self.jAreaLocations.append(location)
            colour = self.COLOR_JANUS_RADAR
               
        self.radar.AddRadarContact(area,GEGlobal.RADAR_TYPE_OBJECTIVE,True,"sprites/hud/radar/capture_point",colour)
        self.radar.SetupObjective(area,area.GetTeamNumber(),"", "",colour, 0, False )
   
    def OnCaptureAreaEntered( self, area, player, token ):
        if area.GetTeamNumber() == player.GetTeamNumber():
            areasTeam = area.GetTeamNumber()
           
            #Add player to area's user list, creating if it hasn't been created already
            self.resurrectionAreaUserLists[area.GetGroupName()].append(player)
           
            #Create & configure resurrection timer & Give it the area's name and team
            resurrectionTimer = self.timerTracker.CreateTimer(str(areasTeam)  + "," + area.GetGroupName())
            resurrectionTimer.SetUpdateCallback(self.ResurrectionTimerTick,1.0)
            resurrectionTimer.SetAgeRate(1.0,0)
           
            #Create a resurrection progress bar on the player's screen TODO: use language files
            GEUtil.InitHudProgressBar(player,self.ResurrectionPBIndex, "Resurrecting Team Mate...", GEGlobal.HUDPB_SHOWVALUE, self.resurrectionTime, self.ResurrectionPBX, self.ResurrectionPBY, 120, 16, GEUtil.CColor( 220, 220, 220, 240 ) )
           
            #Start the resurrection timer
            resurrectionTimer.Start(self.resurrectionTime,False)
       
    def OnCaptureAreaExited( self, area, player ):
        areasTeam = area.GetTeamNumber()
        areasName = area.GetGroupName()
       
        if areasTeam == player.GetTeamNumber():
            #Remove player from the area's user list
            self.resurrectionAreaUserLists[areasName].remove(player)
               
            #Remove the resurrection progress progress bar from the player's screen
            GEUtil.RemoveHudProgressBar(player,self.ResurrectionPBIndex)

    def ResurrectionTimerTick( self, timer, update_type ):
        areasID = timer.GetName()[2:]

        #Area still in use?
        if update_type != Timer.UPDATE_STOP and self.areaInUse(areasID):
            #Update each user's resurrection progress GUI
            for areaUser in self.resurrectionAreaUserLists[areasID]:
                if update_type == Timer.UPDATE_FINISH:
                    GEUtil.RemoveHudProgressBar(areaUser,self.ResurrectionPBIndex)
                else:
                    GEUtil.UpdateHudProgressBar(areaUser,self.ResurrectionPBIndex,int(timer.GetCurrentTime()))
       
            if update_type == Timer.UPDATE_FINISH:
                #Get area's team
                areasTeam = int(timer.GetName()[0])
               
                teamString = self.getTeamString(areasTeam)
               
                #Delete the resurrection area
                self.deleteResurrectionArea(areasID,areasTeam)
               
                #Choose player to be resurrected.
                resurrectedPlayer = None
                if areasTeam == GEGlobal.TEAM_MI6 and len(self.mResurrectionQueue) != 0: resurrectedPlayer = self.mResurrectionQueue.pop(0)
                elif len(self.jResurrectionQueue) != 0: resurrectedPlayer = self.jResurrectionQueue.pop(0)
               
                #If for some reason there is no player to resurrect, don't resurrect anyone.
                if resurrectedPlayer != None:
                    #Resurrect player and respond to their resurrection
                    self.resurrectPlayer(resurrectedPlayer)
                   
                    #Update player bounty
                    self.increaseTeamBounty(areasTeam)
                   
                    #Update resurrection queue progress bars for team mates
                    self.resurrectionQueueUpdateNotify(areasTeam)
                   
                    if self.playerNotBot(resurrectedPlayer):
                        #Remove resurrected player's resurrection queue progress bar
                        GEUtil.RemoveHudProgressBar(resurrectedPlayer,self.ResurrectionPBIndex)
                       
                        #Emit player resurrected event
                        GEUtil.EmitGameplayEvent("DieAnotherDay_resurrection", "%s" % resurrectedPlayer.GetName(),"%s" % teamString)
                   
                        #Announce event in console
                        GEUtil.Msg("A " + teamString + " player has been resurrected: " + resurrectedPlayer.GetName())
                   
                    #Announce resurrection
                    GEUtil.ClientPrint(None, GEGlobal.HUD_PRINTTALK,"A " + teamString + " player has been resurrected.")
                   
                    #If there are now no eliminated players, allow new players to join without needing
                    #to be spawned by their team mates.
                    numberOfMPlayers = GEMPGameRules.GetNumInRoundTeamPlayers(GEGlobal.TEAM_MI6)
                    numberOfJPlayers = GEMPGameRules.GetNumInRoundTeamPlayers(GEGlobal.TEAM_JANUS)
                   
                    if numberOfMPlayers == self.mi6Bounty and numberOfJPlayers == self.janusBounty: self.eliminatedSpectators = False
           
        #Activated if the timer hasn't expired in this tick and it's area no longer has users:
        elif update_type != Timer.UPDATE_STOP:
            timer.Stop()
           
    def resurrectionQueueUpdateNotify(self,team):
        resurrectionQueue = None
        if(team == GEGlobal.TEAM_MI6): resurrectionQueue = self.mResurrectionQueue
        else: resurrectionQueue = self.jResurrectionQueue
       
        for player in resurrectionQueue:
            if self.playerNotBot(player):
                self.tellPlayerWhatTheirResurrectionQueuePositionIs(player,queueP=resurrectionQueue)
           
    def tellPlayerWhatTheirResurrectionQueuePositionIs(self,player,queueP=None,queuePositionP=None):
        if queuePositionP == None and queueP != None: queuePositionP = queueP.index(player)
        if queuePositionP != None :
            #TODO use language files
            GEUtil.ClientPrint(player,GEGlobal.HUD_PRINTCONSOLE,"Team mates who will be resurrected before you = ")
            GEUtil.PopupMessage(player, "You've Been Eliminated", "Team mates who will be resurrected before you = " + str(queuePositionP))       
           
    def playerNotBot(self,player):
        return player.__class__.__name__ != "CGEBotPlayer"

    def resurrectPlayer(self,player):
        self.pltracker.SetValue(player,self.TR_ELIMINATED,False)
   
    def getTeamsRadarColor(self,teamNumber):
        if teamNumber == GEGlobal.TEAM_MI6: return self.COLOR_MI6_RADAR
        else: return self.COLOR_JANUS_RADAR

    def OnThink( self ):
        if GEMPGameRules.GetNumActivePlayers() < 2:
            self.waitingForPlayers = True
            return

        if self.waitingForPlayers:
            self.waitingForPlayers = False
            GEUtil.HudMessage( None, "#GES_GP_GETREADY", -1, -1, GEUtil.CColor( 255, 255, 255, 255 ), 2.5 )
            GEMPGameRules.EndRound( False )

        #Check to see if the round is over!:
       
        #check to see if each team has a player...
        inPlayMPlayers = []
        inPlayJPlayers = []

        for i in range( 32 ):
            if not GEPlayer.IsValidPlayerIndex( i ):
                continue

            player = GEPlayer.GetMPPlayer( i )
            if self.IsInPlay( player ):
                if player.GetTeamNumber() == GEGlobal.TEAM_MI6:
                    inPlayMPlayers.append( player )
                elif player.GetTeamNumber() == GEGlobal.TEAM_JANUS:
                    inPlayJPlayers.append( player )

        numMI6Players = len(inPlayMPlayers)
        numJanusPlayers = len(inPlayJPlayers)

        if numMI6Players == 0 and numJanusPlayers == 0: GEMPGameRules.EndRound()
        elif numMI6Players == 0 and numJanusPlayers > 0: self.teamWins(GEGlobal.TEAM_JANUS)
        elif numMI6Players > 0 and numJanusPlayers == 0: self.teamWins(GEGlobal.TEAM_MI6)
           
    def teamWins(self,teamNumber):
        team = GEMPGameRules.GetTeam(teamNumber)
        team.IncrementMatchScore( 5 )
        GEMPGameRules.SetTeamWinner(team)
        GEMPGameRules.EndRound()

    def CanPlayerRespawn( self, player ):
        if self.isEliminatedPlayer(player):
            player.SetScoreBoardColor( GEGlobal.SB_COLOR_ELIMINATED )
            return False

        player.SetScoreBoardColor( GEGlobal.SB_COLOR_NORMAL )
        return True

    def InitializePlayerBounty( self ):
        if self.mi6Bounty == 0 and self.janusBounty == 0:
            self.mi6Bounty = GEMPGameRules.GetNumInRoundTeamPlayers(GEGlobal.TEAM_MI6)
            self.janusBounty = GEMPGameRules.GetNumInRoundTeamPlayers(GEGlobal.TEAM_JANUS)
   
            GEUtil.InitHudProgressBar(None,self.MBountyPBIndex,"MI6: ",GEGlobal.HUDPB_SHOWVALUE, self.mi6Bounty, self.MBountyPBX,self.MBountyPBY, 0, 10, self.MBountyFontColour)
            GEUtil.InitHudProgressBar(None,self.JBountyPBIndex,"Janus: ",GEGlobal.HUDPB_SHOWVALUE, self.janusBounty, self.JBountyPBX,self.JBountyPBY, 0, 10,self.JBountyFontColour)

    def updateTeamsMaxPlayers(self,team):
        numberOfPlayersInTeam = GEMPGameRules.GetNumInRoundTeamPlayers(team)
       
        if team == GEGlobal.TEAM_MI6:
            GEUtil.RemoveHudProgressBar(None,self.MBountyPBIndex)
            GEUtil.InitHudProgressBar(None, self.MBountyPBIndex,"MI6: ", GEGlobal.HUDPB_SHOWVALUE,numberOfPlayersInTeam, self.MBountyPBX,self.MBountyPBY, 0, 10, self.MBountyFontColour)
        else:
            GEUtil.RemoveHudProgressBar(None,self.JBountyPBIndex)
            GEUtil.InitHudProgressBar(None,self.JBountyPBIndex,"Janus: ", GEGlobal.HUDPB_SHOWVALUE,numberOfPlayersInTeam, self.JBountyPBX,self.JBountyPBY, 0, 10,self.JBountyFontColour)     

    def decreaseTeamBounty(self,team):
        if team == GEGlobal.TEAM_JANUS: self.janusBounty -= 1
        else: self.mi6Bounty -= 1
        self.updateDisplayedBounties()
       
    def increaseTeamBounty(self,team):
        if team == GEGlobal.TEAM_JANUS: self.janusBounty += 1
        else: self.mi6Bounty += 1
        self.updateDisplayedBounties()
       
    def updateDisplayedBounties(self):
        GEUtil.UpdateHudProgressBar(None,self.JBountyPBIndex,self.janusBounty)
        GEUtil.UpdateHudProgressBar(None,self.MBountyPBIndex,self.mi6Bounty)

    def IsInPlay( self, player ):
        return player.GetTeamNumber() is not GEGlobal.TEAM_SPECTATOR and self.pltracker.GetValue( player, self.TR_SPAWNED ) and not self.pltracker.GetValue( player, self.TR_ELIMINATED )

    def GetTeamPlay(self):
        return GEGlobal.TEAMPLAY_ALWAYS
       
       
--- End code ---

Joe:
I've still not been able to fix the spectator view bug.

I've tested this bug on the Runway map instead of the Facility and I've found that it manifests itself differently. Instead of making the spectator view try to show two different views, it locks the view in to one position making it unmovable when a player is on the spectator team. This view position is shown in the attached image.

If a GE:S developer can tell me why the spectator view behaved strangely in the following test, then I might be able to find a solution to the spectator view bug.

Runway View Bug Test

EPILEPSY WARNING: The script used in the following test allows the spectator view bug to occur, this view bug can make the spectator view rapidly flicker as it tries to display 3 different views on the Facility Map.
http://en.wikipedia.org/wiki/Photosensitive_epilepsy

Script used: Dev 25 with 2 changed functions shown below:

--- Code: ---
def CanPlayerChangeTeam(self,player,oldTeam,newTeam ):
#        if oldTeam == GEGlobal.TEAM_NONE: return True
#        elif oldTeam == GEGlobal.TEAM_SPECTATOR and player.IsInitialSpawn(): self.newPlayerWantsToJoinTeam(player,newTeam)
#        elif oldTeam == GEGlobal.TEAM_SPECTATOR: self.spectatorWantsToJoinTeam(player,newTeam)
#        elif oldTeam != GEGlobal.TEAM_SPECTATOR and newTeam != GEGlobal.TEAM_SPECTATOR: self.playerWantsToChangeTheirTeam(player,oldTeam,newTeam)
#        elif oldTeam != GEGlobal.TEAM_SPECTATOR and newTeam == GEGlobal.TEAM_SPECTATOR: self.playerWantsToBecomeSpectator(player,oldTeam)
       
        #self.eliminatePlayer(player)
       
        return True

def CanPlayerRespawn( self, player ):
        #if self.isEliminatedPlayer(player):
            #player.SetScoreBoardColor( GEGlobal.SB_COLOR_ELIMINATED )
            #return False

        #player.SetScoreBoardColor( GEGlobal.SB_COLOR_NORMAL )
       
        return False

--- End code ---

This is the Dev 25 script with these changed functions:

--- Code: ---
from . import GEScenario
from GamePlay.Utils.GEPlayerTracker import GEPlayerTracker
from Utils.GETimer import TimerTracker, Timer
from collections import defaultdict

import GEPlayer, GEUtil, GEMPGameRules, GEGlobal

USING_API = GEGlobal.API_VERSION_1_0_0

'''
I chose to implement this mode by editing the "You Only Live Twice" mode script. So
this script uses lots of code that was created by the author(s) of the YOLT script.

I've also reused code from the "Capture The Key" mode's script.

Unresolved bugs:
* When an eliminated & unspawned player changes their team to spectator, there is a problem with their spectator view.

@author: Joe
@version: Bug Test Version
'''

class DieAnotherDay( GEScenario ):
    MRE_MODEL = "models/players/bond/bond.mdl"
    JRE_MODEL = "models/players/jaws/jaws.mdl"
   
    COLOR_MI6_RADAR = GEUtil.Color( 94, 171, 231, 255 )
    COLOR_JANUS_RADAR = GEUtil.Color( 206, 43, 43, 255 )
   
    JBountyFontColour = GEUtil.CColor( 206, 43, 43, 255 )
    MBountyFontColour = GEUtil.CColor( 100, 184, 234, 220 )
   
    #Progress bar positions
    MBountyPBX = 0.4
    MBountyPBY = 0
   
    JBountyPBX = 0.6
    JBountyPBY = 0
   
    ResurrectionPBX = -1
    ResurrectionPBY = 0.6
    #-------------------------
   
    resurrectionTime = 5.0
   
    TR_ELIMINATED = "eliminated"
    TR_SPAWNED = "spawned"
   
    TOKEN_MI6 = 'token_mi6'
    TOKEN_JANUS = 'token_janus'
   
    #Progress Bar Indexs
    MBountyPBIndex = 0
    JBountyPBIndex = 1
    ResurrectionPBIndex = 2

    def __init__( self ):
        super( DieAnotherDay, self ).__init__()
       
        self.radar = None
       
        self.eliminateNewPlayers = False

        self.waitingForPlayers = False
        self.radarSet = False
        self.mBounty = 0
        self.jBounty = 0
        self.pltracker = GEPlayerTracker( self )
       
        self.mBountyMaxPlayers = 0
        self.jBountyMaxPlayers = 0
       
        self.timerTracker = TimerTracker( self )
        self.tokenManager = GEMPGameRules.GetTokenMgr()
       
        #Eliminated player collections
        self.mResurrectionQueue = []
        self.jResurrectionQueue = []
       
        self.eliminatedSpectators = []
       
        #Collections related to resurrection area entities
        self.mAreaIDs = []
        self.jAreaIDs = []
       
        self.mAreaLocations = []
        self.jAreaLocations = []
       
        self.resurrectionAreaUserLists = defaultdict(list)
       
    def OnLoadGamePlay( self ):
        GEUtil.PrecacheModel( self.MRE_MODEL )
        GEUtil.PrecacheModel( self.JRE_MODEL )
       
        self.radar = GEMPGameRules.GetRadar()

    def Cleanup( self ):
        super( DieAnotherDay, self ).Cleanup()
        self.pltracker = None

    def GetPrintName( self ):
        return "Die Another Day"

    def GetScenarioHelp( self, help_obj ):
        #TODO use UI Language Files:
        help_obj.SetDescription(
                                 """
Based on: Mefy's MOHAA Freeze Tag Mode
Version: Bug Test Version

*Eliminate the opposing team.
*Resurrect your eliminated team mates.
*To resurrect a team mate stand next
to them.
   
The ability to resurrect players from
a long distance will be added in
version 2.00, if it can be implemented.
                                 """)
       
    def GetGameDescription( self ):
        return "Die Another Day"

    def OnPlayerConnect( self, player ):
        self.pltracker.SetValue( player, self.TR_SPAWNED, False )

    def OnPlayerDisconnect( self, player ):
        team = player.GetTeamNumber()
       
        if team != GEGlobal.TEAM_SPECTATOR:
            self.decrementTeamsPlayerCount(team)
            self.updateTeamsDisplayedMaxPlayers(team)
           
            if self.isEliminatedPlayer(player):
                self.deleteNotInUseResurrectionEntityFromTeam(team)
                self.removePlayerFromTeamsRQueue(player,team)
            else: self.decreaseTeamBounty(team)
               
    def isEliminatedPlayer(self,player):
        return self.pltracker.GetValue(player,self.TR_ELIMINATED)
   
    #-------------------------------
    def CanPlayerChangeTeam(self,player,oldTeam,newTeam ):
#        if oldTeam == GEGlobal.TEAM_NONE: return True
#        elif oldTeam == GEGlobal.TEAM_SPECTATOR and player.IsInitialSpawn(): self.newPlayerWantsToJoinTeam(player,newTeam)
#        elif oldTeam == GEGlobal.TEAM_SPECTATOR: self.spectatorWantsToJoinTeam(player,newTeam)
#        elif oldTeam != GEGlobal.TEAM_SPECTATOR and newTeam != GEGlobal.TEAM_SPECTATOR: self.playerWantsToChangeTheirTeam(player,oldTeam,newTeam)
#        elif oldTeam != GEGlobal.TEAM_SPECTATOR and newTeam == GEGlobal.TEAM_SPECTATOR: self.playerWantsToBecomeSpectator(player,oldTeam)
       
        #self.eliminatePlayer(player)
       
        return True

    def newPlayerWantsToJoinTeam(self,player,newTeam):
        self.incrementTeamsPlayerCount(newTeam)
       
        if self.eliminateNewPlayers:
            #TODO use language files
            GEUtil.PopupMessage(player, "You Can't Spawn Yet","To prevent resurrection rejoins, new players won't spawn until a team mate spawns them.")
            self.eliminatePlayer(player)
            self.spawnNewResurrectionEntity(player,newTeam)
            self.addPlayerToResurrectionQueue(player,newTeam)
           
        else: self.increaseTeamBounty(newTeam)
   
    def playerWantsToChangeTheirTeam(self,player,oldTeam,newTeam):
        self.incrementTeamsPlayerCount(newTeam)
        self.decrementTeamsPlayerCount(oldTeam)
       
        if self.isEliminatedPlayer(player):
            self.deleteNotInUseResurrectionEntityFromTeam(oldTeam)
            self.removePlayerFromTeamsRQueue(player,oldTeam)
           
            self.spawnNewResurrectionEntity(player,newTeam)
            self.addPlayerToResurrectionQueue(player,newTeam)
           
        else:
            self.decreaseTeamBounty(oldTeam)
            self.increaseTeamBounty(newTeam)
   
    def playerWantsToBecomeSpectator(self,player,oldTeam):
        self.decrementTeamsPlayerCount(oldTeam)
       
        if self.isEliminatedPlayer(player):
            self.deleteNotInUseResurrectionEntityFromTeam(oldTeam)
            self.removePlayerFromTeamsRQueue(player,oldTeam)
        else: self.decreaseTeamBounty(oldTeam)
   
    def spectatorWantsToJoinTeam(self,player,newTeam):
        self.incrementTeamsPlayerCount(newTeam)
       
        if self.isEliminatedPlayer(player):
            #TODO use language files
            GEUtil.PopupMessage(player, "You Can't Spawn Yet","You will have to wait for a team mate to spawn you because you were eliminated before becoming a specator.")
            self.spawnNewResurrectionEntity(player,newTeam)
            self.addPlayerToResurrectionQueue(player,newTeam)
           
        else: self.increaseTeamBounty(newTeam)
       
    #-------------------------------   
    def incrementTeamsPlayerCount(self,team):
        if team == GEGlobal.TEAM_MI6: self.mBountyMaxPlayers += 1
        else: self.jBountyMaxPlayers += 1
       
    def decrementTeamsPlayerCount(self,team):
        if team == GEGlobal.TEAM_MI6: self.mBountyMaxPlayers -= 1
        else: self.jBountyMaxPlayers -= 1
   
    def deleteNotInUseResurrectionEntityFromTeam(self,team):
        teamsResurrectionAreaIDs = None
        if team == GEGlobal.TEAM_MI6: teamsResurrectionAreaIDs = self.mAreaIDs
        else: teamsResurrectionAreaIDs = self.jAreaIDs
       
        for areaID in teamsResurrectionAreaIDs:
            if not self.areaInUse(areaID):
                self.deleteResurrectionArea(areaID,team)
                break
   
    def deleteResurrectionArea(self,areasID,areasTeam):
        self.resurrectionAreaUserLists.pop(areasID)
           
        if areasTeam == GEGlobal.TEAM_MI6: self.mAreaIDs.remove(areasID)
        else: self.jAreaIDs.remove(areasID)
           
        self.tokenManager.RemoveCaptureArea(areasID)
       
    def areaInUse(self,areasID):
        return len(self.resurrectionAreaUserLists[areasID]) > 0
       
    def eliminatePlayer(self,player):
        self.pltracker.SetValue(player,self.TR_ELIMINATED,True)
       
    def announceElimination(self,victim,killer):
        #Emit "Player Eliminated" event
        GEUtil.EmitGameplayEvent( "DieAnotherDay_eliminated", "%i" % victim.GetUserID(), "%i" % killer.GetUserID())
       
        #Tell the other players that a player has been eliminated #TODO use UI Language Files
        GEUtil.ClientPrint(None,GEGlobal.HUD_PRINTTALK, "A " + self.getTeamString(victim.GetTeamNumber()) + " player has been eliminated.")
       
    def getTeamString(self,teamNumber):
        if(teamNumber == GEGlobal.TEAM_MI6): return "MI6"
        elif(teamNumber == GEGlobal.TEAM_JANUS): return "Janus"   
        else: return "Spectator"
       
    def addPlayerToResurrectionQueue(self,player,team):
        if team == GEGlobal.TEAM_MI6: self.mResurrectionQueue.append(player)
        else: self.jResurrectionQueue.append(player)
       
    def removePlayerFromTeamsRQueue(self,player,team):
        if team == GEGlobal.TEAM_MI6: self.mResurrectionQueue.remove(player)
        else: self.jResurrectionQueue.remove(player)
           
    def spawnNewResurrectionEntity(self,victim,team):
        #Create a new resurrection area id
        newAreasID = str(victim.GetUserID())
       
        #Spawn a new resurrection area
        self.spawnResurrectionEntity(newAreasID,team)
       
        #Create entries for the new area in resurrection entity collections
        if team == GEGlobal.TEAM_MI6: self.mAreaIDs.append(newAreasID)
        else: self.jAreaIDs.append(newAreasID)
       
        #Added to radar in CaptureAreaSpawned()
   
    def respawnResurrectionEntity(self,areaID,team):
        self.tokenManager.RemoveCaptureArea(areaID)
        self.spawnResurrectionEntity(areaID,team)
       
    def spawnResurrectionEntity(self,areaID,team):
        #Get Model Name
        modelName = None
       
        if team == GEGlobal.TEAM_MI6: modelName = self.MRE_MODEL
        else: modelName = self.JRE_MODEL
       
        #Spawn resurrection entity
        self.tokenManager.SetupCaptureArea(areaID,
                                   model=modelName,
                                   limit=1, location=GEGlobal.SPAWN_PLAYER,
                                   rqd_team=team)

    def OnPlayerSpawn(self,player):
        playersTeam = player.GetTeamNumber()
       
        if playersTeam != GEGlobal.TEAM_SPECTATOR:
            if player in self.eliminatedSpectators:
                self.spawnNewResurrectionEntity(player,playersTeam)
                self.updateTeamsDisplayedMaxPlayers(playersTeam)
               
                self.eliminatedSpectators.remove(player)
               
            #If can spawn:
            else:
                GEUtil.Msg("*** NON spectator spawned ***") #TODO remove
                self.pltracker.SetValue( player, self.TR_SPAWNED,True)
               
        else: GEUtil.Msg("*** Spectator spawned ***") #TODO remove
           
        #TODO Use UI Language Files
        GEUtil.PopupMessage( player, "Die Another Day", "Eliminate your opponents and resurrect your eliminated team mates." )

    def OnRoundBegin( self ):
        self.mBounty = 0
        self.jBounty = 0
       
        if not self.waitingForPlayers:
            for i in range( 32 ):
                if not GEPlayer.IsValidPlayerIndex( i ):
                    continue
                self.pltracker.SetValue( GEPlayer.GetMPPlayer( i ), self.TR_ELIMINATED, False )
   
            GEMPGameRules.ResetAllPlayerDeaths()
            GEMPGameRules.ResetAllPlayersScores()

    def OnRoundEnd( self ):
        self.eliminateNewPlayers = False
        self.radar.DropAllContacts()
        self.timerTracker.RemoveTimer(None) #Stop all timers
       
        #Remove all progress bars
        GEUtil.RemoveHudProgressBar( None,self.MBountyPBIndex)
        GEUtil.RemoveHudProgressBar( None,self.JBountyPBIndex)
        GEUtil.RemoveHudProgressBar( None,self.ResurrectionPBIndex)
       
        #Empty resurrection queues
        del self.mResurrectionQueue[:]
        del self.jResurrectionQueue[:]
       
        self.deleteAllCaptureAreasAndTheirCollections()

    def deleteAllCaptureAreasAndTheirCollections(self):
        for areaID in self.mAreaIDs: self.tokenManager.RemoveCaptureArea(areaID)
        for areaID in self.jAreaIDs: self.tokenManager.RemoveCaptureArea(areaID)
       
        self.resurrectionAreaUserLists.clear()
        del self.mAreaIDs[:]
        del self.jAreaIDs[:]

    def OnPlayerKilled( self, victim, killer, weapon ):
        super( DieAnotherDay, self ).OnPlayerKilled( victim, killer, weapon )
        self.InitializePlayerBounty() #if not initialised already
       
        victimsTeam = victim.GetTeamNumber()
       
        #Don't allow player's to accidentally/intentionally eliminate their team mates
        if killer.GetTeamNumber()!= victimsTeam:
            self.eliminatePlayer(victim)
            self.announceElimination(victim,killer)
           
            self.decreaseTeamBounty(victimsTeam)
         
            #Get the survivor count for the victim's team.
            teamsSurvivors = 0
            if victimsTeam == GEGlobal.TEAM_MI6: teamsSurvivors = self.mBounty
            else: teamsSurvivors = self.jBounty
           
            #If the victim was the last player alive on their team then don't create a resurrection area because
            #the game will be ended by OnThink() when this function has finished.
            if teamsSurvivors > 0:
                self.eliminateNewPlayers = True
                self.spawnNewResurrectionEntity(victim,victimsTeam)
                self.addPlayerToResurrectionQueue(victim,victimsTeam)
               
                if self.playerNotBot(victim):
                    queuePosition = None
                    if victimsTeam == GEGlobal.TEAM_MI6: queuePosition = self.mResurrectionQueue.index(victim)
                    else: queuePosition = self.jResurrectionQueue.index(victim)
               
                    #TODO use language files
                    self.tellPlayerWhatTheirResurrectionQueuePositionIs(victim,queuePositionP=queuePosition)
               
            elif teamsSurvivors < 0: GEUtil.Msg("ERROR:OnPlayerKilled():teamsSurvivors < 0: = " + str(teamsSurvivors))

    def OnCaptureAreaSpawned( self, area ):
        areasTeam = area.GetTeamNumber()
        location = area.GetAbsOrigin()
           
        #Recusrive Function Call Loop:
        #If the area has spawned at an enemy resurrection area's location respawn it and exit this function call
        #because this function will be called again when the area respawns and should only execute statements
        #after the respawn IF block, when it is called for an area which has an acceptable location.
        if areasTeam == GEGlobal.TEAM_MI6 and location in self.jAreaLocations or areasTeam == GEGlobal.TEAM_JANUS and location in self.mAreaLocations:
            self.respawnResurrectionEntity(area.GetGroupName(),areasTeam)
            return
       
        colour = None
        if area.GetTeamNumber() == GEGlobal.TEAM_MI6:
            self.mAreaLocations.append(location)
            colour = self.COLOR_MI6_RADAR
        else:
            self.jAreaLocations.append(location)
            colour = self.COLOR_JANUS_RADAR
               
        self.radar.AddRadarContact(area,GEGlobal.RADAR_TYPE_OBJECTIVE,True,"sprites/hud/radar/capture_point",colour)
        self.radar.SetupObjective(area,area.GetTeamNumber(),"", "",colour, 0, False )
   
    def OnCaptureAreaEntered( self, area, player, token ):
        if area.GetTeamNumber() == player.GetTeamNumber():
            areasTeam = area.GetTeamNumber()
           
            #Add player to area's user list, creating if it hasn't been created already
            self.resurrectionAreaUserLists[area.GetGroupName()].append(player)
           
            #Create & configure resurrection timer & Give it the area's name and team
            resurrectionTimer = self.timerTracker.CreateTimer(str(areasTeam)  + "," + area.GetGroupName())
            resurrectionTimer.SetUpdateCallback(self.ResurrectionTimerTick,1.0)
            resurrectionTimer.SetAgeRate(1.0,0)
           
            #Create a resurrection progress bar on the player's screen TODO: use language files
            GEUtil.InitHudProgressBar(player,self.ResurrectionPBIndex, "Resurrecting Team Mate...", GEGlobal.HUDPB_SHOWVALUE, self.resurrectionTime, self.ResurrectionPBX, self.ResurrectionPBY, 120, 16, GEUtil.CColor( 220, 220, 220, 240 ) )
           
            #Start the resurrection timer
            resurrectionTimer.Start(self.resurrectionTime,False)
       
    def OnCaptureAreaExited( self, area, player ):
        areasTeam = area.GetTeamNumber()
        areasName = area.GetGroupName()
       
        if areasTeam == player.GetTeamNumber():
            #Remove player from the area's user list
            self.resurrectionAreaUserLists[areasName].remove(player)
               
            #Remove the resurrection progress progress bar from the player's screen
            GEUtil.RemoveHudProgressBar(player,self.ResurrectionPBIndex)

    def ResurrectionTimerTick( self, timer, update_type ):
        areasID = timer.GetName()[2:]

        #Area still in use?
        if update_type != Timer.UPDATE_STOP and self.areaInUse(areasID):
            #Update each user's resurrection progress GUI
            for areaUser in self.resurrectionAreaUserLists[areasID]:
                if update_type == Timer.UPDATE_FINISH:
                    GEUtil.RemoveHudProgressBar(areaUser,self.ResurrectionPBIndex)
                else:
                    GEUtil.UpdateHudProgressBar(areaUser,self.ResurrectionPBIndex,int(timer.GetCurrentTime()))
       
            if update_type == Timer.UPDATE_FINISH:
                #Get area's team
                areasTeam = int(timer.GetName()[0])
               
                teamString = self.getTeamString(areasTeam)
               
                #Delete the resurrection area
                self.deleteResurrectionArea(areasID,areasTeam)
               
                #Choose player to be resurrected.
                resurrectedPlayer = None
                if areasTeam == GEGlobal.TEAM_MI6 and len(self.mResurrectionQueue) != 0: resurrectedPlayer = self.mResurrectionQueue.pop(0)
                elif len(self.jResurrectionQueue) != 0: resurrectedPlayer = self.jResurrectionQueue.pop(0)
               
                #If for some reason there is no player to resurrect, don't resurrect anyone.
                if resurrectedPlayer != None:
                    #Resurrect player and respond to their resurrection
                    self.resurrectPlayer(resurrectedPlayer)
                   
                    #Update player bounty
                    self.increaseTeamBounty(areasTeam)
                   
                    #Update resurrection queue progress bars for team mates
                    self.resurrectionQueueUpdateNotify(areasTeam)
                   
                    if self.playerNotBot(resurrectedPlayer):
                        #Remove resurrected player's resurrection queue progress bar
                        GEUtil.RemoveHudProgressBar(resurrectedPlayer,self.ResurrectionPBIndex)
                       
                        #Emit player resurrected event
                        GEUtil.EmitGameplayEvent("DieAnotherDay_resurrection", "%s" % resurrectedPlayer.GetName(),"%s" % teamString)
                   
                        #Announce event in console
                        GEUtil.Msg("A " + teamString + " player has been resurrected: " + resurrectedPlayer.GetName())
                   
                    #Announce resurrection
                    GEUtil.ClientPrint(None, GEGlobal.HUD_PRINTTALK,"A " + teamString + " player has been resurrected.")
                   
                    #If there are now no eliminated players, allow new players to join without needing
                    #to be spawned by their team mates.
                    numberOfMPlayers = GEMPGameRules.GetNumInRoundTeamPlayers(GEGlobal.TEAM_MI6)
                    numberOfJPlayers = GEMPGameRules.GetNumInRoundTeamPlayers(GEGlobal.TEAM_JANUS)
                   
                    if numberOfMPlayers == self.mBounty and numberOfJPlayers == self.jBounty: self.eliminatedSpectators = False
           
        #Activated if the timer hasn't expired in this tick and it's area no longer has users:
        elif update_type != Timer.UPDATE_STOP:
            timer.Stop()
           
    def resurrectionQueueUpdateNotify(self,team):
        resurrectionQueue = None
        if(team == GEGlobal.TEAM_MI6): resurrectionQueue = self.mResurrectionQueue
        else: resurrectionQueue = self.jResurrectionQueue
       
        for player in resurrectionQueue:
            if self.playerNotBot(player):
                self.tellPlayerWhatTheirResurrectionQueuePositionIs(player,queueP=resurrectionQueue)
           
    def tellPlayerWhatTheirResurrectionQueuePositionIs(self,player,queueP=None,queuePositionP=None):
        if queuePositionP == None and queueP != None: queuePositionP = queueP.index(player)
        if queuePositionP != None :
            #TODO use language files
            GEUtil.ClientPrint(player,GEGlobal.HUD_PRINTCONSOLE,"Team mates who will be resurrected before you = ")
            GEUtil.PopupMessage(player, "You've Been Eliminated", "Team mates who will be resurrected before you = " + str(queuePositionP))       
           
    def playerNotBot(self,player):
        return player.__class__.__name__ != "CGEBotPlayer"

    def resurrectPlayer(self,player):
        self.pltracker.SetValue(player,self.TR_ELIMINATED,False)
   
    def getTeamsRadarColor(self,teamNumber):
        if teamNumber == GEGlobal.TEAM_MI6: return self.COLOR_MI6_RADAR
        else: return self.COLOR_JANUS_RADAR

    def OnThink( self ):
        if GEMPGameRules.GetNumActivePlayers() < 2:
            self.waitingForPlayers = True
            return

        if self.waitingForPlayers:
            self.waitingForPlayers = False
            GEUtil.HudMessage( None, "#GES_GP_GETREADY", -1, -1, GEUtil.CColor( 255, 255, 255, 255 ), 2.5 )
            GEMPGameRules.EndRound( False )

        #Check to see if the round is over!:
       
        #check to see if each team has a player...
        inPlayMPlayers = []
        inPlayJPlayers = []

        for i in range( 32 ):
            if not GEPlayer.IsValidPlayerIndex( i ):
                continue

            player = GEPlayer.GetMPPlayer( i )
            if self.IsInPlay( player ):
                if player.GetTeamNumber() == GEGlobal.TEAM_MI6:
                    inPlayMPlayers.append( player )
                elif player.GetTeamNumber() == GEGlobal.TEAM_JANUS:
                    inPlayJPlayers.append( player )

        numMI6Players = len(inPlayMPlayers)
        numJanusPlayers = len(inPlayJPlayers)

        if numMI6Players == 0 and numJanusPlayers == 0: GEMPGameRules.EndRound()
        elif numMI6Players == 0 and numJanusPlayers > 0: self.teamWins(GEGlobal.TEAM_JANUS)
        elif numMI6Players > 0 and numJanusPlayers == 0: self.teamWins(GEGlobal.TEAM_MI6)
           
    def teamWins(self,teamNumber):
        team = GEMPGameRules.GetTeam(teamNumber)
        team.IncrementMatchScore( 5 )
        GEMPGameRules.SetTeamWinner(team)
        GEMPGameRules.EndRound()

    def CanPlayerRespawn( self, player ):
        #if self.isEliminatedPlayer(player):
            #player.SetScoreBoardColor( GEGlobal.SB_COLOR_ELIMINATED )
            #return False

        #player.SetScoreBoardColor( GEGlobal.SB_COLOR_NORMAL )
       
        return False

    def InitializePlayerBounty( self ):
        if self.mBounty == 0 and self.jBounty == 0:
            self.mBountyMaxPlayers = GEMPGameRules.GetNumInRoundTeamPlayers(GEGlobal.TEAM_MI6)
            self.jBountyMaxPlayers = GEMPGameRules.GetNumInRoundTeamPlayers(GEGlobal.TEAM_JANUS)
           
            self.mBounty = self.mBountyMaxPlayers
            self.jBounty = self.jBountyMaxPlayers
   
            GEUtil.InitHudProgressBar(None,self.MBountyPBIndex,"MI6: ",GEGlobal.HUDPB_SHOWVALUE, self.mBountyMaxPlayers, self.MBountyPBX,self.MBountyPBY, 0, 10, self.MBountyFontColour)
            GEUtil.InitHudProgressBar(None,self.JBountyPBIndex,"Janus: ",GEGlobal.HUDPB_SHOWVALUE, self.jBountyMaxPlayers, self.JBountyPBX,self.JBountyPBY, 0, 10,self.JBountyFontColour)

    def getTeamsPlayerCount(self,team):
        if team == GEGlobal.TEAM_MI6: return self.mBountyMaxPlayers
        else: return self.jBountyMaxPlayers       

    def updateTeamsDisplayedMaxPlayers(self,team):
        numberOfPlayersInTeam = self.getTeamsPlayerCount(team)
       
        if team == GEGlobal.TEAM_MI6:
            GEUtil.RemoveHudProgressBar(None,self.MBountyPBIndex)
            GEUtil.InitHudProgressBar(None, self.MBountyPBIndex,"MI6: ", GEGlobal.HUDPB_SHOWVALUE,numberOfPlayersInTeam, self.MBountyPBX,self.MBountyPBY, 0, 10, self.MBountyFontColour)
        else:
            GEUtil.RemoveHudProgressBar(None,self.JBountyPBIndex)
            GEUtil.InitHudProgressBar(None,self.JBountyPBIndex,"Janus: ", GEGlobal.HUDPB_SHOWVALUE,numberOfPlayersInTeam, self.JBountyPBX,self.JBountyPBY, 0, 10,self.JBountyFontColour)     

    def decreaseTeamBounty(self,team):
        if team == GEGlobal.TEAM_JANUS: self.jBounty -= 1
        else: self.mBounty -= 1
        self.updateDisplayedBounties()
       
    def increaseTeamBounty(self,team):
        if team == GEGlobal.TEAM_JANUS: self.jBounty += 1
        else: self.mBounty += 1
        self.updateDisplayedBounties()
       
    def updateDisplayedBounties(self):
        GEUtil.UpdateHudProgressBar(None,self.JBountyPBIndex,self.jBounty)
        GEUtil.UpdateHudProgressBar(None,self.MBountyPBIndex,self.mBounty)

    def IsInPlay( self, player ):
        return player.GetTeamNumber() is not GEGlobal.TEAM_SPECTATOR and self.pltracker.GetValue( player, self.TR_SPAWNED ) and not self.pltracker.GetValue( player, self.TR_ELIMINATED )

    def GetTeamPlay(self):
        return GEGlobal.TEAMPLAY_ALWAYS

       
--- End code ---

Game settings:
I was the only player.

The Test:
1.When the map had loaded and the team choice menu appeared, I chose to be a spectator: I was then able to move my view around the map normally.
2.I then opened the team menu and chose to join MI6: I was able to move my view around the map normally.
3.I then changed my team to Janus: I was still able to move my view around the map normally.
4.I then changed my team to Spectator: I was able to move my view around the map normally for a few seconds, but then my view changed to the view shown in the attached screen shot and I was no longer able to move it.
5.I then changed my team to MI6: I was then able to move my view around the map normally again.
6.I finally changed my team back to Spectator: The view problem from step 4 reoccurred.

killermonkey:
Does this happen when there are other players (or bots) in the server?

If it does NOT, than I know what is going wrong.

Either way, you can't fix this from python so don't worry about it.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version