- Joined
- Apr 17, 2017
- Messages
- 316
JASS:
scope UnitSpawn initializer init
globals
private timer t
private group neutralGroup
private group playerGroup
private integer counter = 20
endglobals
private function callback takes nothing returns nothing
local real x
local real y
local real ang
local real dist = 100.00
local integer array unitID
local integer attackOrder = 851983
local unit tempUnit = GetEnumUnit()
local unit tempUnit2
if tempunit == null then
call DestroyGroup(playerGroup)
endif
set unitID[1] = 'hfoo'
set unitID[2] = 'hrif'
set x = GetUnitX(tempUnit)
set y = GetUnitY(tempUnit)
set ang = Atan2(y,x)+bj_PI
set x = x+dist*Cos(ang)
set y = y+dist*Sin(ang)
set tempUnit2 = CreateUnit(GetOwningPlayer(tempUnit), unitID[GetRandomInt(1,2)], x, y,ang)
call IssuePointOrderById(tempUnit2, attackOrder, 0, 0)
set tempUnit2 = null
set tempUnit = null
endfunction
private function onloop takes nothing returns nothing
call ForGroup(playerGroup, function callback)
endfunction
private function conditions takes nothing returns boolean
local group tempGroup = CreateGroup()
local unit tempUnit
if IsUnitInGroup(GetTriggerUnit(), playerGroup) == true then
call GroupRemoveUnit(playerGroup, GetTriggerUnit())
elseif IsUnitInGroup(GetTriggerUnit(), neutralGroup) == true then
call GroupRemoveUnit(neutralGroup, GetTriggerUnit())
set counter = counter - 1
if counter == 0 then
call GroupEnumUnitsInRange(tempGroup, 0, 0, 5000, null)
loop
set tempUnit = FirstOfGroup(tempGroup)
exitwhen tempUnit == null
call SetUnitExploded(tempUnit, true)
call KillUnit(tempUnit)
call GroupRemoveUnit(tempGroup, tempUnit)
set tempUnit = null
endloop
call BJDebugMsg("You won!")
call PauseTimer(t)
call DestroyTimer(t)
endif
endif
call DestroyGroup(tempGroup)
set tempGroup = null
set tempUnit = null
return false
endfunction
private function init takes nothing returns nothing
local trigger tr = CreateTrigger()
local integer i = 0
local integer n = 0
local unit temp
local unit temp2
local real dist = 3000.00
local real ang
local real x
local real y
set playerGroup = CreateGroup()
set neutralGroup = CreateGroup()
set t = CreateTimer()
loop
exitwhen i > 20
set temp = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), ChooseRandomCreep(GetRandomInt(1,10)), 0, 0, 0)
call GroupAddUnit(neutralGroup, temp)
set temp = null
set i = i+1
endloop
set i = 0
set n = 0
loop
exitwhen i > 3
loop
exitwhen n > 3
call SetPlayerAlliance(Player(i), Player(n), ALLIANCE_PASSIVE, true)
call SetPlayerAlliance(Player(i), Player(n), ALLIANCE_SHARED_VISION, true)
set n = n+1
endloop
set n = 0
set i = i+1
endloop
set i = 0
loop
exitwhen i > 3
set ang = (45+(90*i))*bj_PI/180
set x = 0+dist*Cos(ang)
set y = 0+dist*Sin(ang)
set temp2 = CreateUnit(Player(i), 'hbar', x, y, (ang*180/bj_PI)+180)
call GroupAddUnit(playerGroup, temp2)
set temp2 = null
set i = i+1
endloop
call TriggerRegisterAnyUnitEventBJ(tr, EVENT_PLAYER_UNIT_DEATH)
call TriggerAddCondition(tr, Condition(function conditions))
call TimerStart(t, 2.50, true, function onloop)
set tr = null
endfunction
endscope