Skip to content

Guard Illness#11637

Open
armele wants to merge 6 commits into
ldtteam:version/mainfrom
armele:guard_to_hospital
Open

Guard Illness#11637
armele wants to merge 6 commits into
ldtteam:version/mainfrom
armele:guard_to_hospital

Conversation

@armele
Copy link
Copy Markdown
Contributor

@armele armele commented Apr 27, 2026

Closes #11597

I could not reliably reproduce the symptom (guards not going to the hospital when sick) in a consistent, repeatable pattern, so I am not 100% sure that these fixes completely resolve it - but they address the theories I have as to the root cause.

Changes proposed in this pull request

  • Adjusted EntityAISickTask to not stop the trip to the hospital until the entity is asleep in a hospital bed (not just asleep somewhere randomly, as guards are prone to do).
  • Adjusted CitizenAI to prioritize addressing illness as a higher priority than addressing hunger.
  • Adjusted AbstractEntityAIGuard to allow sickness to make them interruptable in their guard duties, and to wake them up (in case they become ill while sleeping).
  • Exposed the sickness immunity through the ICitizenDiseaseHandler API.

Testing

I poisoned my entire barracks full of guards with rotten flesh and noted that they went to the hospital if closer to the hospital, and the hut block if closer to work. Once at the hospital, they found a bed until cured, then left and resumed their guard duties.

Poisoned guards and citizens without a hospital to ensure no exceptions or adverse behavior.

Review please

@github-actions
Copy link
Copy Markdown

In order for this pull request to be merged, make sure you test whether your changes work.

If the changes are working as intended, remove the https://github.com/ldtteam/minecolonies/labels/undefined label from the pull request.
As long as this label is on the pull request, it will not be merged.
If your pull request made no changes to the source code, the label will not be automatically added to the pull request.

Contributors, please review this pull request!

@armele
Copy link
Copy Markdown
Contributor Author

armele commented Apr 27, 2026

Please remove the "Untested" label. Tested as described above.

{
if (citizen.getCitizenJobHandler().getColonyJob() instanceof AbstractJobGuard guardJob)
{
if (shouldEat())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure if sick should be > food

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restored eating > sick.

@armele
Copy link
Copy Markdown
Contributor Author

armele commented May 12, 2026

Please remove the "Untested" label. Tested by poisoning my barracks and observing that they headed off to the hospital.

@Thodor12 Thodor12 removed the Untested label May 22, 2026
return SEARCH_HOSPITAL;
}

citizen.getCitizenSleepHandler().onWakeUp();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won 't this make them get up from the hospital bed if they're inside?

Copy link
Copy Markdown
Contributor Author

@armele armele May 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention is actually if they are asleep somewhere NOT a hospital bed, that it wakes them up and restarts their search. (Full snippet in this area is

if (citizen.getCitizenSleepHandler().isAsleep())
        {
            if (isSleepingInHospitalBed())
            {
                return SEARCH_HOSPITAL;
            }

            citizen.getCitizenSleepHandler().onWakeUp();
            return GO_TO_HUT;
        }

However, per your comment from three weeks ago we can make this smarter - no need to go to the hut in this situation. This could be

if (citizen.getCitizenSleepHandler().isAsleep())
        {
            if (isSleepingInHospitalBed())
            {
                return WAIT_FOR_CURE;
            }

            citizen.getCitizenSleepHandler().onWakeUp();
            return SEARCH_HOSPITAL;
        }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this could be triggered at night... I will give some thought as to what to do with "asleep not in a hospital bed at night, and sick".

if (citizen.getCitizenData().getCitizenDiseaseHandler().isSick())
{
return GO_TO_HUT;
return SEARCH_HOSPITAL;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In search hospital we should add a "if closer to building than closest hospital go to building first"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently the main path to SEARCH_HOSPITAL is from GO_TO_HUT (so effectively they go to their work location first, not the hospital). I think if we want to add the "if closer to building than closest hospital, go to building first" (which suggests "if closer to hospital than work building, go to hospital first") logic we would actually want to do that from goToHut(). Unless you object, I will add it there.

@Raycoms
Copy link
Copy Markdown
Contributor

Raycoms commented May 24, 2026 via email

@armele
Copy link
Copy Markdown
Contributor Author

armele commented May 24, 2026

Addressed code review feedback and re-tested with adjusted logic. I also exposed the immunity ticks on the API for future potential use in add-on mods.

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.

Ill guards do not go to hospital

3 participants