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()
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))
def gg_start(event_var): global played_knife global played_nade global knife_level global nade_level # Reset the globals when GG starts played_knife = False played_nade = False nade_level = 0 knife_level = 0 # Loop through all levels for level in xrange(1, get_total_levels() + 1): # Get the weapon for the current level weapon = get_level_weapon(level) # Is the weapon hegrenade? if weapon == 'hegrenade': # Each time hegrenade is found, change nade_level so # that nade_level ends up being the last hegrenade level nade_level = level # Is the weapon knife? if weapon == 'knife': # Each time knife is found, change knife_level so # that knife_level ends up being the last knife level knife_level = level
def increase_level(self): '''Increases the team's level and levels up all team memebers''' # Reset the team's multikill value self.multikill = 0 # Increase the team's level self.level += 1 # Did the team just win? if self.level > get_total_levels(): GG_Team_Win(winner=self.team, loser=5 - self.team).fire() # Do not send messages or increase player levels return # Fire GG_Team_LevelUp GG_Team_LevelUp(team=self.team, old_level=self.level - 1, new_level=self.level).fire() # Loop through all team members for userid in self.team_players: # Set the player's level to the team level self.set_player_level(userid)
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)
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)
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')
def getLevelupList(currentLevel, levelupLevel): levelupList = [] # Get the total number of levels totalLevels = get_total_levels() # If the player would exceed the total number of levels, stop at the total if levelupLevel > totalLevels: levelupLevel = totalLevels # Create a list of the weapon names for levels we plan to level the player # up past for level in xrange(currentLevel + 1, levelupLevel): levelupList.append(get_level_weapon(level)) # Return the list return levelupList
def gg_levelup(event_var): global voteHasStarted # Vote has allready been started? if voteHasStarted: return # Start vote ? if get_leader_level() < (get_total_levels() - int(gg_map_vote_trigger)): return # Change global so we dont fire the vote twice voteHasStarted = True # Use 3rd party voting system ? if int(gg_map_vote) > 1: es.server.queuecmd(str(gg_map_vote_command)) return voteStart()
def server_cvar(event_var): cvar_name = event_var["cvarname"] cvar_value = event_var["cvarvalue"] # If the weapon order changed, get the new rtv_DisableLevel if cvar_name in ["gg_weapon_order_file", "gg_weapon_order_sort_type"]: global rtv_DisableLevel rtv_DisableLevel = get_total_levels() * gg_map_vote_rtv_levels_required / 100 # Register RTV commmands? if cvar_name == "gg_map_vote_rtv": # Register RTV and nomination commands if int(cvar_value): registerSayCommand(str(gg_map_vote_rtv_command), rtv_cmd, "" + "RTV command.") registerSayCommand(str(gg_map_vote_nominate_command), nominate_cmd, "Nominate command.") # Unregister RTV and nomination commands else: unregisterSayCommand(str(gg_map_vote_rtv_command)) unregisterSayCommand(str(gg_map_vote_nominate_command))
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)
def give_weapon(userid, previousLevel): if not es.exists('userid', userid) and userid != 0: return # Is spectator? if es.getplayerteam(userid) < 2: return # Get playerlib object pPlayer = getPlayer(userid) # Is player dead? if pPlayer.isdead: return # Give them their next weapon ggPlayer = Player(userid) ggPlayer.give_weapon() # If previousLevel is not in the order due to weapon orders changing, # stop here if previousLevel > get_total_levels(): return weapsToStrip = [get_level_weapon(previousLevel)] # If the player is was on hegrenade level, and gg_nade_bonus is enabled, # and the current level is not hegrenade as well, get the list of their # bonus weapons if (weapsToStrip[0] == "hegrenade" and str(gg_nade_bonus) != "0" and ggPlayer.weapon != "hegrenade"): weapsToStrip.extend(get_weapon(userid)) # If any weapons to be removed were just given, do not strip them if ggPlayer.weapon in weapsToStrip: weapsToStrip.remove(ggPlayer.weapon) # Strip the previous weapons ggPlayer.strip_weapons(weapsToStrip)
def server_cvar(event_var): cvar_name = event_var['cvarname'] cvar_value = event_var['cvarvalue'] # If the weapon order changed, get the new rtv_DisableLevel if cvar_name in ['gg_weapon_order_file', 'gg_weapon_order_sort_type']: global rtv_DisableLevel rtv_DisableLevel = (get_total_levels() * gg_map_vote_rtv_levels_required / 100) # Register RTV commmands? if cvar_name == 'gg_map_vote_rtv': # Register RTV and nomination commands if int(cvar_value): registerSayCommand(str(gg_map_vote_rtv_command), rtv_cmd, '' + 'RTV command.') registerSayCommand(str(gg_map_vote_nominate_command), nominate_cmd, 'Nominate command.') # Unregister RTV and nomination commands else: unregisterSayCommand(str(gg_map_vote_rtv_command)) unregisterSayCommand(str(gg_map_vote_nominate_command))
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))
def give_bonus(userid, sound=False, turboCheck=False): ggPlayer = Player(userid) # Using weapon list? if using_weapon_list(): # Player needs a real levelup? totalLevels = get_total_levels(str(gg_nade_bonus)) if totalLevels < ggPlayer.nadeBonusLevel: # Reset bonus multi kills ggPlayer.nadeBonusMulti = 0 # Player stuck on last gun ? if int(gg_nade_bonus_mode) == 0: ggPlayer.nadeBonusLevel = totalLevels return # Resetting player's bonus level ggPlayer.nadeBonusLevel = 1 # Put the player back on level 1 ? if int(gg_nade_bonus_mode) == 1: # Recall the function to give level 1 weapon give_bonus(userid, sound, turboCheck) # Strip the previous weapons ggPlayer.strip_weapons([ get_level_weapon(get_total_levels(str(gg_nade_bonus)), str(gg_nade_bonus)) ]) return # Level them up ggPlayer.levelup(1, userid, 'kill') # Play the levelup sound ggPlayer.playsound('levelup') # Strip the previous weapons ggPlayer.strip_weapons([ get_level_weapon(get_total_levels(str(gg_nade_bonus)), str(gg_nade_bonus)) ]) # Display message ggPlayer.msg('Levelup', {}, True) return # Play sound ? if sound: ggPlayer.playsound('nadebonuslevel') # gg_turbo is loaded ? if turboCheck and not int(es.ServerVar('gg_turbo')): return # Get weapon weapons = get_weapon(userid) # All you get is a knife? if len(weapons) == 1 and weapons[0] == 'knife': # Not carrying a nade? if getPlayer(userid).get('he') == 0: # Pull out knife es.sexec(userid, 'use weapon_knife') return # Give weapons count = 0 for weapon in weapons: # If the weapon is flashbang, and it is not the first flashbang in the # list, give it without stripping the first one we gave, and continue if (weapon == "flashbang" and weapons.count("flashbang") > 1 and count != weapons.index("flashbang")): ggPlayer.give(weapon, False, False) continue count += 1 ggPlayer.give(weapon, False, True) # if they are carrying an hegrenade, make them use it if getPlayer(userid).get('he') != 0: es.sexec(userid, 'use weapon_hegrenade') # If a weapon list is being used, strip the previous weapons if using_weapon_list(): previousLevel = Player(userid).nadeBonusLevel - 1 # If their level just started the loop again, their previous level is # the total number of levels if previousLevel < 1: previousLevel = get_total_levels(str(gg_nade_bonus)) # If the total number of levels is 1, don't strip them if previousLevel == 1: return # Strip the previous weapons ggPlayer.strip_weapons( [get_level_weapon(previousLevel, str(gg_nade_bonus))])
def give_bonus(userid, sound=False, turboCheck=False): ggPlayer = Player(userid) # Using weapon list? if using_weapon_list(): # Player needs a real levelup? totalLevels = get_total_levels(str(gg_nade_bonus)) if totalLevels < ggPlayer.nadeBonusLevel: # Reset bonus multi kills ggPlayer.nadeBonusMulti = 0 # Player stuck on last gun ? if int(gg_nade_bonus_mode) == 0: ggPlayer.nadeBonusLevel = totalLevels return # Resetting player's bonus level ggPlayer.nadeBonusLevel = 1 # Put the player back on level 1 ? if int(gg_nade_bonus_mode) == 1: # Recall the function to give level 1 weapon give_bonus(userid, sound, turboCheck) # Strip the previous weapons ggPlayer.strip_weapons([get_level_weapon( get_total_levels(str(gg_nade_bonus)), str(gg_nade_bonus))]) return # Level them up ggPlayer.levelup(1, userid, 'kill') # Play the levelup sound ggPlayer.playsound('levelup') # Strip the previous weapons ggPlayer.strip_weapons([get_level_weapon(get_total_levels( str(gg_nade_bonus)), str(gg_nade_bonus))]) # Display message ggPlayer.msg('Levelup', {}, True) return # Play sound ? if sound: ggPlayer.playsound('nadebonuslevel') # gg_turbo is loaded ? if turboCheck and not int(es.ServerVar('gg_turbo')): return # Get weapon weapons = get_weapon(userid) # All you get is a knife? if len(weapons) == 1 and weapons[0] == 'knife': # Not carrying a nade? if getPlayer(userid).get('he') == 0: # Pull out knife es.sexec(userid, 'use weapon_knife') return # Give weapons count = 0 for weapon in weapons: # If the weapon is flashbang, and it is not the first flashbang in the # list, give it without stripping the first one we gave, and continue if (weapon == "flashbang" and weapons.count("flashbang") > 1 and count != weapons.index("flashbang")): ggPlayer.give(weapon, False, False) continue count += 1 ggPlayer.give(weapon, False, True) # if they are carrying an hegrenade, make them use it if getPlayer(userid).get('he') != 0: es.sexec(userid, 'use weapon_hegrenade') # If a weapon list is being used, strip the previous weapons if using_weapon_list(): previousLevel = Player(userid).nadeBonusLevel - 1 # If their level just started the loop again, their previous level is # the total number of levels if previousLevel < 1: previousLevel = get_total_levels(str(gg_nade_bonus)) # If the total number of levels is 1, don't strip them if previousLevel == 1: return # Strip the previous weapons ggPlayer.strip_weapons([get_level_weapon(previousLevel, str(gg_nade_bonus))])
# Holds map nominations nominations = [] # Instance of popuplib ggVote = None # Holds a list of userids at the time the vote was started voteUserids = [] winningMap = None # True/False if vote has allready been ran this map voteHasStarted = False # The level which, once the leader hits, disables RTV rtv_DisableLevel = get_total_levels() * gg_map_vote_rtv_levels_required / 100 # The list of userids who have voted to RTV rtvList = [] # Has the vote been rocked? voteRocked = False # ============================================================================= # >> LOAD & UNLOAD # ============================================================================= def load(): # Store the value of eventscripts_maphandler global eventscripts_maphandler_backup eventscripts_maphandler_backup = int(eventscripts_maphandler)