Bungie-net / api

Resources for the Bungie.net API
Other
1.22k stars 92 forks source link

How identify weapon classes and attributes based on given Ids from PGCR? #453

Open ynorouzz opened 6 years ago

ynorouzz commented 6 years ago

I extracted the match data by PGCR that includes us weapon kills/precision kills for specific unique weapons for each player in a match. (player -> extended -> weapons -> WeaponNo. -> values -> referenceID ). How can I identify the weapon classes that these IDs belong to, or any way to map these weapons to classes and attributes?

vthornheart-bng commented 6 years ago

Ah, yes! So unfortunately that field is poorly named: usually our standard is to refer to such identifiers as "hashes": as you look through other data in the API, you'll see that as the usual standard for referring to the numerical identifier of the definition of an entity.

In this case, the referenceID is the numerical, content version-agnostic identifier for the definition of an inventory item. If you are extracting the mobile manifest databases, you'll be able to find this data in the Items table: you'll have to cast the ID to a signed integer if you're doing a query directly against the database, and when you do so it'll return a JSON blob that you can deserialize into one of these:

https://bungie-net.github.io/multi/schema_Destiny-Definitions-DestinyInventoryItemDefinition.html#schema_Destiny-Definitions-DestinyInventoryItemDefinition

The itemType and itemSubType are some easy to use enum values contained in that definition that'll give you some data about the item's type. If you don't mind cross-referencing to another set of definitions (DestinyItemCategoryDefinition), you can use the itemCategoryHashes property to get more detailed item type information.

Hopefully this helps!

ynorouzz commented 6 years ago

Thank you for your help. So I can use manifest database to find weapon classes as mentioned here.

vthornheart-bng commented 6 years ago

Yes indeed! I still need to write an official guide, but the old guide from lowlines still holds true (as long as you replace any /destiny_content/ folders with /destiny2_content/)

ynorouzz commented 6 years ago

I tried to map the “DestinyInventoryItemDefinition” hash dictionary to the weapon table with reference id. For example, I select reference_id “174804902” to map. We can use bucketTypeHash “953998645” to map the “DestinyInventoryBucketDefinition” dictionary back to the weapon table. But there are many items in the DestinyInventoryItemDefinition dictionary with the same bucketTypeHash and I can not find the common key to map DestinyInventoryItemDefinition and weapon table.

vthornheart-bng commented 6 years ago

Oh, you're looking for the type of the weapon right?

Once you look up the DestinyInventoryItemDefinition - indeed, use 174804902 to grab the relevant definition directly - try using the itemType and itemSubType enum values. That should give you what you want, because indeed the Buckets won't be sufficient info to know the type of weapon. Try that out and let me know if that gives you what you seek!