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?
Unrecognized character
syntax error
Undeclared variable
This is my first time making AI, what am I doing wrong?
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