Posted: Fri Sep 03, 2010 4:33 am Post subject:
Found a way to make AI fully play as 3rd side
While working on the AI for my mod I decided to mess around with the AI and try to make it play as my 3rd mutant faction. After some trial and error I think I've found a pretty flawless way to make the AI play a 3rd (and with some extra work 4th, 5th, etc) factions.
Now that that's out of the way, go to [Houses] in rules.ini. You'll need to add a new faction for the AI. In my case:
Code:
[Houses]
0=GDI
1=Nod
2=ForgAI ; This is for the AI only
3=Forg
4=Neutral
5=Special
Note that its important the faction is placed after GDI and Nod. If you wanted a 4th faction playable by the AI, you'd add it after ForgAI. Right below you'll see the [Sides] list. Again, add ForgAI after GDI and Nod.
Move on to the Country Statistics and add ForgAI there (just search for [GDI]):
Code:
[ForgAI]
Name=Do not choose me!
Suffix=FRA
Prefix=A
Color=DarkBlue
Multiplay=yes
Side=ForgAI
SmartAI=no ; Haven't tested enough to tell if this should be yes or no.
Next, go to the MCV unit entry. You'll have to use a faction shared MCV vehicle as the AI does not understand more than 1 MCV / construction yard. In my case GDI and Nod use the default MCV, while my own faction has a seperate one. You need to edit the GDI / Nod MCV as shown below:
Code:
[MCV]
...
Owner=GDI,Nod,ForgAI,Special
...
Same thing for the default construction yard:
Code:
[GACNST]
...
Owner=GDI,Nod,ForgAI,Special
...
Now it gets bit trickier. You'll need to "hijack" one of the default shared prerequisite settings. Look for this bit in rules.ini:
Code:
; Building prerequisite categories are specified here.
PrerequisitePower=CACSITE,FAKEY ;GAPOWR,NAPOWR,NAAPWR ; Took over this one. CACSITE is my 3rd faction's con.yard. Fakey will be explained later.
PrerequisiteFactory=GAWEAP,NAWEAP
PrerequisiteBarracks=NAHAND,GAPILE
PrerequisiteRadar=GARADR,NARADR
PrerequisiteTech=GATECH,NATECH
In my case the power prerequisite had become obsolete, since in my mod GDI and Nod have seperate refineries, and refinery used to be the only building with POWER as prerequisite. If POWER doesn't work for you, you'll have to find a way to free one of the other shared prerequisites.
Now, go to your 3rd faction's buildings and add this to all of them:
Code:
Prerequisite=POWER
Rest of the prerequisites for specific buildings will of course be listed after this one. But make sure at least one building (probably the power plant) has ONLY this prerequisite. Make sure all your 3rd faction buildings have AIBuildThis=yes set to them, except the construction yard. So in my case every building except CACSITE has it. If you give AIBuildThis=yes to the 3rd faction's construction yard the AI will get the cloning bug, so it's not a good idea.
EDIT: You also need to add the correct ownership to all 3rd faction buildings:
Code:
Owner=Forg,ForgAI,Special
The 3rd faction construction yard is the exception (CACSITE in my case), it needs to have:
Code:
Owner=Forg,Special
Next we need to define FAKEY to give the AI access to the 3rd factions buildings (since he never builds CACSITE):
Code:
[FAKEY]
Name=IM_NOT_HERE! ; Shouldn't be able to see this anyway
Image=INVISO ; I'm not sure this works for buildings... anyway, use an empty shp here.
BuildLimit=0 ; Disables it from human players
Owner=ForgAI,Special ; Notice the owners!!!
AIBuildThis=yes ; Yes, yes, yes!
Nominal=yes ; Rest of these keys simply make this fake building invisible and blow it up when the AI dies
Strength=10000
Cost=1
;Prerequisite=
Armor=wood
TechLevel=1
Adjacent=12
Sight=0
Invisible=yes
InvisibleInGame=yes
RadarInvisible=yes
Insignificant=yes
BaseNormal=no
IsBase=no
Immune=yes
LegalTarget=no
Selectable=no
Repairable=false
Capturable=false
TogglePower=no
Powered=false
Power=0
Crewed=no
Points=1
Explosion=
MaxDebris=0
DamageParticleSystems=
ThreatPosed=0
Finally, go under [AI] and add your side's structures to the list correctly:
Code:
BuildConst=GACNST ; Only accepts 1 value
BuildPower=NAPOWR,GAPOWR,NAAPWR,YOURPOWER
BuildRefinery=PROC ; I don't recommend more than 1 value, it can cause some SERIOUS bugs. Create extra AI only refineries instead.
BuildBarracks=NAHAND,GAPILE,YOURBARRACKS
BuildTech=NATECH,GATECH,YOURTECH
BuildWeapons=GAWEAP,NAWEAP,YOURWEAP
BuildDefense=NAOBEL,YOURDEFENCES
BuildPDefense=NAOBEL,YOURDEFENCES
BuildAA=NASAM,YOURDEFENCES_AA
BuildHelipad=GAHPAD,NAHPAD,YOURHELIPAD
BuildRadar=GARADR,NARADR,YOURRADAR
The AI will now start a match with the shared MCV, move on to construct this FAKEY building, and then gain access to all the 3rd faction structures and units. This method will not mess up sidebar building / unit lists for GDI, Nod or for any other extra factions. However there are few quirks:
1. You have to use up one of the shared Prerequisites as mentioned earlier
2. One extra faction will show up in the side selection box. This can't be exploited though, if you choose to play as ForgAI you'll start with an MCV. But once you deploy it you won't be able to build anything. So choosing the fake side really makes no sense.
3. The AI controlled 3rd faction has to use the default MCV / construction yard. I already tried and the AI does not build anything if he doesn't have the first building listed in BuildConst=. The human controlled 3rd faction can (and must) use a custom MCV / construction yard.
4. For some reason the AI will build some basic nod power plants and some of the 3rd factions power plants, even if you list the new factions power plants in BuildPower=. This might be fixable but I haven't found a way yet.
You can now make the AI build your 3rd factions units like you would with GDI and Nod AI. Just remember to set the owner of the TeamType to your 3rd faction, eg. House=ForgAI. In the AITriggerTypes you'll need to use 3 as the new faction indentifier. An example (the highlighted number needs to be 3):
Code:
08594AB0-G=H_Forg tank attack,07EB8E90-G,<all>,6,-1,<none>,0000000000000000000000000000000000000000000000000000000000000000,40.000000,10.000000,70.000000,1,0,[b]3[/b],0,<none>,0,0,1
Any way I can't try this due I my mod have 5 faction. also, add more faction for AI will screwed up my mission. _________________ Tiberian Sun : True Power - Reality Power Of 5 Factions... QUICK_EDIT
greated job, it takes some time to i make et works but i try et, your buildings looks very nice man you mast realese your mod or buildings to public (sorry my english) QUICK_EDIT
It's good, shame you can't hide the DO NOT CHOOSE side in the menu, I'm guessing the game will IE if you tried to play with it? _________________ QUICK_EDIT
Multiplayerpassive sides aren't targetted properly by your units, so it would lead to some very buggy issues and I still think the AI will not select the side, all this hack does is make the ai select a playable side. _________________ QUICK_EDIT
I already tested Multiplay=no, and it won't work, the AI that was supposed to be the 3rd side simply wasn't there. If a human chooses to play as the DONOTCHOOSE, he will simply start with the default MCV but won't be able to build any structures since he would either need the 3rd side con.yard or the FAKEY building. So it's only a cosmetic issue, it can't be exploited or used to make the game crash. Still, maybe Hyper could take a look if it could be hidden from the list somehow...
Joined: 23 Apr 2010 Location: indonesia, sticking at keyboard
Posted: Sun Oct 03, 2010 8:25 am Post subject:
Wow! great find, trying...
note. i think you doesn't need "hijack" the prerequisite, just give all building THENEWSIDEMCV as prerequisite, since AI never use prerequisite _________________ QUICK_EDIT
The AI doesn't care about prerequisites when it comes to units, but with buildings it actually does care. If you didn't hijack the generic prerequisite you would have to create an AI only copy of every building and unit of the 3rd side, which is alot more code _________________ QUICK_EDIT
I know this is a bump, but can someone with the proper rights move this topic to the Tutorials Factory? Also this topic. They should have gone there in the first place, my mistake... _________________ QUICK_EDIT
I've found a partial fix to the "3rd faction keeps building Nod power plants" problem. Create extra copies of your 3rd factions power plants that only the AI can build (BuildLimit=0 disables them from humans). Put them before the other 3rd faction structures in the [BuildingTypes] list, since the AI prefers to build things that are on top of the list first. You can also control the build order by adjusting the prerequisites of each power plant. Make sure the AI has enough of these extra plants, since if the AI ever goes to low power it will build the Nod one. This can still happen though if the enemy takes out enough of the extra plants.
I managed to completely stop the 3rd faction from building Nod power plants by changing the NodRegularPower= to a building that has AIBuildThis=no and a prerequisite that can't be met. Problem is it screws up the Nod AI (gets stuck trying to construct a 2nd basic powerplant), but for some reason it doesn't screw up the 3rd faction. Maybe with some further work it could be used to completely get rid of this problem.
EDIT: I can also confirm that PrerequisitePower seems to be the only prerequisite that can be "hijacked" without completely screwing up the AI. I've tried to use PrerequisiteRadar, PrerequisiteFactory and PrerequisiteTech instead, and every time the GDI and Nod AI stop building the structure related to the key, eg. when I took over PrerequisiteRadar the AI would never build any radars. So the AI building logic is somehow tied to the generic prerequisite keys. Some reason they don't seem to mind PrerequisitePower though. _________________ QUICK_EDIT
Are you sure with that? I have 'hijacked' the PrerequisiteFactory tag just fine. My Nod does have some serious problems, but they're not related to that...
^^From my experience do the prerequisite groups NodFactory, GDIFactory and Radar also cause AI problems when used as an OR-conjunction for different buildings.
After some time the game crashes, to say exactly after the 3rd or 4th faction reach a special point. I haven't set up any taskforces etc. for them, could that be the problem?
Also sometimes they don't deploy their MCVs. Cabal for example crashes when they want to build the War Factory, so I swapped prequisites with tech building. Now they build the factory without problem, then it tries to build tech building -> crash.
So I am not sure if this is a rules or ai problem.
I am looking forward to get some help for this problem _________________ 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