[AI] Centaur AI not Working

Level 6
Joined
Jul 5, 2021
Messages
11
Hello Hive Workshop, I believe this is my first time trying to ask for help (Sorry if i posted it in the wrong thread, still new to this) But anyways, i have a problem with my Centaur AI Well... not building or training everything... I looked, and looked and found no issues! Even JassDemo said there were No Syntax Errors! So im not entirely sure what the problem is and i thought posting here would be a good idea for the issue im having! Here's the script ^_^

JASS:
//GLOBAL DECELERATION
//------------------------------------------------
globals
    constant integer CENTAUR_RUNNER = 'o008'
    constant integer CENTAUR_DRUDGE = 'n000'
    constant integer CENTAUR_ARCHER = 'n001'
    constant integer CENTAUR_BONGELLER = 'O009'
    constant integer CENTAUR_HALL = 'o00A'
    constant integer CENTAUR_ALTAR = 'oOOB'
    constant integer CENTAUR_BARRACKS = 'o00C'
    constant integer CENTAUR_TENT = 'h003'
    constant integer CENTAUR_FORGE = 'o00D'
    constant integer CENTAUR_TOWER = 'o00E'
    constant integer CENTAUR_BERSERK = 'A005'
    constant integer CENTAUR_SCROLL = 'A006'
    constant integer CENTAUR_CLEAVE = 'A007'
    constant integer CENTAUR_AVATAR = 'A008'
    constant integer CENTAUR_MELEE = 'R003'
    constant integer CENTAUR_RANGED = 'R004'
    constant integer CENTAUR_ARMOR = 'R005'
    player user = PlayerEx(1)
    integer Tier = 1
endglobals
//BUILD PRIORITIES
//------------------------------------------------
function BuildOrder takes nothing returns nothing
    call SetBuildUnit(1, CENTAUR_RUNNER)
    call SetBuildUnitEx(1,1,1, CENTAUR_HALL)
    call SetBuildUnitEx(2,2,2, CENTAUR_BARRACKS)
    call SetBuildUnitEx(3,3,3, CENTAUR_TENT)
    call SetBuildUnitEx(1,1,1, CENTAUR_ALTAR)
    call SetBuildUnit(8, CENTAUR_RUNNER)
    call SetBuildUnitEx(1,1,1, CENTAUR_FORGE)
    call SetBuildUnitEx(3,3,3, CENTAUR_TOWER)
endfunction
//BASE DEFENSE
//------------------------------------------------
function CampaignDefenses takes nothing returns nothing
    if Tier == 1 then
        call CampaignDefenderEx(1,1,1, CENTAUR_BONGELLER)
        call CampaignDefenderEx(6,6,6, CENTAUR_DRUDGE)
        call CampaignDefenderEx(3,3,3, CENTAUR_ARCHER)
    endif
endfunction
//ATTACK WAVE STRATEGY
//------------------------------------------------
function Tier1Waves takes nothing returns nothing
    local integer AttackTier = Tier
    loop
        call SetBuildUpgrEx(1,1,1, CENTAUR_MELEE)
        //WAVE 1
        call InitAssaultGroup()
        call CampaignAttackerEx(3,3,3, CENTAUR_DRUDGE)
        call SuicideOnPlayerEx(M2,M2,M2,user)
        exitwhen AttackTier != Tier
        call SetBuildUpgrEx(1,1,1, CENTAUR_RANGED)
     
        //WAVE 2
        call InitAssaultGroup()
        call CampaignAttackerEx(2,2,2, CENTAUR_ARCHER)
        call SuicideOnPlayerEx(M2,M2,M2,user)
        exitwhen AttackTier != Tier
        loop
            call SetBuildUpgrEx(1,1,1, CENTAUR_ARMOR)
            //WAVE 3
            call InitAssaultGroup()
            call CampaignAttackerEx(4,4,4, CENTAUR_DRUDGE)
            call CampaignAttackerEx(2,2,2, CENTAUR_ARCHER)
            call SuicideOnPlayerEx(M3,M3,M3,user)
            exitwhen AttackTier != Tier
            //WAVE 4
            call InitAssaultGroup()
            call CampaignAttackerEx(1,1,1, CENTAUR_BONGELLER)
            call CampaignAttackerEx(6,6,6, CENTAUR_DRUDGE)
            call CampaignAttackerEx(3,3,3, CENTAUR_ARCHER)
            call SuicideOnPlayerEx(M3,M3,M3,user)
            exitwhen AttackTier != Tier
        endloop
        exitwhen AttackTier != Tier
    endloop
endfunction
function AttackLoop takes nothing returns nothing
    loop
        if Tier == 1 then
            call Tier1Waves()
        else
            call DisplayTextToPlayer(user,0,0,"Something's Not Right")
        endif
    endloop
endfunction
//COMMAND FUNCTIONS
//------------------------------------------------
function TierCondition takes nothing returns nothing
    if CommandsWaiting() > 0 then
        set Tier = GetLastCommand()
        call PopLastCommand()
        call InitBuildArray()
        call InitDefenseGroup()
        call BuildOrder()
        call CampaignDefenses()
    endif
endfunction
function ConditionLoop takes nothing returns nothing
    call TierCondition()
    call StaggerSleep(1,5)
    loop
        call TierCondition()
        call Sleep(5)
    endloop
endfunction
//MAIN FUNCTION
//------------------------------------------------
function ConfigureAI takes nothing returns nothing
    call SetSlowChopping(false)
    call SetPeonsRepair(true)
    call SetUnitsFlee(false)
    call SetHeroesFlee(false)
    call SetGroupsFlee(false)
    call SetHeroesBuyItems(true)
    call SetHeroesTakeItems(true)
    call SetTargetHeroes(false)
endfunction
function hero_levels takes nothing returns integer
    local integer hero = GetHeroId()
    local integer level = GetHeroLevelAI()
    local integer a = 0
    if hero == CENTAUR_BONGELLER then
        if level == 1 or level == 3 or level == 5 then
            set a = CENTAUR_BERSERK
        endif
        if level == 2 or level == 4 or level == 7 then
            set a = CENTAUR_CLEAVE
        endif
        if level >= 8 then
            set a = CENTAUR_SCROLL
        endif
        if level == 6 then
            set a = CENTAUR_AVATAR
        endif
    endif
    return a
endfunction
function main takes nothing returns nothing
    call CampaignAI(CENTAUR_TENT,function hero_levels)
    call DoCampaignFarms(false)
    call ConfigureAI()
    call BuildOrder()
    call CampaignDefenses()
    call StartThread(function ConditionLoop)
    call AttackLoop()
endfunction

If anyone knows the issue or attempts to figure it out then i'll gladly appreciate it. Have a good day! (What i meant by the Centaur AI not building anything, it doesn't train all the drudges and archers or runners and only trains 3 drudges or more for each attack wave. Doesn't build all the Structures and only 2 barracks and 3 Tents, with 1 Hall of Drudges at the beginning with 5 Runners, and uh maybe you can see the Map i made with the Script? Sense maybe you can see for yourself? and it will need Classic Graphics at the version of 1.32.10)


SOLVED: I just had to Rewrite the Code, sorry for wasting all of your guys time if you were trying to figure it out. Sorry!
 

Attachments

  • Tauren VS Centaur.w3m
    1.3 MB · Views: 22
Last edited:
Top