Items
packets11 packets
Clothing: the inventory, wearing and taking off, buying and recycling (item.ItemXtCommManager).
An item in the inventory is named by its invId (Item.invIdx). Eyes and patterns are items too, with no place in the inventory: their invId is their definition id made negative (ItemXtCommManager.getBodyModFromDefId), and they are worn and taken off the same way.
Hearing and sending packets
What the game sends is heard on phantom.packets.client, and what the server sends on phantom.packets.server. watch hears a packet after it has gone through; on hears it first and may change or drop it; send sends one to that end. See Packets.
Overview
| Packet | Command | Way | What it is |
|---|---|---|---|
ItemListRequest | il | game → server | The client asks for an avatar’s items. |
ItemList | il | server → game | The server lists or changes an avatar’s items. |
ItemUse | iu | game → server | The player puts items on and takes items off. |
ItemUseResult | iu | server → game | The server says whether the player’s items changed. |
ItemBuy | ib | game → server | The player buys an item. |
ItemBuyResult | ib | server → game | The server says whether an item was bought. |
ItemRecycle | ir | game → server | The player recycles items. |
ItemRecycleResult | ir | server → game | The server says which items were recycled. |
ItemDiamondBundleBuy | id | game → server | The player buys the bundle shop’s whole bundle for diamonds. |
ItemDiamondBundleBuyResult | id | server → game | The server says whether the bundle shop’s whole bundle was bought. |
ItemPrize | ip | server → game | The server offers the player a prize. |
ItemListRequest
Asks for an avatar's items (ItemXtCommManager.requestItemListForAvatar): [userName, perUserAvId, full]. full asks for the whole inventory rather than what the avatar wears; the client sets it the first time it asks for the player's own.
Fields
| Field | Type | |
|---|---|---|
userName | string | The player whose avatar it is, by username. |
perUserAvId | number | Which of the player's avatars, by its per user id. |
full | boolean | Asks for the whole inventory rather than what the avatar wears. The client sets it the first time it asks for the player's own. |
room | number | The room the message was sent in, as the SmartFox room id; -1 when it names none. |
Example
// Each time the game sends it to the server, after it has gone through.
const stop = phantom.packets.client.watch(packets.ItemListRequest, (packet) => {
console.log(packet.userName, packet.perUserAvId, packet.full);
});ItemList
An avatar's items (ItemXtCommManager.itemListResponse). The field after the room says which kind of list follows:
0 %xt%il%<room>%0%<unused>%<perUserAvId>%<userName>%<pattern>%<eyes>%<count>%<items>...% 1 the same, for the items worn (itemsInUseResponse) 2 %xt%il%<room>%2%<wear>%<perUserAvId>%<userName>%<color>%<added>%<removed>% <invId>%<defId>%...%<invId>%...% 3 the same, when only what is worn changed -1 a failure
The pattern comes before the eyes, as Animal Jam's server sends them (a raccoon's %457%3%, pattern 457 and eyes 3) and as generateBodyModList(avInvId, patternDefId, eyesDefId) names them; the client marks both as worn alike, so the order shows only in what reads them.
Each item is <defId>%<invId>%<color>%, and in the player's own inventory also <equippedAvatars>%<denStoreInvId>% (generateClothingList). The client knows the list is its own by the name; the packet goes by how many fields the items take, three or five each.
Fields
| Field | Type | |
|---|---|---|
kind | "inventory" | "worn" | "changed" | "failed" | inventory is the whole list (itemListResponse); worn is what the avatar wears (itemsInUseResponse), always without the player's details. Items came or went, or were put on or taken off (itemsChangedListResponse). The server sent -1: there is no list. |
room | number | The room the message was sent in, as the SmartFox room id; -1 when it names none. |
Example
// Each time the server sends it to the game, after it has gone through.
const stop = phantom.packets.server.watch(packets.ItemList, (packet) => {
console.log(packet.kind);
});ItemUse
Puts items on and takes items off the player's avatar (ItemXtCommManager.requestItemUse, sent by the avatar editor and the shop when it closes):
%xt%o%iu%<room>%<wearCount>%<removeCount>%<invId>%...%<invId>%...%
The client sends nothing when both lists are empty.
Fields
| Field | Type | |
|---|---|---|
wear | number[] | The items to put on, by invId (negative for eyes and patterns). |
remove | number[] | The items to take off, by invId. |
room | number | The room the message was sent in, as the SmartFox room id; -1 when it names none. |
Example
// Each time the game sends it to the server, after it has gone through.
const stop = phantom.packets.client.watch(packets.ItemUse, (packet) => {
console.log(packet.wear, packet.remove);
});ItemUseResult
Whether the items were put on and taken off (ItemXtCommManager.itemUseResponse): %xt%iu%<room>%1%. What the avatar wears then arrives as an item.list change.
Fields
| Field | Type | |
|---|---|---|
success | boolean | The change went through: the field is 1. |
extra | string[] | Whatever follows, as it came. |
room | number | The room the message was sent in, as the SmartFox room id; -1 when it names none. |
Example
// Each time the server sends it to the game, after it has gone through.
const stop = phantom.packets.server.watch(packets.ItemUseResult, (packet) => {
console.log(packet.success, packet.extra);
});ItemBuy
Buys an item from a shop (ItemXtCommManager.requestItemBuy, called by shop.Shop):
%xt%o%ib%<room>%<shopId>%1%<defId>%<colorIndex>%<diamond>%<targetInvId>%<targetUserName>%
quantity is always 1. diamond is set for an item bought with diamonds. targetInvId and targetUserName are -1 and empty, except for a charm bought for a den item (the den item's invIdx and its owner).
Fields
| Field | Type | |
|---|---|---|
shopId | number | The shop the item is bought from, by its id. |
quantity | number | How many to buy. The client always sends 1. |
defId | number | The item's definition id. |
colorIndex | number | Which of the item's colours, by its index in the item's def. |
diamond | boolean | The item is bought with diamonds. |
targetInvId | number | For a charm bought for a den item, that den item's invIdx; otherwise -1. |
targetUserName | string | For a charm bought for a den item, that item's owner; otherwise empty. |
room | number | The room the message was sent in, as the SmartFox room id; -1 when it names none. |
Example
// Each time the game sends it to the server, after it has gone through.
const stop = phantom.packets.client.watch(packets.ItemBuy, (packet) => {
console.log(packet.shopId, packet.quantity, packet.defId);
});ItemBuyResult
The result of a purchase (ItemXtCommManager.itemBuyResponse):
%xt%ib%<room>%<status>%<shopId>%<balance>%<currencyType>%
status is an ITEM_BUY_STATUS; balance is the currency left afterwards, or empty when unchanged. For something priced in several crafting currencies at once (currencyType 100) the balance is the combined form UserCurrency.setCurrency takes, 4x10,5x20. The item itself arrives as an item.list change.
Fields
| Field | Type | |
|---|---|---|
status | number | An ITEM_BUY_STATUS: 1 bought, -2 no longer to be had, anything else refused. |
shopId | number | The shop it was bought from, by its id. |
balance | string | number | null | The currency left afterwards: a number, the combined form (4x10,5x20) for several crafting currencies, or null when the field is empty (unchanged). |
currencyType | number | Which currency balance is, by its index (CURRENCY), or 100 for several. |
extra | string[] | Whatever follows, as it came. |
room | number | The room the message was sent in, as the SmartFox room id; -1 when it names none. |
Example
// Each time the server sends it to the game, after it has gone through.
const stop = phantom.packets.server.watch(packets.ItemBuyResult, (packet) => {
console.log(packet.status, packet.shopId, packet.balance);
});ItemRecycle
Recycles items for gems (ItemXtCommManager.requestItemRecycle, called by gui.RecycleItems): the items' invIds, with no count before them.
Fields
| Field | Type | |
|---|---|---|
invIds | number[] | The items to recycle, by invId: every field of the message. |
room | number | The room the message was sent in, as the SmartFox room id; -1 when it names none. |
Example
// Each time the game sends it to the server, after it has gone through.
const stop = phantom.packets.client.watch(packets.ItemRecycle, (packet) => {
console.log(packet.invIds);
});ItemRecycleResult
Items recycled (ItemXtCommManager.itemRecycleResponse):
%xt%ir%<room>%<count>%<gems>%<invId>%...%
gems is the balance afterwards, -1 when unchanged. No items means nothing was recycled.
Fields
| Field | Type | |
|---|---|---|
gems | number | The gem balance afterwards, or -1 when unchanged. |
invIds | number[] | The items recycled, by invId. Empty when nothing was recycled. |
room | number | The room the message was sent in, as the SmartFox room id; -1 when it names none. |
Example
// Each time the server sends it to the game, after it has gone through.
const stop = phantom.packets.server.watch(packets.ItemRecycleResult, (packet) => {
console.log(packet.gems, packet.invIds);
});ItemDiamondBundleBuy
Buys the bundle shop's whole bundle for diamonds (ItemXtCommManager.requestBuyDiamondBundle, from shop.BundleShop's buy button). The bundle shop always sends its own id, 1.
Fields
| Field | Type | |
|---|---|---|
shopId | number | The bundle shop's id. The client always sends 1. |
room | number | The room the message was sent in, as the SmartFox room id; -1 when it names none. |
Example
// Each time the game sends it to the server, after it has gone through.
const stop = phantom.packets.client.watch(packets.ItemDiamondBundleBuy, (packet) => {
console.log(packet.shopId);
});ItemDiamondBundleBuyResult
Whether the bundle was bought (ItemXtCommManager.itemDiamondBundleResponse, read by BundleShop.onDiamondPurchaseComplete):
%xt%id%<room>%<bought>%<balance>%
bought is written true/false, not 1/0, as BundleShop reads it; balance is absent for a refusal, which the client then leaves the diamond balance alone for.
Fields
| Field | Type | |
|---|---|---|
bought | boolean | Whether the bundle was bought. |
balance | number | null | The diamonds left afterwards, or null when the server sent none (a refusal). |
extra | string[] | Whatever follows, as it came. |
room | number | The room the message was sent in, as the SmartFox room id; -1 when it names none. |
Example
// Each time the server sends it to the game, after it has gone through.
const stop = phantom.packets.server.watch(packets.ItemDiamondBundleBuyResult, (packet) => {
console.log(packet.bought, packet.balance, packet.extra);
});ItemPrize
A prize the server hands the player (ItemXtCommManager.itemPrizeResponse, which passes it to GuiManager.onItemPrize). The client never asks for it. It keeps the prize and shows it at the next chance it has (GuiManager.showPrizePopupIfAny): a popup with the prize's description, then a gift popup to keep or throw it away. Keeping it sets the user var the prize names (requestSetUserVar(userVarId, 3 | color << 4)), which is how the server hands it over.
%xt%ip%<room>%<userVarId>%<isClothing>%<defId>%<nameStrId>%<descStrId>%<color>%
Fields
| Field | Type | |
|---|---|---|
userVarId | number | The user var that keeping the prize sets. |
isClothing | boolean | Whether the prize is clothing: 1. The client draws it as a den item either way. |
defId | number | The prize's definition id, which the client looks up as a den item's. |
nameStrId | number | The prize's name, as a localisation string id. |
descStrId | number | What the popup says about it, as a localisation string id. |
color | number | Its colour, as the client passes it to the den item's icon (uint). |
extra | string[] | Whatever follows, as it came. |
room | number | The room the message was sent in, as the SmartFox room id; -1 when it names none. |
Example
// Each time the server sends it to the game, after it has gone through.
const stop = phantom.packets.server.watch(packets.ItemPrize, (packet) => {
console.log(packet.userVarId, packet.isClothing, packet.defId);
});