Skip to content

Fix AI team recruitment inconsistency causing underfilled teams#2172

Open
handama wants to merge 4 commits intoPhobos-developers:developfrom
handama:bugfix-teamRecruitment
Open

Fix AI team recruitment inconsistency causing underfilled teams#2172
handama wants to merge 4 commits intoPhobos-developers:developfrom
handama:bugfix-teamRecruitment

Conversation

@handama
Copy link
Copy Markdown
Contributor

@handama handama commented Apr 15, 2026

In certain situations, the AI incorrectly assumes that some units on the map are recruitable when forming a team, leading to teams that can never reach full strength. For example, when there are 3 GI on the map with recruitable flags (RecruitableA, RecruitableB) set to 1,1; 1,0; and 0,0, and an AI team with Autocreate enabled is created via trigger action 4 (Create Team), only the units with 1,1 should be considered recruitable, and the AI should produce 2 additional GIs to fill the team. However, during production planning (0x4DA230), the AI incorrectly treats units with 1,0 or 0,0 as recruitable and therefore only produces 1 GI. During actual recruitment (0x6EA610), these GIs are skipped due to stricter conditions, leaving the team permanently underfilled. Notably, if the intermediate GI (1,0) is destroyed, the AI will then correctly produce the missing GI and the team can finally form.
Snipaste_2026-04-15_15-12-31
testmap.zip

This PR addresses it by modifying 0x4DA230 so that its conditions match those of 0x6EA610 as closely as possible to avoid such inconsistencies.

@phoboscn-bot
Copy link
Copy Markdown

To Chinese users:
This pull request has been mentioned on Phobos CN. There might be relevant details there:

致中文用户:
此拉取请求已在 Phobos CN 上被提及。那里可能有相关详细信息:

https://www.phoboscn.top/t/topic/358/11

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 15, 2026

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

@Coronia
Copy link
Copy Markdown
Contributor

Coronia commented Apr 15, 2026

as far as I know, if Recruitable A and B are both set to 0, the unit will not be considered as occupying a team member. AI will still skip it when recruiting a team and build sufficient units instead

Making it as 1,0 is indeed problematic but maybe a toggle is needed for this fix, since it'll alter the AI behaviors of existing missions, making their AI unintentionally stronger

@handama
Copy link
Copy Markdown
Contributor Author

handama commented Apr 15, 2026

as far as I know, if Recruitable A and B are both set to 0, the unit will not be considered as occupying a team member. AI will still skip it when recruiting a team and build sufficient units instead

Making it as 1,0 is indeed problematic but maybe a toggle is needed for this fix, since it'll alter the AI behaviors of existing missions, making their AI unintentionally stronger

I understand the concern about potentially affecting AI strength, but I don’t think a toggle is necessary here. This change mainly fixes a case which is more of a bug than intended behavior. The situations where this occurs should also be relatively limited, so the overall impact on existing missions is likely small. What do you think?

@DeathFishAtEase DeathFishAtEase added ❓Vanilla bug Vanilla game bugs that are requested to be fixed Needs testing ⚙️T1 T1 maintainer review is sufficient labels Apr 15, 2026
Copy link
Copy Markdown
Contributor

@TaranDahl TaranDahl left a comment

Choose a reason for hiding this comment

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

The code looks good to me.
I have a shallow understanding of the Team system. So I think I am not qualified for judging the design aspect.

Comment thread src/Ext/Techno/Body.cpp

bool TechnoExt::CanBeRecruitedFix(FootClass* pThis, HouseClass* pHouse)
{
if (!pThis || !pHouse) return false;
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.

no need check pThis here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs testing ⚙️T1 T1 maintainer review is sufficient ❓Vanilla bug Vanilla game bugs that are requested to be fixed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants