• 🏆 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!

Custom Campaign AI not working - Acolyte problem?

Status
Not open for further replies.
Level 2
Joined
Apr 8, 2011
Messages
10
Custom Campaign AI not working - Acolyte problem? [SOLVED]

Hi everyone!

It's kind of embarrassing for me to ask this... It seems selfish that I am asking for help after being so inactive in these forums for so long. I'm sorry for that. Anyway, if anyone wants to help me I would be extremely grateful, I could include your name in the Special Thanks credits if you want.

Recently I moved to Dublin, and I got more freetime than in the past, so I decided to resurrect one of my old World Editor projects. I'm not too pro on it, but I know the basics. I think I can say I know more than the basics :p Anyway, my project consists on a modification of the Human ROC campaign with new races and introducing some of my friends names (they've been asking me to finish it for years xP)

The problems begin when I start handling campaign AI's. Having custom units based on Human and Undead units, I need to create campaign AI scripts (easy to do so by copying files like h04_green.ai inside the campaign files) and start them using triggers.

The custom scripts I previously used for some race based on Orcs (with no workers, only basic attacking units and training buildings with preset properties) worked, but the ones for the Undead army don't work at all.

My theory was that the problems come when using Acolytes and Haunted Gold Mine, as the Gather and Gold Mine abilities might be complicated to call, but I tested the units and I can assure:

· The custom Haunted Gold Mine can be built on normal Gold Mines, as usual. No problem with that.

· The custom Acolytes can harvest gold with the custom Haunted Gold Mine. No problem with that.

· Both the custom Haunted Gold Mine and the custom Acolytes are marked as 'undead'. No problem with that.

I must clarify that the custom Acolytes are new units based on Acolytes, but the custom Haunted Gold Mine is just the usual Haunted Mine modified in the Campaign editor custom data. I tried modifying the usual Acolytes as well but the result was the same: the result is that all custom units stay still and do nothing when game starts and the campaign AI is called. Specially the custom Acolytes don't harvest at all.

Unless I'm missing something, I think the problem is in the AI script, because the units seem to behave correctly when used by a human player (me). Somehow the script can't order any custom unit to do anything, although it is an exact copy of h04_green.ai but stablishing global variables for the custom units and changing the units that are called for them.

If I remember right, I did manage to make the AI work the last time I attempted to work in the project (in 2010 or so, I didn't finish any chapter further than the 6th one), the suicidal waves worked and so on, but I lost all the files, so I don't know where the answer is :/

So, if anyone can throw me some light, I would be very grateful. I've looking for help in the forums and I found a lot of people complaining about custom Haunted Gold Mines not working, but that's not been of any help.

I can provide further information or files, if needed

Thanks for reading
Have a nice November!
 
Last edited:
Level 5
Joined
Oct 27, 2007
Messages
158
Hi everyone!

It's kind of embarrassing for me to ask this... It seems selfish that I am asking for help after being so inactive in these forums for so long. I'm sorry for that. Anyway, if anyone wants to help me I would be extremely grateful, I could include your name in the Special Thanks credits if you want.

Recently I moved to Dublin, and I got more freetime than in the past, so I decided to resurrect one of my old World Editor projects. I'm not too pro on it, but I know the basics. I think I can say I know more than the basics :p Anyway, my project consists on a modification of the Human ROC campaign with new races and introducing some of my friends names (they've been asking me to finish it for years xP)

The problems begin when I start handling campaign AI's. Having custom units based on Human and Undead units, I need to create campaign AI scripts (easy to do so by copying files like h04_green.ai inside the campaign files) and start them using triggers.

The custom scripts I previously used for some race based on Orcs (with no workers, only basic attacking units and training buildings with preset properties) worked, but the ones for the Undead army don't work at all.

My theory was that the problems come when using Acolytes and Haunted Gold Mine, as the Gather and Gold Mine abilities might be complicated to call, but I tested the units and I can assure:

· The custom Haunted Gold Mine can be built on normal Gold Mines, as usual. No problem with that.

· The custom Acolytes can harvest gold with the custom Haunted Gold Mine. No problem with that.

· Both the custom Haunted Gold Mine and the custom Acolytes are marked as 'undead'. No problem with that.

I must clarify that the custom Acolytes are new units based on Acolytes, but the custom Haunted Gold Mine is just the usual Haunted Mine modified in the Campaign editor custom data. I tried modifying the usual Acolytes as well but the result was the same: the result is that all custom units stay still and do nothing when game starts and the campaign AI is called. Specially the custom Acolytes don't harvest at all.

Unless I'm missing something, I think the problem is in the AI script, because the units seem to behave correctly when used by a human player (me). Somehow the script can't order any custom unit to do anything, although it is an exact copy of h04_green.ai but stablishing global variables for the custom units and changing the units that are called for them.

If I remember right, I did manage to make the AI work the last time I attempted to work in the project (in 2010 or so, I didn't finish any chapter further than the 6th one), the suicidal waves worked and so on, but I lost all the files, so I don't know where the answer is :/

So, if anyone can throw me some light, I would be very grateful. I've looking for help in the forums and I found a lot of people complaining about custom Haunted Gold Mines not working, but that's not been of any help.

I can provide further information or files, if needed

Thanks for reading
Have a nice November!

I'd be happy to help. Please post the following info so I can look at it.

  • Contents of the custom h04_green.ai script in jass tags.
  • Complete triggers that deal with setting up the AI's in trigger tags.
  • The path you used to import the custom AI script in the map. By default it's war3imported/customscript.ai
 
Level 2
Joined
Apr 8, 2011
Messages
10
I'd be happy to help. Please post the following info so I can look at it.

  • Contents of the custom h04_green.ai script in jass tags.
  • Complete triggers that deal with setting up the AI's in trigger tags.
  • The path you used to import the custom AI script in the map. By default it's war3imported/customscript.ai

:)

JASS:
//============================================================================
//  Orden 04 -- green player -- AI Script
//============================================================================

globals
    player user = Player(1)
    constant integer GRANO_1 = 'u60B'
    constant integer GRANO_2 = 'u60C'
    constant integer ESTIGIA_1 = 'u607'
    constant integer BARRACAO = 'u606'
    constant integer MAUSOLEO = 'u60D'
    constant integer ESTIGIA_2 = 'u608'
    constant integer ZOMBI = 'u602''
    constant integer ESQUEL = 'u605'
    constant integer HECHIESQ = 'u603'
    constant integer UPG_PUDRE = 'R60K'
    constant integer UPG_MARCHF = 'R60G'
    constant integer UPG_MUERTE_FA = 'R60C'
    constant integer UPG_MUERTE_FD = 'R60E'
    constant integer UPG_HECHIESQ = 'R60H'
endglobals

//============================================================================
//  main
//============================================================================
function main takes nothing returns nothing

	call CampaignAI(GRANO_1,null)
    set campaign_wood_peons = 2
	call SetReplacements(1,1,3)

    call SetBuildUnitEx( 1,1,1, ZOMBI           )
    call SetBuildUnitEx( 0,0,1, ESTIGIA_1      )
    call SetBuildUnitEx( 0,0,1, BARRACAO             )
    call SetBuildUnitEx( 0,0,1, MAUSOLEO         )
    call SetBuildUnitEx( 0,0,6, GRANO_1        )
    call SetBuildUnitEx( 0,0,1, ESTIGIA_2      )
	call SetBuildUnitEx( 0,0,6, GRANO_2        )
    call SetBuildUnitEx( 5,5,5, ZOMBI           )

    call CampaignDefenderEx (1,1,3, ESQUEL	)
	call CampaignDefenderEx (0,0,2, HECHIESQ	)

    call WaitForSignal()

	// *** WAVE 1 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 3,3,6, ESQUEL   )
    call CampaignAttackerEx( 0,0,1, HECHIESQ   )
    call SuicideOnPlayerEx(M5,M5,M1,user)

	call SetBuildUpgrEx( 0,0,1, UPG_PUDRE )
    call SetBuildUpgrEx( 0,0,1, UPG_MARCHF   )

	// *** WAVE 2 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 4,4,7, ESQUEL	)
    call CampaignAttackerEx( 0,0,2, HECHIESQ   )
    call SuicideOnPlayerEx(M6,M6,M3,user)

	call SetBuildUpgrEx( 0,0,1, UPG_MUERTE_FA  )

	// *** WAVE 3 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 1,1,12, ESQUEL	)
    call CampaignAttackerEx( 2,2,0, HECHIESQ	)
    call SuicideOnPlayerEx(M5,M5,M3,user)

	call SetBuildUpgrEx( 0,0,1, UPG_HECHIESQ		)
	call SetBuildUpgrEx( 0,0,1, UPG_MUERTE_DA)

	// *** WAVE 4 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 5,5,2, ESQUEL   )
    call CampaignAttackerEx( 0,0,6, HECHIESQ   )
    call SuicideOnPlayerEx(M5,M5,M4,user)

	call SetBuildUpgrEx( 0,0,2, UPG_MUERTE_FA  )

	// *** WAVE 5 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 3,3,12, ESQUEL  )
    call CampaignAttackerEx( 2,2,2, HECHIESQ   )
    call SuicideOnPlayerEx(M6,M6,M3,user)

	call SetBuildUpgrEx( 0,0,2, UPG_MUERTE_DA)

    loop
		// *** WAVE 6+ ***
		call InitAssaultGroup()
		call CampaignAttackerEx( 6,6,6, ESQUEL   )
		call CampaignAttackerEx( 0,0,6, HECHIESQ   )
		call SuicideOnPlayerEx(M5,M5,M4,user)

		// *** WAVE 7+ ***
		call InitAssaultGroup()
		call CampaignAttackerEx( 4,4,12, ESQUEL	)
		call CampaignAttackerEx( 2,2,2, HECHIESQ	)
		call SuicideOnPlayerEx(M6,M6,M3,user)
    endloop
endfunction

(I'm sorry, some variables have Spanish names)

  • Events
  • Conditions
  • Actions
  • AI - Start campaign AI script for Player 7 (Green): war3campImported\orden04_green.ai
  • AI - Send Player 7 (Green) the AI Command (0, 0)
  • AI - Ignore Guerrero esqueleto 0102 <gen>'s guard position
  • AI - Ignore Guerrero esqueleto 0101 <gen>'s guard position
As you can see, the path is war3campImported\orden04_green.ai
Should I import the script in the map itself instead of importing it in the campaign files?
 
Level 5
Joined
Oct 27, 2007
Messages
158
:)

JASS:
//============================================================================
//  Orden 04 -- green player -- AI Script
//============================================================================

globals
    player user = Player(1)
    constant integer GRANO_1 = 'u60B'
    constant integer GRANO_2 = 'u60C'
    constant integer ESTIGIA_1 = 'u607'
    constant integer BARRACAO = 'u606'
    constant integer MAUSOLEO = 'u60D'
    constant integer ESTIGIA_2 = 'u608'
    constant integer ZOMBI = 'u602''
    constant integer ESQUEL = 'u605'
    constant integer HECHIESQ = 'u603'
    constant integer UPG_PUDRE = 'R60K'
    constant integer UPG_MARCHF = 'R60G'
    constant integer UPG_MUERTE_FA = 'R60C'
    constant integer UPG_MUERTE_FD = 'R60E'
    constant integer UPG_HECHIESQ = 'R60H'
endglobals

//============================================================================
//  main
//============================================================================
function main takes nothing returns nothing

	call CampaignAI(GRANO_1,null)
    set campaign_wood_peons = 2
	call SetReplacements(1,1,3)

    call SetBuildUnitEx( 1,1,1, ZOMBI           )
    call SetBuildUnitEx( 0,0,1, ESTIGIA_1      )
    call SetBuildUnitEx( 0,0,1, BARRACAO             )
    call SetBuildUnitEx( 0,0,1, MAUSOLEO         )
    call SetBuildUnitEx( 0,0,6, GRANO_1        )
    call SetBuildUnitEx( 0,0,1, ESTIGIA_2      )
	call SetBuildUnitEx( 0,0,6, GRANO_2        )
    call SetBuildUnitEx( 5,5,5, ZOMBI           )

    call CampaignDefenderEx (1,1,3, ESQUEL	)
	call CampaignDefenderEx (0,0,2, HECHIESQ	)

    call WaitForSignal()

	// *** WAVE 1 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 3,3,6, ESQUEL   )
    call CampaignAttackerEx( 0,0,1, HECHIESQ   )
    call SuicideOnPlayerEx(M5,M5,M1,user)

	call SetBuildUpgrEx( 0,0,1, UPG_PUDRE )
    call SetBuildUpgrEx( 0,0,1, UPG_MARCHF   )

	// *** WAVE 2 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 4,4,7, ESQUEL	)
    call CampaignAttackerEx( 0,0,2, HECHIESQ   )
    call SuicideOnPlayerEx(M6,M6,M3,user)

	call SetBuildUpgrEx( 0,0,1, UPG_MUERTE_FA  )

	// *** WAVE 3 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 1,1,12, ESQUEL	)
    call CampaignAttackerEx( 2,2,0, HECHIESQ	)
    call SuicideOnPlayerEx(M5,M5,M3,user)

	call SetBuildUpgrEx( 0,0,1, UPG_HECHIESQ		)
	call SetBuildUpgrEx( 0,0,1, UPG_MUERTE_DA)

	// *** WAVE 4 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 5,5,2, ESQUEL   )
    call CampaignAttackerEx( 0,0,6, HECHIESQ   )
    call SuicideOnPlayerEx(M5,M5,M4,user)

	call SetBuildUpgrEx( 0,0,2, UPG_MUERTE_FA  )

	// *** WAVE 5 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 3,3,12, ESQUEL  )
    call CampaignAttackerEx( 2,2,2, HECHIESQ   )
    call SuicideOnPlayerEx(M6,M6,M3,user)

	call SetBuildUpgrEx( 0,0,2, UPG_MUERTE_DA)

    loop
		// *** WAVE 6+ ***
		call InitAssaultGroup()
		call CampaignAttackerEx( 6,6,6, ESQUEL   )
		call CampaignAttackerEx( 0,0,6, HECHIESQ   )
		call SuicideOnPlayerEx(M5,M5,M4,user)

		// *** WAVE 7+ ***
		call InitAssaultGroup()
		call CampaignAttackerEx( 4,4,12, ESQUEL	)
		call CampaignAttackerEx( 2,2,2, HECHIESQ	)
		call SuicideOnPlayerEx(M6,M6,M3,user)
    endloop
endfunction

(I'm sorry, some variables have Spanish names)

  • Events
  • Conditions
  • Actions
  • AI - Start campaign AI script for Player 7 (Green): war3campImported\orden04_green.ai
  • AI - Send Player 7 (Green) the AI Command (0, 0)
  • AI - Ignore Guerrero esqueleto 0102 <gen>'s guard position
  • AI - Ignore Guerrero esqueleto 0101 <gen>'s guard position
As you can see, the path is war3campImported\orden04_green.ai
Should I import the script in the map itself instead of importing it in the campaign files?

UPG_MUERTE_DA is not defined in the globals section of the script. Furthermore there's an extra ' at line 13 of the script. You should remove that. Those two syntax errors cause the script not to be run.

Importing files in the campaign editor is fine as long as you start the AI with the same path as the path you used to import the AI script in the campaign editor.

Also remember that campaign AI scripts do not do very well on their own without triggered or scripted resource bonuses. If you haven't already add gold and lumber bonuses, otherwise the AI will run out of resources and do nothing.
 
Level 2
Joined
Apr 8, 2011
Messages
10
I can't believe that, after all this time, the problem was only a syntax mistake.
Specially one as simple and easy to spot as that. I feel kind of ashamed.

I'm not at home right now, so I'll fix it when I come back and I'll tell you the result.

Thank you for your assistance and your advice, Drone.
 
Level 2
Joined
Apr 8, 2011
Messages
10
Problem solved.

I would buy you a beer if you lived closer. It was a stupid mistake, actually, but sometimes it takes you long to find a very small failure and you need the point of view of someone else.

Thank you

+rep

Holy cow, I love this site
 
Status
Not open for further replies.
Top