function Trig_Trigger_Conditions takes nothing returns boolean
if ( not ( IsUnitType(GetAttackedUnitBJ(), UNIT_TYPE_TOWNHALL) == true ) ) then
return false
endif
if ( not ( R2I(GetUnitStateSwap(UNIT_STATE_LIFE, GetAttackedUnitBJ())) <= 500 ) ) then
return false
endif
return true
endfunction
function Trig_Trigger_Actions takes nothing returns nothing
call SetUnitOwner( GetAttackedUnitBJ(), GetOwningPlayer(GetAttacker()), true )
call SetUnitLifePercentBJ( GetAttackedUnitBJ(), 100 )
endfunction
//===========================================================================
function InitTrig_Trigger takes nothing returns nothing
set gg_trg_Trigger = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Trigger, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddCondition( gg_trg_Trigger, Condition( function Trig_Trigger_Conditions ) )
call TriggerAddAction( gg_trg_Trigger, function Trig_Trigger_Actions )
endfunction
Just copy and paste that into a open trigger or something. This is the Gui ver turned into jass and is therefore compatable with roc. im not sure if this is leakless or not.