Repository navigation
Summon, command and feed pets - #521
Merged
Merged
Conversation
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."
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #520 (
v83/guild-invites-shops). Please change the base tomasteronce #520 is merged, since GitHub won't retarget it here.Pets, first steps (L159).
What changed
Verification
pets; new client testpets.cargo fmt --checkandcargo check --workspace --tests.