Beispiel #1
0
    def OnPlayerKilled( self, victim, killer, weapon ):
        # Let the base scenario behavior handle scoring so we can just worry about the gun swap mechanics.
        GEScenario.OnPlayerKilled( self, victim, killer, weapon )
        
        if not victim:
            return

        if killer and victim != killer:
            # Normal kill

            # Equip new weapons
            wepname = weapon.GetClassname().lower()

            if (wepname == "weapon_slappers" or wepname == "trigger_trap"): #Slapper kills replace the victim's weapon with a random new one.
                self.gt_SubSwapWeapon( killer, victim )
            elif wepname == "player" and self.gt_GetWeaponTierOfPlayer(victim) >= self.gt_GetWeaponTierOfPlayer(killer): #Killbind greifing protection, lower tiers are better.
                self.gt_SubSwapWeapon( killer, victim )
            else:
                self.gt_SwapWeapons( killer, victim ) #Normal swap.    

            #Killer ID, Victim ID, Weapon Killer Traded Away, Weapon Victim Traded Away
            GEUtil.EmitGameplayEvent( "gt_weaponswap" , str( killer.GetUserID()), str( victim.GetUserID() ), weaponList[ self.pltracker[victim][TR_WEPINDEX] ], weaponList[ self.pltracker[killer][TR_WEPINDEX] ], True )

            self.gt_SpawnWeapon( killer ) # Only killer gets their weapon right now.
            
            GEUtil.PlaySoundTo( victim, "GEGamePlay.Woosh" )
            GEUtil.PlaySoundTo( killer, "GEGamePlay.Woosh" )

        victim.StripAllWeapons() # Victim always loses their weapons so they never drop anything, as there are no weapon pickups in this mode.
 def giveSkip(self, player):
     if self.playerTracker.GetValue(player, self.USED_SKIP):
         self.playerTracker.SetValue(player, self.USED_SKIP, False)
         GEUtil.EmitGameplayEvent("cr_restoredskip",
                                  "%i" % player.GetUserID())
         GEUtil.PlaySoundToPlayer(player, "GEGamePlay.Token_Chime", True)
         self.showSkipText(player)
Beispiel #3
0
 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)
Beispiel #4
0
 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.")
Beispiel #5
0
    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")
Beispiel #6
0
    def OnLoadGamePlay(self):
        # Pre-cache the popped a cap sound
        GEUtil.PrecacheSound(
            "GEGamePlay.Token_Grab")  # sound for popping the cap
        GEUtil.PrecacheSound(
            "GEGamePlay.Level_Down")  # sound for becoming the victim

        self.CreateCVar(
            "pac_reduced_damage", "1",
            "Reduces the damage to non-victim players by 99% (0 to disable, 1 to enable)"
        )
        self.CreateCVar(
            "pac_survive_time", "30",
            "The amount of time in seconds the victim should survive before being awarded a point "
            "(default=30, range 5 - 60)")
        self.CreateCVar(
            "pac_victim_scoring", "1",
            "Enables the victim to score (all kills score) (1 to enable, 0 to disable)"
        )
        self.CreateCVar(
            "pac_classic_mode", "0",
            "Enables the original Perfect Dark Settings (ie: 1 minute survive timer, normal damage, and "
            "death match scoring [all kills score]. Overrides Timer and Reduced Damage settings)"
        )

        # Make sure we don't start out in wait time or have a warmup if we changed gameplay mid-match
        if GERules.GetNumActivePlayers() > 1:
            self.waitingForPlayers = False
            self.warmupTimer.StartWarmup(0)
Beispiel #7
0
    def OnPlayerKilled(self, victim, killer, weapon):
        if self.WaitingForPlayers or self.warmupTimer.IsInWarmup(
        ) or GERules.IsIntermission() or not victim:
            return

        kL = self.ar_GetLevel(killer)
        vL = self.ar_GetLevel(victim)

        # Convert projectile entity names to their corresponding weapon
        name = weapon.GetClassname().lower()
        if name.startswith("npc_"):
            if name == "npc_grenade":
                name = "weapon_grenade"
            elif name == "npc_rocket":
                name = "weapon_rocket_launcher"
            elif name == "npc_shell":
                name = "weapon_grenade_launcher"
            elif name == "npc_mine_remote":
                name = "weapon_remotemine"
            elif name == "npc_mine_timed":
                name = "weapon_timedmine"
            elif name == "npc_mine_proximity":
                name = "weapon_proximitymine"

        if not killer or victim == killer:
            # World kill or suicide
            self.ar_IncrementKills(victim, -1)
        else:
            # Normal kill
            if name == "weapon_slappers" or name == "player":  # Slappers or killbind.
                self.ar_IncrementLevel(victim, -1)
                if vL > 0:
                    self.ar_IncrementLevel(
                        killer, 1
                    )  # Jump forward an entire level, keeping our kill count.
                    msg = _("#GES_GP_GUNGAME_SLAPPED",
                            victim.GetCleanPlayerName(),
                            killer.GetCleanPlayerName())
                    GEUtil.PostDeathMessage(msg)
                    GEUtil.EmitGameplayEvent("ar_levelsteal",
                                             str(killer.GetUserID()),
                                             str(victim.GetUserID()), "", "",
                                             True)  #Acheivement event
                else:
                    msg = _("#GES_GP_GUNGAME_SLAPPED_NOLOSS",
                            killer.GetCleanPlayerName())
                    GEUtil.PostDeathMessage(msg)
                    self.ar_IncrementKills(
                        killer, 1
                    )  # We can't steal a whole level but we can at least get a kill.

                killer.SetArmor(int(Glb.GE_MAX_ARMOR))
            elif maxLevel == self.ar_GetLevel(killer):
                self.ar_IncrementLevel(killer,
                                       1)  # Final level only needs one kill.
            else:
                self.ar_IncrementKills(killer, 1)

        victim.StripAllWeapons(
        )  # This prevents the victim from dropping weapons, which might confuse players since there are no pickups.
Beispiel #8
0
    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)
Beispiel #9
0
    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()
Beispiel #10
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

        # 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)
Beispiel #11
0
    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)
Beispiel #12
0
    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)
Beispiel #13
0
 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:
         if self.rules_allowToss:
             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)
             else:
                 GEUtil.HudMessage(player, "#GES_GP_CTK_TOKEN_DROP_NOFLAG",
                                   -1, self.MSG_MISC_YPOS,
                                   self.COLOR_NEUTRAL, 2.0,
                                   self.MSG_MISC_CHANNEL)
         else:
             GEUtil.HudMessage(player, "#GES_GP_CTK_TOKEN_DROP_DISABLED",
                               -1, self.MSG_MISC_YPOS, self.COLOR_NEUTRAL,
                               2.0, self.MSG_MISC_CHANNEL)
         return True
     return False
Beispiel #14
0
    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

        victimTeam = victim.GetTeamNumber()
        killerTeam = killer.GetTeamNumber(
        ) if killer else -1  # Only need to do this for killer since not having a victim aborts early.

        # death by world
        if not killer:
            victim.AddRoundScore(-1)
        elif 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).  We know we have a killer and a victim but there might not be a weapon.
            if victim == self.game_tokens[victimTeam].GetOwner():
                clr_hint = '^i' if killerTeam == Glb.TEAM_MI6 else '^r'
                GEUtil.EmitGameplayEvent(
                    "ctf_tokendefended", str(killer.GetUserID()),
                    str(victim.GetUserID()), str(victimTeam),
                    weapon.GetClassname().lower() if weapon else "weapon_none",
                    True)
                GEUtil.PostDeathMessage(
                    _("#GES_GP_CTK_DEFENDED", clr_hint,
                      killer.GetCleanPlayerName(),
                      self.ctk_TokenName(victimTeam)))
                killer.AddRoundScore(2)
            else:
                killer.AddRoundScore(1)
Beispiel #15
0
    def lld_embaron_randomly(self):
        if self.lld_num_inround_players() < 2:
            return

        only_inround = lambda x: x.get(TR_INROUND, False)
        player_slice = self.pltracker.Slice(TR_TICKETS, only_inround)

        # Figure out our smallest held ticket count
        player_slice = sorted(player_slice, key=lambda x: x[1])
        #player_slice = sorted( player_slice, key=lambda x, y: cmp( x[1], y[1] ) )
        min_tickets = player_slice[0][1]

        # Remove all players with more than the minimum ticket count and the current baron
        # this ensures that everyone gets to play as the baron during the course of a match
        candidates = [
            x for x, y in player_slice
            if y == min_tickets and x != self.baron_uid
        ]

        if len(candidates) == 0:
            # Failure case, should never happen
            GEUtil.Warning(
                "[LALD] Failed to pick a baron due to lack of candidates!\n")
            return

        if LLD_DEBUG:
            GEUtil.Msg(
                "[LALD] Picking a baron from %i candidates with ticket count %i!\n"
                % (len(candidates), min_tickets))

        # Randomly choose the next Baron!
        self.lld_embaron(random.choice(candidates))
Beispiel #16
0
    def OnPlayerKilled(self, victim, killer, weapon):
        if self.warmupTimer.IsInWarmup(
        ) or self.WaitingForPlayers or not victim:
            return
        else:
            if self.isBoris(victim):
                victim.AddRoundScore(-5)
                GEUtil.EmitGameplayEvent("iami_boris_suicide",
                                         "%i" % victim.GetUserID())
            else:
                GEUtil.EmitGameplayEvent("iami_killed_by_boris",
                                         "%i" % victim.GetUserID())
                GEUtil.EmitGameplayEvent("iami_boris_kills",
                                         "%i" % victim.GetUserID())
                GEScenario.OnPlayerKilled(self, victim, killer, weapon)
                weaponName = weapon.GetClassname().replace('weapon_',
                                                           '').lower()

                if self.isBoris(killer) and (weaponName == "slappers"
                                             or weaponName == "knife"):
                    GEUtil.PlaySoundToPlayer(killer, self.soundSpeedBoost,
                                             False)
                    self.timerBorisSpeedBoost = self.timerBorisSpeedBoostMax
                    GEUtil.EmitGameplayEvent("iami_boris_slap_kill",
                                             "%i" % killer.GetUserID())
                    if not self.isBorisSpeedBoosted:
                        self.isBorisSpeedBoosted = True
                        killer.SetSpeedMultiplier(self.speedBoostMultiplier)
	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
Beispiel #18
0
    def CalculateCustomDamage(self, victim, info, health, armor):
        attacker = GEPlayer.ToMPPlayer(info.GetAttacker())

        if self.isBoris(victim) and self.isExplosiveDamage(info):
            if self.isBoris(attacker):
                health = health * self.borisSelfDamageMultiplier
                armor = armor * self.borisSelfDamageMultiplier
            # We ignore the damage reduction for direct-hit explosions
            elif health + armor != 398.0:
                health = health * self.explosionDamageMultiplier
                armor = armor * self.explosionDamageMultiplier

        if self.isBoris(victim) and attacker and not self.isBoris(attacker):
            damageTotal = self.playerTracker.GetValue(attacker,
                                                      self.PLAYER_BORIS_DAMAGE)
            damageTotal += min(health + armor, self.breakpointDamage)

            if damageTotal >= self.breakpointDamage:
                damageTotal -= self.breakpointDamage
                attacker.AddRoundScore(1)
                GEMPGameRules.GetTeam(GEGlobal.TEAM_MI6).IncrementRoundScore(1)
                GEUtil.PlaySoundToPlayer(attacker, self.soundPoint, False)
                GEUtil.EmitGameplayEvent("iami_damage_point",
                                         "%i" % attacker.GetUserID())
            self.playerTracker.SetValue(attacker, self.PLAYER_BORIS_DAMAGE,
                                        damageTotal)
            health = 0
            armor = 0

        if self.identifyWeapon(info) == "weapon_slappers" and self.isBoris(
                attacker):
            health = 1000
            armor = 1000

        return health, armor
Beispiel #19
0
    def OnLoadGamePlay(self):
        global weaponList

        GEUtil.PrecacheSound("GEGamePlay.Token_Drop_Enemy")
        GEUtil.PrecacheSound("GEGamePlay.Token_Grab")
        GEUtil.PrecacheSound("GEGamePlay.Token_Grab_Enemy")

        self.CreateCVar(
            "ar_lowestlevel", "1",
            "Give new players the lowest active player's level. (Use 0 to start new players at level 1)"
        )
        self.CreateCVar("ar_warmuptime", "20",
                        "The warmup time in seconds. (Use 0 to disable)")
        self.CreateCVar(
            "ar_numrounds", "3",
            "The number of rounds that should be played per map. (Use 0 to play until time runs out, Max is 10)"
        )
        self.CreateCVar("ar_randomweapons", "0",
                        "Randomize the weapons every round.")

        # Make sure we don't start out in wait time if we changed gameplay mid-match
        if GERules.GetNumActivePlayers() >= 2:
            self.WaitingForPlayers = False

        # Restore the default weapon list
        if weaponList != weaponListCopy:
            weaponList = list(weaponListCopy)
Beispiel #20
0
    def yolt_UpdateTimer( self, playercount, onlydecrease = False ):
        playertime = int( GEUtil.GetCVarValue( "yolt_timeperplayer" ) )
        basetime = int( GEUtil.GetCVarValue( "yolt_basetime" ) )

        #Dynamic timer disabled.
        if playertime == 0 and basetime == 0:
            return

        #Setting unlimited time, which we have to do here instead of directly so we don't mess with static roundtimes.
        if playercount == 0:
            GERules.SetRoundTimeLeft(0)
            GERules.AllowRoundTimer( False ) # We do both of these so it hides the match timer and flashes green when the time is started.
            return

        GERules.AllowRoundTimer( True ) # Reenable it now that the timer is started again.
        newtime = basetime + playercount * playertime

        #Make sure we're decreasing and not increasing the roundtime if we want to avoid doing that.
        if onlydecrease:
            timeleft = int(GERules.GetRoundTimeLeft())

            if (timeleft > newtime):
                GERules.SetRoundTimeLeft(newtime)
        else:
            GERules.SetRoundTimeLeft(newtime)
Beispiel #21
0
    def OnLoadGamePlay(self):
        GEUtil.PrecacheSound(
            "GEGamePlay.Token_Drop_Enemy")  # Used for final weapon.
        GEUtil.PrecacheSound(
            "GEGamePlay.Level_Up")  # Plays when level is gained
        GEUtil.PrecacheSound(
            "GEGamePlay.Level_Down")  # Plays when level is lost

        self.CreateCVar(
            "ar_lowestlevel", "1",
            "Give new players the lowest active player's level. (Use 0 to start new players at level 1)"
        )
        self.CreateCVar("ar_warmuptime", "15",
                        "The warmup time in seconds. (Use 0 to disable)")
        self.CreateCVar(
            "ar_killsperlevel", "2",
            "How many kills is required to level up to the next weapon.")

        # Make sure we don't start out in wait time or have a warmup if we changed gameplay mid-match
        if GERules.GetNumActivePlayers() >= 2:
            self.WaitingForPlayers = False
            self.warmupTimer.StartWarmup(0)

        GERules.EnableSuperfluousAreas()
        GERules.EnableInfiniteAmmo()
Beispiel #22
0
    def yolt_InitFoes( self ):
        if self.game_foes_orig != 0:
            # We are already init'd
            return
        
        if GERules.IsTeamplay():
            mi6_count = GERules.GetNumInRoundTeamPlayers( Glb.TEAM_MI6 )
            janus_count = GERules.GetNumInRoundTeamPlayers( Glb.TEAM_JANUS )
            self.game_foes_orig = mi6_count + janus_count
            self.game_MI6_foes_orig = mi6_count
            self.game_Janus_foes_orig = janus_count
            self.game_foes = [mi6_count, janus_count]
            playercount = min(mi6_count, janus_count) * 2
            # Display the foes progress bars (note color and values are swapped since these are "foes")
            GEUtil.InitHudProgressBar( Glb.TEAM_MI6_NO_OBS, 0, "#GES_GP_FOES", Glb.HUDPB_SHOWVALUE, janus_count, -1, 0.02, 0, 10, CLR_JANUS_BAR, janus_count )
            GEUtil.InitHudProgressBar( Glb.TEAM_JANUS_NO_OBS, 0, "#GES_GP_FOES", Glb.HUDPB_SHOWVALUE, mi6_count, -1, 0.02, 0, 10, CLR_MI6_BAR, mi6_count )
        else:
            # DM foes is just a number
            self.game_foes_orig = GERules.GetNumInRoundPlayers()
            playercount = self.game_foes_orig
            # Subtract one because we don't count the local player as a "foe"
            GEUtil.InitHudProgressBar( Glb.TEAM_NO_OBS, 0, "#GES_GP_FOES", Glb.HUDPB_SHOWVALUE, self.game_foes_orig - 1, -1, 0.02, 0, 10, CLR_DM_BAR, self.game_foes_orig - 1 )
            # Copy our origin into the tracker
            self.game_foes = self.game_foes_orig

        for player in GetPlayers():
            if not self.pltracker[player][TR_ELIMINATED]:
                self.pltracker[player][TR_WASINPLAY] = True

        self.yolt_UpdateTimer( playercount )
        
        # Initialize observer bars
        self.yolt_InitObserverBars( Glb.TEAM_OBS )
Beispiel #23
0
    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)
Beispiel #24
0
    def yolt_InitObserverBars( self, player ):
        if not GERules.IsRoundLocked():
            self.yolt_InitOpenroundBars()
            return
        
        # We don't init if there are no foes
        if not self.game_foes:
            return

        if self.yolt_IsShowdown():
            self.yolt_InitShowdownBars()
            return

        # Remove latent bars
        GEUtil.RemoveHudProgressBar( player, 0 )
        GEUtil.RemoveHudProgressBar( player, 1 )

        # Initialize and update
        if GERules.IsTeamplay():
            GEUtil.InitHudProgressBar( player, 0, "##TEAM_MI6: ", Glb.HUDPB_SHOWVALUE, self.game_MI6_foes_orig, 0.35, 0.14, 0, 10, CLR_MI6_BAR, self.game_foes[0] )
            GEUtil.InitHudProgressBar( player, 1, "##TEAM_JANUS: ", Glb.HUDPB_SHOWVALUE, self.game_Janus_foes_orig, 0.5, 0.14, 0, 10, CLR_JANUS_BAR, self.game_foes[1] )
        else:
            foes_orig = self.game_foes_orig
            if self.pltracker.GetValue( player, TR_WASINPLAY, False ):
                # Previously in-game players see a different original foes count
                foes_orig -= 1
                
            
            GEUtil.InitHudProgressBar( player, 0, "#GES_GP_FOES", Glb.HUDPB_SHOWVALUE, foes_orig, -1, 0.14, 0, 10, CLR_DM_BAR, self.game_foes )
Beispiel #25
0
 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
Beispiel #26
0
 def OnPlayerKilled(self, victim, killer, weapon):
     if victim == None:
         return
     if self.baron_uid != 0 and self.lld_player_isbaron(victim):
         # Baron died
         if killer == None or victim == killer:
             self.lld_eliminateplayer(victim)
             self.lld_misix_jackpot()
         elif not self.pltracker[self.baron_uid][TR_INROUND]:
             killer.AddRoundScore(self.bounty)
     else:
         # Player died
         if killer == None or victim == killer:
             # Eliminated by suicide, penalized
             self.lld_eliminateplayer(victim)
             victim.AddRoundScore(-self.lld_num_inround_players() + 1)
             baronid = self.lld_Baron().GetUserID() if (
                 self.lld_Baron()) else -1
             GEUtil.EmitGameplayEvent("lald_eliminated",
                                      str(victim.GetUserID()), str(baronid),
                                      "suicide")
         elif self.lld_player_isbaron(killer):
             killer.AddRoundScore(1)
             self.baron_frags += 1
             self.lld_eliminateplayer(victim)
             baronid = self.lld_Baron().GetUserID() if (
                 self.lld_Baron()) else -1
             GEUtil.EmitGameplayEvent("lald_eliminated",
                                      str(victim.GetUserID()), str(baronid),
                                      "baronkill")
Beispiel #27
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()
Beispiel #28
0
    def lld_baron_usevoodoo(self):
        baron = self.lld_Baron()
        if baron:
            if self.baron_voodoo_recharge == 0 and self.result == self.RESULT_NONE and not baron.IsDead(
            ):
                if self.baron_voodoo > 0:
                    # Kick off the particle effect FIRST, when we revisit from OnThink we will actually teleport
                    if self.hack_voodoodelay == 0:
                        self.hack_voodoodelay = 1
                        GEUtil.ParticleEffect(baron, "eyes",
                                              "ge_baron_teleport", False)
                        return

                    # Now we can actually teleport
                    self.hack_voodoodelay = 0
                    self.baron_voodoo = max(
                        0, self.baron_voodoo - self.BARON_VOODOO_COST)
                    self.baron_voodoo_recharge = self.BARON_VOODOO_RECHARGE
                    self.baron_health_cache = baron.GetHealth(
                    ) + self.BARON_SPAWN_RECOVER
                    # Upgrade the baron's weapons
                    self.lld_baron_levelup()
                    self.lld_baron_update_voodoobar()
                    # Play the voodoo laugh
                    GEUtil.PlaySoundTo(None, "GEGamePlay.Baron_Voodoo", True)
                    # Force the respawn
                    baron.ForceRespawn()
                else:
                    # We have no power left, fall through to below
                    GEUtil.HudMessage(self.lld_Baron(), "#GES_GP_LALD_NOPOWER",
                                      -1, -1, EP_SHOUT_COLOR, 2.0)
Beispiel #29
0
    def CreateNPC( self, ident, parent ):
        tmp = FindModule( Ai, ident )
        if not tmp:
            GEUtil.DevWarning( "Failed to find npc %s!\n" % ident )
            return None
        else:
            ident = tmp
            module = "Ai.%s" % ident
            npc = None

            try:
                # Try to load immediately, fallback to import if new class
                npc = getattr( sys.modules[module], ident )( parent )
                print( "Loading NPC %s from cache" % ident )
            except KeyError:
                try:
                    __import__( module, globals(), locals() )

                    npc = getattr( sys.modules[module], ident )( parent )

                    print( "Loading NPC %s from disk" % ident )

                except ImportError:
                    PrintError( "Failed to load NPC %s\n" % ident )

            if npc:
                # Make sure we are using the proper API!
                if not CheckAPI( sys.modules[module], GEGlobal.API_AI_VERSION ):
                    GEUtil.Warning( "Ai load FAILED due to API mismatch.\n" )
                    return None

                # Load any custom schedules defined by the npc
                self.LoadSchedules( npc )

            return npc
Beispiel #30
0
    def Start(self, npc, data):
        from Ai import PYBaseNPC, AiSystems

        assert isinstance(npc, PYBaseNPC)

        if data <= 0:
            data = 512

        # grab weapons nearby (this searches for dropped weapons which don't show up in itemTracker by default)
        weaponsNearby = GEEntity.GetEntitiesInBox(
            "weapon_*", npc.GetAbsOrigin(), GEUtil.Vector(-data, -data, -10),
            GEUtil.Vector(data, data, 120))

        # combine that list of weapons with the item tracker's list
        weapons = list(set(GetScenario().itemTracker.weapons + weaponsNearby))

        if len(weapons) > 0:
            bestChoice = None

            # find closest weapon
            for weapon in weapons:
                if npc.GetSystem(AiSystems.WEAPONS).WantsWeapon(
                        weapon, bestChoice):
                    bestChoice = weapon

            if bestChoice != None:
                # target closest weapon
                npc.SetTarget(bestChoice)
                self.Complete(npc)
                return

        # We failed to find anything, fail the task
        npc.TaskFail(GEAiTasks.TaskFail.NO_TARGET)