Fix AI team recruitment inconsistency causing underfilled teams#2172
Fix AI team recruitment inconsistency causing underfilled teams#2172handama wants to merge 4 commits intoPhobos-developers:developfrom
Conversation
|
To Chinese users:
|
|
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. |
|
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? |
TaranDahl
left a comment
There was a problem hiding this comment.
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.
|
|
||
| bool TechnoExt::CanBeRecruitedFix(FootClass* pThis, HouseClass* pHouse) | ||
| { | ||
| if (!pThis || !pHouse) return false; |
There was a problem hiding this comment.
no need check pThis here
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.

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.