I found a system for a custom birth animation for structures in an old thread here on the Hive, but while it seems to work fine in the test map, it's broken when I import it. Jasshelper gives me the error "cannot assign a struct array's index" and picks this line:
Here's the entire system:
JASS:
set Dummy[id] = CreateUnit(GetTriggerPlayer(), udg_Dummy, GetUnitX(u), GetUnitY(u), 0.00)
Here's the entire system:
JASS:
library DemonBirth initializer Init
globals
unit array Dummy
endglobals
private function Create takes nothing returns boolean
local unit u = GetTriggerUnit()
local integer id
local integer index = 0
if GetUnitAbilityLevel(u, udg_Ability) > 0 then
set id = GetUnitUserData(u)
set Dummy[id] = CreateUnit(GetTriggerPlayer(), udg_Dummy, GetUnitX(u), GetUnitY(u), 0.00)
loop
exitwhen index > udg_Array_Size
if GetUnitTypeId(u) == udg_Building[index] then
call SetUnitTimeScale(Dummy[id], udg_Animation_Length / udg_Time[index])
endif
set index = index + 1
endloop
call SetUnitVertexColor(u, 0, 0, 0, 0)
endif
set u = null
return false
endfunction
private function End takes nothing returns boolean
local unit u = GetTriggerUnit()
local integer id
if GetUnitAbilityLevel(u, udg_Ability) > 0 then
set id = GetUnitUserData(u)
call RemoveUnit(Dummy[id])
set Dummy[id] = null
call SetUnitVertexColor(u, 255, 255, 255, 255)
endif
set u = null
return false
endfunction
private function Death takes nothing returns boolean
local unit u = GetTriggerUnit()
local integer id
if GetUnitAbilityLevel(u, udg_Ability) > 0 then
set id = GetUnitUserData(u)
if Dummy[id] != null then
call SetUnitVertexColor(Dummy[id], 0, 0, 0, 0)
call RemoveUnit(Dummy[id])
endif
endif
set u = null
return false
endfunction
private function Init takes nothing returns nothing
local trigger t1 = CreateTrigger()
local trigger t2 = CreateTrigger()
local trigger t3 = CreateTrigger()
local integer index = 0
loop
call TriggerRegisterPlayerUnitEvent(t1, Player(index), EVENT_PLAYER_UNIT_CONSTRUCT_START, null)
call TriggerRegisterPlayerUnitEvent(t2, Player(index), EVENT_PLAYER_UNIT_CONSTRUCT_FINISH, null)
call TriggerRegisterPlayerUnitEvent(t3, Player(index), EVENT_PLAYER_UNIT_DEATH, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition(t1, function Create)
call TriggerAddCondition(t2, function End)
call TriggerAddCondition(t3, function Death)
set t1 = null
set t2 = null
set t3 = null
endfunction
endlibrary