[AI] Custom AI not producing garrison units

Level 7
Joined
Oct 19, 2024
Messages
55
Hello. One of the AIs on one of my maps does no longer build garrison units. Here's the code:

JASS:
//------------------------------------------------
//              GLOBALS
//------------------------------------------------

globals
    player user = Player(0)
    constant integer MOM = 'N00J'
    
endglobals

//------------------------------------------------
//              MAIN
//------------------------------------------------

function main takes nothing returns nothing
    call CampaignAI(PERCH, null)
    call DoCampaignFarms(true)
    
    call SetHeroesFlee(false)
    call SetGroupsFlee(false)
    call SetReplacements(0, 0, 0)
    call SetSlowChopping(true)
    call SetPeonsRepair(true)
    
    call SetBuildUnitEx(2, 2, 2, NEST)
    call SetBuildUnitEx(7, 7, 7, HATCH)
    call SetBuildUnitEx(3, 3, 3, ROOST)
    
    call SetBuildUnitEx(3, 3, 3, ROGUE)
    call SetBuildUnitEx(2, 2, 2, WIND)
    call SetBuildUnitEx(2, 2, 2, HAG)
    
    call SetBuildUnitEx(7, 7, 7, PERCH)
    
    call CampaignDefenderEx(3, 3, 3, ROGUE)
    call CampaignDefenderEx(2, 2, 2, WIND)
    call CampaignDefenderEx(2, 2, 2, HAG)
    call CampaignDefenderEx(1, 1, 1, MOM)
    
    call WaitForSignal()

    // WAVE 1
    
    call InitAssaultGroup()
    call CampaignAttackerEx(2, 3, 4, EXPLORER)
    call CampaignAttackerEx(1, 2, 2, WIND)
    call SuicideOnPlayerEx(240, 240, 240, user)
    
    loop
    
        // WAVE 2
    
        call InitAssaultGroup()
        call CampaignAttackerEx(3, 3, 4, EXPLORER)
        call CampaignAttackerEx(1, 1, 2, ROGUE)
        call CampaignAttackerEx(0, 1, 1, WIND)
        call SuicideOnPlayerEx(360, 360, 360, user)
        
        // WAVE 3
    
        call InitAssaultGroup()
        call CampaignAttackerEx(3, 3, 4, ROGUE)
        call CampaignAttackerEx(2, 2, 2, WIND)
        call SuicideOnPlayerEx(360, 360, 360, user)
        
        // WAVE 4
    
        call InitAssaultGroup()
        call CampaignAttackerEx(3, 3, 4, EXPLORER)
        call CampaignAttackerEx(3, 3, 4, ROGUE)
        call SuicideOnPlayerEx(360, 360, 360, user)       
           
    endloop
endfunction

Now, the map uses custom units. As far as I can tell, the AI has no trouble with those: The attack waves are produced just fine and on time. However, the AI will not train any garrison units. Even in the same map, the other AI's (which also use custom units, but different ones) do train their garrisons properly. This one, however, will train only the attack waves.

All AI's start with plenty of resources and buildings (no units though, I still haven't figured out completlely how guards work).
Does anyone know what could be happening here?

(NOTE: For clarity; "Nest", "Roost" and "Perch" are buildings, with everything else being units (with the "Hatch" being the worker).)
 
As far as the supplies go, they should be good. It starts with less than 10 upkeep, and with the starting buildings alone they can go up to 80 (and of course, it can build more). Also, Iseedeadpeople shows that they don't even bother with garrison at any point: At the bery least, they should train the "Hag", since it is not used in the attack waves.

All of these units are air units. Could that be the issue?
 
I confirm the AI harvest and the like works as intended, yes? Because, I'm not sure if all these PERCH HAG etc are native data or not

Does the total food exceed 100 in your map/campaign?

Can you confirm food not the issue at all by temporary setting to 100 for all productions and use shared vision to observe AI behavior?

I don't think air unit is an issue here.
 
They are not native data, no. They are imported through the campaign import manager, where I have added a modified common.ai with all the corresponding constants.

As for the food consumption, it is not an issue, no. From what I can see with shared vision; they start with maximum food capacity, and they only have 8 upkeep. And yet they train no garrison units, only attack waves.

Edit: Solved. There was a typo with one of the natives. Now it works properly.
 
Last edited:
Back
Top