scope killForPlayer initializer i
globals
private constant integer KINGID='hfoo' //Change this to your king type unit
private group grp=CreateGroup()
private player tempPlayer
endglobals
private function f2 takes nothing returns boolean
if GetOwningPlayer(GetFilterUnit())==tempPlayer then
call KillUnit(GetFilterUnit())
endif
return false
endfunction
private function f takes nothing returns boolean
if GetUnitTypeId(GetFilterUnit())==KINGID then
set tempPlayer=GetOwningPlayer(GetFilterUnit())
call GroupEnumUnitsInRect(grp,bj_mapInitialPlayableArea,Filter(function f2))
endif
return false
endfunction
private function i takes nothing returns nothing
local trigger t=CreateTrigger()
local integer index=0
loop
exitwhen index>11
call TriggerRegisterPlayerUnitEvent(t,Player(index),EVENT_PLAYER_UNIT_DEATH,Filter(function f))
set index=index+1
endloop
endfunction
endscope