- Joined
- Jan 1, 2011
- Messages
- 1,534
JASS:
library UnitSpawn initializer Init
globals
integer TillEnd = 0
unit array Spawners
endglobals
private function Spawner takes nothing returns nothing
local integer i = 0
loop
exitwhen i == 4
if GetUnitState(Spawners[i], UNIT_STATE_LIFE) >= 0 and TillEnd > 0 then
if GetRandomInt(0, 1) == 1 then
call IssuePointOrder(CreateUnit(Player(i), 'hfoo', GetUnitX(Spawners[i]), GetUnitY(Spawners[i]), 0), "attack", 0, 0)
else
call IssuePointOrder(CreateUnit(Player(i), 'hrif', GetUnitX(Spawners[i]), GetUnitY(Spawners[i]), 0), "attack", 0, 0)
endif
endif
set i = i + 1
endloop
endfunction
private function Enum takes nothing returns boolean
local unit u = GetFilterUnit()
local integer i = GetUnitTypeId(u)
if i == 'hfoo' or i == 'hrif' then
call SetUnitExploded(u, true)
call KillUnit(u)
endif
set u = null
return false
endfunction
private function Death takes nothing returns boolean
local group g
set TillEnd = TillEnd - 1
if TillEnd == 0 then
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Victory!")
set g = CreateGroup()
call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, function Enum)
call DestroyBoolExpr(function Enum)
call DestroyGroup(g)
set g = null
endif
return false
endfunction
private function Count takes nothing returns boolean
local unit u = GetTriggerUnit()
if GetPlayerId(GetOwningPlayer(u)) == PLAYER_NEUTRAL_AGGRESSIVE then
set TillEnd = TillEnd + 1
endif
set u = null
return false
endfunction
private function Init takes nothing returns nothing
local integer i = 20
local real a
local player p = Player(PLAYER_NEUTRAL_AGGRESSIVE)
local trigger t = CreateTrigger()
call TriggerRegisterPlayerUnitEvent(t, p, EVENT_PLAYER_UNIT_DEATH, null)
call TriggerAddCondition(t, function Death)
set t = CreateTrigger()
call TriggerRegisterEnterRectSimple(t, bj_mapInitialPlayableArea)
call TriggerAddCondition(t, function Count)
call TimerStart(CreateTimer(), 2.5, true, function Spawner)
loop
exitwhen i == 0
set i = i - 1
call CreateUnit(p, ChooseRandomCreep(GetRandomInt(1, 10)), 0, 0, 0)
endloop
loop
exitwhen i == 4
set a = (90 * (i + 1) + 45) * bj_DEGTORAD
set Spawners[i] = CreateUnit(Player(i), 'hbar', 3000 * Cos(a), 3000 * Sin(a), 270)
set i = i + 1
endloop
endfunction
endlibrary
//Code indented using The_Witcher's Script Language Aligner
//Download the newest version and report bugs at www.hiveworkshop.com
Attachments
Last edited: