Skip to content

Instantly share code, notes, and snippets.

@ammaraskar
Last active January 25, 2023 18:24
Show Gist options
  • Save ammaraskar/6bc17300bc68ac890983ddc3ed5eec56 to your computer and use it in GitHub Desktop.
Save ammaraskar/6bc17300bc68ac890983ddc3ed5eec56 to your computer and use it in GitHub Desktop.
set NeutralRect=Rect(3872.0,-3008.0,4928.0,-1952.0)
set NeutralRectSpawnLoc=Rect(4288.0,-2688.0,4544.0,-2400.0)
function SpawnNeutrals takes nothing returns boolean
local group g
local rect r1
local rect r2
if NoNuetrals == true then
return false
endif
set r1 = NeutralRect
set r2 = NeutralRectSpawnLoc
set g = GetNewGroup()
call GroupEnumUnitsInRect(g, r1, Condition(function AlwaysTrue))
if GroupHasNoUnits(g) then
call SpawnNeutral(GetRectCenterX(r2), GetRectCenterY(r2))
endif
...
endfunction
function GroupHasNoUnits takes group g returns boolean
call ForGroup(g, function RemoveDeadUnitsCallback)
return FirstOfGroup(g) == null
endfunction
function GetNewGroup takes nothing returns group
local integer i = lastGroup
loop exitwhen i == lastGroup-1
if groupUsed[i]==false then
set lastGroup = i+1
if lastGroup == 120 then
set lastGroup = 0
endif
set groupUsed[i] = true
return groupPool[i]
endif
set i = i+1
if i == 120 then
set i=0
endif
endloop
call ShowMessage(
I0100, 5.00, "|c00ff0303CRITICAL ERROR: FOUND NO AVAILABLE GROUPS|r")
call ShowMessage(
I0100, 5.00, "|c00ff0303Send this replay to IceFrog@gmail.com|r")
return CreateGroup()
endfunction
function SpawnNeutral takes real x, real y returns nothing
local integer whichNuetral = GetRandomInt(1,4)
if whichNuetral == 1 then
call SpawnJungleStalkerNuetral(x,y)
elseif whichNuetral == 2 then
call SpawnBlueDragonNuetral(x,y)
elseif whichNuetral == 3 then
...
elseif whichNuetral == 4 then
...
endif
endfunction
function SpawnJungleStalkerNuetral takes real x,real y returns nothing
'junglestalker
call SetUnitPosition(CreateUnit(OO0I,"njg1",x,y,0),x,y)
call SetUnitPosition(CreateUnit(OO0I,"njg1",x,y,0),x,y)
'elderjunglestalker
call SetUnitPosition(CreateUnit(OO0I,"njga",x,y,0),x,y)
endfunction
function SpawnBlueDragonNuetral takes real x,real y returns nothing
' bluedragonspawnoverseer
call SetUnitPosition(CreateUnit(OO0I,"nbdo",x,y,0),x,y)
call SetUnitPosition(CreateUnit(OO0I,"nbdo",x,y,0),x,y)
' bluedragonspawnsorceror
call SetUnitPosition(CreateUnit(OO0I,"nbds",x,y,0),x,y)
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment