:: Home :: Get Hosted :: PPM FAQ :: Forum FAQ :: Privacy Policy :: Search :: Memberlist :: Usergroups :: Register :: Profile :: Log in to check your private messages :: Log in ::

Do you want to advertise at Project Perfect Mod. Find out how to do it HERE.

The time now is Fri Sep 18, 2020 10:56 am
All times are UTC + 0
 Forum index » Modding Central » Red Alert 2 Editing Forum
How to make AI build new/added buildings?
Moderators: Global Moderators, Red Alert 2 Moderators
Post new topic   Reply to topic Page 1 of 1 [27 Posts] View previous topic :: View next topic
Author Message
rey
Cyborg Engineer


Joined: 15 Jul 2019

PostPosted: Tue Aug 04, 2020 10:58 pm    Post subject:  How to make AI build new/added buildings? Reply with quote

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".

Back to top
View user's profile Send private message
Mig Eater
Defense Minister


Joined: 13 Nov 2003
Location: Eindhoven

PostPosted: Wed Aug 05, 2020 12:37 am    Post subject: Reply with quote

To make defenses buildable by the AI add them to the AlliedBaseDefenses=, SovietBaseDefenses= or ThirdBaseDefenses= tags depending on which side owns them.
_________________



Back to top
View user's profile Send private message Visit poster's website ModDB Profile ID YouTube User URL Facebook Profile URL Twitter Channel URL
E1 Elite
Commander


Joined: 28 May 2013

PostPosted: Wed Aug 05, 2020 1:56 am    Post subject: Reply with quote

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.

Back to top
View user's profile Send private message
rey
Cyborg Engineer


Joined: 15 Jul 2019

PostPosted: Wed Aug 05, 2020 8:40 am    Post subject: Reply with quote

@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.

Back to top
View user's profile Send private message
rey
Cyborg Engineer


Joined: 15 Jul 2019

PostPosted: Fri Aug 07, 2020 10:01 am    Post subject: Reply with quote

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?

Back to top
View user's profile Send private message
E1 Elite
Commander


Joined: 28 May 2013

PostPosted: Fri Aug 07, 2020 3:14 pm    Post subject: Reply with quote

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.

Back to top
View user's profile Send private message
G-E
General


Joined: 09 Feb 2015

PostPosted: Fri Aug 07, 2020 11:39 pm    Post subject: Reply with quote

If you want it randomly built, without being just built once as a normal building would, put it in BuildDummy= ...
_________________
http://www.moddb.com/mods/scorched-earth-ra2-mod-with-smart-ai

Back to top
View user's profile Send private message
rey
Cyborg Engineer


Joined: 15 Jul 2019

PostPosted: Mon Aug 10, 2020 11:11 pm    Post subject: Reply with quote

E1 Elite wrote:
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. Confused

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". Question

Back to top
View user's profile Send private message
G-E
General


Joined: 09 Feb 2015

PostPosted: Tue Aug 11, 2020 12:49 am    Post subject: Reply with quote

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.

Again if you just want it built randomly, all you need is BuildDummy.
_________________
http://www.moddb.com/mods/scorched-earth-ra2-mod-with-smart-ai

Back to top
View user's profile Send private message
rey
Cyborg Engineer


Joined: 15 Jul 2019

PostPosted: Tue Aug 11, 2020 8:37 am    Post subject: Reply with quote

G-E wrote:
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.

Back to top
View user's profile Send private message
G-E
General


Joined: 09 Feb 2015

PostPosted: Tue Aug 11, 2020 11:24 am    Post subject: Reply with quote

Try adding IsBaseDefense to the building?

PS. I just checked, most of the defensive structures don't have AIBuildThis so it must be triggered by IsBaseDefense as well.
_________________
http://www.moddb.com/mods/scorched-earth-ra2-mod-with-smart-ai

Back to top
View user's profile Send private message
E1 Elite
Commander


Joined: 28 May 2013

PostPosted: Tue Aug 11, 2020 3:17 pm    Post subject: Reply with quote

Info was already given. Will repeat again.

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.

Back to top
View user's profile Send private message
G-E
General


Joined: 09 Feb 2015

PostPosted: Tue Aug 11, 2020 11:27 pm    Post subject: Reply with quote

I was talking about BuildDummy only, but the horse is beat...
_________________
http://www.moddb.com/mods/scorched-earth-ra2-mod-with-smart-ai

Back to top
View user's profile Send private message
rey
Cyborg Engineer


Joined: 15 Jul 2019

PostPosted: Wed Aug 12, 2020 11:30 pm    Post subject: Reply with quote

@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. Confused

Back to top
View user's profile Send private message
E1 Elite
Commander


Joined: 28 May 2013

PostPosted: Thu Aug 13, 2020 2:54 am    Post subject: Reply with quote

AIBuildThis=yes is the only thing needed to make one instance of a generic building to be built for sure.

If prereq is the problem, you should check other stuffs like AIBasePlanningSide and owner/house related flags.

You could have shared the INI file or code in complete, so that other problems could be looked into.

Back to top
View user's profile Send private message
G-E
General


Joined: 09 Feb 2015

PostPosted: Thu Aug 13, 2020 5:22 am    Post subject: Reply with quote

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.

Defensive structures don't have AIBuildThis and are still built, because they are explicitly defined in those build options.
_________________
http://www.moddb.com/mods/scorched-earth-ra2-mod-with-smart-ai

Back to top
View user's profile Send private message
E1 Elite
Commander


Joined: 28 May 2013

PostPosted: Thu Aug 13, 2020 8:30 am    Post subject: Reply with quote

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.

Back to top
View user's profile Send private message
rey
Cyborg Engineer


Joined: 15 Jul 2019

PostPosted: Thu Aug 13, 2020 10:30 am    Post subject: Reply with quote

G-E wrote:
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:
Code:
[NAPSENS]
UIName=Name:NAPSIS
Name=Soviet Psychic Sensor
BuildCat=Tech
Prerequisite=NACNST,NATEK
Strength=2000
Armor=steel
TechLevel=7
Adjacent=2
Sight=10
Owner=British,French,Germans,Americans,Alliance,Russians,Confederation,Africans,Arabs,YuriCountry
AIBasePlanningSide=1
EligibileForAllyBuilding=yes
Cost=2000
Bounty.Value=1000
Points=75
Power=-150
Powered=true
Capturable=true
Crewed=yes
Explosion=TWLT070,S_BANG48,S_BRNL58,S_CLSN58,S_TUMU60
DebrisAnims=Dbris1sm,Dbris1lg,Dbris4sm,Dbris5sm,Dbris4lg,Dbris7sm,Dbris8sm,Dbris5lg,Dbris4lg
MaxDebris=5
MinDebris=2
ThreatPosed=0
DamageParticleSystems=SparkSys,SmallGreySSys,BigGreySmokeSys
DamageSmokeOffset=220, 390, 150
AIBuildThis=yes
SpecialThreatValue=1
SuperWeapon=TransformSpecial
BuildLimit=1
HasRadialIndicator=true
ConcentricRadialIndicator=true
RadialIndicatorRadius=14
PsychicDetectionRadius=14
DetectDisguise=yes
DetectDisguiseRange=14
SensorArray=yes
SensorsSight=14
ImmuneToPsionics=no
LightningRod=yes
BuildTimeMultiplier=1.75
Spyable=yes
SpyEffect.Custom=yes
SpyEffect.ResetRadar=yes
SpyEffect.ResetSuperweapons=yes
BaseNormal=yes
LightningRod=yes
InhibitorRange=4
AIBuildCounts=1,1,1
AIExtraCounts=1,1,1

Back to top
View user's profile Send private message
G-E
General


Joined: 09 Feb 2015

PostPosted: Thu Aug 13, 2020 11:10 am    Post subject: Reply with quote

Try BuildCat=Combat ?

You'll notice the non-defense buildings missing AIBuildThis (radar) are also on the combat tab, perhaps this is the exception...
_________________
http://www.moddb.com/mods/scorched-earth-ra2-mod-with-smart-ai

Back to top
View user's profile Send private message
E1 Elite
Commander


Joined: 28 May 2013

PostPosted: Thu Aug 13, 2020 11:44 am    Post subject: Reply with quote

Do you really have a building as NATEK or is it NATECH?

Back to top
View user's profile Send private message
rey
Cyborg Engineer


Joined: 15 Jul 2019

PostPosted: Thu Aug 13, 2020 4:33 pm    Post subject: Reply with quote

G-E wrote:
Try BuildCat=Combat ?

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.

Back to top
View user's profile Send private message
Mig Eater
Defense Minister


Joined: 13 Nov 2003
Location: Eindhoven

PostPosted: Thu Aug 13, 2020 9:01 pm    Post subject: Reply with quote

The Grand Cannon and Spy Stellite use AIBuildThis=yes to make the AI build a single copy.

Have you tried adding AntiInfantryValue=, AntiArmorValue= & AntiAirValue= to the defenses as E1 Elite suggested?

AI scripts (in aimd.ini) are only used for units, buildings are produced based on their rules ini settings.
_________________



Back to top
View user's profile Send private message Visit poster's website ModDB Profile ID YouTube User URL Facebook Profile URL Twitter Channel URL
G-E
General


Joined: 09 Feb 2015

PostPosted: Fri Aug 14, 2020 12:06 am    Post subject: Reply with quote

rey wrote:
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.
_________________
http://www.moddb.com/mods/scorched-earth-ra2-mod-with-smart-ai

Back to top
View user's profile Send private message
E1 Elite
Commander


Joined: 28 May 2013

PostPosted: Fri Aug 14, 2020 1:32 am    Post subject: Reply with quote

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.

Back to top
View user's profile Send private message
rey
Cyborg Engineer


Joined: 15 Jul 2019

PostPosted: Wed Aug 19, 2020 12:14 am    Post subject: Reply with quote

G-E wrote:
rey wrote:
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?

Back to top
View user's profile Send private message
E1 Elite
Commander


Joined: 28 May 2013

PostPosted: Wed Aug 19, 2020 1:36 am    Post subject: Reply with quote

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.

Back to top
View user's profile Send private message
silverwind
Rocket Cyborg


Joined: 11 Jun 2016

PostPosted: Wed Aug 19, 2020 1:44 am    Post subject: Reply with quote

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.

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [27 Posts] View previous topic :: View next topic
 Forum index » Modding Central » Red Alert 2 Editing Forum
Jump to:  
Share on TwitterShare on FacebookShare on Google+Share on DiggShare on RedditShare on PInterestShare on Del.icio.usShare on Stumble Upon
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


Powered by phpBB © phpBB Group

[ Time: 0.5226s ][ Queries: 10 (0.1808s) ][ Debug on ]