scope Test initializer onInit
globals
private constant real MIN_OFFSET = 100.0
private constant real MAX_OFFSET = 250.0
endglobals
private function offsetTest takes nothing returns boolean
local real dist = GetRandomReal(MIN_OFFSET, MAX_OFFSET)
local real ang = GetRandomReal(1.0, 360.0)
local real x = GetUnitX(GetTriggerUnit())
local real y = GetUnitY(GetTriggerUnit())
local real x2 = x + dist * Cos(Deg2Rad(ang))
local real y2 = y + dist * Sin(Deg2Rad(ang))
// More actions...such as:
call CreateItem('bspd', x2, y2)
return false
endfunction
private function onInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerAddCondition(t, Condition(function offsetTest))
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH)
set t = null
endfunction
endscope