HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

campaign AI problem

12-17-2008, 02:48 PM#1
imarafan
sorry if this is the wrong section.... also sorry for may bad english

anyway.... i'm new with this JASS thing (and world editor in general, started yesterday )

and i tried to make a campaing AI (thanks to moyack and his/her tutorial ) but i can't get it to work :(

here is the script:

Collapse JASS:
//******************************************************************************
//*                           Blood Elf Campaign AI                            *
//*        By Moyack (is just a cpoy paste... so i give credit)        *
//******************************************************************************
//*
globals
    player MyVictim = Player( 0 )
endglobals

function ConfigureAI takes nothing returns nothing
    call SetSlowChopping( false )
    call SetPeonsRepair( true )
endfunction

function main takes nothing returns nothing
    call CampaignAI( ELF_FARM, null )
    call ConfigureAI( )
    // **********************************
    // *      Building Strategy         *
    // **********************************
    //
    // Tier 1 Buildings
    call SetReplacements( 1, 2, 3 )
    call SetBuildUnitEx( 1, 1, 1, 'h001' )
    call SetBuildUnit( 15, BLOOD_PEASANT )
    call SetBuildUnitEx( 1, 2, 3, ELF_FARM )
    call SetBuildUnitEx( 1, 2, 2, 'h005' )
    call SetBuildUnit( 1, 'h004' )
    call SetBuildUnit( 1, 'h006' )
    call SetBuildUnit( 1, 'h00F' )
    call CampaignDefenderEx( 2, 2, 3, 'n000' ) 
    call CampaignDefenderEx( 1, 1, 1, 'h000' )
    call SetBuildUnitEx( 1, 2, 3, 'n000' )
    // Tier 2 buildings
    call SetBuildUnit( 1, 'h002' )
    call SetBuildUnitEx( 1, 2, 2, 'h008' )
    call SetBuildUnit( 1, 'h00C' )
    // Tier 3 buildings
    call SetBuildUnit( 1, 'h003' )
    call SetBuildUnitEx( 0, 1, 1, 'h007' )
    // **********************************
    // *    End Building Strategy       *
    // **********************************
    // **********************************
    // *       Attack Strategy          *
    // **********************************
    //*** WAVE 1 *** AI will begin to attack in 5 minutes
    call InitAssaultGroup()
    call CampaignAttackerEx( 2, 3, 3, 'n000' )
    call CampaignAttackerEx( 0, 1, 2, 'h000' )  
    call SuicideOnPlayerEx( M5, M5, M5, MyVictim )
    //*** Basic upgrades from HUNTERS HALL ***
    call SetBuildUpgrEx( 1, 2, 3, 'R00A' )
    call SetBuildUpgrEx( 1, 2, 3, 'R009' )
    call SetBuildUpgrEx( 1, 2, 3, 'R001' )
    call SetBuildUpgrEx( 1, 2, 3, 'R007' )
    //*** WAVE 2 *** Between 2 or 3 minutes after Wave 1
    call InitAssaultGroup()
    call CampaignAttackerEx( 3, 4, 4, 'n000' )
    call CampaignAttackerEx( 1, 2, 3, 'h000' )  
    call SuicideOnPlayerEx( M3, M2, M2, MyVictim )
    //*** WAVE 3 *** Between 2 or 3 minutes after Wave 2
    call InitAssaultGroup()
    call CampaignAttackerEx( 3, 4, 4, 'n000' )
    call CampaignAttackerEx( 1, 2, 3, 'h000' )
    call CampaignAttackerEx( 1, 1, 1, 'H00B' )
    call SuicideOnPlayerEx( M3, M2, M2, MyVictim )
    //*** WAVE 4 *** Between 2 or 3 minutes after Wave 3
    call InitAssaultGroup()
    call CampaignAttackerEx( 3, 4, 4, 'n000' )
    call CampaignAttackerEx( 1, 2, 3, 'h000' )
    call CampaignAttackerEx( 0, 1, 1, 'e000' )
    call CampaignAttackerEx( 1, 1, 1, 'H00B' )
    call SuicideOnPlayerEx( M3, M2, M2, MyVictim )
    //*** Dryad Upgrade
    call SetBuildUpgrEx( 1, 1, 1, R000 )
    //*** WAVE 5 *** Between 3 or 4 minutes after Wave 4
    call InitAssaultGroup()
    call CampaignAttackerEx( 3, 3, 3, 'n000' )
    call CampaignAttackerEx( 2, 2, 2, 'h000' )
    call CampaignAttackerEx( 1, 1, 1, 'H00B' )
    call CampaignAttackerEx( 0, 1, 2, 'h00J' )
    call SuicideOnPlayerEx( M4, M3, M3, MyVictim )
    //*** Druid of the Claw Upgrade
    call SetBuildUpgrEx( 0, 1, 2, 'R00D' )
    call SetBuildUpgrEx( 0, 1, 2, 'R00E' )    
    //*** WAVE 6 *** Between 3 or 4 minutes after Wave 5
    call InitAssaultGroup()
    call CampaignAttackerEx( 2, 2, 2, 'h000' )
    call CampaignAttackerEx( 1, 1, 1, 'H00B' )
    call CampaignAttackerEx( 1, 1, 2, 'e000' )
    call CampaignAttackerEx( 1, 2, 3, 'h00J' )
    call CampaignAttackerEx( 0, 1, 2, 'h00G' )
    call SuicideOnPlayerEx( M4, M3, M3, MyVictim )
    //*** chimaera Upgrade
    call SetBuildUpgrEx( 0, 0, 1, 'R00F:Rhan' )
    loop //Init the infinite attack loop
    //*** WAVE 7 *** Between 3 or 5 minutes after Wave 6
        call InitAssaultGroup()
        call CampaignAttackerEx( 2, 2, 2, 'h000' )
        call CampaignAttackerEx( 1, 1, 1, 'H00B' )
        call CampaignAttackerEx( 1, 1, 2, 'e000' )
        call CampaignAttackerEx( 1, 2, 3, 'h00J' )
        call CampaignAttackerEx( 0, 1, 2, 'h00G' )
        call CampaignAttackerEx( 0, 1, 2, 'n004' )
        call SuicideOnPlayerEx( M5, M4, M3, MyVictim )
        //*** WAVE 8 *** Between 3 or 5 minutes after Wave 7
        call InitAssaultGroup()
        call CampaignAttackerEx( 2, 2, 2, 'h000' )
        call CampaignAttackerEx( 1, 1, 1, 'H00B' )
        call CampaignAttackerEx( 1, 1, 2, 'e000' )
        call CampaignAttackerEx( 1, 2, 3, 'h00J' )
        call CampaignAttackerEx( 0, 1, 2, 'h00G' )
        call SuicideOnPlayerEx( M5, M4, M3, MyVictim )
        //*** WAVE 9 *** Between 4 or 6 minutes after Wave 8
        call InitAssaultGroup()
        call CampaignAttackerEx( 2, 2, 2, 'h000' )
        call CampaignAttackerEx( 1, 1, 1, 'H00B' )
        call CampaignAttackerEx( 1, 1, 2, 'e000' )
        call CampaignAttackerEx( 1, 2, 3, 'h00J' )
        call CampaignAttackerEx( 0, 1, 2, 'h00G' )
        call CampaignAttackerEx( 0, 1, 2, 'n004' )
        call CampaignAttackerEx( 1, 1, 2, 'h00H' )
        call CampaignAttackerEx( 0, 1, 2, 'h00K' ) 
        call SuicideOnPlayerEx( M6, M5, M4, MyVictim )
    endloop
    // **********************************
    // *   Attack Strategy never ends   *
    // **********************************
endfunction

as you can see this is just a copy paste of the nightelf script made by moyack for the tutorial

also you can see i'm trying to make a blood elf AI with a lot of custom units

but i can't get it to work....

- i tried tanking out the '
- i tried renaming ELF_FARM and BLOOD_PEASANT to their raw code names
- i also tried with another script

i don't know if i'm screwing with the script... or if i fail importing the script to the map

as i said before, i'm new with all this world edit thing (a real noob, not just a JASS noob) :(

so i would like to know if you could help me

thanks for your time
12-17-2008, 10:45 PM#2
Captain Griffen
Keywords: vJASS, campaign.

Search. Now. If you still don't know, search more.
12-17-2008, 11:13 PM#3
moyack
Names are only if you have defined its value, so just set the rawcodes of your units.

Questions: Have you set the AI file to the right computer player?

Why it fails?? what are the workers doing when you test the map?

Hmm, I found an error:

Collapse Check the red line...:
function main takes nothing returns nothing
    call CampaignAI( ELF_FARM, null )
    call ConfigureAI( )
    // **********************************
    // *      Building Strategy         *
    // **********************************
    //
    // Tier 1 Buildings
    call SetReplacements( 1, 2, 3 )
    call SetBuildUnitEx( 1, 1, 1, 'h001' )
    call SetBuildUnit( 15, BLOOD_PEASANT ) //Set the rawcode...
    call SetBuildUnitEx( 1, 2, 3, ELF_FARM ) //Set the rawcode...
    call SetBuildUnitEx( 1, 2, 2, 'h005' )
    call SetBuildUnit( 1, 'h004' )
    call SetBuildUnit( 1, 'h006' )
    call SetBuildUnit( 1, 'h00F' )
    call CampaignDefenderEx( 2, 2, 3, 'n000' ) 
    call CampaignDefenderEx( 1, 1, 1, 'h000' )
    call SetBuildUnitEx( 1, 2, 3, 'n000' )
    // Tier 2 buildings
    call SetBuildUnit( 1, 'h002' )
    call SetBuildUnitEx( 1, 2, 2, 'h008' )
    call SetBuildUnit( 1, 'h00C' )
    // Tier 3 buildings
    call SetBuildUnit( 1, 'h003' )
    call SetBuildUnitEx( 0, 1, 1, 'h007' )
    // **********************************
    // *    End Building Strategy       *
    // **********************************
    // **********************************
    // *       Attack Strategy          *
    // **********************************
    //*** WAVE 1 *** AI will begin to attack in 5 minutes
    call InitAssaultGroup()
    call CampaignAttackerEx( 2, 3, 3, 'n000' )
    call CampaignAttackerEx( 0, 1, 2, 'h000' )  
    call SuicideOnPlayerEx( M5, M5, M5, MyVictim )
    //*** Basic upgrades from HUNTERS HALL ***
    call SetBuildUpgrEx( 1, 2, 3, 'R00A' )
    call SetBuildUpgrEx( 1, 2, 3, 'R009' )
    call SetBuildUpgrEx( 1, 2, 3, 'R001' )
    call SetBuildUpgrEx( 1, 2, 3, 'R007' )
    //*** WAVE 2 *** Between 2 or 3 minutes after Wave 1
    call InitAssaultGroup()
    call CampaignAttackerEx( 3, 4, 4, 'n000' )
    call CampaignAttackerEx( 1, 2, 3, 'h000' )  
    call SuicideOnPlayerEx( M3, M2, M2, MyVictim )
    //*** WAVE 3 *** Between 2 or 3 minutes after Wave 2
    call InitAssaultGroup()
    call CampaignAttackerEx( 3, 4, 4, 'n000' )
    call CampaignAttackerEx( 1, 2, 3, 'h000' )
    call CampaignAttackerEx( 1, 1, 1, 'H00B' )
    call SuicideOnPlayerEx( M3, M2, M2, MyVictim )
    //*** WAVE 4 *** Between 2 or 3 minutes after Wave 3
    call InitAssaultGroup()
    call CampaignAttackerEx( 3, 4, 4, 'n000' )
    call CampaignAttackerEx( 1, 2, 3, 'h000' )
    call CampaignAttackerEx( 0, 1, 1, 'e000' )
    call CampaignAttackerEx( 1, 1, 1, 'H00B' )
    call SuicideOnPlayerEx( M3, M2, M2, MyVictim )
    //*** Dryad Upgrade
    call SetBuildUpgrEx( 1, 1, 1, R000 )
    //*** WAVE 5 *** Between 3 or 4 minutes after Wave 4
    call InitAssaultGroup()
    call CampaignAttackerEx( 3, 3, 3, 'n000' )
    call CampaignAttackerEx( 2, 2, 2, 'h000' )
    call CampaignAttackerEx( 1, 1, 1, 'H00B' )
    call CampaignAttackerEx( 0, 1, 2, 'h00J' )
    call SuicideOnPlayerEx( M4, M3, M3, MyVictim )
    //*** Druid of the Claw Upgrade
    call SetBuildUpgrEx( 0, 1, 2, 'R00D' )
    call SetBuildUpgrEx( 0, 1, 2, 'R00E' )    
    //*** WAVE 6 *** Between 3 or 4 minutes after Wave 5
    call InitAssaultGroup()
    call CampaignAttackerEx( 2, 2, 2, 'h000' )
    call CampaignAttackerEx( 1, 1, 1, 'H00B' )
    call CampaignAttackerEx( 1, 1, 2, 'e000' )
    call CampaignAttackerEx( 1, 2, 3, 'h00J' )
    call CampaignAttackerEx( 0, 1, 2, 'h00G' )
    call SuicideOnPlayerEx( M4, M3, M3, MyVictim )
    //*** chimaera Upgrade
    call SetBuildUpgrEx( 0, 0, 1, 'R00F:Rhan' ) //It should be 'R00F'...
    loop //Init the infinite attack loop
    //*** WAVE 7 *** Between 3 or 5 minutes after Wave 6
        call InitAssaultGroup()
        call CampaignAttackerEx( 2, 2, 2, 'h000' )
        call CampaignAttackerEx( 1, 1, 1, 'H00B' )
        call CampaignAttackerEx( 1, 1, 2, 'e000' )
        call CampaignAttackerEx( 1, 2, 3, 'h00J' )
        call CampaignAttackerEx( 0, 1, 2, 'h00G' )
        call CampaignAttackerEx( 0, 1, 2, 'n004' )
        call SuicideOnPlayerEx( M5, M4, M3, MyVictim )
        //*** WAVE 8 *** Between 3 or 5 minutes after Wave 7
        call InitAssaultGroup()
        call CampaignAttackerEx( 2, 2, 2, 'h000' )
        call CampaignAttackerEx( 1, 1, 1, 'H00B' )
        call CampaignAttackerEx( 1, 1, 2, 'e000' )
        call CampaignAttackerEx( 1, 2, 3, 'h00J' )
        call CampaignAttackerEx( 0, 1, 2, 'h00G' )
        call SuicideOnPlayerEx( M5, M4, M3, MyVictim )
        //*** WAVE 9 *** Between 4 or 6 minutes after Wave 8
        call InitAssaultGroup()
        call CampaignAttackerEx( 2, 2, 2, 'h000' )
        call CampaignAttackerEx( 1, 1, 1, 'H00B' )
        call CampaignAttackerEx( 1, 1, 2, 'e000' )
        call CampaignAttackerEx( 1, 2, 3, 'h00J' )
        call CampaignAttackerEx( 0, 1, 2, 'h00G' )
        call CampaignAttackerEx( 0, 1, 2, 'n004' )
        call CampaignAttackerEx( 1, 1, 2, 'h00H' )
        call CampaignAttackerEx( 0, 1, 2, 'h00K' ) 
        call SuicideOnPlayerEx( M6, M5, M4, MyVictim )
    endloop
    // **********************************
    // *   Attack Strategy never ends   *
    // **********************************
endfunction