Tutorial: The wc3 AI Editor

uberfoop

~=Admiral Stukov=~
Reaction score
177
Notification:
Firstly, if you are looking at this tutorial to create anything other then a simple campaign AI to make a computer army control it's units like other standard computer armies, you should probably stop looking here now and check out Conan's tutorial, which focuses mainly on making a great AI for a single hero or unit. Conan's tutorial is located here: http://www.thehelper.net/forums/showthread.php?t=15516



The AI editor is a fairly simple tool, although it can be confusing to new mappers because of its layout. The game uses .ai files to command units, but ai editor files (before being converted to game-readable .ai files by the editor) are stored as .wai.

This tutorial is split up to do a surface covering of the important aspects of each of the different tabs in the editor:
Code:
I. General
II. Heroes
III. Building
IV: Attacking
V. Test Configuration
VI. Finishing Up
Each section gives a brief explaination of each part of its Tab.


I. General Tab

The 'General' Tab is, as it's name implies, very general. Parts of the general tab, starting from the top left:

-Name: The name of the AI that the game uses. If the box below that says 'set player name' is checked, whatever army in-game that uses this AI will have the name you enter here be their player name.

-Race: This is obviously important; an orc AI can only make orc units. If you want to be free in that sense, you can pick 'custom'. This opens up other options so you can create custom races AI's. However, to use custom units in an AI, you need to open up the object editor where the custom units are, use the 'export all object data' under the 'file' menu, and import the data into the AI editor using the custom data area on the bottom of the general tab.

-The 'option' section which contains the 17 checkboxes:
Set Player Name: Makes the AI player in-game use the name you gave it in the name box
Melee: If checked, the AI will be more alliance-strike-oriented. If unchecked, the AI is good at ignoring what allies are doing to own the enemy.
Defend Users: If checked, an AI will try to help person-controlled players who are being attacked.
Random Paths: If checked, the AI will choose where to go more randomely.
Target Heroes: Checking this makes the AI focus heavily on enemy heroes.
Repair Structures: Allows the AI to repair damaged structures when needed.
Heroes Flee: Causes damaged or heroes incapable of hurting the enemy to try and retreat themselves from combat.
Units Flee: Same as above, but with non-hero units
Groups Flee: Allows an army to retreat from battle if it thinks it's at a disadvantage. Without this option checked, AI armies will still fight even if their units are getting wrecked up. Units and heroes can still flee temporarily individualy if those options are checked.
Have No Mercy: The AI version of a maphack. With this checked, the AI will try to nail enemies when they're weak.
Ignore Injured: Causes units with less than 50% health to be exempt from joining attack groups. These units will chill at their base as a defensive-only force until their health gets back up past 50%.
Remove Injured: Causes the AI to send injured units to places to heal if the unit is already in a raiding party.
Take Items: The AI will pick up items from the ground.
Buy Items: The AI can buy items from stores.
Slow Harvesting: Sticks the biggest resource handicap ever on the AI; They can only harvest 1 resource at a time if this is checked.
Allow Home Changes: The main base of an AI is where it attacks from and retreats to; This option allows the AI to choose a new location for this mid-game.
Smart Artillery: The AI will focus siege-damage attacks on buildings if this is checked.

-The custom data section: The uses of the import option are explained 8 lines above on this page. Export will export whatever custom data you;ve already imported. Clear will delete it from the AI.

-Conditions: This is nothing but a big scary white box that does absolutely nothing by itself. You can set up conditions in here for use in the 'building' and 'attacking' tabs. This is explained in tut sections III and IV. Note that you don't actualy NEED to write your conditions here to use them in a different part of the editor; any option where you can use conditions has an option to either use a condition specified in this menu OR create a new one right there. However, when you have a condition that will go through multiple uses for a part of the AI's system, it's good to write it in here for use elsewhere.

II. Heroes Tab

This tab controls what heroes the AI will build by default and abilities it learns on those heroes.
Parts of the heroes tab:

-Heroes used: Interestingly enough, and sadly, it's impossible to make an AI with this editor that is capable of picking between more then 3 heroes, or capable of using more than 10 ability levels. If you want the AI to never get heroes, you can just set all 3 boxes to 'none'. If you only want the AI to get 1 hero type, just fill in the 1st box. If you want the AI to pick between 2 hero types, fill in 2 boxes. If you want an AI army that can pick between 3 hero types, fill in all three.

-Training order: Self explanitory. It just lists all the possible combinations of hero choosing order, and you set which ones you want to occur and how often. For example, if you only want 1 of the orders to ever happen, just set that order to 100%.

-Skill Selection: The tab brings down your lists per hero, and the box on the left below is for choosing what the ability skilling order you want that hero to get is. The boxes to the right are for if you want the hero to level abilities up differently depending on when then hero is picked.


III. Building Tab

This is a very important tab. It not only controls build order, but how many workers do what. Parts of it:

Base Building: This option is only useable if you set race to 'custom' in Tab 1. It's very simple, just set it to the AI's town-hall style building and it'll work fine.

Mine Building: This is only used for custom AI's and only for the Undead style of gold mining where you build the building over the mine. Don't ask why night elf gold mining doesnt use this too, I honestly have no idea. Again, if you're using that style of gold mining, set it to the building your race uses. Otherwise, if it harvests gold normal, leave this as 'none'.

-Build Priorities: This is the build order of your AI, and controls all construction and unit training. It's also the first part where you use conditions. There really isn't that much to say about this, but it is of vital importance. The things closer to the list top are to be built sooner than things near the bottom. Also, Conditions: When you set a condition to one of these, if the condition isnt true when the priority list reaches it, it ignores that object totally until the condition is true. Another thing to be noted is that the AI doesn't understand techtrees, and has some evil 'features' that will screw stuff up. If you have the system queued to make a thing, and it doesn't have the tech requirements for that thing, it will build whatever was last on the list, forever. So if you have a farm on the list right above a gryphon aviary, and the AI doesn't have the tech requirements for the aviary, it will build farms forever.

-Gold worker: Custom race only option. Set it to the worker unit of your race that you want to mine gold.

-Lumber Worker: Custom race only option again. Pretty much same as gold worker option.

-Harvest Priorities: Workers will not do resource gathering without this. A good idea is to have 5 set to gold at each mine your AI might have. This list also has conditions so the AI will ignore harvesting priorities if the condition isnt set. For example, rather then just setting 5 gold workers to work on mine #2, add a condition to check that your AI actualy has 2 gold mines (eg 'number of mines owned greater than or equal to 2'). This chart, as with the other in this AI editor tab, take some practice to coordinate things properly.


IV. Attacking Tab

This is the final tab that controls what the AI will be like in-game. It controls how the computer uses military units. I'm going to go over this tab a little differently then others because theres some things about it that are actualy important and some things that aren't, and I'm basically going to go over the standard way of setting it up, which most people use. There are many ways to set it up, but in general (like, 99% of the time. No joke), people do it like this:

-Attack groups: Make 2 attack groups. Call 1 minimum units and call the other 'main attack group' or something like that. Unit settings for the group currently selected can be found in the white box to the right. Minimum should contain the fewest units that you ever want your AI to leave base with. Basically, the units that the AI will initialy creep with and whatnot. This should contain the hero and at least several of the army's basic units. A good setup for a human AI might be:
first hero...quantity all...conditions none
footman...quantity 2...conditions nonw.
The other attack group should contain everything that you ever want the AI to attack with. Basically, list the first hero and every single attack unit that exists in your building priorities that you want to leave base. If you want that 1 mortar team your AI will make to stay and defend the base, dont list mortar teams in the main attack group. However, even if you leave a unit to defend base, if an enemy aggros the base that unit may run around in retaliation strikes.

-Attack waves: Using the standard method, just make 1 attack wave, and make the group it uses be the 'main attack group' thing. Thats all you need to do.

-Minimum Forces: Set it to your 'minimum' group

-Initial Delay: This is almost always 0. Yes that sounds very untutorial like, but thats what is almost always done with this value, and it always works properly like that in a basic sense.

-Repeats waves: We only have 2 attack groups, and 1 of them is the general 'attack' group, so this should be 1.

-Target priorities: This is very difficult to explain in a tutorial and regardless of skill with the AI editor will require testing of the AI to work it how you want in a map. The things at the top of the list, as long as the conditions you give it are met and the AI is ready to do that thing, will be top priority. Note that in a standard map the default arrangement works pretty well, in case you don't want to mess around with it and test it for a campaign map with several ai players and whatnot.
WARNING: DELETING THE CREEP CAMP PRIORITIES MAY RESULT IN AN AI ARMY SITTING THERE DOING NOTHING

V. Test Configuration

This tab is for testing the AI vs yourself or other AI. If you want it to fight with/against other AI scripts you made, you can select ai type custom in the ai column and import a .ai file.

VI. Finishing Up

There are 2 ways to save an AI for use:
1. Adding it to the map directly. To do this, when you're done with your ai, have the map you want to add it to open and go to the ai editors 'file' options and select 'add to map'. The ai is now attached to the mao directly and can be accessed from the map editor at any time by opening the ai editor and closing any other ai's.

2. Go to 'file' and select 'export script' to save it as a wc3-readable ai file (.ai). Now you have a .ai file which can be imported into a map or campaign and run using the trigger action AI-start campaign AI script.



Note: .ai files can be opened in notepad and directly edited in JASS. There is a tutorial available on how to create and/or edit AI files using JASS:
JASS AI tut-Full credit to moyack of WC3Campaigns
 

R@d14nc3

New Member
Reaction score
49
bump*

Nice one, but I will suggest some things:

1.Do not use coloured text almost never (oh, my eyes!!!).
2.>GL and HF with the AI Editor!
not advisable as well.
Tutorials are pretty more of the formal type (no colours, no words like lol, omg, wtf, gl, hf);)

But nice info contain.
+rep, +rating 4 star galaxy :)
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
*bump* because everything I've received so far on it has been pretty positive


And because I did a few format adjustments to the top +linked up a great tut on how to do this stuff straight as JASS (yes, I did ask him before linking to the tut)
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/
  • The Helper The Helper:
    Here is another comfort food favorite - Million Dollar Casserole - https://www.thehelper.net/threads/recipe-million-dollar-casserole.193614/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top