def OnPlayerSpawn(self, player): if not self.WaitingForPlayers and not self.warmupTimer.IsInWarmup(): if not self.pltracker[player][TR_SPAWNED] and int( GEUtil.GetCVarValue("ar_lowestlevel")) != 0: self.SetLevel(player, self.LowestLevel()) if self.pltracker[player][TR_ROUND] and self.RoundLimit > 0: if self.RoundNumber < self.RoundLimit: GEUtil.HudMessage( player, _("#GES_GP_AR_ROUNDCOUNT", self.RoundNumber, self.RoundLimit), -1, 0.02, GEUtil.Color(170, 170, 170, 220), 3.5) else: GEUtil.HudMessage(player, "#GES_GP_AR_FINALROUND", -1, 0.02, GEUtil.Color(206, 43, 43, 255), 3.5) self.pltracker[player][TR_ROUND] = False self.GivePlayerWeapons(player) self.pltracker[player][TR_SPAWNED] = True if player.IsInitialSpawn(): GEUtil.PopupMessage(player, "#GES_GP_ARSENAL_NAME", "#GES_GPH_AR_GOAL")
def vtak_CheckObjStatus(self, player, seconds): timeRatio = seconds / self.longestinning if timeRatio > 0.75 and seconds >= 60 and not self.pltracker[player][ TR_OBJTAG]: radar = GERules.GetRadar() radar.SetupObjective( player, Glb.TEAM_NONE, "", "", GEUtil.Color(180, 30, 30, 255), 256 ) # Minimum distance of 256 to make it harder to shoot targets through walls. radar.AddRadarContact(player, Glb.RADAR_TYPE_PLAYER, True, "", GEUtil.Color(180, 30, 30, 255)) self.pltracker[player][TR_OBJTAG] = True return
def OnRoundBegin(self): super(Vampire, self).OnRoundBegin() if not self.warmupTimer.IsInWarmup() and self.warmupTimer.HadWarmup(): GERules.LockRound() for player in GetPlayers(): self.blood_counter[player.GetUID()] = self.max_blood GEUtil.InitHudProgressBar(player, 0, "Blood", 1, self.max_blood, -1, .04, 130, 12, GEUtil.Color(255, 0, 0, 255), self.max_blood) if self.max_lives > 0: self.lives_counter[player.GetUID()] = self.max_lives GEUtil.InitHudProgressBar(player, 1, "Lives", 2, self.max_lives, -1, .08, 130, 12, GEUtil.Color(255, 255, 255, 255), self.max_lives)
def vtak_UpdateTimer(self, player, seconds): timercolor = GEUtil.Color(150, 150, 150, 255) recordcolor = GEUtil.Color(255, 255, 255, 255) targetcolor = GEUtil.Color(255, 0, 50, 255) if self.pltracker[player][ TR_OBJTAG]: # If we're an objective we need to know that before anything else. timercolor = targetcolor # So make our timer red. elif seconds >= self.pltracker[player][ TR_BESTINN]: # Otherwise we could at least be beating our previous best inning. timercolor = recordcolor # Which deserves a brighter color. msg = _("#GES_GP_VTAK_TIME", str(self.vtak_SecondsToClockTime(seconds))) GEUtil.HudMessage(player, msg, -1, 0.745, timercolor, 1.5, 0)
def OnThink(self): if GEMPGameRules.GetNumActivePlayers() < 2: GEMPGameRules.UnlockRound() self.waitingForPlayers = True return if self.waitingForPlayers and GEMPGameRules.GetNumActivePlayers() > 1: self.waitingForPlayers = False if not self.warmupTimer.HadWarmup(): self.warmupTimer.StartWarmup(15.0, True) else: GEUtil.HudMessage(None, "#GES_GP_GETREADY", -1, -1, GEUtil.Color(255, 255, 255, 255), 2.5) GEMPGameRules.EndRound(False) if self.warmupTimer.IsInWarmup(): return # Check to see if more than one player is around iPlayers = [] for player in self.pltracker.GetPlayers(): if self.IsInPlay(player): iPlayers.append(player) numPlayers = len(iPlayers) if numPlayers == 0: # This shouldn't happen, but just in case it does we don't want to overflow the vector... GEMPGameRules.EndRound() if numPlayers == 1: # Make last remaining player the winner, and double his or her score. # GEMPGameRules.SetPlayerWinner(iPlayers[0]) # iPlayers[0].IncrementScore(iPlayers[0].GetScore()) GEMPGameRules.EndRound()
def InitializePlayerBounty(self): if self.dmBounty == 0: deduct = 0 if self.eliminationMode else 1 self.dmBounty = GEMPGameRules.GetNumInRoundPlayers() - deduct GEUtil.InitHudProgressBar(GEGlobal.TEAM_NONE, 0, "#GES_GP_FOES", GEGlobal.HUDPB_SHOWVALUE, self.dmBounty, -1, 0.02, 0, 10, GEUtil.Color(170, 170, 170, 220), self.dmBounty)
def AddRadarContact(self, entity, type=0, always_visible=False, icon="", color=GEUtil.Color()): '''
def OnThink(self): self.updateRings() if GEMPGameRules.GetNumActivePlayers() < 2: if not self.WaitingForPlayers: self.notice_WaitingForPlayers = 0 GEMPGameRules.EndRound() elif GEUtil.GetTime() > self.notice_WaitingForPlayers: GEUtil.HudMessage(None, "#GES_GP_WAITING", -1, -1, GEUtil.Color(255, 255, 255, 255), 2.5, 1) self.notice_WaitingForPlayers = GEUtil.GetTime() + 12.5 self.warmupTimer.Reset() self.WaitingForPlayers = True return elif self.WaitingForPlayers: self.WaitingForPlayers = False if not self.warmupTimer.HadWarmup(): self.warmupTimer.StartWarmup( int(GEUtil.GetCVarValue("up_warmup")), True) GEUtil.EmitGameplayEvent("up_startwarmup") else: GEMPGameRules.EndRound(False) if not self.warmupTimer.IsInWarmup() and not self.WaitingForPlayers: if GEMPGameRules.IsTeamplay(): scoreMI6 = GEMPGameRules.GetTeam( GEGlobal.TEAM_MI6).GetRoundScore() scoreJanus = GEMPGameRules.GetTeam( GEGlobal.TEAM_JANUS).GetRoundScore() for uplinkPoint in list(self.areaDictionary): updated = self.areaDictionary[uplinkPoint].updateUplinkTimer( self.uplinkTimerMax) self.updateBar(self.areaDictionary[uplinkPoint].playerList, self.areaDictionary[uplinkPoint].name) if updated: self.uplinkCaptured(self.areaDictionary[uplinkPoint].name, self.areaDictionary[uplinkPoint].UID, updated) if GEMPGameRules.IsTeamplay(): self.areaDictionary[uplinkPoint].updatePointTimer( self.pointTimerMax) if not updated and ( (self.areaDictionary[uplinkPoint].timerJanus + self.areaDictionary[uplinkPoint].timerMI6) or len(self.areaDictionary[uplinkPoint].playerList)): self.createObjective( self.areaDictionary[uplinkPoint].UID, self.areaDictionary[uplinkPoint].name, self.areaDictionary[uplinkPoint].inProgress) if GEMPGameRules.IsTeamplay(): if scoreMI6 != GEMPGameRules.GetTeam( GEGlobal.TEAM_MI6).GetRoundScore( ) or scoreJanus != GEMPGameRules.GetTeam( GEGlobal.TEAM_JANUS).GetRoundScore(): self.showRoundScore(None)
def __init__(self): super(IAmInvincible, self).__init__() self.playerTracker = GEPlayerTracker(self) self.warmupTimer = GEWarmUp(self) self.notice_WaitingForPlayers = 0 self.WaitingForPlayers = True self.roundActive = False self.currentBorisPlayer = False self.costumeBoris = "boris" self.soundError = "Buttons.beep_denied" self.soundPoint = "GEGamePlay.Token_Chime" self.soundSpeedBoost = "GEGamePlay.Whoosh" self.radarIconShapeBoris = "" self.radarIconColorBoris = GEUtil.Color(206, 43, 43, 255) self.objectiveColorBoris = GEUtil.Color(206, 43, 43, 255) self.objectiveTextBoris = "Boris" self.messageChannel = 0 self.messageDisplayTime = 6.0 self.messageXPos = -1 self.messageYPos = 0.71 self.newBorisMessageColor = GEUtil.Color(206, 43, 43, 255) self.newBorisMessageText = "You are now Boris. You are invincible!" self.noBorisMessageColor = GEUtil.CColor(220, 220, 220, 255) self.noBorisMessageText = "Boris abandoned the match!" self.isBorisSpeedBoosted = False self.speedBoostMultiplier = 1.25 self.timerBorisSpeedBoost = 0 self.timerBorisSpeedBoostMax = 30 self.breakpointDamage = 160 #Default max health/armor is 160/160 self.explosionDamageMultiplier = 0.5 self.borisSelfDamageMultiplier = 0.07
def CanPlayerHaveItem(self, player, item): if item.GetClassname().startswith("item_armorvest"): if player.GetMaxArmor( ) == 0: # If we can't pick up this armor due to not having enough kills, inform the player as to why. killsToNextLevel = self.KillsPerArmor - self.pltracker.GetValue( player, ARMORKILLS) if killsToNextLevel == 1: GEUtil.HudMessage( player, "You need 1 more kill to pick up armor!", -1, 0.71, GEUtil.Color(150, 50, 50, 255), 1.0, 1) else: GEUtil.HudMessage( player, "You need " + str(killsToNextLevel) + " more kills to pick up armor!", -1, 0.71, GEUtil.Color(150, 50, 50, 255), 1.0, 1) elif player.GetArmor() < int( Glb.GE_MAX_ARMOR ): # If we made it here we're most certainly picking up that armor. self.pltracker.SetValue(player, ARMORKILLS, 0) self.__CheckEnableArmorPickup(player, 0) return True
def OnThink(self): # Check to see if we can get out of warmup if self.waitingForPlayers: if GERules.GetNumActivePlayers() > 1: self.waitingForPlayers = False if not self.warmupTimer.HadWarmup(): self.warmupTimer.StartWarmup(15, True) else: GEUtil.HudMessage(None, "#GES_GP_GETREADY", -1, -1, GEUtil.Color(255, 255, 255, 255), 2.5, 1) GERules.EndRound(False) elif GEUtil.GetTime() > self.PLAYER_WAIT_TICKER: need = 2 - GERules.GetNumActivePlayers() GEUtil.HudMessage(None, "#GES_GP_WAITING", -1, -1, GEUtil.Color(255, 255, 255, 255), 2.5, 1) GEUtil.HudMessage(None, "Need %i more players" % need, -1, -1.3, GEUtil.Color(255, 255, 255, 255), 2.5, 2) self.PLAYER_WAIT_TICKER = GEUtil.GetTime() + 12.5 if not self.waitingForPlayers and GERules.GetNumActivePlayers() < 2: self.waitingForPlayers = True GERules.EndRound()
def __CheckEnableArmorPickup(self, player, armorkills): ''' Check to see if we should enable armor pickups for the given player. ''' if self.KillsPerArmor <= 0: # This setting is disabled, so always let players pick up armor. player.SetMaxArmor(160) return if armorkills == self.KillsPerArmor: player.SetMaxArmor(160) # Turn the armor bar blue again. GEUtil.PlaySoundToPlayer(player, "Buttons.beep_ok") GEUtil.HudMessage(player, "You've earned an armor pickup!", -1, 0.71, GEUtil.Color(50, 100, 200, 255), 3.0, 1) elif armorkills < self.KillsPerArmor: killsToNextLevel = self.KillsPerArmor - armorkills if killsToNextLevel == 1: GEUtil.HudMessage(player, "1 kill until next armor pickup", -1, 0.71, GEUtil.Color(50, 100, 200, 255), 3.0, 1) else: GEUtil.HudMessage( player, str(killsToNextLevel) + " kills until next armor pickup", -1, 0.71, GEUtil.Color(50, 100, 200, 255), 3.0, 1)
def ar_PrintCurLevel(self, player): if not player: return lvl = self.ar_GetLevel(player) if lvl < maxLevel: name = GEWeapon.WeaponPrintName(self.weaponList[lvl]) else: name = "Hunting Knife" msg = _("#GES_GP_GUNGAME_LEVEL", str(lvl + 1), name) GEUtil.HudMessage(player, msg, -1, 0.71, GEUtil.Color(220, 220, 220, 255), 3.0, 2)
def OnThink(self): # Check to see if we can get out of warmup if self.waitingForPlayers: if GERules.GetNumActivePlayers() > 1: self.waitingForPlayers = False Thunderball.PLTRACKER.SetValueAll(TR_SPAWNED, True) if not self.warmupTimer.HadWarmup(): self.warmupTimer.StartWarmup(15, True) else: GERules.EndRound(False) elif GEUtil.GetTime() > self.PLAYER_WAIT_TICKER: GEUtil.HudMessage(None, "#GES_GP_WAITING", -1, -1, GEUtil.Color(255, 255, 255, 255), 2.5, 1) self.PLAYER_WAIT_TICKER = GEUtil.GetTime() + 12.5 # check if we can do the initial assignment of the Thunderball if Thunderball.CAN_ASSIGN and not Thunderball.ASSIGNED_ONCE: self.assignThunderball(self.chooserandom()) return if self.warmupTimer.HadWarmup( ) and not self.waitingForPlayers and Thunderball.ASSIGNED_ONCE: for player in Thunderball.PLTRACKER.GetPlayers(): if player.GetUID( ) == Thunderball.TB_CARRIER and Thunderball.PLTRACKER[player][ TB_KNOCKEDOUT]: self.assignThunderball(self.chooserandom()) remain = Thunderball.TIME_TRACK - int( self.thunderballTimer.GetCurrentTime()) if remain <= 5: GEUtil.HudMessage(None, "Thunderball Detonation in %i sec" % remain, -1, 0.12, ALERT_COLOR, 1.0, 5) else: GEUtil.HudMessage(None, "Thunderball Detonation in %i sec" % remain, -1, 0.12, TIMER_COLOR, 1.0, 5) if remain == 6: # it takes a moment to play the sound player = GEPlayer.ToMPPlayer(Thunderball.TB_CARRIER) GEUtil.PlaySoundToPlayer(player, "GEGamePlay.Level_Down") GEUtil.HudMessage(player, "YOU HAVE THE THUNDERBALL!", -1, -1, ALERT_COLOR, 3.0, 6) if remain < 0: # Timer broke, force it to die GEUtil.PostDeathMessage("The Thunderball has malfunctioned!") self.thunderballTimer.Stop() self.assignThunderball(self.chooserandom())
def ar_SetKills(self, player, kills): if not player: return if (kills >= self.KillsPerLevel): self.ar_IncrementLevel(player, 1) self.pltracker[player][TR_LEVELKILLS] = 0 elif (kills < 0): self.ar_IncrementLevel(player, -1) self.pltracker[player][TR_LEVELKILLS] = max( self.pltracker[player][TR_LEVELKILLS] + kills, 0 ) # Kills is negative here so we're using it to correct previous level killcount. else: self.pltracker[player][ TR_LEVELKILLS] = kills # No level advancement, just complete the request as asked. msg = _( "#GES_GP_GUNGAME_KILLS", str(self.KillsPerLevel - kills) ) # We didn't increment a level which would have caused a level advancement message. GEUtil.HudMessage(player, msg, -1, 0.71, GEUtil.Color(220, 220, 220, 255), 1.5, 2) # So give a killcount message instead.
def OnThink(self): # Check for insufficient player count if GERules.GetNumActivePlayers() < 2: if not self.WaitingForPlayers: self.notice_WaitingForPlayers = 0 GERules.EndRound() elif GEUtil.GetTime() > self.notice_WaitingForPlayers: GEUtil.HudMessage(None, "#GES_GP_WAITING", -1, -1, GEUtil.Color(255, 255, 255, 255), 2.5, 1) self.notice_WaitingForPlayers = GEUtil.GetTime() + 12.5 self.warmupTimer.Reset() self.WaitingForPlayers = True return elif self.WaitingForPlayers: self.WaitingForPlayers = False if not self.warmupTimer.HadWarmup(): self.warmupTimer.StartWarmup( int(GEUtil.GetCVarValue("ar_warmuptime")), True) else: GERules.EndRound(False)
def OnThink(self): if GEMPGameRules.GetNumActivePlayers() < 2: if not self.WaitingForPlayers: self.notice_WaitingForPlayers = 0 GEMPGameRules.EndRound(True, True) if self.currentBorisPlayer: oldBorisPlayer = self.currentBorisPlayer self.currentBorisPlayer = False self.outgoingBorisPlayer(oldBorisPlayer, True) elif GEUtil.GetTime() > self.notice_WaitingForPlayers: GEUtil.HudMessage(None, "#GES_GP_WAITING", self.messageXPos, self.messageYPos, GEUtil.Color(255, 255, 255, 255), 2.5, 1) self.notice_WaitingForPlayers = GEUtil.GetTime() + 12.5 self.warmupTimer.Reset() self.WaitingForPlayers = True return elif self.WaitingForPlayers: self.WaitingForPlayers = False if not self.warmupTimer.HadWarmup(): self.warmupTimer.StartWarmup( int(GEUtil.GetCVarValue("iami_warmup")), True) GEUtil.EmitGameplayEvent("iami_startwarmup") else: GEMPGameRules.EndRound(False, True) if self.timerBorisSpeedBoost: self.timerBorisSpeedBoost -= 1 if self.currentBorisPlayer and self.isBorisSpeedBoosted and not self.timerBorisSpeedBoost: self.currentBorisPlayer.SetSpeedMultiplier(1) self.isBorisSpeedBoosted = False if self.currentBorisPlayer and not self.currentBorisPlayer.IsDead(): self.giveAllWeapons(self.currentBorisPlayer, False)
def OnThink(self): # Check for insufficient player count if GERules.GetNumActiveTeamPlayers( Glb.TEAM_MI6) < 2 or GERules.GetNumActiveTeamPlayers( Glb.TEAM_JANUS) < 2: if not self.WaitingForPlayers: self.notice_WaitingForPlayers = 0 GERules.EndRound() elif GEUtil.GetTime() > self.notice_WaitingForPlayers: GEUtil.HudMessage(None, "#GES_GP_WAITING", -1, -1, GEUtil.Color(255, 255, 255, 255), 2.5, 1) self.notice_WaitingForPlayers = GEUtil.GetTime() + 12.5 self.warmupTimer.Reset() self.WaitingForPlayers = True return elif self.WaitingForPlayers: self.WaitingForPlayers = False if not self.warmupTimer.HadWarmup(): self.warmupTimer.StartWarmup( int(GEUtil.GetCVarValue("tdm_warmuptime")), True) if self.warmupTimer.IsInWarmup(): GEUtil.EmitGameplayEvent("tdm_startwarmup") else: GERules.EndRound(False) if self.FragLimit > 0: teamJ = GERules.GetTeam(Glb.TEAM_JANUS) teamM = GERules.GetTeam(Glb.TEAM_MI6) jScore = teamJ.GetRoundScore() + teamJ.GetMatchScore() mScore = teamM.GetRoundScore() + teamM.GetMatchScore() if jScore >= self.FragLimit or mScore >= self.FragLimit: self.LateAttendance = True GERules.EndMatch()
class ForYourEyesOnly(GEScenario): TR_ELIMINATED = "eliminated" TR_SPAWNED = "spawned" CASE_CLASS = 'token_deathmatch' CASE_GLOW = GEUtil.Color(14, 139, 237, 200) CASE_COLOR = GEUtil.Color(94, 171, 231, 255) def __init__(self): super(ForYourEyesOnly, self).__init__() self.CaseOwnerID = None self.waitingForPlayers = True self.dmBounty = 0 self.pltracker = GEPlayerTracker(self) self.warmupTimer = GEWarmUp(self) # CVars self.allScore = True self.caseEliminate = True self.eliminationMode = False def GetPrintName(self): return "For Your Eyes Only" def GetScenarioHelp(self, help_obj): help_obj.SetDescription("At the beginning of the round, a Briefcase is spawned somewhere on the map " "(blue square on the radar). Whoever picks up the Briefcase " "will get full health and armor, increased speed, and will eliminate " "players he or she kills. You will respawn normally if killed by someone without " "the Briefcase. For every elimination you make while holding the Briefcase, you will " "score 1 point (extra if allScore enabled0 and regain 1 bar of health (or armor, " "if health is full). The last remaining player will win the round, and have his or her " "score doubled for the round!") def GetGameDescription(self): return "For Your Eyes Only" def GetTeamPlay(self): return GEGlobal.TEAMPLAY_NONE def OnLoadGamePlay(self): # Spawn a Briefcase token where DM tokens normally spawn, and force radar on. GEMPGameRules.GetTokenMgr().SetupToken(self.CASE_CLASS, team=GEGlobal.TEAM_NONE, limit=1, location=GEGlobal.SPAWN_TOKEN, glow_color=self.CASE_GLOW, glow_dist=450.0, allow_switch=True, respawn_delay=30, view_model="models/weapons/tokens/v_briefcasetoken.mdl", world_model="models/weapons/tokens/w_briefcasetoken.mdl", print_name="Briefcase") GEMPGameRules.GetRadar().SetForceRadar(True) # Precache all necessary sounds GEUtil.PrecacheSound("GEGamePlay.Token_Chime") GEUtil.PrecacheSound("GEGamePlay.Token_Capture_Enemy") GEUtil.PrecacheSound("GEGamePlay.Token_Drop_Friend") GEUtil.PrecacheSound("GEGamePlay.Token_Grab") # Help list, to keep track of which players have seen the Briefcase help popups upon case pickup. # When a player picks up the case, they will be added to this list. self.helplist = [] self.CreateCVar("fyeo_case_carrier_elimination", "1", "Allows the briefcase holder to be eliminated if killed (0 to disable, 1 to enable)") self.CreateCVar("fyeo_all_score", "1", "Allows all players to score points for kills (0 to disable, 1 to enable)") self.CreateCVar("fyeo_elimination", "0", "Enables the old elimination style of gameplay, " "disabling bars the players from getting the case for the rest of the match " "(0 to disable, 1 to enable") # Make sure we don't start out in wait time or have a warm-up if we changed game play mid-match if GEMPGameRules.GetNumActivePlayers() >= 2: self.waitingForPlayers = False self.warmupTimer.StartWarmup(0) def OnUnloadGamePlay(self): super(ForYourEyesOnly, self).OnUnloadGamePlay() self.warmupTimer = None self.pltracker = None def OnCVarChanged(self, name, oldvalue, newvalue): if name == "fyeo_case_carrier_elimination": self.caseEliminate = int(newvalue) >= 1 elif name == "fyeo_all_score": self.allScore = int(newvalue) >= 1 elif name == "fyeo_elimination": self.eliminationMode = int(newvalue) >= 1 def OnPlayerConnect(self, player): self.pltracker[player][self.TR_SPAWNED] = False self.pltracker[player][self.TR_ELIMINATED] = False if GEMPGameRules.IsRoundLocked(): self.pltracker[player][self.TR_ELIMINATED] = True def OnPlayerDisconnect(self, player): if GEMPGameRules.IsRoundLocked() and player.IsActive() and not self.pltracker[player][self.TR_ELIMINATED]: self.UpdatePlayerBounty(player) def OnPlayerTeamChange(self, player, oldTeam, newTeam): if GEMPGameRules.IsRoundLocked(): if self.IsInPlay(player) and oldTeam != GEGlobal.TEAM_SPECTATOR: self.UpdatePlayerBounty(player) elif oldTeam == GEGlobal.TEAM_SPECTATOR: GEUtil.PopupMessage(player, "#GES_GPH_CANTJOIN_TITLE", "#GES_GPH_CANTJOIN") else: GEUtil.PopupMessage(player, "#GES_GPH_ELIMINATED_TITLE", "#GES_GPH_ELIMINATED") # Changing teams will automatically eliminate you self.pltracker[player][self.TR_ELIMINATED] = True def OnRoundBegin(self): self.dmBounty = 0 # Reset all player's statistics self.pltracker.SetValueAll(self.TR_ELIMINATED, False) GEMPGameRules.UnlockRound() GEMPGameRules.ResetAllPlayerDeaths() GEMPGameRules.ResetAllPlayersScores() def OnRoundEnd(self): GEMPGameRules.GetRadar().DropAllContacts() GEUtil.RemoveHudProgressBar(None, 0) def OnPlayerSpawn(self, player): if player.GetTeamNumber() != GEGlobal.TEAM_SPECTATOR: self.pltracker[player][self.TR_SPAWNED] = True # Reset scoreboard color and max speed for player, and make sure they can't go above max health and armor. player.SetScoreBoardColor(GEGlobal.SB_COLOR_NORMAL) player.SetMaxHealth(int(GEGlobal.GE_MAX_HEALTH)) player.SetMaxArmor(int(GEGlobal.GE_MAX_ARMOR)) player.SetSpeedMultiplier(1.0) if player.IsInitialSpawn(): if not self.IsInPlay(player): GEUtil.PopupMessage(player, "#GES_GPH_CANTJOIN_TITLE", "#GES_GPH_CANTJOIN") GEUtil.PopupMessage(player, "#GES_GPH_OBJECTIVE", "Pick up the Briefcase, then kill other players to eliminate them. " "\nLast agent standing wins the round!") GEUtil.PopupMessage(player, "#GES_GPH_RADAR", "Dropped Briefcase = Blue Square \nBriefcase Holder = Blue Dot") GEUtil.ClientPrint(player, GEGlobal.HUD_PRINTTALK, "^yIf you experience any bugs or have suggestions, " "please report them on GitHub. https://git.io/fpih1") def OnPlayerKilled(self, victim, killer, weapon): if not victim: return # Let the base scenario behavior handle scoring when the mode isn't in effect if self.waitingForPlayers or self.warmupTimer.IsInWarmup() or GEMPGameRules.IsIntermission(): GEScenario.OnPlayerKilled(self, victim, killer, weapon) return # Initialize the bounty (if we need to) self.InitializePlayerBounty() if self.allScore: # Do death match scoring GEScenario.OnPlayerKilled(self, victim, killer, weapon) # If someone is killed by the person with the case, they are eliminated. if killer.GetUID == self.CaseOwnerID: GEMPGameRules.LockRound() GEUtil.EmitGameplayEvent("fyeo_eliminated", str(victim.GetUID()), str(killer.GetUID() if killer else ""), "", "", True) if self.eliminationMode: GEUtil.PostDeathMessage(_("#GES_GP_YOLT_ELIMINATED", victim.GetCleanPlayerName())) GEUtil.PopupMessage(victim, "#GES_GPH_ELIMINATED_TITLE", "#GES_GPH_ELIMINATED") GEUtil.PlaySoundToPlayer(killer, "GEGamePlay.Token_Chime") GEUtil.PlaySoundToPlayer(victim, "GEGamePlay.Token_Capture_Enemy") elif not self.pltracker[victim][self.TR.ELIMINATED]: # Don't display message if already revoked GEUtil.PopupMessage(victim, "Not For Your Eyes", "You have been barred from picking up the case") GEUtil.PostDeathMessage("^r%s ^rhas lost their security clearance..." % victim.GetCleanPlayerName()) # Officially eliminate the player self.pltracker[victim][self.TR_ELIMINATED] = True # Initialize the bounty (if we need to) self.InitializePlayerBounty() # Update the bounty self.UpdatePlayerBounty(victim) # Case owner gets an extra point killer.AddRoundScore(1) # Death by world if not killer: if victim.GetUID == self.CaseOwnerID: GEMPGameRules.LockRound() GEUtil.EmitGameplayEvent("fyeo_suicide", str(victim.GetUID()), "", "", "", True) GEUtil.PostDeathMessage("^rThe Briefcase holder committed suicide.") GEUtil.PlaySoundToPlayer(victim, "GEGamePlay.Token_Capture_Enemy") GEUtil.EmitGameplayEvent("fyeo_eliminated", str(victim.GetUID()), str(killer.GetUID if killer else ""), "", "", True) # Eliminate player on suicide if they are the case holder, # unless game is currently "Waiting For Players" if self.eliminationMode: GEUtil.PostDeathMessage(_("#GES_GP_YOLT_ELIMINATED", victim.GetCleanPlayerName())) GEUtil.PopupMessage(victim, "#GES_GPH_ELIMINATED_TITLE", "#GES_GPH_ELIMINATED") elif not self.pltracker[victim][self.TR.ELIMINATED]: # Don't display message if already revoked GEUtil.PopupMessage(victim, "Not For Your Eyes", "You have been barred from picking up the case") GEUtil.PostDeathMessage("^r%s ^rhas lost their security clearance..." % victim.GetCleanPlayerName()) # Officially eliminate the player self.pltracker[victim][self.TR_ELIMINATED] = True # Initialize the bounty (if we need to) self.InitializePlayerBounty() # Update the bounty self.UpdatePlayerBounty(victim) return if victim == killer: # Suicide if not self.allScore: killer.IncrementScore(-1) else: if killer.GetUID == self.CaseOwnerID: # Case holder scores for every kill he or she gets, double if its with the Briefcase if weapon.GetClassname().lower() == "token_deathmatch": killer.IncrementScore(2) # Add an extra point else: # give the case owner extra points for killing killer.IncrementScore(1) # If case holder gets a kill, he/she regains a bar of health (or armor, if health is full). if killer.GetHealth() >= killer.GetMaxHealth(): killer.SetArmor(int(killer.GetArmor() + killer.GetMaxArmor() / 8)) else: killer.SetHealth(int(killer.GetHealth() + killer.GetMaxHealth() / 8)) # If case holder has greater than max health/armor, reset it to max. # (Not sure if this is necessary if max health/armor is set to GEglobal.GE_MAX_HEALTH # and GEGlobal.GE_MAX_ARMOR on spawn, but just in case...) if killer.GetHealth() > killer.GetMaxHealth(): killer.SetHealth(int(killer.GetMaxHealth())) if killer.GetArmor() > killer.GetMaxArmor(): killer.SetArmor(int(killer.GetMaxArmor())) elif victim.GetUID == self.CaseOwnerID: GEUtil.EmitGameplayEvent("fyeo_caseholder_killed", str(victim.GetUID), str(killer.GetUID)) GEUtil.PostDeathMessage("^1"+killer.GetPlayerName()+" ^4killed the Briefcase holder.") GEUtil.PlaySoundToPlayer(victim, "GEGamePlay.Token_Drop_Friend") GEMPGameRules.LockRound() GEUtil.EmitGameplayEvent("fyeo_eliminated", str(victim.GetUserID()), str(killer.GetUserID() if killer else ""), "", "", True) if self.caseEliminate: if self.eliminationMode: GEUtil.PostDeathMessage(_("#GES_GP_YOLT_ELIMINATED", victim.GetCleanPlayerName())) GEUtil.PopupMessage(victim, "#GES_GPH_ELIMINATED_TITLE", "#GES_GPH_ELIMINATED") elif not self.pltracker[victim][self.TR.ELIMINATED]: # Don't display message if already revoked GEUtil.PopupMessage(victim, "Not For Your Eyes", "You have been barred from picking up the case") GEUtil.PostDeathMessage("^r%s ^rhas lost their security clearance..." % victim.GetCleanPlayerName()) # Officially eliminate the player self.pltracker[victim][self.TR_ELIMINATED] = True # Initialize the bounty (if we need to) self.InitializePlayerBounty() # Update the bounty self.UpdatePlayerBounty(victim) def OnThink(self): if GEMPGameRules.GetNumActivePlayers() < 2: GEMPGameRules.UnlockRound() self.waitingForPlayers = True return if self.waitingForPlayers and GEMPGameRules.GetNumActivePlayers() > 1: self.waitingForPlayers = False if not self.warmupTimer.HadWarmup(): self.warmupTimer.StartWarmup(15.0, True) else: GEUtil.HudMessage(None, "#GES_GP_GETREADY", -1, -1, GEUtil.Color(255, 255, 255, 255), 2.5) GEMPGameRules.EndRound(False) if self.warmupTimer.IsInWarmup(): return # Check to see if more than one player is around iPlayers = [] for player in self.pltracker.GetPlayers(): if self.IsInPlay(player): iPlayers.append(player) numPlayers = len(iPlayers) if numPlayers == 0: # This shouldn't happen, but just in case it does we don't want to overflow the vector... GEMPGameRules.EndRound() if numPlayers == 1: # Make last remaining player the winner, and double his or her score. # GEMPGameRules.SetPlayerWinner(iPlayers[0]) # iPlayers[0].IncrementScore(iPlayers[0].GetScore()) GEMPGameRules.EndRound() def CanPlayerRespawn(self, player): if GEMPGameRules.IsRoundLocked(): if self.pltracker[player][self.TR_ELIMINATED] and self.eliminationMode: player.SetScoreBoardColor(GEGlobal.SB_COLOR_ELIMINATED) return False player.SetScoreBoardColor(GEGlobal.SB_COLOR_NORMAL) return True def InitializePlayerBounty(self): if self.dmBounty == 0: deduct = 0 if self.eliminationMode else 1 self.dmBounty = GEMPGameRules.GetNumInRoundPlayers() - deduct GEUtil.InitHudProgressBar(GEGlobal.TEAM_NONE, 0, "#GES_GP_FOES", GEGlobal.HUDPB_SHOWVALUE, self.dmBounty, -1, 0.02, 0, 10, GEUtil.Color(170, 170, 170, 220), self.dmBounty) def UpdatePlayerBounty(self, victim): self.dmBounty -= 1 # Remember, we take 1 off to account for the local player GEUtil.UpdateHudProgressBar(GEGlobal.TEAM_NONE, 0, self.dmBounty) def IsInPlay(self, player): return player.GetTeamNumber() is not GEGlobal.TEAM_SPECTATOR \ and self.pltracker[player][self.TR_SPAWNED] and not self.pltracker[player][self.TR_ELIMINATED] def OnTokenSpawned(self, token): GEMPGameRules.GetRadar().AddRadarContact(token, GEGlobal.RADAR_TYPE_TOKEN, True, "", self.CASE_COLOR) def OnTokenPicked(self, token, player): radar = GEMPGameRules.GetRadar() radar.DropRadarContact(token) radar.AddRadarContact(player, GEGlobal.RADAR_TYPE_PLAYER, True, "", self.CASE_COLOR) GEUtil.PlaySoundToPlayer(player, "GEGamePlay.Token_Grab") GEUtil.PostDeathMessage("^1"+player.GetPlayerName()+" ^ipicked up the Briefcase!") GEUtil.HudMessage(player, "You have the Briefcase!", -1, 0.75, self.CASE_COLOR, 3.0) GEUtil.EmitGameplayEvent("fyeo_case_picked", str(player.GetUserID()), "", "", "", True) player.SetScoreBoardColor(GEGlobal.SB_COLOR_GOLD) self.CaseOwnerID = player.GetUID # Case holder gets full health and armor upon case pickup, and gets slightly increased speed. player.SetHealth(int(GEGlobal.GE_MAX_HEALTH)) player.SetArmor(int(GEGlobal.GE_MAX_ARMOR)) player.SetSpeedMultiplier(1.15) # Explain to player what to do, now that he or she has the case. Will only show on first case pickup. if self.helplist.count(player.GetUID): return GEUtil.PopupMessage(player, "Briefcase", "You have the Briefcase! \nKill other players to eliminate them.") GEUtil.PopupMessage(player, "Scoring", "You score 1 point for every player you eliminate. " "\nIf you win the round, your score will be doubled for the round!") GEUtil.PopupMessage(player, "Buffs", "Upon picking up the Briefcase, you received full health and armor, " "plus increased speed. " "\nFor every player you eliminate, 1 bar of health (or armor, if health is full) " "will be restored.") self.helplist.append(player.GetUID) def OnTokenDropped(self, token, player): radar = GEMPGameRules.GetRadar() radar.DropRadarContact(player) radar.AddRadarContact(token, GEGlobal.RADAR_TYPE_TOKEN, True, "", self.CASE_COLOR) GEUtil.PostDeathMessage("^1"+player.GetCleanPlayerName()+" ^idropped the Briefcase!") player.SetScoreBoardColor(GEGlobal.SB_COLOR_NORMAL) self.CaseOwnerID = None def OnTokenRemoved(self, token): GEMPGameRules.GetRadar().DropRadarContact(token) GEMPGameRules.GetRadar().DropRadarContact(token.GetOwner()) self.CaseOwnerID = None def CanPlayerHaveItem(self, player, item): if self.pltracker[player][self.TR_ELIMINATED]: return not item.GetClassname().lower() == "token_deathmatch" return True
def OnPlayerKilled(self, victim, killer, weapon): bonus = 0 if victim == None: return if killer == None or victim == killer: # If we killed ourselves then our bonus becomes a deduction. bonus = int( self.pltracker[victim][TR_CURINN] / 2 ) * -1 # Still need to calculate bonus instead of dividing directly since we use it later. self.pltracker[victim][TR_CURINN] += bonus elif not killer.IsDead(): bonus = int(self.pltracker[victim][TR_CURINN] / 2) wepname = weapon.GetClassname().lower() #Bonus time for slapper kills, amounting to 75% of victim's time. if wepname == "weapon_slappers" or wepname == "player": bonus = round(bonus * 1.5) # We subtract from the killer's spawn time since inning time is calculated with: curtime - spawntime # and thus curtime - (spawntime - bonus) = curtime - spawntime + bonus = inningtime + bonus self.pltracker[killer][TR_SPNTIME] -= bonus # Also recalculate their current inning time here since they can die before the next server wide calculation. self.pltracker[killer][TR_CURINN] = int( GEUtil.GetTime() - self.pltracker[killer][TR_SPNTIME]) if self.pltracker[victim][TR_CURINN] > self.pltracker[victim][ TR_BESTINN]: # If we beat our best inning that life then we need to update it and our score. victim.SetRoundScore(int(self.pltracker[victim][TR_CURINN])) self.pltracker[victim][TR_BESTINN] = self.pltracker[victim][ TR_CURINN] else: victim.SetRoundScore( int(self.pltracker[victim] [TR_BESTINN])) #Needed in case of suicide. #Get rid of objective icon radar = GERules.GetRadar() radar.DropRadarContact(victim) victim.SetScoreBoardColor(Glb.SB_COLOR_NORMAL) # Killer, Victim, Time Stolen GEUtil.EmitGameplayEvent("vtak_stealtime", str(killer.GetUserID() if killer else -1), str(victim.GetUserID()), str(bonus), "", True) # Convert our bonus time to a string, figure out the approperate color, and which player should receive the time notification. if bonus > 0: bonustag = "+" + self.vtak_SecondsToClockTime(bonus) bonuscolor = GEUtil.Color(0, 255, 50, 255) player = killer else: bonustag = "-" + self.vtak_SecondsToClockTime(bonus * -1) bonuscolor = GEUtil.Color(255, 0, 50, 255) player = victim # Print out how much time we gained/lost GEUtil.HudMessage(player, " " + bonustag, -1, 0.720, bonuscolor, 1.0, 3) self.vtak_UpdateTimer(player, self.pltracker[player][TR_CURINN]) self.vtak_CheckCertainVictory() self.pltracker[victim][ TR_CURINN] *= 0.25 #Victim will respawn with their current time multiplied by this value.
# Pop-A-Cap # v1.0 # By: DarkDiplomat # # Based on the concept of the original Perfect Dark Game Mode # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # from . import GEScenario from .Utils import GetPlayers, clamp from .Utils.GEWarmUp import GEWarmUp from .Utils.GETimer import TimerTracker, Timer import random import GEEntity, GEPlayer, GEUtil, GEWeapon, GEMPGameRules as GERules, GEGlobal as Glb import re VICTIM_ALERT_COLOR = GEUtil.Color(250, 0, 0, 255) SURVIVE_COLOR = GEUtil.Color(0, 150, 0, 200) GET_VICTIM_COLOR = GEUtil.Color(170, 170, 170, 150) CAP_OBJECTIVE = GEUtil.Color(128, 128, 0, 255) USING_API = Glb.API_VERSION_1_2_0 class PopACap(GEScenario): VICTIM = None PRV_VIC1 = None PRV_VIC2 = None PLAYER_WAIT_TICKER = 0 @staticmethod def caplived(timer, type_): if type_ == Timer.UPDATE_FINISH:
def OnPlayerSay(self, player, cmd): assert isinstance(player, GEPlayer.CGEMPPlayer) cmd = cmd.lower() origin = player.GetAbsOrigin() origin[2] += 20.0 if cmd == "ring": GEUtil.CreateTempEnt(TE.RING, origin=origin) elif cmd == "beam": origin = player.GetEyePosition() end = GEUtil.VectorMA(origin, player.GetAimDirection(), 300.0) GEUtil.CreateTempEnt(TE.BEAM, origin=origin, end=end) elif cmd == "follow": GEUtil.CreateTempEnt(TE.BEAM_FOLLOW, origin=origin, entity=player, duration=3.0) elif cmd == "dust": GEUtil.CreateTempEnt(TE.DUST, origin=origin, size=50.0, speed=0.2) elif cmd == "smoke": GEUtil.CreateTempEnt(TE.SMOKE, origin=origin, size=50.0, framerate=2) elif cmd == "spark": origin = GEUtil.VectorMA(origin, player.GetAimDirection(), 150.0) GEUtil.CreateTempEnt(TE.SPARK, origin=origin) elif cmd == "trace": origin = player.GetEyePosition() end = GEUtil.VectorMA(origin, player.GetAimDirection(), 300.0) hit = GEUtil.Trace(origin, end, TraceOpt.PLAYER, player) if hit == None: GEUtil.HudMessage(None, "No hit!", -1, -1) else: player = GEPlayer.ToMPPlayer(hit) GEUtil.HudMessage(None, "Hit: " + hit.GetClassname(), -1, -1, hold_time=10.0, color=Color(255, 255, 0, 255)) GEUtil.HudMessage(None, "Player: " + player.GetPlayerName(), y=0.6, x=-1) elif cmd == "obj": self.obj_blink = not self.obj_blink for pl in GetPlayers(): GERules.GetRadar().SetupObjective(pl, 0, "", pl.GetCleanPlayerName(), Color(120, 120, 0, 255), 0, self.obj_blink) elif cmd == "box": GEUtil.PopupMessage( None, "Default Title", "This is a really long message that should not be " "displayed for more than four lines I don't want to " "keep typing but I will god damnit! I really don't " "like typing so I am eventually going to stop doing " "it but not anytime soon baby cakes!") elif cmd == "sound": GEUtil.PlaySoundFrom(player.GetAbsOrigin(), "@custom/nano-blade-loop.wav", 0.27) elif cmd == Glb.SAY_COMMAND1: if not hasattr(self, "blah"): self.blah = 1 else: self.blah += 1 GEUtil.HudMessage(None, "Test: " + str(self.blah), -1, -1, GEUtil.Color(100, 184, 234), 3.0) elif cmd == "sniper": player.StripAllWeapons() player.GiveNamedWeapon("weapon_slappers", 0) player.GiveNamedWeapon("weapon_knife", 0) player.GiveNamedWeapon("weapon_sniper_rifle", 20) player.WeaponSwitch("weapon_sniper_rifle") else: return False return True
def OnThink(self): # Check to see if we can get out of warm-up if self.waitingForPlayers: if GERules.GetNumActivePlayers() > 1: self.waitingForPlayers = False if not self.warmupTimer.HadWarmup(): self.warmupTimer.StartWarmup(15, True) else: GERules.EndRound(False) elif GEUtil.GetTime() > self.PLAYER_WAIT_TICKER: GEUtil.HudMessage(None, "#GES_GP_WAITING", -1, -1, GEUtil.Color(255, 255, 255, 255), 2.5, 1) self.PLAYER_WAIT_TICKER = GEUtil.GetTime() + 12.5 return if GERules.GetNumActivePlayers() <= 1: self.waitingForPlayers = True if GERules.IsRoundLocked(): for player in GetPlayers(): if not player.IsInRound(): continue if not player.IsDead(): # Only update blood while the player is alive and active blood = self.blood_counter[player.GetUID()] - self.blood_factor # Reduce blood each tick (1 seemed a little fast) self.blood_counter[player.GetUID()] = blood if blood <= 0: # Player has run out of blood player.CommitSuicide(False, False) else: GEUtil.UpdateHudProgressBar(player, 0, blood) if self.max_lives > 0: if GERules.IsTeamplay(): mi6Lives = [] janusLives = [] for uid in self.lives_counter: if self.lives_counter[uid] > 0: player = GEPlayer.ToMPPlayer(uid) if player.GetTeamNumber() == GEGlobal.TEAM_MI6: mi6Lives.append(uid) else: janusLives.append(uid) if len(mi6Lives) > 0 >= len(janusLives): # MI6 Wins GERules.SetTeamWinner(GEGlobal.TEAM_MI6) GERules.EndRound() elif len(mi6Lives) <= 0 < len(janusLives): # Janus Wins GERules.SetTeamWinner(GEGlobal.TEAM_JANUS) GERules.EndRound() elif len(mi6Lives) <= 0 >= len(janusLives): # RIP ALL GERules.EndRound() else: hasLives = [] for uid in self.lives_counter: if self.lives_counter[uid] > 0: hasLives.append(uid) if len(hasLives) == 1: GERules.SetPlayerWinner(GEPlayer.ToMPPlayer(hasLives[0])) GERules.EndRound() elif len(hasLives) < 1: GERules.EndRound()
def __init__(self): super(Uplink, self).__init__() self.warmupTimer = GEWarmUp(self) self.notice_WaitingForPlayers = 0 self.WaitingForPlayers = True self.roundActive = False # >> Uplink data >> self.areaDictionary = { } # Holds each Uplink's data (as a class object) self.fixDictionary = { } # Holds player information before an Uplink is added to self.areaDictionary (e.g. an Uplink spawning on a player) # >> Uplink names >> self.uplinkNames = [] # List of unused Uplink names # >> Uplink variables >> self.pointRadius = 255.0 # Sets radius of each Uplink self.pointSeperation = 5 * self.pointRadius # Sets minimum distance between Uplink points (changes with map size, see OnLoadGamePlay) self.uplinkTimerMax = None # Sets amount of time to make an Uplink (changes depending on teamplay setting) self.uplinkTimerMaxSolo = 145 # Sets amount of time to make an Uplink in free-for-all mode self.uplinkTimerMaxTeam = 165 # Sets amount of time to make an Uplink in teamplay self.pointTimerMax = 150 # Sets amount of time between each point being awarded self.areaTotal = 3 # Sets the number of Uplinks to spawn self.skinNeutral = 0 self.skinJanus = 2 self.skinMI6 = 1 self.uplinkReward = 2 self.uplinkRewardSoloPoints = 3 self.uplinkRewardSoloHP = 0.25 # >> Ping effect variables >> self.pingTimerMax = 12 # Sets how long between each "ping" effect on Uplinks self.pingTimer = self.pingTimerMax + 1 # Keeps track of how long since last "ping" effect on Uplinks # >> Color variables >> self.colorNeutral = GEUtil.CColor(255, 255, 255, 255) self.colorNeutralPing = GEUtil.CColor(255, 255, 255, 100) self.colorMI6 = GEUtil.CColor(0, 150, 255, 255) self.colorMI6Ping = GEUtil.CColor(0, 150, 255, 100) self.colorJanus = GEUtil.CColor(255, 0, 0, 255) self.colorJanusPing = GEUtil.CColor(255, 0, 0, 100) # >> Objective color variables self.colorMI6_Hot = GEUtil.Color(94, 171, 231, 235) self.colorMI6_Cold = GEUtil.Color(94, 171, 231, 120) self.colorJanus_Hot = GEUtil.Color(206, 43, 43, 235) self.colorJanus_Cold = GEUtil.Color(206, 43, 43, 120) self.colorNeutral_Hot = GEUtil.Color(231, 231, 231, 235) self.colorNeutral_Cold = GEUtil.Color(231, 231, 231, 120) # >> Message & Progress Bar colors >> self.colorMsg = GEUtil.CColor(220, 220, 220, 240) self.colorMsgContested = GEUtil.CColor(255, 210, 210, 185) self.colorBarStandard = GEUtil.CColor( 220, 220, 220, 240) # Color of progress bar when player is completing an Uplink # >> Killticker Message colors >> self.colorKilltickerJanus = "^r" self.colorKilltickerMI6 = "^i" self.colorKilltickerDefault = "^1" self.colorKilltickerNoTeam = "^1" # >> Scoreboard color variables >> self.scoreboardDefault = GEGlobal.SB_COLOR_NORMAL self.scoreboardOnPoint = GEGlobal.SB_COLOR_WHITE # >> Round Score Display Colors >> self.colorOwnershipJanus = "^r" # Since Janus' score displays first, we don't add spaces self.colorOwnershipMI6 = "^c" # Since MI6's score displays last, we add spaces... self.colorOwnershipNeutral = " ^w: " # ...same for Neutral score, which is the second to display # >> Message & Progress Bar information >> self.barIndex = 0 self.barTitle = "Uplink" # Displays as the title of the progress bar when a player is capturing an Uplink self.completeMsg = "Uplink Established!" # Displays when a player finishes an Uplink self.ownedMsg = "Your team controls this Uplink" # Displays when a player steps on an Uplink their team already owns self.contestedMsg = "Error: Uplink Blocked!" # Displays when a player is making an Uplink and an opposing player enters the Uplink self.capturedPrintMsg = "^u established an Uplink" # Displays in killticker when team make an Uplink self.capturedPrintMsgAnd = " ^1and " # Displays before final player who helped complete an Uplink self.printMI6 = "MI6" self.printJanus = "Janus" self.helpMsg = "MI6 and Janus fight for control of key military satellites. Capture and control Uplinks while preventing your opponents from doing the same!\n\nEnter an Uplink to initiate capture and earn points. Team-controlled Uplinks generate points over time.\n\nTeamplay: Toggleable\n\nCreated by Euphonic" # >> Uplink Distribution display >> self.distColorJanus = GEUtil.CColor(255, 0, 0, 255) self.distColorMI6 = GEUtil.CColor(0, 0, 255, 255) self.distColorNeutral = GEUtil.CColor(255, 255, 255, 255)
from . import GEScenario from .Utils import _, clamp from .Utils.GEPlayerTracker import GEPlayerTracker from .Utils.GEWarmUp import GEWarmUp from .Utils.GETimer import TimerTracker, Timer import random import GEEntity, GEPlayer, GEUtil, GEWeapon, GEMPGameRules as GERules, GEGlobal as Glb import re USING_API = Glb.API_VERSION_1_2_0 TB_KNOCKEDOUT = "ko" TR_SPAWNED = "spawned" TB_PREV = "tbprev" ALERT_COLOR = GEUtil.Color(255, 80, 80, 255) RELIEF_COLOR = GEUtil.Color(150, 150, 150, 220) SURVIVE_COLOR = GEUtil.Color(0, 190, 0, 220) TIMER_COLOR = GEUtil.Color(200, 200, 200, 255) class Thunderball(GEScenario): PLTRACKER = None # playertracker ASSIGNED_ONCE = False # check that a Thunderball has been assigned at least once CAN_ASSIGN = False # var to set whether we can assign the thunderball TIMER_ADJUST = False # var to set whether the timer needs updated DETONATE_TIME = 15 # time before thunderball detonation KNOCKOUT_TIME = DETONATE_TIME - 5 # amount of time knocked out for TIME_TRACK = DETONATE_TIME # time tracker for HUD messages PLAYER_WAIT_TICKER = 0 # redisplay waiting for players timer TB_CARRIER = None
class CaptureTheKey(GEScenario): # Static Defines (PROBAR_MI6, PROBAR_JANUS, PROBAR_OVERRIDE) = range(1, 4) (MSG_JANUS_CHANNEL, MSG_MI6_CHANNEL, MSG_MISC_CHANNEL) = range(3) MSG_JANUS_YPOS = 0.71 MSG_MI6_YPOS = 0.75 MSG_MISC_YPOS = 0.67 OVERTIME_DELAY = 3.0 CVAR_CAPOVERRIDE = "ctk_capture_override_time" CVAR_CAPPOINTS = "ctk_player_capture_points" CVAR_SPEEDMULT = "ctk_player_speed_mult" CVAR_WARMUP = "ctk_warmup_time" TOKEN_MI6 = 'token_mi6' TOKEN_JANUS = 'token_janus' COLOR_NEUTRAL = GEUtil.Color(220, 220, 220, 255) COLOR_MI6_GLOW = GEUtil.Color(14, 139, 237, 200) COLOR_MI6_RADAR = GEUtil.Color(94, 171, 231, 255) COLOR_MI6_OBJ_COLD = GEUtil.Color(94, 171, 231, 150) COLOR_MI6_OBJ_HOT = GEUtil.Color(94, 171, 231, 235) COLOR_JANUS_GLOW = GEUtil.Color(224, 18, 18, 200) COLOR_JANUS_RADAR = GEUtil.Color(206, 43, 43, 255) COLOR_JANUS_OBJ_COLD = GEUtil.Color(206, 43, 43, 150) COLOR_JANUS_OBJ_HOT = GEUtil.Color(206, 43, 43, 235) (COLOR_RADAR, COLOR_OBJ_COLD, COLOR_OBJ_HOT) = range(3) TAG = "[CTK]" def __init__(self): super(CaptureTheKey, self).__init__() # Create trackers and utilities self.warmupTimer = GEWarmUp(self) self.timerTracker = TimerTracker(self) self.overtime = GEOvertime() # Initialize base elements self.game_tokens = {Glb.TEAM_MI6: Token(), Glb.TEAM_JANUS: Token()} self.game_timers = {} def GetPrintName(self): return "#GES_GP_CAPTUREKEY_NAME" def GetScenarioHelp(self, help_obj): assert isinstance(help_obj, GEScenarioHelp) help_obj.SetInfo("#GES_GPH_CTK_TAGLINE", "http://wiki.geshl2.com/Capture_The_Key") help_obj.SetDescription("#GES_GP_CAPTUREKEY_HELP") pane = help_obj.AddPane("ctk") help_obj.AddHelp(pane, "ctk_objectives", "#GES_GPH_CTK_OBJECTIVES") help_obj.AddHelp(pane, "ctk_radar", "#GES_GPH_CTK_RADAR") def GetGameDescription(self): return "Capture The Key" def GetTeamPlay(self): return Glb.TEAMPLAY_ALWAYS def OnLoadGamePlay(self): # Precache our models GEUtil.PrecacheModel("models/gameplay/capturepoint.mdl") # Ensure our sounds are precached GEUtil.PrecacheSound("GEGamePlay.Overtime") GEUtil.PrecacheSound("GEGamePlay.Token_Grab") GEUtil.PrecacheSound("GEGamePlay.Token_Grab_Enemy") GEUtil.PrecacheSound("GEGamePlay.Token_Capture_Friend") GEUtil.PrecacheSound("GEGamePlay.Token_Capture_Enemy") GEUtil.PrecacheSound("GEGamePlay.Token_Drop_Friend") GEUtil.PrecacheSound("GEGamePlay.Token_Drop_Enemy") # Setup our tokens tokenmgr = GERules.GetTokenMgr() # MI6 Team Token Definition tokenmgr.SetupToken( self.TOKEN_MI6, limit=1, team=Glb.TEAM_MI6, location=Glb.SPAWN_TOKEN | Glb.SPAWN_OTHERTEAM, glow_color=self.COLOR_MI6_GLOW, glow_dist=450.0, allow_switch=False, respawn_delay=20, view_model="models/weapons/tokens/v_briefcasetoken.mdl", world_model="models/weapons/tokens/w_briefcasetoken.mdl", print_name="#GES_GP_CTK_BRIEFCASE") # Janus Team Token Definition tokenmgr.SetupToken(self.TOKEN_JANUS, limit=1, team=Glb.TEAM_JANUS, location=Glb.SPAWN_TOKEN | Glb.SPAWN_OTHERTEAM, glow_color=self.COLOR_JANUS_GLOW, glow_dist=450.0, allow_switch=False, respawn_delay=20, print_name="#GES_GP_CTK_KEY") # Setup the capture areas tokenmgr.SetupCaptureArea("capture_mi6", model="models/gameplay/capturepoint.mdl", skin=1, limit=1, location=Glb.SPAWN_CAPAREA | Glb.SPAWN_MYTEAM, rqd_token=self.TOKEN_MI6, rqd_team=Glb.TEAM_MI6) tokenmgr.SetupCaptureArea("capture_janus", model="models/gameplay/capturepoint.mdl", skin=2, limit=1, location=Glb.SPAWN_CAPAREA | Glb.SPAWN_MYTEAM, rqd_token=self.TOKEN_JANUS, rqd_team=Glb.TEAM_JANUS) # Reset variables self.game_inWaitTime = True self.game_inWarmup = True self.game_inOvertime = False self.game_inOvertimeDelay = False self.game_canFinishRound = True # Clear the timer list self.timerTracker.RemoveTimer() # Create the MI6 delay timer self.game_timers[Glb.TEAM_MI6] = self.timerTracker.CreateTimer( "ctk_mi6") self.game_timers[Glb.TEAM_MI6].SetAgeRate(1.2, 1.5) self.game_timers[Glb.TEAM_MI6].SetUpdateCallback( self.ctk_OnTokenTimerUpdate, 0.1) # Create the Janus delay timer self.game_timers[Glb.TEAM_JANUS] = self.timerTracker.CreateTimer( "ctk_janus") self.game_timers[Glb.TEAM_JANUS].SetAgeRate(1.2, 1.5) self.game_timers[Glb.TEAM_JANUS].SetUpdateCallback( self.ctk_OnTokenTimerUpdate, 0.1) # CVars self.CreateCVar( self.CVAR_CAPOVERRIDE, "5", "Sets the amount of seconds that a player has to stay on a capture point to capture if both tokens are held" ) self.CreateCVar( self.CVAR_CAPPOINTS, "5", "Sets the amount of points a player recieves on token capture") self.CreateCVar( self.CVAR_SPEEDMULT, "1.1", "Speed multiplier for a player holding a token [0.5 - 1.5]") self.CreateCVar( self.CVAR_WARMUP, "20", "Seconds of warmup time before the match begins (set to 0 to disable)" ) self.rules_overrideTime = 5.0 self.rules_playerCapPoints = 5 self.rules_speedMultiplier = 1.1 self.rules_warmupTime = 20 # Make sure we don't start out in wait time if we changed gameplay mid-match if GERules.GetNumActivePlayers() >= 2: self.game_inWaitTime = False GERules.GetRadar().SetForceRadar(True) def OnUnloadGamePlay(self): GEScenario.OnUnloadGamePlay(self) self.game_timers = None self.warmupTimer = None self.timerTracker = None self.overtime = None def OnCVarChanged(self, name, oldvalue, newvalue): if name == self.CVAR_CAPOVERRIDE: overridetime = float(newvalue) self.rules_overrideTime = 0 if overridetime < 0 else overridetime elif name == self.CVAR_CAPPOINTS: points = int(newvalue) self.rules_playerCapPoints = 0 if points < 0 else points elif name == self.CVAR_SPEEDMULT: self.rules_speedMultiplier = float(newvalue) elif name == self.CVAR_WARMUP: self.rules_warmupTime = int(newvalue) if self.warmupTimer.IsInWarmup(): self.warmupTimer.StartWarmup(self.rules_warmupTime) if self.rules_warmupTime <= 0: GERules.EndRound(False) def OnRoundBegin(self): GERules.ResetAllPlayersScores() # This makes sure players get a new set of bars on spawn self.game_inOvertime = False self.game_canFinishRound = True if not self.game_inWaitTime and not self.warmupTimer.HadWarmup(): self.warmupTimer.StartWarmup(self.rules_warmupTime) def CanRoundEnd(self): if self.warmupTimer.IsInWarmup(): return False # See if any tokens are picked, if so we postpone the ending # We can only break overtime if a token is dropped or captured if not self.game_inOvertime and not GERules.IsIntermission(): mi6Score = GERules.GetTeam( Glb.TEAM_MI6).GetRoundScore() + GERules.GetTeam( Glb.TEAM_MI6).GetMatchScore() janusScore = GERules.GetTeam( Glb.TEAM_JANUS).GetRoundScore() + GERules.GetTeam( Glb.TEAM_JANUS).GetMatchScore() # Only go into overtime if our match scores are close and we have a token in hand if abs(mi6Score - janusScore) <= 3 and (self.ctk_IsTokenHeld( Glb.TEAM_MI6) or self.ctk_IsTokenHeld(Glb.TEAM_JANUS)): GEUtil.HudMessage(None, "#GES_GPH_OVERTIME_TITLE", -1, self.MSG_MISC_YPOS, self.COLOR_NEUTRAL, 4.0, self.MSG_MISC_CHANNEL) GEUtil.PopupMessage(None, "#GES_GPH_OVERTIME_TITLE", "#GES_GPH_OVERTIME") GEUtil.EmitGameplayEvent("ctk_overtime") GEUtil.PlaySoundTo(None, "GEGamePlay.Overtime", True) self.game_inOvertime = True self.game_inOvertimeDelay = False self.game_canFinishRound = False # Ensure overtime never lasts longer than 5 minutes self.overtime.StartOvertime(300.0) elif not self.game_inOvertimeDelay and not GERules.IsIntermission(): # Exit overtime if a team is eliminated, awarding the other team a point if GERules.GetNumInRoundTeamPlayers(Glb.TEAM_MI6) == 0: GERules.GetTeam(Glb.TEAM_JANUS).AddRoundScore(1) GEUtil.HudMessage(None, _("#GES_GP_CTK_OVERTIME_SCORE", "Janus"), -1, -1, self.COLOR_NEUTRAL, 5.0) self.timerTracker.OneShotTimer(self.OVERTIME_DELAY, EndRoundCallback) self.game_inOvertimeDelay = True elif GERules.GetNumInRoundTeamPlayers(Glb.TEAM_JANUS) == 0: GERules.GetTeam(Glb.TEAM_MI6).AddRoundScore(1) GEUtil.HudMessage(None, _("#GES_GP_CTK_OVERTIME_SCORE", "MI6"), -1, -1, self.COLOR_NEUTRAL, 5.0) self.timerTracker.OneShotTimer(self.OVERTIME_DELAY, EndRoundCallback) self.game_inOvertimeDelay = True elif not self.overtime.CheckOvertime(): # Overtime failsafe tripped, end the round now return True return self.game_canFinishRound def OnPlayerSpawn(self, player): player.SetSpeedMultiplier(1.0) player.SetScoreBoardColor(Glb.SB_COLOR_NORMAL) def OnThink(self): # Enter "wait time" if we only have 1 player if GERules.GetNumActivePlayers() < 2: # Check overtime fail safe if self.game_inOvertime: self.game_canFinishRound = True # Restart the round and count the scores if we were previously not in wait time if not self.game_inWaitTime: GERules.EndRound() self.warmupTimer.Reset() self.game_inWaitTime = True return # Restart the round (not counting scores) if we were in wait time if self.game_inWaitTime: GEUtil.HudMessage(None, "#GES_GP_GETREADY", -1, -1, GEUtil.CColor(255, 255, 255, 255), 2.5) GERules.EndRound(False) self.game_inWaitTime = False def OnPlayerKilled(self, victim, killer, weapon): assert isinstance(victim, GEPlayer.CGEMPPlayer) assert isinstance(killer, GEPlayer.CGEMPPlayer) # In warmup? No victim? if self.warmupTimer.IsInWarmup() or not victim: return # death by world if not killer: victim.AddRoundScore(-1) return victimTeam = victim.GetTeamNumber() killerTeam = killer.GetTeamNumber() if victim == killer or victimTeam == killerTeam: # Suicide or team kill killer.AddRoundScore(-1) else: # Check to see if this was a kill against a token bearer (defense) if victim == self.game_tokens[victimTeam].GetOwner(): clr_hint = '^i' if killerTeam == Glb.TEAM_MI6 else '^r' GEUtil.EmitGameplayEvent("ctk_tokendefended", str(killer.GetUserID()), str(victim.GetUserID()), str(victimTeam)) GEUtil.PostDeathMessage( _("#GES_GP_CTK_DEFENDED", clr_hint, killer.GetCleanPlayerName(), self.ctk_TokenName(victimTeam))) killer.AddRoundScore(2) else: killer.AddRoundScore(1) def CanPlayerRespawn(self, player): if self.game_inOvertime: GEUtil.PopupMessage(player, "#GES_GPH_ELIMINATED_TITLE", "#GES_GPH_ELIMINATED") player.SetScoreBoardColor(Glb.SB_COLOR_ELIMINATED) return False return True def OnCaptureAreaSpawned(self, area): team = area.GetTeamNumber() tknName = self.TOKEN_MI6 if team == Glb.TEAM_MI6 else self.TOKEN_JANUS GERules.GetRadar().AddRadarContact(area, Glb.RADAR_TYPE_OBJECTIVE, True, "sprites/hud/radar/capture_point", self.ctk_GetColor(team)) GERules.GetRadar().SetupObjective( area, team, tknName, "#GES_GP_CTK_OBJ_CAPTURE", self.ctk_GetColor(team, self.COLOR_OBJ_HOT), 0, True) def OnCaptureAreaRemoved(self, area): GERules.GetRadar().DropRadarContact(area) def OnCaptureAreaEntered(self, area, player, token): assert isinstance(area, GEEntity.CBaseEntity) assert isinstance(player, GEPlayer.CGEMPPlayer) assert isinstance(token, GEWeapon.CGEWeapon) if token is None: return # We don't delay capture in overtime if self.game_inOvertime: self.ctk_CaptureToken(token, player) return # If the other team has our token, we have to wait a set period tokenteam = token.GetTeamNumber() otherteam = OppositeTeam(player.GetTeamNumber()) if self.ctk_IsTokenHeld(otherteam): timer = self.game_timers[tokenteam] if timer.state is Timer.STATE_STOP: GEUtil.InitHudProgressBar(player, self.PROBAR_OVERRIDE, "#GES_GP_CTK_CAPTURE_OVR", Glb.HUDPB_SHOWBAR, self.rules_overrideTime, -1, 0.6, 120, 16, GEUtil.CColor(220, 220, 220, 240)) timer.Start(self.rules_overrideTime) else: self.ctk_CaptureToken(token, player) def OnCaptureAreaExited(self, area, player): assert isinstance(area, GEEntity.CBaseEntity) assert isinstance(player, GEPlayer.CGEMPPlayer) tokenteam = player.GetTeamNumber() self.game_timers[tokenteam].Pause() def OnTokenSpawned(self, token): tokenTeam = token.GetTeamNumber() GERules.GetRadar().AddRadarContact(token, Glb.RADAR_TYPE_TOKEN, True, "", self.ctk_GetColor(tokenTeam)) GERules.GetRadar().SetupObjective( token, Glb.TEAM_NONE, "", self.ctk_TokenName(tokenTeam), self.ctk_GetColor(tokenTeam, self.COLOR_OBJ_COLD)) self.game_tokens[tokenTeam].SetTokenEnt(token) def OnTokenPicked(self, token, player): tokenTeam = token.GetTeamNumber() otherTeam = OppositeTeam(tokenTeam) self.game_tokens[tokenTeam].next_drop_time = GEUtil.GetTime() + 10.0 GERules.GetRadar().DropRadarContact(token) GERules.GetRadar().AddRadarContact( player, Glb.RADAR_TYPE_PLAYER, True, "sprites/hud/radar/run", self.ctk_GetColor(player.GetTeamNumber())) GERules.GetRadar().SetupObjective( player, Glb.TEAM_NONE, "", self.ctk_TokenName(tokenTeam), self.ctk_GetColor(tokenTeam, self.COLOR_OBJ_HOT)) GEUtil.EmitGameplayEvent("ctk_tokenpicked", str(player.GetUserID()), str(tokenTeam)) # Token bearers move faster player.SetSpeedMultiplier(self.rules_speedMultiplier) player.SetScoreBoardColor(Glb.SB_COLOR_WHITE) msgFriend = _("#GES_GP_CTK_PICKED_FRIEND", player.GetCleanPlayerName(), self.ctk_TokenName(tokenTeam)) msgEnemy = _("#GES_GP_CTK_PICKED_FOE", player.GetCleanPlayerName(), self.ctk_TokenName(tokenTeam)) self.ctk_PostMessage(msgFriend, tokenTeam, tokenTeam) self.ctk_PostMessage(msgEnemy, otherTeam, tokenTeam) GEUtil.PlaySoundTo(tokenTeam, "GEGamePlay.Token_Grab", False) GEUtil.PlaySoundTo(otherTeam, "GEGamePlay.Token_Grab_Enemy", False) def OnTokenDropped(self, token, player): tokenTeam = token.GetTeamNumber() otherTeam = OppositeTeam(tokenTeam) # Stop the override timer and force remove just in case self.game_timers[tokenTeam].Stop() GEUtil.RemoveHudProgressBar(player, self.PROBAR_OVERRIDE) GEUtil.EmitGameplayEvent("ctk_tokendropped", str(player.GetUserID()), str(tokenTeam)) GERules.GetRadar().AddRadarContact(token, Glb.RADAR_TYPE_TOKEN, True, "", self.ctk_GetColor(tokenTeam)) GERules.GetRadar().SetupObjective( token, Glb.TEAM_NONE, "", self.ctk_TokenName(tokenTeam), self.ctk_GetColor(tokenTeam, self.COLOR_OBJ_COLD)) GERules.GetRadar().DropRadarContact(player) GERules.GetRadar().ClearObjective(player) player.SetSpeedMultiplier(1.0) player.SetScoreBoardColor(Glb.SB_COLOR_NORMAL) msg = _("#GES_GP_CTK_DROPPED", player.GetCleanPlayerName(), self.ctk_TokenName(tokenTeam)) self.ctk_PostMessage(msg, tokenTeam, tokenTeam) self.ctk_PostMessage(msg, otherTeam, tokenTeam) GEUtil.PlaySoundTo(tokenTeam, "GEGamePlay.Token_Drop_Friend", True) GEUtil.PlaySoundTo(otherTeam, "GEGamePlay.Token_Drop_Enemy", True) def OnTokenRemoved(self, token): tokenTeam = token.GetTeamNumber() GERules.GetRadar().DropRadarContact(token) self.game_tokens[tokenTeam].SetTokenEnt(None) def OnPlayerSay(self, player, text): team = player.GetTeamNumber() # If the player issues !voodoo they will drop their token if text.lower() == Glb.SAY_COMMAND1 and team != Glb.TEAM_SPECTATOR: tokendef = self.game_tokens[team] if player == tokendef.GetOwner(): if GEUtil.GetTime() >= tokendef.next_drop_time: GERules.GetTokenMgr().TransferToken( tokendef.GetTokenEnt(), None) else: timeleft = max( 1, int(tokendef.next_drop_time - GEUtil.GetTime())) GEUtil.HudMessage(player, _("#GES_GP_CTK_TOKEN_DROP", timeleft), -1, self.MSG_MISC_YPOS, self.COLOR_NEUTRAL, 2.0, self.MSG_MISC_CHANNEL) return True return False #-------------------# # Utility Functions # #-------------------# def ctk_GetColor(self, team, color_type=0): if team == Glb.TEAM_JANUS: if color_type == CaptureTheKey.COLOR_RADAR: return self.COLOR_JANUS_RADAR elif color_type == CaptureTheKey.COLOR_OBJ_COLD: return self.COLOR_JANUS_OBJ_COLD else: return self.COLOR_JANUS_OBJ_HOT elif team == Glb.TEAM_MI6: if color_type == CaptureTheKey.COLOR_RADAR: return self.COLOR_MI6_RADAR elif color_type == CaptureTheKey.COLOR_OBJ_COLD: return self.COLOR_MI6_OBJ_COLD else: return self.COLOR_MI6_OBJ_HOT else: return self.COLOR_NEUTRAL def ctk_CaptureToken(self, token, holder): assert isinstance(token, GEWeapon.CGEWeapon) assert isinstance(holder, GEPlayer.CGEMPPlayer) tokenTeam = token.GetTeamNumber() otherTeam = OppositeTeam(tokenTeam) GERules.GetRadar().DropRadarContact(token) GERules.GetRadar().DropRadarContact(holder) holder.SetSpeedMultiplier(1.0) holder.SetScoreBoardColor(Glb.SB_COLOR_NORMAL) # Check overtime requirements if self.game_inOvertime: if not self.game_inOvertimeDelay: self.game_inOvertimeDelay = True self.timerTracker.OneShotTimer(self.OVERTIME_DELAY, EndRoundCallback) else: # We already scored in overtime, ignore this return # Capture the token and give the capturing team points GERules.GetTokenMgr().CaptureToken(token) # Make sure our timer goes away self.game_timers[tokenTeam].Stop() GEUtil.RemoveHudProgressBar(holder, self.PROBAR_OVERRIDE) # Give points if not in warmup if not self.warmupTimer.IsInWarmup(): GERules.GetTeam(tokenTeam).AddRoundScore(1) holder.AddRoundScore(self.rules_playerCapPoints) GEUtil.EmitGameplayEvent("ctk_tokencapture", str(holder.GetUserID()), str(tokenTeam)) GEUtil.PlaySoundTo(tokenTeam, "GEGamePlay.Token_Capture_Friend", True) GEUtil.PlaySoundTo(otherTeam, "GEGamePlay.Token_Capture_Enemy", True) msg = _("#GES_GP_CTK_CAPTURE", holder.GetCleanPlayerName(), self.ctk_TokenName(tokenTeam)) self.ctk_PostMessage(msg) GEUtil.PostDeathMessage(msg) def ctk_OnTokenTimerUpdate(self, timer, update_type): assert isinstance(timer, Timer) tokenTeam = Glb.TEAM_MI6 if (timer.GetName() == "ctk_mi6") else Glb.TEAM_JANUS otherTeam = OppositeTeam(tokenTeam) time = timer.GetCurrentTime() holder = self.game_tokens[tokenTeam].GetOwner() if holder is not None: if update_type == Timer.UPDATE_FINISH: token = self.game_tokens[tokenTeam].GetTokenEnt() if token is not None: self.ctk_CaptureToken(token, holder) elif update_type == Timer.UPDATE_STOP: GEUtil.RemoveHudProgressBar(holder, self.PROBAR_OVERRIDE) elif update_type == Timer.UPDATE_RUN: GEUtil.UpdateHudProgressBar(holder, self.PROBAR_OVERRIDE, time) # Check to see if the other team dropped their token mid-capture if not self.ctk_IsTokenHeld(otherTeam): timer.Finish() def ctk_IsTokenHeld(self, team): return self.game_tokens[team].GetOwner() != None def ctk_PostMessage(self, msg, to_team=Glb.TEAM_NONE, from_team=Glb.TEAM_NONE): if from_team == Glb.TEAM_JANUS: channel = self.MSG_JANUS_CHANNEL ypos = self.MSG_JANUS_YPOS elif from_team == Glb.TEAM_MI6: channel = self.MSG_MI6_CHANNEL ypos = self.MSG_MI6_YPOS else: channel = self.MSG_MISC_CHANNEL ypos = self.MSG_MISC_YPOS if to_team == Glb.TEAM_NONE: GEUtil.HudMessage(None, msg, -1, ypos, self.ctk_GetColor(from_team), 5.0, channel) else: GEUtil.HudMessage(to_team, msg, -1, ypos, self.ctk_GetColor(from_team), 5.0, channel) def ctk_TokenName(self, team): return "#GES_GP_CTK_OBJ_JANUS" if team == Glb.TEAM_MI6 else "#GES_GP_CTK_OBJ_MI6"