AI trouble.

Evan1993

Ultra Cool Member
Reaction score
30
When I use Jasscraft's syntax checker it says tons of:
Unrecognized character
syntax error
Undeclared variable
This is my first time making AI, what am I doing wrong? :confused:
Code:
//==================================================================================================
//  Robo warz AI ver 0.03a
//==================================================================================================
globals
//units
integer workerbots
integer worker_done
integer spawns
integer gunbots
integer heavybots
integer meleebots
integer shadowbots
integer eyes
integer sniperbots
integer artillerytanks
integer rocketBots
integer slicerbots
integer stomperbots
integer battletanks
integer pyrocopters
integer seekerdrones
integer seekerdrone_done
integer annihilators
integer demolisherbots
integer demolisherbot_done
//buildings
integer mainfactory_done
integer advancedmainfactory_done 
integer ubermainfactory_done
integer cybermainfactory_done
integer powermainfactory_done
integer powersupplys
integer powersupply_done
integer assemblyplants
integer assemblyplant_done
integer battlefactorys
integer battlefactory_done
integer techlabs
integer techlab_done
integer apocalypsefactorys
integer apocalypsefactory_done
integer sensors
integer sensor_done
integer airspires
integer airspire_done
integer towers
integer tower_done
integer towert2
integer towert2_done
integer towert3
integer towert3_done
integer towert4
integer towert4_done
integer towert5
integer towert5_done
integer buildings = mainfactory_done + advancedmainfactory_done + ubermainfactory_done + cybermainfactory_done + powermainfactory_done + powersupplys + assemblyplants + battlefactorys + techlabs + apocalypsefactorys + sensors + airspires + towers + towert3 + towert4 + towert5
//Heroes
integer c_hero1_done        = 0
integer c_hero2_done        = 0
integer c_hero3_done        = 0
//Resources
integer c_gold
integer c_gold_owned
integer c_food_made
integer c_food_used
endglobals

//Update vars
function update_vars takes nothing returns nothing

//Update units
set workerbots                = GetUnitCount('uaco')
set worker_done               = GetUnitCountDone('uaco')
set spawns                    = gunbots + heavybots + meleebots + shadowbots
set gunbots                   = GetUnitCount('h002:hfoo')
set heavybots                 = GetUnitCount('h000:hfoo')
set meleebots                 = GetUnitCount('h001:hfoo')
set shadowbots                = GetUnitCount('h003:hfoo')
set eyes                      = GetUnitCount('h00U:hfoo')
set sniperbots                = GetUnitCount('h00I:hfoo')
set artillerytanks            = GetUnitCount('h008:hfoo')
set rocketBots                = GetUnitCount('h00M:hfoo')
set slicerbots                = GetUnitCount('h00P:hfoo')
set stomperbots               = GetUnitCount('h00J:hfoo')
set battletanks               = GetUnitCount('h00G:hfoo')
set pyrocopters               = GetUnitCount('hstp')
set seekerdrones              = GetUnitCount('ugar')
set seekerdrone_done          = GetUnitCountDone('ugar')
set annihilators              = GetUnitCount('U000:uaco')
set demolisherbots            = GetUnitCount('U000:uaco')
set demolisherbot_done        = GetUnitCountDone('U000:uaco')
//Update buildings
set mainfactory_done          = GetUnitCountDone('htow')
set advancedmainfactory_done  = GetUnitCountDone('hkee')
set ubermainfactory_done      = GetUnitCountDone('hcas')
set cybermainfactory_done     = GetUnitCountDone('h00D:hcas')
set powermainfactory_done     = GetUnitCountDone('h00C:hcas')
set powersupplys              = GetUnitCount('hhou')
set powersupply_done          = GetUnitCountDone('hhou')
set assemblyplants            = GetUnitCount('halt')
set assemblyplant_done        = GetUnitCountDone('halt')
set battlefactorys            = GetUnitCount('hbar')
set battlefactory_done        = GetUnitCountDone('hbar')
set techlabs                  = GetUnitCount('hlum')
set techlab_done              = GetUnitCountDone('hlum')
set apocalypsefactorys        = GetUnitCount('hgra')
set apocalypsefactory_done    = GetUnitCountDone('hgra')
set sensors                   = GetUnitCount('hwtw')
set sensor_done               = GetUnitCountDone('hwtw')
set airspires                 = GetUnitCount('hvlt')
set airspire_done             = GetUnitCountDone('hwtw')
set towers                    = GetUnitCount('nft1')
set tower_done                = GetUnitCountDone('nft1')
set towert2                   = GetUnitCount('nft2')
set towert2_done              = GetUnitCountDone('nft1')
set towert3                   = GetUnitCount('net1')
set towert3_done              = GetUnitCountDone('net1')
set towert4                   = GetUnitCount('ntt1')
set towert4_done              = GetUnitCountDone('ntt1')
set towert5                   = GetUnitCount('ndt1')
set towert5_done              = GetUnitCountDone('ntd1')
//Update Resources              
set c_gold                    = GetGold()
set c_gold_owned              = GetGoldOwned()
set c_food_made               = GetFoodMade('htow') + powersupplys * GetFoodMade('hhou')
set c_food_used               = FoodUsed()
endfunction
//--------------------------------------------------------------------------------------------------
//  attack_sequence
//--------------------------------------------------------------------------------------------------
function attack_sequence takes nothing returns nothing
    local boolean needs_exp
    local boolean has_siege
    local boolean air_units
    local integer level

    loop
        exitwhen c_hero1_done > 0 and spawns >= 4
        call Sleep(2)
    endloop

    if MeleeDifficulty() == MELEE_NEWBIE then
        call Sleep(240)
    endif

    call StaggerSleep(0,2)
    loop
        loop
            exitwhen not CaptainRetreating()
            call Sleep(2)
        endloop

        set wave = wave + 1
        if wave = 2 then
            loop
                exitwhen spawns >= 8 
                call Sleep(2)
            endloop
        endif

        call setup_force()

        set level = force_level()
        set needs_exp = false
        set has_siege        = level >= 40 or heavybots > 0 or demolisherbot_done > 0 or pyrocopters > 0
        set air_units        = seekerdrone_done > 0 or pyrocopters > 0

        call SingleMeleeAttack(needs_exp,has_siege,false,air_units)

        if MeleeDifficulty() == MELEE_NEWBIE then
            call Sleep(60)
        endif
    endloop
endfunction
//--------------------------------------------------------------------------------------------------
//  set_vars
//--------------------------------------------------------------------------------------------------
function set_vars takes nothing returns nothing
    loop
        call init_vars()
        call Sleep(1)
    endloop
endfunction
//--------------------------------------------------------------------------------------------------
//  do_upgrades
//--------------------------------------------------------------------------------------------------
function do_upgrades takes nothing returns nothing

    if mainfactory_done >= 1 and techlab_done >= 1 then
        call SetBuildUpgr( 1, 'Rhan' )
        call SetBuildUpgr( 1, 'Rhme' )
        call SetBuildUpgr( 1, 'Rhar' )
        call SetBuildUpgr( 1, 'Rhra' )
        call SetBuildUpgr( 1, 'Rhac' )      
    endif
     if advancedmainfactory_done >= 1 and techlab_done >= 1 then
        call SetBuildUpgr( 1, 'Rhan' )
        call SetBuildUpgr( 1, 'Rhme' )
        call SetBuildUpgr( 1, 'Rhar' )
        call SetBuildUpgr( 1, 'Rhra' )
        call SetBuildUpgr( 1, 'Rhde' )
        call SetBuildUpgr( 1, 'Rhac' )      
    endif
 if ubermainfactory_done >= 1 and techlab_done >= 1 then
        call SetBuildUpgr( 1, 'Rhan' )
        call SetBuildUpgr( 1, 'Rhme' )
        call SetBuildUpgr( 1, 'Rhar' )
        call SetBuildUpgr( 1, 'Rhra' )
        call SetBuildUpgr( 1, 'Rhde' )
        call SetBuildUpgr( 1, 'Rhpt' )
        call SetBuildUpgr( 1, 'Rhac' )          
    endif
     if cybermainfactory_done >= 1 and techlab_done >= 1 then
        call SetBuildUpgr( 1, 'Rhan' )
        call SetBuildUpgr( 1, 'Rhme' ) //Attack
        call SetBuildUpgr( 1, 'Rhar' ) //armor
        call SetBuildUpgr( 1, 'Rhra' ) //HP
        call SetBuildUpgr( 1, 'Rhde' )
        call SetBuildUpgr( 1, 'Rhpt' )
        call SetBuildUpgr( 1, 'Rhrt' )          
    endif
     if powermainfactory_done >= 1 and techlab_done >= 1 then
        call SetBuildUpgr( 1, 'Rhan' )
        call SetBuildUpgr( 1, 'Rhme' )
        call SetBuildUpgr( 1, 'Rhar' )
        call SetBuildUpgr( 1, 'Rhra' )
        call SetBuildUpgr( 1, 'Rhde' )
        call SetBuildUpgr( 1, 'Rhpt' )
        call SetBuildUpgr( 1, 'Rhac' ) 
        call SetBuildUpgr( 1, 'Rhhl' )
        call SetBuildUpgr( 1, 'Rhhl' )
        call SetBuildUpgr( 1, 'Rhhb' )             
    endif      
    if GetUpgradeLevel('Rhme') >= 20 and GetUpgradeLevel('Rhar') >= 20 and GetUpgradeLevel('Rhra') >= 20 then
    call SetBuildUpgr( 1, 'Rhla' )  
    endif
    if  sniperbots >= 1 or  artillerytanks >= 1 then 
     call SetBuildUpgr( 1, 'Rhfc' )
     endif  
    endif
endfunction
//--------------------------------------------------------------------------------------------------
//  build_sequence
//--------------------------------------------------------------------------------------------------
function build_sequence takes nothing returns nothing
    local boolean primary_melee
    local integer wisps

    call InitBuildArray()
    //Starting buildings
    
    if basic_opening then
        call SetBuildUnit(  1, 'htow'           )
        call SetBuildUnit(  1, 'hlum'           )
        call SetBuildUnit(  1, 'halt'           )
        call SetBuildUnit(  1, 'hhou'           )
        call SetBuildUnit(  1, hero_id          )
        call do_upgrades 
        return
    endif
    
    // Food
    if c_food_used + 7 > c_food_made then
        call SetBuildUnit( powersupply_done + 1, 'hhou' )
    endif
   // ReviveHeroes
   if battlefactory_done >= 1 or mainfactory_done >=1 or  advancedmainfactory_done >= 1 or ubermainfactory_done >= 1 or cybermainfactory_done >= 1 or powermainfactory_done >= 1  then

        if b_hero1_done and MeleeDifficulty() != MELEE_NEWBIE then
            call SetBuildUnit( 1, hero_id2 )
        else
            call SetBuildUnit( 1, hero_id  )
        endif
    else
        call SetBuildUnit( 1, 'hlum' )
    endif

  
    //if we have enough gold then advance on the tech tree
    if c_gold > 1000 then  
    //First try to teir up.
        call SetBuildUnit(  1, 'hkee'           )  
        call SetBuildUnit(  1, 'hcas'           ) 
        call SetBuildUnit(  1, 'h00D:hcas'      )  
        call SetBuildUnit(  1, 'h00C:hcas'      )
        // next upgrade
        call do_upgrades()
        // and if you still have gold get buildings and mercs
        if  powermainfactory_done >= 1 then
        if apocalypsefactorys = 0 then call SetBuildUnit(  1, 'hgra'          )
        call SetBuildUnit(  1, 'h00H:hfoo'     )
        call SetBuildUnit(  1, 'h00M:hfoo'     )
        call SetBuildUnit(  1, 'hspt'          )
        call SetBuildUnit(  1, 'ugar'          )
        elseif  cybermainfactory_done >= 1 then
        if airspires = 0 then call SetBuildUnit(1, 'hvlt')
        call SetBuildUnit(  1, 'h00G:hfoo'     )
        call SetBuildUnit(  1, 'h00J:hfoo'     )
        call SetBuildUnit(  1, 'h00P:hfoo'     )
        call SetBuildUnit(  1, 'ugar'          ) 
        elseif ubermainfactory_done >= 1 then
        call SetBuildUnit(  1, 'h008:hfoo'     )
        call SetBuildUnit(  1, 'h00I:hfoo'     )
        elseif advancedmainfactory_done >= 1 then
        if battlefactorys = 0 then call SetBuildUnit(  1, 'hbar'          )
        call SetBuildUnit(  2, 'h00N:hfoo'     )
        call SetBuildUnit(  1, 'h00U:hfoo'     )
  else
        call SetBuildUnit(  1, 'nft1'          )
        if towers >= 1 then
         call SetBuildUnit(  1, 'nft2'         )
         elseif towerst1 >= 1 then
          call SetBuildUnit(  1, 'net1'        )
          elseif towerst2 >= 1 then
           call SetBuildUnit(  1, 'ntt1'       )
           elseif  towerst3 >= 1 then
            call SetBuildUnit(  1, 'ntd1'      )
            endif
            
            if assemblyplants = 0 then  call SetBuildUnit(1, 'halt')
            if battlefactorys = 0 then  call SetBuildUnit(1, 'hbar')
            if techlabs = 0 then  call SetBuildUnit(1, 'hlum')
            if sensors = 0 then  call SetBuildUnit(1, 'hwtw')
            if airspires = 0 then  call SetBuildUnit(1, 'hvlt')
            if workerbots = 0 then  call SetBuildUnit(1, 'uaco')
            call do_upgrades
            
        call SetBuildUnit(  1, 'otau'     )
        call SetBuildUnit(  1, 'ohun'     )
        call SetBuildUnit(  1, 'owyv'     )
        call SetBuildUpgr(  1, 'Rhss'     )
        call SetBuildUpgr(  1, 'Rhcd'     ) 
    endif
    
endfunction
//--------------------------------------------------------------------------------------------------
//	main
//--------------------------------------------------------------------------------------------------
function main takes nothing returns nothing
    call PickMeleeHero(RACE_NIGHTELF)
    call set_skills()
    call StandardAI(function SkillArrays, function peon_assignment, function attack_sequence)
    call StartThread(function set_vars)
    call PlayGame()
endfunction
 
N

no0by

Guest
From what I can see you are referencing the rawcodes incorrectly

Code:
set gunbots                   = GetUnitCount('h002:hfoo')
set heavybots                 = GetUnitCount('h000:hfoo')
set meleebots                 = GetUnitCount('h001:hfoo')
set shadowbots                = GetUnitCount('h003:hfoo')
set eyes                      = GetUnitCount('h00U:hfoo')
set sniperbots                = GetUnitCount('h00I:hfoo')
set artillerytanks            = GetUnitCount('h008:hfoo')
set rocketBots                = GetUnitCount('h00M:hfoo')
set slicerbots                = GetUnitCount('h00P:hfoo')
set stomperbots               = GetUnitCount('h00J:hfoo')
set battletanks               = GetUnitCount('h00G:hfoo')

set annihilators              = GetUnitCount('U000:uaco')
set demolisherbots            = GetUnitCount('U000:uaco')
set demolisherbot_done        = GetUnitCountDone('U000:uaco')

set cybermainfactory_done     = GetUnitCountDone('h00D:hcas')
set powermainfactory_done     = GetUnitCountDone('h00C:hcas')
Should be:
Code:
set gunbots                   = GetUnitCount('h002')
set heavybots                 = GetUnitCount('h000')
set meleebots                 = GetUnitCount('h001')
set shadowbots                = GetUnitCount('h003')
set eyes                      = GetUnitCount('h00U')
set sniperbots                = GetUnitCount('h00I')
set artillerytanks            = GetUnitCount('h008')
set rocketBots                = GetUnitCount('h00M')
set slicerbots                = GetUnitCount('h00P')
set stomperbots               = GetUnitCount('h00J')
set battletanks               = GetUnitCount('h00G')

set annihilators              = GetUnitCount('U000')
set demolisherbots            = GetUnitCount('U000')
set demolisherbot_done        = GetUnitCountDone('U000')

set cybermainfactory_done     = GetUnitCountDone('h00D')
set powermainfactory_done     = GetUnitCountDone('h00C')

The part after the ':' is to show what it is based off e.g. 'h002:hfoo' is based off the footman 'hfoo' with the rawcode 'h002'

Just fix them and it should work (function update_vars And function build_sequence Need fixing)
 

Evan1993

Ultra Cool Member
Reaction score
30
Thanks, I having some new problems now tho. Bolded 'em.
Code:
//==================================================================================================
//  Robo warz AI ver 0.03b
//==================================================================================================
globals 
boolean basic_opening             = true
integer wave
//units
integer workerbots                = 0
integer worker_done               = 0
integer spawns                    = 0
integer gunbots                   = 0
integer heavybots                 = 0
integer meleebots                 = 0
integer shadowbots                = 0
integer eyes                      = 0
integer sniperbots                = 0
integer artillerytanks            = 0
integer rocketBots                = 0
integer slicerbots                = 0
integer stomperbots               = 0
integer battletanks               = 0
integer pyrocopters               = 0
integer seekerdrones              = 0
integer seekerdrone_done          = 0
integer annihilators              = 0
integer demolisherbots            = 0
integer demolisherbot_done        = 0
//buildings
integer mainfactory_done          = 0
integer advancedmainfactory_done  = 0
integer ubermainfactory_done      = 0
integer cybermainfactory_done     = 0
integer powermainfactory_done     = 0
integer powersupplys              = 0
integer powersupply_done          = 0
integer assemblyplants            = 0
integer assemblyplant_done        = 0
integer battlefactorys            = 0
integer battlefactory_done        = 0
integer techlabs                  = 0
integer techlab_done              = 0
integer apocalypsefactorys        = 0
integer apocalypsefactory_done    = 0
integer sensors                   = 0
integer sensor_done               = 0
integer airspires                 = 0
integer airspire_done             = 0
integer towers                    = 0
integer tower_done                = 0
integer towert2                   = 0
integer towert2_done              = 0
integer towert3                   = 0
integer towert3_done              = 0
integer towert4                   = 0
integer towert4_done              = 0
integer towert5                   = 0
integer towert5_done              = 0
integer buildings                 = 0
//Heroes
integer c_hero1_done              = 0
integer c_hero2_done              = 0
integer c_hero3_done              = 0
//Resources                       
integer c_gold                    = 0
integer c_gold_owned              = 0
integer c_food_made               = 0
integer c_food_used               = 0
endglobals
                                        
//Update vars
function update_vars takes nothing returns nothing

//Update units
set workerbots                = GetUnitCount('uaco')
set worker_done               = GetUnitCountDone('uaco')
set gunbots                   = GetUnitCount('h002')
set heavybots                 = GetUnitCount('h000')
set meleebots                 = GetUnitCount('h001')
set shadowbots                = GetUnitCount('h003')
set spawns                    = gunbots + heavybots + meleebots + shadowbots
set eyes                      = GetUnitCount('h00U')
set sniperbots                = GetUnitCount('h00I')
set artillerytanks            = GetUnitCount('h008')
set rocketBots                = GetUnitCount('h00M')
set slicerbots                = GetUnitCount('h00P')
set stomperbots               = GetUnitCount('h00J')
set battletanks               = GetUnitCount('h00G')
set pyrocopters               = GetUnitCount('hstp')
set seekerdrones              = GetUnitCount('ugar')
set seekerdrone_done          = GetUnitCountDone('ugar')
set annihilators              = GetUnitCount('U000')
set demolisherbots            = GetUnitCount('U000')
set demolisherbot_done        = GetUnitCountDone('U000')
//Update buildings
set mainfactory_done          = GetUnitCountDone('htow')
set advancedmainfactory_done  = GetUnitCountDone('hkee')
set ubermainfactory_done      = GetUnitCountDone('hcas')
set cybermainfactory_done     = GetUnitCountDone('h00D')
set powermainfactory_done     = GetUnitCountDone('h00C')
set powersupplys              = GetUnitCount('hhou')
set powersupply_done          = GetUnitCountDone('hhou')
set assemblyplants            = GetUnitCount('halt')
set assemblyplant_done        = GetUnitCountDone('halt')
set battlefactorys            = GetUnitCount('hbar')
set battlefactory_done        = GetUnitCountDone('hbar')
set techlabs                  = GetUnitCount('hlum')
set techlab_done              = GetUnitCountDone('hlum')
set apocalypsefactorys        = GetUnitCount('hgra')
set apocalypsefactory_done    = GetUnitCountDone('hgra')
set sensors                   = GetUnitCount('hwtw')
set sensor_done               = GetUnitCountDone('hwtw')
set airspires                 = GetUnitCount('hvlt')
set airspire_done             = GetUnitCountDone('hwtw')
set towers                    = GetUnitCount('nft1')
set tower_done                = GetUnitCountDone('nft1')
set towert2                   = GetUnitCount('nft2')
set towert2_done              = GetUnitCountDone('nft1')
set towert3                   = GetUnitCount('net1')
set towert3_done              = GetUnitCountDone('net1')
set towert4                   = GetUnitCount('ntt1')
set towert4_done              = GetUnitCountDone('ntt1')
set towert5                   = GetUnitCount('ndt1')
set towert5_done              = GetUnitCountDone('ntd1')
set buildings = mainfactory_done + advancedmainfactory_done + ubermainfactory_done + cybermainfactory_done + powermainfactory_done + powersupplys + assemblyplants + battlefactorys + techlabs + apocalypsefactorys + sensors + airspires + towers + towert3 + towert4 + towert5
//Update Resources              
set c_gold                    = GetGold()
set c_gold_owned              = GetGoldOwned()
set c_food_made               = GetFoodMade('htow') + powersupplys * GetFoodMade('hhou')
set c_food_used               = FoodUsed()
endfunction

//--------------------------------------------------------------------------------------------------
//  attack_sequence
//--------------------------------------------------------------------------------------------------
function attack_sequence takes nothing returns nothing
    local boolean needs_exp
    local boolean has_siege
    local boolean air_units
    local integer level

    if MeleeDifficulty() == MELEE_NEWBIE then
        call Sleep(240)
    endif

    call StaggerSleep(0,2)
    loop
        loop
            exitwhen not CaptainRetreating()
            call Sleep(2)
        endloop

            
        set has_siege        = level >= 40 or heavybots > 0 or demolisherbot_done > 0 or pyrocopters > 0
        set air_units        = seekerdrone_done > 0 or pyrocopters > 0

        call SingleMeleeAttack(false,has_siege,false,air_units)

        if MeleeDifficulty() == MELEE_NEWBIE then
            call Sleep(60)
        endif
    endloop
endfunction
//--------------------------------------------------------------------------------------------------
//  set_vars
//--------------------------------------------------------------------------------------------------
function set_vars takes nothing returns nothing
    loop
        call update_vars()
        call Sleep(1)
    endloop
endfunction
//--------------------------------------------------------------------------------------------------
//  do_upgrades
//--------------------------------------------------------------------------------------------------
function do_upgrades takes nothing returns nothing

    if mainfactory_done >= 1 and techlab_done >= 1 then
        call SetBuildUpgr( 1, 'Rhan' )
        call SetBuildUpgr( 1, 'Rhme' )
        call SetBuildUpgr( 1, 'Rhar' )
        call SetBuildUpgr( 1, 'Rhra' )
        call SetBuildUpgr( 1, 'Rhac' )      
    endif
     if advancedmainfactory_done >= 1 and techlab_done >= 1 then
        call SetBuildUpgr( 1, 'Rhan' )
        call SetBuildUpgr( 1, 'Rhme' )
        call SetBuildUpgr( 1, 'Rhar' )
        call SetBuildUpgr( 1, 'Rhra' )
        call SetBuildUpgr( 1, 'Rhde' )
        call SetBuildUpgr( 1, 'Rhac' )      
    endif
 if ubermainfactory_done >= 1 and techlab_done >= 1 then
        call SetBuildUpgr( 1, 'Rhan' )
        call SetBuildUpgr( 1, 'Rhme' )
        call SetBuildUpgr( 1, 'Rhar' )
        call SetBuildUpgr( 1, 'Rhra' )
        call SetBuildUpgr( 1, 'Rhde' )
        call SetBuildUpgr( 1, 'Rhpt' )
        call SetBuildUpgr( 1, 'Rhac' )          
    endif
     if cybermainfactory_done >= 1 and techlab_done >= 1 then
        call SetBuildUpgr( 1, 'Rhan' )
        call SetBuildUpgr( 1, 'Rhme' ) //Attack
        call SetBuildUpgr( 1, 'Rhar' ) //armor
        call SetBuildUpgr( 1, 'Rhra' ) //HP
        call SetBuildUpgr( 1, 'Rhde' )
        call SetBuildUpgr( 1, 'Rhpt' )
        call SetBuildUpgr( 1, 'Rhrt' )          
    endif
     if powermainfactory_done >= 1 and techlab_done >= 1 then
        call SetBuildUpgr( 1, 'Rhan' )
        call SetBuildUpgr( 1, 'Rhme' )
        call SetBuildUpgr( 1, 'Rhar' )
        call SetBuildUpgr( 1, 'Rhra' )
        call SetBuildUpgr( 1, 'Rhde' )
        call SetBuildUpgr( 1, 'Rhpt' )
        call SetBuildUpgr( 1, 'Rhac' ) 
        call SetBuildUpgr( 1, 'Rhhl' )
        call SetBuildUpgr( 1, 'Rhhl' )
        call SetBuildUpgr( 1, 'Rhhb' )             
    endif      
    if GetUpgradeLevel('Rhme') >= 20 and GetUpgradeLevel('Rhar') >= 20 and GetUpgradeLevel('Rhra') >= 20 then
    call SetBuildUpgr( 1, 'Rhla' )  
    endif
    if  sniperbots >= 1 or  artillerytanks >= 1 then 
     call SetBuildUpgr( 1, 'Rhfc' )
     endif  
endfunction
//--------------------------------------------------------------------------------------------------
//  build_sequence
//--------------------------------------------------------------------------------------------------
function build_sequence takes nothing returns nothing
    local boolean primary_melee
    local integer wisps

    call InitBuildArray()
    //Starting buildings
    
    if basic_opening then
        call SetBuildUnit(  1, 'htow'           )
        call SetBuildUnit(  1, 'hlum'           )
        call SetBuildUnit(  1, 'halt'           )
        call SetBuildUnit(  1, 'hhou'           )
        call SetBuildUnit(  1, hero_id          )
        call do_upgrades 
   [B] endif [I]Syntax Error[/I][/B]
    
    // Food
    if c_food_used + 7 > c_food_made then
        call SetBuildUnit( powersupply_done + 1, 'hhou' )
    endif
   // ReviveHeroes
   if battlefactory_done >= 1 or mainfactory_done >=1 or  advancedmainfactory_done >= 1 or ubermainfactory_done >= 1 or cybermainfactory_done >= 1 or powermainfactory_done >= 1  then

        if c_hero1_done >= 1 and MeleeDifficulty() != MELEE_NEWBIE then
            call SetBuildUnit( 1, hero_id2 )
        else
            call SetBuildUnit( 1, hero_id  )
        endif
    else
        call SetBuildUnit( 1, 'hlum' )
    endif

  
    //if we have enough gold then advance on the tech tree
    if c_gold > 1000 then  
    //First try to teir up.
        call SetBuildUnit(  1, 'hkee'           )  
        call SetBuildUnit(  1, 'hcas'           ) 
        call SetBuildUnit(  1, 'h00D'      )  
        call SetBuildUnit(  1, 'h00C'      )
        // next upgrade
        call do_upgrades()
        // and if you still have gold get buildings and mercs
        if  powermainfactory_done >= 1 then
        if apocalypsefactorys == 0 then
        call SetBuildUnit(  1, 'hgra'          )
        endif
        call SetBuildUnit(  1, 'h00H'     )
        call SetBuildUnit(  1, 'h00M'     )
        call SetBuildUnit(  1, 'hspt'          )
        call SetBuildUnit(  1, 'ugar'          )
        elseif  cybermainfactory_done >= 1 then
        if airspires == 0 then
        call SetBuildUnit(1, 'hvlt')
        endif
        call SetBuildUnit(  1, 'h00G'     )
        call SetBuildUnit(  1, 'h00J'     )
        call SetBuildUnit(  1, 'h00P'     )
        call SetBuildUnit(  1, 'ugar'          ) 
        elseif ubermainfactory_done >= 1 then
        call SetBuildUnit(  1, 'h008'     )
        call SetBuildUnit(  1, 'h00I'     )
        elseif advancedmainfactory_done >= 1 then
        if battlefactorys == 0 then
        call SetBuildUnit(  1, 'hbar'          )
        endif
        call SetBuildUnit(  2, 'h00N'     )
        call SetBuildUnit(  1, 'h00U'     )
  else
        call SetBuildUnit(  1, 'nft1'          )
        if towers >= 1 then
         call SetBuildUnit(  1, 'nft2'         )
         elseif towert2 >= 1 then
          call SetBuildUnit(  1, 'net1'        )
          elseif towert3 >= 1 then
           call SetBuildUnit(  1, 'ntt1'       )
           elseif  towert4 >= 1 then
            call SetBuildUnit(  1, 'ntd1'      )
            endif
            
            if assemblyplants == 0 then 
            call SetBuildUnit(1, 'halt')
            endif
            if battlefactorys == 0 then
            call SetBuildUnit(1, 'hbar')
            endif
            if techlabs == 0 then
            call SetBuildUnit(1, 'hlum')
            endif
            if sensors == 0 then
            call SetBuildUnit(1, 'hwtw')
            endif
            if airspires == 0 then 
            call SetBuildUnit(1, 'hvlt')
            endif
            if workerbots == 0 then 
            call SetBuildUnit(1, 'uaco')
            endif
            call do_upgrades
            
        [B]call SetBuildUnit(  1, 'otau'     )[I]Syntax Error[/I][/B]
        call SetBuildUnit(  1, 'ohun'     )
        call SetBuildUnit(  1, 'owyv'     )
        call SetBuildUpgr(  1, 'Rhss'     )
        call SetBuildUpgr(  1, 'Rhcd'     ) 
    endif
 endif   
endfunction
//--------------------------------------------------------------------------------------------------
//	main
//--------------------------------------------------------------------------------------------------
function main takes nothing returns nothing
    call PickMeleeHero(RACE_NIGHTELF)
    //call set_skills()
    
 [B]local boolean isNewbie = (MeleeDifficulty() == MELEE_NEWBIE) [I]Syntax Error[/I][/B]

    call InitAI()

    call SetMeleeAI()

    call SetDefendPlayer(true)
    call SetGroupsFlee(not isNewbie)
    call SetHeroesBuyItems(not isNewbie)
    call SetHeroesFlee(true)
    call SetHeroesTakeItems(true)
    call SetIgnoreInjured(true)
    call SetPeonsRepair(true)
    call SetSmartArtillery(not isNewbie)
    call SetTargetHeroes(not isNewbie)
    call SetUnitsFlee(not isNewbie)
    call SetWatchMegaTargets(true)

    call CreateCaptains()

    //call SetHeroLevels(heroes)

    call Sleep(0.1)
   // call StartThread(peons)
    call StartThread(attacks)
    
    //call StandardAI(function SkillArrays,, function attack_sequence)
    call StartThread(function set_vars)
    call PlayGame()
endfunction
 
N

no0by

Guest
In function main
Code:
    call PickMeleeHero(RACE_NIGHTELF)
    //call set_skills()
    local boolean isNewbie = (MeleeDifficulty() == MELEE_NEWBIE)

Locals need to be the first thing in a function if they are going to be used
Code:
    local boolean isNewbie = (MeleeDifficulty() == MELEE_NEWBIE) 
    call PickMeleeHero(RACE_NIGHTELF)
    //call set_skills()

So just move the local to the top.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top