diff --git a/Jobs/MICRO_HERO.eai b/Jobs/MICRO_HERO.eai index 76712f8db..24189145e 100644 --- a/Jobs/MICRO_HERO.eai +++ b/Jobs/MICRO_HERO.eai @@ -20,6 +20,79 @@ #ELSE +//========================================================================== +// (AMAI) GetDensities +//========================================================================== +function GetDensities takes location l, player p, real r returns nothing + local group g = CreateGroup() + local unit u = null + local real ur = 0 + local real xe = 0 + local real ye = 0 + local real xa = 0 + local real ya = 0 + local location ul = null + local location loc = null + local integer i = 0 + + set enemy_density = 0 + set ally_density = 0 + call GroupEnumUnitsInRangeOfLoc(g, l, r, null) + loop + set u = FirstOfGroup(g) + exitwhen u == null + if (ModuloInteger(i, 200) == 0) then + call TQSleep(0.1) + endif + if UnitAlive(u) then + set ul = GetUnitLoc(u) + set ur = 1 - (DistanceBetweenPoints(ul, l) / r) + set loc = GetMultipleLoc(ul, ur) + //if ur == 1 then + if IsPlayerEnemy(p, GetOwningPlayer(u)) then + set enemy_density = enemy_density + ur + set xe = xe + GetLocationX(loc) // Prevent loc exceeding map range + set ye = ye + GetLocationY(loc) + //set enemy_density_loc = GetSumLoc_dd(enemy_density_loc, GetMultipleLoc(ul, ur)) + elseif IsPlayerAlly(p, GetOwningPlayer(u)) then + set ally_density = ally_density + ur + set xa = xa + GetLocationX(loc) + set ya = ya + GetLocationY(loc) + //set ally_density_loc = GetSumLoc_dd(ally_density_loc, GetMultipleLoc(ul, ur)) + endif + call RemoveLocation(loc) + call RemoveLocation(ul) + endif + call GroupRemoveUnit(g, u) + set i = i + 1 + endloop + + if ally_density > 0 then + set xa = xa / ally_density + set ya = ya / ally_density + //set ally_density_loc = GetDivisionLoc_d(ally_density_loc, ally_density) + else + set xa = 0 + set ya = 0 + endif + call RemoveLocation(ally_density_loc) + set ally_density_loc = Location(xa,ya) + if enemy_density > 0 then + set xe = xe / enemy_density + set ye = ye / enemy_density + //set enemy_density_loc = GetDivisionLoc_d(enemy_density_loc, enemy_density) + else + set xe = 0 + set ye = 0 + endif + call RemoveLocation(enemy_density_loc) + set enemy_density_loc = Location(xe,ye) + call DestroyGroup(g) + set g = null + set ul = null + set loc = null +endfunction + function TeleportHome takes integer hn returns nothing // Team Game improvements Added by Strategy Master 12/03/05 local integer i = 0 diff --git a/common.eai b/common.eai index 36e88a642..3d6e6b66f 100644 --- a/common.eai +++ b/common.eai @@ -4914,79 +4914,6 @@ function TQSleep takes real time returns nothing call Sleep(time) endfunction -//========================================================================== -// (AMAI) GetDensities -//========================================================================== -function GetDensities takes location l, player p, real r returns nothing - local group g = CreateGroup() - local unit u = null - local real ur = 0 - local real xe = 0 - local real ye = 0 - local real xa = 0 - local real ya = 0 - local location ul = null - local location loc = null - local integer i = 0 - - set enemy_density = 0 - set ally_density = 0 - call GroupEnumUnitsInRangeOfLoc(g, l, r, null) - loop - set u = FirstOfGroup(g) - exitwhen u == null - if (ModuloInteger(i, 200) == 0) then - call TQSleep(0.1) - endif - if UnitAlive(u) then - set ul = GetUnitLoc(u) - set ur = 1 - (DistanceBetweenPoints(ul, l) / r) - set loc = GetMultipleLoc(ul, ur) - //if ur == 1 then - if IsPlayerEnemy(p, GetOwningPlayer(u)) then - set enemy_density = enemy_density + ur - set xe = xe + GetLocationX(loc) // Prevent loc exceeding map range - set ye = ye + GetLocationY(loc) - //set enemy_density_loc = GetSumLoc_dd(enemy_density_loc, GetMultipleLoc(ul, ur)) - elseif IsPlayerAlly(p, GetOwningPlayer(u)) then - set ally_density = ally_density + ur - set xa = xa + GetLocationX(loc) - set ya = ya + GetLocationY(loc) - //set ally_density_loc = GetSumLoc_dd(ally_density_loc, GetMultipleLoc(ul, ur)) - endif - call RemoveLocation(loc) - call RemoveLocation(ul) - endif - call GroupRemoveUnit(g, u) - set i = i + 1 - endloop - - if ally_density > 0 then - set xa = xa / ally_density - set ya = ya / ally_density - //set ally_density_loc = GetDivisionLoc_d(ally_density_loc, ally_density) - else - set xa = 0 - set ya = 0 - endif - call RemoveLocation(ally_density_loc) - set ally_density_loc = Location(xa,ya) - if enemy_density > 0 then - set xe = xe / enemy_density - set ye = ye / enemy_density - //set enemy_density_loc = GetDivisionLoc_d(enemy_density_loc, enemy_density) - else - set xe = 0 - set ye = 0 - endif - call RemoveLocation(enemy_density_loc) - set enemy_density_loc = Location(xe,ye) - call DestroyGroup(g) - set g = null - set ul = null - set loc = null -endfunction - //========================================================================== // (AMAI) Action List Utility functions //==========================================================================