def dissolve_ragdoll(userid, current_type): """Dissolve/remove the player's ragdoll.""" # Get the ragdoll entity try: inthandle = Player.from_userid(userid).ragdoll except ValueError: return if inthandle == INVALID_ENTITY_INTHANDLE: return entity = Entity(index_from_inthandle(inthandle)) # Should the ragdoll just be removed? if current_type == _num_dissolve_types + 2: entity.remove() return # Set the target name for the player's ragdoll entity.target_name = 'ragdoll_{userid}'.format(userid=userid) # Get the dissolver entity dissolver_entity = Entity.find_or_create('env_entity_dissolver') # Should a random dissolve type be chosen? if current_type == _num_dissolve_types + 1: current_type = randrange(_num_dissolve_types) # Set the magnitude dissolver_entity.magnitude = magnitude.get_int() # Set the dissolve type dissolver_entity.dissolve_type = current_type # Dissolve the ragdoll dissolver_entity.dissolve('ragdoll_{userid}'.format(userid=userid))
def endround(self, condition): """CSS: 0 TERRORIST "Target_Bombed" 1 CT "VIP_Escaped" 2 TERRORIST "VIP_Assassinated" 3 TERRORIST "Terrorists_Escaped" 4 CT "CTs_PreventEscape" 5 CT "Escaping_Terrorists_Neutralized" 6 CT "Bomb_Defused" 7 CT "CTs_Win" 8 TERRORIST "Terrorists_Win" 9 World "Round_Draw" 10 CT "All_Hostages_Rescued" 11 CT "Target_Saved" 12 TERRORIST "Hostages_Not_Rescued" 13 CT "Terrorists_Not_Escaped" 14 TERRORIST "VIP_Not_Escaped" 15 World "Game_Commencing" 16 World "UNKNOWN" """ if self.is_endround == False: self.is_endround = True info_map_parameters = Entity.find_or_create("info_map_parameters") info_map_parameters.call_input('FireWinCondition', condition) # play sound self.sounds.play_random('endround')
def _dissolve_ragdoll(inthandle, current_type): """Dissolve/remove the player's ragdoll.""" try: entity = Entity(index_from_inthandle(inthandle)) except (OverflowError, ValueError): return # Should the ragdoll just be removed? if current_type == NUM_DISSOLVE_TYPES + 2: entity.remove() return # Set the target name for the player's ragdoll entity.target_name = f'ragdoll_{inthandle}' # Get the dissolver entity dissolver_entity = Entity.find_or_create('env_entity_dissolver') # Should a random dissolve type be chosen? if current_type == NUM_DISSOLVE_TYPES + 1: current_type = randrange(NUM_DISSOLVE_TYPES) # Set the magnitude dissolver_entity.magnitude = dissolver_magnitude.get_int() # Set the dissolve type dissolver_entity.dissolve_type = current_type # Dissolve the ragdoll dissolver_entity.dissolve(f'ragdoll_{inthandle}')
def _player_death(game_event): # Dead Strip remove_idle_weapons(status=GunGameMatchStatus.WARMUP) # Dissolver victim = game_event['userid'] try: inthandle = Player.from_userid(victim).ragdoll except ValueError: return if inthandle == INVALID_ENTITY_INTHANDLE: return entity = Entity(index_from_inthandle(inthandle)) entity.target_name = f'ragdoll_{victim}' dissolver_entity = Entity.find_or_create('env_entity_dissolver') dissolver_entity.magnitude = 2 dissolver_entity.dissolve_type = 0 dissolver_entity.dissolve(f'ragdoll_{victim}') # DeathMatch Delay( delay=2, callback=_respawn_player, args=(victim,), cancel_on_level_end=True, )
def victory(team): message = common_strings['team victory ' + team.name.lower()] SayText2(tagged(colorize(message))).send() for team in _team_points.keys(): _team_points[team] = 0 info_map_parameters = Entity.find_or_create('info_map_parameters') info_map_parameters.fire_win_condition( WIN_CONDITIONS.get(team.value, WIN_CONDITIONS[0]))
def _gg_win(game_event): """Increase the win total for the winner and end the map.""" # Set the match status GunGameStatus.MATCH = GunGameMatchStatus.POST # Get the winner winner = player_dictionary[game_event['winner']] # Increase the winner's win total if they are not a bot if not winner.is_fake_client(): winner.wins += 1 # Send the winner messages message_manager.chat_message( message='Winner:Long', index=winner.index, winner=winner.name, ) for second in range(4): Delay( delay=second, callback=message_manager.center_message, kwargs={ 'message': 'Winner:Short', 'winner': winner.name, }, cancel_on_level_end=True, ) color = {2: RED, 3: BLUE}.get(winner.team_index, WHITE) message_manager.top_message( message='Winner:Short', color=color, winner=winner.name ) # Play the winner sound winner_sound = sound_manager.play_sound('winner') # Set the dynamic chat time, if needed if dynamic_chat_time.get_bool() and winner_sound is not None: with suppress(MutagenError): ConVar('mp_chattime').set_float(winner_sound.duration) # End the match to move to the next map entity = Entity.find_or_create('game_end') entity.end_game() # Do not remove! This fixes a lot of console spam and hanging on map end. queue_command_string('bot_kick')
def _end_match(game_event): # Set the match status GunGameStatus.MATCH = GunGameMatchStatus.POST # Get the winning team information winning_team = teamwork_manager[game_event['winner']] # Send the winner messages message_manager.chat_message( index=winning_team.index, message='TeamWork:Winner:Long', team_name=winning_team.name, ) for second in range(4): Delay( delay=second, callback=message_manager.center_message, kwargs={ 'message': 'TeamWork:Winner:Short', 'team_name': winning_team.name, }, cancel_on_level_end=True, ) color = {2: RED, 3: BLUE}.get(winning_team, WHITE) message_manager.top_message( message='TeamWork:Winner:Short', color=color, team_name=winning_team.name, ) # Play the winner sound winner_sound = sound_manager.play_sound('winner') # Set the dynamic chat time, if needed if dynamic_chat_time.get_bool() and winner_sound is not None: with suppress(MutagenError): ConVar('mp_chattime').set_float(winner_sound.duration) # End the match to move to the next map entity = Entity.find_or_create('game_end') entity.end_game() # Do not remove! This fixes a lot of console spam and hanging on map end. queue_command_string('bot_kick') # Reset the teams _clear_team_dictionary()
def _player_spawn(game_event): """Give the player their level weapon.""" # Is GunGame active? if GunGameStatus.MATCH is not GunGameMatchStatus.ACTIVE: return # Use try/except to get the player's instance try: player = player_dictionary[game_event['userid']] except ValueError: return # Verify that the player is on a team if player.team < 2: return # Spawn protection player.give_spawn_protection() # Give the player their new weapon player.strip_weapons() player.give_level_weapon() # Give CTs defusers, if need be if player.team == 3 and give_defusers.get_bool(): player.has_defuser = True # Give player armor, if necessary armor_type = {1: 'kevlar', 2: 'assaultsuit'}.get(give_armor.get_int()) if armor_type is not None: equip = Entity.find_or_create('game_player_equip') equip.add_output('{weapon} 1'.format(weapon=_melee_weapon)) equip.add_output( 'item_{armor_type} 1'.format( armor_type=armor_type ), caller=player, activator=player, ) # Skip bots if player.is_fake_client(): return # Send the player their level information _send_level_info(player)
def _gg_win(game_event): """Increase the win total for the winner and end the map.""" # Set the match status GunGameStatus.MATCH = GunGameMatchStatus.POST # Get the winner winner = player_dictionary[game_event['winner']] # Increase the winner's win total if they are not a bot if not winner.is_fake_client(): winner.wins += 1 # Send the winner messages message_manager.chat_message( message='Winner:Long', index=winner.index, winner=winner.name, ) for second in range(4): Delay( second, message_manager.center_message, kwargs={ 'message': 'Winner:Short', 'winner': winner.name, } ) color = {2: RED, 3: BLUE}.get(winner.team, WHITE) message_manager.top_message( message='Winner:Short', color=color, winner=winner.name ) # Play the winner sound winner_sound = sound_manager.play_sound('winner') # Set the dynamic chat time, if needed if dynamic_chat_time.get_bool(): with suppress(MutagenError): ConVar('mp_chattime').set_float(winner_sound.duration) # End the match to move to the next map entity = Entity.find_or_create('game_end') entity.end_game()
def change_level(round_end=False): if status.next_map is None: raise RuntimeError("It's already time to change the level, " "but next map is yet to be decided") if config_manager['instant_change_level'] or round_end: log.log_debug("Ending the game...") game_end_entity = Entity.find_or_create('game_end') game_end_entity.end_game() else: log.log_debug("Waiting for the round end to end the game...") status.round_end_needed = True if config_manager['timeleft_auto_lastround_warning']: broadcast(strings_common['timeleft_last_round'])
def change_level(round_end=False): if status.next_map is None: raise RuntimeError("It's already time to change the level, " "but next map is yet to be decided") if config_manager['instant_change_level'] or round_end: logger.log_debug("Ending the game...") game_end_entity = Entity.find_or_create('game_end') game_end_entity.end_game() else: logger.log_debug("Waiting for the round end to end the game...") status.round_end_needed = True if config_manager['timeleft_auto_lastround_warning']: broadcast(common_strings['timeleft_last_round'])
def _end_match(game_event): # Set the match status GunGameStatus.MATCH = GunGameMatchStatus.POST # Get the winning team information winning_team = teamwork_manager[game_event['winner']] # Send the winner messages message_manager.chat_message( index=winning_team.index, message='TeamWork:Winner:Long', team_name=winning_team.name, ) for second in range(4): Delay( second, message_manager.center_message, kwargs={ 'message': 'TeamWork:Winner:Short', 'team_name': winning_team.name, } ) color = {2: RED, 3: BLUE}.get(winning_team, WHITE) message_manager.top_message( message='TeamWork:Winner:Short', color=color, team_name=winning_team.name, ) # Play the winner sound winner_sound = sound_manager.play_sound('winner') # Set the dynamic chat time, if needed if dynamic_chat_time.get_bool(): with suppress(MutagenError): ConVar('mp_chattime').set_float(winner_sound.duration) # End the match to move to the next map entity = Entity.find_or_create('game_end') entity.end_game() # Reset the teams _clear_team_dictionary()
def load(map_name=None): """Set the chicken count.""" map_info = Entity.find_or_create('info_map_parameters') map_info.pet_population = chicken_count.get_int()
def load(map_name=None): """Set the chickens for the map.""" map_info = Entity.find_or_create('info_map_parameters') map_info.pet_population = max_chickens.get_int()