globals
integer MaxWisps =13
unit Main =null
boolean T2Started =false
boolean T3Started =false
integer attackWave = 1
integer nextDelay = 0
integer awGold = 0
integer awWood = 0
// Conditions
boolean gCond_Ready_to_Upgrade1 = false
boolean gCond_Ready_to_Upgrade2 = false
boolean gCond_SchwacheCamps = false
boolean gCond_MittelCamps = false
boolean gCond_T1_Damageup = false
boolean BuildingsT2T3 = false
boolean gCond_ExeDefBauen = false
boolean gCond_Third_hero = false
boolean gCond_MittelCampsStaerker = false
boolean gCond_T1_DefenseUp = false
boolean gCond_ExeBauen = false
boolean gCond_Keine_Resourcen_Angriff = false
boolean AOLsStehen =false
boolean GegnerExe =false
boolean Hunthall =false
boolean T3Schritt2 =false
boolean T3 = false
endglobals
.
.
.
//***************************************************************************
//*
//* Attacking
//*
//***************************************************************************
//===========================================================================
// Returns true if the minimum forces for an attack exist
//===========================================================================
function HaveMinimumAttackers takes nothing returns boolean
local integer count
// Check for attack wave limit
if (attackWave > 1) then
return false
endif
// First Hero Only
if (GetUnitCountDone(hero_id) < 1) then
return false
endif
return true
endfunction
//===========================================================================
// Assigns units to attack based on the given attack group
//===========================================================================
function PrepareAttackGroup takes integer groupID returns nothing
local integer all
// Attack Group #1: Alle Einheiten
if (groupID == 1) then
set all = GetUnitCountDone( hero_id )
call AddAttackUnit( all, all, hero_id )
set all = GetUnitCountDone( hero_id2 )
call AddAttackUnit( all, all, hero_id2 )
set all = GetUnitCountDone( hero_id3 )
call AddAttackUnit( all, all, hero_id3 )
set all = GetUnitCountDone( 'earc' )
call AddAttackUnit( all, all, 'earc' )
set all = GetUnitCountDone( 'ebal' )
call AddAttackUnit( all, all, 'ebal' )
set all = GetUnitCountDone( 'echm' )
call AddAttackUnit( all, all, 'echm' )
set all = GetUnitCountDone( 'edoc' )
call AddAttackUnit( all, all, 'edoc' )
set all = GetUnitCountDone( 'edot' )
call AddAttackUnit( all, all, 'edot' )
set all = GetUnitCountDone( 'edry' )
call AddAttackUnit( all, all, 'edry' )
set all = GetUnitCountDone( 'efdr' )
call AddAttackUnit( all, all, 'efdr' )
set all = GetUnitCountDone( 'ehip' )
call AddAttackUnit( all, all, 'ehip' )
set all = GetUnitCountDone( 'ehpr' )
call AddAttackUnit( all, all, 'ehpr' )
set all = GetUnitCountDone( 'emtg' )
call AddAttackUnit( all, all, 'emtg' )
set all = GetUnitCountDone( 'esen' )
call AddAttackUnit( all, all, 'esen' )
endif
endfunction
//===========================================================================
// Prepares an attack group based on the current attack wave
//===========================================================================
function PrepareForces takes nothing returns nothing
if (attackWave == 1) then
call PrepareAttackGroup( 1 )
endif
endfunction
//===========================================================================
// Sleep delays for each attack wave
//===========================================================================
function AttackWaveDelay takes integer inWave returns nothing
if (inWave < nextDelay) then
return
endif
set nextDelay = inWave + 1
endfunction
//===========================================================================
// Advances attack wave counter
//===========================================================================
function AttackWaveUpdate takes nothing returns nothing
call AttackWaveDelay( attackWave )
set attackWave = attackWave + 1
if (attackWave > 1) then
set attackWave = 1
set nextDelay = attackWave + 1
endif
endfunction
//===========================================================================
// Basic attack functionality
//===========================================================================
function AttackTarget takes unit target, boolean addAlliance returns nothing
if (target == null) then
return
endif
if (addAlliance) then
call SetAllianceTarget( target )
endif
call FormGroup( 3, true )
call AttackMoveKillA( target )
if (not addAlliance) then
call SetAllianceTarget( null )
endif
endfunction
//===========================================================================
// Initiates an attack based on target priorities
//===========================================================================
function LaunchAttack takes nothing returns nothing
local unit target = null
local boolean setAlly = true
// Don't launch any attack while town is threatened
if (TownThreatened()) then
call Sleep( 2 )
return
endif
// Target Priority #1
if (GegnerExe) then
set target = GetEnemyExpansion()
endif
if (gCond_ExeBauen) then
if (target == null) then
set target = GetExpansionFoe()
if (target != null) then
set take_exp = false
endif
endif
// Target Priority #5
endif
// Target Priority #8
if (gCond_MittelCamps) then
if (target == null) then
set target = GetCreepCamp( 6, 14, false )
endif
// Target Priority #9
endif
// Target Priority #2
if (gCond_Keine_Resourcen_Angriff) then
if (target == null) then
set target = GetAllianceTarget()
if (target != null) then
set setAlly = false
endif
endif
// Target Priority #3
if (target == null) then
set target = GetMegaTarget()
endif
// Target Priority #4
endif
if (gCond_MittelCampsStaerker) then
if (target == null) then
set target = GetCreepCamp( 1, 16, false )
endif
// Target Priority #6
endif
if (target == null) then
set target = GetAllianceTarget()
if (target != null) then
set setAlly = false
endif
endif
// Target Priority #7
if (target == null) then
set target = GetMegaTarget()
endif
if (gCond_SchwacheCamps) then
if (target == null) then
set target = GetCreepCamp( 0, 11, false )
endif
// Target Priority #10
endif
if (target == null) then
set target = GetCreepCamp( 14, 100, true )
endif
// Target Priority #11
if (target == null) then
set target = GetEnemyExpansion()
if (target == null) then
call StartGetEnemyBase()
loop
exitwhen (not WaitGetEnemyBase())
call SuicideSleep( 1 )
endloop
set target = GetEnemyBase()
endif
endif
// Attack the target and increment attack wave
if (target != null) then
call AttackTarget( target, setAlly )
call AttackWaveUpdate( )
else
// If no target was found, sleep a bit before trying again
call Sleep( 5 )
endif
endfunction
//===========================================================================
// Determines all attacking assignments
//===========================================================================
function AttackAssignment takes nothing returns nothing
call StaggerSleep( 0, 2 )
if (attackWave == 1) then
call AttackWaveDelay( 0 )
endif
loop
loop
call UpdateConditions( )
exitwhen (HaveMinimumAttackers() and not CaptainRetreating())
call Sleep( 2 )
endloop
call RemoveInjuries( )
call ResetAttackUnits( )
call PrepareForces( )
call LaunchAttack( )
endloop
endfunction