Dirac
22710180
- Reaction score
- 147
Provides the UnitCreateIllusion function (takes unit whichUnit, boolexpr action)
Example usage
Will display effect "boom" everytime an illusion is created.
Yes, it uses trigger evaluations, that's just awful
Yes, it's very inaccurate, not my fault, most likely the editor's fault for not having this as a native.
Yes, the action function fired when an illusion is created must return a boolean, any way to fix this without creating leaks.
PLEASE feedback
JASS:
library Illusion initializer onInit
// external ObjectMerger w3a AIil UIEa anam "Illusion Create" atar 1 "notself" atat "" aart "" ahdu 1 0 adur 1 0 aran 1 100000
globals
private constant integer DUMMY=039;e000039;
private constant integer OFFSET=0x100000
private trigger array callback
public unit Get
endglobals
function UnitCreateIllusion takes unit whichUnit,boolexpr action returns nothing
local unit u=CreateUnit(GetOwningPlayer(whichUnit),DUMMY,GetUnitX(whichUnit),GetUnitY(whichUnit),0)
local integer id=GetHandleId(u)-OFFSET
set callback[id]=CreateTrigger()
call UnitAddAbility(u,039;UIEa039;)
call IssueTargetOrderById(u,852274,whichUnit)
call TriggerAddCondition(callback[id],action)
set u=null
endfunction
private function onCreate takes nothing returns boolean
local unit c=GetSummoningUnit()
local unit t=GetSummonedUnit()
local integer id
if GetUnitTypeId(c)==DUMMY then
set id=GetHandleId(c)-OFFSET
set Get=t
call TriggerEvaluate(callback[id])
call DestroyTrigger(callback[id])
endif
return false
endfunction
private function onInit takes nothing returns nothing
local trigger trig=CreateTrigger()
local integer i=0
call TriggerAddCondition(trig,Condition(function onCreate))
loop
call TriggerRegisterPlayerUnitEvent(trig,Player(i),EVENT_PLAYER_UNIT_SUMMON,null)
set i=i+1
exitwhen i==bj_MAX_PLAYER_SLOTS
endloop
set trig=null
endfunction
endlibrary
Example usage
JASS:
private function forIllusion takes nothing returns boolean
call DestroyEffect(AddSpecialEffect("boom",GetUnitX(Illusion_Get),GetUnitY(Illusion_Get))
return false
endfunction
private function create takes nothing returns nothing
call UnitCreateIllusion(someUnit,Filter(function forIllusion))
endfunction
Will display effect "boom" everytime an illusion is created.
Yes, it uses trigger evaluations, that's just awful
Yes, it's very inaccurate, not my fault, most likely the editor's fault for not having this as a native.
Yes, the action function fired when an illusion is created must return a boolean, any way to fix this without creating leaks.
PLEASE feedback