AI for Wheat Player dosen't work.

Level 6
Joined
Aug 3, 2021
Messages
106
Hello everyone. I just finished programing AI for the Wheat Player enemy of my upcoming map. When i put the ai in the trigger edtior then tested the map units don't do anything. Watched the Warseeker tutorial on Jass ai did everything right dosent work. Can anyone help me with this? Best regards from Pekisa7.
 

Attachments

  • HumanWheatAI.ai
    3.7 KB · Views: 6
Level 30
Joined
Aug 29, 2012
Messages
1,382
Yeah you had quite a few errors in your script as it turns out :d

1730717142966.png


The problem is that a comma was missing in most lines, you need to do it like so

1730717229328.png


There were also errors (like KNGITH instead of KNIGHT or GRYPHON_RIDER instead of GRYPHON so the game doesn't know what's this)

There's an endloop at the end but no loop to mark the beginning of the loop, I've removed it

Finally, you need to declare what is commander Zolas. I've added this at the beginning:

1730717385401.png


Replace the question marks with the raw ID of your hero in the editor (it's a 4 digit code like H50Z) and it should be good
 

Attachments

  • HumanWheatAI.ai
    3.8 KB · Views: 6
Level 6
Joined
Aug 3, 2021
Messages
106
Yeah you had quite a few errors in your script as it turns out :d

View attachment 494758

The problem is that a comma was missing in most lines, you need to do it like so

View attachment 494759

There were also errors (like KNGITH instead of KNIGHT or GRYPHON_RIDER instead of GRYPHON so the game doesn't know what's this)

There's an endloop at the end but no loop to mark the beginning of the loop, I've removed it

Finally, you need to declare what is commander Zolas. I've added this at the beginning:

View attachment 494760

Replace the question marks with the raw ID of your hero in the editor (it's a 4 digit code like H50Z) and it should be good
Thank you so much. Now it works!
 
Level 6
Joined
Aug 3, 2021
Messages
106
Yeah you had quite a few errors in your script as it turns out :d

View attachment 494758

The problem is that a comma was missing in most lines, you need to do it like so

View attachment 494759

There were also errors (like KNGITH instead of KNIGHT or GRYPHON_RIDER instead of GRYPHON so the game doesn't know what's this)

There's an endloop at the end but no loop to mark the beginning of the loop, I've removed it

Finally, you need to declare what is commander Zolas. I've added this at the beginning:

View attachment 494760

Replace the question marks with the raw ID of your hero in the editor (it's a 4 digit code like H50Z) and it should be good
Hi can you check the demon ai as well. I changed it a little bit. Do i have to do the same thing as last time? Best regards from Pekisa7
 

Attachments

  • DemonGreenAI.ai
    3.7 KB · Views: 6
Level 30
Joined
Aug 29, 2012
Messages
1,382
It wouldn't work because you cannot declare stuff like this

1731068464026.png


Instead you either do this (it will fetch the raw code from the game itself)

1731068402472.png


Or declare everything in the globals at the beginning

1731068642331.png


Note that you technically don't need the names in white, it's just for your own convenience because it's much easier to read instead of "nerw" and stuff like that. But your script is just fine using the raw codes if you give it only that
 

Attachments

  • DemonGreenAI.ai
    3.2 KB · Views: 5
Level 6
Joined
Aug 3, 2021
Messages
106
It wouldn't work because you cannot declare stuff like this

View attachment 495622

Instead you either do this (it will fetch the raw code from the game itself)

View attachment 495621

Or declare everything in the globals at the beginning

View attachment 495623

Note that you technically don't need the names in white, it's just for your own convenience because it's much easier to read instead of "nerw" and stuff like that. But your script is just fine using the raw codes if you give it only that
what about this ai? Whats wrong?
 

Attachments

  • OrcOrangeAI.ai
    3.1 KB · Views: 7
Level 28
Joined
Dec 3, 2020
Messages
968
I generally advise you to not use variables for units if it causes you issues. Player variables are good enough.
Learning the raw ID of wc3 units, spells, upgrades etc becomes muscle memory after you write 10-20 scripts for each race, including some neutral hostile units.
ID of custom units is pretty simple and you can just write a comment like this:

call CampaignDefenderEx( 1,2,3, 'ogru') // Grunt
call CampaignDefenderEx( 1,2,3, 'o001') // Custom Unit X -> for example:
call CampaignDefenderEx( 1,2,3, 'o002') // Crossbowman

Like this you at least won't risk the AI not working.

Edit:
I also recommend just copying AI from the campaign maps and adapting it to fit your map(s).
 
Top