Skip to content

Pet missing system#584

Merged
Volte6 merged 1 commit into
masterfrom
pet-missing
May 17, 2026
Merged

Pet missing system#584
Volte6 merged 1 commit into
masterfrom
pet-missing

Conversation

@Volte6
Copy link
Copy Markdown
Member

@Volte6 Volte6 commented May 17, 2026

Description

Adds a temporary-absence mechanic for pets. A pet can be sent away for a
configurable number of rounds and will automatically return when the countdown
expires. While absent the pet is hidden from all game systems — room
descriptions, combat, stat and buff contributions, item interactions, and
script dispatch — until it comes back.

Changes

Core pet model (internal/pets/pets.go)

  • Added MissingCountdown int field to Pet. When non-zero the pet is absent.
  • IsMissing() bool — returns true when the countdown is positive.
  • GoMissing(rounds int) — sets the countdown; zero or negative clears it immediately.
  • DecrementMissing() bool — decrements by one each round; returns true the round the countdown reaches zero.

Round tick (internal/hooks/NewRound_UserRoundTick.go)

  • Each round, if a player's pet is missing the countdown is decremented.
  • When the countdown reaches zero PetReturn is fired on the pet script.
  • PetAct is suppressed while the pet is missing and on the same round it returns.

Scripting (internal/scripting/)

  • ScriptPet gains IsMissing() and GoMissing(rounds) methods exposed to JavaScript.
  • GoMissing with a positive value fires PetLeave (only when the pet is not already missing, to avoid duplicate events on countdown extensions).
  • GoMissing(0) fires PetReturn immediately.
  • GetPet now accepts the owner's userId so script-triggered events have the context they need.
  • PetLeave and PetReturn are registered in the schema as new pet script events.

Commands — missing-state guards

The following commands now treat a missing pet as non-present, matching the
same behaviour as a player who has no pet at all:

File Change
usercommands/feed.go Cannot feed a missing pet
usercommands/get.go get <item> from pet ignores missing pet
usercommands/give.go give <item> to pet ignores missing pet
usercommands/go.go Missing pet does not emit follow messages on room exit
usercommands/look.go look pet targets missing pet for a "not here" message; restored first-person "You look at X" line
usercommands/pet.go Cannot rename or interact with a missing pet
usercommands/usercommands.go Pet script command interception disabled while missing

Room and combat systems

  • rooms/roomdetails.go — missing pet excluded from the visible-players list.
  • rooms/rooms.goFindHasPet flag excludes missing pets for both players and mobs.
  • combat/combat.go — pet combat participation gated on !IsMissing().
  • characters/character.goStatMod and reapplyPermabuffs skip pet contributions while missing.

GMCP (modules/gmcp/gmcp.Char.go)

  • Missing pet excluded from the Char GMCP payload.

Documentation (_datafiles/guides/building/scripting/)

  • FUNCTIONS_PETS.md — documents IsMissing() and GoMissing() with examples.
  • SCRIPTING_PETS.md — documents the PetLeave and PetReturn script events with examples.

Example script usage

// Random chance each round for the pet to wander off
function PetAct(pet, actor, room) {
    if (RandInt(1, 100) === 1) {
        pet.GoMissing(10);
    }
}

function PetLeave(pet, actor, room) {
    room.SendText(pet.NameSimple() + ' darts into the shadows and disappears!');
}

function PetReturn(pet, actor, room) {
    room.SendText(pet.NameSimple() + ' trots back to your side.');
}

// Allow the owner to recall the pet early
function onCommand_recall(rest, pet, actor, room) {
    if (pet.IsMissing()) {
        pet.GoMissing(0);
        actor.SendText('Your pet bounds back to your side!');
        return true;
    }
    return false;
}

@Volte6 Volte6 merged commit d8e9f5d into master May 17, 2026
8 checks passed
@Volte6 Volte6 deleted the pet-missing branch May 17, 2026 05:14
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