library InvulnerabilityCheck initializer Init
globals
private unit InvulnerabilityChecker //unit we'll use to test targets
endglobals
private function Init takes nothing returns nothing //create our checking unit
set InvulnerabilityChecker = CreateUnit(Player(12), 'hpea', 0, 0, 0)
call ShowUnit(InvulnerabilityChecker, false)
endfunction
function IsUnitInvulnerable takes unit u returns boolean
if (GetOwningPlayer(u) == Player(15)) then //for neutral passive compatibility
call SetPlayerAlliance( Player(12), Player(15), ALLIANCE_PASSIVE, false)
endif
call IssueTargetOrder(InvulnerabilityChecker, "smart", u)
if (GetUnitCurrentOrder(InvulnerabilityChecker) == 851971) then
call IssueImmediateOrder(InvulnerabilityChecker, "stop" )
if (GetOwningPlayer(u) == Player(15)) then
call SetPlayerAlliance( Player(12), Player(15), ALLIANCE_PASSIVE, true)
endif
return false
else
call IssueImmediateOrder(InvulnerabilityChecker, "stop" )
if (GetOwningPlayer(u) == Player(15)) then
call SetPlayerAlliance( Player(12), Player(15), ALLIANCE_PASSIVE, true)
endif
return true
endif
endfunction
endlibrary