• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

AI won't get his upgrades

Level 11
Joined
Sep 30, 2017
Messages
169
I'm not the brightest guy when it comes to AI; I have made this script for one of my maps, and it has some issues that I cannot figure out really. First. The AI DOESN'T recognize the blacksmith building at all! I have checked the code and tested the AI on another map, and it works fine. It doesn't use it or use its upgrades for some reason.

I have used AI to help me out a little bit, still the problem is still there.

JASS:
//============================================================================
//  Chapter02 -- Red player -- AI Script
//============================================================================
globals
    player Target = PlayerEx(4) //player 4 Purple
    
    constant integer Peasant = 'h60C'
    constant integer Swordsman = 'h601'
    constant integer Bowman = 'n605'
    constant integer Mage = 'h60X'    
    constant integer Catapult = 'o601'
    constant integer Protector = 'h60Y'
    constant integer Cavalier = 'h602'
    constant integer Sorceress = 'h60Z'
    constant integer Ballista = 'e600'
    constant integer Champion = 'h606'
    constant integer GryphonRider = 'e602'
    
    constant integer Armor_Piercing = 'R605'
    constant integer Great_Bows = 'R603'
    constant integer Iron_Forged_Swords = 'R600'
    constant integer Long_Bows = 'R604'
    constant integer Shieldwall = 'R606'
    constant integer Sorceress_Adept_Training = 'R60P'
    constant integer Scalemail_Armor = 'R601'
    constant integer Ranger_Armorset = 'R602'

endglobals

function main takes nothing returns nothing

    call CampaignAI('h60G',null) //House
    call SetReplacements(1,1,1)
    call GroupTimedLife(true)
    call SetPeonsRepair(true)
    call SetSlowChopping(true)
    set campaign_wood_peons = 2 

    //==================================================
    // Building Strategy
    //==================================================
    
//Building Strategy
    //Tier 1
    call SetBuildUnitEx(7,7,7,Peasant) //Peasant
    call SetBuildUnitEx(1,1,1,'h60F') //Palace
    call SetBuildUnitEx(2,2,2,'h60I') //Barracks
    call SetBuildUnitEx(1,1,1,'h60O') //Watch Tower
    call SetBuildUnitEx(3,3,3,'h60P') //Guard Tower
    call SetBuildUnitEx(1,1,1,'h60H') //Altar
    call SetBuildUnitEx(1,1,1,'h60J') //Saw Mill
    call SetBuildUnitEx(1,1,1,'h60K') //Blacksmith
    call SetBuildUnitEx(14,14,14,'h60G') //House
    
    //Tier 2
    call SetBuildUnitEx(1,1,1,'h60L') //Siege Workshop
    call SetBuildUnitEx(1,1,1,'h60T') //Market
    call SetBuildUnitEx(1,1,1,'h610') //Spellcaster Building
    call SetBuildUnitEx(1,1,1,'h60R') //Arcane Tower
    call SetBuildUnitEx(1,1,1,'h60Q') //Cannon Tower
    
    //Tier 3
    call SetBuildUnitEx(1,1,1,'h60N') //Aivary Tower
    
    
    //Build Units
    call SetBuildUnitEx(9,9,9,Swordsman)   // Wave needs 5, so cap must be at least 5
    call SetBuildUnitEx(6,6,6,Bowman)      // Defenders need 3, Wave 5 needs 3 (Total 6)
    call SetBuildUnitEx(5,5,5,Cavalier)    // Defenders need 2, Wave 5 needs 3 (Total 5)
    call SetBuildUnitEx(4,4,4,Protector)   // Defenders need 2, Wave 3 needs 2 (Total 4)
    call SetBuildUnitEx(4,4,4,Mage)        
    call SetBuildUnitEx(2,2,2,Sorceress)   
    call SetBuildUnitEx(2,2,2,Ballista)    
    call SetBuildUnitEx(2,2,2,Champion)    // Defenders need 1, Wave 2 needs 1 (Total 2)
    call SetBuildUnitEx(5,5,5,GryphonRider)// Defenders need 2, Wave 7 needs 3 (Total 5)

    //Defenders Units
    call CampaignDefenderEx(2,2,2,Protector)  
    call CampaignDefenderEx(2,2,2,Cavalier) 
    call CampaignDefenderEx(3,3,3,Bowman) 
    call CampaignDefenderEx(2,2,2,GryphonRider)
    call CampaignDefenderEx(1,1,1,Champion) 
    
    // Tier 1 Upgrades (Will now process cleanly)
    call SetBuildUpgrEx(1,1,1,Iron_Forged_Swords)
    call SetBuildUpgrEx(1,1,1,Armor_Piercing)
    call SetBuildUpgrEx(1,1,1,Long_Bows)
    call SetBuildUpgrEx(1,1,1,Shieldwall)
    call SetBuildUpgrEx(1,1,1,Great_Bows)
    call SetBuildUpgrEx(1,1,1,Scalemail_Armor)
    call SetBuildUpgrEx(1,1,1,Ranger_Armorset)
    
    call WaitForSignal()

    //==================================================
    // Attack Waves
    //==================================================

    //Wave 1
    call InitAssaultGroup()
    call CampaignAttackerEx(5,5,5,Swordsman)
    call CampaignAttackerEx(2,2,2,Cavalier)
    call SuicideOnPlayerEx(M4,M4,M4,Target)
    
    //Wave 2
    call InitAssaultGroup()
    call CampaignAttackerEx(4,4,4,Swordsman)
    call CampaignAttackerEx(2,2,2,Cavalier)
    call CampaignAttackerEx(1,1,1,Champion)
    call SuicideOnPlayerEx(M4,M4,M4,Target)
    call SetBuildUpgrEx(1,1,1,Sorceress_Adept_Training) 
    
    //Wave 3
    call InitAssaultGroup()
    call CampaignAttackerEx(5,5,5,Swordsman)
    call CampaignAttackerEx(2,2,2,Protector)
    call CampaignAttackerEx(2,2,2,Mage)
    call CampaignAttackerEx(2,2,2,Bowman)
    call SuicideOnPlayerEx(M4,M4,M4,Target)
    
    //==================================================
    // Infinite Waves
    //==================================================
    loop
        //Wave 5
        call InitAssaultGroup()
        call CampaignAttackerEx(4,4,4,Swordsman)
        call CampaignAttackerEx(3,3,3,Bowman)
        call CampaignAttackerEx(3,3,3,Cavalier)
        call CampaignAttackerEx(2,2,2,Protector)
        call SuicideOnPlayerEx(M4,M4,M4,Target)
        
        //Wave 7
        call InitAssaultGroup()
        call CampaignAttackerEx(4,4,4,Swordsman)
        call CampaignAttackerEx(3,3,3,Bowman)
        call CampaignAttackerEx(1,1,1,Champion)
        call CampaignAttackerEx(3,3,3,GryphonRider)
        call SuicideOnPlayerEx(M4,M4,M4,Target)
        
        //Wave 8
        call InitAssaultGroup()
        call CampaignAttackerEx(5,5,5,Swordsman)
        call CampaignAttackerEx(3,3,3,Bowman)
        call CampaignAttackerEx(3,3,3,Cavalier)
        call CampaignAttackerEx(2,2,2,Protector)
        call SuicideOnPlayerEx(M4,M4,M4,Target)
              
    endloop
endfunction
 
I can't see any error within the script itself, does your blacksmith has some tech requirements that could be missing? E.g. the regular human sawmill instead of your custom one

In any case it might be easier to handle the upgrades via trigger, less of a headache and issuing orders to structures doesn't usually causes trouble
 
Back
Top