Fix AI team recruitment inconsistency causing underfilled teams#2172
Fix AI team recruitment inconsistency causing underfilled teams#2172handama wants to merge 11 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.
|
@Metadorius @Starkku @ZivDero can anyone help judging the design concept? |
|
Tested by: https://www.phoboscn.top/t/topic/361/9 |
|
Given that no one is willing to make further comments, this PR will be merged in 24 hours. |
|
Strange, ef120cd is just a documentation change (resolve merge conflicts), but Nightly failed to build successfully. However, when I pull the branch of that PR locally for testing, it builds successfully.
|
f34ef4d to
cdbe08d
Compare
|
Could it possibly be this one that's causing the problem? |
cdbe08d to
f34ef4d
Compare
Not that one. I also suspected this, so I tested in another repository. The result was that whether or not Revert that commit, the build succeeded. I even reset the Additionally, that 055cdc2 had already been merged into the After further testing, it was found that as long as the synchronization target of the branch where this PR is located is set to commit 0b21108 and later commits, this abnormal behavior will occur, but the cause is not clear. |
f34ef4d to
dea4751
Compare
b057271 to
1da520d
Compare
|
@Metadorius Help |
42e9952 to
f34ef4d
Compare
|
The branch has been restored to the state before a series of tests were conducted, waiting for others to handle it. |
There was a problem hiding this comment.
After review, investigation and some research it appears this PR addresses a real inconsistency and correctly fixes the problem - adjusting the recruitment-stage check to require both recruitment flags (which as an aside could be renamed in YRpp to better match their actual purpose, A is for Autocreate=false teams and B for true ones) to be set to true produces no false-positive results for Autocreate=true teams and has no impact on Autocreate=false teams which didn't have this issue to begin with.
Although I am unsure how the both flags set to false case return true from 0x4DA230 when the only code path in it that can requires RecruitableA to be set to true.
Aside from that I have some nitpicks.
There was a problem hiding this comment.
Single row if statements (the condition is on single row) don't need the curly braces per project code style specs and omitting them is usually cleaner but them being there isn't a problem. LGTM I guess.
Although I am unsure how the both flags set to false case return true from 0x4DA230 when the only code path in it that can requires RecruitableA to be set to true.
If someone is able to enlighten me on how this happened though it would be nice for understanding this part of the game better.
My mistake. The issue only occurs in the 1,0 case. I didn’t thoroughly double-check during the translation. |

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.