Tutorial Part 04

Dual AI

<<<– 5 –>>>
>>> Index >>> Tutorial Part 04

9. Now we combine all and make it work together!

9.1 To do this, we will first need to set the Relationships between the Human and Civilian Players on the map with a few scripts. We will do it so that theoretically any of the three players can start from any slot in the lobby. Furthermore, a third human should be able to host and just observe and the scripts should still work. Actually “CompFriend” won’t have units or scripts in this example map, but I will include it as well. If we set a Flag additionally here, then we can use it later again. That will be helpfully to manage Startposition related scripts.

Slot 1 can’t be taken by Skirmish AI, because there is always the host of a game. But we can also set a Flag there for the case, if the host picks the wrong Startposition for some reason. This can be part of a check of wrong setup conditions on start. Of course there we only need to set that Flag and nothing else.

The last script in Relationships folder must be about the releationship between both Civilian AI players, which we have added.

As you can see I have disabled the Relationships folder. This is because of the use of Flags with the initializing scripts. I like to have a kind of overview about the created Flags and for that I will create a script where all Flags will be set to “FALSE” right on start. That means I must delay the set up of Relationships with the Flags by a timer.


9.2 To synchronize Skirmish AI and Civilian AI to Dual AI, a script must now wait for confirmed conditions of the two AI types, which will then initiate the ending in the way we want. I will put 2 named units on the map for this.

The folder of the Skirmish AI is a “closed” area. You can’t set a flag or counter in it and also using it in scripts of other players folders. A crossover-use is not possible! That is why I use the named units here. Make them indestrucable, that you can remove them only via script during a game.

We will begin with modifying the end of the Skirmish AI first now. Normally it sells all buildings after a certain point (conditions) and the game ends. That can be found in “Sell Off” folders of any Skirmish Faction. On default it looks like:

Now we edit the “China Sell off check” script and after that delete the “China Sell off” script. We only need to change *** THEN *** in the check script, there we remove one of our named units.

So we have stopped it from selling all structures already. But if all buildings of the Skirmish AI are destroyed the game would still end except we do anything against that. So we give an additional structure to Skirmish AI outside of the map, where the opponent players can’t kill it. The ChinaPowerPlant can be transfered to a SkirmishPlayer and it won’t be sold like other buildings. First spawn it on team CompEnemy at a safe location outside of the map.

Now we still need to transfer the building to the Skirmish AI. We need to know on which Slot in Lobby it has been started from. For this we use our set flags in conditions. Make sure, that the other scripts due to this point will be closed as well by it.

Last script we need now is about the condition for the Civilian AI, that removes our second named unit.


These are already all basic steps you need. Additional scripts or script snippets sorted by AI type and its purpose will be available soon on the page 6 (Usefull Stuff). It will gradually become more. At least I will share the created map here:

CO-OP Tutorial Map

The created map from the CO-OP Tutorial. You can compare it with my notes there. Of course it can be used as a template map. Feel free.

<<<– 5 –>>>
>>> Index >>> Tutorial Part 04
Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.