def on_kill(self, e): # Ignore suicides and team kills if not e.valid_kill: return attacker_vehicle = model_mgr.get_vehicle(e.attacker.vehicle_id) victim_vehicle = model_mgr.get_vehicle(e.victim.vehicle_id) if attacker_vehicle.group == AIR and victim_vehicle.group != AIR: self.results[e.attacker] += 1
def on_kill(self, e): # Ignore suicides and team kills if not e.valid_kill: return # Ignore empty attackers if not e.attacker in self.player_to_pos: return # Ignore aircraft kills vehicle = model_mgr.get_vehicle(e.attacker.vehicle_id) if vehicle.group == AIR: return # Calculate the distance traveled by the attacker to get the kill last_pos = self.player_to_pos[e.attacker] distance = stat_mgr.dist_3d(last_pos, e.attacker_pos) # Increment the distance and kills for the attacker self.distance[e.attacker] += round(distance) self.kills[e.attacker] += 1 # Display the average self.results[e.attacker] = round(self.distance[e.attacker] / self.kills[e.attacker]) # Store the current position for next time self.player_to_pos[e.attacker] = e.attacker_pos
def on_kill(self, e): #Ignore suicides and team kills if not e.valid_kill: return tank_check = model_mgr.get_vehicle(e.victim.vehicle_id) if tank_check.vehicle_type != ARMOR: return jeep_check = model_mgr.get_vehicle(e.attacker.vehicle_id) if jeep_check.vehicle_type != TRANSPORT: return #may have to exclude some transports? i.e. amphibious if e.attacker.driver: return self.results[e.attacker] += 1
def on_kill(self, e): # Ignore suicides and team kills if not e.valid_kill: return attack_vehicle = model_mgr.get_vehicle(e.attacker.vehicle_id) if attack_vehicle.vehicle_type == ARMOR: self.results[e.victim] += 1
def on_kill(self, e): # Ignore suicides and team kills if not e.valid_kill: return victim_vehicle = model_mgr.get_vehicle(e.victim.vehicle_id) if victim_vehicle.vehicle_type == PARACHUTE: self.results[e.attacker] += 1
def on_kill(self, e): # Ignore suicides and team kills if not e.valid_kill: return attacker_vehicle = model_mgr.get_vehicle(e.attacker.vehicle_id) if attacker_vehicle.vehicle_type == HELICOPTER: self.results[e.attacker] += 1
def on_kill(self, e): # Ignore suicides and team kills if not e.valid_kill: return victim_vehicle = model_mgr.get_vehicle(e.victim.vehicle_id) if victim_vehicle.group == STATION: self.results[e.attacker] += 1
def __init__(self, tick, values): BaseEvent.__init__(self, tick, values, 4) self.vehicle = model_mgr.get_vehicle(values[0]) self.vehicle_pos = event_mgr.parse_pos(values[1]) self.giver = model_mgr.get_player_by_name(values[2]) self.giver_pos = event_mgr.parse_pos(values[3]) event_mgr.get_history(self.vehicle).add_event(self) event_mgr.get_history(self.giver).add_event(self)
def get_vehicle(self, id): ''' Provides details for a specific vehicle based on the given vehicle identifier. Args: id (string): The unique identifier of a vehicle. Returns: vehicle (object): Detailed information for a specific vehicle. ''' # Get the model for the requested vehicle vehicle = model_mgr.get_vehicle(id) if not vehicle: raise cherrypy.HTTPError(404) # Get the stats for the requested vehicle vehicle_stats = stat_mgr.get_vehicle_stats(vehicle) # Build a list of column descriptors columns = [{ 'name': 'Players', 'data': 'player' }, { 'name': 'Kills', 'data': 'number', 'sorted': False }, { 'name': 'Deaths', 'data': 'number' }] # Build a list of vehicle statistics rows = list() for player in vehicle_stats.players: if player != models.players.EMPTY: object_stats = vehicle_stats.players[player] player_tuple = { 'id': player.id, 'name': player.name, 'photo': player.photo_s } rows.append( [player_tuple, object_stats.kills, object_stats.deaths]) # Sort the results by kills rows.sort(key=lambda r: r[1], reverse=True) return { 'id': vehicle.id, 'name': vehicle.name, 'columns': columns, 'rows': rows }
def on_kill(self, e): # Ignore suicides and team kills if not e.valid_kill: return # Make sure the attacker is not in a vehicle attacker_vehicle = model_mgr.get_vehicle(e.attacker.vehicle_id) if attacker_vehicle != vehicles.EMPTY: return # Check whether the attacker was at least a story higher than the victim if (e.attacker.pos[1] - e.victim.pos[1]) > 3: self.results[e.attacker] += 1
def __init__(self, tick, values): BaseEvent.__init__(self, tick, values, 4) self.player = model_mgr.get_player_by_name(values[0]) self.player_pos = event_mgr.parse_pos(values[1]) self.vehicle = model_mgr.get_vehicle(values[2]) self.vehicle_slot_id = values[3] if self.vehicle_slot_id and not self.vehicle_slot_id in self.vehicle.slot_ids: print ('ERROR - Missing vehicle slot reference: %s -> %s' % (self.vehicle.id, self.vehicle_slot_id)) event_mgr.get_history(self.player).add_event(self) event_mgr.get_history(self.vehicle).add_event(self)
def on_vehicle_destroy(self, e): # Ignore events caused by the environment if e.attacker == players.EMPTY: return # Ignore air-to-air attacks attacker_vehicle = model_mgr.get_vehicle(e.attacker.vehicle_id) if attacker_vehicle.group == AIR: return # Check whether an aircraft was killed while in flight if e.vehicle.group == AIR: if (e.vehicle_pos[1] - e.attacker_pos[1]) > 10: self.results[e.attacker] += 1
def on_kill(self, e): # Ignore suicides and team kills if not e.valid_kill: return # Hitting the victim with an aircraft would not have a weapon if e.weapon != weapons.EMPTY: return victim_vehicle = model_mgr.get_vehicle(e.victim.vehicle_id) if victim_vehicle.vehicle_type == PARACHUTE: if (e.vehicle.vehicle_type == JET or e.vehicle.vehicle_type == HELICOPTER): self.results[e.attacker] += 1
def on_kill(self, e): # Make sure only the driver gets credit if e.victim.passenger: return # Check whether the victim vehicle was an aircraft victim_vehicle = model_mgr.get_vehicle(e.victim.vehicle_id) if victim_vehicle.vehicle_type == HELICOPTER or victim_vehicle.vehicle_type == JET: # Compute the height difference of the victim height = e.victim_pos[1] - self.startPos[e.victim] # Check whether the victim died to nobody at a sufficient height if e.attacker == players.EMPTY and height > 30: self.results[e.victim] += 1
def on_kill(self, e): # Make sure only the driver gets credit if e.victim.passenger: return # Check whether the victim vehicle was an aircraft victim_vehicle = model_mgr.get_vehicle(e.victim.vehicle_id) if (victim_vehicle.vehicle_type == HELICOPTER or victim_vehicle.vehicle_type == JET): # Compute the height difference of the victim height = e.victim_pos[1] - self.startPos[e.victim] # Check whether the victim died to nobody at a sufficient height if e.attacker == players.EMPTY and height > 30: self.results[e.victim] += 1
def on_death(self, e): # Get the vehicle used by the player vehicle_id = None if e.player in self.vehicles: vehicle_id = self.vehicles[e.player] del self.vehicles[e.player] player_vehicle = model_mgr.get_vehicle(vehicle_id) vehicle_stats = stat_mgr.get_vehicle_stats(player_vehicle) # Increment the total vehicle deaths vehicle_stats.deaths += 1 # Increment the player deaths if not e.player in vehicle_stats.players: vehicle_stats.players[e.player] = VehicleItemStats() vehicle_stats.players[e.player].deaths += 1
def on_kill(self, e): # Ignore kills where victim isn't passenger if not e.victim.passenger: return # Check whether the victim was in an aircraft v = model_mgr.get_vehicle(e.victim.vehicle_id) if v.group == AIR: # Check whether the vehicle was destroyed at the same time if v in self.vehicles and self.vehicles[v].tick == e.tick: # Make sure the victim and driver are teammates driver = self.vehicles[v].driver if driver.team_id == e.victim.team_id: self.results[driver] += 1
def __init__(self, tick, values): BaseEvent.__init__(self, tick, values, 6) self.victim = model_mgr.get_player_by_name(values[0]) self.victim_pos = event_mgr.parse_pos(values[1]) self.attacker = model_mgr.get_player_by_name(values[2]) self.attacker_pos = event_mgr.parse_pos(values[3]) self.weapon = model_mgr.get_weapon(values[4]) self.vehicle = model_mgr.get_vehicle(values[5]) self.suicide = (self.victim == self.attacker) self.team_kill = ((self.suicide == False) and (self.victim.team_id == self.attacker.team_id)) self.valid_kill = (self.suicide == False and self.team_kill == False) event_mgr.get_history(self.victim).add_event(self) event_mgr.get_history(self.attacker).add_event(self) event_mgr.get_history(self.weapon).add_event(self)
def get_vehicle(self, id): ''' Provides details for a specific vehicle based on the given vehicle identifier. Args: id (string): The unique identifier of a vehicle. Returns: vehicle (object): Detailed information for a specific vehicle. ''' # Get the model for the requested vehicle vehicle = model_mgr.get_vehicle(id) if not vehicle: raise cherrypy.HTTPError(404) # Get the stats for the requested vehicle vehicle_stats = stat_mgr.get_vehicle_stats(vehicle) # Build a list of column descriptors columns = [{ 'name': 'Players', 'data': 'player' }, { 'name': 'Kills', 'data': 'number', 'sorted': False }, { 'name': 'Deaths', 'data': 'number' }] # Build a list of vehicle statistics rows = list() for player in vehicle_stats.players: if player != models.players.EMPTY: object_stats = vehicle_stats.players[player] player_tuple = { 'id': player.id, 'name': player.name, 'photo': player.photo_s } rows.append([player_tuple, object_stats.kills, object_stats.deaths]) # Sort the results by kills rows.sort(key=lambda r: r[1], reverse=True) return { 'id': vehicle.id, 'name': vehicle.name, 'columns' : columns, 'rows': rows }
def on_kill(self, e): # Ignore suicides and team kills if not e.valid_kill: return # Store the vehicle of the victim for future use if e.victim.vehicle_id: self.vehicles[e.victim] = e.victim.vehicle_id # Get the vehicle for the attacker attacker_vehicle = model_mgr.get_vehicle(e.attacker.vehicle_id) attacker_vehicle_stats = stat_mgr.get_vehicle_stats(attacker_vehicle) # Increment the total vehicle kills attacker_vehicle_stats.kills += 1 # Increment the attacker kills if not e.attacker in attacker_vehicle_stats.players: attacker_vehicle_stats.players[e.attacker] = VehicleItemStats() attacker_vehicle_stats.players[e.attacker].kills += 1
def on_kill(self, e): # Ignore suicides and team kills if not e.valid_kill: return # Reset counter to 0 for kills self.current[e.attacker] = 0 if e.victim not in self.current: self.current[e.victim] = 0 # Check whether the victim was killed by a station attack_vehicle = model_mgr.get_vehicle(e.attacker.vehicle_id) if attack_vehicle.group == STATION: # Add a station death point update the results with the max self.current[e.victim] += 1 self.results[e.victim] = max(self.results[e.victim], self.current[e.victim]) else: # Reset counter for non turret deaths self.current[e.victim] = 0
def on_vehicle_enter(self, e): # Store the time when a player gets in an aircraft player_vehicle = model_mgr.get_vehicle(e.player.vehicle_id) if player_vehicle.group == AIR: self.last_vehicle_entrance[e.player] = e
def on_kill(self, e): self.victims[e.victim] = e victim_stats = stat_mgr.get_player_stats(e.victim) attacker_stats = stat_mgr.get_player_stats(e.attacker) # Get the last known kit for the attacker # Attacker may be dead and may not have an active kit attacker_kit = event_mgr.get_last_kit(e.attacker) # Get the team and vehicle for the attacker attacker_team = model_mgr.get_team(e.attacker.team_id) attacker_vehicle = model_mgr.get_vehicle(e.attacker.vehicle_id) # Get the current game and map current_game = model_mgr.get_game() current_map = model_mgr.get_map(current_game.map_id) # Check whether the kill was actually a suicide if e.suicide: attacker_stats.suicides += 1 attacker_stats.suicides_total += 1 return # Check whether the kill was actually a teammate if e.team_kill: victim_stats.team_killed += 1 victim_stats.team_killed_total += 1 attacker_stats.team_kills += 1 attacker_stats.team_kills_total += 1 return # Store the vehicle of the victim for future use if e.victim.vehicle_id: self.vehicles[e.victim] = e.victim.vehicle_id # Increment wound count for the victim victim_stats.wounds += 1 victim_stats.wounds_total += 1 # Increment enemy wound count for the victim if not e.attacker in victim_stats.enemies: victim_stats.enemies[e.attacker] = PlayerItemStats() victim_stats.enemies[e.attacker].wounds += 1 # Increment kill count for the attacker attacker_stats.kills += 1 attacker_stats.kills_total += 1 # Update kill streaks for the attacker attacker_stats.kills_streak += 1 if attacker_stats.kills_streak > attacker_stats.kills_streak_max: attacker_stats.kills_streak_max = attacker_stats.kills_streak attacker_stats.deaths_streak = 0 if attacker_stats.kills_streak == 5: attacker_stats.kills_5 += 1 attacker_stats.kills_5_total += 1 elif attacker_stats.kills_streak == 10: attacker_stats.kills_10 += 1 attacker_stats.kills_10_total += 1 # Update kill ratio for the attacker if attacker_stats.deaths == 0: attacker_stats.kills_ratio = 1.0 else: attacker_stats.kills_ratio = round(float(attacker_stats.kills) / float(attacker_stats.deaths), 2) if attacker_stats.deaths_total == 0: attacker_stats.kills_ratio_total = 1.0 else: attacker_stats.kills_ratio_total = round(float(attacker_stats.kills_total) / float(attacker_stats.deaths_total), 2) # Increment the enemy kill count for the attacker if not e.victim in attacker_stats.enemies: attacker_stats.enemies[e.victim] = PlayerItemStats() attacker_stats.enemies[e.victim].kills += 1 # Increment the kit kill count for the attacker if not attacker_kit in attacker_stats.kits: attacker_stats.kits[attacker_kit] = PlayerItemStats() attacker_stats.kits[attacker_kit].kills += 1 # Increment the map kill count for the attacker if not current_map in attacker_stats.maps: attacker_stats.maps[current_map] = PlayerItemStats() attacker_stats.maps[current_map].kills += 1 # Increment the vehicle kill count for the attacker if not attacker_vehicle in attacker_stats.vehicles: attacker_stats.vehicles[attacker_vehicle] = PlayerItemStats() attacker_stats.vehicles[attacker_vehicle].kills += 1 # Increment the team kill count for the attacker if not attacker_team in attacker_stats.teams: attacker_stats.teams[attacker_team] = PlayerItemStats() attacker_stats.teams[attacker_team].kills += 1 # Increment the weapon kill count for the attacker if not e.weapon in attacker_stats.weapons: attacker_stats.weapons[e.weapon] = PlayerWeaponStats() attacker_stats.weapons[e.weapon].kills += 1
def on_death(self, e): player_stats = stat_mgr.get_player_stats(e.player) # Get the last known kit for the player # Player will no longer have an active kit at this point player_kit = event_mgr.get_last_kit(e.player) # Get the team and weapon for the player player_team = model_mgr.get_team(e.player.team_id) player_weapon = model_mgr.get_weapon(e.player.weapon_id) # Get the vehicle used by the player vehicle_id = None if e.player in self.vehicles: vehicle_id = self.vehicles[e.player] del self.vehicles[e.player] player_vehicle = model_mgr.get_vehicle(vehicle_id) # Get the current game and map current_game = model_mgr.get_game() current_map = model_mgr.get_map(current_game.map_id) # Increment death count for the player player_stats.deaths += 1 player_stats.deaths_total += 1 # Update death streaks for the player player_stats.deaths_streak += 1 if player_stats.deaths_streak > player_stats.deaths_streak_max: player_stats.deaths_streak_max = player_stats.deaths_streak player_stats.kills_streak = 0 # Update kill ratio for the player player_stats.kills_ratio = round(float(player_stats.kills) / float(player_stats.deaths), 2) player_stats.kills_ratio_max = round(float(player_stats.kills_total) / float(player_stats.deaths_total), 2) # Increment the enemy death count for the player if e.player in self.victims: kill_event = self.victims[e.player] if kill_event and kill_event.valid_kill: if not kill_event.attacker in player_stats.enemies: player_stats.enemies[kill_event.attacker] = PlayerItemStats() player_stats.enemies[kill_event.attacker].deaths += 1 # Increment the kit death count for the player if not player_kit in player_stats.kits: player_stats.kits[player_kit] = PlayerItemStats() player_stats.kits[player_kit].deaths += 1 # Increment the map death count for the player if not current_map in player_stats.maps: player_stats.maps[current_map] = PlayerItemStats() player_stats.maps[current_map].deaths += 1 # Increment the team death count for the player if not player_team in player_stats.teams: player_stats.teams[player_team] = PlayerItemStats() player_stats.teams[player_team].deaths += 1 # Increment the vehicle death count for the player if not player_vehicle in player_stats.vehicles: player_stats.vehicles[player_vehicle] = PlayerItemStats() player_stats.vehicles[player_vehicle].deaths += 1 # Increment the weapon death count for the player if not player_weapon in player_stats.weapons: player_stats.weapons[player_weapon] = PlayerWeaponStats() player_stats.weapons[player_weapon].deaths += 1 # Reset all the temporary accuracy values self._update_accuracy(e.player) # Stop active timers player_stats.commander_time.stop(e.tick) player_stats.leader_time.stop(e.tick) player_stats.play_time.stop(e.tick) player_stats.squad_time.stop(e.tick) # Start the spectator timer player_stats.spec_time.start(e.tick)
def on_death(self, e): player_stats = stat_mgr.get_player_stats(e.player) # Get the last known kit for the player # Player will no longer have an active kit at this point player_kit = event_mgr.get_last_kit(e.player) # Get the team and weapon for the player player_team = model_mgr.get_team(e.player.team_id) player_weapon = model_mgr.get_weapon(e.player.weapon_id) # Get the vehicle used by the player vehicle_id = None if e.player in self.vehicles: vehicle_id = self.vehicles[e.player] del self.vehicles[e.player] player_vehicle = model_mgr.get_vehicle(vehicle_id) # Get the current game and map current_game = model_mgr.get_game() current_map = model_mgr.get_map(current_game.map_id) # Increment death count for the player player_stats.deaths += 1 player_stats.deaths_total += 1 # Update death streaks for the player player_stats.deaths_streak += 1 if player_stats.deaths_streak > player_stats.deaths_streak_max: player_stats.deaths_streak_max = player_stats.deaths_streak player_stats.kills_streak = 0 # Update kill ratio for the player player_stats.kills_ratio = round( float(player_stats.kills) / float(player_stats.deaths), 2) player_stats.kills_ratio_max = round( float(player_stats.kills_total) / float(player_stats.deaths_total), 2) # Increment the enemy death count for the player if e.player in self.victims: kill_event = self.victims[e.player] if kill_event and kill_event.valid_kill: if not kill_event.attacker in player_stats.enemies: player_stats.enemies[ kill_event.attacker] = PlayerItemStats() player_stats.enemies[kill_event.attacker].deaths += 1 # Increment the kit death count for the player if not player_kit in player_stats.kits: player_stats.kits[player_kit] = PlayerItemStats() player_stats.kits[player_kit].deaths += 1 # Increment the map death count for the player if not current_map in player_stats.maps: player_stats.maps[current_map] = PlayerItemStats() player_stats.maps[current_map].deaths += 1 # Increment the team death count for the player if not player_team in player_stats.teams: player_stats.teams[player_team] = PlayerItemStats() player_stats.teams[player_team].deaths += 1 # Increment the vehicle death count for the player if not player_vehicle in player_stats.vehicles: player_stats.vehicles[player_vehicle] = PlayerItemStats() player_stats.vehicles[player_vehicle].deaths += 1 # Increment the weapon death count for the player if not player_weapon in player_stats.weapons: player_stats.weapons[player_weapon] = PlayerWeaponStats() player_stats.weapons[player_weapon].deaths += 1 # Reset all the temporary accuracy values self._update_accuracy(e.player) # Stop active timers player_stats.commander_time.stop(e.tick) player_stats.leader_time.stop(e.tick) player_stats.play_time.stop(e.tick) player_stats.squad_time.stop(e.tick) # Start the spectator timer player_stats.spec_time.start(e.tick)
def on_kill(self, e): self.victims[e.victim] = e victim_stats = stat_mgr.get_player_stats(e.victim) attacker_stats = stat_mgr.get_player_stats(e.attacker) # Get the last known kit for the attacker # Attacker may be dead and may not have an active kit attacker_kit = event_mgr.get_last_kit(e.attacker) # Get the team and vehicle for the attacker attacker_team = model_mgr.get_team(e.attacker.team_id) attacker_vehicle = model_mgr.get_vehicle(e.attacker.vehicle_id) # Get the current game and map current_game = model_mgr.get_game() current_map = model_mgr.get_map(current_game.map_id) # Check whether the kill was actually a suicide if e.suicide: attacker_stats.suicides += 1 attacker_stats.suicides_total += 1 return # Check whether the kill was actually a teammate if e.team_kill: victim_stats.team_killed += 1 victim_stats.team_killed_total += 1 attacker_stats.team_kills += 1 attacker_stats.team_kills_total += 1 return # Store the vehicle of the victim for future use if e.victim.vehicle_id: self.vehicles[e.victim] = e.victim.vehicle_id # Increment wound count for the victim victim_stats.wounds += 1 victim_stats.wounds_total += 1 # Increment enemy wound count for the victim if not e.attacker in victim_stats.enemies: victim_stats.enemies[e.attacker] = PlayerItemStats() victim_stats.enemies[e.attacker].wounds += 1 # Increment kill count for the attacker attacker_stats.kills += 1 attacker_stats.kills_total += 1 # Update kill streaks for the attacker attacker_stats.kills_streak += 1 if attacker_stats.kills_streak > attacker_stats.kills_streak_max: attacker_stats.kills_streak_max = attacker_stats.kills_streak attacker_stats.deaths_streak = 0 if attacker_stats.kills_streak == 5: attacker_stats.kills_5 += 1 attacker_stats.kills_5_total += 1 elif attacker_stats.kills_streak == 10: attacker_stats.kills_10 += 1 attacker_stats.kills_10_total += 1 # Update kill ratio for the attacker if attacker_stats.deaths == 0: attacker_stats.kills_ratio = 1.0 else: attacker_stats.kills_ratio = round( float(attacker_stats.kills) / float(attacker_stats.deaths), 2) if attacker_stats.deaths_total == 0: attacker_stats.kills_ratio_total = 1.0 else: attacker_stats.kills_ratio_total = round( float(attacker_stats.kills_total) / float(attacker_stats.deaths_total), 2) # Increment the enemy kill count for the attacker if not e.victim in attacker_stats.enemies: attacker_stats.enemies[e.victim] = PlayerItemStats() attacker_stats.enemies[e.victim].kills += 1 # Increment the kit kill count for the attacker if not attacker_kit in attacker_stats.kits: attacker_stats.kits[attacker_kit] = PlayerItemStats() attacker_stats.kits[attacker_kit].kills += 1 # Increment the map kill count for the attacker if not current_map in attacker_stats.maps: attacker_stats.maps[current_map] = PlayerItemStats() attacker_stats.maps[current_map].kills += 1 # Increment the vehicle kill count for the attacker if not attacker_vehicle in attacker_stats.vehicles: attacker_stats.vehicles[attacker_vehicle] = PlayerItemStats() attacker_stats.vehicles[attacker_vehicle].kills += 1 # Increment the team kill count for the attacker if not attacker_team in attacker_stats.teams: attacker_stats.teams[attacker_team] = PlayerItemStats() attacker_stats.teams[attacker_team].kills += 1 # Increment the weapon kill count for the attacker if not e.weapon in attacker_stats.weapons: attacker_stats.weapons[e.weapon] = PlayerWeaponStats() attacker_stats.weapons[e.weapon].kills += 1
def on_kill(self, e): victim_vehicle = model_mgr.get_vehicle(e.victim.vehicle_id) if victim_vehicle.group == LAND and e.attacker == players.EMPTY: self.results[e.victim] += 1