Henrik-3 / unofficial-valorant-api

Unofficial VALORANT API using the VALORANT Ingame API
442 stars 19 forks source link

damage_made value is not accurate to calculate ADR #62

Closed awexandrr closed 1 year ago

awexandrr commented 1 year ago

API URL : https://api.henrikdev.xyz/valorant/v2/match/d633c23b-0b51-44fa-86a6-51db4df04afc REGION: ap

Im using your api to get a match report every time i finished my game and generate combat report based on it.

based on my code, formula for ADR is ADR = damage_made / round_played.

but, sometimes the value reported from your api is not as accurate with the value that i got from ingame report or tracker.gg report. here is the report that i made,

here is from tracker.gg,

image

here is the response from api for iSee#PRO,

  {
      "puuid":"04d55559-f884-5579-ac24-6bb92c4c591b",
      "name":"iSee",
      "tag":"PRO",
      "team":"Blue",
      "level":133,
      "character":"Sage",
      "currenttier":19,
      "currenttier_patched":"Diamond 2",
      "player_card":"68b0c8c2-4158-7b21-658d-b4ae86f137ce",
      "player_title":"d67cef9b-43cd-bc8c-840d-039582975c2a",
      "party_id":"63e8ffab-6aff-4674-ae4a-b6613dbe187d",
      "session_playtime":{
          "minutes":67,
          "seconds":4020,
          "milliseconds":4020000
      },
      "behavior":{
          "afk_rounds":0,
          "friendly_fire":{
              "incoming":0,
              "outgoing":0
          },
          "rounds_in_spawn":0
      },
      "platform":{
          "type":"PC",
          "os":{
              "name":"Windows",
              "version":"10.0.19044.1.256.64bit"
          }
      },
      "ability_casts":{
          "c_cast":20,
          "q_cast":14,
          "e_cast":15,
          "x_cast":3
      },
      "assets":{
          "card":{
              "small":"https://media.valorant-api.com/playercards/68b0c8c2-4158-7b21-658d-b4ae86f137ce/smallart.png",
              "large":"https://media.valorant-api.com/playercards/68b0c8c2-4158-7b21-658d-b4ae86f137ce/largeart.png",
              "wide":"https://media.valorant-api.com/playercards/68b0c8c2-4158-7b21-658d-b4ae86f137ce/wideart.png"
          },
          "agent":{
              "small":"https://media.valorant-api.com/agents/569fdd95-4d10-43ab-ca70-79becc718b46/displayicon.png",
              "bust":"https://media.valorant-api.com/agents/569fdd95-4d10-43ab-ca70-79becc718b46/bustportrait.png",
              "full":"https://media.valorant-api.com/agents/569fdd95-4d10-43ab-ca70-79becc718b46/fullportrait.png",
              "killfeed":"https://media.valorant-api.com/agents/569fdd95-4d10-43ab-ca70-79becc718b46/killfeedportrait.png"
          }
      },
      "stats":{
          "score":5490,
          "kills":19,
          "deaths":15,
          "assists":10,
          "bodyshots":30,
          "headshots":15,
          "legshots":0
      },
      "economy":{
          "spent":{
              "overall":64700,
              "average":2696
          },
          "loadout_value":{
              "overall":91550,
              "average":3815
          }
      },
      "damage_made":3069,
      "damage_received":3221
  }
as you can see, some of the ADR for some players are not as accurate as tracker.gg. player damage_made calculatedADR trackerADR
iSee#PRO 3069 128 133.2
PssyHunter#ezpz 2796 116 120.2
Starzie#4fun 3059 127 99.2
Somet#olo 2526 105 114.2
Miyu#2045 2360 98 102.7
Awexander#007 3032 126 126.3
mandylindley#00000 4654 194 110.7
el diavolo#daisy 4166 174 178
NamT#88888 3507 127 150.2
Awaken#4279 4260 178 177.5

At first, im thinking maybe the problem was with the compiler rounding float numbers but the value was far off from the actual one. is there any work around for this ?

Henrik-3 commented 1 year ago

I am gonna look at it, but from the first look it seems to be a bug that is not easy to find, the code loops over all damage events and calculates them correctly. I will update here if i find some news about this

awexandrr commented 1 year ago

thanks! very much appreciated!

edit: the same problem occurs on headshot counts, formula: headshots = ( headshots / (headshots + bodyshots + legshots) ) * 100 but for some reasons, the value calculated is also not as accurate as from tracker.gg

awexandrr commented 1 year ago

Hi, i ran some loops to get each individual damage events for all players and it seems like the result that i got is better now.

code snippet:

for rounds in data.get('data')[0].get('rounds'):
    for damage in rounds.get('player_stats'):
        if damage.get('player_puuid') == puuid:
            dmg += float(damage.get('damage'))

results:

player damage_made calculatedADR trackerADR damage_loop loopADR
iSee#PRO 3069 128 133.2 3197 133.2
PssyHunter#ezpz 2796 116 120.2 2884 120.17
Starzie#4fun 3059 127 99.2 3379 140.79
Somet#olo 2526 105 114.2 2740 114.17
Miyu#2045 2360 98 102.7 2465 102.71
Awexander#007 3032 126 126.3 3032 126.33
mandylindley#00000 4654 194 110.7 4654 193.92
el diavolo#daisy 4166 174 178 4271 177.96
NamT#88888 3507 127 150.2 3604 150.17
Awaken#4279 4260 178 177.5 4260 177.50

edit: upon a closer look, i found that the report included damage / die from spike which is 999dmg, screenshot: image

so i looping through all the damage_events:

for rounds in data.get('data')[0].get('rounds'):
    for player in rounds.get('player_stats'):
        if player.get('player_puuid') == puuid:
            for dmg_event in player.get('damage_events'):
                if dmg_event.get('receiver_puuid') != puuid:
                    dmg += float(dmg_event.get('damage'))

this snippet had fix mandylindley#00000's and Starzie#4fun's adr which excluding the dmg from spike

Henrik-3 commented 1 year ago

Update: I pushed a fix that should address the issue. Could u maybe verify that it's working now as intended?

awexandrr commented 1 year ago

Hi, I tested the update and so far for 2 games, the report is good and accurate. thanks for the fix!