• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

how do use custom AI with a custom race for a Campaign

Status
Not open for further replies.

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
You need to export the AI script in the AI editor and import that script into your map. Then you can use
  • AI - Start campaign AI script for Player 2 (Blue): importedAIscript
to start the AI for a player
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
Can you post your triggers?
It is important, that the player status of that player is "computer" and that you do not start the melee ai for that player.
 
Level 3
Joined
Jun 7, 2016
Messages
21
upload_2017-11-5_22-47-19.png
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
You should use Map Initialization as event, as your event will fire multiple times.
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
Can you send me the map? It's difficult to say what is wrong at the moment and it is probably just a small detail that causes the AI not to work.
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
A few things I noticed:
the player is player 2, but player 1 is set as victim in the ai script.
you have several triggers with the event map initialization, that are connected and need to run in a certain order to work:
Burning Legion AI Attack has to run after Name, because it uses the variable that is set in Name
you can use
  • Trigger - Run Burning Legion AI Attack <gen> (checking conditions)
in Name to run Burning Legion AI Attack and remove the event from Burning Legion AI Attack.
the raw codes in your ai script are wrong:
Doomguard: you use "n00M:nbal", but you need to use 'n00M'. Raw codes consist of 4 characters and are marked with these ' '
With a syntax highlighter it looks like this:
JASS:
"n00M:nbal" //this is a string
'n00M' //this is a raw code
The hero abilities also need to be surrounded by ' ' and not " ".

There are syntax errors in your AI script:
JASS:
function main takes nothing returns nothing   
    call CampaignAI (<"u004:unp2">, function hero_levels)
    call ConfigureAI()
   
    local integer cmd // <==Only set it if you are going to use the option 2
    ... // Your building code here
    // Option 1
    call WaitForSignal() // <== Just waits until the map sends a command
local variables may only be declared at the top of the function, so no "set", "call", "if" or any other similar keyword before all locals
the ... before the // will also cause a syntax error. Either remove them or put them behind the //

I can't say for sure, that the AI will work, if you fix these, but you are getting it closer to work.
 
Level 3
Joined
Jun 7, 2016
Messages
21
A few things I noticed:
the player is player 2, but player 1 is set as victim in the ai script.
you have several triggers with the event map initialization, that are connected and need to run in a certain order to work:
Burning Legion AI Attack has to run after Name, because it uses the variable that is set in Name
you can use
  • Trigger - Run Burning Legion AI Attack <gen> (checking conditions)
in Name to run Burning Legion AI Attack and remove the event from Burning Legion AI Attack.
the raw codes in your ai script are wrong:
Doomguard: you use "n00M:nbal", but you need to use 'n00M'. Raw codes consist of 4 characters and are marked with these ' '
With a syntax highlighter it looks like this:
JASS:
"n00M:nbal" //this is a string
'n00M' //this is a raw code
The hero abilities also need to be surrounded by ' ' and not " ".

There are syntax errors in your AI script:
JASS:
function main takes nothing returns nothing  
    call CampaignAI (<"u004:unp2">, function hero_levels)
    call ConfigureAI()
  
    local integer cmd // <==Only set it if you are going to use the option 2
    ... // Your building code here
    // Option 1
    call WaitForSignal() // <== Just waits until the map sends a command
local variables may only be declared at the top of the function, so no "set", "call", "if" or any other similar keyword before all locals
the ... before the // will also cause a syntax error. Either remove them or put them behind the //

I can't say for sure, that the AI will work, if you fix these, but you are getting it closer to work.


Thank for the help and i get the AI working for the most part but now the AI is not sending out unit to attack.
 
Status
Not open for further replies.
Top