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

Custom AI

Status
Not open for further replies.
Level 10
Joined
Jun 6, 2007
Messages
392
Hello! I already asked this long time ago, but I still haven't found a solution and I've been inactive on this project for a long time. I'd be very thankful if someone could help me with this issue.

I've made an ai for a custom race using ai editor (see the screenshots). The problem is that ai doesn't build anything, it only sends workers to gather gold and wood.

I've imported the ai to the map, and I've started it through triggers. Here's my initialization trigger, where I replace the standard units and activate the ai:

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Melee Game - Use melee time of day (for all players)
      • Melee Game - Limit Heroes to 1 per Hero-type (for all players)
      • Melee Game - Give trained Heroes a Scroll of Town Portal (for all players)
      • Melee Game - Set starting resources (for all players)
      • Melee Game - Remove creeps and critters from used start locations (for all players)
      • Melee Game - Create starting units (for all players)
      • Melee Game - Run melee AI scripts (for computer players)
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Race of (Picked player)) Equal to Human
            • Then - Actions
              • Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
              • Unit - Create 1 Town Hall (custom) for (Picked player) at ((Picked player) start location) facing Default building facing degrees
              • Unit - Create 5 Worker for (Picked player) at ((Picked player) start location) facing Default building facing degrees
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked player) is in (All players controlled by a User player)) Equal to False
                • Then - Actions
                  • AI - Start campaign AI script for (Picked player): war3mapImported\AlienAiHuman.ai
                • Else - Actions
            • Else - Actions
 

Attachments

  • AiEditorGeneral.JPG
    AiEditorGeneral.JPG
    92.4 KB · Views: 690
  • AiEditorBuilding.JPG
    AiEditorBuilding.JPG
    128.7 KB · Views: 754
Hi, some questions first,

a) Why have you used the action Campaign AI? Is your map part of a campaign?
b) If you are to use a custom AI, why did you use the action " Melee Game - Run melee AI scripts (for computer players)"?
c) Have you performed the changes in the attached image (through AI editor)?
 

Attachments

  • AI.png
    AI.png
    14.3 KB · Views: 803
Level 10
Joined
Jun 6, 2007
Messages
392
Thanks for your reply!

a) I tried different things and accidentally left it that way. It should be melee ai.

b) Currently I'm using custom ai for only human race, I want other computer players to use the standard ai. I tried disabling that line, after that the computer doesn't do anything (so clearly my custom ai doesn't get started for some reason).

c) I tried that. However, I believe that only affects the test map. I start wc3 manually when testing, because newgen doesn't find my war3.exe.
 
Level 10
Joined
Jun 6, 2007
Messages
392
I editer the trigger a little, but still human ai doesn't work. Other races (default) work as they should.

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Melee Game - Use melee time of day (for all players)
      • Melee Game - Limit Heroes to 1 per Hero-type (for all players)
      • Melee Game - Give trained Heroes a Scroll of Town Portal (for all players)
      • Melee Game - Set starting resources (for all players)
      • Melee Game - Remove creeps and critters from used start locations (for all players)
      • Melee Game - Create starting units (for all players)
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) is in (All players controlled by a User player)) Equal to False
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Race of (Picked player)) Equal to Human
                • Then - Actions
                  • Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
                    • Loop - Actions
                      • Unit - Remove (Picked unit) from the game
                  • Unit - Create 1 Town Hall (custom) for (Picked player) at ((Picked player) start location) facing Default building facing degrees
                  • Unit - Create 5 Worker for (Picked player) at ((Picked player) start location) facing Default building facing degrees
                  • AI - Start melee AI script for (Picked player): war3mapImported\AlienAiHuman.ai
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Race of (Picked player)) Equal to Orc
                    • Then - Actions
                      • AI - Start melee AI script for (Picked player): orc.ai
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Race of (Picked player)) Equal to Undead
                        • Then - Actions
                          • AI - Start melee AI script for (Picked player): undead.ai
                        • Else - Actions
                          • AI - Start melee AI script for (Picked player): nightelf.ai
            • Else - Actions
 
Level 10
Joined
Jun 6, 2007
Messages
392
General tab

Race: custom
Imported custom data

Heroes tab

Changed heroes to custom ones

Building tab

Changed base building to custom town hall
All buildings in priority list are custom, even if they have same names as standard buildings.
Changed gold and lumber workers to custom worker.

Attacking tab

Made one attack group of custom units.

Test configuration tab

Made the changes that you suggested earlier.
 
Level 10
Joined
Jun 6, 2007
Messages
392
Just a thought that crossed my mind... How does the ai know which unit is used for building? There are configuration fields for gold and lumber workers, but not for builder. I also tried changing build priorities so that ai trains more workers first, but it doesn't train them either.
 
Level 10
Joined
Jun 6, 2007
Messages
392
I decided to write the ai from scratch. I tried with the simplest possible ai, yet it still doesn't work (computer doesn't build farms):
JASS:
 globals
        integer worker = 'n00D'   
        integer townHall = 'h001'
        integer farm = 'h00L'
    endglobals
    
    function main takes nothing returns nothing
        call SetMeleeAI()
        
        call SetBuildUnit(1, townHall)
        call SetBuildUnit(5, worker)
        call SetBuildUnit(2, farm)
    endfunction
 
Level 14
Joined
Dec 12, 2009
Messages
1,027
Does the worker unit have a modified Stuctures-Built list in the Object Editor's Techtree - Structures Built field?

Do those structures have any research requirements that would stop them from being built?

Can the AI afford to build the structures/units?

Are required building upgrades listed in the build priorities?

//\\o0//\\
 
Level 10
Joined
Jun 6, 2007
Messages
392
Yes, the worker has (only) custom buildings in the build list.

First items (town hall, worker, farm) don't have any requirements.

The ai doesn't have enough money for a town hall at the start, but that shouldn't matter, because it already has one. It can afford workers and farms. I also tested the ai with greedisgood, didn't work.

In the beginning there are no requirements, and the ai doesn't build at all.
 
Level 14
Joined
Dec 12, 2009
Messages
1,027
Generally speaking, the AI will freeze if no town-hall type building is present (you already have one, and I assume the Object Editor classification includes Town Hall among other relevant types. The worker unit also has the worker classification

If the game isn't started normally, as in use of test map instead of opening the map in-game and assigning AI players, the AI won't do anything. (My experience)

You've imported both the .ai &the .wai files into the map, which include all relevant data

There is space at the base for construction (no unbuildable areas) I assume. AI will crash if no space for building things is present

On a side note, two attack groups should be present: minimum & primary. More can be added if desired.

For the AI I use in Erebus, I have a builder unit listed as highest priority. I also don't have melee checked in the main tab. I also have the AI townhall existing before running the AI scripts (you appear to be doing this).

The only other thing that comes to mind is remaking the AI, but you've done this too. I've several cases where the AI files corrupt for no obvious reason. Sorry I couldn't get you unstuck...

//\\==//\\
 
Level 10
Joined
Jun 6, 2007
Messages
392
Worker and town hall have correct classifications.

I always test the map by starting it from wc3, because I've installed newgen to a different location than wc3.

I've imported only the .ai file. Isn't .wai only used by the ai editor? Anyway, I'll try importing both.

If I start default human ai and replace starting units with human ones, ai works, so there's space at the starting location.

Can attack groups affect building?

Still haven't fixed this, but thanks for your help.

EDIT: IT BUILDS!!! :D I decided to open and save the ai with vanilla editor instead of newgen, and it gave a syntax error. For some reason, my second and third hero's abilities were unknown (which compiles to set skills3[ 1] = ' ') , although I haven't changed the object data after making the ai. Anyway, it works now, thanks to all who have helped!
 
Last edited:
Level 14
Joined
Dec 12, 2009
Messages
1,027
Attack groups shouldn't affect building; however nothing will happen after building everything if the attack groups aren't set-up properly.

I've never used modified versions of the WE; it is recommended that if you're using a non-typical version that you mention it. That way other users can check for any common idiosyncrasies (assuming they exist).

It seems like your .ai did corrupt on you, gotta love it when that happens... I'm glad you're up and running again!

//\\^^//\\
 
Status
Not open for further replies.
Top