• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

AI Editor

Level 21
Joined
Jul 27, 2008
Messages
14,361
AI Editor

Introduction:

AI Editor is simple way to create AI for existing or custom race other then use of JASS. AI editor is used for making "Melee Maps or Campaigns", for other type of maps (AoS, TD...) you should use triggers. This tutorial will teach you the basics and hopefully you will be able to make our very own AIs. It is recommended you have at least basic knowledge with triggers.


General Tab

Clip.png
This is where we begin. First thing you will probably do is set AI name and AI race. If you are making AI for custom race, allays remember to set race to be custom.

-Options-
This is quite simple. You will check certain options for AI that will effect it in game. It is already explained in AI Editor but just in case:
*Set Player Name - This option enables use AI name as the AI players name.
*Melee - To use Melee AI for standard games. Melee AI tend to attack and defend more closely to with allied player.
*Defend Users - AI will try to defend attacked user-controlled players.
*Random Paths - AI will tend to use paths more randomly.
*Attack Heroes - AI will place higher priority on attacking enemy heroes.
*Repair Structures - Workers will automatically repair structures.
*Heroes Flee - Heroes will leave the battle if they are seriously damaged or incapable of attacking.
*Units Flee - Units will leave the battle if they are seriously damaged or incapable of attacking.
*Group Flee - AI will try to avoid battles where he is at disadvantage and will run from the battles where he is loosing.
*Have No Mercy - AI will attack when his enemy is at disadvantage or if it is injured. The target corresponds to Enemy-Major Assault (more about this down)
*Ignore Injured - When preparing attack force AI will not use units with health bellow of 50%
*Remove Injured - AI will send injured units back to base or Fountain of Healing.
*Pick Up Items - Heroes will pick up items they find.
*Buy Items - Will buy useful items from any shop they encounter.
*Slow Harvesting - AI will gather only 1 gold and wood. instead of workers capability. This gives AI serious disadvantage.
*Allow Home Changes - AI will be able to chose new locations as Main Base where he will gather attack force and send injured units.
*Smart Artillery - Artillery units will tend to come in front of the attack force and will siege the enemy base if possible.


-Conditions-
But what is more important is window for conditions, they are almost same as the regular editor triggers. Condition you make here will be used latter for unit creation and attacks. Here you'll be able for example to make simple condition like "If number of footmen equal to 5" which you will then use in latter tabs. Conditions are extremely important for your AI.

-Custom Data-
Another important thing here is Custom Data import. Because AI editor is not connected to the map in World Editor you'll first have to extract data of your race from object editor. Go to object editor-file-extract all custom data..." and then simply import them. Its important if you are making a custom race.

Hero Tab

Clip_2.png

In a Hero Tab you will be telling AI what to do with Heroes.

-Heroes Used-
Here you'll set which heroes will be used. You can use any of the already existing heroes and custom heroes but you can chose only 3.

-Training Order-
Here you will set in which order heroes will be used. You can make 6 variation of order which AI will use depending of chance % you set.

-Skill Selection-
Here you will make order by which abilities will be learned for each hero. For each hero there are 3 lists depending when he was made ("as first Hero, as second Hero and as third Hero). You can make all 3 list same which means no mater when hero was made he will use same list.

NOTE:
-If you are using custom hero remember to add them in Advanced-Gameplay Content).
-Be sure AI can make Heroes.
-Go to link below to see which spells are usable by AI.


Building Tab

Clip_3.png

This probably most important tab. Here you'll say to AI each unit that he is going to train and and arrange his economy priorities.

-Building priority-

On this window you'll arrange the "what to do list" for AI. You can also specify in which base to build it. Also you'll here specify Town Hall that is going to be used for race (If it is custom remember to go to Advanced-Gameplay Content) and which mine building will use (like Undead or Night Elves do). AI will build from top to bottom so it is most important to make sure:

1)That units won't go over the food limit. If you go over the current food supply the order will be changed to red color. If this happens simply add food producing building above the red order.

2)That AI is capable of making the unit. You must make sure that the building that produces the unit is made, if upgraded is first needed it must be researched. All requirements must come "before" the unit or it will confuse AI and cause lag. Also be make sure that unit can be made in the building.

When making the list it is wise to use conditions in General Tab or if it is for only one unit you can modify custom condition by right clicking on unit and choosing "custom" condition. It is best to use conditions as much as possible because it will avoid bugs and units with conditions will be "skipped" so you can for example when AI reaches Third Tier order him to stop making footmen and switch to knights. The Conditions are important thing if you want to give your AI more intelligent behavior. Without conditions you are basically giving AI a predictable list which can be exploited.

-Harvest Priorities-

Here you say to AI how many workers will be used on gold or wood. You'll also be have to specified which worker will be used. You can have up to two workers, one for Gold and one for Lumber.

NOTE:
-Be sure AI can make units.

Attack Tab


Clip_4.png

Here you'll make attacks that AI will use. In Attack Group window you'll speechify which units will be used in attack. On the right side just add desired units and number of them that will be used for attack.

In Attack Waves you'll make list of which attack groups will be used and how often.

And last in Target Priorities you'll say which targets (Main Base, creep Camps...) will AI attack and when. Once again here is advices to use conditions from General Tab because you don't want AI to attack with 1 hero and 2 units medium creep camp. You can order for example AI to wait until he reaches 50 food before he attacks. Just don't forget that bad conditions may result for AI to never attack.

Test Configuration


Here you'll be testing your race against opponents but this only works for melee races.

In Action
When building a base, you have to make sure the AI has enough room to place it's buildings. In the WE, this is a radius of about 4 squares (the large golden ones). It'll freeze if it can't place them all.


--------------------------------------------------------------------------
Tutoraials also to see:
http://www.hiveworkshop.com/forums/...-cast-melee-game-ai-units-193280/#post1890195
by Boris_Spider.


Hope this explains the basics and if you have any advice or complaint please tell me. Here is a example of AI View attachment AI(Sea L).w3x. To play with AI set computer player-random-60%.
 
Last edited:
Level 21
Joined
Jul 27, 2008
Messages
14,361
You can only tell AI to make building at specific base like Main, Expansion First, Exp. Second...
You would have to use I guess triggers to order him specifically where.

And thanks on "approval" and choosing category. I'll try in future to make this better.
 
Level 2
Joined
May 28, 2010
Messages
22
Hey, can i make AI for unstandart units...Because i made custom race, but i dont see units in AI editor...How i need make AI for Computer player?
 
Level 21
Joined
Jul 27, 2008
Messages
14,361
Another important thing here is Custom Data import. Because AI editor is not connected to the map in World Editor you'll first have to extract data of your race from object editor. Go to Object Editor-file-extract all custom data..." and then simply import them.

You must first create in editor custom units and then extract that data from the map. Place the newly created file where you want and then open AI Editor go to "General Tab" and you'll see below "Custom Data:" and beneath it you'll see 3 buttons with one of them being "import". Click it then choose the data file you extracted earlier from the map.
 
Level 14
Joined
Dec 12, 2009
Messages
1,027
Is this needed to make a AoS?

The AI editor is only useful if for melee or altered-melee type AI. If you need AoS or Arena type AI you're better off triggering it, otherwise it won't behave as expected.

Some tips for the AI Editor:
~Building: When building a base, you have to make sure the AI has enough room to place it's buildings. In the WE, this is a radius of about 4 squares (the large golden ones). It'll freeze if it can't place them all.

~Priorities: (build order) determine what the AI should get first. YOU MUST HAVE CONDITIONS SPECIFYING WHETHER OR NOT IT IS CAPABLE OF BUILDING THE UNITS. If you don't the game will probably lag as the AI repeatedly attempts to make something when it doesn't possess the tech-tree requirements for it. The game automatically checks to make sure it has the required resources to build. You can increase it if you want via Conditions.

Note: The AI will train units over the expected food limit (red units) as long as you ensure that it has the necessary food before it builds the units.

~Avoid changing hero abilities after importing OE data into the AI. It may not appear and force you to remake the entire thing or spend 3-5 hours reimporting the OE data until the hero skills stick. If you don't re-import the OE data the AI will try to learn abilities it doesn't have and result in an unlearning hero for one or more abilities. Regular (non-learnable)abilities are not affected by this.

~Attacking: Make sure melee AI have a ground path to use to reach opponents. It doesn't really understand how to use Zepplins/Sky Barges if it has them; more often then not you'll stumble acrossa lone unit/hero or maybe a small group of units. If you don't provide a ground path to traverse for ground units, the game will lag as the AI repeatedly issues attack-move commands to a location it can't reach.

Those are the main things that come to mind right now. There are restrictions on what spells the AI will automatically cast. Using channel as the base spell WILL NOT allow the AI to cast it without you triggering it's casting. VeljkoM linked to the tutorial I put up.

//\\oo//\\
 
Last edited:
Level 16
Joined
May 2, 2011
Messages
1,351
I have a problem with my AI,It keeps building orc borrow,masses of orc borrows I mean,even more then those in the ''building'' ,and for that the AI has no lumber,and all his troops are stuck in the base.and he still keep clicking on building .
I tried reimporting the AI but no use,although It doesn't do like that when I test the AI(except if its insane).
Any idea how to solve this?
 
Level 14
Joined
Dec 12, 2009
Messages
1,027
As VeljkoM said, it's probably a bad condition.

Try using this condition:

Condition Type: Integer Comparison:
Total Units of Type: Orc Burrow [Includes those currently being constructed]
Comparison Operator: Less than or Equal to
Value: <Max # of units you want to allow>

You can also use Total Units of Type - By Town to determine the max per town if you want.

Make sure your AI script is the only one running.

//\\oo//\\
 
Level 16
Joined
May 2, 2011
Messages
1,351
yes I think so,I used no condition for building the orc borrows,but shouldn't the AI just build the number I give(in the building section).if not so that means if I let him build 10 grunts and 1 orc raider ,then the orc raider died he may not necessarily build the raider ,but maybe he build a grunt unless I put condition for that, true?and also means that he have to build millions of towns,towers barracks and every thing,but I only see this with orc borrows,not with barracks for examaple,why is that?how does it exactly work with building the units?
this also has just happened to the human AI I made with the scout towers,but yet not with the undead
 
Level 14
Joined
Dec 12, 2009
Messages
1,027
All right, I got access to the scripts. It'll probably be a day or two before I can work on finding the problem. Worse case scenario I'll get to it this weekend. Feel free to start spamming my VMs if you haven't heard from me by the end of Sunday (I'm on Eastern time, btw).

At a glance, it looks like you're getting the same problem I did with my AI in regards to the Human mass towers. When the Scout tower is upgraded into a Guard Tower, the AI detects that it needs to replace the lost scout tower. Basically, it doesn't recognize the upgraded unit. All in all you should be getting 14 scout towers that upgrade into 14 guard towers, but they're getting replaced as they upgrade. You should end up with 28 towers total if you let it run (assuming the AI doesn't run out of build space, AI bases have a max size radius of about 4 of the large squares on the WE grid. Trees, cliffs, unbuildable areas further shrink the amount of usable space.

Only towers and food buildings seem to do this, the others upgrade without problems in my experience. Adding this condition should fix the problem:

[Arithmatic as main function]
[B]Total number units of type: Scout Towers[/B] + Total number of units of type: Guard Towers Less than 21

I strongly recommend experimenting with Conditions in the editor for the mean time. Do random changes to the AE on a seperate test map and see what happens.

Priorities on their own don't make a good AI, conditions do. No conditions will probably crash the AI, or worse, the map. If you'd like an idea of what I'm talking about, download this map and look through the AI build order I have set up. It may help reveal other problems you could have. I'll explain fully when I have some time.

Happy hunting.

//\\^^//\\
 
Level 16
Joined
May 2, 2011
Messages
1,351
As VeljkoM said, it's probably a bad condition.

Try using this condition:

Condition Type: Integer Comparison:
Total Units of Type: Orc Burrow [Includes those currently being constructed]
Comparison Operator: Less than or Equal to
Value: <Max # of units you want to allow>

You can also use Total Units of Type - By Town to determine the max per town if you want.

Make sure your AI script is the only one running.

//\\oo//\\
I made the conditions, still no use and the game started to lag.
one time I tried playing against 2 insane
one of them(the yellow) was building too many orc burrows,the other one plays normally.when I destroyed most of his base he then started to play normally and doing all the upgrade.
unfortunately, I edited the map and the reply no longer works.
 
Level 14
Joined
Dec 12, 2009
Messages
1,027
The lagging indicates that the AI is repeatedly trying to do the same thing over and over again. I did a test run and didn't see anything out of the ordinary. Then again, I had the god cheat on and both AI were constantly attacking me only and thus didn't build normally...

I still have the ver of the map you sent me if you lost your back-up. If you like I can send it to you or edit your AI (add conditions) then send it to you and see if that fixes your problem.

A little off topic, the Orcs are heavily favored to win with access to the most durable ground units in the game, especially since ground is typically only weak to flyers.

//\\oo//\\
 
Level 16
Joined
May 2, 2011
Messages
1,351
I think I got the error.
I remember once trying this AI(grunt master without editing) on 10 player map.They were me and nine computers.And now I really remember that continuous lag happening some time later in the game.There must some kind of error in AI itself even before I edit it.
anyway thank you for your help and responses.
 
Level 1
Joined
Jun 23, 2011
Messages
3
map make

You must first create in editor custom units and then extract that data from the map. Place the newly created file where you want and then open AI Editor go to "General Tab" and you'll see below "Custom Data:" and beneath it you'll see 3 buttons with one of them being "import". Click it then choose the data file you extracted earlier from the map.

please help me, how can i extract the custon unit?!
it's copy unit? please help me!!!

and sorry my vad english ;)
 
Level 14
Joined
Dec 12, 2009
Messages
1,027
please help me, how can i extract the custon unit?!
it's copy unit? please help me!!!

and sorry my vad english ;)

Export the Object data out of the Object Editor to your desktop. Then import that Object data into your AI Editor. You'll have access to all custom units/data you need.

You will have a hard time changing hero abilities after you do this, be sure you won't change what abilities your heroes have before you import the data.

//\\oo//\\
 
Level 4
Joined
Jul 7, 2011
Messages
61
I'm making a Naga AI but the units are not swimming in the water. If you put the base on an island they aren't doing anything they just standing there. Please help.
 
Level 4
Joined
Jul 7, 2011
Messages
61
@VeljkoM I used the original Naga units of Warcraft 3 I tried everything and they still standing on the same spot.
 
Last edited:
Level 21
Joined
Jul 27, 2008
Messages
14,361
Ok first use pastebin not public map section.

Well I think you confused AI since he is tasked to train lady Vashj which he can't also AI doesn't have instruction to use Heroes. Also think Ai is confused since many of the units are already placed so it is possible that they took the populations space needed for units from training list. As for units not swimming I only noticed slaves getting stuck, the rest units that were trained were swimming while those already placed were confused.
 
Level 16
Joined
May 2, 2011
Messages
1,351
Old Times

Hey! Do you remember that AI lagging problem? I think I found an acceptable but not perfect solution to it. It is to Limit the number of orc burrows that can possibly be built by the computer (player X) to a reasonable number. we may use this trigger to do so:
  • Events
    • Map initialization
  • For each (Integer A) from 1 to 12, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Race of (Player((Integer A)))) Equal to Orc
          • ((Player((Integer A))) controller) Equal to Computer
        • Then - Actions
          • AI - Start melee AI script for (Player((Integer A))): war3mapImported\OrcMaster v1.01.ai
          • Player - Limit training of Orc Burrow to 11 for (Player((Integer A)))
          • Game - Grant shared vision and full shared unit control of (Player((Integer A))) units with his/her allies
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
 
Level 3
Joined
May 4, 2011
Messages
35
For those who think that when creating an AI with all building, attacking and conditions and stuff, when you create starting units(Not the workers and the Main Building, everything.), you think that the AI will still use the one you created while there are already the requirements, doubling the buildings provided, you're wrong. The AI will only build once more if that building, if a requirement on the building tab of Building in the AI, when that building is destroyed.
 
Level 21
Joined
Jul 27, 2008
Messages
14,361
Examples like Natures Call series, Rise of the Lich King, Forgotten War, Shards of Resistance, recreations of Wc1 campaigns. Some rpg campaigns though have few missions with bases. Also a special mention for Coming of Horde that uses exclusively triggers for enemy player. All of this is just from Hive Workshop.

Also Creep Rebellion Installer when used on map creates 5th race with workable AIs.
 
Top