Posted: Tue Aug 04, 2020 10:58 pm Post subject:
How to make AI build new/added buildings?
Short question: is it all about editing AI scripts or if there is a way to add "proper parameters" to buildings in rulesmd.ini?
I seem to copy all the proper parameters from building AI does build(plus added new one to listing), but it doesn't work.
Strange thing is that these buildings are defences and surely they have level-req and tech-req. But if i dismiss req - AI builds them, making me think there is somewhere a parameter that makes AI "skip" these on higher tech level due to smt like "base is already stuffed with buildings/defences". QUICK_EDIT
To make defenses buildable by the AI add them to the AlliedBaseDefenses=, SovietBaseDefenses= or ThirdBaseDefenses= tags depending on which side owns them. _________________
AI uses Build* category under [AI] section, AIBuildThis=yes etc. YR uses AlliedBaseDefenses also. Units also can deploy into buildings. Ares for YR adds definitions for powerplants and defense counts etc.
Don't keep the last prereq unique, use the same prereqs more than once for different buildings. QUICK_EDIT
@Mig Eater yes, listed them in AlliedBaseDefenses and SovietBaseDefenses before asking, but AI seems to skip/ignore them as it's high tier defense.
starting to think it has smt to do with AlliedBaseDefenseCounts=35,25,35
or smt similar, but i never saw AI really reaching 35 defences to "have no place anymore"...
@E1 Elite yeap, used AIBuildThis=yes too, same as AIBuildCounts, AIExtraCounts, IsBaseDefense=yes. Prereq is not unique, just asks for higher tier just like like any powerful units of late game. QUICK_EDIT
after some experiments i can say for sure there is some limit AI has for defences.
if i erase tech prereq and make tier 1 req = AI does build!
AND
somitimes AI builds high-tier defences(even with all prereq present) after most base defence was destroyed
==
this makes me think there is some limit that states AI it "can't" build special defences, 'cause before that tier was achieved, there are already a lot of simple defences being built.
so far i found only AlliedBaseDefenseCounts and SovietBaseDefenseCounts, but can't see them making much difference.. any ideas? QUICK_EDIT
YR uses AntiXXXValue flags to decide which defense type has to be built. AIForcePredictionFudge also affects it. TS (which doesn't have these flags) uses building's weapon type of AA/AG to decide.
YR doesn't use IsBaseDefense=yes for building AI base defenses but that flag is used in AI target selection. SovietBaseDefenses / AI.BaseDefenses (Ares), SovietBaseDefenseCounts etc. defines the defenses in YR.
If you are not able to get the correct proportions of defense type, can drop all the defense related flags and make those as generic buildings. Then use AIBuildThis=yes (with IsBaseDefense=yes) and Ares AIBuildCounts/AIExtraCounts for fine control. QUICK_EDIT
YR doesn't use IsBaseDefense=yes for building AI base defenses but that flag is used in AI target selection. SovietBaseDefenses / AI.BaseDefenses (Ares), SovietBaseDefenseCounts etc. defines the defenses in YR.
If you are not able to get the correct proportions of defense type, can drop all the defense related flags and make those as generic buildings. Then use AIBuildThis=yes (with IsBaseDefense=yes) and Ares AIBuildCounts/AIExtraCounts for fine control.
G-E wrote:
If you want it randomly built, without being just built once as a normal building would, put it in BuildDummy= ...
well, i added them to seemingly every section mentioned here, like list of defences in sections [AI], then in lists of strange for me sections [Nod] and [GDI], and finally in BuildDummy list, as proposed. yet added all tags, like AIBuildThis=, IsBaseDefense=, AIBuildCounts/AIExtraCounts.
something seems smt to do the trick, AI started to use those. but i'm not really happy 'cause i don't know What really does the effect. initially i was adding all these one by one and testing after each with no effect, and only after adding all, in one long game i accidentally found out AI builds them only as response to attacks, which makes it really difficult/long to test every small change. plus it's still not a "must have in base" solution, which was my goal.
along with trying to make AI use these defences, i wanted to make it use one "modded" building(tweaked version of Psychic Sensor), but it doesn't work. compared code to buildings with similar functions and all tags are there. even added it to BuildDummy list, still AI doesn't use it.
though there is strange behaviour: if i remove prereq AI does build it, seemingly the problem should be those prereq, but they are plain simple, i copied them from ordinary middle tier building that AI always builds.
still open for any ideas and propositions how to make AI build structures(both, ordinary and def) so to say "must have for sure". QUICK_EDIT
Defenses are prioritized when the AI is attacked, and the overpowered defenses are prioritized when the AI also has excess power. It even goes as far as prioritizing anti-air defenses when you have an airbase, even if you've never attacked it with aircraft.
Defenses are prioritized when the AI is attacked, and the overpowered defenses are prioritized when the AI also has excess power. It even goes as far as prioritizing anti-air defenses when you have an airbase, even if you've never attacked it with aircraft.
so it's like a "smart behaviour" and AI will use "overpowered defences" if there were attacks with aircrafts/airbase thread, got it.
then how about non-defence buildings? i tried adding one to BuildDummy, but AI never build it. QUICK_EDIT
YR is different from TS/RA2. It doesn't use BuildDefense or BuildPDefense (excess power defense) as in TS/RA2, those are obsolete. IsBaseDefense is also not used for building defenses in YR. It uses AlliedBaseDefenses, SovietBaseDefenses and ThirdBaseDefenses. For counts it uses AlliedBaseDefenseCounts, SovietBaseDefenseCounts and ThirdBaseDefenseCounts. Ares adds AI.BaseDefenses and AI.BaseDefenseCounts. The varying count in a base is guided by values in AntiInfantryValue, AntiArmorValue and AntiAirValue.
Other building categories are defined with Build* under [AI]. Generic building which are not in defense or Build* use AIBuildThis=yes, which typically builds only one instance of it. Ares gives AIBuildCounts/AIExtraCounts to increase those counts.
As the exact count of base defense buildings is determined by the game, modder doesn't have full control on how many of a particular building will be built. To get exact counts based on difficulty, one can remove those building from base defenses flags of AlliedBaseDefenses etc. and just use AIBuildThis to build them with fixed counts by using Ares flags of AIBuildCounts and AIExtraCounts. By using IsBaseDefense on those buildings, AI will be able to target those when using Attack base defenses (0,7) script. QUICK_EDIT
@E1 Elite i heard you first time, but you didn't hear me: i tried ALL that and it doesn't work, unless i totally erase prereq.
my defs arelisted in:
[AI]
BuildAA=
AlliedBaseDefenses=
SovietBaseDefenses=
[Nod]
AI.BaseDefenses=
AI.BaseDefenseCounts=
[GDI]
AI.BaseDefenses=
AI.BaseDefenseCounts=
and have code tags:
AIBuildThis=yes
AIBuildCounts=
AIExtraCounts=
IsBaseDefense=yes
but it gives Nothing!
only after adding in BuildDummy=, as @G-E proposed, AI starts to built them sometimes(while i'd wish them be build for sure).
and again, even this doesn't make AI to build that other non-defence building. same as before, erasing prereq kinda solves it, but it definitely wrong as prereq are simple/typical. QUICK_EDIT
It seems like AIBuildThis bypasses the prerequisites, because the AI has no problem building out of order, especially when one of them is destroyed. It randomly selects from a list of buildings valid to build, and I think it's only influenced by that coefficient section.
Which coefficient section? AIBuildThis doesn't use any coefficients.
GDIBaseDefenseCoefficient/NodBaseDefenseCoefficient are obsolete in RA2/YR, it works in TS only. In TS those 2 coefficient gives the max count in relation to the base size. Defined base defenses in YR uses the counts for upper limit and AntiXXXValue to get the proportions. RA2 still uses BuildDefense/BuildPDefense and IsBaseDefense to build defenses like in TS, but RA2 has replaced the coefficients with the count flags when compared to TS. QUICK_EDIT
It randomly selects from a list of buildings valid to build, and I think it's only influenced by that coefficient section.
what do you mean by "list of buildings valid to build"? proper tags in building code concerning owner/side or there is some list for tier-specific buildings?
the thing is Allied Spy Satellite is not listed anywhere, but AI builds it - my building is quite similar but for Soviets. so i checked all possible similar tags that may matter, still no luck. =/
E1 Elite wrote:
If prereq is the problem, you should check other stuffs like AIBasePlanningSide and owner/house related flags.
re-checked, everything is proper.
well maybe building code will really show smth:
You'll notice the non-defense buildings missing AIBuildThis (radar) are also on the combat tab, perhaps this is the exception...
tried Combat - no difference.
plus noticed that adding defences to BuildDummy= is bad idea, AI starts to ignore Owner=.
E1 Elite wrote:
Do you really have a building as NATEK or is it NATECH?
have both, tier 2 and 3 accordingly.
main secret for me here is how Grand Cannon is being built and Spy Stellite, while neither of them is in any list = these are direct similar building to what i'm trying to add. this brings me back to thought AI scripts may be involved. QUICK_EDIT
Even though the building code seems fine, it doesn't give the complete picture. Does the AI make NATEK first before attempting to make this building? Have you looked into Ares debug log? Is this building the last building with that prereq? In that case you could have a non-buildable clone after this building. Have you tried giving simpler prereq like NARADR only?
It looks odd to have EligibileForAllyBuilding for a non-conyard building. Also if you need only one instance of the building, then AIBuildThis=yes is sufficient, there is no need for AIBuildCounts/AIExtraCounts. QUICK_EDIT
plus noticed that adding defences to BuildDummy= is bad idea, AI starts to ignore Owner=.
I use a house specific defense in BuildDummy, and the only way that works is using a single Owner instead of RequiredHouses.
single Owner is not desirable as it cuts the way to obtain technology by spy-building enemies base, but i already understood that it's the only way to use BuildDummy efficiently and seems to be the only way to really rise chances of particular defences to be build. thanks again for this hint.
Mig Eater wrote:
Have you tried adding AntiInfantryValue=, AntiArmorValue= & AntiAirValue= to the defenses as E1 Elite suggested?
one defence had these values AntiInfantryValue=0, AntiArmorValue=0, AntiAirValue=75
other didn't, but AI was building them with seemingly similar chances. added values to second def and even risen the AntiAirValue=95(both my defences are AA) - still don't see much change in probability of their construction, "maybe yes, maybe no.=)
E1 Elite wrote:
It looks odd to have EligibileForAllyBuilding for a non-conyard building. Also if you need only one instance of the building, then AIBuildThis=yes is sufficient, there is no need for AIBuildCounts/AIExtraCounts.
i added those in search of any way that could surely grant AI would build this building.
E1 Elite wrote:
Does the AI make NATEK first before attempting to make this building?
yes, AI builds NATEK in every skirmish.
E1 Elite wrote:
Have you looked into Ares debug log?
didn't check Ares debug as i don't know what to look there for. checked right now and i don't see any mentions of any buildings names. what should i be looking for?
E1 Elite wrote:
Have you tried giving simpler prereq like NARADR only?
yes, giving prereq NARADR alows AI to build it, that's why i was thinking in past posts it must probably smt about prereq.
E1 Elite wrote:
Is this building the last building with that prereq? In that case you could have a non-buildable clone after this building.
well initially i tried it with NATECH(tier 3), that didn't work so i tried this NATEK(tier 2, which is a prereq for NATECH. at least AI always builds NATEK.
what is the problem with possible "last building with prereq"? i ask 'cause i noticed different sub-faction kinda "build differently": some almost never build tier 3, while one most often does(which leaves me with even more questions).
yet, what is "non-buildable clone"? trick to add code of some fake building that prereqs this my problematic building? or simply adding another building that has same prereq? QUICK_EDIT
If it works with NARADR as prereq, then there is no other problem from AI side to build it, only you have to sort out the prereq. Simply add another building with same prereqs and that should come after this in buildingtype list. If that doesn't work and if NACNST being part of prereq is problem, remove it and try with NATEK alone. QUICK_EDIT
Enable debug logging by adding the "-LOG" command line argument when running ares.
Then, in the pause menu, go to keyboard settings, assign a keyboard shortcut for AI Base Plan Dumping, and activate that in game. This will dump the AI's base plan to debug.log.
Close the game, and open debug.log, to if the AI attempts to build your AA defense, and any errors preventing it from building it. QUICK_EDIT
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum