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

[AI] Need Help with not working Campaign AI

Status
Not open for further replies.
Level 24
Joined
Feb 28, 2007
Messages
3,480
I followed Moyack's campaign AI tutorial here on the hive and came up with this, though the attacks won't begin, and I would like to know why. I have imported the .ai file and used a trigger that starts it, so I believed there was something up with the code. I'll be thankful for any help, thanks!

JASS:
globals
   
   player MyVictim = Player ( 0 )

endglobals

function setup takes nothing returns nothing
    
    call SetSlowChopping (true)
    call SetPeonsRepair (false)

endfunction

function main takes nothing returns nothing
    
    call CampaignAI( FARM, null )
    call ConfigureAI( )
    
    call SetReplacements( 2, 3, 4 ) //   
    call CampaignDefenderEx( 2, 3, 4, hfoo )
     
    loop
   
    call InitAssaultGroup() // <==(1)  
    call CampaignAttackerEx( 2, 3, 3, Footman )
    call CampaignAttackerEx( 1, 1, 1, n600:nhea )  
    call SuicideOnPlayerEx( M2, M2, M2, MyVictim )
    
    call InitAssaultGroup() // <==(2)  
    call CampaignAttackerEx( 2, 2, 3, n600:nhea )
    call CampaignAttackerEx( 1, 2, 2, Footman ) 
    call SuicideOnPlayerEx( M2, M2, M2, MyVictim )
        
    call InitAssaultGroup() // <==(3)  
    call CampaignAttackerEx( 3, 3, 3, n600:nhea )
    call CampaignAttackerEx( 1, 1, 1, Footman ) 
    call SuicideOnPlayerEx( M2, M2, M2, MyVictim )
        
    call InitAssaultGroup() // <==(4)  
    call CampaignAttackerEx( 4, 4, 4, Footman ) 
    call SuicideOnPlayerEx( M3, M3, M3, MyVictim )
        
    call InitAssaultGroup() // <==(5)  
    call CampaignAttackerEx( 1, 1, 2, n600:nhea )
    call CampaignAttackerEx( 3, 3, 3, Footman ) 
    call SuicideOnPlayerEx( M2, M2, M2, MyVictim )
    
    endloop

endfunction
 
Level 6
Joined
Jan 7, 2007
Messages
247
make loop not infinite? o.0
When i had infinite loop in my map it crushed all triggers with loops. dunno why.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
in a loop, exitwhen <boolean> denotes under what conditions a loop should exit

Eg:

loop
exitwhen i == 5
endloop

would exit when i = 5

So, put it where it should exit, and put in the proper conditions.

Or, if you want it to loop forever but with waits in between, you can use either PolledWait or TriggerSleepAction
 
Level 5
Joined
Oct 27, 2007
Messages
158
I suggest you read a JASS tutorial and get all these answers in one place rather than keep pestering PurplePoot with questions. I suggest Wyrmlord's Beginning JASS Tutorial Series as a good place to start reading.

I don't see this guy pestering anyone. It's in fact others that provide him with info that has nothing to do with the problem. A loop doesn't cause a script to fail or not get executed. In fact loops are often used in campaign AI's to keep the attacks going.

The problem here is caused by undeclared globals or incorrect use of Common.ai globals and wrong use of object codes.

I don't know if it helps you, seeing this was posted some months ago. You need to put rawcodes like hfoo between ''. Like this: 'hfoo'
I have no clue why you used n600:nhea as a raw object code. I assume you ment to include high elf archer in the attack group. You only use 'nhea' in that case. If n600 is a custom unit with that rawcode, then use 'n600'
 
Level 21
Joined
Dec 9, 2007
Messages
3,096
Oh! You make me sick! Oh MY GOD! there is an wrong line!

call InitAssaultGroup() // <==(4)
call CampaignAttackerEx( x_, x_, x_, n600:nhea )
call CampaignAttackerEx( 4, 4, 4, Footman )
call SuicideOnPlayerEx( M3, M3, M3, MyVictim )
call InitAssaultGroup() // <==(5)

X_ = random script number... You make me SICK!
 
Level 21
Joined
Dec 9, 2007
Messages
3,096
call InitAssaultGroup() // <==(4)
_________________________________________________________________
call CampaignAttackerEx( x_, x_, x_, n600:nhea ) - the wrong line!
_________________________________________________________________
call CampaignAttackerEx( 4, 4, 4, Footman )
call SuicideOnPlayerEx( M3, M3, M3, MyVictim )
call InitAssaultGroup() // <==(5)
 
Level 5
Joined
Oct 27, 2007
Messages
158
Oh! You make me sick! Oh MY GOD! there is an wrong line!

call InitAssaultGroup() // <==(4)
call CampaignAttackerEx( x_, x_, x_, n600:nhea )
call CampaignAttackerEx( 4, 4, 4, Footman )
call SuicideOnPlayerEx( M3, M3, M3, MyVictim )
call InitAssaultGroup() // <==(5)

X_ = random script number... You make me SICK!

Sigh...

Sorry, but you have no clue what you're talking about. Setting the same amount for each difficulty has nothing to do with the script not running. Granted it would be better to use SetAssaultGroup if the amount of attackers is the same for each difficulty. But this doesn't cause the script not to run properly.

Like I said the problem lies with incorrect use of variables (Footman) instead of FOOTMAN, or not defining Footman as a global. And also incorrect use of object codes. This is the reason why the script will never be loaded in game and why the main function will never be called.

Try to do your homework a little better before ranting at people will you? Thanks. :wthumbsup:
 
Status
Not open for further replies.
Top