def OnUnloadGamePlay(self):
		GEUtil.HudMessage( None, "", -1, 0.0, GEUtil.CColor(255,255,255,255), 0, self.scoreDisplayChannel )
		GEUtil.HudMessage( None, "", -1, 0.0, GEUtil.CColor(255,255,255,255), 0, self.skipMSgChannel )
		GEUtil.HudMessage( None, "", -1, 0.0, GEUtil.CColor(255,255,255,255), 0, self.weaponMsgChannel )
		GEUtil.RemoveHudProgressBar(None, self.timerBarIndex)
		GEUtil.RemoveHudProgressBar(None, self.skipTextIndex)
		self.setDamageMultiplier( 1 )
Exemplo n.º 2
0
    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

        # 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) and self.rules_overrideTime >= 0:
            if self.rules_overrideTime > 0 and not self.game_inOvertime:  # Can't capture if other team has your token in overtime.
                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:
                GEUtil.HudMessage(player, "#GES_GP_CTK_CAPTURE_DENY", -1, 0.6,
                                  GEUtil.CColor(220, 220, 220, 240), 2.0,
                                  self.MSG_MISC_CHANNEL)
        else:
            self.ctk_CaptureToken(token, player)
	def __init__( self ):
		super( HoldTheBriefcase, self ).__init__()
		
		self.warmupTimer = GEWarmUp( self )
		self.notice_WaitingForPlayers = 0
		self.WaitingForPlayers = True

		self.teamScoringTimer = 100
		self.TokenClass = "token_deathmatch"
		
		self.RoundActive = False
		
		self.caseDict = {}
		
		self.prevCount = 0
		self.nextCheckTime = -1
		
		self.roundScoreJanus = 0
		self.roundScoreMI6 = 0
		
#		>> Colors >>
		self.colorMsg = GEUtil.CColor(255,255,255,240)
		self.colorCase = GEUtil.CColor(230,230,230,240)
		self.colorMI6 = GEUtil.CColor(0,150,255,255)
		self.colorJanus = GEUtil.CColor(255,0,0,255)
		self.scoreboardDefault = GEGlobal.SB_COLOR_NORMAL
		self.scoreboardOwner = GEGlobal.SB_COLOR_WHITE
		
#		>> Messages & Text
		self.caseName = "Briefcase"
		self.dropText = " ^1dropped a ^u" + self.caseName
		self.grabText = " ^1picked up a ^u" + self.caseName
		self.pickText = "Picked up a " + self.caseName
Exemplo n.º 4
0
    def SetupObjective(self,
                       entity,
                       team_filter=GEGlobal.TEAM_NONE,
                       token_filter="",
                       text="",
                       color=GEUtil.CColor(),
                       min_dist=0,
                       pulse=False):
        '''
        Setup an on-screen objective icon. RADAR_TYPE_OBJECTIVE or RADAR_TYPE_TOKEN
        automatically become objectives, you can override the defaults with this
        function. Use the team_filter to restrict the icon by team number. Use
        token_filter to restrict the icon to those who hold the named token, put
        a ! in front of the name for the inverse. Text displays above the icon. Set
        min_dist to have icons fade out when the player is within this distance to
        the objective. Pulse causes the icon to pulse, useful to attract attention.
        
        entity -- Entity to make an objective

        Keyword Arguments:
          team_filter -- Team ID that can see this objective
          token_filter -- Token classname that a player must hold to see this objective
          text -- Text to display above the icon
          color -- Color of the icon
          min_dist -- Minimum viewable distance, useful to prevent griefing
          pulse -- Cause the icon to slowly pulse
        '''
        return
Exemplo n.º 5
0
    def CanPlayerChangeTeam(self, player, oldteam, newteam, wasforced):
        # The hacker cannot change teams
        if player.GetUID() == self.hacker_playerUID:
            GEUtil.HudMessage(player, "You cannot change teams as the hacker!", -1, -1,
                              GEUtil.CColor(255, 255, 255, 255), 3.0)
            return False

        return True
Exemplo n.º 6
0
 def lc_CreateHackingTool(self):
     mgr = GERules.GetTokenMgr()
     mgr.SetupToken(self.TOOL_CLASSNAME,
                    limit=1,
                    location=Glb.SPAWN_AMMO,
                    allow_switch=True,
                    glow_color=GEUtil.CColor(80, 80, 80, 255),
                    glow_dist=500.0)
Exemplo n.º 7
0
    def __init__(self):
        super(LivingDaylights, self).__init__()
        self.TokenClass = 'token_deathmatch'
        self.TokenGlow = GEUtil.CColor(244, 192, 11, 64)

        self.MI6Flags = 0
        self.JanusFlags = 0
        self.FlagCount = 0
        self.ShowMI6Flags = True
        self.ShowJanusFlags = True
Exemplo n.º 8
0
 def OnTokenSpawned(self, token):
     self.ft_registerflag(GEEntity.GetUID(token))
     GEMPGameRules.GetRadar().AddRadarContact(token,
                                              GEGlobal.RADAR_TYPE_TOKEN,
                                              True, "", self.COLOR_COLD)
     GEMPGameRules.GetRadar().SetupObjective(
         token, GEGlobal.TEAM_NONE, "!%s" % self.TokenClass,
         "#GES_GP_LD_OBJ_TAKE", GEUtil.CColor(220, 220, 220, 200))
     token.SetSkin(0)
     self.ft_teambalancebars()
     self.ft_showteamflags()
	def __init__(self):
		super(CasinoRoyaleLTK, self).__init__()
		
		weaponListLTK = [ Weapon("pp7", "PP7s", 50), Weapon("pp7_silenced", "Silenced PP7s", 50), Weapon("dd44", "DD44s", 50), Weapon("sniper_rifle", "Sniper Rifles", 75), Weapon("silver_pp7", "Silver PP7s", 25), Weapon("golden_pp7", "Golden PP7s", 10), Weapon("cmag", "Cougar Magnums", 25), Weapon("golden_gun", "Golden Guns", 10), Weapon("klobb", "Klobbs", 50), Weapon("shotgun", "Shotguns", 20), Weapon("grenade", "Grenades", 3), Weapon("knife_throwing", "Throwing Knives", 5), Weapon("moonraker", "Moonraker Lasers", 0), Weapon("knife", "Hunting Knives", 0) ]
		
		self.weaponList = [weaponListLTK]
	
		# Defines new variable that will track the current weapon, when created it's outside of the weaponlist length
		self.weaponIndex = [-1, -1]
		# Length of each weapon round
		self.timerMax = 40 * 10
		# Current weapon timer
		self.weaponTimer = self.timerMax
		# Creates player tracker
		self.playerTracker = GEPlayerTracker( self )
		# Defines a toggle that says if round is active or not
		self.isRoundActive = False
		# Next two keep track of how many kills that team has had during the current weapon round
		self.roundScoreJanus = 0
		self.roundScoreMI6 = 0
		
		self.skipTextColor = GEUtil.CColor(232,180,2,240)
		self.skipTextFadedColor = GEUtil.CColor(232,180,2,10)
		self.timerBarColor = GEUtil.CColor(220,220,220,240)
		
		self.skipMsgColor = GEUtil.CColor(232,180,2,230)
		self.weaponMsgColor = GEUtil.CColor(220,220,220,240)
		
		self.timerBarIndex = 0
		self.skipTextIndex = 1
		
		self.scoreDisplayChannel = 0
		self.skipMSgChannel = 1
		self.weaponMsgChannel = 2
		
		self.skipTextYPos = 0.67
		self.weaponMsgYPos = 0.71
		
		self.winMsgJanus = "^rJanus ^1scored the most kills and ^ugot a point"
		self.winMsgMI6 = "^iMI6 ^1scored the most kills and ^ugot a point"
		self.winMsgTie = "^1Tie score! Both teams ^ugot a point"
Exemplo n.º 10
0
    def OnCaptureAreaEntered(self, area, player, token):
        aUID = area.GetUID()
        if aUID not in self.game_terminals or self.game_terminals[aUID]["hacked"]:
            return

        if player.GetUID() == self.hacker_playerUID:
            time_hack = float(GEUtil.GetCVarValue("lc_hacktime"))
            if self.timer_hacking.state is Timer.STATE_STOP or self.game_lastTerminalUID != area.GetUID():
                GEUtil.InitHudProgressBar(None, 1, "Hack Progress:", 1, time_hack, -1, 0.75, 120, 15,
                                          GEUtil.CColor(220, 220, 220, 240))

            self.game_lastTerminalUID = aUID
            self.game_currTerminalUID = aUID
            self.timer_hacking.Start(time_hack)
Exemplo n.º 11
0
    def OnCaptureAreaEntered(self, area, player, token):
        aUID = area.GetUID()
        if not self.game_terminals.has_key(
                aUID) or self.game_terminals[aUID]["hacked"]:
            return

        if player.GetUID() == self.hacker_playerUID:
            if self.timer_hacking.state is Timer.STATE_STOP or self.game_lastTerminalUID != area.GetUID(
            ):
                GEUtil.InitHudProgressBar(None, 1, "Hack Progress:", 1, 10.0,
                                          -1, 0.75, 120, 15,
                                          GEUtil.CColor(220, 220, 220, 240))

            self.game_lastTerminalUID = aUID
            self.game_currTerminalUID = aUID
            self.timer_hacking.Start(10.0)
Exemplo n.º 12
0
    def OnTokenDropped(self, token, player):
        player.SetScoreBoardColor(GEGlobal.SB_COLOR_NORMAL)
        if self.ft_flagdebt() >= 0:
            GEMPGameRules.GetRadar().AddRadarContact(token,
                                                     GEGlobal.RADAR_TYPE_TOKEN,
                                                     True, "", self.COLOR_WARM)
            GEMPGameRules.GetRadar().SetupObjective(
                token, GEGlobal.TEAM_NONE, "!%s" % self.TokenClass,
                "#GES_GP_LD_OBJ_TAKE", GEUtil.CColor(220, 220, 220, 200))
            GEMPGameRules.GetRadar().DropRadarContact(player)
            self.ft_disassociate(token, False)
        else:
            GEMPGameRules.GetTokenMgr().RemoveTokenEnt(token)

        self.ft_teambalancebars()
        self.ft_showteamflags()
        token.SetSkin(0)
Exemplo n.º 13
0
    def lc_EnrobeHacker(self, uid):
        player = getPlayerFromUID(uid)
        if player is not None:
            model = self.MI6_HACKER_COSTUME
            if player.GetTeamNumber() == Glb.TEAM_JANUS:
                model = self.JANUS_HACKER_COSTUME

            # Store away his old costume and set him as the hacker
            self.hacker_oldCostume = player.GetPlayerModel()
            self.hacker_oldSkin = player.GetSkin()
            player.SetPlayerModel(model, 0)
            # Add me to the radar as always visible
            GERules.GetRadar().AddRadarContact(
                player, Glb.RADAR_TYPE_PLAYER, True, "sprites/hud/radar/run",
                GEUtil.CColor(255, 180, 225, 170))
            # Reset notices
            self.hacker_notice = 0
            self.hacker_playerUID = uid
Exemplo n.º 14
0
    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
Exemplo n.º 15
0
    def OnThink(self):
        # Enter "wait time" if we only have 1 player
        if GERules.GetNumActivePlayers() < 2 and self.warmupTimer.HadWarmup():
            # 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.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
Exemplo n.º 16
0
    def OnCVarChanged(self, name, oldvalue, newvalue):
        if name == "cr_timer":
            GEUtil.RemoveHudProgressBar(None, self.timerBarIndex)
            self.timerMax = float(newvalue) * 10
            if self.weaponTimer >= float(newvalue):
                self.weaponTimer = float(newvalue)
            self.showTimerBar(None)

        if name == "cr_teamscoring" and GEMPGameRules.IsTeamplay():
            if int(newvalue) == 0 and int(oldvalue) == 1:
                GEMPGameRules.ResetAllTeamsScores()
                self.resetRoundScore()
                GEMPGameRules.EndRound(False)
                GEUtil.HudMessage(None, "", 0.0, 0.0,
                                  GEUtil.CColor(255, 255, 255, 255), 0,
                                  self.scoreDisplayChannel)
            elif float(newvalue) == 1 and float(oldvalue) == 0:
                GEMPGameRules.ResetAllTeamsScores()
                self.resetRoundScore()
                GEMPGameRules.EndRound(False)
                self.showRoundScore(None)

        elif name == "cr_skip":
            if int(GEUtil.GetCVarValue("cr_skip")) == 0:
                for i in range(32):
                    if not GEPlayer.IsValidPlayerIndex(i):
                        continue
                    player = GEPlayer.GetMPPlayer(i)
                    GEUtil.RemoveHudProgressBar(player, self.skipTextIndex)
            else:
                for i in range(32):
                    if not GEPlayer.IsValidPlayerIndex(i):
                        continue
                    player = GEPlayer.GetMPPlayer(i)
                    self.playerTracker.SetValue(player, self.USED_SKIP, False)
                    self.showSkipText(player)

        elif name == "ge_teamplay" and newvalue == 0:
            self.hideRoundScore(None)
Exemplo n.º 17
0
 def showRoundScore(self, target):
     GEUtil.HudMessage(
         target, "^r" + str(self.roundScoreJanus) +
         "    ^w:    ^c" + str(self.roundScoreMI6), -1, 0.0,
         GEUtil.CColor(255, 255, 255,
                       255), float('inf'), self.scoreDisplayChannel)
Exemplo n.º 18
0
 def lc_CreateHackingTool(self):
     # Only create the hacking tool if allowed
     if GEUtil.GetCVarValue("lc_hackertool") == 1:
         mgr = GERules.GetTokenMgr()
         mgr.SetupToken(self.TOOL_CLASSNAME, limit=1, location=Glb.SPAWN_AMMO,
                    allow_switch=True, glow_color=GEUtil.CColor(80, 80, 80, 255), glow_dist=500.0)
Exemplo n.º 19
0
class LaunchCode(GEScenario):
    # ------------------ #
    #  GLOBAL CONSTANTS  #
    # ------------------ #
    JANUS_HACKER_COSTUME = "boris"
    MI6_HACKER_COSTUME = "female_scientist"

    MIN_PLAYERS = 2
    LOW_PLAYER_NOTICE_INTERVAL = 10.0

    TOOL_CLASSNAME = "token_custom1"
    TOOL_WMODEL = "models/weapons/tokens/w_keytoken.mdl"
    TOOL_VMODEL = "models/weapons/tokens/v_keytoken.mdl"

    COLOR_INFO = GEUtil.CColor(240, 200, 120, 170)
    COLOR_NOTICE = GEUtil.CColor(240, 200, 120, 170)
    COLOR_RADAR_MI6 = GEUtil.CColor(94, 171, 231, 255)
    COLOR_RADAR_JANUS = GEUtil.CColor(206, 43, 43, 255)

    TAG = "[LaunchCode]"

    DEFAULT_PARAMS = {
        # Hacker Variables
        "hacker_notice": 0,
        "hacker_playerUID": None,
        "hacker_oldCostume": "",
        "hacker_oldSkin": 0,
        "hacker_switched": False,
        "hacker_hasTool": False,
        "hacker_hasWeapon": False,

        # Game Variables
        "game_startTime": GEUtil.GetTime(),
        "game_hackersWin": False,
        "game_tool": None,
        "game_lastTerminalUID": None,
        "game_currTerminalUID": None,
    }

    # ---------------- #
    #  CORE FUNCTIONS  #
    # ---------------- #

    def __init__(self):
        super(LaunchCode, self).__init__()
        self.warmUpTimer = GEWarmUp(self)
        self.timerTracker = TimerTracker(self)
        self.__debug = False
        # Defining some vars
        self.game_terminals = {}
        self.team_hacker = None
        self.team_preventor = None
        self.timer_endRound = None
        self.timer_hacking = None
        self.game_roundCount = 0
        self.hacker_hasWeapon = False
        self.hacker_canArm = True
        self.game_lastTerminalUID = None
        self.game_currTerminalUID = None
        self.hacker_hasTool = False
        self.game_lowPlayers = True
        self.game_lowPlayersNotice = 0
        self.game_terminal_model = "models/props/bunker/oldlaptop.mdl"

        # Hacker Variables
        self.hacker_notice = 0
        self.hacker_playerUID = None
        self.hacker_oldCostume = ""
        self.hacker_oldSkin = 0
        self.hacker_switched = False
        self.hacker_hasTool = False
        self.hacker_hasWeapon = False

        # Game Variables
        self.game_startTime = GEUtil.GetTime()
        self.game_hackersWin = False
        self.game_lastTerminalUID = None
        self.game_currTerminalUID = None
        self.game_tool = None

    def Cleanup(self):
        super(LaunchCode, self).Cleanup()
        self.timer_endRound = None
        self.timer_hacking = None
        self.warmUpTimer = None
        self.timerTracker = None

    def GetPrintName(self):
        return "Launch Code"

    def GetScenarioHelp(self, help_obj):
        pass

    def GetGameDescription(self):
        return "Launch Code"

    def GetTeamPlay(self):
        return Glb.TEAMPLAY_ALWAYS

    def OnLoadGamePlay(self):
        # Precache our custom items
        GEUtil.PrecacheModel(self.game_terminal_model)

        # Clear the timer list
        self.timerTracker.RemoveTimer()

        # Create the hacking timer
        self.timer_hacking = self.timerTracker.CreateTimer("hack")
        self.timer_hacking.SetAgeRate(0.75, 2.0)
        self.timer_hacking.SetUpdateCallback(self.lc_OnHackTimer)
        # Delay of End Round timer
        self.timer_endRound = self.timerTracker.CreateTimer("endround")
        self.timer_endRound.SetUpdateCallback(self.lc_OnEndRoundTimer)

        # Setup all our vars
        self.lc_InitRound()

        # Reset the some vars
        self.game_terminals = {}
        self.team_hacker = None
        self.team_preventor = None
        self.game_roundCount = 0

        # Enable team spawns
        GERules.SetAllowTeamSpawns(True)

        # Exclude hacker costumes
        GERules.SetExcludedCharacters("female_scientist, boris")

        GERules.GetTokenMgr().SetupCaptureArea("terminals", model=self.game_terminal_model,
                                                                limit=4, radius=32, location=Glb.SPAWN_PLAYER)

        self.CreateCVar("lc_warmup", "30", "Warmup time before the match begins")
        self.CreateCVar("lc_hackerboost", "0", "Allow the hacker to gain an ego-boost")
        self.CreateCVar("lc_hackertool", "1", "Allow the Insta-Hack tool")
        self.CreateCVar("lc_hacktime", "15", "Base number of seconds to hack a terminal")
        self.CreateCVar("lc_hackerdefense", "1", "Allows the hacker to have a DD44 to protect themselves")
        self.CreateCVar("lc_debug", "0", "Enabled/Disables debugging prompts")

    def OnRoundBegin(self):
        self.__debug = GEUtil.GetCVarValue("lc_debug") == 1
        if self.__debug:
            GEUtil.ClientPrint(None, Glb.HUD_PRINTTALK, self.TAG + "Debugging Enabled")
        else:
            GEUtil.ClientPrint(None, Glb.HUD_PRINTTALK, self.TAG + "Debugging Disabled")

        GERules.GetRadar().SetForceRadar(True)
        GERules.ResetAllPlayersScores()
        self.hacker_canArm = GEUtil.GetCVarValue("lc_hackerdefense") == 1
        self.game_roundCount += 1

        self.lc_DerobeHacker()
        self.lc_InitRound()
        self.lc_ChooseHacker()
        self.lc_CreateHackingTool()

    def OnRoundEnd(self):
        GERules.GetRadar().DropAllContacts()

        if self.lc_HavePlayers() and not self.game_hackersWin:
            pTeam = GERules.GetTeam(self.team_preventor)
            GERules.SetTeamWinner(pTeam)
            for t in self.game_terminals.values():
                if not t["hacked"]:
                    pTeam.IncrementRoundScore(1)

    def OnPlayerSpawn(self, player):
        # Properly arm the hacker
        if self.hacker_playerUID == player.GetUID():
            if self.hacker_canArm:
                self.lc_ArmHacker(player)  # Give the hacker back their weapon on respawn
            if self.hacker_notice < 3:
                self.hacker_notice += 1
                GEUtil.HudMessage(player, "You are the hacker, hack the terminals by standing next to them", -1, -1,
                                  self.COLOR_NOTICE, 5.0, 2)

    def OnPlayerKilled(self, victim, killer, weapon):
        if victim is None:
            return

        if victim.GetUID() == self.hacker_playerUID:
            self.hacker_hasWeapon = False
            if self.team_preventor:
                GERules.GetTeam(self.team_preventor).IncrementRoundScore(1)

        if killer and victim != killer:
            killer.IncrementScore(1)
        else:
            victim.IncrementScore(-1)

    def OnCaptureAreaSpawned(self, area):
        aUID = area.GetUID()
        self.game_terminals[aUID] = {"hacked": False}

        GERules.GetRadar().AddRadarContact(area, Glb.RADAR_TYPE_TOKEN, True, "sprites/hud/radar/capture_point",
                                           self.lc_GetHackerTeamColor())

    def OnCaptureAreaRemoved(self, area):
        aUID = area.GetUID()
        if aUID in self.game_terminals:
            del self.game_terminals[aUID]

        GERules.GetRadar().DropRadarContact(area)

    def OnCaptureAreaEntered(self, area, player, token):
        aUID = area.GetUID()
        if aUID not in self.game_terminals or self.game_terminals[aUID]["hacked"]:
            return

        if player.GetUID() == self.hacker_playerUID:
            time_hack = float(GEUtil.GetCVarValue("lc_hacktime"))
            if self.timer_hacking.state is Timer.STATE_STOP or self.game_lastTerminalUID != area.GetUID():
                GEUtil.InitHudProgressBar(None, 1, "Hack Progress:", 1, time_hack, -1, 0.75, 120, 15,
                                          GEUtil.CColor(220, 220, 220, 240))

            self.game_lastTerminalUID = aUID
            self.game_currTerminalUID = aUID
            self.timer_hacking.Start(time_hack)

    def OnCaptureAreaExited(self, area, player):
        if player.GetUID() == self.hacker_playerUID:
            self.timer_hacking.Pause()
            self.game_currTerminalUID = None

    def CanPlayerChangeChar(self, player, ident):
        if player is None:
            return False

        if ident == self.JANUS_HACKER_COSTUME or ident == self.MI6_HACKER_COSTUME:
            GEUtil.HudMessage(player, "You cannot impersonate the hacker!", -1, 0.1, self.COLOR_INFO, 2.0)
            return False

        elif player.GetUID() == self.hacker_playerUID:
            if self.lc_CanHackerSwitch():
                self.lc_ChooseHacker()
                return True
            else:
                GEUtil.HudMessage(player, "You cannot switch from the hacker!", -1, 0.1, self.COLOR_INFO, 2.0)
                return False

        return True

    def CanPlayerHaveItem(self, player, item):
        name = item.GetClassname()

        if player.GetUID() == self.hacker_playerUID:
            # The hacker can only pickup armor
            if name.startswith("item_armorvest"):
                return True
            elif name == "weapon_slappers" or name == self.TOOL_CLASSNAME:
                return True
            elif name == "weapon_dd44" and self.hacker_canArm:
                return True

            return False
        else:
            if name == self.TOOL_CLASSNAME:
                return False

            return True

    def OnTokenSpawned(self, token):
        GERules.GetRadar().AddRadarContact(token, Glb.RADAR_TYPE_TOKEN, True)

    def OnTokenRemoved(self, token):
        GERules.GetRadar().DropRadarContact(token)

    def OnTokenPicked(self, token, player):
        self.hacker_hasTool = True
        GEUtil.PlaySoundTo(player, "GEGamePlay.Token_Grab")
        GEUtil.ClientPrint(None, Glb.HUD_PRINTTALK, self.TAG + " The hacker picked up the Insta-Hack")
        GEUtil.HudMessage(self.team_hacker, "The hacker has the Insta-Hack, protect them at all costs!", -1, 0.65,
                          self.COLOR_NOTICE, 4.0, 1)
        GEUtil.HudMessage(self.team_preventor, "Warning! The hacker has the Insta-Hack!!", -1, 0.65, self.COLOR_NOTICE,
                          4.0, 1)
        GEUtil.PlaySoundTo(self.team_hacker, "GEGamePlay.Token_Grab")
        GEUtil.PlaySoundTo(self.team_preventor, "GEGamePlay.Token_Grab_Enemy")
        GERules.GetRadar().DropRadarContact(token)

    def OnTokenDropped(self, token, player):
        self.hacker_hasTool = False
        GEUtil.ClientPrint(None, Glb.HUD_PRINTTALK, self.TAG + " The Insta-Hack has been destroyed")
        GEUtil.HudMessage(None, "The Insta-Hack has been destroyed!", -1, 0.65, self.COLOR_NOTICE, 4.0, 1)
        GEUtil.PlaySoundTo(None, "GEGamePlay.Token_Drop_Friend")
        GERules.GetTokenMgr().RemoveTokenType(self.TOOL_CLASSNAME)

    def OnThink(self):
        if self.game_lowPlayers:
            if self.lc_HavePlayers():
                # We have enough players, start the warmup period
                self.warmUpTimer.StartWarmup(float(GEUtil.GetCVarValue("lc_warmup")))
                self.game_lowPlayers = False
                self.lc_DerobeHacker()
            elif GEUtil.GetTime() >= self.game_lowPlayersNotice:
                # Notify anyone in the serve that we don't have enough players
                GEUtil.HudMessage(None, "Not enough players, please wait...", -1, -1, self.COLOR_NOTICE,
                                  self.LOW_PLAYER_NOTICE_INTERVAL / 4.0)
                self.game_lowPlayersNotice = GEUtil.GetTime() + self.LOW_PLAYER_NOTICE_INTERVAL

        elif not self.lc_HavePlayers():
            # Put us back into low player state
            self.warmUpTimer.Reset()
            self.game_lowPlayers = True
            self.game_lowPlayersNotice = 0
            self.lc_DerobeHacker()

    def CanPlayerChangeTeam(self, player, oldteam, newteam, wasforced):
        # The hacker cannot change teams
        if player.GetUID() == self.hacker_playerUID:
            GEUtil.HudMessage(player, "You cannot change teams as the hacker!", -1, -1,
                              GEUtil.CColor(255, 255, 255, 255), 3.0)
            return False

        return True

    def OnPlayerDisconnect(self, player):
        # If the hacker disconnects we must choose a new one
        if player.GetUID() == self.hacker_playerUID:
            self.hacker_hasWeapon = False
            self.hacker_hasTool = False
            self.lc_ChooseHacker(True)

    def OnPlayerSay(self, player, text):
        if text == "!voodoo":
            if player.GetUID() == self.hacker_playerUID and self.hacker_hasTool and self.game_currTerminalUID:
                self.lc_OnHackCompleted()
                self.timer_hacking.Stop()
                GERules.GetTokenMgr().RemoveTokenType(self.TOOL_CLASSNAME)
                return True

        return False

    # ------------------ #
    #  CUSTOM FUNCTIONS  #
    # ------------------ #

    def lc_InitRound(self):
        # Hacker Variables
        self.hacker_notice = 0
        self.hacker_playerUID = None
        self.hacker_oldCostume = ""
        self.hacker_oldSkin = 0
        self.hacker_switched = False
        self.hacker_hasTool = False
        self.hacker_hasWeapon = False

        # Game Variables
        self.game_startTime = GEUtil.GetTime()
        self.game_hackersWin = False
        self.game_lastTerminalUID = None
        self.game_currTerminalUID = None
        self.game_tool = None

        # Reset Timers
        self.timerTracker.ResetTimer()

        # Check for low player counts
        self.game_lowPlayersNotice = 0
        if not self.lc_HavePlayers():
            self.game_lowPlayers = True
        else:
            self.game_lowPlayers = False

        # Setup Teams
        if self.team_hacker:
            # Swap the teams
            tmp = self.team_hacker
            self.team_hacker = self.team_preventor
            self.team_preventor = tmp
        else:
            # First time? Pick a random team
            self.team_hacker = random.choice([Glb.TEAM_MI6, Glb.TEAM_JANUS])
            if self.team_hacker == Glb.TEAM_JANUS:
                self.team_preventor = Glb.TEAM_MI6
            else:
                self.team_preventor = Glb.TEAM_JANUS

    def lc_ChooseHacker(self, force=False):
        if not self.team_hacker:
            self.lc_ErrorShout("Hacker assignment attempted before team chosen!")
            return

        # Enumerate the number of eligible players
        players = self.lc_ListPlayers(self.team_hacker, self.hacker_playerUID)
        self.lc_DerobeHacker()
        if self.hacker_playerUID:
            if len(players) > 1 and (force or self.lc_CanHackerSwitch()):
                self.lc_DebugShout("Hacker being switched")

                self.lc_EnrobeHacker(random.choice(players))
                self.hacker_switched = True

        elif len(players) > 0:
            self.lc_DebugShout("New hacker being selected")
            self.lc_EnrobeHacker(random.choice(players))
            self.hacker_switched = False

    def lc_CanHackerSwitch(self):
        timeIn = GEUtil.GetTime() - self.game_startTime;
        plrCount = GERules.GetNumActiveTeamPlayers(self.team_hacker)
        if self.hacker_playerUID and plrCount > 1 and not self.hacker_switched and timeIn < 15.0:
            return True
        return False

    def lc_CreateHackingTool(self):
        # Only create the hacking tool if allowed
        if GEUtil.GetCVarValue("lc_hackertool") == 1:
            mgr = GERules.GetTokenMgr()
            mgr.SetupToken(self.TOOL_CLASSNAME, limit=1, location=Glb.SPAWN_AMMO,
                       allow_switch=True, glow_color=GEUtil.CColor(80, 80, 80, 255), glow_dist=500.0)

    def lc_EnrobeHacker(self, uid):
        player = GEPlayer.ToMPPlayer(uid)
        if player is not None:
            model = self.MI6_HACKER_COSTUME
            if player.GetTeamNumber() == Glb.TEAM_JANUS:
                model = self.JANUS_HACKER_COSTUME

            # Store away his old costume and set him as the hacker
            self.hacker_oldCostume = player.GetPlayerModel()
            self.hacker_oldSkin = player.GetSkin()
            player.SetPlayerModel(model, 0)
            # Add me to the radar as always visible
            GERules.GetRadar().AddRadarContact(player, Glb.RADAR_TYPE_PLAYER, True, "sprites/hud/radar/run",
                                               GEUtil.CColor(255, 180, 225, 170))
            # Reset notices
            self.hacker_notice = 0
            self.hacker_playerUID = uid
            if self.hacker_canArm:
                self.lc_ArmHacker(player)

    def lc_DerobeHacker(self):
        player = getPlayerFromUID(self.hacker_playerUID)
        if player is not None:
            # Revert back to the old costume
            player.SetPlayerModel(self.hacker_oldCostume, self.hacker_oldSkin)
            player.StripAllWeapons()
            player.GiveDefaultWeapons()
            GERules.GetRadar().DropRadarContact(player)

        self.hacker_hasWeapon = False
        self.hacker_hasTool = False
        self.hacker_playerUID = None

    def lc_ArmHacker(self, player):
        if player is not None:
            player.StripAllWeapons()
            player.GiveNamedWeapon("weapon_slappers", 0)
            player.GiveNamedWeapon("weapon_dd44", 14)  # DD44 starts w/ 10 bullets: 8|16
            player.SetArmor(int(Glb.GE_MAX_ARMOR))

    def lc_OnHackTimer(self, timer, update_type):
        assert isinstance(timer, Timer)

        if update_type is Timer.UPDATE_FINISH:
            # Complete the hack
            self.lc_OnHackCompleted()

        elif update_type is Timer.UPDATE_STOP:
            GEUtil.RemoveHudProgressBar(None, 1)
            # Reset the terminal usage since we abandoned our current effort
            self.game_lastTerminalUID = self.game_currTerminalUID = None

        elif update_type is Timer.UPDATE_RUN:
            GEUtil.UpdateHudProgressBar(None, 1, timer.GetCurrentTime())

    def lc_OnHackCompleted(self):
        GERules.GetTeam(self.team_hacker).IncrementRoundScore(1)
        GERules.GetRadar().DropRadarContact(GEEntity.GetEntByUID(self.game_lastTerminalUID))

        GEUtil.PlaySoundTo(self.team_hacker, "GEGameplay.Token_Capture_Friend", True)
        GEUtil.PlaySoundTo(self.team_preventor, "GEGamePlay.Token_Capture_Enemy", True)
        GEUtil.HudMessage(None, "The hacker has taken over a terminal!", -1, -1, self.COLOR_NOTICE, 2.0, 2)

        self.game_terminals[self.game_lastTerminalUID]["hacked"] = True
        self.game_lastTerminalUID = self.game_currTerminalUID = None

        self.lc_CheckHackerWin()

    def lc_OnEndRoundTimer(self, timer, update_type):
        if update_type is Timer.UPDATE_FINISH:
            GERules.EndRound()

    def lc_CheckHackerWin(self):
        for t in self.game_terminals.values():
            if not t["hacked"]:
                return

        # If we made it here, hackers won! End the round
        self.game_hackersWin = True
        hTeam = GERules.GetTeam(self.team_hacker)
        GERules.SetTeamWinner(hTeam)
        hTeam.IncrementRoundScore(len(self.game_terminals))
        # End the round in 3 seconds (this should be a variable in EndRound(...))
        self.timer_endRound.Start(3.0)

    def lc_GetHackerTeamColor(self):
        if self.team_hacker == Glb.TEAM_MI6:
            return self.COLOR_RADAR_MI6
        else:
            return self.COLOR_RADAR_JANUS

    def lc_ListPlayers(self, team, ignore=None, npcs=False):
        list = []
        for j in range(32):
            if GEPlayer.IsValidPlayerIndex(j):
                player = GEPlayer.GetMPPlayer(j)
                if player.GetTeamNumber() == team and player.GetUID() != ignore:
                    # Favor humans over NPCs
                    if not npcs and player.IsNPC():
                        continue
                    list.append(player.GetUID())
        if len(list) == 0:  # No humans on hacker team, regrab list without stripping NPCs
            self.lc_ListPlayers(team, ignore, True)
        return list

    def lc_HavePlayers(self):
        if GERules.GetNumActivePlayers() >= self.MIN_PLAYERS:
            return True
        return False

    def lc_DebugShout(self, msg):
        if self.__debug:
            GEUtil.Msg(self.TAG + msg + "\n")

    def lc_ErrorShout(self, msg):
        if self.__debug:
            GEUtil.Warning(self.TAG + msg + "\n")
Exemplo n.º 20
0
 def hideRoundScore(self, target):
     GEUtil.HudMessage(target, "", -1, 0.0,
                       GEUtil.CColor(255, 255, 255,
                                     255), 0, self.scoreDisplayChannel)
Exemplo n.º 21
0
class LivingDaylights(GEScenario):
    BAR_CARRY = 100
    BAR_ESCAPE = 100
    BAR_TEAMBALANCE = 50
    BAR_CAP_X = 0.3

    COLOR_COLD = GEUtil.CColor(30, 150, 180, 170)
    COLOR_HOLD = GEUtil.CColor(255, 180, 225, 170)
    COLOR_H_MI = GEUtil.CColor(180, 225, 255, 170)
    COLOR_H_JS = GEUtil.CColor(255, 225, 180, 170)
    COLOR_P_JS = GEUtil.CColor(255, 180, 180, 170)
    COLOR_WARM = GEUtil.CColor(180, 150, 30, 170)
    COLOR_CASH = GEUtil.CColor(240, 225, 45, 170)
    COLOR_MI6 = GEUtil.CColor(94, 171, 231, 255)
    COLOR_JS = GEUtil.CColor(206, 43, 43, 255)

    PERK_ADREN = 0.3
    PERK_SPEED = 0.025

    THEFT_DELTA = 1

    # Flag information management
    FLAGLIST_LIMIT = 16
    FLAGLIST_MAXID = FLAGLIST_LIMIT - 1
    flaglist = [LivingDaylightsFlag() for j in range(FLAGLIST_LIMIT)]

    def ft_ageflag(self, flagindex, ticks):
        if self.flaglist[flagindex].age(ticks, True):
            self.ft_creditcarrier(self.flaglist[flagindex])

    # Flag Tag functions
    def ft_ageflags(self):
        for j in range(self.FLAGLIST_LIMIT):
            flag = self.flaglist[j]
            if flag.exp_to_escape > -1:
                self.ft_perk_speed(j)
            if flag.age_escape(1):
                self.ft_creditescape(flag)
            if flag.age(1, True):
                self.ft_creditcarrier(flag, 1)
                self.ft_perk_speed(j)
            if flag.armor_up > -1:
                self.ft_escapee_armorapply(flag)

    def ft_announceearning(self, flag, frags):
        player = ep_player_by_id(flag.player_id)
        GEUtil.PlaySoundTo(player, "GEGamePlay.Token_Chime")
        self.ft_progressbar(flag, ep_player_by_id(flag.player_id))

    def ft_announceescaping(self, flag):
        player = ep_player_by_id(flag.player_id)
        GEUtil.HudMessage(
            player, _(plural(flag.escapes, "#GES_GP_LD_ESCAPED"),
                      flag.escapes), -1, -1, EP_SHOUT_COLOR, 2.0)
        GEUtil.PlaySoundTo(player, "Buttons.beep_ok")
        ep_shout("Escaped successfully.")

    def ft_associate(self, token, player):
        flagindex = self.ft_flagindexbytoken(token)
        if (flagindex >= 0):
            self.flaglist[flagindex].player_id = GEEntity.GetUID(player)
        else:
            ep_shout(
                "[ft_associate] Token %d does not have associated information."
                % (GEEntity.GetUID(token)))
        return flagindex

    def ft_coldflaglevel(self, index):
        if (index >= 0):
            self.flaglist[index].level_by_playercount(
                GEMPGameRules.GetNumActivePlayers())

    def ft_creditcarrier(self, flag, frags):
        player = ep_player_by_id(flag.player_id)
        ep_incrementscore(player, frags)
        self.ft_announceearning(flag, frags)
        GEUtil.EmitGameplayEvent("ld_flagpoint", str(player.GetUserID()), "-1",
                                 "timer", str(frags))

    def ft_creditescape(self, flag):
        player = ep_player_by_id(flag.player_id)
        ep_incrementscore(player, flag.escapes)
        self.ft_escapee_armorup(flag, player)
        self.ft_announceescaping(flag)
        self.ft_escapebar_remove(flag)
        GEUtil.EmitGameplayEvent("ld_flagpoint", str(player.GetUserID()), "-1",
                                 "escape", str(flag.escapes))

    def ft_disassociate(self, token, respawned):
        flagindex = self.ft_flagindexbytoken(token)
        if (flagindex >= 0):
            flag = self.flaglist[flagindex]
            self.ft_progressbar_remove(flag)
            self.ft_escapebar_remove(flag)
            if respawned:
                flag.zot()
            else:
                flag.release()
        else:
            ep_shout("[Disassociate] Token %d was unregistered when dropped.")
        return flagindex

    def ft_escapebar(self, flag, player):
        GEUtil.InitHudProgressBar(player, 1, "%d " % (flag.escapes + 1),
                                  GEGlobal.HUDPB_SHOWBAR, flag.ESCAPE_TIME, -1,
                                  .72, self.BAR_ESCAPE, 10, self.COLOR_WARM)

    def ft_escapebar_remove(self, flag):
        GEUtil.RemoveHudProgressBar(ep_player_by_id(flag.player_id), 1)

    def ft_escapee_armorapply(self, flag):
        ep_player_by_id(flag.player_id).SetArmor(flag.armor_up)
        flag.armor_up = -1

    def ft_escapee_armorup(self, flag, player):
        flag.armor_up = clamp(int(player.GetArmor() + flag.escape_ap), 0,
                              GEGlobal.GE_MAX_ARMOR)
        flag.escape_ap = 0

    def ft_flagdebt(self):
        return self.ft_flagsdesired() - self.ft_flagsregistered()

    def ft_flagindexbytoken(self, token):
        uid = GEEntity.GetUID(token)
        rtn_j = -1
        for j in range(self.FLAGLIST_LIMIT):
            if (self.flaglist[j].token_id == uid):
                rtn_j = j
                break
        return rtn_j

    def ft_flagindexbyplayer(self, player):
        uid = GEEntity.GetUID(player)
        rtn_j = -1
        for j in range(self.FLAGLIST_LIMIT):
            if (self.flaglist[j].player_id == uid):
                rtn_j = j
                break
        return rtn_j

    def ft_flagindexbyplayerprevious(self, player):
        uid = GEEntity.GetUID(player)
        rtn_j = -1
        for j in range(self.FLAGLIST_LIMIT):
            if (self.flaglist[j].player_previous == uid):
                rtn_j = j
                break
        return rtn_j

    def ft_flaglist_openslot(self):
        rtn_index = -1
        for j in range(self.FLAGLIST_LIMIT):
            if self.flaglist[j].token_id == 0:
                rtn_index = j
                break
        return rtn_index

    def ft_flagsdesired(self):
        if GEMPGameRules.IsTeamplay():
            fd = min(
                min(
                    GEMPGameRules.GetTeam(GEGlobal.TEAM_MI6).GetNumPlayers(),
                    GEMPGameRules.GetTeam(
                        GEGlobal.TEAM_JANUS).GetNumPlayers()),
                self.FLAGLIST_LIMIT)
            fd = clamp(
                fd, 1,
                fd - max(0, int(GEUtil.GetCVarValue("ld_teamguardians"))))
        else:
            playersperflag = max(1,
                                 int(GEUtil.GetCVarValue("ld_playersperflag")))
            fd = min(
                int((GEMPGameRules.GetNumActivePlayers() + playersperflag - 1)
                    / playersperflag), self.FLAGLIST_LIMIT)
        return fd

    def ft_flagsregistered(self):
        flagsregistered = 0
        for j in range(self.FLAGLIST_LIMIT):
            if self.flaglist[j].token_id != 0:
                flagsregistered += 1
        return flagsregistered

    def ft_gameislive(self):
        return GEMPGameRules.GetNumActivePlayers() > 1 or FT_DEBUG

    def ft_omnomnomnom(self, player, itemname):
        flagindex = self.ft_flagindexbyplayer(player)
        if flagindex >= 0:
            quality = -1
            if itemname.startswith("item_armorvest_half"):
                quality = 2
            elif itemname.startswith("item_armorvest"):
                quality = 3
            elif itemname.startswith("weapon_"):
                quality = 1
            elif itemname.startswith("ge_ammo"):
                quality = 0
            if quality >= 0:
                if self.ft_gameislive():
                    self.flaglist[flagindex].age_item(quality, 1.0)
# 					ep_shout("Consumed %s for %d EXP." % (itemname, self.flaglist[flagindex].BONUS_ITEM[quality]))
        return True

    def ft_perk_speed(self, flagindex):
        if flagindex >= 0 and self.flaglist[flagindex].i_am_held():
            flag = self.flaglist[flagindex]
            player = ep_player_by_id(flag.player_id)
            perk = (1.0 + (float(GEMPGameRules.GetNumActivePlayers()) +
                           (float(flag.adrenaline) * self.PERK_ADREN)) *
                    self.PERK_SPEED)**0.5
            ep_shout("[Perk Speed] %f" % perk)
            player.SetSpeedMultiplier(
                min(perk, choice(GEMPGameRules.IsTeamplay(), 1.20, 1.35)))

    def ft_playercarries(self, player):
        return self.ft_flagindexbyplayer(player) != -1

    def ft_progressbar(self, flag, player):
        GEUtil.InitHudProgressBar(player, 0, "%d " % flag.earnings,
                                  GEGlobal.HUDPB_SHOWBAR,
                                  flag.exp_this_level(flag.level), -1, .76,
                                  self.BAR_CARRY, 10, self.COLOR_H_MI)

    def ft_progressbar_remove(self, flag):
        GEUtil.RemoveHudProgressBar(ep_player_by_id(flag.player_id), 0)

    def ft_progressbars(self):
        for j in range(self.FLAGLIST_LIMIT):
            flag = self.flaglist[j]
            if flag.player_id != 0:
                GEUtil.UpdateHudProgressBar(ep_player_by_id(flag.player_id), 0,
                                            flag.exp_to_next)
            if flag.exp_to_escape > -1:
                GEUtil.UpdateHudProgressBar(ep_player_by_id(flag.player_id), 1,
                                            flag.exp_to_escape)

    def ft_progressbars_legacy(self):
        for j in range(self.FLAGLIST_LIMIT):
            flag = self.flaglist[j]
            if flag.player_id != 0:
                step = 4.0
                text_lifespan = 0.2
                scale = 1.0 / step
                width = scale * flag.exp_this_level(flag.level)
                fill = scale * flag.exp_to_next
                exp_bar = ""
                for jj in range(1, int(width), 1):
                    if jj < fill:
                        exp_bar = "-%s" % exp_bar
                    else:
                        exp_bar = "!%s" % exp_bar
                exp_bar = "[%s] %d" % (exp_bar, flag.earnings)
                GEUtil.HudMessage(ep_player_by_id(flag.player_id), exp_bar, -1,
                                  .75, EP_SHOUT_COLOR, text_lifespan)

    def ft_registerflag(self, newflag_id):
        newflag_index = self.ft_flaglist_openslot()
        if (newflag_index > -1):
            self.flaglist[newflag_index].zot()
            self.flaglist[newflag_index].token_id = newflag_id
        else:
            ep_shout(
                "[Register Flag] Failed to find an information slot. (CRITICAL)"
            )
        return newflag_index

    def ft_shepherd(self):
        if self.ft_flagdebt() > 0:
            GEMPGameRules.GetTokenMgr().SetupToken(
                self.TokenClass, limit=self.ft_flagsdesired())

    def ft_showteamflags(self, player=None):
        if GEMPGameRules.IsTeamplay():
            if player is None:
                if self.ShowMI6Flags:
                    GEUtil.HudMessage(
                        GEGlobal.TEAM_MI6,
                        _("#GES_GP_LD_TEAMHOLDS", self.MI6Flags,
                          self.FlagCount), -1, 0.65, self.COLOR_MI6, 5.0, 1)
                if self.ShowJanusFlags:
                    GEUtil.HudMessage(
                        GEGlobal.TEAM_JANUS,
                        _("#GES_GP_LD_TEAMHOLDS", self.JanusFlags,
                          self.FlagCount), -1, 0.65, self.COLOR_JS, 5.0, 1)

                self.ShowMI6Flags = self.ShowJanusFlags = False
            else:
                if player.GetTeamNumber() == GEGlobal.TEAM_MI6:
                    GEUtil.HudMessage(
                        player,
                        _("#GES_GP_LD_TEAMHOLDS", self.MI6Flags,
                          self.FlagCount), -1, 0.65, self.COLOR_MI6, 5.0, 1)
                else:
                    GEUtil.HudMessage(
                        player,
                        _("#GES_GP_LD_TEAMHOLDS", self.JanusFlags,
                          self.FlagCount), -1, 0.65, self.COLOR_JS, 5.0, 1)

    def ft_teambalancebars(self):
        if GEMPGameRules.IsTeamplay():
            mi_flags = 0
            js_flags = 0
            barwidth = 0
            for j in range(self.FLAGLIST_LIMIT):
                if self.flaglist[j].token_id != 0:
                    barwidth += 1
                    thisflagteam = self.flaglist[j].my_team()
                    if thisflagteam == GEGlobal.TEAM_MI6:
                        mi_flags += 1
                    if thisflagteam == GEGlobal.TEAM_JANUS:
                        js_flags += 1

            # Store out values before adding micro t
            if self.MI6Flags != mi_flags or barwidth != self.FlagCount:
                self.ShowMI6Flags = True
            if self.JanusFlags != js_flags or barwidth != self.FlagCount:
                self.ShowJanusFlags = True

            self.MI6Flags = mi_flags
            self.JanusFlags = js_flags
            self.FlagCount = barwidth

            microt = barwidth * 0.05
            barwidth += microt
            mi_flags += microt
            js_flags += microt

            GEUtil.InitHudProgressBar(None, 2, "", GEGlobal.HUDPB_SHOWBAR,
                                      barwidth, .1875, .920,
                                      self.BAR_TEAMBALANCE, 10,
                                      self.COLOR_H_MI)
            GEUtil.InitHudProgressBar(None, 3, "", GEGlobal.HUDPB_SHOWBAR,
                                      barwidth, .1875, .905,
                                      self.BAR_TEAMBALANCE, 10,
                                      self.COLOR_P_JS)
            GEUtil.UpdateHudProgressBar(None, 2, mi_flags)
            GEUtil.UpdateHudProgressBar(None, 3, js_flags)
        else:
            GEUtil.RemoveHudProgressBar(None, 2)
            GEUtil.RemoveHudProgressBar(None, 3)

    def ft_zot(self):
        GEMPGameRules.GetTokenMgr().SetupToken(self.TokenClass, limit=0)
        for j in range(self.FLAGLIST_LIMIT):
            self.flaglist[j].zot()

    def ft_zot_token(self, token):
        j = self.ft_flagindexbytoken(token)
        if j >= 0:
            self.flaglist[j].zot()
        else:
            ep_shout("[Zot Token] Attempted to remove unregistered token %d" %
                     GEEntity.GetUID(token))

    # Engine callbacks
    def __init__(self):
        super(LivingDaylights, self).__init__()
        self.TokenClass = 'token_deathmatch'
        self.TokenGlow = GEUtil.CColor(244, 192, 11, 64)

        self.MI6Flags = 0
        self.JanusFlags = 0
        self.FlagCount = 0
        self.ShowMI6Flags = True
        self.ShowJanusFlags = True

    def GetGameDescription(self):
        if GEMPGameRules.IsTeamplay():
            return "Team Living Daylights"
        return "Living Daylights"

    def GetPrintName(self):
        return "#GES_GP_LD_NAME"

    def GetScenarioHelp(self, help_obj):
        assert isinstance(help_obj, GEScenarioHelp)

        help_obj.SetInfo("#GES_GPH_LD_TAGLINE",
                         "http://wiki.geshl2.com/index.php/Living_Daylights")
        help_obj.SetDescription("#GES_GP_LD_HELP")

        pane = help_obj.AddPane("ld")
        help_obj.AddHelp(pane, "ld_earnpoints1", "")
        help_obj.AddHelp(pane, "ld_earnpoints2", "#GES_GPH_LD_FLAG_POINTS")

    def GetTeamPlay(self):
        return GEGlobal.TEAMPLAY_TOGGLE

    def OnThink(self):
        if self.ft_gameislive():
            self.ft_ageflags()
            self.ft_progressbars()

    def OnPlayerKilled(self, victim, killer, weapon):
        if victim == None:
            return
        # Disconnecting player_previous to prevent multiple penalties.
        flagindex = self.ft_flagindexbyplayer(victim)
        if flagindex >= 0:
            self.flaglist[flagindex].player_previous = 0
            GEUtil.EmitGameplayEvent("ld_flagdropped", str(victim.GetUserID()),
                                     str(killer.GetUserID()))

        vid = GEEntity.GetUID(victim)
        kid = GEEntity.GetUID(killer)
        ep_shout("[OPK] Victim %d, Killer %d, VFlag Index %d" %
                 (vid, kid, flagindex))
        bounty = min(self.flaglist[flagindex].earnings,
                     self.flaglist[flagindex].LEVEL_LIMIT)

        # Suicide
        if killer == None or killer.GetIndex(
        ) == 0 or vid == kid or GEMPGameRules.IsTeamplay(
        ) and victim.GetTeamNumber() == killer.GetTeamNumber():
            suicide_bounty = -choice(flagindex >= 0, bounty + bounty, 1)
            ep_incrementscore(victim, suicide_bounty)
            if flagindex >= 0:
                GEUtil.EmitGameplayEvent("ld_flagpoint",
                                         str(victim.GetUserID()), "-1",
                                         "suicide", str(suicide_bounty))
            return

        # slap and snatch TODO: Verify
        if weapon != None and weapon.GetClassname(
        ) == "weapon_slappers" and flagindex >= 0:
            delta = choice(flagindex >= 0, bounty, 0)
            if delta > 0:
                ep_incrementscore(victim, -delta)
                GEUtil.HudMessage(
                    victim, _(plural(delta, "#GES_GP_LD_LOSEPOINTS"), delta),
                    -1, -1, EP_SHOUT_COLOR, 2.0)
                ep_incrementscore(killer, delta)
                GEUtil.HudMessage(
                    killer, _(plural(delta, "#GES_GP_LD_STOLEPOINTS"), delta),
                    -1, -1, EP_SHOUT_COLOR, 2.0)
                GEUtil.EmitGameplayEvent("ld_flagpoint",
                                         str(victim.GetUserID()),
                                         str(killer.GetUserID()),
                                         "slapperkill", str(-delta))

        # credit if token will be removed from play. TODO: Verify
        if self.ft_flagdebt() < 0:
            if flagindex >= 0:
                ep_incrementscore(killer, self.flaglist[flagindex].level)
            else:
                ep_shout(
                    "[OPK] No flag index associated with slain carrier whose flag is removed."
                )

    def OnPlayerSay(self, player, text):
        return False

    def OnLoadGamePlay(self):
        self.CreateCVar("ld_playersperflag", "4",
                        "Number of players per flag spawned.")
        self.CreateCVar(
            "ld_teamguardians", "0",
            "Flags are withheld to ensure this many players must guard on the shortest team. One flag will always be available."
        )

        tokenmgr = GEMPGameRules.GetTokenMgr()
        tokenmgr.SetupToken(
            self.TokenClass,
            limit=1,
            location=GEGlobal.SPAWN_TOKEN,
            allow_switch=False,
            glow_color=self.TokenGlow,
            respawn_delay=30.0,
            print_name="#GES_GP_LD_OBJ",
            view_model="models/weapons/tokens/v_flagtoken.mdl",
            world_model="models/weapons/tokens/w_flagtoken.mdl")

        GEMPGameRules.GetRadar().SetForceRadar(True)

        GEUtil.PrecacheSound("GEGamePlay.Token_Chime")
        GEUtil.PrecacheSound("GEGamePlay.Token_Knock")
        GEUtil.PrecacheSound("GEGamePlay.Token_Grab")
        GEUtil.PrecacheSound("Buttons.beep_ok")
        GEUtil.PrecacheSound("Buttons.beep_denied")

    def OnRoundBegin(self):
        self.ft_zot()
        GEMPGameRules.ResetAllPlayersScores()

    def OnRoundEnd(self):
        GEMPGameRules.GetRadar().DropAllContacts()

    def OnPlayerSpawn(self, player):
        assert isinstance(player, GEPlayer.CGEMPPlayer)

        player.SetSpeedMultiplier(1.0)
        player.SetScoreBoardColor(GEGlobal.SB_COLOR_NORMAL)
        player.SetMaxArmor(int(GEGlobal.GE_MAX_ARMOR))
        player.GiveNamedWeapon("weapon_slappers", 0)
        self.ft_shepherd()
        self.ft_teambalancebars()
        self.ft_showteamflags(player)

    def CanPlayerChangeTeam(self, player, oldteam, newteam):
        # If we switched from DM to Team (or vice versa) or Spectating, reset help
        if oldteam == GEGlobal.TEAM_SPECTATOR \
          or oldteam == GEGlobal.TEAM_NONE and newteam >= GEGlobal.TEAM_MI6 \
          or oldteam >= GEGlobal.TEAM_MI6 and newteam == GEGlobal.TEAM_NONE:
            # Reset this players help archive so they don't recall old help
            player.SetInitialSpawn(True)

        return True

    def CanPlayerHaveItem(self, player, item):
        # 		itemname = entity.GetClassname()
        return self.ft_omnomnomnom(player, item.GetClassname())
# 		return not (itemname.startswith("item_armorvest") and self.ft_flagindexbyplayer(player) >= 0)

    def ShouldForcePickup(self, player, item):
        if self.ft_playercarries(player):
            GEUtil.PlaySoundTo(player, "HL2Player.PickupWeapon")
            return True
        return False

    def CalculateCustomDamage(self, victim, info, health, armour):
        assert isinstance(victim, GEPlayer.CGEMPPlayer)
        if victim == None:
            return health, armour
        killer = GEPlayer.ToMPPlayer(info.GetAttacker())
        v_flagindex = self.ft_flagindexbyplayer(victim)
        k_flagindex = self.ft_flagindexbyplayer(killer)
        # ep_shout("[SDCD] %d %d" % (v_flagindex, k_flagindex) )
        if v_flagindex >= 0:
            # Suicide or friendly fire exacerbates but does not trigger escape.
            total_damage = health + armour
            if killer == None or GEEntity.GetUID(victim) == GEEntity.GetUID(
                    killer) or GEMPGameRules.IsTeamplay(
                    ) and victim.GetTeamNumber() == killer.GetTeamNumber():
                self.flaglist[v_flagindex].escape(False, total_damage)
            else:
                self.flaglist[v_flagindex].escape(True, total_damage)
                self.ft_escapebar(self.flaglist[v_flagindex], victim)
        if k_flagindex >= 0:
            # Flag carrier steals a point on successful attack.
            if victim.GetRoundScore() > 0:
                ep_incrementscore(victim, -self.THEFT_DELTA)
                ep_incrementscore(killer, self.THEFT_DELTA)
                GEUtil.PlaySoundTo(killer, "Buttons.beep_ok")
                GEUtil.PlaySoundTo(victim, "Buttons.Token_Knock")
                ep_shout("Point stolen from %s via slap." %
                         victim.GetPlayerName())
                GEUtil.EmitGameplayEvent("ld_flagpoint",
                                         str(killer.GetUserID()),
                                         str(victim.GetUserID()), "flaghit",
                                         "1")
        return health, armour

    def CalcFinalScores(self):
        pass

    def OnTokenSpawned(self, token):
        self.ft_registerflag(GEEntity.GetUID(token))
        GEMPGameRules.GetRadar().AddRadarContact(token,
                                                 GEGlobal.RADAR_TYPE_TOKEN,
                                                 True, "", self.COLOR_COLD)
        GEMPGameRules.GetRadar().SetupObjective(
            token, GEGlobal.TEAM_NONE, "!%s" % self.TokenClass,
            "#GES_GP_LD_OBJ_TAKE", GEUtil.CColor(220, 220, 220, 200))
        token.SetSkin(0)
        self.ft_teambalancebars()
        self.ft_showteamflags()

    def OnTokenPicked(self, token, player):
        player.SetScoreBoardColor(GEGlobal.SB_COLOR_WHITE)
        GEMPGameRules.GetRadar().DropRadarContact(token)
        GEMPGameRules.GetRadar().AddRadarContact(
            player, GEGlobal.RADAR_TYPE_PLAYER, True, "sprites/hud/radar/run",
            choice(
                GEMPGameRules.IsTeamplay(),
                choice(player.GetTeamNumber() == GEGlobal.TEAM_MI6,
                       self.COLOR_H_MI, self.COLOR_H_JS), self.COLOR_HOLD))
        GEUtil.PlaySoundTo(player, "GEGamePlay.Token_Grab")
        GEUtil.EmitGameplayEvent("ld_flagpickup", str(player.GetUserID()))
        flagindex = self.ft_flagindexbytoken(token)
        if GEMPGameRules.IsTeamplay() and flagindex >= 0 and self.flaglist[
                flagindex].team_previous == player.GetTeamNumber():
            self.ft_associate(token, player)
        else:
            self.ft_coldflaglevel(self.ft_associate(token, player))

        # Support team colors!
        if GEMPGameRules.IsTeamplay():
            if player.GetTeamNumber() == GEGlobal.TEAM_MI6:
                skin = 1
                color = self.COLOR_MI6
            else:
                skin = 2
                color = self.COLOR_JS

            token.SetSkin(skin)
            GEMPGameRules.GetRadar().SetupObjective(player, GEGlobal.TEAM_NONE,
                                                    "!%s" % self.TokenClass,
                                                    "", color)
        else:
            GEMPGameRules.GetRadar().SetupObjective(player, GEGlobal.TEAM_NONE,
                                                    "!%s" % self.TokenClass,
                                                    "", self.COLOR_HOLD)

        health_coefficient = 2.0 * float(player.GetHealth() + player.GetArmor(
        )) / float(player.GetMaxHealth() + player.GetMaxArmor())
        player.SetHealth(int(GEGlobal.GE_MAX_HEALTH))
        player.SetArmor(int(GEGlobal.GE_MAX_ARMOR))
        # Suppress Armor pickup
        player.SetMaxArmor(0)
        self.flaglist[self.ft_flagindexbytoken(token)].age_item(
            3, health_coefficient)
        self.ft_teambalancebars()
        self.ft_showteamflags()

    def OnTokenDropped(self, token, player):
        player.SetScoreBoardColor(GEGlobal.SB_COLOR_NORMAL)
        if self.ft_flagdebt() >= 0:
            GEMPGameRules.GetRadar().AddRadarContact(token,
                                                     GEGlobal.RADAR_TYPE_TOKEN,
                                                     True, "", self.COLOR_WARM)
            GEMPGameRules.GetRadar().SetupObjective(
                token, GEGlobal.TEAM_NONE, "!%s" % self.TokenClass,
                "#GES_GP_LD_OBJ_TAKE", GEUtil.CColor(220, 220, 220, 200))
            GEMPGameRules.GetRadar().DropRadarContact(player)
            self.ft_disassociate(token, False)
        else:
            GEMPGameRules.GetTokenMgr().RemoveTokenEnt(token)

        self.ft_teambalancebars()
        self.ft_showteamflags()
        token.SetSkin(0)

    def OnTokenRemoved(self, token):
        self.ft_disassociate(token, True)
        GEMPGameRules.GetRadar().DropRadarContact(token)
        GEMPGameRules.GetRadar().DropRadarContact(token.GetOwner())
        self.ft_teambalancebars()
        self.ft_showteamflags()
Exemplo n.º 22
0
#
# GoldenEye: Source's Python Library is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GoldenEye: Source's Python Library.
# If not, see <http://www.gnu.org/licenses/>.
#############################################################################
from . import GEScenario, GEScenarioHelp
from Utils import plural, clamp, choice, _
import GEEntity, GEPlayer, GEUtil, GEMPGameRules, GEGlobal

USING_API = GEGlobal.API_VERSION_1_1_1
EP_SHOUT_COLOR = GEUtil.CColor(240, 200, 120, 170)
FT_DEBUG = False


def ep_incrementscore(player, frags):
    GEMPGameRules.GetTeam(player.GetTeamNumber()).AddRoundScore(frags)
    player.AddRoundScore(frags)
    return player


def ep_naturalsubtraction(value, delta):
    if value > delta:
        return value - delta
    return 0

Exemplo n.º 23
0
    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)
Exemplo n.º 24
0
# along with GoldenEye: Source's Python Library.
# If not, see <http://www.gnu.org/licenses/>.
#############################################################################
import GEUtil, GEMPGameRules as GERules, GEGlobal as Glb
from GEGlobal import EventHooks

# These are in seconds
PREROUND_END_DELAY = 3.5

NOTICE_INTERVAL_LONG = 15.0
NOTICE_INTERVAL_SHORT = 10.0
NOTICE_INTERVAL_TINY = 0.9

CHAN_TIMER = 4

COLOR_TIMER = GEUtil.CColor(255, 255, 255, 255)
COLOR_GETREADY = GEUtil.CColor(255, 255, 255)


class GEWarmUp:
    def __init__(self, parent):
        if not hasattr(parent, 'RegisterEventHook'):
            raise AttributeError("Parent must be a Gameplay Scenario type!")

        parent.RegisterEventHook(EventHooks.GP_THINK, self._think)
        parent.RegisterEventHook(EventHooks.GP_PLAYERCONNECT,
                                 self._player_connect)

        self.keep_weaponset = False
        self.Reset()