• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[GUI] AI Editor: A graphical tutorial

Level 15
Joined
Feb 15, 2006
Messages
851
AI EDITOR
An easy start to the AI.


By moyack

Under construction

Recommendations: This tutorial is best viewed in Firefox with 1280x1024 monitor resolution

Index.


Introduction.

Due to demand in AI information, I've decided to start a tutorial about the AI editor. I'll do my best to make it as easy as possible, anyways if you have any question, I'll answer it here.

This text will have reference information from this tutorial: The WC3 AI Editor by uberfoop and Av3n which is more related with AI editor functionality.

Let's start.


Starting the AI editor.

To start the AI editor, you should open WE and press [BROKE=F8]F8[/BROKE] or this button
attachment.php
. This editor is not like the trigger or object editor which require an opened map, instead you can create, edit and open an AI independently to any of them. But if you have a map open, you can inject the developed AI to the map, making it dependable to the units created there (excellent for AI based on custom races). This option will be explained later.

When you open the AI editor you will have this interface:


Figure 1. AI editor - General tab

This interface shows the General tab, we will use it to set the general configuration and global conditions. Because we want to start quickly with our AI, we are going to set the basic features.

First we need to define what kind of AI we are going to do. If we are going to make an AI using a standard race, we should choose in the race combobox the respective race, or custom if we are planning to make one based on a custom race in a map. If we select a normal race, we won't be able to use units from other races, only the standard, campaign or custom ones for the selected race. Custom race in the other hand allow us to select any unit defined in the object editor.

See General Tab reference


Starting a new AI.

Because an example is a good start in the learning process, we are going to emulate a famous human strategy: Mass sorceress. This strategy consist in reach quickly tier 2 to train the sorceress, and then reach tier 3 to get the master training and make this strategy unbeatable. What we will need? well, besides the sorceress, some units from the barracks, mainly footman for tier 1 that can be replaced by knights in tier 3, mortar team as siege support, some special units like priest, and a good support hero for the casters, in this case it will be the Archmage with its summon water elemental + brilliance aura skills. I've seen this strategy sometimes done with a Blood Mage as a second hero (because it can offer its damaging and disabling abilities as an advantage), so I'll add in this strategy too.

With a defined strategy to make, I'll select Human race in general tab, and set the AI name as: Sheep lovers (Figure 2). With this configuration done, we can go straight to the Building tab.

attachment.php

Figure 2. Our first starting...

What can we see?? Basically there is an interface conformed by two list box, the left one is to define the building priorities and the right one is to define the harvest priorities (Figure 3).


Figure 3. Building tab.

attachment.php

Figure 4. Adding a new unit in the building editor
Why is it called building priorities? what's that?

The AI will build the units following the list order, but if any previous unit or building is killed, the AI will give priority to replace the fallen unit according to the list order.

Now that we now how the priorities work, let's start adding some units to this list. As you can see, the list is prefilled with the main hall and 5 peasants, those units are the first units set in a melee game, and with them we are going to build our town. First of all, we need to build a barrack, a farm and an Altar of Kings buildings. To do that, we select the last unit in the list, right click with the mouse, and we will have a menu with the options (Figure 4). We select Add priority..., and a dialog box will appear: the unit type dialog box (Figure 5).

attachment.php

Figure 5. Unit type dialog box.

Here we have different options:
  • Town: Here we select in which town we are going to train or build the unit required. The options are: Any (suggested), Main (The town at the player start location), Expansion # (Refers to a mine WITH the town hall), Mine # (Refers to the mine expansion location, not necessarily it should have the town hall).
  • Build: Here we select the unit which we are going to train. Options are: Hero first, second and third (This will be explained later), Expansion Town, Specific unit and Specific upgrade.

attachment.php

Picture 6. Our first buildings
For our example, we are going to order to the AI to build a barrack, then a farm, and then the Altar of Kings, then we must say to the AI to build more peasants, so they can harvest wood. To do that, we select in Town: Any, Build: Specific Unit, and then we select the barrack building. and press OK. We do the same for the other buildings and units (Figure 6).

As you can see, we must do that for every unit / upgrade we want to build. The question is... is there a faster way to do that?? Of course yes :) For the peons, I just select the last peon, and then make CTRL+C (or do right click and select copy in the pop up menu), and then paste it by pressing CTRL+V. Repeat this step until you get 10 peons.

Now let me see if you do the things in the right way. If you add peasants until get 10 units trained, you will see something like picture 7, but if you paste 10 times the peasant (or even better, 18 peasants... YEAHHH), you will have something like the picture 8:
attachment.php

Picture 7 - Added peasants until get 10 of them trained
attachment.php

Figure 8 - Added peasants in excess :p

As you can see in the picture 8, the last peon is shown in red, why?? because the interface is indicating that the the food produced is not enough to keep the units trained, if you add a food provider building prior to this unit, it will be marked in black again.

Because we won't need that amount of peasants at this level, we will remove them until get 10 peasants (like picture 7). Later we will add more peasants when we manage expansions.

Ok, I think it's time to add some attacking units to this AI, so let's add 3 footmen and the First hero. First add a farm so we can have enough food for the next units, then we must add the first hero, do right click over the last unit in the list and select "add priority...", in the unit type dialog box we select in the Build combobox: "Hero - First", then we make click in [BUTTON]OK[/BUTTON]. After that, we add the footmen units, I suggest 3 of them. After doing this, the priorities list should look like the picture on the right (Picture 9).

Our first test.

With this small progress, we can do a test to this AI. To do that, you can press CTRL+F9 or this button
attachment.php
in the AI editor dialog box. This command will start WE running the plunder isle map. When the AI starts, you will see the sequence in the building process:
  • First it will start the barracks, then a farm and then the Altar of Kings. That's ok.
  • The town hall won't build any peasant until it has started all the prior buildings (according to the priorities list), as soon as the Altar of Kings is started, the AI will construct the peons. This situation can become a disadvantage against the enemy because is time that the AI waste and can be used to get a warrior unit. We will discuss later how to solve this issue.
  • After finishing the Altar of Kings, it starts to train a random hero.
  • As soon as a hero is trained, it will try to get a new gold mine. If the AI can't defeat the enemy, it retreats and it gets more warriors, and it will try again, and again, and again until defeat the target enemy group.
attachment.php

Figure 9 - AI with the first warrior units.
Now we must have several questions: How should we control how randomly a hero is chosen, and which heroes should be chosen by the AI?? How to remove those "dead times" and make the AI faster at training units /buildings?? how to control the AI attacks?? As the Spellbreaker said: Watch and learn.


Hero Settings.

As we know, the heroes in WC3 are a very important component for the game, for its skills and attributes which makes them unique, affecting the game flow for good or for bad. The hero effect in the game depends on the following factors:

  • Heroes selection and order (which hero is trained in which tier)
  • Skills selection in all the heroes
For the AI specifically, the heroes have other important function: they are the leaders of the attacking units. If in the game there's no defined AI heroes, there are many chances that the AI won't attack, keeping sleeping until it's is attacked (without react accordingly).

Now that we understand how important are the heroes for the AI, we are going to check it out the Hero interface. Select the "Heroes" tab in the AI editor and you will see this (Figure 10):


Figure 10 - Hero Interface

Let's enumerate the interface functions:
  • We have a section called "Heroes used" to select which heroes will be trained for the AI.
  • A "Training Order" section where we indicate the chances that the AI will train heroes in a specific order, showing us the different combinations.
  • And finally a the "Skill selection" section, where we define in which order the heroes skills are learned. As you can see, the skills per hero can be different depending of the tier which the hero is trained.

Now... how can we configure this interface according to the AI example?? as you remember, we need to train 2 heroes only. We can set this by assigning in the "Heroes Used" section the third hero as None. When you do that, automatically the interface disable some parts of the interface (very convenient :emote_wink: ). After doing that, select in the first choose box the Archmage and in the second one the Blood mage. Then set to 100% the chances that the AI trains fist the archmage and then the blood mage. You will notice that the second option (first bloodmage and second archmage) is set to 0% automatically. The interface should look like this (Figure 11):


Figure 11 - Setting the heroes for the Sheep Lovers example. Step 1.

And the last thing to do is to set the skill learning order for each hero. To do that, we select in the "For Hero" choose box the hero which we want to modify the skills order, and we arrange them by selecting each one and modifying its order with the [button]Move Up[/button] and [button]Move Down[/button] buttons. For our AI example, we are going to modify the Archmage's skill order to this one (Figure 12):

Level
Skill
1Water Elemental
2Brilliant Aura
3Water Elemental
4Brilliant Aura
5Blizzard
6Teletransportation
7Brilliance Aura
8Water Elemental
9Blizzard
10Blizzard
attachment.php
Figure 12 - Setting the heroes for the Sheep Lovers example. Step 2.

For this case I consider the Blood mage abilities are ok, but if you want to change them too, go ahead :)

Now that we know how to set up the heroes for our AI, we are going to deal with other important AI Editor feature: Conditionals.


Conditionals.

One of the most important features in the AI Editor is the Conditionals. They can be used to help the AI to take a right decision according to the situation at some point, making more "smart".

Where can you apply the conditionals? they can be used in:

  • General tab:
    • Conditions
  • Building tab:
    • Building Priorities
    • Harvest Priorities
  • Attacking tab:
    • Units
    • Target Priorities
How to add a condition to priorities?? Just select the desired priority and right click over it, you will see the option "Modify Condition..." (Figure 13). As soon as you make click on it, you will see the following dialog box (Figure 14).
attachment.php


Figure 13. Conditional menu
attachment.php


Figure 14. Conditional Dialog Box

attachment.php


Figure 15. Configure Condition dialog box
By default, this dialog box is set to none. In order to create a new conditional, we must do click in the list box, and select "custom", this will enable the button [button]Configure Condition[/button]. Now you can press it and a new dialog box appears (Figure 15). In this one you will feel familiar, because it's similar to the trigger editor dialogs, the only difference is the kind of data that you can select in it. The comparisons are classified in:

  • Boolean Comparison
  • Integer Comparison
  • And
  • Or

The last two kind of Comparison enable And and Or operations between other comparisons, so you will be able to do complex evaluations. A complete list of comparisons can be found in the AI Editor tutorial by Av3n

I think it's time to do a conditional for our AI example. As you can remember, the AI only will train the first hero if it has built 10 peasants and a farm, as you can see, putting the AI to wait until this is a waste of time, it will be better if as soon as the Altar of Kings is built, we put the hero to train. In order to achieve this behavior, we must change the hero priority before the sixth peasant. If we left the things as is, the other 5 peasants won't be trained until the hero begins its training at the Altar of Kings. So we are going to configure the AI so it will train the first hero as soon as the Altar of Kings building is completed, if not, it will train the other units and buildings.
First we have to put the Hero First priority after the Altar of Kings building, then we select it, and then we do right click over this priority selecting "Modify Condition..."

attachment.php

Figure 16.1
After the AI condition is selected, we change in the Condition list box to Custom. We'll see that the button [button]Configure Condition[/button] is enabled.

attachment.php

Figure 16.2
Press it and the "Configure Condition" dialog box pop ups. Having that, we select an "Integer Comparison" and we'll see a text in hyperlink showing a dogmatic true 0 = 0. Let's click on the first 0

attachment.php

Figure 16.3
With the Integer comparison dialog box opened, we browse through the integers functions and select the item with the label "Unit - Total Units of Type - Completed Only". Then we press the [button]Ok[/button] button.

attachment.php

Figure 16.4
Now that we have selected our function, we must define the unit type to be counted. In this case we want to check the amount of Altars of Kings. We make click in the link text, and this will open this window.

attachment.php

Figure 16.5
Now that we have selected that unit type, we will see this dialog box "filled". After this press the [button]Ok[/button] button. With this we have defined the first element of comparison.

attachment.php

Figure 16.6
Now let's define the comparison operator. Select in the "Configure condition" dialog box the Equal to link. This will open this dialog (Figure 16.7). After selecting the appropriate comparison operator (In this case Greater than), press the [button]Ok[/button] button.

attachment.php

Figure 16.7

Because we need to do a comparison to a value greater than 0, we don't have to modify the comparison value. But if you need to change that value, just make click in the integer and change the variable in the value that you need. When you have the conditional set, just press the [button]OK[/button] button.

attachment.php

Figure 16.8 - Almost finishing the conditional
Congratulations!!! you have done your first conditional!!! Now it's time to save it, so please press the [button]OK[/button] button in the AI condition dialog box.

attachment.php

Figure 16.9 - Conditional finished... saving time!!
 

Attachments

  • AI Editor Icon.jpg
    AI Editor Icon.jpg
    918 bytes · Views: 2,102
  • Basic Conf1.jpg
    Basic Conf1.jpg
    5.6 KB · Views: 269
  • Conditional Dialog2.jpg
    Conditional Dialog2.jpg
    14.3 KB · Views: 227
  • Conditional Dialog.jpg
    Conditional Dialog.jpg
    7.6 KB · Views: 203
  • Conditional Ex1.jpg
    Conditional Ex1.jpg
    13.6 KB · Views: 190
  • Conditional Ex2.jpg
    Conditional Ex2.jpg
    8.1 KB · Views: 231
  • Conditional Ex3.jpg
    Conditional Ex3.jpg
    21 KB · Views: 265
  • Conditional Ex4.jpg
    Conditional Ex4.jpg
    33.3 KB · Views: 236
  • Conditional Ex5.jpg
    Conditional Ex5.jpg
    49.5 KB · Views: 281
  • Conditional Ex8.jpg
    Conditional Ex8.jpg
    16.5 KB · Views: 200
  • Conditional Ex9.jpg
    Conditional Ex9.jpg
    11.2 KB · Views: 191
  • Conditional menu.jpg
    Conditional menu.jpg
    8.9 KB · Views: 192
  • Hero Interface small.jpg
    Hero Interface small.jpg
    40.9 KB · Views: 211
  • Hero Interface.jpg
    Hero Interface.jpg
    80 KB · Views: 314
  • Hero settings 1.jpg
    Hero settings 1.jpg
    80.3 KB · Views: 247
  • Hero settings 1s.jpg
    Hero settings 1s.jpg
    39.7 KB · Views: 212
  • Hero skill order1.jpg
    Hero skill order1.jpg
    15.8 KB · Views: 266
  • Interface1s.jpg
    Interface1s.jpg
    26.6 KB · Views: 198
  • Interface2s.jpg
    Interface2s.jpg
    29.4 KB · Views: 196
  • Interface3.jpg
    Interface3.jpg
    16 KB · Views: 214
  • Interface4-1.jpg
    Interface4-1.jpg
    19.9 KB · Views: 225
  • Interface4-2.jpg
    Interface4-2.jpg
    32.1 KB · Views: 271
  • Interface5.jpg
    Interface5.jpg
    26.3 KB · Views: 231
  • Menu1.jpg
    Menu1.jpg
    18.5 KB · Views: 302
  • Test_Button.jpg
    Test_Button.jpg
    920 bytes · Views: 886
  • Unit selection1.jpg
    Unit selection1.jpg
    33.2 KB · Views: 288
Last edited:
Things to do: place the images in the Hive server...

Hi moyack. Great tutorial. :) However, the images must be shown in the main post instead of just attached. =X If wc3c goes down, then the links won't show up.

If you don't want to do this, then I may be able to do it for you in my spare time. However, it may take a little longer for me to match up the images with where they are in the post.

EDIT: Sadly, I'm graveyarding it until the broken images are updated or removed. I'll still use this as a linkback. PM me if you want to update it.
 
Last edited:
Top