Skip to content

Summon, command and feed pets - #521

Merged
neeerp merged 5 commits into
masterfrom
v83/pets-summon-food
Oct 18, 2026
Merged

neeerp merged 5 commits into
masterfrom
v83/pets-summon-food

Conversation

@neeerp

@neeerp neeerp commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Stacked on #520 (v83/guild-invites-shops). Please change the base to master once #520 is merged, since GitHub won't retarget it here.

Pets, first steps (L159).

What changed

  • Summoning:
    • Pets come out of the Cash inventory as type-3 items named after their kind, and double-clicking one summons it.
    • The server keeps the pets out in the same closing-up list as the v83 client.
    • Others see the pets, and they persist across fields and relogs.
  • Commands and chat:
    • PET_COMMAND (0xA9) rolls the command against the pet's level range from Item.nx and adds closeness on success, answered with 174.
    • PET_CHAT (0xA8) is relayed.
    • HeavenClient matches chat lines against a pet's commands as v83's TryChatCommand does.
  • Food:
    • PET_FOOD (0x4C) feeds the pet out that is least full, and pets grow hungry over time.
    • Cash food works too.
    • HeavenClient plays the eat sound, reacts from the pet's food table, and shows closeness lines and the level-up effect.

Verification

  • New harness test pets; new client test pets.
  • Xvfb, with two clients: summoning, following, others seeing the pet, chat commands and feeding.
  • This layer passes cargo fmt --check and cargo check --workspace --tests.
  • At the top of the stack the full harness suite passes (run at 45e356d, the last server commit; the commits after it change only HeavenClient). All 83 client tests pass in a debug build.

Pets bought in the Cash Shop now come out of the Cash Inventory as type 3
items named after their kind, and double-clicking one summons it. The
server keeps the pets out in the same closing-up list the v83 client keeps,
so the indexes in SPAWN_PET (168) match: a pet that is out goes back,
without Follow the Lead a new pet replaces the old, and with it the lead
flag puts the new one first. Pets are stored by cash serial in a new pets
table, keep their place in the list across relogs, come back after every
map change, appear in SPAWN_PLAYER and CHAR_INFO, and their moves (0xA7)
are relayed to the map as MOVE_PET (170). The pet serials go in the stat
change right after HAIR, 8 bytes each.

HeavenClient follows v83 for the summon rules (USE_WAIT lock, the
three-pet limit and the lead question), the closing-up list, the reasons
a pet went back, the pets in SPAWN_PLAYER (it read a byte v83 doesn't
send), the pet stat bits, item type 3, and the stance byte. Its own pets
send their paths; other players' pets replay 170. A map change clears the
player's pets until the server sends them again.

Covered by game and net unit tests, the pets harness test, HeavenClient's
pets tests, and a two-client run: summon, follow, a watcher seeing the pet
walk, dismissal, and a portal trip there and back.
PET_COMMAND (0xA9) rolls the command's prob against the pet's level range
from Item.nx interact, adds its closeness on success with Cosmic's level
table, and answers the owner with 174. A closeness change re-sends the pet
item, and a level-up shows the pet level-up effect to the owner and the
map. Only the owner's client reacts to 174, so the owner's echoed PET_CHAT
(0xA8) is relayed as 171 to the others on the map.
HeavenClient now matches chat lines against a pet's commands the way v83's
TryChatCommand does: the line is trimmed, a renamed pet's name and any
leading '!', ',' or '~' are cut, and the rest must equal one of the
command's words for the pet's level, case and all. A match sends
PET_COMMAND. The answer (174) picks a random success or fail reaction,
plays its action, shows a line in the pet's chat balloon and sends it on as
PET_CHAT, which other clients play from 171. Still pets with randAction
entries play one now and then, and effect 4 shows a pet's level up for the
player and for others.

The server sets 171's balloon flag for answers to commands that called the
pet by name, since PET_CHAT itself does not carry it; watchers now see the
same balloon as the owner.
PET_FOOD (0x4C) gives a pet food from the USE tab to the pet out that is
least full. A pet that isn't full gains the food's spec/inc fullness, and a
closeness point if it was hungry; a full one refuses and loses a point,
which can lower its level. The server answers with 174, then an exclusive
inventory operation that takes the food and re-sends the pet, then the
level-up effect.

USE_CASH_ITEM (0x4F) now has a handler. It serves cash pet food (524xxxx):
the first pet out that the food's spec list names eats, fills up and gains
spec/inc closeness, and the server answers 76 before the same packets. A
food that suits no pet out gets 76's refusal. Every other cash item, for
now, gets an empty stat change so the client unlocks.

Every three minutes each pet out loses its info/hungry fullness. One left
at 5 or less goes home with 168 reason 1. These are Cosmic's rules, since
there is no v83 server to follow.

The route table test now counts the 68 world routes; it had not been
updated since the pet routes were added.
Double-clicking pet food in the USE tab, or its hotkey, sends PET_FOOD and
plays the eat sound of the pet that will eat it. 174's food answer picks a
reaction from the pet's food table for its level, and a pet whose closeness
changes shows "The closeness increased (+N)" or "decreased" in yellow.

Cash pet food in the Cash tab sends USE_CASH_ITEM and plays the shop sound,
or says "This item can only be used with a pet." in the chat bar when no pet
is out, as v83 does. 76 plays the pet's eat sound, or shows "Your pet cannot
consume this food. Please check again."
@neeerp
neeerp changed the base branch from v83/guild-invites-shops to master October 18, 2026 18:46
@neeerp
neeerp merged commit 89235ab into master Oct 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant