Pets
packets16 packets
Pets: the player's list, bringing one out or putting it away, adopting, buying, dressing and freeing one, and the kinds the account has unlocked (pet.PetXtCommManager and pet.PetManager in the client).
A pet's look is packed into three numbers, lBits, uBits and eBits (PetManager.packPetBits). The low byte of lBits is the pet's definition id (PetManager.getDefIdFromLBits); lBits of 0 means no pet at all.
Phantom's private server has more pets than a byte holds (petDefId): one of its custom pets is a low byte from 160 up, which none of Animal Jam's own is (theirs end at 123), and its whole lBits is its def.
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 |
|---|---|---|---|
PetListRequest | pl | game → server | The client asks for a player’s pets. |
PetList | pl | server → game | The server lists a player’s pets. |
PetSwitchRequest | ps | game → server | The player brings out a pet, or puts theirs away. |
PetSwitched | ps | server → game | Someone brought out a pet or put theirs away. |
PetMasteryDisplayRequest | pm | game → server | The player shows or hides a pet’s mastery badge. |
PetMasteryDisplayed | pm | server → game | The server says whether a pet’s mastery badge changed. |
PetEggNameRequest | pn | game → server | The player names a newly hatched egg pet from two lists of predefined name parts. |
PetEggNamed | pn | server → game | The server says whether an egg pet was named. |
PetCreateRequest | pc | game → server | The player adopts a new pet. |
PetCreated | pc | server → game | The server says whether a new pet was adopted. |
PetDismissRequest | pd | game → server | The player frees one of their pets. |
PetDismissed | pd | server → game | The server says whether a pet was freed. |
PetShopBuyRequest | pb | game → server | The player buys a pet they have not unlocked from a shop. |
PetItemsRequest | pi | game → server | The player changes what their pet that is out is wearing. |
PetItemsChanged | pi | server → game | The server says whether the pet that is out now wears something new. |
PetsUnlocked | pu | server → game | The server says which kinds of pet the account has unlocked. |
PetListRequest
Asks for a player's pets (PetXtCommManager.sendPetListRequest(userName)).
Fields
| Field | Type | |
|---|---|---|
userName | string | The player whose pets to list, by username. |
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.PetListRequest, (packet) => {
console.log(packet.userName);
});PetList
A player's pets (PetManager.onPetListResponse):
%xt%pl%<room>%1%<userName>%<count>%<invId>%<createdTs>%<name>%<lBits>%<uBits>%<eBits>% <mastery>%<personality>%<toy>%<food>%<denStoreInvId>%...%
Anything but 1 after the room means there is no list, and the client reads nothing more.
Fields
| Field | Type | |
|---|---|---|
found | boolean | The server sent a list: the field after the room is 1. |
userName | string | The player the pets belong to, by username; empty when there is no list. |
pets | ListedPet[] | The player's pets, after their count; empty when 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.PetList, (packet) => {
console.log(packet.found, packet.userName, packet.pets);
});PetSwitchRequest
Brings out one of the player's pets, or puts the active one away with 0 (PetXtCommManager.sendPetSwitchRequest(invId), sent by gui.PetInventory).
Fields
| Field | Type | |
|---|---|---|
invId | number | The pet to bring out, by its place in the player's inventory, or 0 to put it away. |
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.PetSwitchRequest, (packet) => {
console.log(packet.invId);
});PetSwitched
Someone in the room brought out a pet or put theirs away (PetManager.onPetSwitchResponse):
%xt%ps%<room>%1%<userId>%<activePetInvId>% to the player who switched %xt%ps%<room>%1%<userId>%<lBits>%<uBits>%<eBits>%<name>%<createdTs>%<personality>%<food>%<toy>% to everyone else
The client tells the two apart by whether userId is its own; the message does not say, so the packet goes by how many fields follow. %xt%ps%<room>%0% is a refused switch.
Fields
| Field | Type | |
|---|---|---|
success | boolean | The switch went through: the field after the room is 1. |
userId | number | The SmartFox user id of the player who switched, or -1 for a refused switch. |
activePetInvId | number | null | The inventory id of the pet now out, 0 when it was put away. Sent only to the player who switched; null otherwise. |
pet | RoomPet | null | The pet now out, as everyone else is told; null in the switcher's own form. |
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.PetSwitched, (packet) => {
console.log(packet.success, packet.userId, packet.activePetInvId);
});PetMasteryDisplayRequest
Shows or hides the badge a pet's mastery earned it, as the pet inventory's mastery button does (PetXtCommManager.sendPetMasteryRequest(show, invId), sent by gui.PetInventory.onMasteryBtn). show is a bit of the pet's own uBits, so this is a look, not a training session: nothing about the pet's mastery counter changes.
Fields
| Field | Type | |
|---|---|---|
show | boolean | Whether to show the badge. |
invId | number | The pet, by its place in the player's inventory. |
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.PetMasteryDisplayRequest, (packet) => {
console.log(packet.show, packet.invId);
});PetMasteryDisplayed
Whether a pet's mastery badge is shown now (PetManager.onPetMasteryResponse):
%xt%pm%<room>%1%<invId>%<lBits>%<uBits>%<eBits>%
The three numbers are the pet's look with the badge's bit already folded into uBits, exactly as the client keeps it afterwards. %xt%pm%<room>%0% is a refused request.
Fields
| Field | Type | |
|---|---|---|
success | boolean | The change went through: the field after the room is 1. |
invId | number | The pet, by its place in the player's inventory. |
lBits | number | The pet's look, unchanged. |
uBits | number | The pet's look, with the badge's bit now set or cleared. |
eBits | number | The pet's look, unchanged. |
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.PetMasteryDisplayed, (packet) => {
console.log(packet.success, packet.invId, packet.lBits);
});PetEggNameRequest
Names a newly hatched egg pet, picking two name parts from the naming popup's own two lists (PetXtCommManager.sendPetEggNameRequest(invId, firstNameLocId, secondNameLocId), sent by gui.EggPetHatchedPopup). The parts are localisation ids, not free text: the popup offers two scrollable lists of predefined name halves and the player picks one from each.
Fields
| Field | Type | |
|---|---|---|
invId | number | The pet's place in the player's inventory. |
firstNameLocId | number | The first name part, a localisation id from the naming popup's first list. |
secondNameLocId | number | The second name part, a localisation id from the naming popup's second list. |
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.PetEggNameRequest, (packet) => {
console.log(packet.invId, packet.firstNameLocId, packet.secondNameLocId);
});PetEggNamed
Whether an egg pet was named, and its name afterwards (PetManager.onPetEggNameResponse).
Fields
| Field | Type | |
|---|---|---|
success | boolean | The name was taken: the field after the room is 1. |
invId | number | The pet's place in the player's inventory. |
name | string | The name the server kept, built from the two parts the client sent. |
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.PetEggNamed, (packet) => {
console.log(packet.success, packet.invId, packet.name);
});PetCreateRequest
Adopts a brand new pet, coloured and named as the pet creator has it (PetXtCommManager.sendPetCreateRequest(shopId, lBits, uBits, eBits, firstNameLocId, secondNameLocId, fromRedemption), sent by gui.PetCreator). PetManager.packPetBits is what packs a kind, its colours and its parts into lBits, uBits and eBits.
Fields
| Field | Type | |
|---|---|---|
shopId | number | The shop the pet is adopted from, by its id. |
lBits | number | The pet's packed look: a kind, its colours and its parts (PetManager.packPetBits). |
uBits | number | The pet's packed look, the second of the three numbers. |
eBits | number | The pet's packed look, the third of the three numbers. |
firstNameLocId | number | The first name part, a localisation id from the pet creator's first name list. |
secondNameLocId | number | The second name part, a localisation id from the pet creator's second name list. |
fromRedemption | boolean | Whether this adoption comes from redeeming a card rather than an ordinary purchase. |
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.PetCreateRequest, (packet) => {
console.log(packet.shopId, packet.lBits, packet.uBits);
});PetCreated
Whether a new pet was adopted, and the pet itself, with what it cost (PetManager.onPetCreateResponse, which folds the pet into myPetList through insertPet).
Fields
| Field | Type | |
|---|---|---|
success | boolean | The pet was adopted: the field after the room is 1. |
balance | number | What is left of the currency it cost. |
currencyType | number | Which currency balance is, by its index (CURRENCY). |
pet | { invId: number; lBits: number; uBits: number; eBits: number; name: string; createdTs: number; personalityDefId: number; favoriteToyDefId: number; favoriteFoodDefId: number; broughtOut: boolean; } | null | The pet the server made: its inventory id, its packed look, its name and its traits. |
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.PetCreated, (packet) => {
console.log(packet.success, packet.balance, packet.currencyType);
});PetDismissRequest
Frees one of the player's pets for good (PetXtCommManager.sendPetDismissRequest(invId), sent by gui.PetInventory once the player confirms).
Fields
| Field | Type | |
|---|---|---|
invId | number | The pet to free, by its place in the player's inventory. |
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.PetDismissRequest, (packet) => {
console.log(packet.invId);
});PetDismissed
Whether a pet was freed, and which (PetManager.onPetDismissResponse).
Fields
| Field | Type | |
|---|---|---|
success | boolean | The pet was freed: the field is 1. |
invId | number | The pet, by its place in the player's inventory. |
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.PetDismissed, (packet) => {
console.log(packet.success, packet.invId);
});PetShopBuyRequest
Buys a kind of pet the account has not unlocked, from the shop the pet creator was opened for, coloured and named as the creator has it (PetXtCommManager.sendPetShopBuyRequest(shopId, itemDefId, lBits, uBits, eBits, firstNameLocId, secondNameLocId, callback, fromRedemption), sent by gui.PetCreator in place of pc when the kind is not unlocked and came from the diamond shop).
The server answers with pc (pet.created): the client hands both requests' answers to the same callback.
Fields
| Field | Type | |
|---|---|---|
shopId | number | The shop the pet is bought from, by its id; the pet creator uses 214 for the diamond shop. |
itemDefId | number | What is bought: the diamond shop item's def id, not the pet's own kind. |
lBits | number | The pet's packed look: a kind, its colours and its parts (PetManager.packPetBits). |
uBits | number | The pet's packed look, the second of the three numbers. |
eBits | number | The pet's packed look, the third of the three numbers. |
firstNameLocId | number | The first name part, a localisation id from the pet creator's first name list. |
secondNameLocId | number | The second name part, a localisation id from the pet creator's second name list. |
fromRedemption | boolean | Whether this comes from redeeming a card rather than an ordinary purchase. |
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.PetShopBuyRequest, (packet) => {
console.log(packet.shopId, packet.itemDefId, packet.lBits);
});PetItemsRequest
Changes what the pet that is out is wearing, as the pet salon's "done" button does (PetXtCommManager.sendPetItemRequest(cat9, cat10, cat11, enviroType, callback), sent through MinigameManager.sendPetItemRequest by game.microPetSalon.MicroPetSalon).
cat9, cat10 and cat11 are the salon's own names for slots 9, 10 and 11 of the pet's look (PetManager.packPetBits), the three things it wears; the server works the new look out itself.
Fields
| Field | Type | |
|---|---|---|
cat9 | number | Slot 9 of the pet's look, as the salon picked it. |
cat10 | number | Slot 10 of the pet's look, as the salon picked it. |
cat11 | number | Slot 11 of the pet's look, as the salon picked it. |
enviroType | number | The room's world, as MinigameManager.roomEnviroType gives it: 0 land, 1 ocean. |
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.PetItemsRequest, (packet) => {
console.log(packet.cat9, packet.cat10, packet.cat11);
});PetItemsChanged
What the pet that is out wears now, and the gems left after paying for it (PetManager.onPetItemsResponse):
%xt%pi%<room>%1%<gems>%<invId>%<lBits>%<uBits>%<eBits>%
The client sets its gems to the balance, then puts the new look on the pet that is out, in the room and in the den. %xt%pi%<room>%0% is a refusal.
Fields
| Field | Type | |
|---|---|---|
success | boolean | The change went through: the field after the room is 1. |
gems | number | The player's gems afterwards (UserCurrency.setCurrency(gems, 0)). |
invId | number | The pet, by its place in the player's inventory; the client checks it is the one out. |
lBits | number | The pet's new look, the first of the three numbers. |
uBits | number | The pet's new look, the second of the three numbers. |
eBits | number | The pet's new look, the third of the three numbers. |
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.PetItemsChanged, (packet) => {
console.log(packet.success, packet.gems, packet.invId);
});PetsUnlocked
The kinds of pet the account has unlocked (PetXtCommManager.onPetUnlockResponse, which sets PetManager.unlockedPets). The client never asks for it; the server sends it on its own:
%xt%pu%<room>%<bit field>%
unlockedPetDefIds reads the bit field into kinds.
Fields
| Field | Type | |
|---|---|---|
unlockedPets | string | The unlocked kinds as the client's ScalableBitField takes them: comma separated words. |
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.PetsUnlocked, (packet) => {
console.log(packet.unlockedPets);
});