- Joined
- Oct 12, 2011
- Messages
- 3,449
JASS:
library IsUnitCorpse initializer onInit
/*
Simple library used to check whether a unit has become a corpse or not.
How to use:
- You must have a dummy caster at your OE
- Copy this trigger into your map
- Save your map, then re-open it
*/
//! external ObjectMerger w3a Amel IRAA anam "CORPSE_CHECKER" abpy 0 auby 0 aart "" auar "" arac "other" ahky "" auhk "" aran 1 0 atar 1 "air,dead,ground,player" atp1 1 "" aub1 1 "" aut1 1 "" auu1 1 ""
/*
- Delete or comment out that one line above and save again.
*/
globals
private constant integer DUMMY_ID = 'h000'
private constant integer SPELL_ID = 'IRAA'
private constant integer CONTAINER_ID = 'Sch2'
private constant integer ORDER_ID = 852053
private constant player UNUSED_PLAYER = Player(15)
private unit Dummy
endglobals
native UnitAlive takes unit id returns boolean
function IsUnitCorpse takes unit u returns boolean
local boolean b
local player p
if not UnitAlive(u) then
set p = GetOwningPlayer(u)
call SetUnitOwner(u, UNUSED_PLAYER, false)
call SetUnitX(Dummy, GetUnitX(u) + 100)
call SetUnitY(Dummy, GetUnitY(u) + 100)
call IssueImmediateOrderById(Dummy, ORDER_ID)
set b = GetUnitCurrentOrder(Dummy) == ORDER_ID
call SetUnitPosition(Dummy, 1234567890, 1234567890)
call SetUnitOwner(u, p, false)
else
return false
endif
return b
endfunction
private function onInit takes nothing returns nothing
set Dummy = CreateUnit(UNUSED_PLAYER, DUMMY_ID, 1234567890, 1234567890, 0)
call UnitAddAbility(Dummy, SPELL_ID)
call UnitAddAbility(Dummy, CONTAINER_ID)
endfunction
endlibrary
Last edited: