Posted: Fri Apr 06, 2007 9:03 pm Post subject:
Single Player AI Triggers (***)
Credits:
-Aro and his topic of AI triggers for making me think on this.
-scorpionim6@msn.com, not sure what his forum name here is.
-OrcaCommander for refering me to scorp.
Okay here's the thing that sets the difference between Aro's AI Trigger tutorial and mine.
Aro's is for multiplayer, and I have tested this myself on a single player test map. I tested this for about 3 days now, and I finally achieved the result I wanted.
First thing's first. Set up teamtypes, scripts, and taskforces. You will need to construct a total of 1 taskforce, 2 scripts, and 2 teamtypes. I will go into this in detail.
The most important part, other than creating the AI triggers itself, is activating them. Be sure that your triggers allow Production and AI triggers to begin. Otherwise, your AI is a sitting duck.
First, let's know what we want the AI to build shall we? Let's do something small, like light infantry.
Now we set up two scripts. One is for them to just stand around and look pretty while the other one is what they're REALLY going to do.
Now it's time for the teamtypes. One is something that rings a bell: Pools, while the other is the actual attack. While researching Westwood maps and the AI.ini file, I saw what was called pools. Doing further research, I've noticed that they used the same taskforce as the actual attack action they're supposed to do. Priority and options selected between the pool and attack are different from what I've seen. Pool teamtypes have a priority of 6, while attack teamtypes have a priority of 7. The Max are generally the same, unless you want some units in reserve for another AI script or just to defend the base. Pool teamtypes MUST have the option "AreTeamMembersRecruitable" checked, while IsBaseDefense is actually optional, but recommended.
AreTeamMembersRecruitable is crucial due to the fact that these units NEED to be recruitable in order for the other AI trigger to fire and send these units on their mission.
IsBaseDefense is optional, but recommended because, while these units are in reserve, if the base or harvester is to be attacked, then these units will respond to the attack. CORRECTION: IsBaseDefense is crucial as well. It NEEDS to be checked.
In our attack team, we need to have recruiter checked so that the AI can recruit any available units (preferably our pool units) to launch a strike force. The rest are optional. Waypoint NEEDS to be blank in order for the AI to look throughout the whole map instead of in one particular area to recruit units. If there aren't any available. The AI will create "pool" units to use. Here's a screenshot to sum it all up for you.
NOTE: For the attack scripts, be sure to have "Success" be the second action.
And now, for the last part. The AI triggers itself. I will copy and paste what Aro wrote in his post on the descriptions on AI triggers. As well as commentary on some additions.
Aro wrote:
Enabled: Do not forget to check this if the AI trigger shall be used
Type: This specifies the general event type for the AI Trigger. You can choose between several different types, The selected one specifies that the house that accesses the AI trigger must have a certain amount of certain objects. The exact amount, and the object type, is specified later on.
Name: Just a descriptive name of the AI Trigger
House: Usually this should be all, except you want only a certain house to access the AI trigger
Teamtypes: They specify the teams that shall be created as result of the AI trigger
Multi-Side: Specify if this trigger is for Everybody, Soviets, Allies or Yuri
This is for Multiplayer only. You can set this to <none>
Base defense: If this is checked, this AI trigger may be used even if the house doesn´t have a hated enemy yet
Available in Skirmish: Check this, and the AI trigger may be used in multiplayer games
We will not be using this option for Singleplayer maps.
Easy, Medium, Hard: In which difficulty modes is this AI trigger available?
Weight: Starting weight of the AI trigger. As higher, as more likely it is that the house decides to build the teamtype
MinWeight: The minimum weight that this AI trigger must have
MaxWeight: The maximum weight that this AI trigger can have
For pools, be sure that the weights are relatively close together. For example: Min. Weight: 30.000000, Weight: 40.000000, Max Weight: 40.000000.
For attackers, it doesn't really matter. It's based on you.
Note: AI trigger types for Pools are generally set to -1 None, but if a certain building requirement is needed you can change it to 1 House Owns (CONDITION) N of type X. They also tend to repeat the same teamtype pool so more units are in reserve.
Here's screen shots:
Basically, my AI will pool units when the AI triggers begin, and once 2 GDI Power plants are built, the AI (depending on whether or not it feels like it) will launch an attack on the base.
And now comes the moment of truth, testing.
AI builds the pool team.
Conditions are met.
AI launches strike force.
And there you go, the AI successfully fired both triggers!
Known issues: The AI tends to sit there after pooling units. I'm not sure if it's due to the fact that I have only 2 AI triggers or not, but it'll eventually send its forces at you. Sometimes you need to give him a little "kick" to start him up.
and glad to see you being active here and making this nicely detailed tut (yes i know Aro made one so congrats to him to )
keep up the good work yoshi. it would be nice to see some good fixes to the FSData.ini sometime in the future. (well more further fixes to it) _________________ Kalistia Crestland (2)
In Soviet Russia, grass grows on tiberium! QUICK_EDIT
This tutorial should be scrapped. Upon 5 hours of further research on AI Triggers I've noticed that "IsBaseDefense=" is VERY limited by the rules.ini entry "MinAIDefensiveTeams" and "MaxAIDefensiveTeams". Depending on the difficulty setting is what determines how many "defense" teams should be created. I started noticing that the computer usually built a couple units from my "pool" list, but sometimes did not pool every team type, or even didn't build the team all the way (it was a rather odd bug I suppose).
I've also tested various combinations of options for Teams to try and make the AI pop new units out of the structures, but all to no avail. Prebuild and Autocreate do not create units. Same with keeping "waypoint=" blank (this works with the fourth trigger action, Create Team, however). Also, when "IsBaseDefense" is switched to yes, SOMETIMES the AI will allow its base defense units to be recruited in another AI trigger, while other times it would disallow recruitment of units regardless of "AreTeamMembersRecruitable" being chosen as yes.
It's still kind of funny and strange how I modeled my test AI system like how WW made theirs (even copied one for research purposes) and it still failed. Perhaps I'm doing something wrong? I'm not even sure.
Pooling may allow SOME recruitment to other AI triggers, but it doesn't seem very reliable. From both missions that I've done in my campaign that contain AI triggers, it appears that sometimes they work fine for a little while, but then crash and burn as time goes on, or from the very beginning.
Other than trying the "pool" option, I attempted to create a simple AI trigger that is supposed to create a taskforce by scratch, and have them move along a VERY simple linear path of waypoints. Weights were adjusted to where it was a very high percentage chance that the AI would trigger this, fired up the game, loaded the map, and it failed miserably. Sitting on the computer for about 3-5 minutes on the fastest setting, and nothing happened.
In conclusion, single player AI triggers seem to cause more of a headache than multiplayer ones. Can anyone who actually got the AI triggers to work in single player without the use of "pooling" can shed light into this? By use of AI triggers, I mean using them to produce new units.
I swear to god, at this rate, my mapping production rate will become stagnant again because of this, unless I go back the way I used to make the AI build, which would cause difficulty to shoot up the roof again.
EDIT: By the way, I already went and read up http://www.steffke.de/jbbs/doc/CC/KuenstlicheIntelligenz/AI-Engine/lang_en/index.html and I still got problems. The AI engine helped with identifying the tags easier, but it didn't seem to clarify much for single player. Mostly multiplayer it seems. _________________ Creator of Tiberian Sun: Firepower QUICK_EDIT
Joined: 18 Jun 2005 Location: Dordrecht, the Netherlands
Posted: Sat Jan 12, 2008 1:11 pm Post subject:
Can't you just add MinAIDefensiveTeams" and "MaxAIDefensiveTeams" to your map file. Then you can set the minimal and maximal amount of defence teams for that specific map. That may help solving one of your problems QUICK_EDIT
Unfortunately, it's under [General], and I don't think you can add in that entry if I could remember. I don't want to edit the rules.ini entry either, but I'd really like to know how to get this functioning right. _________________ Creator of Tiberian Sun: Firepower QUICK_EDIT
That answers my shaky thoughts, but back on topic though. Single Player AI Triggers when it comes to building a unit. Has there been any successful SP AI Triggers that were triggered successfully when it came to constructing a unit without the use of "IsBaseDefense"? _________________ Creator of Tiberian Sun: Firepower QUICK_EDIT
It's still kind of funny and strange how I modeled my test AI system like how WW made theirs (even copied one for research purposes) and it still failed. Perhaps I'm doing something wrong? I'm not even sure.
_________________ Creator of Tiberian Sun: Firepower QUICK_EDIT
DCoders AI Editor is good, but for some reason, It can't seem to get custom ones to work correctly. The only time it works sucessfully, is when you just edit some features in the existing ones. Last edited by Aro on Mon Jan 14, 2008 1:34 am; edited 1 time in total QUICK_EDIT
Aro, we ain't discussing the usefullnes of DCoder's AI coder, but something else..
I know what you're discussing, but I noticed someone bring it up, so I just thought I'd give my input. But yeah, WW must've used something simmilar, Otherwise It wouldn't be so damn difficult to get these AI Triggers working. Just read through THIS. QUICK_EDIT
Too bad Westwood never fully implemented Prebuild and Autocreate in Teams. It would've made this a whole lot easier, especially combined with the AI editor that's built into FinalSun. It appears that I have to create my pools by scratch, which will amplify the difficulty level and will further amplify the percentage that an AI pool will fail (as in units getting stuck). If you want to know what I mean by difficulty level, you can look at my campaign demo that I released years ago and see that. _________________ Creator of Tiberian Sun: Firepower QUICK_EDIT
That answers my shaky thoughts, but back on topic though. Single Player AI Triggers when it comes to building a unit. Has there been any successful SP AI Triggers that were triggered successfully when it came to constructing a unit without the use of "IsBaseDefense"?
Ok massive bump but did anyone ever get this working?
Something is really screwy with AI building units with preplaced bases on maps and yes I have copied westwood code for research with the same results. 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