Pets never leave the get-hit mode: a struck skeleton stands and twitches until it dies

Open
#683 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
Half a day
Newbie friendliness
62/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp
Domain
game-dev

Research direction

The stall is in Fight::pets_turn in components/game/fight/pets.cpp, where the GH check continues before NecroPet and traced pets reach their think functions, and pet_walking never sees mode NU again. Compare with the get-hit reset in merc.cpp to see how the merc returns to NU. Reproduce with the devctl script in the issue, then confirm that a struck skeleton returns to NU and resumes following and attacking.

Written by the indexing model from the issue text.

Description

Version: v0.12.3 (macOS arm64 release). The same lines are in the tag v0.13.0 and in main at c5c3edda83 (2026-11-22, pets.cpp:380).

What happens

A Necromancer's skeleton or skeleton mage that takes a get-hit (GH) stays in GH for the rest of its life. It stops walking, following and attacking, and the get-hit animation keeps playing. Summoning a new one helps until that one is struck too.

Cause

components/game/fight/pets.cpp, Fight::pets_turn:

if (monster.mode == "GH" && now_ms < monster.mode_until) continue;
if (ai_name == "NecroPet") { necropet_turn(pet, now_ms, elapsed, crowd); continue; }
if (traced) { pet_think_turn(pet, now_ms, elapsed, crowd); continue; }

Once the get-hit is over nothing sets the mode back to NU. Both thinks start with pet_walking, which ends in

return monster.mode != "NU" || now_ms < monster.next_act;

set_mode(.., "GH", ..) cleared unit.walking, so this returns true on every turn and the think never runs again. The merc has the reset (merc.cpp):

if (actor->merc->mode == "GH") { if (now_ms < actor->merc->mode_until) return; set("NU"); actor->merc->next_act = now_ms; }

Fix that worked here

             if (monster.mode == "GH" && now_ms < monster.mode_until) continue;
+            if (monster.mode == "GH") { set_mode(*game_data, monster, "NU", now_ms); monster.next_act = now_ms; }
             if (ai_name == "NecroPet") { necropet_turn(pet, now_ms, elapsed, crowd); continue; }

This copies the merc's line; it is not traced against game.exe (the delay before the next think after a get-hit may differ).

Reproduction

Headless, --no-save, devctl; a level 23 Necromancer:

debug difficulty 2
debug goto 78            # Flayer Jungle
debug stat 7 256000000   # the owner survives
debug stat 6 256000000
debug kill 14            # corpses
cmd skill 70 <x> <y> <corpse unit>   # x6, then skill 80 x3
debug warp <5 cells short of the nearest living monster>
state                    # polled every 0.1 s, the pets= field

Same script, 40 s rounds, runs of consecutive GH polls per pet:

build GH runs longest what followed
v0.12.3 release 27 (two rounds) 15.6 s DT 9, pet list changed 15, still in GH at the end 3; never NU / WL / A1
v0.12.3 + the line above 25 (one round) 0.5 s A1 20, NU 2, pet list changed 3; never DT

("pet list changed": another pet died and the slots shifted, which cuts the run short in the poller.)

Dominant language
C++
Stars
17
Forks
6
Avg merge
6h 14m
Merged PRs (30d)
570

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from psi29a/d2decomped

All issues in psi29a/d2decomped

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.