unofficial-valorant-api
unofficial-valorant-api copied to clipboard
friendly_fire for players is not calculated (correctly)
In the ["players"]["all_players"]
list returned by the /valorant/v3/by-puuid/matches/{affinity}/{puuid}
endpoint, each entry has the behavior
dictonary which includes the key friendly_fire
among others. However its value is always set to 0, it is possible to calculate it yourself beacuse you can iterate over the damage_events. Here as python example:
import json
import requests
match_id = "0123456789" # CHANGE THIS TO THE MATCH ID YOU WANT TO CHECK
response = json.loads(
requests.get("https://api.henrikdev.xyz/valorant/v2/match/" + match_id).content
)
for round_num, round in enumerate(response["data"]["rounds"]):
for player_stats in round["player_stats"]:
# check if on the same team
source_team = player_stats["player_team"]
source_player = player_stats["player_display_name"]
for damage_event in player_stats["damage_events"]:
receiver_team = damage_event["receiver_team"]
receiver_player = damage_event["receiver_display_name"]
if source_team == receiver_team and not source_player == receiver_player:
print(
f"Friendly fire in round {round_num+1} by {source_player} to {receiver_player} for {damage_event['damage']} damage"
)
)
Do you have an example match ID where the calculation is wrong?