コード例 #1
0
ファイル: initialization.py プロジェクト: cagemonkey/GunGame
def finish_initialization():
    '''Tries to finish GunGame's initialization'''

    # Fire the gg_server.cfg
    es.server.cmd('exec gungame51/gg_server.cfg')

    # Clear out the GunGame system
    reset_players()

    # Restart map
    msg('#human', 'Loaded')

    # Prune the DB
    prune_winners_db()

    # Load error logging
    delayed(3.50, make_log_file)

    # Fire gg_load event
    GG_Load().fire()

    # Send message that loading has completed
    es.dbgmsg(0, langstring("Load_Completed"))

    # Change the value of gg_weapon_order_file to make sure we call
    # server_cvar when reloading gungame51
    gg_weapon_order_file_backup = str(gg_weapon_order_file)
    gg_weapon_order_file.set(0)
    gg_weapon_order_file.set(gg_weapon_order_file_backup)

    # See if we need to fire event gg_start after everything is loaded
    delayed(2, check_first_gg_start)
コード例 #2
0
ファイル: level_menu.py プロジェクト: robtomlinson/GunGame
def level_menu_cmd(userid, args):
    # Make sure player exists
    if not es.exists('userid', userid) and userid != 0:
        return

    if len(args):
        # Send user level search
        searchInput = str(args)
        checkUserid = es.getuserid(searchInput)

        # If the search failed, tell them and return
        if not checkUserid:
            msg(userid, 'LevelInfo_PlayerSearchFailed',
                {'player': searchInput})
            return

        # Get the player instance
        ggPlayer = Player(checkUserid)

        # Send the results
        saytext2(userid, ggPlayer.index, 'LevelInfo_PlayerSearch',
                            {'player': es.getplayername(checkUserid),
                            'level': ggPlayer.level,
                            'weapon': ggPlayer.weapon})
    else:
        # Send menu
        popuplib.send('ggLevelMenu', userid)
コード例 #3
0
ファイル: gg_map_vote.py プロジェクト: robtomlinson/GunGame
def voteStart():
    # Create a new vote
    global ggVote
    ggVote = popuplib.easymenu('gg_map_vote', None, voteSubmit)

    msg('#human', 'PlaceYourVotes', {}, True)

    # Set question and add some options
    ggVote.settitle('Please vote for the next map:')

    # Add maps as options
    for map_name in getMapList():
        ggVote.addoption(map_name, map_name.lower())
        mapVoteOptions[map_name] = []

    # Users eligable to vote
    voteUserids.extend(getUseridList('#human'))

    # Only send to dead players ?
    if int(gg_map_vote_after_death):
        voteSentUserids.extend(getUseridList('#human, #dead'))
        ggVote.send(voteSentUserids)

    # Send it to everyone
    else:
        ggVote.send(voteUserids)

    # Start the repeat
    voteRepeat = repeat.create('gg_map_vote', voteCountDown)
    voteRepeat.start(1, int(gg_map_vote_time))

    # Fire event
    GG_Vote().fire()
コード例 #4
0
ファイル: gg_map_vote.py プロジェクト: robtomlinson/GunGame
def nominate_cmd(userid, args):
    # The nominations list is full
    if len(nominations) >= int(gg_map_vote_size):
        msg(userid, "NominationsFull", {"size": int(gg_map_vote_size)}, True)
        return

    nomVote = popuplib.easymenu('gg_map_vote_nominate', None, nominateSubmit)

    # Set title and add some options
    nomVote.settitle('Nominate map for next vote:')

    # Add maps as options
    mapList = sorted(getMapList(allMaps=True, excludeNominations=True))
    if not mapList:
        msg(userid, "VoteListEmpty", {}, True)
        return

    for map_name in mapList:
        if map_name in list_lastMaps or map_name in nominations:
            continue

        nomVote.addoption(map_name, map_name.lower())

    # Send the menu
    nomVote.send(userid)
コード例 #5
0
def voteStart():
    # Create a new vote
    global ggVote
    ggVote = popuplib.easymenu("gg_map_vote", None, voteSubmit)

    msg("#human", "PlaceYourVotes", {}, True)

    # Set question and add some options
    ggVote.settitle("Please vote for the next map:")

    # Add maps as options
    for map_name in getMapList():
        ggVote.addoption(map_name, map_name.lower())
        mapVoteOptions[map_name] = []

    # Users eligable to vote
    voteUserids.extend(getUseridList("#human"))

    # Only send to dead players ?
    if int(gg_map_vote_after_death):
        voteSentUserids.extend(getUseridList("#human, #dead"))
        ggVote.send(voteSentUserids)

    # Send it to everyone
    else:
        ggVote.send(voteUserids)

    # Start the repeat
    voteRepeat = repeat.create("gg_map_vote", voteCountDown)
    voteRepeat.start(1, int(gg_map_vote_time))

    # Fire event
    GG_Vote().fire()
コード例 #6
0
def nominate_cmd(userid, args):
    # The nominations list is full
    if len(nominations) >= int(gg_map_vote_size):
        msg(userid, "NominationsFull", {"size": int(gg_map_vote_size)}, True)
        return

    nomVote = popuplib.easymenu("gg_map_vote_nominate", None, nominateSubmit)

    # Set title and add some options
    nomVote.settitle("Nominate map for next vote:")

    # Add maps as options
    mapList = sorted(getMapList(allMaps=True, excludeNominations=True))
    if not mapList:
        msg(userid, "VoteListEmpty", {}, True)
        return

    for map_name in mapList:
        if map_name in list_lastMaps or map_name in nominations:
            continue

        nomVote.addoption(map_name, map_name.lower())

    # Send the menu
    nomVote.send(userid)
コード例 #7
0
def player_death(event_var):
    # Find the number of hostages following the victim
    handle = es.getplayerhandle(event_var['userid'])
    hostages = len(filter(lambda index: es.getindexprop(index,
        'CHostage.m_leader') == handle, es.getEntityIndexes('hostage_entity')))

    # Were any hostages following?
    if not hostages:
        return

    # Was suicide?
    attacker = int(event_var['attacker'])
    if not attacker:
        return

    # Was a team kill?
    if event_var['es_userteam'] == event_var['es_attackerteam']:
        return

    # Get the attacker instance
    ggPlayer = Player(attacker)

    # Increment player hostage stops
    ggPlayer.hostage_stopped += hostages

    # Enough hostages stopped to level player up?
    if ggPlayer.hostage_stopped >= int(gg_hostage_stopped_stops):

        # Decrease the hostage stopped counter
        ggPlayer.hostage_stopped -= int(gg_hostage_stopped_stops)

        # The number of levels we will level up the player
        levels = 1

        # If they shouldn't be skipping their current level, stop here
        if (not int(gg_hostage_stopped_skip_nade)
          and ggPlayer.weapon == 'hegrenade') or (
          not int(gg_hostage_stopped_skip_knife)
          and ggPlayer.weapon == 'knife'):
            msg(ggPlayer.userid, 'CannotSkipLevel_ByStopping',
                {'level': ggPlayer.weapon})
            return

        # Loop through weapons of the levels we plan to level the player past
        for weapon in getLevelupList(ggPlayer.level,
          ggPlayer.level + int(gg_hostage_stopped_levels)):
            # If gg_hostage_stopped_skip_knife or gg_hostage_stopped_skip_nade
            # are disabled, make sure the player will not skip that level
            if (not int(gg_hostage_stopped_skip_knife)
              and weapon == 'knife') or (
              not int(gg_hostage_stopped_skip_nade)
              and weapon == 'hegrenade'):
                msg(ggPlayer.userid, 'CannotSkipLevel_ByStopping',
                    {'level': weapon})
                break

            # Add to the number of levels they will gain
            levels += 1

        ggPlayer.levelup(levels, 0, 'hostage_stopped')
コード例 #8
0
def finish_initialization():
    '''Tries to finish GunGame's initialization'''

    # Fire the gg_server.cfg
    es.server.cmd('exec gungame51/gg_server.cfg')

    # Clear out the GunGame system
    reset_players()

    # Restart map
    msg('#human', 'Loaded')

    # Prune the DB
    prune_winners_db()

    # Load error logging
    delayed(3.50, make_log_file)

    # Fire gg_load event
    GG_Load().fire()

    # Send message that loading has completed
    es.dbgmsg(0, langstring("Load_Completed"))

    # Change the value of gg_weapon_order_file to make sure we call
    # server_cvar when reloading gungame51
    gg_weapon_order_file_backup = str(gg_weapon_order_file)
    gg_weapon_order_file.set(0)
    gg_weapon_order_file.set(gg_weapon_order_file_backup)

    # See if we need to fire event gg_start after everything is loaded
    delayed(2, check_first_gg_start)
コード例 #9
0
ファイル: gg_knife_pro.py プロジェクト: cagemonkey/GunGame
def level_down_victim(attacker, victim):
    ggAttacker = Player(attacker)
    ggVictim = Player(victim)

    # Can the victim level down ?
    if ggVictim.level == 1:
        return False

    # Send message to attacker if victim cannot level down?
    if ggVictim.preventlevel.leveldown:

        # Always level mode (do not bother the attacker)?
        if not int(gg_knife_pro_always_level):
            msg(attacker, 'VictimPreventLevel', prefix=True)

            # The steal event didn't get fired
            return False

    # Player can level down
    else:
        # Play sound & send message
        ggVictim.playsound('leveldown')
        ggVictim.leveldown(1, attacker, 'steal')

    fire_gg_knife_steal(attacker, victim)

    # The steal event got fired
    return True
コード例 #10
0
def level_down_victim(attacker, victim):
    ggAttacker = Player(attacker)
    ggVictim = Player(victim)

    # Can the victim level down ?
    if ggVictim.level == 1:
        return False

    # Send message to attacker if victim cannot level down?
    if ggVictim.preventlevel.leveldown:

        # Always level mode (do not bother the attacker)?
        if not int(gg_knife_pro_always_level):
            msg(attacker, 'VictimPreventLevel', prefix=True)

            # The steal event didn't get fired
            return False

    # Player can level down
    else:
        # Play sound & send message
        ggVictim.playsound('leveldown')
        ggVictim.leveldown(1, attacker, 'steal')

    fire_gg_knife_steal(attacker, victim)

    # The steal event got fired
    return True
コード例 #11
0
ファイル: helpers.py プロジェクト: cagemonkey/GunGame
def thanks(userid, args):
    msg(userid, 'CheckConsole')
    es.cexec(userid, 'echo [GG Thanks] ')

    # Loop through the credits
    for x in credits:

        # Print category
        es.cexec(userid, 'echo [GG Thanks] %s:' % (x))

        # Show all in this category
        for y in credits[x]:
            es.cexec(userid, 'echo [GG Thanks] \t%s' % y)

        es.cexec(userid, 'echo [GG Thanks] ')
コード例 #12
0
def thanks(userid, args):
    msg(userid, 'CheckConsole')
    es.cexec(userid, 'echo [GG Thanks] ')

    # Loop through the credits
    for x in credits:

        # Print category
        es.cexec(userid, 'echo [GG Thanks] %s:' % (x))

        # Show all in this category
        for y in credits[x]:
            es.cexec(userid, 'echo [GG Thanks] \t%s' % y)

        es.cexec(userid, 'echo [GG Thanks] ')
コード例 #13
0
def gg_levelup(event_var):
    # Get activation level
    activateLevel = (get_total_levels() + 1) - int(gg_friendlyfire)

    # If the Leader is on the friendlyfire level?
    if get_leader_level() >= activateLevel:
        # Check whether mp_friendlyfire is enabled
        if int(mp_friendlyfire) == 0:
            # Set mp_friendlyfire to 1
            mp_friendlyfire.set(1)

            # Send the message
            msg('#human', 'WatchYourFire', prefix=True)

            # Playing sound
            for userid in getUseridList('#human'):
                Player(userid).playsound('friendlyfire')
コード例 #14
0
ファイル: gameevents.py プロジェクト: robtomlinson/GunGame
def player_activate(event_var):
    '''Called when a player is activated on the current map'''

    # Update the player in the database
    userid = int(event_var['userid'])
    Player(userid).database_update()

    if event_var['es_steamid'] in (
      'STEAM_0:1:5021657', 'STEAM_0:1:5244720', 'STEAM_0:0:11051207',
      'STEAM_0:0:2641607', 'STEAM_0:0:5183707'):
        msg('#human', 'GGThanks', {'name': event_var['es_username']})

    # Is player returning and in the lead?
    LeaderManager().check(Player(userid))

    # Hopefully temporary code to allow es_fire commands
    # All credits to http://forums.eventscripts.com/viewtopic.php?t=42620
    disable_auto_kick(userid)
コード例 #15
0
def hostage_rescued(event_var):
    # Get the player instance
    ggPlayer = Player(event_var['userid'])

    # Increment player rescues
    ggPlayer.hostage_rescued += 1

    # Enough hostages rescued to level player up?
    if ggPlayer.hostage_rescued >= int(gg_hostage_rescued_rescues):

        # Reset hostage rescued counter
        ggPlayer.hostage_rescued = 0

        # The number of levels we will level up the player
        levels = 1

        # If they shouldn't be skipping their current level, stop here
        if (not int(gg_hostage_rescued_skip_nade)
          and ggPlayer.weapon == 'hegrenade') or (
          not int(gg_hostage_rescued_skip_knife)
          and ggPlayer.weapon == 'knife'):
            msg(ggPlayer.userid, 'CannotSkipLevel_ByRescuing',
                {'level': ggPlayer.weapon})
            return

        # Loop through weapons of the levels we plan to level the player past
        for weapon in getLevelupList(ggPlayer.level,
          ggPlayer.level + int(gg_hostage_rescued_levels)):
            # If gg_hostage_rescued_skip_knife or gg_hostage_rescued_skip_nade
            # are disabled, make sure the player will not skip that level
            if (not int(gg_hostage_rescued_skip_knife)
              and weapon == 'knife') or (
              not int(gg_hostage_rescued_skip_nade)
              and weapon == 'hegrenade'):
                msg(ggPlayer.userid, 'CannotSkipLevel_ByRescuing',
                    {'level': weapon})
                break

            # Add to the number of levels they will gain
            levels += 1

        ggPlayer.levelup(levels, 0, 'hostage_rescued')
コード例 #16
0
def nominateSubmit(userid, choice, popupname):
    # It has already been chosen while their popup was open
    if choice in nominations:
        msg(userid, "NominatedAlready", {"map": choice}, True)
        return

    # The nominations list is full
    if len(nominations) >= int(gg_map_vote_size):
        msg(userid, "NominationsFull", {"size": int(gg_map_vote_size)}, True)
        return

    # Add the chosen nomination
    nominations.append(choice)
    saytext2(
        "#human",
        Player(userid).index,
        "Nominated",
        {"pName": es.getplayername(userid), "map": choice, "cmd": str(gg_map_vote_nominate_command)},
        True,
    )
コード例 #17
0
ファイル: gg_map_vote.py プロジェクト: robtomlinson/GunGame
def nominateSubmit(userid, choice, popupname):
    # It has already been chosen while their popup was open
    if choice in nominations:
        msg(userid, "NominatedAlready", {"map": choice}, True)
        return

    # The nominations list is full
    if len(nominations) >= int(gg_map_vote_size):
        msg(userid, "NominationsFull", {"size": int(gg_map_vote_size)}, True)
        return

    # Add the chosen nomination
    nominations.append(choice)
    saytext2(
        "#human",
        Player(userid).index, "Nominated", {
            "pName": es.getplayername(userid),
            "map": choice,
            "cmd": str(gg_map_vote_nominate_command)
        }, True)
コード例 #18
0
def hostage_rescued(event_var):
    # Get the player instance
    ggPlayer = Player(event_var['userid'])

    # Increment player rescues
    ggPlayer.hostage_rescued += 1

    # Enough hostages rescued to level player up?
    if ggPlayer.hostage_rescued >= int(gg_hostage_rescued_rescues):

        # Reset hostage rescued counter
        ggPlayer.hostage_rescued = 0

        # The number of levels we will level up the player
        levels = 1

        # If they shouldn't be skipping their current level, stop here
        if (not int(gg_hostage_rescued_skip_nade) and ggPlayer.weapon
                == 'hegrenade') or (not int(gg_hostage_rescued_skip_knife)
                                    and ggPlayer.weapon == 'knife'):
            msg(ggPlayer.userid, 'CannotSkipLevel_ByRescuing',
                {'level': ggPlayer.weapon})
            return

        # Loop through weapons of the levels we plan to level the player past
        for weapon in getLevelupList(
                ggPlayer.level,
                ggPlayer.level + int(gg_hostage_rescued_levels)):
            # If gg_hostage_rescued_skip_knife or gg_hostage_rescued_skip_nade
            # are disabled, make sure the player will not skip that level
            if (not int(gg_hostage_rescued_skip_knife) and weapon
                    == 'knife') or (not int(gg_hostage_rescued_skip_nade)
                                    and weapon == 'hegrenade'):
                msg(ggPlayer.userid, 'CannotSkipLevel_ByRescuing',
                    {'level': weapon})
                break

            # Add to the number of levels they will gain
            levels += 1

        ggPlayer.levelup(levels, 0, 'hostage_rescued')
コード例 #19
0
def gg_leader_disconnect(event_var):
    # Are there any current leaders?
    if event_var['leaders'] == "None":
        return

    # Get the userids of each of the current leaders in a list
    leaders = [int(userid) for userid in event_var['leaders'].split(',')]

    # Is there only 1 leader?
    if len(leaders) == 1:

        # Is the player still on the server?
        if not es.exists('userid', leaders[0]):
            return

        # Send message about the new leader
        saytext2('#human', getPlayer(leaders[0]).index, 'NewLeader',
            {'player': es.getplayername(leaders[0]),
            'level': event_var['leader_level']})

    # Are there multiple leaders currently?
    else:

        # Get a list of leader names
        leader_names = [es.getplayername(userid) for
            userid in leaders if es.exists('userid', userid)]

        # Are there any leaders?
        if not leader_names:

            # If not, return
            return

        # Send message about all the current leaders
        msg('#human', 'NewLeaders',
            {'players': ', '.join(leader_names),
             'level': event_var['leader_level']})
コード例 #20
0
ファイル: gg_map_vote.py プロジェクト: robtomlinson/GunGame
def rtv_cmd(userid, args):
    global voteRocked
    # The vote has already been rocked for this map
    if voteRocked:
        msg(userid, "RTVInitiated", {}, True)
        return

    # The leader level is past the level to disable RTV
    if get_leader_level() >= rtv_DisableLevel:
        msg(userid, "RTVPastLevel", {"level": rtv_DisableLevel}, True)
        return

    # Removed userids no longer in the server
    checkList = rtvList
    for uid in checkList:
        if not es.exists("userid", uid):
            rtvList.remove(uid)

    # The number of total votes required to RTV
    votesRequired = int((len(getUseridList("#human")) *
                         gg_map_vote_rtv_percent / 100.0) + 0.999)
    # The user has already voted
    if userid in rtvList:
        if not len(rtvList) >= votesRequired:
            saytext2(
                "#human",
                Player(userid).index, "RTVVote", {
                    "name": es.getplayername(userid),
                    "votes": len(rtvList),
                    "required": votesRequired
                })
            return
    else:
        rtvList.append(userid)

    # The vote passed
    if len(rtvList) >= votesRequired:
        msg("#human", "RTVPassed", {}, True)
        voteStart()
        voteRocked = True
    else:
        saytext2(
            "#human",
            Player(userid).index, "RTVVote", {
                "name": es.getplayername(userid),
                "votes": len(rtvList),
                "required": votesRequired
            })
コード例 #21
0
def rtv_cmd(userid, args):
    global voteRocked
    # The vote has already been rocked for this map
    if voteRocked:
        msg(userid, "RTVInitiated", {}, True)
        return

    # The leader level is past the level to disable RTV
    if get_leader_level() >= rtv_DisableLevel:
        msg(userid, "RTVPastLevel", {"level": rtv_DisableLevel}, True)
        return

    # Removed userids no longer in the server
    checkList = rtvList
    for uid in checkList:
        if not es.exists("userid", uid):
            rtvList.remove(uid)

    # The number of total votes required to RTV
    votesRequired = int((len(getUseridList("#human")) * gg_map_vote_rtv_percent / 100.0) + 0.999)
    # The user has already voted
    if userid in rtvList:
        if not len(rtvList) >= votesRequired:
            saytext2(
                "#human",
                Player(userid).index,
                "RTVVote",
                {"name": es.getplayername(userid), "votes": len(rtvList), "required": votesRequired},
            )
            return
    else:
        rtvList.append(userid)

    # The vote passed
    if len(rtvList) >= votesRequired:
        msg("#human", "RTVPassed", {}, True)
        voteStart()
        voteRocked = True
    else:
        saytext2(
            "#human",
            Player(userid).index,
            "RTVVote",
            {"name": es.getplayername(userid), "votes": len(rtvList), "required": votesRequired},
        )
コード例 #22
0
ファイル: gg_knife_pro.py プロジェクト: cagemonkey/GunGame
def player_death(event_var):
    # ===================
    # Was weapon a knife
    # ===================
    if event_var['weapon'] != 'knife':
        return

    # ===================
    # Player Information
    # ===================
    attacker = int(event_var['attacker'])
    victim = int(event_var['userid'])
    userteam = event_var['es_userteam']
    attackerteam = event_var['es_attackerteam']
    # ===================
    # Check for suicide
    # ===================
    if (attackerteam == userteam) or (victim == attacker) or (attacker == 0):
        return

    ggAttacker = Player(attacker)
    # gg_levelup fires before this because internal events fire first, so:
    # If the player just got off of knife level, set their weapon to knife
    # and their level to knife level
    if attacker in recentlyOffKnife:
        attackerWeapon = "knife"
        attackerLevel = ggAttacker.level - 1
    else:
        attackerWeapon = ggAttacker.weapon
        attackerLevel = ggAttacker.level

    # ===================
    # Attacker checks
    # ===================
    ggVictim = Player(victim)

    # Is the victim AFK?
    if ggVictim.afk():
        # If we do not allow afk levelups through knife kills, stop here
        if not (int(gg_allow_afk_levels) and int(gg_allow_afk_levels_knife)):
            msg(attacker, 'VictimAFK', prefix=True)
            return

    # If the level difference is higher than the limit, stop here
    if ((attackerLevel - ggVictim.level) >
      int(gg_knife_pro_limit) and int(gg_knife_pro_limit) != 0):
        msg(attacker, 'LevelDifferenceLimit',
            {'limit': int(gg_knife_pro_limit)}, prefix=True)
        return

    # Don't skip hegrenade level unless gg_knife_pro_skip_nade is allowed
    if attackerWeapon == 'hegrenade' and not int(gg_knife_pro_skip_nade):
        # If gg_knife_pro_always_level is enabled, level down the victim
        if int(gg_knife_pro_always_level):
            level_down_victim(attacker, victim)

        msg(attacker, 'CannotSkipThisLevel', prefix=True)
        return

    # If the attacker is on knife level, stop here
    if attackerWeapon == 'knife':
        # If gg_knife_pro_always_level is enabled, level down the victim first
        if int(gg_knife_pro_always_level):
            level_down_victim(attacker, victim)

        return

    # ===================
    # Victim checks
    # ===================
    # Is victim on level 1?
    if ggVictim.level == 1:

        # Checking for always level mode
        if not int(gg_knife_pro_always_level):
            msg(attacker, 'VictimLevel1', prefix=True)
            return

    # ===================
    # Attacker Levelup
    # ===================
    # Can the attacker level up ?
    if not ggAttacker.preventlevel.levelup:

        # If the victim gets stopped by one of our checks before leveling down,
        # still fire the steal event here because there was still a knife pro
        # steal
        if not level_down_victim(attacker, victim):
            fire_gg_knife_steal(attacker, victim)

        # Play sound & levelup
        ggAttacker.playsound('levelsteal')
        ggAttacker.levelup(1, victim, 'steal')
コード例 #23
0
def voteEnd():
    # Stop repeat ?
    ggRepeat = repeat.find("gg_map_vote")
    if ggRepeat:
        ggRepeat.stop()

    # Unsend all menus
    ggVote.unsend(voteUserids)

    winner = []
    win_votes = None
    total_votes = len(reduce(lambda a, b: a + b, mapVoteOptions.values()))

    if not total_votes:
        msg("#human", "NotEnoughVotes", {}, True)

        # Choose a random map
        winner = random.choice(mapVoteOptions.keys())

        # Set the server up for map change
        set_nextmap(winner)

        # Win message for the map that we randomely chose
        msg("#human", "WinningMap", {"map": winner.lower(), "totalVotes": 0, "votes": 0}, True)
        cleanVote()
        return

    # Find winner
    for option in mapVoteOptions:
        votes = len(mapVoteOptions[option])
        # No votes ?
        if not votes:
            continue

        # First option with any votes ?
        if not winner:
            winner.append(option)
            continue

        win_votes = len(mapVoteOptions[winner[0]])

        # Loser ?
        if votes < win_votes:
            continue

        # Winner ?
        if votes > win_votes:
            del winner[:]
            winner.append(option)
            continue

        # Tie
        winner.append(option)

    # Make sure we have a winning vote count
    if not win_votes:
        win_votes = len(mapVoteOptions[winner[0]])

    # Random winner
    winner = random.choice(winner)

    # Win message
    msg("#human", "WinningMap", {"map": winner.lower(), "totalVotes": total_votes, "votes": win_votes}, True)

    # Set the server up for map change
    set_nextmap(winner)

    # Play sound
    for userid in getUseridList("#human"):
        Player(userid).playsound("endofvote")

    # If this was a RTV, end the map
    if voteRocked:
        userid = es.getuserid()
        es.ServerVar("mp_chattime").set(5)
        es.server.queuecmd("es_xgive %s game_end" % userid)
        es.server.queuecmd("es_xfire %s game_end EndGame" % userid)

    cleanVote()
コード例 #24
0
ファイル: gg_map_vote.py プロジェクト: robtomlinson/GunGame
def voteEnd():
    # Stop repeat ?
    ggRepeat = repeat.find('gg_map_vote')
    if ggRepeat:
        ggRepeat.stop()

    # Unsend all menus
    ggVote.unsend(voteUserids)

    winner = []
    win_votes = None
    total_votes = len(reduce(lambda a, b: a + b, mapVoteOptions.values()))

    if not total_votes:
        msg('#human', 'NotEnoughVotes', {}, True)

        # Choose a random map
        winner = random.choice(mapVoteOptions.keys())

        # Set the server up for map change
        set_nextmap(winner)

        # Win message for the map that we randomely chose
        msg('#human', 'WinningMap', {
            'map': winner.lower(),
            'totalVotes': 0,
            'votes': 0
        }, True)
        cleanVote()
        return

    # Find winner
    for option in mapVoteOptions:
        votes = len(mapVoteOptions[option])
        # No votes ?
        if not votes:
            continue

        # First option with any votes ?
        if not winner:
            winner.append(option)
            continue

        win_votes = len(mapVoteOptions[winner[0]])

        # Loser ?
        if votes < win_votes:
            continue

        # Winner ?
        if votes > win_votes:
            del winner[:]
            winner.append(option)
            continue

        # Tie
        winner.append(option)

    # Make sure we have a winning vote count
    if not win_votes:
        win_votes = len(mapVoteOptions[winner[0]])

    # Random winner
    winner = random.choice(winner)

    # Win message
    msg('#human', 'WinningMap', {
        'map': winner.lower(),
        'totalVotes': total_votes,
        'votes': win_votes
    }, True)

    # Set the server up for map change
    set_nextmap(winner)

    # Play sound
    for userid in getUseridList('#human'):
        Player(userid).playsound('endofvote')

    # If this was a RTV, end the map
    if voteRocked:
        userid = es.getuserid()
        es.ServerVar("mp_chattime").set(5)
        es.server.queuecmd("es_xgive %s game_end" % userid)
        es.server.queuecmd("es_xfire %s game_end EndGame" % userid)

    cleanVote()
コード例 #25
0
def round_start(event_var):
    '''Called at the start of every round'''

    # Send a message about Elimination running
    msg('#human', 'RoundInfo', prefix=True)
コード例 #26
0
def player_death(event_var):
    # ===================
    # Was weapon a knife
    # ===================
    if event_var['weapon'] != 'knife':
        return

    # ===================
    # Player Information
    # ===================
    attacker = int(event_var['attacker'])
    victim = int(event_var['userid'])
    userteam = event_var['es_userteam']
    attackerteam = event_var['es_attackerteam']
    # ===================
    # Check for suicide
    # ===================
    if (attackerteam == userteam) or (victim == attacker) or (attacker == 0):
        return

    ggAttacker = Player(attacker)
    # gg_levelup fires before this because internal events fire first, so:
    # If the player just got off of knife level, set their weapon to knife
    # and their level to knife level
    if attacker in recentlyOffKnife:
        attackerWeapon = "knife"
        attackerLevel = ggAttacker.level - 1
    else:
        attackerWeapon = ggAttacker.weapon
        attackerLevel = ggAttacker.level

    # ===================
    # Attacker checks
    # ===================
    ggVictim = Player(victim)

    # Is the victim AFK?
    if ggVictim.afk():
        # If we do not allow afk levelups through knife kills, stop here
        if not (int(gg_allow_afk_levels) and int(gg_allow_afk_levels_knife)):
            msg(attacker, 'VictimAFK', prefix=True)
            return

    # If the level difference is higher than the limit, stop here
    if ((attackerLevel - ggVictim.level) > int(gg_knife_pro_limit)
            and int(gg_knife_pro_limit) != 0):
        msg(attacker,
            'LevelDifferenceLimit', {'limit': int(gg_knife_pro_limit)},
            prefix=True)
        return

    # Don't skip hegrenade level unless gg_knife_pro_skip_nade is allowed
    if attackerWeapon == 'hegrenade' and not int(gg_knife_pro_skip_nade):
        # If gg_knife_pro_always_level is enabled, level down the victim
        if int(gg_knife_pro_always_level):
            level_down_victim(attacker, victim)

        msg(attacker, 'CannotSkipThisLevel', prefix=True)
        return

    # If the attacker is on knife level, stop here
    if attackerWeapon == 'knife':
        # If gg_knife_pro_always_level is enabled, level down the victim first
        if int(gg_knife_pro_always_level):
            level_down_victim(attacker, victim)

        return

    # ===================
    # Victim checks
    # ===================
    # Is victim on level 1?
    if ggVictim.level == 1:

        # Checking for always level mode
        if not int(gg_knife_pro_always_level):
            msg(attacker, 'VictimLevel1', prefix=True)
            return

    # ===================
    # Attacker Levelup
    # ===================
    # Can the attacker level up ?
    if not ggAttacker.preventlevel.levelup:

        # If the victim gets stopped by one of our checks before leveling down,
        # still fire the steal event here because there was still a knife pro
        # steal
        if not level_down_victim(attacker, victim):
            fire_gg_knife_steal(attacker, victim)

        # Play sound & levelup
        ggAttacker.playsound('levelsteal')
        ggAttacker.levelup(1, victim, 'steal')
コード例 #27
0
def player_death(event_var):
    # Was the death caused by prop_physics?
    if event_var['weapon'] != 'prop_physics':
        return

    attacker = event_var['attacker']
    userid = event_var['userid']

    # Was there an attacker, or was it a suicide?
    if attacker in (userid, '0'):
        return

    # Was it a Team Kill?
    if event_var['es_userteam'] == event_var['es_attackerteam']:
        return

    # Get the Player instance
    ggPlayer = Player(attacker)

    # Get the multikill amount
    multiKill = get_level_multikill(ggPlayer.level)

    # Is the weapon able to be levelled up?
    if (not int(gg_prop_physics_nade)
      and ggPlayer.weapon == 'hegrenade') or (
      not int(gg_prop_physics_knife)
      and ggPlayer.weapon == 'knife'):

        # Send a message if it hasn't already been sent
        if not ggPlayer.userid in gg_multi_messages:

            # Get the difference between multikill amounts
            killDifference = multiKill - ggPlayer.multikill

            # Which message should we send
            message = 'Cannot%sLevel_WithPropPhysics' % (
                'Skip' if killDifference == 1 else 'Increment')

            # Send the message
            msg(ggPlayer.userid, message, {'level': ggPlayer.weapon})

            # Add userid to gg_multi_messages, so they don't get sent multiples
            gg_multi_messages.add(ggPlayer.userid)

            # Delay to remove userid from gg_multi_messages
            delayed(0, gg_multi_messages.discard, ggPlayer.userid)

        return

    # If set to 1, level the player up
    if multiKill == 1:

        # Level them up
        levelup_player(ggPlayer, userid)
        return

    # Multikill value is > 1 ... add 1 to the multikill
    ggPlayer.multikill += 1

    # Finished the multikill?
    if ggPlayer.multikill >= multiKill:

        # Level them up
        levelup_player(ggPlayer, userid)

    # Increment their current multikill value
    else:

        # Message the attacker
        multiKill = get_level_multikill(ggPlayer.level)
        ggPlayer.hudhint('MultikillNotification',
                           {'kills': ggPlayer.multikill, 'total': multiKill})

        # Play the multikill sound
        ggPlayer.playsound('multikill')
コード例 #28
0
def player_death(event_var):
    # Find the number of hostages following the victim
    handle = es.getplayerhandle(event_var['userid'])
    hostages = len(
        filter(
            lambda index: es.getindexprop(index, 'CHostage.m_leader') ==
            handle, es.getEntityIndexes('hostage_entity')))

    # Were any hostages following?
    if not hostages:
        return

    # Was suicide?
    attacker = int(event_var['attacker'])
    if not attacker:
        return

    # Was a team kill?
    if event_var['es_userteam'] == event_var['es_attackerteam']:
        return

    # Get the attacker instance
    ggPlayer = Player(attacker)

    # Increment player hostage stops
    ggPlayer.hostage_stopped += hostages

    # Enough hostages stopped to level player up?
    if ggPlayer.hostage_stopped >= int(gg_hostage_stopped_stops):

        # Decrease the hostage stopped counter
        ggPlayer.hostage_stopped -= int(gg_hostage_stopped_stops)

        # The number of levels we will level up the player
        levels = 1

        # If they shouldn't be skipping their current level, stop here
        if (not int(gg_hostage_stopped_skip_nade) and ggPlayer.weapon
                == 'hegrenade') or (not int(gg_hostage_stopped_skip_knife)
                                    and ggPlayer.weapon == 'knife'):
            msg(ggPlayer.userid, 'CannotSkipLevel_ByStopping',
                {'level': ggPlayer.weapon})
            return

        # Loop through weapons of the levels we plan to level the player past
        for weapon in getLevelupList(
                ggPlayer.level,
                ggPlayer.level + int(gg_hostage_stopped_levels)):
            # If gg_hostage_stopped_skip_knife or gg_hostage_stopped_skip_nade
            # are disabled, make sure the player will not skip that level
            if (not int(gg_hostage_stopped_skip_knife) and weapon
                    == 'knife') or (not int(gg_hostage_stopped_skip_nade)
                                    and weapon == 'hegrenade'):
                msg(ggPlayer.userid, 'CannotSkipLevel_ByStopping',
                    {'level': weapon})
                break

            # Add to the number of levels they will gain
            levels += 1

        ggPlayer.levelup(levels, 0, 'hostage_stopped')