• 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.

[General] Adding custom units for AI?

Status
Not open for further replies.
Level 3
Joined
May 4, 2012
Messages
29
Hello and pardon me if this is the wrong section or if this has been asked before (likely it has but I could not find anything).

I have created several custom units for my altered melee maps and I would want them to be recruitable and usable by AI as well. I don't want, however, to create a whole new AI system, I simply want to edit default standard AI and add my units to it. Still, I don't see a way to modify standard AI - when I open AI editor it seems it allows me only to create a whole new AI and it looks like default one is not present as a file for opening anywhere either.

How can I then add these units without having to make a whole new AI?

Thanks for help.
 
Level 3
Joined
May 4, 2012
Messages
29
Hmm.. If you don't want to create a whole new ai, then instead of creating new custom units, what about editing just the default ones.. I think you can do that to trick AI into buidling em' but I'm pretty sure they won't be able to use custom abilities right.

The thing is, I don't want existing units to disappear, I just want to add some new ones.

Is there, perhaps, a standard AI file for download somewhere, so that it could be opened and modified?
 
Level 14
Joined
Dec 12, 2009
Messages
1,027
As I recall, the standard AI is buried somewhere in the mpq files. Generating a new custom-AI that uses all the standard units as well as the ones you want it to is a viable option. The only thing you should avoid is changing a Hero's abilities after generating the AI script; updating that feature of the AI code is a pain.

For more info on the AI editor:
VeljKom's AI Editor Tutorial
Av3n's AI Editor Tutorial
Av3n's AI Editor Importing Tutorial

//\\oo//\\
 
Level 3
Joined
May 4, 2012
Messages
29
I will search for it today in the evening, are there several AI standard files or just one?
 
Level 3
Joined
May 4, 2012
Messages
29
I got these files, but they are .ai and not .wai and so I cannot open them in AI editor. How do I convert them to .wai or import them otherwise?

Thanks for help!
 
Level 14
Joined
Dec 12, 2009
Messages
1,027
.wai is the GUI interface-version of the script, the .ai is the JASS code. The .ai is imported into the map with the .wai and is used by the game. You can edit the .ai files via some text editor and import them back into your game.

To edit the right things requires trial and error. To figure out what unit/ability names are in JASS I create a GUI trigger that checks for them as a condition (no actions) and convert it to JASS to get the unit names I need to search for in the JASS code. Then it becomes trial and error regarding how to get the code working. Just change one thing at a time to allow for easy checking of your work. This will take a while, sinceyou're beginning to learn JASS.

//\\oo//\\
 
Level 3
Joined
May 4, 2012
Messages
29
I see. That's a lot of a hassle to just make AI use several new units...

Are there any good AI files out there for download that I could maybe use instead? They don't have to be similar to Blizzard ones, just bug-free and at least as difficult.

If there are none (and I couldn't find any), I will do what you said, thanks for this!
 
Level 3
Joined
May 4, 2012
Messages
29
Ok, so I've found this revamped AI system, AMAI, and it allows for customization. While I understand I have to modify standardunits.txt file to add new units, I don't get where can I find my units' "4-letter codes" and "Names in AI". For example, according to this file, Mountain King's "Name in AI" is "MTN_KING" and his code is "Hmkg". Where do I find these when it comes to custom units?
 
Level 14
Joined
Dec 12, 2009
Messages
1,027
Ok, so I've found this revamped AI system, AMAI, and it allows for customization. While I understand I have to modify standardunits.txt file to add new units, I don't get where can I find my units' "4-letter codes" and "Names in AI". For example, according to this file, Mountain King's "Name in AI" is "MTN_KING" and his code is "Hmkg". Where do I find these when it comes to custom units?

I'm not sure if there's a list posted somewhere. Usually, I do this:
1) Create a new trigger in the Trigger Editor
2) Under "Actions" you create a new action (ignore Events/Conditions), Action Type is "Unit", create 1 <units> (footman as example) facing angle... the rest doesn't matter, just hit "OK" after you've selected the unit you want.
3) Select the trigger you just made; under "Edit" you'll find "Convert to Custom Text", click it. You'll get a warning prompt, just hit "OK" (you can undo this conversion if it's for some reason desired).
4) You'll see something like this:

JASS:
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
    call CreateNUnitsAtLoc( 1, 'hfoo, Player(0), GetRectCenter(GetPlayableMapRect()), bj_UNIT_FACING )
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction

CreateNUnitsAtLoc( 1, 'hfoo, Player(0), part is what you're interested in.

5) Now you know that footman = hfoo, write it down somewhere for later ref.
6) Repeat for any other names you need.

On a side note, you can find JASS names of abilities this way too.

//\\oo//\\
 
Level 3
Joined
May 4, 2012
Messages
29
There's an easier way too. You can press Ctrl+D in object editor and it shows the IDs.

Works like a charm :)
One more thing though, when can I get the "names in AI" of these units as well? Like "MTN_KING" for Mountain King. These are needed, as well.
 
Level 3
Joined
May 4, 2012
Messages
29
Hmm, I will try to do something about it.

Anyway, I have another question - if I changed a standard unit's name (and also description, sound set and model, though that probably doesn't matter) but not abilities or production requirements, will this affect the AI? Will AI still train this unit as if it was the old one?

Thank you. :)
 
Level 14
Joined
Dec 29, 2009
Messages
931
I believe the AI doesn't actually use the names or anything from the unit. It likely only uses it's value,
which, if you don't create a new unit, will probably remain the same.'

This said, you can create custom abilities and give it to the default units.
You simply need to base the ability off of something the AI would cast.

Visit this thread to see what base abilities the AI will use.
 
Status
Not open for further replies.
Top