diff --git a/README.md b/README.md index 9fddbc0..053a1d4 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,12 @@ related events), where applicable: - `offset_y` - Float, `null` if not applicable - `casket_id` - If this item is contained in a casket (storage unit), this is a string containing that casket's item ID - `casket_contained_item_count` - If this item is a casket (storage unit), this is a count of how many items it contains +- `charm` - If a charm (sometimes referred to as keychain) is attached to the item, this object contains details about the charm. + - `charm_id` - The ID of the charm + - `offset_x` - Float + - `offset_y` - Float + - `offset_z` - Float + - `pattern` - The charm's pattern (1-100,000) Note that if any of the above attributes are not applicable, then they will not exist in the item object. diff --git a/handlers.js b/handlers.js index ca434b5..e96fd3e 100644 --- a/handlers.js +++ b/handlers.js @@ -249,6 +249,23 @@ GlobalOffensive.prototype._processSOEconItem = function(item) { item.stickers = stickers; } + // charms + let charmIdBytes = getAttributeValueBytes(299); + let charmOffsetXBytes = getAttributeValueBytes(300); + let charmOffsetYBytes = getAttributeValueBytes(301); + let charmOffsetZBytes = getAttributeValueBytes(302); + let charmPatternBytes = getAttributeValueBytes(306); + + if (charmIdBytes && charmOffsetXBytes && charmOffsetYBytes && charmOffsetZBytes && charmPatternBytes) { + item.charm = { + charm_id: charmIdBytes.readUInt32LE(0), + offset_x: charmOffsetXBytes.readFloatLE(0), + offset_y: charmOffsetYBytes.readFloatLE(0), + offset_z: charmOffsetZBytes.readFloatLE(0), + pattern: charmPatternBytes.readUInt32LE(0), + }; + } + // def_index-specific attribute parsing switch (item.def_index) { case 1201: