Exemplo n.º 1
0
def send_level_info_hudhint(ggPlayer):
    # Get the level, total number of levels and leader level for the hudhint
    level = ggPlayer.level
    totalLevels = get_total_levels()
    leaderLevel = get_leader_level()

    # Create a string for the hudhint
    text = langstring('LevelInfo_CurrentLevel',
                      tokens={
                          'level': level,
                          'total': totalLevels
                      },
                      userid=ggPlayer.userid)

    text += langstring('LevelInfo_CurrentWeapon',
                       tokens={'weapon': ggPlayer.weapon},
                       userid=ggPlayer.userid)
    multiKill = get_level_multikill(level)
    if multiKill > 1:
        text += langstring('LevelInfo_RequiredKills',
                           tokens={
                               'kills': ggPlayer.multikill,
                               'total': get_level_multikill(level)
                           },
                           userid=ggPlayer.userid)

    leaderTokens = {}
    # Choose the leaderString based on the player's leadership status
    if get_leader_count() == 0:
        leaderString = 'LevelInfo_NoLeaders'
    elif is_leader(ggPlayer.userid):
        leaderString = 'LevelInfo_CurrentLeader'
        if get_leader_count() > 1:
            leaderString = 'LevelInfo_AmongstLeaders'
    else:
        leaderString = 'LevelInfo_LeaderLevel'
        leaderTokens = {
            'level': leaderLevel,
            'total': totalLevels,
            'weapon': get_level_weapon(leaderLevel)
        }

    text += langstring(leaderString,
                       tokens=leaderTokens,
                       userid=ggPlayer.userid)

    # Send the level information hudhint
    ggPlayer.hudhint(text)
Exemplo n.º 2
0
def weapons_menu_cmd(userid, args):
    # Make sure player exists
    if not es.exists('userid', userid) and userid != 0:
        return

    weaponOrder = []
    level = 1
    totalLevels = get_total_levels()

    while level <= totalLevels:
        weaponOrder.append(
            "[%s] %s" % (get_level_multikill(level), get_level_weapon(level)))
        level += 1

    # Get the level the player is on
    ggLevel = Player(userid).level

    # Create a new OrderedMenu
    ggWeaponsMenu = OrderedMenu(userid,
                                'GunGame: Weapons Menu',
                                weaponOrder,
                                highlightIndex=ggLevel)

    # Send the OrderedMenu on the page the player's weapon is on
    ggWeaponsMenu.send_page(get_index_page(ggLevel))
Exemplo n.º 3
0
    def check_final_kill(self, userid, weapon):
        '''Checks to see if the kill should end the match'''

        # Is the team on the last level?
        if self.level != get_total_levels():

            # If not, return
            return

        # Is the team on the last multikill for the last level?
        if self.multikill + 1 < get_level_multikill(self.level):

            # If not, return
            return

        # Was the weapon used the last level's weapon?
        if get_level_weapon(self.level) != weapon:

            # If not, return
            return

        # Get the Player instance
        ggPlayer = Player(userid)

        # Is the attacker on the last level?
        if ggPlayer.level != get_total_levels():

            # If not, return
            return

        # End the match
        GG_Team_Win(winner=self.team, loser=5 - self.team).fire()
Exemplo n.º 4
0
    def check_final_kill(self, userid, weapon):
        '''Checks to see if the kill should end the match'''

        # Is the team on the last level?
        if self.level != get_total_levels():

            # If not, return
            return

        # Is the team on the last multikill for the last level?
        if self.multikill + 1 < get_level_multikill(self.level):

            # If not, return
            return

        # Was the weapon used the last level's weapon?
        if get_level_weapon(self.level) != weapon:

            # If not, return
            return

        # Get the Player instance
        ggPlayer = Player(userid)

        # Is the attacker on the last level?
        if ggPlayer.level != get_total_levels():

            # If not, return
            return

        # End the match
        GG_Team_Win(winner=self.team, loser=5 - self.team).fire()
Exemplo n.º 5
0
def multikill_call_back(name, value, ggPlayer):
    # Does the player have a multikill value?
    if not hasattr(ggPlayer, 'multikill'):
        return

    # Is the player a bot?
    if es.isbot(ggPlayer.userid):
        return

    # Did the player just level up?
    if value == 0:
        return

    # Get multikills needed
    multikill = get_level_multikill(ggPlayer.level)

    # Is the player going to level up?
    if value >= multikill:
        return

    # Message the player
    ggPlayer.hudhint('MultikillNotification', {
        'kills': value,
        'total': multikill
    })
Exemplo n.º 6
0
def player_death(event_var):
    attacker = int(event_var['attacker'])

    # Checking if player needs a new nade bonus
    if not check_bonus(attacker):
        return

    # We using a weapon list ?
    if not using_weapon_list():
        return

    weapon = get_weapon(attacker)

    # Was the kill with the bonus gun ?
    if event_var['weapon'] != weapon[0]:
        return

    ggPlayer = Player(attacker)

    # Stop Player at last level ?
    if int(gg_nade_bonus_mode) == 0:

        # Player on last level ?
        if get_total_levels(str(gg_nade_bonus)) == ggPlayer.nadeBonusLevel:
            return

    # Multikil check
    multiKill = get_level_multikill(ggPlayer.nadeBonusLevel,
                                            str(gg_nade_bonus))

    # Checking for multikill level
    if multiKill > 1:

        # Adding kill
        ggPlayer.nadeBonusMulti += 1

        # Level up ?
        if ggPlayer.nadeBonusMulti >= multiKill:

            # Reset multikill count
            ggPlayer.nadeBonusMulti = 0

            # Level up
            ggPlayer.nadeBonusLevel += 1

            # Give new weapon
            give_bonus(attacker, True, True)

        else:
            # Play sound
            ggPlayer.playsound('multikill')

    else:
        # Level up
        ggPlayer.nadeBonusLevel += 1

        # Give new weapon
        give_bonus(attacker, True, True)
Exemplo n.º 7
0
def player_death(event_var):
    attacker = int(event_var['attacker'])

    # Checking if player needs a new nade bonus
    if not check_bonus(attacker):
        return

    # We using a weapon list ?
    if not using_weapon_list():
        return

    weapon = get_weapon(attacker)

    # Was the kill with the bonus gun ?
    if event_var['weapon'] != weapon[0]:
        return

    ggPlayer = Player(attacker)

    # Stop Player at last level ?
    if int(gg_nade_bonus_mode) == 0:

        # Player on last level ?
        if get_total_levels(str(gg_nade_bonus)) == ggPlayer.nadeBonusLevel:
            return

    # Multikil check
    multiKill = get_level_multikill(ggPlayer.nadeBonusLevel,
                                    str(gg_nade_bonus))

    # Checking for multikill level
    if multiKill > 1:

        # Adding kill
        ggPlayer.nadeBonusMulti += 1

        # Level up ?
        if ggPlayer.nadeBonusMulti >= multiKill:

            # Reset multikill count
            ggPlayer.nadeBonusMulti = 0

            # Level up
            ggPlayer.nadeBonusLevel += 1

            # Give new weapon
            give_bonus(attacker, True, True)

        else:
            # Play sound
            ggPlayer.playsound('multikill')

    else:
        # Level up
        ggPlayer.nadeBonusLevel += 1

        # Give new weapon
        give_bonus(attacker, True, True)
Exemplo n.º 8
0
def prep_level_menu(userid, popupid):
    # Make sure the popup exists
    if not popuplib.exists('ggLevelMenu'):
        return

    ggLevelMenu = popuplib.find('ggLevelMenu')
    ggPlayer = Player(userid)

    # Get multikill count for the player's level
    multiKill = get_level_multikill(ggPlayer.level)

    # Use multikill style menu ?
    if multiKill > 1:
        ggLevelMenu.modline(2,
           '   * You are on level %s (%s)' % (ggPlayer.level, ggPlayer.weapon))
        ggLevelMenu.modline(3, '   * You have made %s' % ggPlayer.multikill +
        '/%s of your required kills' % multiKill)

    # Normal style menu
    else:
        ggLevelMenu.modline(2, '   * You are on level %s' % ggPlayer.level)
        ggLevelMenu.modline(3,
                        '   * You need a %s kill to advance' % ggPlayer.weapon)

    # Get leader's level
    leaderLevel = get_leader_level()

    # See if the leader is higher than level 1
    if leaderLevel > 1:

        # See if the player is a leader:
        if is_leader(userid):

            # See if there is more than 1 leader
            if get_leader_count() > 1:
                ggLevelMenu.modline(4,
                        '   * You are currently tied for the leader position')

            # Player is the only leader
            else:
                ggLevelMenu.modline(4, '   * You are currently the leader')

        # This player is not a leader
        else:
            ggLevelMenu.modline(4,
                '   * You are %s level(s)' % (leaderLevel - ggPlayer.level) +
                'behind the leader')

    # There are no leaders
    else:
        ggLevelMenu.modline(4, '   * There currently is no leader')

    # Wins information
    ggLevelMenu.modline(6, '   * You have won %s time(s)' % ggPlayer.wins)
Exemplo n.º 9
0
def send_level_info_hudhint(ggPlayer):
    # Get the level, total number of levels and leader level for the hudhint
    level = ggPlayer.level
    totalLevels = get_total_levels()
    leaderLevel = get_leader_level()

    # Create a string for the hudhint
    text = langstring('LevelInfo_CurrentLevel', tokens={
                            'level': level,
                            'total': totalLevels},
                            userid=ggPlayer.userid)

    text += langstring('LevelInfo_CurrentWeapon', tokens={
                            'weapon': ggPlayer.weapon},
                            userid=ggPlayer.userid)
    multiKill = get_level_multikill(level)
    if multiKill > 1:
        text += langstring('LevelInfo_RequiredKills', tokens={
                            'kills': ggPlayer.multikill,
                            'total': get_level_multikill(level)},
                            userid=ggPlayer.userid)

    leaderTokens = {}
    # Choose the leaderString based on the player's leadership status
    if get_leader_count() == 0:
        leaderString = 'LevelInfo_NoLeaders'
    elif is_leader(ggPlayer.userid):
        leaderString = 'LevelInfo_CurrentLeader'
        if get_leader_count() > 1:
            leaderString = 'LevelInfo_AmongstLeaders'
    else:
        leaderString = 'LevelInfo_LeaderLevel'
        leaderTokens = {'level': leaderLevel,
                    'total': totalLevels,
                    'weapon': get_level_weapon(leaderLevel)}

    text += langstring(leaderString,
        tokens=leaderTokens, userid=ggPlayer.userid)

    # Send the level information hudhint
    ggPlayer.hudhint(text)
Exemplo n.º 10
0
    def increase_multikill(self):
        '''Increases the team's multikill value
            and checks to see if a levelup is needed'''

        # Increase the team's multikill value
        self.multikill += 1

        # Does the team need leveled up?
        if self.multikill >= get_level_multikill(self.level):

            # Increase the team's level
            self.increase_level()

        # Does a message need sent?
        elif int(gg_teamplay_roundend_messages):

            # Send the message
            self.send_increase_multikill_message()
Exemplo n.º 11
0
    def increase_multikill(self):
        '''Increases the team's multikill value
            and checks to see if a levelup is needed'''

        # Increase the team's multikill value
        self.multikill += 1

        # Does the team need leveled up?
        if self.multikill >= get_level_multikill(self.level):

            # Increase the team's level
            self.increase_level()

        # Does a message need sent?
        elif int(gg_teamplay_roundend_messages):

            # Send the message
            self.send_increase_multikill_message()
Exemplo n.º 12
0
    def send_increase_multikill_message(self):
        '''Sends information to chat when a team's multikill increases'''

        # Get the other team's instance
        other = gg_teams[5 - self.team]

        # Is the current team leading?
        if self.level > other.level:

            # Set message name
            message = 'TeamPlay_MultiKill_Leading'

            # Get the level difference
            levels = self.level - other.level

        # Is the current team losing?
        elif self.level < other.level:

            # Set message name
            message = 'TeamPlay_MultiKill_Trailing'

            # Get the level difference
            levels = other.level - self.level

        # Are the teams tied?
        else:

            # Set the message name
            message = 'TeamPlay_MultiKill_Tied'

            # Set the level difference
            levels = 0

        # Send the message to all players
        self.send_all_players_a_message(
            message, {
                'multikill': self.multikill,
                'total': get_level_multikill(self.level),
                'levels': levels,
                'level': self.level,
                'other': other.level
            })
Exemplo n.º 13
0
    def send_increase_multikill_message(self):
        '''Sends information to chat when a team's multikill increases'''

        # Get the other team's instance
        other = gg_teams[5 - self.team]

        # Is the current team leading?
        if self.level > other.level:

            # Set message name
            message = 'TeamPlay_MultiKill_Leading'

            # Get the level difference
            levels = self.level - other.level

        # Is the current team losing?
        elif self.level < other.level:

            # Set message name
            message = 'TeamPlay_MultiKill_Trailing'

            # Get the level difference
            levels = other.level - self.level

        # Are the teams tied?
        else:

            # Set the message name
            message = 'TeamPlay_MultiKill_Tied'

            # Set the level difference
            levels = 0

        # Send the message to all players
        self.send_all_players_a_message(message,
            {'multikill': self.multikill,
             'total': get_level_multikill(self.level), 'levels': levels,
             'level': self.level, 'other': other.level})
Exemplo n.º 14
0
def weapons_menu_cmd(userid, args):
    # Make sure player exists
    if not es.exists('userid', userid) and userid != 0:
        return

    weaponOrder = []
    level = 1
    totalLevels = get_total_levels()

    while level <= totalLevels:
        weaponOrder.append("[%s] %s" % (get_level_multikill(level),
            get_level_weapon(level)))
        level += 1

    # Get the level the player is on
    ggLevel = Player(userid).level

    # Create a new OrderedMenu
    ggWeaponsMenu = OrderedMenu(userid, 'GunGame: Weapons Menu', weaponOrder,
                                                    highlightIndex=ggLevel)

    # Send the OrderedMenu on the page the player's weapon is on
    ggWeaponsMenu.send_page(get_index_page(ggLevel))
Exemplo n.º 15
0
def multikill_call_back(name, value, ggPlayer):
    # Does the player have a multikill value?
    if not hasattr(ggPlayer, 'multikill'):
        return

    # Is the player a bot?
    if es.isbot(ggPlayer.userid):
        return

    # Did the player just level up?
    if value == 0:
        return

    # Get multikills needed
    multikill = get_level_multikill(ggPlayer.level)

    # Is the player going to level up?
    if value >= multikill:
        return

    # Message the player
    ggPlayer.hudhint('MultikillNotification',
        {'kills': value, 'total': multikill})
Exemplo n.º 16
0
    def send_round_start_messages(self):
        '''Sends level info for both teams on round_start'''

        # Set the message type
        message = 'TeamPlay_Round'

        # Get the team's weapon
        weapon = get_level_weapon(self.level)

        tokens = {'level': self.level, 'weapon': weapon}

        # Get the team's current level's multikill
        multikill = get_level_multikill(self.level)

        # Is the needed multikill > 1?
        if multikill > 1:

            # Set the message type to use multikill
            message += '_Multikill'

            # Add multikill values to the tokens
            tokens.update({'multikill': self.multikill, 'needed': multikill})

        self.send_all_players_a_message(message, tokens)
Exemplo n.º 17
0
    def send_round_start_messages(self):
        '''Sends level info for both teams on round_start'''

        # Set the message type
        message = 'TeamPlay_Round'

        # Get the team's weapon
        weapon = get_level_weapon(self.level)

        tokens = {'level': self.level, 'weapon': weapon}

        # Get the team's current level's multikill
        multikill = get_level_multikill(self.level)

        # Is the needed multikill > 1?
        if multikill > 1:

            # Set the message type to use multikill
            message += '_Multikill'

            # Add multikill values to the tokens
            tokens.update({'multikill': self.multikill, 'needed': multikill})

        self.send_all_players_a_message(message, tokens)
Exemplo n.º 18
0
def player_death(event_var):
    '''Called every time a player dies'''

    # Is the round active?
    if not ActiveInfo.round:

        # If not, do nothing
        return

    # Set player ids
    userid = int(event_var['userid'])
    attacker = int(event_var['attacker'])

    # Is the attacker on the server?
    if not es.exists('userid', attacker):
        return

    # Suicide check
    if (attacker == 0 or attacker == userid):
        return

    # TEAM-KILL CHECK
    if (event_var['es_userteam'] == event_var['es_attackerteam']):
        return

    # Get victim object
    ggVictim = Player(userid)

    # Get attacker object
    ggAttacker = Player(attacker)

    # Check the weapon was correct (Normal Kill)
    if event_var['weapon'] != ggAttacker.weapon:
        return

    # Don't continue if the victim is AFK
    if not int(gg_allow_afk_levels):

        # Make sure the victim is not a bot
        if not es.isbot(userid):

            # Is AFK ?
            if ggVictim.afk():

                # Is their weapon an hegrenade
                # and do we allow AFK leveling?
                if (ggAttacker.weapon == 'hegrenade' and
                  int(gg_allow_afk_levels_nade)):

                    # Pass if we are allowing AFK leveling on nade level
                    pass

                # Is their weapon a knife and do we allow AFK leveling?
                elif (ggAttacker.weapon == 'knife' and
                  int(gg_allow_afk_levels_knife)):

                    # Pass if we are allowing AFK leveling on knife level
                    pass

                # None of the above checks apply --- continue with hudhint
                else:

                    # Make sure the attacker is not a bot
                    if es.isbot(attacker):
                        return

                    # Tell the attacker they victim was AFK
                    ggAttacker.hudhint(
                        'PlayerAFK', {'player': event_var['es_username']})
                    return

    # Get the current level's multikill value
    multiKill = get_level_multikill(ggAttacker.level)

    # If set to 1, level the player up
    if multiKill == 1:
        # Level them up
        ggAttacker.levelup(1, userid, 'kill')

        return

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

    # Finished the multikill
    if ggAttacker.multikill >= multiKill:

        # Level them up
        ggAttacker.levelup(1, userid, 'kill')

    # Increment their current multikill value
    else:

        # Play the multikill sound
        ggAttacker.playsound('multikill')
Exemplo n.º 19
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')