I don't know where the bug is...it could be a syntax error or something It's been a long time since I worked with JASS...
JASS:
globals
constant integer HUMAN_TRANSPORT_C = 'Hbot'
constant integer HUMAN_FRIGATE_C = 'Hdes'
constant integer HUMAN_BATTLESHIP_C = 'Hbsh'
boolean canAttack = false
boolean hasNaval = false
endglobals
//--------------------------------------------------------------------------------------------------
// init_vars
//--------------------------------------------------------------------------------------------------
function init_vars takes nothing returns nothing
set hasNaval = (GetUnitCountDone(HUMAN_FRIGATE_C) >= 3) + (GetUnitCountDone(HUMAN_BATTLESHIP_C) >= 1)
set canAttack = (GetUnitCountDone(FOOTMAN) >= 5 + (GetUnitCountDone(RIFLEMAN) >= 4 + (GetUnitCountDone(PRIEST) >= 3 + (GetUnitCountDone(GRYPHON) >= 3 + (GetUnitCountDone(HUMAN_TRANSPORT_C) > 0
endfunction
//--------------------------------------------------------------------------------------------------
// melee_settings
//--------------------------------------------------------------------------------------------------
function melee_settings takes nothing returns nothing
local boolean isNewbie = (MeleeDifficulty() == MELEE_NEWBIE)
call SetMeleeAI()
call SetDefendPlayer(true)
call SetGroupsFlee(not isNewbie)
call SetHeroesBuyItems(true)
call SetHeroesFlee(true)
call SetHeroesTakeItems(true)
call SetIgnoreInjured(true)
call SetPeonsRepair(true)
call SetSmartArtillery(not isNewbie)
call SetTargetHeroes(false) // this should never be used cause it makes the AI weaker...
call SetUnitsFlee(not isNewbie)
call SetWatchMegaTargets(true)
endfunction
//--------------------------------------------------------------------------------------------------
// attack_sequence_Q
//--------------------------------------------------------------------------------------------------
function attack_sequence_Q takes nothing returns nothing
local unit target
call SetMeleeGroup(FOOTMAN)
call SetMeleeGroup(RIFLEMAN)
call SetMeleeGroup(PRIEST)
call SetMeleeGroup(GRYPHON)
call SetMeleeGroup(HUMAN_TRANSPORT_C)
call SetMeleeGroup(HUMAN_FRIGATE_C)
call SetMeleeGroup(HUMAN_BATTLESHIP_C)
if (canAttack + hasNaval) then
set target = GetEnemyBase()
call FormGroup(3, true)
call AttackMoveKillA( target ) // attack until target is dead
endif
endfunction
//--------------------------------------------------------------------------------------------------
// attack_sequence
//--------------------------------------------------------------------------------------------------
function attack_sequence takes nothing returns nothing
loop
call attack_sequence_Q()
call Sleep(2)
endloop
endfunction
//--------------------------------------------------------------------------------------------------
// build_sequence_Q
//--------------------------------------------------------------------------------------------------
function build_sequence_Q takes nothing returns nothing
if GetUnitCountDone(FOOTMAN) < 6 then
call SetBuildUnit(1, FOOTMAN) // Build footmen...
endif
if GetUnitCountDone(RIFLEMAN) < 4 then // Build riflemen...
call SetBuildUnit(1, RIFLEMAN)
endif
if GetUnitCountDone(PRIEST) < 3 then // Build priests...
call SetBuildUnit(1, PRIEST)
endif
if GetUnitCountDone(GRYPHON) < 5 then // Build gryphon riders...
call SetBuildUnit(1, GRYPHON)
endif
// Build Ships
if GetUnitCountDone(HUMAN_TRANSPORT_C) < 1 then
call SetBuildUnit(1, HUMAN_TRANSPORT_C)
endif
if GetUnitCountDone(HUMAN_FRIGATE_C) < 2 then
call SetBuildUnit(1, HUMAN_FRIGATE_C)
endif
if GetUnitCountDone(HUMAN_BATTLESHIP_C) < 1 then
call SetBuildUnit(1, HUMAN_BATTLESHIP_C)
endif
if GetUnitCountDone(HUMAN_FRIGATE_C) < 5 then
call SetBuildUnit(1, HUMAN_FRIGATE_C)
endif
if GetUnitCountDone(HUMAN_BATTLESHIP_C) < 4 then
call SetBuildUnit(1, HUMAN_BATTLESHIP_C)
endif
endfunction
//--------------------------------------------------------------------------------------------------
// build_sequence
//--------------------------------------------------------------------------------------------------
function build_sequence takes nothing returns nothing
loop
call build_sequence_Q()
call Sleep(2)
endloop
endfunction
//--------------------------------------------------------------------------------------------------
// loop_vars
//--------------------------------------------------------------------------------------------------
function loop_vars takes nothing returns nothing
loop
call init_vars()
call Sleep(2)
endloop
endfunction
//--------------------------------------------------------------------------------------------------
// MAIN
//--------------------------------------------------------------------------------------------------
function main takes nothing returns nothing
call InitAI()
call melee_settings() // Set the melee AI settings...
call CreateCaptains()
call SetPlayerName(Player(GetAiPlayer()), "Human AI") // Give the player a name...
// Start the main loops...
call StartThread( function loop_vars )
call StartThread( function attack_sequence )
call StartThread( function build_sequence )
call PlayGame()
endfunction